From b79fda13d75241896c00dfb356bd6cb18ac263c2 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 5 Mar 2026 14:15:18 +0100 Subject: [PATCH 1/5] fix(create-plugin): only set root config version and commit if migrations ran --- .../create-plugin/src/codemods/migrations/manager.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/create-plugin/src/codemods/migrations/manager.ts b/packages/create-plugin/src/codemods/migrations/manager.ts index 937e9cc84f..6cf43435eb 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.ts @@ -43,9 +43,12 @@ export async function runMigrations(migrations: Migration[], options: RunMigrati } } - setRootConfig({ version: CURRENT_APP_VERSION }); + // Only set the version in the config file if there were migrations to run. + if (migrations.length > 0) { + setRootConfig({ version: CURRENT_APP_VERSION }); - if (options.commitEachMigration) { - await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`); + if (options.commitEachMigration) { + await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`); + } } } From 5b961eb97be1a9bb557a27c8c6e3607b32019276 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 5 Mar 2026 14:44:07 +0100 Subject: [PATCH 2/5] feat(create-plugin): if no migrations run don't show success message, just exit --- packages/create-plugin/src/codemods/migrations/manager.ts | 3 ++- packages/create-plugin/src/commands/update.command.ts | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/create-plugin/src/codemods/migrations/manager.ts b/packages/create-plugin/src/codemods/migrations/manager.ts index 6cf43435eb..fe4d0ccae0 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.ts @@ -28,7 +28,8 @@ type RunMigrationsOptions = { export async function runMigrations(migrations: Migration[], options: RunMigrationsOptions = {}) { const migrationList = migrations.map((meta) => `${meta.name} (${meta.description})`); - const migrationListBody = migrationList.length > 0 ? output.bulletList(migrationList) : ['No migrations to run.']; + const migrationListBody = + migrationList.length > 0 ? output.bulletList(migrationList) : ['No migrations to run. Exiting.']; output.log({ title: 'Running the following migrations:', body: migrationListBody }); diff --git a/packages/create-plugin/src/commands/update.command.ts b/packages/create-plugin/src/commands/update.command.ts index 39ba0541ae..670d359390 100644 --- a/packages/create-plugin/src/commands/update.command.ts +++ b/packages/create-plugin/src/commands/update.command.ts @@ -38,9 +38,11 @@ export const update = async (argv: minimist.ParsedArgs) => { commitEachMigration: !!argv.commit, codemodOptions, }); - output.success({ - title: `Successfully updated create-plugin from ${version} to ${CURRENT_APP_VERSION}.`, - }); + if (migrations.length > 0) { + output.success({ + title: `Successfully updated create-plugin from ${version} to ${CURRENT_APP_VERSION}.`, + }); + } } catch (error) { if (error instanceof Error) { output.error({ From c5890ca7327f6062d092a3cce184b5e942f4692e Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 5 Mar 2026 15:24:49 +0100 Subject: [PATCH 3/5] feat(create-plugin): await setConfig and add test --- .../create-plugin/src/codemods/migrations/manager.test.ts | 6 ++++++ packages/create-plugin/src/codemods/migrations/manager.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/create-plugin/src/codemods/migrations/manager.test.ts b/packages/create-plugin/src/codemods/migrations/manager.test.ts index aff77a89e6..f9f3d76f5f 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.test.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.test.ts @@ -223,6 +223,12 @@ describe('Migrations', () => { expect(setRootConfig).toHaveBeenCalledWith({ version: '2.0.0' }); }); + it('should NOT update version in ".config/.cprc.json" if there are no migrations to run', async () => { + await runMigrations([]); + + expect(setRootConfig).not.toHaveBeenCalled(); + }); + it('should NOT update version in ".config/.cprc.json" if any of the migrations fail', async () => { migrationTwoFn.mockImplementation(async () => { throw new Error('Unknown error.'); diff --git a/packages/create-plugin/src/codemods/migrations/manager.ts b/packages/create-plugin/src/codemods/migrations/manager.ts index fe4d0ccae0..dd93c56c47 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.ts @@ -46,7 +46,7 @@ export async function runMigrations(migrations: Migration[], options: RunMigrati // Only set the version in the config file if there were migrations to run. if (migrations.length > 0) { - setRootConfig({ version: CURRENT_APP_VERSION }); + await setRootConfig({ version: CURRENT_APP_VERSION }); if (options.commitEachMigration) { await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`); From fdaff0c2d55001ec9d90fbd346106d58236e6eee Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 5 Mar 2026 18:25:13 +0100 Subject: [PATCH 4/5] Update packages/create-plugin/src/codemods/migrations/manager.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../create-plugin/src/codemods/migrations/manager.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/create-plugin/src/codemods/migrations/manager.test.ts b/packages/create-plugin/src/codemods/migrations/manager.test.ts index f9f3d76f5f..c42e519278 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.test.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.test.ts @@ -229,6 +229,12 @@ describe('Migrations', () => { expect(setRootConfig).not.toHaveBeenCalled(); }); + it('should NOT create any commits if there are no migrations to run, even when commitEachMigration is true', async () => { + await runMigrations([], { commitEachMigration: true }); + + expect(setRootConfig).not.toHaveBeenCalled(); + expect(gitCommitNoVerify).not.toHaveBeenCalled(); + }); it('should NOT update version in ".config/.cprc.json" if any of the migrations fail', async () => { migrationTwoFn.mockImplementation(async () => { throw new Error('Unknown error.'); From b2715121dae648c0bb1b23a43dc53ce425b8bcb2 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Fri, 6 Mar 2026 14:34:37 +0100 Subject: [PATCH 5/5] refactor(create-plugin): move check for migrations to run to update command and bail early --- .../src/codemods/migrations/manager.test.ts | 12 ------------ .../src/codemods/migrations/manager.ts | 12 ++++-------- .../src/commands/update.command.ts | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/packages/create-plugin/src/codemods/migrations/manager.test.ts b/packages/create-plugin/src/codemods/migrations/manager.test.ts index c42e519278..aff77a89e6 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.test.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.test.ts @@ -223,18 +223,6 @@ describe('Migrations', () => { expect(setRootConfig).toHaveBeenCalledWith({ version: '2.0.0' }); }); - it('should NOT update version in ".config/.cprc.json" if there are no migrations to run', async () => { - await runMigrations([]); - - expect(setRootConfig).not.toHaveBeenCalled(); - }); - - it('should NOT create any commits if there are no migrations to run, even when commitEachMigration is true', async () => { - await runMigrations([], { commitEachMigration: true }); - - expect(setRootConfig).not.toHaveBeenCalled(); - expect(gitCommitNoVerify).not.toHaveBeenCalled(); - }); it('should NOT update version in ".config/.cprc.json" if any of the migrations fail', async () => { migrationTwoFn.mockImplementation(async () => { throw new Error('Unknown error.'); diff --git a/packages/create-plugin/src/codemods/migrations/manager.ts b/packages/create-plugin/src/codemods/migrations/manager.ts index dd93c56c47..18ed1786c6 100644 --- a/packages/create-plugin/src/codemods/migrations/manager.ts +++ b/packages/create-plugin/src/codemods/migrations/manager.ts @@ -28,8 +28,7 @@ type RunMigrationsOptions = { export async function runMigrations(migrations: Migration[], options: RunMigrationsOptions = {}) { const migrationList = migrations.map((meta) => `${meta.name} (${meta.description})`); - const migrationListBody = - migrationList.length > 0 ? output.bulletList(migrationList) : ['No migrations to run. Exiting.']; + const migrationListBody = migrationList.length > 0 ? output.bulletList(migrationList) : ['No migrations to run.']; output.log({ title: 'Running the following migrations:', body: migrationListBody }); @@ -44,12 +43,9 @@ export async function runMigrations(migrations: Migration[], options: RunMigrati } } - // Only set the version in the config file if there were migrations to run. - if (migrations.length > 0) { - await setRootConfig({ version: CURRENT_APP_VERSION }); + await setRootConfig({ version: CURRENT_APP_VERSION }); - if (options.commitEachMigration) { - await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`); - } + if (options.commitEachMigration) { + await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`); } } diff --git a/packages/create-plugin/src/commands/update.command.ts b/packages/create-plugin/src/commands/update.command.ts index 670d359390..fd61e7aa41 100644 --- a/packages/create-plugin/src/commands/update.command.ts +++ b/packages/create-plugin/src/commands/update.command.ts @@ -32,17 +32,24 @@ export const update = async (argv: minimist.ParsedArgs) => { } const migrations = getMigrationsToRun(version, CURRENT_APP_VERSION); + + if (migrations.length === 0) { + output.log({ + title: 'No migrations to run, exiting.', + }); + + process.exit(0); + } + // filter out minimist internal properties (_ and $0) before passing to codemod const { _, $0, ...codemodOptions } = argv; await runMigrations(migrations, { commitEachMigration: !!argv.commit, codemodOptions, }); - if (migrations.length > 0) { - output.success({ - title: `Successfully updated create-plugin from ${version} to ${CURRENT_APP_VERSION}.`, - }); - } + output.success({ + title: `Successfully updated create-plugin from ${version} to ${CURRENT_APP_VERSION}.`, + }); } catch (error) { if (error instanceof Error) { output.error({