UNPKG

@nx/storybook

Version:

The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.

52 lines (51 loc) â€ĸ 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.callUpgrade = callUpgrade; exports.checkStorybookInstalled = checkStorybookInstalled; const devkit_1 = require("@nx/devkit"); const child_process_1 = require("child_process"); function callUpgrade(schema) { const packageManager = (0, devkit_1.detectPackageManager)(); const pm = (0, devkit_1.getPackageManagerCommand)(packageManager); try { devkit_1.output.log({ title: `Calling sb upgrade`, bodyLines: [ `â„šī¸ Nx will call the Storybook CLI to upgrade your @storybook/* packages to the latest version.`, `📖 You can read more about the Storybook upgrade command here: https://storybook.js.org/docs/react/configure/upgrading`, ], color: 'blue', }); (0, child_process_1.execSync)(`${pm.dlx} ${packageManager === 'yarn' ? 'storybook' : 'storybook@latest'} upgrade ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, { stdio: [0, 1, 2], windowsHide: true, }); devkit_1.output.log({ title: `Storybook packages upgraded.`, bodyLines: [ `â˜‘ī¸ The upgrade command was successful.`, `Your Storybook packages are now at the latest version.`, ], color: 'green', }); } catch (e) { devkit_1.output.log({ title: 'Migration failed', bodyLines: [ `🚨 The Storybook CLI failed to upgrade your @storybook/* packages to the latest version.`, `Please try running the sb upgrade command manually:`, `${pm.exec} storybook@latest upgrade`, ], color: 'red', }); console.log(e); return 1; } } function checkStorybookInstalled(packageJson) { return ((packageJson.dependencies['storybook'] || packageJson.devDependencies['storybook']) && (packageJson.dependencies['@nx/storybook'] || packageJson.devDependencies['@nx/storybook'])); }