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: Prerelease 8.3.0-beta.3 #29039

Merged
merged 37 commits into from
Sep 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
876264b
move hook usage to the top.
JReinhold Aug 27, 2024
3072e15
remove unused imports
JReinhold Aug 27, 2024
9026bd8
Merge branch 'next' into fix-status-hooks
JReinhold Aug 27, 2024
eb881e5
wip
yannbf Sep 2, 2024
9bd038f
wip: Better logging
ghengeveld Sep 2, 2024
8c97afa
Many improvements
ghengeveld Sep 2, 2024
253623a
Merge branch 'next' into cli/improve-sb-add-messages
ghengeveld Sep 2, 2024
d812d4d
renamed vitest addon import file name to 'test'
Vitorgus Sep 2, 2024
7ca2804
Bail on auto config when a vitest workspace file exists or a vite con…
ghengeveld Sep 3, 2024
22d1814
Consistently use absolute paths
ghengeveld Sep 3, 2024
c38d961
CONSTANT_CASE for constants
ghengeveld Sep 3, 2024
07843b6
Consistently naming the 'Storybook Test' addon
ghengeveld Sep 3, 2024
e399617
Merge pull request #28979 from storybookjs/fix-status-hooks
JReinhold Sep 3, 2024
5e0d8b0
Merge pull request #29031 from Vitorgus/vitest-addon-dir-not-found
yannbf Sep 3, 2024
493a917
additional fixes
yannbf Sep 3, 2024
581e008
add helpful links
yannbf Sep 3, 2024
da69836
Merge branch 'next' into cli/improve-sb-add-messages
yannbf Sep 3, 2024
2b2a83f
add explanation in sb add command
yannbf Sep 3, 2024
8228120
use auto-retrying assertions in e2e tests
JReinhold Sep 3, 2024
01216e1
fix urls in addon-test package.json
JReinhold Sep 3, 2024
53ad1a1
fix tags e2e test
JReinhold Sep 3, 2024
bb3301c
add playwright eslint plugin, fix tests by rules
JReinhold Sep 3, 2024
7d2e30b
review improvements
yannbf Sep 4, 2024
ab66906
Merge pull request #29041 from storybookjs/jeppe/fix-e2e-flake
JReinhold Sep 4, 2024
f1d1896
Merge branch 'next' into cli/improve-sb-add-messages
yannbf Sep 4, 2024
b6b6c24
use named import from dedent
yannbf Sep 4, 2024
b2c4baa
Next.js-Vite: Fix vite plugin exports
valentinpalkovic Sep 4, 2024
30d951f
only install the necessary dependencies
yannbf Sep 4, 2024
75664a0
Merge pull request #29046 from storybookjs/valentin/fix-nextjs-exports
valentinpalkovic Sep 5, 2024
addcce3
Next.js: Update dependencies
valentinpalkovic Sep 5, 2024
4472f10
Merge pull request #29052 from storybookjs/valentin/fix-dependency-req
valentinpalkovic Sep 5, 2024
bd0942c
final fixes
yannbf Sep 5, 2024
8170e25
only append addon to main.js if not already added
yannbf Sep 5, 2024
c8e47c5
Merge pull request #29036 from storybookjs/cli/improve-sb-add-messages
yannbf Sep 5, 2024
f286a1a
fix lint
yannbf Sep 5, 2024
f34c897
Merge pull request #29053 from storybookjs/yann/fix-lint
yannbf Sep 5, 2024
615b74c
Write changelog for 8.3.0-beta.3 [skip ci]
storybook-bot Sep 5, 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
Prev Previous commit
Next Next commit
only install the necessary dependencies
  • Loading branch information
yannbf committed Sep 4, 2024
commit 30d951f0afa57cb5d017532c099a670e1c4ee665
61 changes: 38 additions & 23 deletions code/addons/test/src/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { colors, logger } from 'storybook/internal/node-logger';

import { findUp } from 'find-up';
import { satisfies } from 'semver';
import { satisfies, coerce } from 'semver';
import c from 'tinyrainbow';
import { dedent } from 'ts-dedent';

Expand All @@ -41,11 +41,13 @@ export default async function postInstall(options: PostinstallOptions) {
});

const info = await getFrameworkInfo(options);
const dependencies = ['vitest', '@vitest/browser', 'playwright'];
const optionalDependencies = ['@vitest/coverage-istanbul', '@vitest/coverage-v8'];
const vitestVersion = await packageManager.getInstalledVersion('vitest');
const allDeps = await packageManager.getAllDependencies();
// only install these dependencies if they are not already installed
const dependencies = ['vitest', '@vitest/browser', 'playwright'].filter(p => !allDeps[p]);
const vitestVersionSpecifier = allDeps.vitest || await packageManager.getInstalledVersion('vitest');
const coercedVitestVersion = vitestVersionSpecifier ? coerce(vitestVersionSpecifier) : null;
// if Vitest is installed, we use the same version to keep consistency across Vitest packages
const vitestVersionToInstall = vitestVersion ?? 'latest';
const vitestVersionToInstall = vitestVersionSpecifier ?? 'latest';

const annotationsImport = [
'@storybook/nextjs',
Expand All @@ -59,6 +61,7 @@ export default async function postInstall(options: PostinstallOptions) {
)
? info.rendererPackageName
: null;
const isRendererSupported = !!annotationsImport;

const prerequisiteCheck = async () => {
const reasons = [];
Expand All @@ -72,15 +75,15 @@ export default async function postInstall(options: PostinstallOptions) {
);
}

if (!annotationsImport) {
if (!isRendererSupported) {
reasons.push(dedent`
- The addon cannot yet be used with ${colors.pink.bold(info.frameworkPackageName)}
`);
}

if (vitestVersion && !satisfies(vitestVersion as string, '>=2.0.0')) {
if (coercedVitestVersion && !satisfies(coercedVitestVersion, '>=2.0.0')) {
reasons.push(`
- The addon requires Vitest 2.0.0 or later.
- The addon requires Vitest 2.0.0 or later. You are currently using ${vitestVersionSpecifier}.
Please update your ${colors.pink.bold('vitest')} dependency and try again.
`);
}
Expand All @@ -105,12 +108,23 @@ export default async function postInstall(options: PostinstallOptions) {
in your main Storybook config file and remove the dependency from your package.json file.
`
);
reasons.push(
dedent`
Fear not, however, you can follow the manual installation process instead at:
${c.cyan`https://storybook.js.org/docs/writing-tests/test-runner-with-vitest`}
`
);

if (!isRendererSupported) {
reasons.push(
dedent`
Please check the documentation for more information about its requirements and installation:
${c.cyan`https://storybook.js.org/docs/writing-tests/test-runner-with-vitest`}
`
);
} else {
reasons.push(
dedent`
Fear not, however, you can follow the manual installation process instead at:
${c.cyan`https://storybook.js.org/docs/writing-tests/test-runner-with-vitest#manual`}
`
);
}

return reasons.map((r) => r.trim()).join('\n\n');
}

Expand All @@ -125,13 +139,6 @@ export default async function postInstall(options: PostinstallOptions) {
return;
}

const allDeps = await packageManager.getAllDependencies();
optionalDependencies.forEach((dep) => {
if (allDeps[dep]) {
dependencies.push(dep);
}
});

const vitestInfo = getVitestPluginInfo(info.frameworkPackageName);

if (info.frameworkPackageName === '@storybook/nextjs') {
Expand All @@ -155,13 +162,21 @@ export default async function postInstall(options: PostinstallOptions) {
}
}

const versionedDependencies = dependencies.map((p) => {
if(p.includes('vitest')) {
return `${p}@${vitestVersionToInstall ?? 'latest'}`
}

return p;
})

logger.line(1);
logger.plain(`${step} Installing/updating dependencies:`);
logger.plain(colors.gray(' ' + dependencies.join(', ')));
logger.plain(colors.gray(' ' + versionedDependencies.join(', ')));

await packageManager.addDependencies(
{ installAsDevDependencies: true },
dependencies.map((p) => `${p}@${p.includes('vitest') ? vitestVersionToInstall : 'latest'}`)
versionedDependencies
);

logger.line(1);
Expand Down