Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add export package info command #4298

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Papipo
Copy link

@Papipo Papipo commented Mar 4, 2025

Closes #4240

  • Adds Serialize trait to PackageConfig and all types it depends on.
  • Adds serde options to skip flags that have default values.
  • Adds gleam export package-info --out [out] command
  • Fixes gleam export package-interface format for gleam_version_constraint, which was being exported like: "gleam-version-constraint":"1.8.0 <= v" because it relied on pubgrub. Now it uses hexpm format and emits >= 1.8.0.

Notice that now PackageConfig has gleam, which is a 1:1 field for the gleam.toml field and is serializable, and gleam_version, which is still used as it used to, but it's skipped on serialization.

@Papipo Papipo marked this pull request as draft March 4, 2025 12:51
@Papipo Papipo force-pushed the add-export-package-info-command branch from 8db0fdd to e858ca1 Compare March 6, 2025 16:40
@Papipo Papipo marked this pull request as ready for review March 6, 2025 20:53
@Papipo Papipo force-pushed the add-export-package-info-command branch from d2d59b7 to 0d0f3df Compare March 9, 2025 18:08
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful, thank you!

Let's make it always render all the fields, even if they are the defaults. This will make it easier to understand what all the fields are.

It would also be good to have some round-trip tests, to ensure that a config file serialised and then deserialise doesn't have a bug that results in data-loss.

source: compiler-core/src/config.rs
expression: json
---
{"name":"my_project","version":"1.0.0","gleam":">= 0.30.0","licences":["Apache-2.0","MIT"],"description":"Pretty complex config","documentation":{"pages":[{"title":"My Page","path":"my-page.html","source":"./path/to/my-page.md"}]},"dependencies":{"my_other_project":{"path":"../my_other_project"},"gleam_stdlib":{"version":">= 0.18.0 and < 2.0.0"}},"dev-dependencies":{"gleeunit":{"version":">= 1.0.0 and < 2.0.0"}},"repository":{"type":"github","user":"example","repo":"my_dep"},"links":[{"title":"Home page","href":"https://example.com/"}],"erlang":{"application_start_module":"my_app/application","extra_applications":["inets","ssl"]},"javascript":{"typescript_declarations":true,"runtime":"nodejs","deno":{"allow_env":["DATABASE_URL"],"allow_net":["example.com:443"],"allow_ffi":true,"allow_read":["./database.sqlite"]}},"internal_modules":["my_app/internal"]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the toml in the snapshot and pretty print the JSON 🙏

See the other snapshot for examples of how we format them with both the input and the output

)]
// gleam version field in Hex format (for [de]serialization purposes)
pub gleam: Option<version::Range>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be part of the gleam_version field rather than a second one. They are tightly coupled as being two representations of the same thing, so it is invalid to have one without the other.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, this was bothering me

@lpil lpil marked this pull request as draft March 10, 2025 13:18
@Papipo Papipo force-pushed the add-export-package-info-command branch from d617496 to bac0155 Compare March 11, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add command to export deps/config
2 participants