Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
18 changes: 9 additions & 9 deletions .github/workflows/generate-sandboxes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Generate and publish sandboxes

on:
schedule:
- cron: "2 2 */1 * *"
- cron: '2 2 */1 * *'
workflow_dispatch:
# To test fixes on push rather than wait for the scheduling, do the following:
# 1. Uncomment the lines below and add your branch.
Expand All @@ -14,8 +14,8 @@ on:
# 4. 👉 DON'T FORGET TO UNDO THE STEPS BEFORE YOU MERGE YOUR CHANGES!

env:
YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
CLEANUP_SANDBOX_NODE_MODULES: "true"
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false'
CLEANUP_SANDBOX_NODE_MODULES: 'true'

defaults:
run:
Expand All @@ -33,7 +33,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
node-version-file: '.nvmrc'

- name: Setup git user
run: |
Expand All @@ -48,14 +48,14 @@ jobs:
run: yarn task --task compile --start-from=auto --no-link

- name: Publish to local registry
run: yarn local-registry --publish

- name: Run local registry
run: yarn local-registry --open &
run: yarn local-registry --publish --open --no-local &

- name: Wait for registry
run: yarn wait-on tcp:127.0.0.1:6001

- name: Wait for registry
run: yarn wait-on tcp:127.0.0.1:6002
Comment on lines 73 to 74
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Use distinct names for registry wait steps.

Both wait steps are named "Wait for registry", which makes them indistinguishable in the GitHub Actions UI. Since they wait on different ports (6001 for the proxy and 6002 for Verdaccio), they should have distinct names.

Apply this diff:

-      - name: Wait for registry
+      - name: Wait for proxy registry
         run: yarn wait-on tcp:127.0.0.1:6001
 
-      - name: Wait for registry
+      - name: Wait for Verdaccio
         run: yarn wait-on tcp:127.0.0.1:6002
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Wait for registry
run: yarn wait-on tcp:127.0.0.1:6001
- name: Wait for registry
run: yarn wait-on tcp:127.0.0.1:6002
- name: Wait for proxy registry
run: yarn wait-on tcp:127.0.0.1:6001
- name: Wait for Verdaccio
run: yarn wait-on tcp:127.0.0.1:6002
🤖 Prompt for AI Agents
In .github/workflows/generate-sandboxes.yml around lines 53 to 57, both steps
are labeled "Wait for registry" which makes them indistinguishable in the
Actions UI; change the step names to unique, descriptive labels (e.g., "Wait for
proxy registry (6001)" for the tcp:127.0.0.1:6001 step and "Wait for Verdaccio
registry (6002)" for the tcp:127.0.0.1:6002 step) so each step is clearly
identifiable while keeping the run commands unchanged.


- name: Generate
id: generate
run: yarn generate-sandboxes --local-registry
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
node-version-file: '.nvmrc'

- name: Setup git user
run: |
Expand Down
2 changes: 1 addition & 1 deletion code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/a11y"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/docs"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/links"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/onboarding"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/pseudo-states/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/pseudo-states"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/themes"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/addons/vitest"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/builders/builder-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/builders/builder-webpack5"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/core"
},
"funding": {
Expand Down
6 changes: 5 additions & 1 deletion code/core/src/bin/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ async function run() {
// the package couldn't be imported, use npx to install and run it instead
}

const { default: packageJson } = await import(`storybook/package.json`, {
with: { type: 'json' },
});

const child = executeCommand({
command: 'npx',
args: ['--yes', `${targetCli.pkg}@${versions[targetCli.pkg]}`, ...targetCli.args],
args: ['--yes', `${targetCli.pkg}@${packageJson.version}`, ...targetCli.args],
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure this is a safe change?

it will change it from being the version of @storybook/cli or create-storybook to always be the version of storybook?

Copy link
Member

Choose a reason for hiding this comment

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

I think the actual behavior will be the same, but I don't understand why the change is needed.
What is the intend here?

stdio: 'inherit',
});
child.on('exit', (code) => {
Expand Down
7 changes: 6 additions & 1 deletion code/core/src/common/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ export abstract class JsPackageManager {

const isLatestStableRelease = currentVersion === latestInRange;

if (latestInRange?.includes('-local.')) {
return `${packageName}@local`;
}
Comment on lines +383 to +385
Copy link
Member

Choose a reason for hiding this comment

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

The latestInRange is a lookup of what's on the latest tag on the current registry.
It including -local would only ever be the case when running verdaccio, right?

So I'm guessing latest and local tags are actually equal on verdaccio.
So what is the point of converting it to local tag?

Copy link
Member

Choose a reason for hiding this comment

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

We have tests for this code IIRC, we should ensure added behavior has tests in place.


if (isLatestStableRelease || !currentVersion) {
return `${packageName}@^${latestInRange}`;
}
Expand Down Expand Up @@ -440,7 +444,8 @@ export abstract class JsPackageManager {
current && (!constraint || satisfies(current, constraint)) && gt(current, latest)
? current
: latest;
return `^${versionToUse}`;

return latest.includes('-local.') ? 'local' : `^${versionToUse}`;
}
Comment on lines +447 to 449
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's find and examine the JsPackageManager.ts file
fd "JsPackageManager.ts" -t f

Repository: storybookjs/storybook

Length of output: 124


🏁 Script executed:

# Get the file to understand context around lines 410-449
cat -n code/core/src/common/js-package-manager/JsPackageManager.ts | sed -n '400,460p'

Repository: storybookjs/storybook

Length of output: 2645


🏁 Script executed:

# Search for latestVersion method to understand its return type
rg -n "latestVersion" code/core/src/common/js-package-manager/JsPackageManager.ts -B 2 -A 5

Repository: storybookjs/storybook

Length of output: 3511


🏁 Script executed:

# Search for 'local' dist-tag usage patterns in the codebase
rg -n "dist-tag.*local|--tag.*local|'local'" --type=ts --type=js code/ -B 2 -A 2

Repository: storybookjs/storybook

Length of output: 5887


🏁 Script executed:

# Search for any Verdaccio configuration or publishing patterns
rg -n "verdaccio|dist-tag" --type=ts --type=js --type=json code/ -B 1 -A 1

Repository: storybookjs/storybook

Length of output: 47


🏁 Script executed:

# Check for 'local' string usage in version context
rg -n "\-local\." --type=ts --type=js code/core/src/common/js-package-manager/ -B 3 -A 3

Repository: storybookjs/storybook

Length of output: 1257


🏁 Script executed:

# Check line 383 context more carefully
cat -n code/core/src/common/js-package-manager/JsPackageManager.ts | sed -n '370,390p'

Repository: storybookjs/storybook

Length of output: 978


🏁 Script executed:

# Check if latestInRange could be null at line 383
cat -n code/core/src/common/js-package-manager/JsPackageManager.ts | sed -n '360,395p'

Repository: storybookjs/storybook

Length of output: 1555


🏁 Script executed:

# Check TypeScript configuration for strict mode
cat tsconfig.json | head -50

Repository: storybookjs/storybook

Length of output: 110


🏁 Script executed:

# Check the exact control flow - does TypeScript narrow after throw?
cat -n code/core/src/common/js-package-manager/JsPackageManager.ts | sed -n '427,450p'

Repository: storybookjs/storybook

Length of output: 876


🏁 Script executed:

# Verify TypeScript version and strict mode config
fd "tsconfig" -t f | head -5

Repository: storybookjs/storybook

Length of output: 235


🏁 Script executed:

# Check main tsconfig location
find . -maxdepth 2 -name "tsconfig*.json" -type f

Repository: storybookjs/storybook

Length of output: 109


🏁 Script executed:

# Check TypeScript strict mode configuration
cat code/tsconfig.json | grep -A 20 "compilerOptions"

Repository: storybookjs/storybook

Length of output: 693


Add JSDoc documentation for the local version behavior.

The method properly guards against null values at lines 430–432 with an explicit throw that narrows the latest variable to a non-null string type before line 448, consistent with how latest is already used at line 444 without defensive checks.

However, the special handling of local versions (checking for -local. and returning the string 'local' as a dist-tag) is undocumented. This behavior is used elsewhere in the codebase (line 384: ${packageName}@local) but the getVersion method's JSDoc doesn't explain it.

Add to the JSDoc comment for this method (around line 410):

   /**
    * Return the latest version of the input package available on npmjs registry. If constraint are
    * provided it return the latest version matching the constraints.
    *
    * For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file
    * directly
+   *
+   * When the latest version contains a local pre-release tag (e.g., '8.0.0-local.1'), this method
+   * returns the string 'local' to indicate the package should be installed using the 'local' dist-tag.
    *
    * @param packageName The name of the package
    * @param constraint A valid semver constraint, example: '1.x || >=2.5.0 || 5.0.0 - 7.2.3'
+   * @returns A semver version string prefixed with '^', or the string 'local' for local development versions
    */

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In code/core/src/common/js-package-manager/JsPackageManager.ts around line 410,
update the method JSDoc for getVersion to document the special "local" dist-tag
behavior: note that the method already narrows `latest` to a non-null string
earlier, and that if the resolved latest string contains "-local." the method
returns the literal 'local' (used elsewhere as `${packageName}@local`),
otherwise it returns a caret-prefixed version `^${versionToUse}`; add a short
example and mention that callers should expect the 'local' dist-tag when
testing/local builds include "-local." in the version.


/**
Expand Down
1 change: 1 addition & 0 deletions code/core/src/common/js-package-manager/NPMProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export class NPMProxy extends JsPackageManager {
const process = executeCommand({
command: 'npm',
args: ['info', packageName, ...args],
cwd: this.cwd,
});
const result = await process;
const commandResult = result.stdout ?? '';
Expand Down
1 change: 1 addition & 0 deletions code/core/src/common/js-package-manager/PNPMProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class PNPMProxy extends JsPackageManager {
const process = executeCommand({
command: 'pnpm',
args: ['info', packageName, ...args],
cwd: this.cwd,
});
const result = await process;
const commandResult = result.stdout ?? '';
Expand Down
1 change: 1 addition & 0 deletions code/core/src/common/js-package-manager/Yarn1Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export class Yarn1Proxy extends JsPackageManager {
const process = executeCommand({
command: 'yarn',
args: ['info', packageName, ...args],
cwd: this.cwd,
});
const result = await process;
const commandResult = result.stdout ?? '';
Expand Down
1 change: 1 addition & 0 deletions code/core/src/common/js-package-manager/Yarn2Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export class Yarn2Proxy extends JsPackageManager {
const process = executeCommand({
command: 'yarn',
args: ['npm', 'info', packageName, ...args],
cwd: this.cwd,
});
const result = await process;
const commandResult = result.stdout ?? '';
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/angular"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/ember"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/html-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/html-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/nextjs-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/nextjs"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/nextjs"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/preact-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/preact-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-native-web-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/react-native-web-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/react-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/react-webpack5"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/server-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/server-webpack5"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/svelte-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/svelte-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/sveltekit"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/vue3-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/vue3-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/web-components-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/frameworks/web-components-vite"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli-sb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/lib/cli-sb"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/lib/cli-storybook"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/lib/codemod"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/lib/core-webpack"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/create-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/lib/cli"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/csf-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"url": "git+https://github.com/storybookjs/storybook.git",
"directory": "code/lib/csf-plugin"
},
"funding": {
Expand Down
Loading