Merge branch 'tom/sb-512-angular-14' into tom/sb-606-migrate-stories-and-delete-angular-cli

This commit is contained in:
Tom Coleman 2022-09-16 15:24:46 +10:00
commit b5cc92b087
2 changed files with 9 additions and 16 deletions

View File

@ -1,6 +1,6 @@
import './globals';
export { render, renderToDOM } from './render';
export { decorateStory } from './decorateStory';
export { decorateStory as applyDecorators } from './decorateStory';
export const parameters = { framework: 'angular' as const };

View File

@ -180,19 +180,17 @@ async function findFirstPath(paths: string[], { cwd }: { cwd: string }) {
return null;
}
async function addPackageScripts({
cwd,
scripts,
}: {
cwd: string;
scripts: Record<string, string>;
}) {
async function updatePackageScripts({ cwd, prefix }: { cwd: string; prefix: string }) {
logger.info(`🔢 Adding package scripts:`);
const packageJsonPath = path.join(cwd, 'package.json');
const packageJson = await readJSON(packageJsonPath);
packageJson.scripts = {
...packageJson.scripts,
...scripts,
storybook: packageJson.scripts.storybook.replace(/(npx )?storybook/, `${prefix} storybook`),
'build-storybook': packageJson.scripts['build-storybook'].replace(
/(npx )?storybook/,
`${prefix} storybook`
),
};
await writeJSON(packageJsonPath, packageJson, { spaces: 2 });
}
@ -507,14 +505,9 @@ export async function sandbox(optionValues: OptionValues<typeof options>) {
// Some addon stories require extra dependencies
addExtraDependencies({ cwd, dryRun, debug });
await addPackageScripts({
await updatePackageScripts({
cwd,
scripts: {
storybook:
'NODE_OPTIONS="--preserve-symlinks --preserve-symlinks-main" storybook dev -p 6006',
'build-storybook':
'NODE_OPTIONS="--preserve-symlinks --preserve-symlinks-main" storybook build',
},
prefix: 'NODE_OPTIONS="--preserve-symlinks --preserve-symlinks-main"',
});
}