Skip to content

Commit

Permalink
add 3rd-party tool section and fail on unknown manifest keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tingerrr committed Jan 7, 2024
1 parent 535f9de commit 927a46b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ Optional:
otherwise unnecessarily increase the bundle size. Don't exclude the README or
the LICENSE.

Thrid-party tools can add their own entry under the `[tool]` section to attach
their own typst specific config to the manifest.

```toml
[package]
# ...

[tool.mytool]
foo = "bar"
```

Packages always live in folders named as `{name}/{version}`. The name and
version in the folder name and manifest must match. Paths in a package are local
to that package. Absolute paths start in the package root while relative paths
Expand Down
8 changes: 6 additions & 2 deletions bundler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> anyhow::Result<()> {
/// Create an archive for a package.
fn process_package(path: &Path) -> anyhow::Result<PackageInfo> {
println!("Bundling {}.", path.display());
let PackageManifest { package } =
let PackageManifest { package, .. } =
parse_manifest(path).context("failed to parse package manifest")?;
let buf = build_archive(path, &package.exclude).context("failed to build archive")?;
validate_archive(&buf).context("failed to validate archive")?;
Expand Down Expand Up @@ -139,13 +139,17 @@ fn write_archive(info: &PackageInfo, buf: &[u8]) -> anyhow::Result<()> {
}

/// A parsed package manifest.
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct PackageManifest {
package: PackageInfo,
#[serde(skip_serializing_if = "Option::is_none")]
tool: Option<toml::Table>,
}

/// The `package` key in the manifest.
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct PackageInfo {
name: String,
version: Version,
Expand Down

0 comments on commit 927a46b

Please sign in to comment.