Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { readFileSync, writeFileSync } from 'fs';
import picocolors from 'picocolors';

import { findFilesUp } from '../../util';
import type { Fix } from '../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { getAddonNames, removeAddon } from 'storybook/internal/common';

import picocolors from 'picocolors';

import type { Fix } from '../types';

type AddonMdxGfmOptions = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function isValidVersionType(packageName: string, specifier: string) {
export const upgradeStorybookRelatedDependencies = {
id: 'upgrade-storybook-related-dependencies',
promptType: 'auto',
promptDefaultValue: false,
defaultSelected: false,

async check({ packageManager, storybookVersion }) {
logger.debug('Checking for incompatible storybook packages...');
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli-storybook/src/automigrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export async function runFixes({
const shouldRun = await prompt.confirm(
{
message: `Do you want to run the '${picocolors.cyan(f.id)}' migration on your project?`,
initialValue: f.promptDefaultValue ?? true,
initialValue: f.defaultSelected ?? true,
},
{
onCancel: () => {
Expand Down
3 changes: 2 additions & 1 deletion code/lib/cli-storybook/src/automigrate/multi-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,14 @@ export async function promptForAutomigrations(
value: am.fix.id,
label,
hint: hint.join('\n'),
defaultSelected: am.fix.defaultSelected ?? true,
};
});

const selectedIds = await prompt.multiselect({
message: 'Select automigrations to run',
options: choices,
initialValues: choices.map((c) => c.value),
initialValues: choices.filter((c) => c.defaultSelected).map((c) => c.value),
});

return automigrations.filter((am) => selectedIds.includes(am.fix.id));
Expand Down
3 changes: 2 additions & 1 deletion code/lib/cli-storybook/src/automigrate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type BaseFix<ResultType = any> = {
check: (options: CheckOptions) => Promise<ResultType | null>;
/** Keep the prompt message short and concise. */
prompt: () => string;
promptDefaultValue?: boolean;
/** Whether the automigration is selected by default when the user is prompted. */
defaultSelected?: boolean;
link?: string;
};

Expand Down
1 change: 1 addition & 0 deletions code/lib/cli-storybook/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ command('automigrate [fixId]')
)
.option('--skip-doctor', 'Skip doctor check')
.action(async (fixId, options) => {
prompt.setPromptLibrary('clack');
await doAutomigrate({ fixId, ...options }).catch(handleCommandFailure);
});

Expand Down