Skip to content

Commit bc46f81

Browse files
committed
fix(migrate): summarize skipped git hooks
1 parent 6f97f09 commit bc46f81

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

  • packages/cli/src/migration

packages/cli/src/migration/bin.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ import {
7878
type Framework,
7979
type NodeVersionManagerDetection,
8080
} from './migrator.ts';
81-
import { addMigrationWarning, createMigrationReport, type MigrationReport } from './report.ts';
81+
import {
82+
addManualStep,
83+
addMigrationWarning,
84+
createMigrationReport,
85+
type MigrationReport,
86+
} from './report.ts';
8287

8388
async function confirmNodeVersionFileMigration(
8489
interactive: boolean,
@@ -330,6 +335,7 @@ function parseArgs() {
330335

331336
interface MigrationSetupPlan {
332337
shouldSetupHooks: boolean;
338+
gitHooksSkipReason?: string;
333339
selectedAgentTargetPaths?: string[];
334340
agentConflictDecisions: Map<string, 'append' | 'skip'>;
335341
selectedEditor?: EditorId;
@@ -445,16 +451,18 @@ async function collectGitHooksDecision(
445451
rootDir: string,
446452
packageManager: PackageManager | undefined,
447453
options: MigrationOptions,
448-
): Promise<boolean> {
454+
): Promise<{ shouldSetupHooks: boolean; gitHooksSkipReason?: string }> {
449455
let shouldSetupHooks = await promptGitHooks(options);
456+
let gitHooksSkipReason: string | undefined;
450457
if (shouldSetupHooks) {
451458
const reason = preflightGitHooksSetup(rootDir, packageManager);
452459
if (reason) {
453460
prompts.log.warn(`⚠ ${reason}`);
461+
gitHooksSkipReason = reason;
454462
shouldSetupHooks = false;
455463
}
456464
}
457-
return shouldSetupHooks;
465+
return { shouldSetupHooks, gitHooksSkipReason };
458466
}
459467

460468
async function collectAgentInstructionPlan(
@@ -592,15 +600,15 @@ async function collectMigrationSetupPlan(
592600
packages?: WorkspacePackage[],
593601
includeEslint = true,
594602
): Promise<MigrationSetupPlan> {
595-
const shouldSetupHooks = await collectGitHooksDecision(rootDir, packageManager, options);
603+
const gitHooksPlan = await collectGitHooksDecision(rootDir, packageManager, options);
596604
const agentPlan = await collectAgentInstructionPlan(rootDir, options);
597605
const editorPlan = await collectEditorConfigPlan(rootDir, options);
598606
const eslintPlan = includeEslint
599607
? await collectEslintMigrationDecision(rootDir, options, packages)
600608
: { migrateEslint: false };
601609

602610
return {
603-
shouldSetupHooks,
611+
...gitHooksPlan,
604612
...agentPlan,
605613
...editorPlan,
606614
...eslintPlan,
@@ -1022,6 +1030,9 @@ async function executeMigrationPlan(
10221030
// Without hooks, lint-staged config must stay in package.json so existing
10231031
// .husky/pre-commit scripts that invoke `npx lint-staged` keep working.
10241032
const skipStagedMigration = !plan.shouldSetupHooks;
1033+
if (plan.gitHooksSkipReason) {
1034+
addManualStep(report, `Git hooks were not migrated: ${plan.gitHooksSkipReason}`);
1035+
}
10251036

10261037
// 7. Rewrite configs
10271038
updateMigrationProgress('Rewriting configs');

0 commit comments

Comments
 (0)