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

[WIP] Implement config v0 -> v1 migration. #1653

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

Conversation

duckinator
Copy link
Contributor

@duckinator duckinator commented Dec 18, 2024

Required functionality for this PR:

  1. make dist migrate move v0 to v1
    • Have do_migrate_from_v0() actually copy workspace members to the new configuration.
  2. make dist init use v1
  3. make everything but dist init load v1
  4. make sure dist plan (and other commands) gives an actionable error for v0 configs

Current state (2025-01-10):

image

image

@duckinator duckinator force-pushed the dist-migrate-v1 branch 4 times, most recently from ce26547 to 9a7d939 Compare December 20, 2024 17:15
@duckinator
Copy link
Contributor Author

duckinator commented Dec 20, 2024

This is currently based off #1661. When that gets merged, I'll rebase off main.

@duckinator
Copy link
Contributor Author

The various apply_*() functions should compile now, and some of it will actually be updated properly.

TODO:

  1. get_new_dist_metadata()
  2. finish up the apply_*() functions

@mistydemeo
Copy link
Contributor

mistydemeo commented Jan 7, 2025

We were discussing get_new_dist_metadata during the call. I'll summarize what it does.

This is the interactive portion of init. It's used in two code paths: a newly-initted system, in which case we have no existing config, and updating existing configuration. If there's existing config, the interactive portions are designed to prefill the choice with the decisions that had already been made the last time; this ensures that mashing enter through the settings preserves the user's existing config without changing anything.

Unlike most of the rest of init, which operates on toml_edit documents, get_new_dist_metadata operates on a DistMetadata struct. It parses the existing config to DistMetadata, edits it in place, and returns the altered document. If there's no existing configuration, it instead initializes a completely empty DistMetadata.

Because this code is working from and generating a DistMetadata, we might not actually have to do any changes at all for this branch beyond swapping to the v1 version of DistMetadata.

For each bit of user-selectable config, we use the dialoguer crate to prompt the user for their input unless the user passed the --yes/-y flag, in which case we pick defaults/their existing config without prompting.

Copy link
Contributor

@mistydemeo mistydemeo left a comment

Choose a reason for hiding this comment

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

Left a comment on the as-yet incomplete items in init.rs, just to track them, along with a couple of things to keep an eye on testing.

Aside from the remaining init.rs changes, I think the only other remaining work is in the tests. All of our tests are written in the old config format, and are specifically using Cargo.toml, so they need to be updated to use dist-workspace.toml in the new config format in order to pass.

// FIXME: when there is more than one option this should be a proper
// multiselect like the installer selector is! For now we do
// most of the multi-select logic and then just give a prompt.
let known = &[CiStyle::Github];
/*let known = &[CiStyle::Github];
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole section with the complex "known styles" logic either needs to be uncommented out or deleted. Since we currently don't have any non-GitHub CI options, deletion seems reasonable at this point.

// Enable installer backends (if they have a CI backend that can provide URLs)
// FIXME: "vendored" installers like msi could be enabled without any CI...
let has_ci = meta.ci.as_ref().map(|ci| !ci.is_empty()).unwrap_or(false);
//let has_ci = meta.ci.as_ref().map(|ci| !ci.is_empty()).unwrap_or(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to clear up whether this commented-out version can simply be deleted or not, given the version below.

@@ -733,37 +773,40 @@ fn get_new_dist_metadata(
InstallerStyle::Npm,
InstallerStyle::Homebrew,
InstallerStyle::Msi,
// Pkg intentionally left out because it's currently opt-in only.
Copy link
Contributor

Choose a reason for hiding this comment

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

Due to be added in #1381, but it needs to be rewritten in the style of this new code.

Ok(meta)
}

/// Update a workspace toml-edit document with the current DistMetadata value
pub(crate) fn apply_dist_to_workspace_toml(
workspace_toml: &mut toml_edit::DocumentMut,
workspace_kind: WorkspaceKind,
meta: &DistMetadata,
_workspace_kind: WorkspaceKind,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably remove this param entirely now!

} = &meta;

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole section needs to be uncommented and reimplemented for the new structure.


apply_installers_common(npm_table, &npm.common);

// TODO: similar to shell
Copy link
Contributor

Choose a reason for hiding this comment

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

Impl missing here.


apply_installers_common(powershell_table, &powershell.common);

// TODO: similar to shell
Copy link
Contributor

Choose a reason for hiding this comment

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

Impl missing here.


apply_installers_common(shell_table, &shell.common);

// TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Impl missing here.


apply_optional_value(
pkg_table,
"install_location",
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: this one is still kebab-case.

Suggested change
"install_location",
"install-location",

panic!("Expected [dist.publishers] to be a table");
};

// ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Impl missing here.

@mistydemeo mistydemeo mentioned this pull request Jan 11, 2025
11 tasks
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.

2 participants