feat(storybook): show warning about version 5 support drop (#9257)
This commit is contained in:
parent
064d7ec30c
commit
261b35d90b
@ -1,9 +1,11 @@
|
|||||||
import { ExecutorContext, logger } from '@nrwl/devkit';
|
import { ExecutorContext, logger } from '@nrwl/devkit';
|
||||||
import * as build from '@storybook/core/standalone';
|
import * as build from '@storybook/core/standalone';
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
|
import { showStorybookV5Warning } from '../../utils/utilities';
|
||||||
import { CommonNxStorybookConfig } from '../models';
|
import { CommonNxStorybookConfig } from '../models';
|
||||||
import {
|
import {
|
||||||
getStorybookFrameworkPath,
|
getStorybookFrameworkPath,
|
||||||
|
isStorybookLT6,
|
||||||
normalizeAngularBuilderStylesOptions,
|
normalizeAngularBuilderStylesOptions,
|
||||||
resolveCommonStorybookOptionMapper,
|
resolveCommonStorybookOptionMapper,
|
||||||
runStorybookSetupCheck,
|
runStorybookSetupCheck,
|
||||||
@ -30,6 +32,10 @@ export default async function buildStorybookExecutor(
|
|||||||
// print warnings
|
// print warnings
|
||||||
runStorybookSetupCheck(options);
|
runStorybookSetupCheck(options);
|
||||||
|
|
||||||
|
if (isStorybookLT6()) {
|
||||||
|
showStorybookV5Warning(options.uiFramework);
|
||||||
|
}
|
||||||
|
|
||||||
logger.info(`NX Storybook builder starting ...`);
|
logger.info(`NX Storybook builder starting ...`);
|
||||||
await runInstance(option);
|
await runInstance(option);
|
||||||
logger.info(`NX Storybook builder finished ...`);
|
logger.info(`NX Storybook builder finished ...`);
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
import { ExecutorContext, logger } from '@nrwl/devkit';
|
import { ExecutorContext, logger } from '@nrwl/devkit';
|
||||||
import { buildDevStandalone } from '@storybook/core/server';
|
import { buildDevStandalone } from '@storybook/core/server';
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
|
import { showStorybookV5Warning } from '../../utils/utilities';
|
||||||
import { CommonNxStorybookConfig } from '../models';
|
import { CommonNxStorybookConfig } from '../models';
|
||||||
import {
|
import {
|
||||||
getStorybookFrameworkPath,
|
getStorybookFrameworkPath,
|
||||||
normalizeAngularBuilderStylesOptions,
|
normalizeAngularBuilderStylesOptions,
|
||||||
resolveCommonStorybookOptionMapper,
|
resolveCommonStorybookOptionMapper,
|
||||||
runStorybookSetupCheck,
|
runStorybookSetupCheck,
|
||||||
|
isStorybookLT6,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
export interface StorybookExecutorOptions extends CommonNxStorybookConfig {
|
export interface StorybookExecutorOptions extends CommonNxStorybookConfig {
|
||||||
host?: string;
|
host?: string;
|
||||||
@ -34,6 +36,10 @@ export default async function* storybookExecutor(
|
|||||||
// print warnings
|
// print warnings
|
||||||
runStorybookSetupCheck(options);
|
runStorybookSetupCheck(options);
|
||||||
|
|
||||||
|
if (isStorybookLT6()) {
|
||||||
|
showStorybookV5Warning(options.uiFramework);
|
||||||
|
}
|
||||||
|
|
||||||
await runInstance(option);
|
await runInstance(option);
|
||||||
|
|
||||||
yield { success: true };
|
yield { success: true };
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { checkAndCleanWithSemver } from '@nrwl/workspace/src/utilities/version-u
|
|||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
import { existsSync, readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { gte } from 'semver';
|
import { gte, lt } from 'semver';
|
||||||
import {
|
import {
|
||||||
findOrCreateConfig,
|
findOrCreateConfig,
|
||||||
readCurrentWorkspaceStorybookVersionFromExecutor,
|
readCurrentWorkspaceStorybookVersionFromExecutor,
|
||||||
@ -296,6 +296,15 @@ function isStorybookGTE6_4() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isStorybookLT6() {
|
||||||
|
const storybookVersion = readCurrentWorkspaceStorybookVersionFromExecutor();
|
||||||
|
|
||||||
|
return lt(
|
||||||
|
checkAndCleanWithSemver('@storybook/core', storybookVersion),
|
||||||
|
'6.0.0'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function findStorybookAndBuildTargets(targets: {
|
export function findStorybookAndBuildTargets(targets: {
|
||||||
[targetName: string]: TargetConfiguration;
|
[targetName: string]: TargetConfiguration;
|
||||||
}): {
|
}): {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import { join } from 'path';
|
|||||||
import {
|
import {
|
||||||
isFramework,
|
isFramework,
|
||||||
readCurrentWorkspaceStorybookVersionFromGenerator,
|
readCurrentWorkspaceStorybookVersionFromGenerator,
|
||||||
|
showStorybookV5Warning,
|
||||||
TsConfig,
|
TsConfig,
|
||||||
} from '../../utils/utilities';
|
} from '../../utils/utilities';
|
||||||
import { cypressProjectGenerator } from '../cypress-project/cypress-project';
|
import { cypressProjectGenerator } from '../cypress-project/cypress-project';
|
||||||
@ -78,6 +79,10 @@ export async function configurationGenerator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (workspaceStorybookVersion !== '6') {
|
||||||
|
showStorybookV5Warning(rawSchema.uiFramework);
|
||||||
|
}
|
||||||
|
|
||||||
await formatFiles(tree);
|
await formatFiles(tree);
|
||||||
|
|
||||||
return runTasksInSerial(...tasks);
|
return runTasksInSerial(...tasks);
|
||||||
@ -112,6 +117,7 @@ function createRootStorybookDir(
|
|||||||
`adding .storybook folder to the root directory -
|
`adding .storybook folder to the root directory -
|
||||||
based on the Storybook version installed (v${workspaceStorybookVersion}), we'll bootstrap a scaffold for that particular version.`
|
based on the Storybook version installed (v${workspaceStorybookVersion}), we'll bootstrap a scaffold for that particular version.`
|
||||||
);
|
);
|
||||||
|
|
||||||
const templatePath = join(
|
const templatePath = join(
|
||||||
__dirname,
|
__dirname,
|
||||||
workspaceStorybookVersion === '6' ? './root-files' : './root-files-5'
|
workspaceStorybookVersion === '6' ? './root-files' : './root-files-5'
|
||||||
|
|||||||
@ -1,4 +1,10 @@
|
|||||||
import { ExecutorContext, readJson, readJsonFile, Tree } from '@nrwl/devkit';
|
import {
|
||||||
|
ExecutorContext,
|
||||||
|
logger,
|
||||||
|
readJson,
|
||||||
|
readJsonFile,
|
||||||
|
Tree,
|
||||||
|
} from '@nrwl/devkit';
|
||||||
import { CompilerOptions } from 'typescript';
|
import { CompilerOptions } from 'typescript';
|
||||||
import { storybookVersion } from './versions';
|
import { storybookVersion } from './versions';
|
||||||
import { StorybookConfig } from '../executors/models';
|
import { StorybookConfig } from '../executors/models';
|
||||||
@ -198,3 +204,30 @@ function createStorybookConfig(
|
|||||||
);
|
);
|
||||||
return tmpFolder;
|
return tmpFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function showStorybookV5Warning(
|
||||||
|
uiFramework:
|
||||||
|
| '@storybook/angular'
|
||||||
|
| '@storybook/react'
|
||||||
|
| '@storybook/html'
|
||||||
|
| '@storybook/web-components'
|
||||||
|
| '@storybook/vue'
|
||||||
|
| '@storybook/vue3'
|
||||||
|
| '@storybook/svelte'
|
||||||
|
| '@storybook/react-native'
|
||||||
|
) {
|
||||||
|
logger.warn(
|
||||||
|
`It looks like you're using Storybook version 5.
|
||||||
|
Please note that starting with version 14, Nx will drop support for Storybook version 5.
|
||||||
|
Before upgrading to Nx 14, please make sure you have migrated your Storybook configurations
|
||||||
|
to the latest version of Storybook.
|
||||||
|
|
||||||
|
For more information, please take a look at our upgrade guide:
|
||||||
|
${
|
||||||
|
uiFramework === '@storybook/angular'
|
||||||
|
? 'https://nx.dev/storybook/upgrade-storybook-v6-angular'
|
||||||
|
: 'https://nx.dev/storybook/upgrade-storybook-v6-react'
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user