Skip to content
Prev Previous commit
Next Next commit
fix version detection
  • Loading branch information
ndelangen committed Jan 9, 2024
commit aa02264395b484885f5ddf37b9752ea7860324fc
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 @@ -15,7 +15,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
'react',
{
staticDir,
extraAddons: ['@storybook/addon-onboarding@^2.0.0'],
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@^2.0.0'],
extraAddons: ['@storybook/addon-onboarding@^1.0.0'],
});
};

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@^2.0.0'],
extraAddons: ['@storybook/addon-onboarding@^1.0.0'],
useSWC: ({ builder }) => builder === CoreBuilder.Webpack5,
});
};
Expand Down
30 changes: 16 additions & 14 deletions code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,29 @@ async function doInitiate(
force: pkgMgr,
});

const latestVersion = await packageManager.getVersion('@storybook/cli');
const latestVersion = await packageManager.latestVersion('@storybook/cli');
const currentVersion = versions['@storybook/cli'];
const isPrerelease = !!currentVersion.match(/(beta|rc|canary|future|next)/);
const isPrerelease = !!currentVersion.match(/(alpha|beta|rc|canary|future|next)/);
const isOutdated = lt(currentVersion, latestVersion);
const borderColor = isOutdated ? '#FC521F' : '#F1618C';

const welcome = `Adding storybook version ${currentVersion} to your project..`;
const notLatest = chalk.red(dedent`
Which is behind the latest release: ${latestVersion}!
You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
npx storybook@latest init

You may want to CTRL+C to stop, and run with the latest version instead.
`);
const prelease = chalk.yellow('This is a pre-release version.');
const messages = {
welcome: `Adding storybook version ${chalk.bold(currentVersion)} to your project..`,
notLatest: chalk.red(dedent`
Which is behind the latest release: ${chalk.bold(latestVersion)}!
You likely ran the init command through npx, which can use a locally cached version, to get the latest please run:
npx storybook@latest init

You may want to CTRL+C to stop, and run with the latest version instead.
`),
prelease: chalk.yellow('This is a pre-release version.'),
};

logger.log(
boxen(
[welcome]
.concat(isOutdated ? [notLatest] : [])
.concat(isPrerelease ? [prelease] : [])
[messages.welcome]
.concat(isOutdated && !isPrerelease ? [messages.notLatest] : [])
.concat(isPrerelease ? [messages.prelease] : [])
.join('\n'),
{ borderStyle: 'round', padding: 1, borderColor }
)
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export abstract class JsPackageManager {
return Promise.all(
packages.map(async (pkg) => {
const [packageName, packageVersion] = getPackageDetails(pkg);
const latestInRange = await this.getVersion(packageName, packageVersion);
const latestInRange = await this.latestVersion(packageName, packageVersion);

const k = packageName as keyof typeof storybookPackagesVersions;
const fromData = storybookPackagesVersions[k];
Expand Down