-
-
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 refactor #4168
CLI refactor #4168
Conversation
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.
LGTM!
lib/cli/bin/generate.js
Outdated
logger.log(chalk.yellow('To install storybook, use the following command instead:\n')); | ||
codeLog(['storybook init']); | ||
logger.log(); | ||
process.exit(0); |
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.
The depreciation should actually work. I assume getstorybook
should do what storybook init
does.
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.
Sounds logical, will do
lib/cli/bin/generate.js
Outdated
let projectType; | ||
program | ||
.command('build') | ||
.description('Build the Storybook server') |
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.
maybe something like "Build the Storybook static app" ?
lib/cli/lib/initiate.js
Outdated
logger.log(); | ||
paddedLog('There seems to be a storybook already available in this project.'); | ||
paddedLog('Apply following command to force:\n'); | ||
codeLog(['getstorybook -f']); |
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.
getstorybook ?
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.
Oops slipped through, will change
lib/cli/lib/initiate.js
Outdated
default: | ||
paddedLog(`We couldn't detect your project type. (code: ${projectType})`); | ||
paddedLog( | ||
"Please make sure you are running the `getstorybook` command in your project's root directory." |
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.
getstorybook ?
lib/cli/lib/initiate.js
Outdated
"Please make sure you are running the `getstorybook` command in your project's root directory." | ||
); | ||
paddedLog( | ||
'You can also install storybook for plain HTML snippets with `getstorybook --html` or follow some of the slow start guides: https://storybook.js.org/basics/slow-start-guide/' |
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.
getstorybook ?
Codecov Report
@@ Coverage Diff @@
## master #4168 +/- ##
==========================================
- Coverage 40.74% 40.55% -0.19%
==========================================
Files 489 491 +2
Lines 5799 5826 +27
Branches 778 780 +2
==========================================
Hits 2363 2363
- Misses 3062 3087 +25
- Partials 374 376 +2
Continue to review full report at Codecov.
|
@@ -18,7 +18,8 @@ | |||
"license": "MIT", | |||
"author": "Storybook Team", | |||
"bin": { | |||
"getstorybook": "./bin/index.js" | |||
"getstorybook": "./bin/index.js", |
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.
We could also decide to keep these 2 separate, and keep all backwards compatibility in the getstorybook.js file.
That might be easier to remove?
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.
I tried this locally, but when I change the entrypoint for getstorybook
to something else the command is not detected, not sure what's happening here 🤔 the symlink is present tho
This is great! |
That appeals to me, despite the few comments I left |
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.
tiny changes please (at least the --riot parameter)
app/riot/README.md
Outdated
@@ -15,7 +15,7 @@ So you can develop UI components in isolation without worrying about app specifi | |||
```sh | |||
npm i -g @storybook/cli | |||
cd my-app | |||
getstorybook | |||
storybook init --riot |
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.
oops
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.
--riot parameter does not exist yet
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.
I will address this in another PR, see #4168 (comment)
program | ||
.command('start') | ||
.description('Start the local Storybook server') | ||
.option('-N --use-npm', 'Use NPM to start the Storybook server') |
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.
npm is widely used outside storybook in my opinion. We can identify that easily but figuring out wether we have a package-lock.json or a yarn.lock
np is able to do that (https://github.com/sindresorhus/np)
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.
Sorry to say that at the very end of the review process, I did not see your PR earlier.
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.
When the CLI was made, I don't think NPM had the lockfile yet (i think), that's why the flag was added to the command. On the other hand, we can also argue that what should happen when both files are present (for whatever reason). Although I definitely agree with your solution if we want to prioritize NPM over Yarn, or the other way around which happens now, it would be a great idea
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.
also npm-shrinkwrap.json
😅
thanks |
Anything else blocking this? 😊 |
Refactoring the CLI as an initial step to make a richer CLI: #1108 (comment).
It might be needed to introduce some kind of way to persist data down the road for stuff like
--use-npm
, kinda depends on how much options are shared across the different commands.Running
storybook
will display the help menu with all the commands and options.