···7474 README generated by the `gleam new` command.
7575 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
76767777-- The build tool will now refuse to publish any package that has no README.
7777+- The build tool will now refuse to publish any package that has no README, or
7878+ an empty README.
7879 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
79808081### Language server
···321321 #[error("The modules {unfinished:?} are empty and so cannot be published")]
322322 CannotPublishEmptyModules { unfinished: Vec<EcoString> },
323323324324- #[error("Publishing a package with the default README is not permitted")]
325325- CannotPublishWithDefaultReadme,
326326-327327- #[error("Publishing a package with no README is not permitted")]
328328- CannotPublishWithNoReadme,
324324+ #[error("Publishing packages with an invalid README is not permitted")]
325325+ CannotPublishWithInvalidReadme { reason: InvalidReadmeReason },
329326330327 #[error("Publishing packages to reserve names is not permitted")]
331328 HexPackageSquatting,
···359356360357 #[error("Cannot add a package with the same name as a dependency")]
361358 CannotAddSelfAsDependency { name: EcoString },
359359+}
360360+361361+#[derive(Debug, Eq, PartialEq, Clone, Copy)]
362362+pub enum InvalidReadmeReason {
363363+ Missing,
364364+ Empty,
365365+ Default,
362366}
363367364368// A wrapper that ignores the inner value for equality:
···877881 }]
878882 }
879883880880- Error::CannotPublishWithDefaultReadme => {
884884+ Error::CannotPublishWithInvalidReadme {
885885+ reason: InvalidReadmeReason::Default,
886886+ } => {
881887 let text =
882888 "You appear to be attempting to publish a package with the default README
883889generated by the `gleam new` command. That is meant as a placeholder and a
···896902 }]
897903 }
898904899899- Error::CannotPublishWithNoReadme => {
905905+ Error::CannotPublishWithInvalidReadme {
906906+ reason: InvalidReadmeReason::Missing,
907907+ } => {
900908 let text = "You appear to be attempting to publish a package with no README.
901909All published packages should have one.
902910"
···908916 level: Level::Error,
909917 location: None,
910918 hint: Some("Add a README to your project before publishing.".into()),
919919+ }]
920920+ }
921921+922922+ Error::CannotPublishWithInvalidReadme {
923923+ reason: InvalidReadmeReason::Empty,
924924+ } => {
925925+ let text = "You appear to be attempting to publish a package with an empty README.
926926+All published packages should have a non empty README.
927927+"
928928+ .into();
929929+930930+ vec![Diagnostic {
931931+ title: "Cannot publish with empty README".into(),
932932+ text,
933933+ level: Level::Error,
934934+ location: None,
935935+ hint: Some(
936936+ "Update your project's README to describe it before publishing".into(),
937937+ ),
911938 }]
912939 }
913940
···11+# This file was generated by Gleam
22+# You typically do not need to edit this file
33+44+packages = [
55+ { name = "gleam_stdlib", version = "0.62.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "0080706D3A5A9A36C40C68481D1D231D243AF602E6D2A2BE67BA8F8F4DFF45EC" },
66+]
77+88+[requirements]
99+gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
···11+import gleam/io
22+33+/// This tests that a project with an empty readme doesn't get published.
44+///
55+pub fn main() -> Nil {
66+ greeting()
77+ first_line()
88+ second_line()
99+}
1010+1111+fn greeting() {
1212+ io.println("Hello from empty_readme!")
1313+}
1414+1515+fn first_line() {
1616+ io.println("Here we have some additional code so that this is not mistaken")
1717+}
1818+1919+fn second_line() {
2020+ io.println("for a default main project, that would be rejected as well!")
2121+}
···11+#!/bin/sh
22+33+set -eu
44+55+GLEAM_COMMAND=${GLEAM_COMMAND:-"cargo run --quiet --"}
66+77+g() {
88+ echo "Running: $GLEAM_COMMAND $@"
99+ $GLEAM_COMMAND "$@"
1010+}
1111+1212+echo Resetting the build directory to get to a known state
1313+rm -fr build
1414+1515+echo Running publish should not publish anything
1616+if yes "n" | g publish; then
1717+ echo "Expected publish to fail, but it succeeded"
1818+ exit 1
1919+fi
2020+2121+echo
2222+echo Success! 💖
2323+echo