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

Release: Patch 7.6.9 #25598

Merged
merged 31 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7418581
apply https://github.com/storybookjs/storybook/pull/25517 on main
ndelangen Jan 9, 2024
dbf6a9d
add version modifier
ndelangen Jan 10, 2024
6f6ed73
new upgrade workflow based on https://github.com/storybookjs/storyboo…
JReinhold Jan 11, 2024
3f48968
use current version for sandbox cli command
ndelangen Jan 12, 2024
a89b141
add back deprecated flags
JReinhold Jan 12, 2024
6dff347
Merge branch 'jeppe/upgrade-versioned-main' into norbert/cli-sandbox-…
ndelangen Jan 12, 2024
2ac5b32
fix automigrations and readmes
JReinhold Jan 12, 2024
1d41227
Merge branch 'jeppe/upgrade-versioned-main' into norbert/cli-sandbox-…
ndelangen Jan 12, 2024
9cb3fe6
update message matches new upgrade API
JReinhold Jan 12, 2024
5f28374
Merge branch 'main' into norbert/init-versioning-main
ndelangen Jan 12, 2024
1d7f277
maybe fix
ndelangen Jan 12, 2024
9a628b5
Merge branch 'main' into norbert/init-versioning-main
ndelangen Jan 12, 2024
b24dcbd
Merge branch 'norbert/init-versioning-main' into jeppe/upgrade-versio…
ndelangen Jan 12, 2024
912dde5
Merge branch 'jeppe/upgrade-versioned-main' into norbert/cli-sandbox-…
ndelangen Jan 12, 2024
9f449a5
fix tests
ndelangen Jan 12, 2024
ded297c
Merge branch 'jeppe/upgrade-versioned-main' into norbert/cli-sandbox-…
ndelangen Jan 12, 2024
90c6647
Update ./docs/versions/next.json for v8.0.0-alpha.10
storybook-bot Jan 15, 2024
24f72ed
fix the call to init in the cwd & ignore if next tag is missing
ndelangen Jan 15, 2024
894825d
Merge pull request #25574 from storybookjs/norbert/cli-sandbox-versio…
ndelangen Jan 15, 2024
5ac3a15
Merge pull request #25573 from storybookjs/jeppe/upgrade-versioned-main
ndelangen Jan 15, 2024
a2055b3
Merge pull request #25596 from storybookjs/jeppe/versioned-canary-san…
JReinhold Jan 15, 2024
838d267
init when download-dir = before-storybook
ndelangen Jan 15, 2024
5c11b71
fixes
ndelangen Jan 16, 2024
678515f
Merge pull request #25526 from storybookjs/norbert/init-versioning-main
ndelangen Jan 16, 2024
7772fd7
Merge pull request #25590 from storybookjs/shilman/fix-configfile-exp…
shilman Jan 16, 2024
abaa634
Write changelog for 7.6.9 [skip ci]
storybook-bot Jan 16, 2024
2f96d0f
Merge pull request #25540 from mlazari/next
valentinpalkovic Jan 16, 2024
3017745
add pull 25526 to changelog
JReinhold Jan 16, 2024
0191424
fix wrong assert used in export-order-loader
JReinhold Jan 17, 2024
494e111
add node to tsconfig types array
JReinhold Jan 17, 2024
7f350ca
revert lock file to main
JReinhold Jan 17, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/canary-release-pr.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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`.
<details>
<summary>More information</summary>

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 7.6.9

- ConfigFile: Fix export specifiers - [#25590](https://github.com/storybookjs/storybook/pull/25590), thanks [@shilman](https://github.com/shilman)!
- Webpack5: Make export-order-loader compatible with both esm and cjs - [#25540](https://github.com/storybookjs/storybook/pull/25540), thanks [@mlazari](https://github.com/mlazari)!
- CLI: Support version specifiers in `init`, `upgrade` and `sandbox` - [#25526](https://github.com/storybookjs/storybook/pull/25526), thanks [@ndelangen](https://github.com/ndelangen), [@jreinhold](https://github.com/jreinhold)!

## 7.6.8

- Addon-actions: Fix module resolution for react-native - [#25296](https://github.com/storybookjs/storybook/pull/25296), thanks [@dannyhw](https://github.com/dannyhw)!
Expand Down
1 change: 1 addition & 0 deletions code/builders/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"babel-loader": "^9.0.0",
"browser-assert": "^1.2.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
"cjs-module-lexer": "^1.2.3",
"constants-browserify": "^1.0.0",
"css-loader": "^6.7.1",
"es-module-lexer": "^1.4.1",
Expand Down
66 changes: 45 additions & 21 deletions code/builders/builder-webpack5/src/loaders/export-order-loader.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,58 @@
import { parse } from 'es-module-lexer';
import assert from 'node:assert';
import { parse as parseCjs, init as initCjsParser } from 'cjs-module-lexer';
import { parse as parseEs } from 'es-module-lexer';
import MagicString from 'magic-string';
import type { LoaderContext } from 'webpack';

export default async function loader(this: LoaderContext<any>, source: string) {
export default async function loader(
this: LoaderContext<any>,
source: string,
map: any,
meta: any
) {
const callback = this.async();

try {
// Do NOT remove await here. The types are wrong! It has to be awaited,
// otherwise it will return a Promise<Promise<...>> when wasm isn't loaded.
const [, exports = []] = await parse(source);
const magicString = new MagicString(source);

// Trying to parse as ES module
try {
// Do NOT remove await here. The types are wrong! It has to be awaited,
// otherwise it will return a Promise<Promise<...>> when wasm isn't loaded.
const parseResult = await parseEs(source);
const namedExportsOrder = (parseResult[1] || [])
.map((e) => source.substring(e.s, e.e))
.filter((e) => e !== 'default');

assert(
namedExportsOrder.length > 0,
'No named exports found. Very likely that this is not a ES module.'
);

const namedExportsOrder = exports.some(
(e) => source.substring(e.s, e.e) === '__namedExportsOrder'
);
magicString.append(
`;export const __namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
);
// Try to parse as CJS module
} catch {
await initCjsParser();
const namedExportsOrder = (parseCjs(source).exports || []).filter(
(e: string) => e !== 'default' && e !== '__esModule'
);

if (namedExportsOrder) {
return callback(null, source);
assert(
namedExportsOrder.length > 0,
'No named exports found. Very likely that this is not a CJS module.'
);

magicString.append(
`;module.exports.__namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
);
}

const magicString = new MagicString(source);
const orderedExports = exports.filter((e) => source.substring(e.s, e.e) !== 'default');
magicString.append(
`;export const __namedExportsOrder = ${JSON.stringify(
orderedExports.map((e) => source.substring(e.s, e.e))
)};`
);

const map = magicString.generateMap({ hires: true });
return callback(null, magicString.toString(), map);
const generatedMap = magicString.generateMap({ hires: true });

return callback(null, magicString.toString(), generatedMap, meta);
} catch (err) {
return callback(err as any);
return callback(null, source, map, meta);
}
}
3 changes: 2 additions & 1 deletion code/builders/builder-webpack5/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"strict": true,
"skipLibCheck": true
"skipLibCheck": true,
"types": ["jest", "node"]
},
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion code/frameworks/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ npx storybook@latest init
This framework is designed to work with Storybook 7. If you’re not already using v7, upgrade with this command:

```bash
npx storybook@latest upgrade --prerelease
npx storybook@latest upgrade
```

#### Automatic migration
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/preact-vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ npx storybook@latest init
This framework is designed to work with Storybook 7. If you’re not already using v7, upgrade with this command:

```bash
npx storybook@latest upgrade --prerelease
npx storybook@latest upgrade
```

#### Manual migration
Expand Down
3 changes: 1 addition & 2 deletions code/frameworks/sveltekit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Check out our [Frameworks API](https://storybook.js.org/blog/framework-api/) ann
- [Mocking links](#mocking-links)
- [Troubleshooting](#troubleshooting)
- [Error: `ERR! SyntaxError: Identifier '__esbuild_register_import_meta_url__' has already been declared` when starting Storybook](#error-err-syntaxerror-identifier-__esbuild_register_import_meta_url__-has-already-been-declared-when-starting-storybook)
- [Error: `Cannot read properties of undefined (reading 'disable_scroll_handling')` in preview](#error-cannot-read-properties-of-undefined-reading-disable_scroll_handling-in-preview)
- [Acknowledgements](#acknowledgements)

## Supported features
Expand Down Expand Up @@ -64,7 +63,7 @@ npx storybook@latest init
This framework is designed to work with Storybook 7. If you’re not already using v7, upgrade with this command:

```bash
npx storybook@latest upgrade --prerelease
npx storybook@latest upgrade
```

#### Automatic migration
Expand Down
1 change: 0 additions & 1 deletion code/lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"puppeteer-core": "^2.1.1",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.7",
"simple-update-notifier": "^2.0.0",
"strip-json-comments": "^3.0.1",
"tempy": "^1.0.1",
"ts-dedent": "^2.0.0",
Expand Down
6 changes: 5 additions & 1 deletion code/lib/cli/src/automigrate/fixes/builder-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { writeConfig } from '@storybook/csf-tools';
import type { Fix } from '../types';
import type { PackageJson } from '../../js-package-manager';
import { updateMainConfig } from '../helpers/mainConfigFile';
import { getStorybookVersionSpecifier } from '../../helpers';

const logger = console;

Expand Down Expand Up @@ -68,8 +69,11 @@ export const builderVite: Fix<BuilderViteOptions> = {

logger.info(`✅ Adding '@storybook/builder-vite' as dev dependency`);
if (!dryRun) {
const versionToInstall = getStorybookVersionSpecifier(
await packageManager.retrievePackageJson()
);
await packageManager.addDependencies({ installAsDevDependencies: true }, [
'@storybook/builder-vite',
`@storybook/builder-vite@${versionToInstall}`,
]);
}

Expand Down
6 changes: 4 additions & 2 deletions code/lib/cli/src/automigrate/helpers/checkWebpack5Builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export const checkWebpack5Builder = async ({

To upgrade to the latest stable release, run this from your project directory:

${chalk.cyan('npx storybook upgrade')}
${chalk.cyan('npx storybook@latest upgrade')}

Add the ${chalk.cyan('--prerelease')} flag to get the latest prerelease.
To upgrade to the latest pre-release, run this from your project directory:

${chalk.cyan('npx storybook@next upgrade')}
`.trim()
);
return null;
Expand Down
11 changes: 7 additions & 4 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@ command('babelrc')
.action(() => generateStorybookBabelConfigInCWD());

command('upgrade')
.description('Upgrade your Storybook packages to the latest')
.description(`Upgrade your Storybook packages to v${versions.storybook}`)
.option(
'--package-manager <npm|pnpm|yarn1|yarn2>',
'Force package manager for installing dependencies'
)
.option('-N --use-npm', 'Use NPM to install dependencies (deprecated)')
.option('-y --yes', 'Skip prompting the user')
.option('-n --dry-run', 'Only check for upgrades, do not install')
.option('-t --tag <tag>', 'Upgrade to a certain npm dist-tag (e.g. next, prerelease)')
.option('-p --prerelease', 'Upgrade to the pre-release packages')
.option(
'-t --tag <tag>',
'Upgrade to a certain npm dist-tag (e.g. next, prerelease) (deprecated)'
)
.option('-p --prerelease', 'Upgrade to the pre-release packages (deprecated)')
.option('-s --skip-check', 'Skip postinstall version and automigration checks')
.option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from')
.action(async (options: UpgradeOptions) => upgrade(options).catch(() => process.exit(1)));
Expand Down Expand Up @@ -153,7 +156,7 @@ command('sandbox [filterValue]')
.option('-b --branch <branch>', 'Define the branch to download from', 'next')
.option('--no-init', 'Whether to download a template without an initialized Storybook', false)
.action((filterValue, options) =>
sandbox({ filterValue, ...options }).catch((e) => {
sandbox({ filterValue, ...options }, pkg).catch((e) => {
logger.error(e);
process.exit(1);
})
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/generators/NEXTJS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
{ ...options, builder: CoreBuilder.Webpack5 },
'react',
{
extraAddons: ['@storybook/addon-onboarding'],
extraAddons: ['@storybook/addon-onboarding@^1.0.0'],
},
'nextjs'
);
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/generators/REACT/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'react', {
extraPackages,
useSWC: ({ builder }) => builder === CoreBuilder.Webpack5,
extraAddons: ['@storybook/addon-onboarding'],
extraAddons: ['@storybook/addon-onboarding@^1.0.0'],
});
};

Expand Down
4 changes: 2 additions & 2 deletions code/lib/cli/src/generators/REACT_NATIVE/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const generator = async (
'@storybook/addon-controls@^6.5.16',
];

const resolvedPackages = await packageManager.getVersionedPackages(packagesToResolve);
const versionedPackages = await packageManager.getVersionedPackages(packagesToResolve);

const babelDependencies = await getBabelDependencies(packageManager, packageJson);

const packages = [
...babelDependencies,
...packagesWithFixedVersion,
...resolvedPackages,
...versionedPackages,
missingReactDom && reactVersion && `react-dom@${reactVersion}`,
].filter(Boolean);

Expand Down
7 changes: 1 addition & 6 deletions code/lib/cli/src/generators/REACT_SCRIPTS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import dedent from 'ts-dedent';
import { baseGenerator } from '../baseGenerator';
import type { Generator } from '../types';
import { CoreBuilder } from '../../project_types';
import versions from '../../versions';

const generator: Generator = async (packageManager, npmOptions, options) => {
const monorepoRootPath = path.join(__dirname, '..', '..', '..', '..', '..', '..');
Expand Down Expand Up @@ -47,11 +46,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
// Miscellaneous dependency to add to be sure Storybook + CRA is working fine with Yarn PnP mode
extraPackages.push('prop-types');

const version = versions['@storybook/preset-create-react-app'];
const extraAddons = [
`@storybook/preset-create-react-app@${version}`,
'@storybook/addon-onboarding',
];
const extraAddons = [`@storybook/preset-create-react-app`, '@storybook/addon-onboarding@^1.0.0'];

await baseGenerator(
packageManager,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/generators/WEBPACK_REACT/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Generator } from '../types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'react', {
extraAddons: ['@storybook/addon-onboarding'],
extraAddons: ['@storybook/addon-onboarding@^1.0.0'],
useSWC: ({ builder }) => builder === CoreBuilder.Webpack5,
});
};
Expand Down
11 changes: 5 additions & 6 deletions code/lib/cli/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ export async function baseGenerator(
const versionedPackages = await packageManager.getVersionedPackages(packages);
versionedPackagesSpinner.succeed();

const depsToInstall = [...versionedPackages];

// Add basic babel config for a select few frameworks that need it, if they do not have a babel config file already
if (builder !== CoreBuilder.Vite && !skipBabel) {
const frameworksThatNeedBabelConfig = [
Expand All @@ -349,7 +347,7 @@ export async function baseGenerator(
if (hasNoBabelFile && needsBabelConfig) {
const isTypescript = language !== SupportedLanguage.JAVASCRIPT;
const isReact = rendererId === 'react';
depsToInstall.push(
versionedPackages.push(
...getBabelPresets({
typescript: isTypescript,
jsx: isReact,
Expand All @@ -370,7 +368,7 @@ export async function baseGenerator(

if (hasEslint && !isStorybookPluginInstalled) {
if (skipPrompts || (await suggestESLintPlugin())) {
depsToInstall.push('eslint-plugin-storybook');
versionedPackages.push('eslint-plugin-storybook');
await configureEslintPlugin(eslintConfigFile, packageManager);
}
}
Expand All @@ -379,12 +377,13 @@ export async function baseGenerator(
// any failure regarding configuring the eslint plugin should not fail the whole generator
}

if (depsToInstall.length > 0) {
if (versionedPackages.length > 0) {
const addDependenciesSpinner = ora({
indent: 2,
text: 'Installing Storybook dependencies',
}).start();
await packageManager.addDependencies({ ...npmOptions, packageJson }, depsToInstall);

await packageManager.addDependencies({ ...npmOptions, packageJson }, versionedPackages);
addDependenciesSpinner.succeed();
}

Expand Down
Loading