From 5abe81ad31d6bb9e4cdae1aa9b10c29aaff131a2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 22 Feb 2023 15:15:10 +0100 Subject: [PATCH 1/2] only run initFixes after init --- code/lib/cli/src/automigrate/fixes/index.ts | 4 +++- code/lib/cli/src/automigrate/index.ts | 7 +++++-- code/lib/cli/src/initiate.ts | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/code/lib/cli/src/automigrate/fixes/index.ts b/code/lib/cli/src/automigrate/fixes/index.ts index 2d4ab5aac44d..fff5a5047e37 100644 --- a/code/lib/cli/src/automigrate/fixes/index.ts +++ b/code/lib/cli/src/automigrate/fixes/index.ts @@ -20,7 +20,7 @@ import { bareMdxStoriesGlob } from './bare-mdx-stories-glob'; export * from '../types'; -export const fixes: Fix[] = [ +export const allFixes: Fix[] = [ nodeJsRequirement, cra5, webpack5, @@ -39,3 +39,5 @@ export const fixes: Fix[] = [ addReact, missingBabelRc, ]; + +export const initFixes: Fix[] = [missingBabelRc]; diff --git a/code/lib/cli/src/automigrate/index.ts b/code/lib/cli/src/automigrate/index.ts index 36badae83d90..9f6a978e0518 100644 --- a/code/lib/cli/src/automigrate/index.ts +++ b/code/lib/cli/src/automigrate/index.ts @@ -16,7 +16,7 @@ import { } from '../js-package-manager'; import type { Fix } from './fixes'; -import { fixes as allFixes } from './fixes'; +import { allFixes } from './fixes'; import { cleanLog } from './helpers/cleanLog'; const logger = console; @@ -50,6 +50,7 @@ type FixId = string; interface FixOptions { fixId?: FixId; list?: boolean; + fixes?: Fix[]; yes?: boolean; dryRun?: boolean; useNpm?: boolean; @@ -89,6 +90,7 @@ const logAvailableMigrations = () => { export const automigrate = async ({ fixId, + fixes: inputFixes, dryRun, yes, useNpm, @@ -109,7 +111,8 @@ export const automigrate = async ({ pkgMgr = 'npm'; } - const fixes = fixId ? allFixes.filter((f) => f.id === fixId) : allFixes; + const selectedFixes = inputFixes || allFixes; + const fixes = fixId ? selectedFixes.filter((f) => f.id === fixId) : selectedFixes; if (fixId && fixes.length === 0) { logger.info(`📭 No migrations found for ${chalk.magenta(fixId)}.`); diff --git a/code/lib/cli/src/initiate.ts b/code/lib/cli/src/initiate.ts index c6b3365d26f4..c785941a3cef 100644 --- a/code/lib/cli/src/initiate.ts +++ b/code/lib/cli/src/initiate.ts @@ -36,6 +36,7 @@ import { JsPackageManagerFactory, useNpmWarning } from './js-package-manager'; import type { NpmOptions } from './NpmOptions'; import { automigrate } from './automigrate'; import type { CommandOptions } from './generators/types'; +import { initFixes } from './automigrate/fixes'; const logger = console; @@ -339,7 +340,11 @@ async function doInitiate(options: CommandOptions, pkg: PackageJson): Promise Date: Wed, 22 Feb 2023 16:56:08 +0100 Subject: [PATCH 2/2] add eslint automigration --- code/lib/cli/src/automigrate/fixes/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/cli/src/automigrate/fixes/index.ts b/code/lib/cli/src/automigrate/fixes/index.ts index fff5a5047e37..7bf5b0e4c121 100644 --- a/code/lib/cli/src/automigrate/fixes/index.ts +++ b/code/lib/cli/src/automigrate/fixes/index.ts @@ -40,4 +40,4 @@ export const allFixes: Fix[] = [ missingBabelRc, ]; -export const initFixes: Fix[] = [missingBabelRc]; +export const initFixes: Fix[] = [missingBabelRc, eslintPlugin];