Skip to content

CLI: Add skip onboarding, recommended/minimal config #30930

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

Merged
merged 16 commits into from
May 2, 2025

Conversation

shilman
Copy link
Member

@shilman shilman commented Mar 26, 2025

Closes N/A

What I did

Adds the following prompt to the CLI:

New to Storybook?
> Yes: Help me with onboarding
  No: Skip onboarding & don't ask me again

If the user wants help with onboarding, we'll install the "recommended" setup of dev/docs/test (skipping addon-test if unavailable).

If the user skips onboarding, we won't ask again, but we will prompt for what type of project they want to install:

What configuration should we install?
> Recommended: Component dev, docs, test
  Minimal: Dev only

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Run STORYBOOK_TELEMETRY_DEBUG=1 $PROJECT_ROOT/code/lib/create-storybook/bin/index.cjs in an empty directory.

  1. First time, it should prompt "New to storybook"? Answer yes & verify behavior + telemetry
  2. Second time, it should prompt "New to storybook"? Answer no & verify output + telemetry
  3. Third time, it should prompt "What configuration should we install?"
  4. Delete the settings file and verify that any storybook command causes it to be recreated.

Documentation

  • Updated telemetry.mdx

🦋 Canary release

This pull request has been released as version 0.0.0-pr-30930-sha-9aa8a851. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-30930-sha-9aa8a851
Triggered by @shilman
Repository storybookjs/storybook
Branch shilman/cli-new-users
Commit 9aa8a851
Datetime Thu May 1 13:50:14 UTC 2025 (1746107414)
Workflow run 14776511435

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=30930

Greptile Summary

This PR introduces a new onboarding experience in Storybook's CLI, allowing users to choose between recommended and minimal configurations while tracking preferences through a new Settings system.

  • Added code/core/src/cli/globalSettings.ts for persistent user preferences with JSON storage and dot notation support
  • Added new CLI prompts in code/lib/create-storybook/src/initiate.ts for first-time users to opt into onboarding or choose configuration type
  • Added settingsCreatedAt field in telemetry metadata to track new user decisions
  • Updated telemetry notification message in notify-telemetry.ts for improved clarity
  • Added comprehensive test coverage for Settings class and CLI prompts

@shilman shilman added maintenance User-facing maintenance tasks cli labels Mar 26, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings | Greptile

});

describe('promptInstallType', () => {
const settings = new Settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Settings instance should be initialized in beforeEach to ensure clean state between tests

Comment on lines +139 to +150
it('uses specific prompt options for React Native projects', async () => {
prompts.inject(['recommended']);
const result = await promptInstallType({
settings,
projectType: ProjectType.REACT_NATIVE,
});

expect(result).toBe('recommended');
expect(prompts).not.toHaveBeenCalled();
expect(vi.mocked(telemetry).mock.calls[0][1]).toMatchInlineSnapshot(`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Test description suggests prompting but expects prompts not to be called - either the test name or implementation needs adjustment

Comment on lines +113 to +119
it('prompts user when interactive and yes option is not set', async () => {
prompts.inject(['recommended']);
const result = await promptInstallType({ settings });
expect(result).toBe('recommended');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing telemetry assertion in this test case while other similar tests verify it

Suggested change
it('prompts user when interactive and yes option is not set', async () => {
prompts.inject(['recommended']);
const result = await promptInstallType({ settings });
expect(result).toBe('recommended');
});
it('prompts user when interactive and yes option is not set', async () => {
prompts.inject(['recommended']);
const result = await promptInstallType({ settings });
expect(result).toBe('recommended');
expect(vi.mocked(telemetry).mock.calls[0][1]).toMatchInlineSnapshot({
installType: 'recommended',
step: 'install-type'
});
});

Copy link

nx-cloud bot commented Mar 26, 2025

View your CI Pipeline Execution ↗ for commit 9aa8a85.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 42s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-01 12:41:36 UTC

@tmeasday tmeasday force-pushed the shilman/cli-new-users branch from 514886d to fbf5d2a Compare April 28, 2025 11:42

import { SavingGlobalSettingsFileError } from '../server-errors';

const DEFAULT_SETTINGS_PATH = join(homedir(), '.storybook', 'settings.json');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I foresee issues if we ever use findUp for .storybook in different parts of the CLI and end up finding this package as if it is a config dir. We could be aware of this and try to always limit findUp to only go up until the gitRoot

@shilman shilman merged commit dde78a0 into next May 2, 2025
58 of 59 checks passed
@shilman shilman deleted the shilman/cli-new-users branch May 2, 2025 04:54
@github-actions github-actions bot mentioned this pull request May 2, 2025
9 tasks
@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label May 14, 2025
@github-actions github-actions bot mentioned this pull request May 14, 2025
11 tasks
shilman added a commit that referenced this pull request May 14, 2025
CLI: Add skip onboarding, recommended/minimal config
(cherry picked from commit dde78a0)
This was referenced May 16, 2025
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal cli maintenance User-facing maintenance tasks patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants