Skip to content

Commit

Permalink
CLI: add pre-release flag to automigrate
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Aug 11, 2022
1 parent 27d58ad commit a7f3904
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions code/lib/cli/src/automigrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ interface FixOptions {
fixId?: string;
yes?: boolean;
dryRun?: boolean;
prerelease?: boolean;
}

export const automigrate = async ({ fixId, dryRun, yes }: FixOptions = {}) => {
export const automigrate = async ({ fixId, dryRun, yes, prerelease }: FixOptions = {}) => {
const packageManager = JsPackageManagerFactory.getPackageManager();
const filtered = fixId ? fixes.filter((f) => f.id === fixId) : fixes;

Expand Down Expand Up @@ -53,7 +54,7 @@ export const automigrate = async ({ fixId, dryRun, yes }: FixOptions = {}) => {

if (runAnswer.fix) {
try {
await f.run({ result, packageManager, dryRun });
await f.run({ result, packageManager, dryRun, prerelease });
logger.info(`✅ ran ${chalk.cyan(f.id)} migration`);
} catch (error) {
logger.info(`❌ error when running ${chalk.cyan(f.id)} migration:`);
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/automigrate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface RunOptions<ResultType> {
packageManager: JsPackageManager;
result: ResultType;
dryRun?: boolean;
prerelease?: boolean;
}

export interface Fix<ResultType = any> {
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ program
.description('Check storybook for known problems or migrations and apply fixes')
.option('-y --yes', 'Skip prompting the user')
.option('-n --dry-run', 'Only check for fixes, do not actually run them')
.option('-p --prerelease', 'Use pre-release versions when migrating')
.action((fixId, options) =>
automigrate({ fixId, ...options }).catch((e) => {
logger.error(e);
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ export const upgrade = async ({

if (!skipCheck) {
checkVersionConsistency();
await automigrate({ dryRun, yes });
await automigrate({ dryRun, yes, prerelease });
}
};

0 comments on commit a7f3904

Please sign in to comment.