-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
CLI: Split create-storybook package from toolbox #28476
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const ignore = 0; | ||
|
||
module.exports = { | ||
overrides: [ | ||
{ | ||
files: 'templates/**/*', | ||
env: { | ||
browser: true, | ||
}, | ||
rules: { | ||
'react/no-this-in-sfc': ignore, | ||
'import/no-unresolved': ignore, | ||
'react/react-in-jsx-scope': ignore, | ||
'import/no-extraneous-dependencies': ignore, | ||
'global-require': ignore, | ||
'no-redeclare': ignore, | ||
'react/prop-types': ignore, | ||
}, | ||
}, | ||
{ | ||
files: 'rendererAssets/**/*', | ||
env: { | ||
browser: true, | ||
}, | ||
rules: { | ||
'jsx-a11y/anchor-is-valid': ignore, | ||
'import/no-unresolved': ignore, | ||
'react/prop-types': ignore, | ||
'react/react-in-jsx-scope': ignore, | ||
'import/no-extraneous-dependencies': ignore, | ||
'import/extensions': ignore, | ||
'import/named': ignore, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Storybook | ||
|
||
## Toolbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env node | ||
|
||
const majorNodeVersion = parseInt(process.versions.node, 10); | ||
if (majorNodeVersion < 18) { | ||
console.error('To run Storybook you need to have Node.js 18 or higher'); | ||
process.exit(1); | ||
} | ||
|
||
// The Storybook CLI has a catch block for all of its commands, but if an error | ||
// occurs before the command even runs, for instance, if an import fails, then | ||
// such error will fall under the uncaughtException handler. | ||
// This is the earliest moment we can catch such errors. | ||
process.once('uncaughtException', (error) => { | ||
if (error.message.includes('string-width')) { | ||
console.error( | ||
[ | ||
'🔴 Error: It looks like you are having a known issue with package hoisting.', | ||
'Please check the following issue for details and solutions: https://github.com/storybookjs/storybook/issues/22431#issuecomment-1630086092\n\n', | ||
].join('\n') | ||
); | ||
} | ||
|
||
throw error; | ||
}); | ||
|
||
require('../dist/generate.cjs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"name": "create-storybook", | ||
"version": "8.2.0-beta.0", | ||
"description": "Storybook's Toolbox", | ||
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/lib/toolbox", | ||
"bugs": { | ||
"url": "https://github.com/storybookjs/storybook/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/storybookjs/storybook.git", | ||
"directory": "code/lib/toolbox" | ||
}, | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/storybook" | ||
}, | ||
"license": "MIT", | ||
"author": "Storybook Team", | ||
"type": "module", | ||
"exports": { | ||
"./bin/index.cjs": { | ||
"node": "./bin/index.cjs", | ||
"require": "./bin/index.cjs" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"bin": "./bin/index.cjs", | ||
"files": [ | ||
"bin/**/*", | ||
"dist/**/*", | ||
"rendererAssets/**/*", | ||
"templates/**/*", | ||
"README.md", | ||
"!src/**/*" | ||
], | ||
"scripts": { | ||
"check": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts", | ||
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts" | ||
}, | ||
"dependencies": { | ||
"@ndelangen/get-tarball": "^3.0.7", | ||
"@storybook/core": "workspace:*", | ||
"@types/semver": "^7.3.4", | ||
"chalk": "^4.1.0", | ||
"commander": "^6.2.1", | ||
"execa": "^5.0.0", | ||
"fd-package-json": "^1.2.0", | ||
"find-up": "^5.0.0", | ||
"fs-extra": "^11.1.0", | ||
"get-npm-tarball-url": "^2.0.3", | ||
"ora": "^5.4.1", | ||
"prettier": "^3.1.1", | ||
"prompts": "^2.4.0", | ||
"semver": "^7.3.7", | ||
"strip-json-comments": "^3.0.1", | ||
"tempy": "^3.1.0", | ||
"tiny-invariant": "^1.3.1", | ||
"ts-dedent": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/prompts": "^2.0.9", | ||
"@types/util-deprecate": "^1.0.0", | ||
"boxen": "^7.1.1", | ||
"strip-json-comments": "^3.1.1", | ||
"typescript": "^5.3.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bundler": { | ||
"entries": [ | ||
"./src/generate.ts" | ||
], | ||
"platform": "node" | ||
}, | ||
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "create-storybook", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "library", | ||
"targets": { | ||
"build": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type NpmOptions = { | ||
skipInstall?: boolean; | ||
installAsDevDependencies?: boolean; | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import program from 'commander'; | ||
import { findPackageSync } from 'fd-package-json'; | ||
import invariant from 'tiny-invariant'; | ||
import { addToGlobalContext } from '@storybook/core/telemetry'; | ||
import { versions } from '@storybook/core/common'; | ||
|
||
import type { CommandOptions } from './generators/types'; | ||
import { initiate } from './initiate'; | ||
|
||
addToGlobalContext('cliVersion', versions.storybook); | ||
|
||
const pkg = findPackageSync(__dirname); | ||
invariant(pkg, 'Failed to find the closest package.json file.'); | ||
|
||
program | ||
.name('Initialize Storybook into your project.') | ||
.option( | ||
'--disable-telemetry', | ||
'Disable sending telemetry data', | ||
// default value is false, but if the user sets STORYBOOK_DISABLE_TELEMETRY, it can be true | ||
process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMETRY !== 'false' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪶 style: Consider adding a default value for |
||
) | ||
.option('--debug', 'Get more logs in debug mode', false) | ||
.option('--enable-crash-reports', 'Enable sending crash reports to telemetry data') | ||
.option('-f --force', 'Force add Storybook') | ||
.option('-s --skip-install', 'Skip installing deps') | ||
.option('--package-manager <npm|pnpm|yarn1|yarn2>', 'Force package manager for installing deps') | ||
.option('--use-pnp', 'Enable pnp mode for Yarn 2+') | ||
.option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser') | ||
.option('-t --type <type>', 'Add Storybook for a specific project type') | ||
.option('-y --yes', 'Answer yes to all prompts') | ||
.option('-b --builder <webpack5 | vite>', 'Builder library') | ||
.option('-l --linkable', 'Prepare installation for link (contributor helper)') | ||
// due to how Commander handles default values and negated options, we have to elevate the default into Commander, and we have to specify `--dev` | ||
// alongside `--no-dev` even if we are unlikely to directly use `--dev`. https://github.com/tj/commander.js/issues/2068#issuecomment-1804524585 | ||
.option( | ||
'--dev', | ||
'Launch the development server after completing initialization. Enabled by default', | ||
process.env.CI !== 'true' && process.env.IN_STORYBOOK_SANDBOX !== 'true' | ||
) | ||
.option( | ||
'--no-dev', | ||
'Complete the initialization of Storybook without launching the Storybook development server' | ||
) | ||
.action((options: CommandOptions) => { | ||
initiate(options).catch(() => process.exit(1)); | ||
}) | ||
.version(String(pkg.version)) | ||
.parse(process.argv); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪶 style: Consider using a more descriptive variable name instead of 'ignore' to improve readability.