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

CLI: Versioned installation of monorepo packages #25517

Merged
merged 10 commits into from
Jan 10, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jan 9, 2024

Closes #25501
Works on #25293

What I did

  • Change the mechanism for picking the version to install for packages when adding packages via the package-manager. When a package is in the monorepo, a different heuristic is used. The version in versions.ts is used, and added, unless that version happens to be the latest version, in which case, no modifier is added.
  • The welcome message to sb init has been changed to be more noticeable, as it can now contain a warning to the user, that they are running an old version of the CLI. (The CLI will still proceed to run the actual init!)
  • It will also print a message when the user is running a prerelease version (not latest).

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  1. Create a project which storybook can init on
  2. run npx storybook@{{version}} init
  3. The expected outcome it that that exact version is used to init, and the project's package.json will contain the exact versions of storybook packages that was used.
  4. If the listed version is exactly latest on the npm registry, the project's package.json will contain the ^-prefixed versions of storybook packages that was used.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

@ndelangen ndelangen changed the title get versioned packages from monorepo if not-latest, bail on init if called without version modifier CLI: Versioned installation of monorepo packages Jan 9, 2024
@ndelangen ndelangen self-assigned this Jan 9, 2024
@ndelangen ndelangen changed the base branch from norbert/cli-versioning-base to next January 9, 2024 12:28
Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

Looks good!

code/lib/cli/src/initiate.ts Outdated Show resolved Hide resolved
code/lib/cli/src/initiate.ts Outdated Show resolved Hide resolved
code/lib/cli/src/initiate.ts Outdated Show resolved Hide resolved
code/lib/cli/src/js-package-manager/JsPackageManager.ts Outdated Show resolved Hide resolved
Copy link

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: simple-update-notifier@2.0.0

@JReinhold
Copy link
Contributor

JReinhold commented Jan 9, 2024

An alternative to the warning would be to throw an error, that could be bypassed with a --force flag if the user really intended to init with an older version. This approach makes sense if we think that:

  1. Users that run npx storybook init without the version specifier are the same users that ignore warnings. This is bad because that is the exact use case for the warning
  2. Intentionally initializing an older version is an edge case, where it's okay to require additional flags like --foce.

The downside of this approach is that we might need to adjust our CI/tasks to add this --force flag in any places where it's needed. I can't think of any such place right now, but I wouldn't be surprised if there was one.

I'm leaning slightly towards this alternative approach, but it's not a strong feeling.

code/lib/cli/src/initiate.ts Outdated Show resolved Hide resolved
ndelangen added a commit that referenced this pull request Jan 9, 2024
@JReinhold JReinhold merged commit 4ac3f9e into next Jan 10, 2024
57 of 58 checks passed
@JReinhold JReinhold deleted the norbert/cli-versioning-base2 branch January 10, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always initialize the version that the CLI is invoked as, instead of just latest or next
2 participants