Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,6 @@
been improved with much more detailed documentation output.
([Louis Pilfold](https://github.com/lpil))

- The build tool now emits errors for unknown fields in package config,
except for the ones under `[tools]`. For example, with this:

```toml
name = "hello"
version = "1.0.0"

[tools.my-tool]
my-awesome-setting = true
```

Building the project won't give any errors. But with this:

```toml
name = "hello"
version = "1.0.0"
my-awesome-setting = true
```

Building the project will emit an error.

([Andrey Kozhev](https://github.com/ankddev))

- When attempting to publish a package on Hex with an already taken name,
the message is clearer.
([vyacheslavhere](https://github.com/vyacheslavhere))
Expand Down
1 change: 0 additions & 1 deletion compiler-cli/src/dependencies/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@ fn package_config(
},
target: Target::Erlang,
internal_modules: None,
tools: Default::default(),
}
}

Expand Down
36 changes: 1 addition & 35 deletions compiler-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::{self};
use std::marker::PhantomData;
use toml::Table;

#[cfg(test)]
use crate::manifest::ManifestPackage;
Expand Down Expand Up @@ -145,7 +144,6 @@ impl GleamVersion {
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
#[serde(deny_unknown_fields)]
pub struct PackageConfig {
#[serde(deserialize_with = "package_name::deserialize")]
pub name: EcoString,
Expand Down Expand Up @@ -181,11 +179,6 @@ pub struct PackageConfig {
pub target: Target,
#[serde(default)]
pub internal_modules: Option<Vec<Glob>>,
/// This entry contains values from [tools] table, which is the only way
/// for tools to store configuration inside package config, other unknown
/// values are denied. It isn't used anywhere in the compiler and build tool.
#[serde(default)]
pub tools: Table,
}

pub fn serialise_gleam_version<S>(
Expand Down Expand Up @@ -709,13 +702,11 @@ impl Default for PackageConfig {
links: Default::default(),
internal_modules: Default::default(),
target: Target::Erlang,
tools: Default::default(),
}
}
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct ErlangConfig {
/// An module that can be set in the `.app` file as the entrypoint for a stateful application
/// that defines a singleton supervision tree.
Expand All @@ -732,7 +723,6 @@ pub struct ErlangConfig {
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct JavaScriptConfig {
#[serde(default)]
pub typescript_declarations: bool,
Expand Down Expand Up @@ -812,7 +802,6 @@ where
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct DenoConfig {
#[serde(default, deserialize_with = "bool_or_seq_string_to_deno_flag")]
pub allow_env: DenoFlag,
Expand Down Expand Up @@ -843,7 +832,7 @@ pub struct DenoConfig {
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
#[serde(tag = "type", deny_unknown_fields)]
#[serde(tag = "type")]
pub enum Repository {
#[serde(rename = "github")]
GitHub {
Expand Down Expand Up @@ -979,22 +968,19 @@ impl Repository {
}

#[derive(Deserialize, Serialize, Default, Debug, PartialEq, Eq, Clone)]
#[serde(deny_unknown_fields)]
pub struct Docs {
#[serde(default)]
pub pages: Vec<DocsPage>,
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
#[serde(deny_unknown_fields)]
pub struct DocsPage {
pub title: String,
pub path: String,
pub source: Utf8PathBuf,
}

#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
#[serde(deny_unknown_fields)]
pub struct Link {
pub title: String,
#[serde(with = "uri_serde")]
Expand Down Expand Up @@ -1183,9 +1169,6 @@ allow_ffi = true
allow_env = ["DATABASE_URL"]
allow_net = ["example.com:443"]
allow_read = ["./database.sqlite"]

[tools.my-tool]
enable = true
"#;

let config = toml::from_str::<PackageConfig>(input).unwrap();
Expand Down Expand Up @@ -1230,20 +1213,3 @@ wibble = ">= 1.0.0 and < 2.0.0"
let canonical = deserialise_config("gleam.toml", toml.into()).expect("valid config");
assert_eq!(canonical, hyphen_alternative)
}

#[test]
fn unknown_field_root() {
let input = r#"
name = "wibble"
version = "1.0.0"

unknown = true
"#;

insta::assert_snapshot!(
insta::internals::AutoName,
toml::from_str::<PackageConfig>(input)
.unwrap_err()
.to_string(),
)
}
1 change: 0 additions & 1 deletion compiler-core/src/package_interface/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ fn package_from_module(module: Module) -> Package {
.build()
.expect("internals glob"),
]),
tools: Default::default(),
},
cached_module_names: Vec::new(),
modules: vec![module],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
source: compiler-core/src/config.rs
assertion_line: 1193
expression: output
snapshot_kind: text
---
--- GLEAM.TOML

Expand Down Expand Up @@ -46,6 +48,5 @@ version = "1.0.0"
}
},
"target": "erlang",
"internal_modules": null,
"tools": {}
"internal_modules": null
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
source: compiler-core/src/config.rs
assertion_line: 1177
expression: output
snapshot_kind: text
---
--- GLEAM.TOML

Expand Down Expand Up @@ -39,9 +41,6 @@ allow_env = ["DATABASE_URL"]
allow_net = ["example.com:443"]
allow_read = ["./database.sqlite"]

[tools.my-tool]
enable = true


--- EXPORTED JSON

Expand Down Expand Up @@ -123,10 +122,5 @@ enable = true
"target": "erlang",
"internal_modules": [
"my_app/internal"
],
"tools": {
"my-tool": {
"enable": true
}
}
]
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
source: compiler-core/src/docs.rs
assertion_line: 786
expression: output
snapshot_kind: text
---
--- GLEAM.TOML

Expand Down Expand Up @@ -47,7 +49,6 @@ version = "1.0.0"
}
},
"target": "erlang",
"internal_modules": null,
"tools": {}
"internal_modules": null
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
source: compiler-core/src/docs.rs
assertion_line: 770
expression: output
snapshot_kind: text
---
--- GLEAM.TOML

Expand Down Expand Up @@ -121,7 +123,6 @@ allow_read = ["./database.sqlite"]
"target": "erlang",
"internal_modules": [
"my_app/internal"
],
"tools": {}
]
}
}
Loading