Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Make gleam.toml consistent

+99 -62
+5
CHANGELOG.md
··· 26 26 friendlier. 27 27 ([Ameen Radwan](https://github.com/Acepie)) 28 28 29 + - The `gleam.toml` format is now consistent. The two sausage-case fields 30 + (`dev-dependencies` and `tag-prefix`) have been replaced by snake_case 31 + versions. Files using the old names will continue to work. 32 + ([Louis Pilfold](https://github.com/lpil)) 33 + 29 34 ### Language server 30 35 31 36 - The language server now allows extracting the start of a pipeline into a
+1 -1
changelog/v1.1.md
··· 1206 1206 - The deprecated rebar3 integration has been removed. 1207 1207 - Fixed a bug where `gleam format` would output an unwanted newline at the top 1208 1208 of documents that only contain simple `//` comments. 1209 - - No longer add `dev-dependencies` to generated `.app` Erlang files unless 1209 + - No longer add `dev_dependencies` to generated `.app` Erlang files unless 1210 1210 we're compiling the root project (#1569). 1211 1211 - Fixed a bug where the formatter could render a syntax error with lists on long 1212 1212 unbreakable lines.
+1 -1
changelog/v1.13.md
··· 341 341 ownership of existing packages. 342 342 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 343 343 344 - - `gleam add` now adds `dependencies` and `dev-dependencies` as tables instead 344 + - `gleam add` now adds `dependencies` and `dev_dependencies` as tables instead 345 345 of inline tables if they are missing. 346 346 ([Andrey Kozhev](https://github.com/ankddev)) 347 347
+12 -3
compiler-cli/src/add.rs
··· 70 70 #[allow(clippy::indexing_slicing)] 71 71 { 72 72 if dev { 73 - if !gleam_toml.as_table().contains_key("dev-dependencies") { 74 - gleam_toml["dev-dependencies"] = toml_edit::table(); 73 + let canonical_name = "dev_dependencies"; 74 + let deprecated_name = "dev-dependencies"; 75 + let has_canonical = gleam_toml.as_table().contains_key(canonical_name); 76 + let has_deprecated = gleam_toml.as_table().contains_key(deprecated_name); 77 + if !has_canonical && !has_deprecated { 78 + gleam_toml["dev_dependencies"] = toml_edit::table(); 75 79 } 76 - gleam_toml["dev-dependencies"][&added_package] = toml_edit::value(range.clone()); 80 + let name = if has_deprecated { 81 + deprecated_name 82 + } else { 83 + canonical_name 84 + }; 85 + gleam_toml[name][&added_package] = toml_edit::value(range.clone()); 77 86 } else { 78 87 if !gleam_toml.as_table().contains_key("dependencies") { 79 88 gleam_toml["dependencies"] = toml_edit::table();
+1 -1
compiler-cli/src/new.rs
··· 166 166 [dependencies] 167 167 gleam_stdlib = "{GLEAM_STDLIB_REQUIREMENT}" 168 168 169 - [dev-dependencies] 169 + [dev_dependencies] 170 170 gleeunit = "{GLEEUNIT_REQUIREMENT}" 171 171 "#, 172 172 )),
+11 -9
compiler-cli/src/remove.rs
··· 21 21 // Remove the specified dependencies 22 22 let mut packages_not_exist = vec![]; 23 23 for package_to_remove in packages.iter() { 24 - #[allow(clippy::indexing_slicing)] 25 - let maybe_removed_item = toml["dependencies"] 26 - .as_table_like_mut() 27 - .and_then(|deps| deps.remove(package_to_remove)); 24 + let remove = |toml: &mut toml_edit::DocumentMut, name| { 25 + #[allow(clippy::indexing_slicing)] 26 + toml[name] 27 + .as_table_like_mut() 28 + .and_then(|deps| deps.remove(package_to_remove)) 29 + }; 28 30 29 - #[allow(clippy::indexing_slicing)] 30 - let maybe_removed_dev_item = toml["dev-dependencies"] 31 - .as_table_like_mut() 32 - .and_then(|deps| deps.remove(package_to_remove)); 31 + // dev-dependencies is the old deprecated name for dev_dependencies 32 + let removed = remove(&mut toml, "dependencies") 33 + .or_else(|| remove(&mut toml, "dev_dependencies")) 34 + .or_else(|| remove(&mut toml, "dev-dependencies")); 33 35 34 - if maybe_removed_item.or(maybe_removed_dev_item).is_none() { 36 + if removed.is_none() { 35 37 packages_not_exist.push(package_to_remove.into()); 36 38 } 37 39 }
+1 -1
compiler-cli/test/hello_world/gleam.toml
··· 4 4 [dependencies] 5 5 gleam_stdlib = "~> 0.28" 6 6 7 - [dev-dependencies] 7 + [dev_dependencies] 8 8 gleeunit = "~> 0.10"
+33 -12
compiler-core/src/config.rs
··· 165 165 pub documentation: Docs, 166 166 #[serde(default, serialize_with = "ordered_map")] 167 167 pub dependencies: Dependencies, 168 - #[serde(default, rename = "dev-dependencies", serialize_with = "ordered_map")] 168 + #[serde(default, alias = "dev-dependencies", serialize_with = "ordered_map")] 169 169 pub dev_dependencies: Dependencies, 170 170 #[serde(default)] 171 171 pub repository: Option<Repository>, ··· 216 216 } 217 217 218 218 // Return all the dependencies listed in the configuration, that is, all the 219 - // direct dependencies, both in the `dependencies` and `dev-dependencies`. 219 + // direct dependencies, both in the `dependencies` and `dev_dependencies`. 220 220 pub fn all_direct_dependencies(&self) -> Result<Dependencies> { 221 221 let mut deps = 222 222 HashMap::with_capacity(self.dependencies.len() + self.dev_dependencies.len()); ··· 839 839 user: String, 840 840 repo: String, 841 841 path: Option<String>, 842 - #[serde(rename = "tag-prefix")] 842 + #[serde(alias = "tag-prefix")] 843 843 tag_prefix: Option<String>, 844 844 }, 845 845 #[serde(rename = "gitlab")] ··· 847 847 user: String, 848 848 repo: String, 849 849 path: Option<String>, 850 - #[serde(rename = "tag-prefix")] 850 + #[serde(alias = "tag-prefix")] 851 851 tag_prefix: Option<String>, 852 852 }, 853 853 #[serde(rename = "bitbucket")] ··· 855 855 user: String, 856 856 repo: String, 857 857 path: Option<String>, 858 - #[serde(rename = "tag-prefix")] 858 + #[serde(alias = "tag-prefix")] 859 859 tag_prefix: Option<String>, 860 860 }, 861 861 #[serde(rename = "codeberg")] ··· 863 863 user: String, 864 864 repo: String, 865 865 path: Option<String>, 866 - #[serde(rename = "tag-prefix")] 866 + #[serde(alias = "tag-prefix")] 867 867 tag_prefix: Option<String>, 868 868 }, 869 869 #[serde(rename = "gitea")] ··· 871 871 user: String, 872 872 repo: String, 873 873 path: Option<String>, 874 - #[serde(rename = "tag-prefix")] 874 + #[serde(alias = "tag-prefix")] 875 875 tag_prefix: Option<String>, 876 876 #[serde( 877 877 serialize_with = "uri_serde::serialize", ··· 884 884 user: String, 885 885 repo: String, 886 886 path: Option<String>, 887 - #[serde(rename = "tag-prefix")] 887 + #[serde(alias = "tag-prefix")] 888 888 tag_prefix: Option<String>, 889 889 #[serde( 890 890 serialize_with = "uri_serde::serialize", ··· 897 897 user: String, 898 898 repo: String, 899 899 path: Option<String>, 900 - #[serde(rename = "tag-prefix")] 900 + #[serde(alias = "tag-prefix")] 901 901 tag_prefix: Option<String>, 902 902 }, 903 903 #[serde(rename = "tangled")] ··· 905 905 user: String, 906 906 repo: String, 907 907 path: Option<String>, 908 - #[serde(rename = "tag-prefix")] 908 + #[serde(alias = "tag-prefix")] 909 909 tag_prefix: Option<String>, 910 910 }, 911 911 #[serde(rename = "custom")] 912 912 Custom { 913 913 url: String, 914 - #[serde(rename = "tag-prefix")] 914 + #[serde(alias = "tag-prefix")] 915 915 tag_prefix: Option<String>, 916 916 }, 917 917 } ··· 1149 1149 gleam_stdlib = ">= 0.18.0 and < 2.0.0" 1150 1150 my_other_project = { path = "../my_other_project" } 1151 1151 1152 - [dev-dependencies] 1152 + [dev_dependencies] 1153 1153 gleeunit = ">= 1.0.0 and < 2.0.0" 1154 1154 1155 1155 [documentation] ··· 1192 1192 let output = format!("--- GLEAM.TOML\n{input}\n\n--- EXPORTED JSON\n\n{json}"); 1193 1193 insta::assert_snapshot!(output); 1194 1194 } 1195 + 1196 + #[test] 1197 + fn dev_deps_field_name() { 1198 + let toml = r#" 1199 + name = "wibble" 1200 + version = "1.0.0" 1201 + 1202 + [dev_dependencies] 1203 + wibble = ">= 1.0.0 and < 2.0.0" 1204 + "#; 1205 + let hyphen_alternative = deserialise_config("gleam.toml", toml.into()).expect("valid config"); 1206 + let toml = r#" 1207 + name = "wibble" 1208 + version = "1.0.0" 1209 + 1210 + [dev_dependencies] 1211 + wibble = ">= 1.0.0 and < 2.0.0" 1212 + "#; 1213 + let canonical = deserialise_config("gleam.toml", toml.into()).expect("valid config"); 1214 + assert_eq!(canonical, hyphen_alternative) 1215 + }
+1 -1
compiler-core/src/docs.rs
··· 739 739 gleam_stdlib = ">= 0.18.0 and < 2.0.0" 740 740 my_other_project = { path = "../my_other_project" } 741 741 742 - [dev-dependencies] 742 + [dev_dependencies] 743 743 gleeunit = ">= 1.0.0 and < 2.0.0" 744 744 745 745 [documentation]
+2 -2
compiler-core/src/error.rs
··· 249 249 #[error("Dependency resolution failed: {0}")] 250 250 DependencyResolutionError(String), 251 251 252 - #[error("The package {0} is listed in dependencies and dev-dependencies")] 252 + #[error("The package {0} is listed in dependencies and dev_dependencies")] 253 253 DuplicateDependency(EcoString), 254 254 255 255 #[error("Expected package {expected} at path {path} but found {found} instead")] ··· 4422 4422 Error::DuplicateDependency(name) => { 4423 4423 let text = format!( 4424 4424 "The package `{name}` is specified in both the dependencies and 4425 - dev-dependencies sections of the gleam.toml file." 4425 + dev_dependencies sections of the gleam.toml file." 4426 4426 ); 4427 4427 vec![Diagnostic { 4428 4428 title: "Dependency duplicated".into(),
+2 -2
compiler-core/src/snapshots/gleam_core__config__barebones_package_config_to_json.snap
··· 1 1 --- 2 2 source: compiler-core/src/config.rs 3 - assertion_line: 1187 3 + assertion_line: 1193 4 4 expression: output 5 5 snapshot_kind: text 6 6 --- ··· 22 22 "pages": [] 23 23 }, 24 24 "dependencies": {}, 25 - "dev-dependencies": {}, 25 + "dev_dependencies": {}, 26 26 "repository": null, 27 27 "links": [], 28 28 "erlang": {
+4 -4
compiler-core/src/snapshots/gleam_core__config__package_config_to_json.snap
··· 1 1 --- 2 2 source: compiler-core/src/config.rs 3 - assertion_line: 1171 3 + assertion_line: 1177 4 4 expression: output 5 5 snapshot_kind: text 6 6 --- ··· 20 20 gleam_stdlib = ">= 0.18.0 and < 2.0.0" 21 21 my_other_project = { path = "../my_other_project" } 22 22 23 - [dev-dependencies] 23 + [dev_dependencies] 24 24 gleeunit = ">= 1.0.0 and < 2.0.0" 25 25 26 26 [documentation] ··· 70 70 "path": "../my_other_project" 71 71 } 72 72 }, 73 - "dev-dependencies": { 73 + "dev_dependencies": { 74 74 "gleeunit": { 75 75 "version": ">= 1.0.0 and < 2.0.0" 76 76 } ··· 80 80 "user": "example", 81 81 "repo": "my_dep", 82 82 "path": null, 83 - "tag-prefix": null 83 + "tag_prefix": null 84 84 }, 85 85 "links": [ 86 86 {
+2 -2
compiler-core/src/snapshots/gleam_core__docs__barebones_package_config_to_json.snap
··· 1 1 --- 2 2 source: compiler-core/src/docs.rs 3 - assertion_line: 785 3 + assertion_line: 786 4 4 expression: output 5 5 snapshot_kind: text 6 6 --- ··· 23 23 "pages": [] 24 24 }, 25 25 "dependencies": {}, 26 - "dev-dependencies": {}, 26 + "dev_dependencies": {}, 27 27 "repository": null, 28 28 "links": [], 29 29 "erlang": {
+3 -3
compiler-core/src/snapshots/gleam_core__docs__package_config_to_json.snap
··· 1 1 --- 2 2 source: compiler-core/src/docs.rs 3 - assertion_line: 769 3 + assertion_line: 770 4 4 expression: output 5 5 snapshot_kind: text 6 6 --- ··· 71 71 "path": "../my_other_project" 72 72 } 73 73 }, 74 - "dev-dependencies": { 74 + "dev_dependencies": { 75 75 "gleeunit": { 76 76 "version": ">= 1.0.0 and < 2.0.0" 77 77 } ··· 81 81 "user": "example", 82 82 "repo": "my_dep", 83 83 "path": null, 84 - "tag-prefix": null 84 + "tag_prefix": null 85 85 }, 86 86 "links": [ 87 87 {
+1 -1
test-output/cases/echo_dict/gleam.toml
··· 4 4 [dependencies] 5 5 gleam_stdlib = ">= 0.34.0 and < 2.0.0" 6 6 7 - [dev-dependencies] 7 + [dev_dependencies]
+1 -1
test-package-compiler/cases/erlang_app_generation/gleam.toml
··· 15 15 gleam_stdlib = "~> 1337.0" 16 16 gleam_otp = "~> 1337.0" 17 17 18 - [dev-dependencies] # <- 18 + [dev_dependencies] # <- 19 19 midas = "~> 1337.0" 20 20 simple_json = "~> 1337.0" 21 21
+1 -1
test-package-compiler/cases/erlang_app_generation_with_argument/gleam.toml
··· 16 16 gleam_stdlib = "~> 1337.0" 17 17 gleam_otp = "~> 1337.0" 18 18 19 - [dev-dependencies] # <- 19 + [dev_dependencies] # <- 20 20 midas = "~> 1337.0" 21 21 simple_json = "~> 1337.0" 22 22
+1 -1
test-project-compiler/cases/with_dev_dep/gleam.toml
··· 1 1 name = "example" 2 2 version = "1.0.0" 3 3 4 - [dev-dependencies] 4 + [dev_dependencies] 5 5 package_a = { path = "../support/package_a" }
+1 -1
test-project-compiler/support/package_a/gleam.toml
··· 3 3 4 4 [dependencies] 5 5 6 - [dev-dependencies] 6 + [dev_dependencies]
+1 -1
test/external_only_erlang/gleam.toml
··· 5 5 [dependencies] 6 6 hello_joe = "~> 1.0" 7 7 8 - [dev-dependencies] 8 + [dev_dependencies]
+1 -1
test/external_only_javascript/gleam.toml
··· 5 5 [dependencies] 6 6 hello_joe = "~> 1.0" 7 7 8 - [dev-dependencies] 8 + [dev_dependencies]
+1 -1
test/language/gleam.toml
··· 1 1 name = "language" 2 2 version = "1.0.0" 3 3 4 - [dev-dependencies] 4 + [dev_dependencies] 5 5 gleeunit = ">= 1.9.0 and < 2.0.0" 6 6 7 7 [javascript.deno]
+1 -1
test/project_deno/gleam.toml
··· 13 13 gleam_stdlib = "~> 0.18" 14 14 gleam_erlang = "~> 0.23" 15 15 16 - [dev-dependencies] 16 + [dev_dependencies]
+2 -2
test/project_erlang/README.md
··· 6 6 7 7 - Downloading packages 8 8 - Specified in config.dependencies 9 - - Specified in config.dev-dependencies 9 + - Specified in config.dev_dependencies 10 10 - Importing packages 11 11 - Specified in config.dependencies 12 - - Specified in config.dev-dependencies 12 + - Specified in config.dev_dependencies 13 13 - Compilation of Gleam code 14 14 - in src 15 15 - in test
+1 -1
test/project_erlang/gleam.toml
··· 32 32 hpack_erl = "~> 0.1" 33 33 gleam_javascript = "~> 0.7" 34 34 35 - [dev-dependencies] 35 + [dev_dependencies] 36 36 gleeunit = "~> 1.0"
+1 -1
test/project_erlang_windows/gleam.toml
··· 13 13 # This is a mix dep that uses files in ./priv 14 14 countries = "~> 1.6" 15 15 16 - [dev-dependencies] 16 + [dev_dependencies] 17 17 gleeunit = "~> 1.0"
+2 -2
test/project_javascript/README.md
··· 16 16 These features are not tested yet 17 17 18 18 - Downloading packages 19 - - Specified in config.dev-dependencies 19 + - Specified in config.dev_dependencies 20 20 - Importing packages 21 - - Specified in config.dev-dependencies 21 + - Specified in config.dev_dependencies 22 22 - Compilation of locally defined JavaScript modules 23 23 - in src 24 24 - in test
+1 -1
test/project_javascript/gleam.toml
··· 10 10 gleam_stdlib = "~> 0.18" 11 11 gleam_erlang = "~> 0.23" 12 12 13 - [dev-dependencies] 13 + [dev_dependencies]
+1 -1
test/project_path_deps/project_a/gleam.toml
··· 5 5 project_b = { path = "../project_b" } 6 6 project_c = { path = "../project_c" } 7 7 8 - [dev-dependencies] 8 + [dev_dependencies] 9 9 gleeunit = "~> 1.0"
+1 -1
test/project_path_deps/project_d/gleam.toml
··· 1 1 name = "project_d" 2 2 version = "1.0.0" 3 3 4 - [dev-dependencies] 4 + [dev_dependencies] 5 5 # This dependency is not used by any of the other packages in this project, and 6 6 # it is is only used by this package in dev mode, so it will not be in the other 7 7 # packages at all.
+1 -1
test/root_package_not_compiled_when_running_dep/gleam.toml
··· 16 16 gleam_stdlib = ">= 0.34.0 and < 2.0.0" 17 17 hello_joe = ">= 1.0.0 and < 2.0.0" 18 18 19 - [dev-dependencies] 19 + [dev_dependencies] 20 20 gleeunit = ">= 1.0.0 and < 2.0.0"
+1 -1
test/subdir_ffi/gleam.toml
··· 15 15 [dependencies] 16 16 gleam_stdlib = ">= 0.34.0 and < 2.0.0" 17 17 18 - [dev-dependencies] 18 + [dev_dependencies] 19 19 gleeunit = ">= 1.0.0 and < 2.0.0"