From e5ddd2b99a80b9f1b096769b5a459245d5c2ffbc Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 10:30:07 +0100 Subject: [PATCH 1/7] add temporary log to test released canary --- code/lib/core-server/src/presets/common-preset.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index 15fb3bfceb26..727ee4bf8fb5 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -206,6 +206,7 @@ export const frameworkOptions = async ( options: Options ): Promise | null> => { const config = await options.presets.apply('framework'); + console.log('LOG: this is a log message from frameworkOptions!'); if (typeof config === 'string') { return {}; From 579fbffd47ed76184978b98979387fedebc42dad Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 10:41:53 +0100 Subject: [PATCH 2/7] add sandbox and upgrade commands to canary PR description --- .github/workflows/canary-release-pr.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/canary-release-pr.yml b/.github/workflows/canary-release-pr.yml index 827f24a2c5f8..659765318fe5 100644 --- a/.github/workflows/canary-release-pr.yml +++ b/.github/workflows/canary-release-pr.yml @@ -1,11 +1,11 @@ name: Publish canary release of PR -run-name: 'Canary release: PR #${{ inputs.pr }}, triggered by ${{ github.triggering_actor }}' +run-name: "Canary release: PR #${{ inputs.pr }}, triggered by ${{ github.triggering_actor }}" on: workflow_dispatch: inputs: pr: - description: 'Pull request number to create a canary release for' + description: "Pull request number to create a canary release for" required: true type: number @@ -58,7 +58,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version-file: '.nvmrc' + node-version-file: ".nvmrc" - name: Cache dependencies uses: actions/cache@v3 with: @@ -91,10 +91,10 @@ jobs: with: githubToken: ${{ secrets.GH_TOKEN }} prNumber: ${{ inputs.pr }} - find: 'CANARY_RELEASE_SECTION' + find: "CANARY_RELEASE_SECTION" isHtmlCommentTag: true replace: | - This pull request has been released as version [`${{ steps.version.outputs.next-version }}`](https://npmjs.com/package/@storybook/cli/v/${{ steps.version.outputs.next-version }}). Install it by pinning all your Storybook dependencies to that version. + This pull request has been released as version `${{ steps.version.outputs.next-version }}`. Try it out in a new sandbox by running `npx storybook@${{ steps.version.outputs.next-version }} sandbox` or in an existing project with `npx storybook@${{ steps.version.outputs.next-version }} upgrade`.
More information From 8f662b4af49f6d8ed9e29ced09d6b8e4ab07c1b5 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 11:31:50 +0100 Subject: [PATCH 3/7] support canary versions in upgrade command --- code/lib/cli/src/upgrade.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 8738f1bfea6a..9f61431fc622 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -1,6 +1,6 @@ import { sync as spawnSync } from 'cross-spawn'; import { telemetry, getStorybookCoreVersion } from '@storybook/telemetry'; -import semver, { eq, lt, prerelease } from 'semver'; +import semver, { eq, lt, parse, prerelease } from 'semver'; import { logger } from '@storybook/node-logger'; import { withTelemetry } from '@storybook/core-server'; import { @@ -110,13 +110,19 @@ export const doUpgrade = async ({ }: UpgradeOptions) => { const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr }); - const currentVersion = versions['@storybook/cli']; const beforeVersion = await getStorybookCoreVersion(); - - if (lt(currentVersion, beforeVersion)) { + const currentVersion = versions['@storybook/cli']; + const currentSemver = parse(currentVersion); + const isCanary = + currentSemver && + currentSemver.major === 0 && + currentSemver.minor === 0 && + currentSemver.patch === 0; + + if (!isCanary && lt(currentVersion, beforeVersion)) { throw new UpgradeStorybookToLowerVersionError({ beforeVersion, currentVersion }); } - if (eq(currentVersion, beforeVersion)) { + if (!isCanary && eq(currentVersion, beforeVersion)) { throw new UpgradeStorybookToSameVersionError({ beforeVersion }); } From ccd9740d53bb379266c3d8c5342249571334009c Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 12:47:04 +0100 Subject: [PATCH 4/7] dont add tilde to canary versions --- code/lib/cli/src/upgrade.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 9f61431fc622..32e0e34cb6df 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -172,12 +172,12 @@ export const doUpgrade = async ({ // only upgrade packages that are in the monorepo return dependency in versions; }) as Array; - return monorepoDependencies.map( - (dependency) => - // add ^ modifier to the version if this is the latest and stable version - // example output: @storybook/react@^8.0.0 - `${dependency}@${!isOutdated || isPrerelease ? '^' : ''}${versions[dependency]}` - ); + return monorepoDependencies.map((dependency) => { + /* add ^ modifier to the version if this is the latest stable or prerelease version + example outputs: @storybook/react@^8.0.0 */ + const maybeTilde = (!isOutdated || isPrerelease) && !isCanary ? '^' : ''; + return `${dependency}@${maybeTilde}${versions[dependency]}`; + }); }; const upgradedDependencies = toUpgradedDependencies(packageJson.dependencies); From 947cbefd4fe8af42dfeb3f7b8d34ec23b1c74e4b Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 12:52:47 +0100 Subject: [PATCH 5/7] tilde -> caret --- code/lib/cli/src/upgrade.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 32e0e34cb6df..23876f933403 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -175,8 +175,8 @@ export const doUpgrade = async ({ return monorepoDependencies.map((dependency) => { /* add ^ modifier to the version if this is the latest stable or prerelease version example outputs: @storybook/react@^8.0.0 */ - const maybeTilde = (!isOutdated || isPrerelease) && !isCanary ? '^' : ''; - return `${dependency}@${maybeTilde}${versions[dependency]}`; + const maybeCaret = (!isOutdated || isPrerelease) && !isCanary ? '^' : ''; + return `${dependency}@${maybeCaret}${versions[dependency]}`; }); }; From 198b25c04fd006ed7704a7a930dbae05e1b97ccd Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 13:11:01 +0100 Subject: [PATCH 6/7] remove temporary console.log --- code/lib/core-server/src/presets/common-preset.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index 727ee4bf8fb5..15fb3bfceb26 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -206,7 +206,6 @@ export const frameworkOptions = async ( options: Options ): Promise | null> => { const config = await options.presets.apply('framework'); - console.log('LOG: this is a log message from frameworkOptions!'); if (typeof config === 'string') { return {}; From 036235b74ddfda141372ce2c99ff486e24a1eca3 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 15 Jan 2024 14:55:34 +0100 Subject: [PATCH 7/7] simplify isCanary --- code/lib/cli/src/upgrade.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 23876f933403..29115c4244cf 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -1,6 +1,6 @@ import { sync as spawnSync } from 'cross-spawn'; import { telemetry, getStorybookCoreVersion } from '@storybook/telemetry'; -import semver, { eq, lt, parse, prerelease } from 'semver'; +import semver, { eq, lt, prerelease } from 'semver'; import { logger } from '@storybook/node-logger'; import { withTelemetry } from '@storybook/core-server'; import { @@ -112,12 +112,7 @@ export const doUpgrade = async ({ const beforeVersion = await getStorybookCoreVersion(); const currentVersion = versions['@storybook/cli']; - const currentSemver = parse(currentVersion); - const isCanary = - currentSemver && - currentSemver.major === 0 && - currentSemver.minor === 0 && - currentSemver.patch === 0; + const isCanary = currentVersion.startsWith('0.0.0'); if (!isCanary && lt(currentVersion, beforeVersion)) { throw new UpgradeStorybookToLowerVersionError({ beforeVersion, currentVersion });