Skip to content

Commit 7112e7e

Browse files
committed
feat(migration): enhance framework shim detection and addition for workspaces
1 parent 7a0e29b commit 7112e7e

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

packages/cli/src/create/bin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,11 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
900900
}
901901
updateCreateProgress('Integrating into monorepo');
902902
rewriteMonorepoProject(fullPath, workspaceInfo.packageManager, undefined, compactOutput);
903+
for (const framework of detectFramework(fullPath)) {
904+
if (!hasFrameworkShim(fullPath, framework)) {
905+
addFrameworkShim(fullPath, framework);
906+
}
907+
}
903908

904909
if (workspaceInfo.packages.length > 0) {
905910
if (options.interactive) {

packages/cli/src/migration/bin.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,19 @@ async function collectMigrationPlan(
520520
}
521521

522522
// 11. Framework shim detection + prompt
523-
const detectedFrameworks = detectFramework(rootDir);
523+
// Collect unique frameworks from root and all workspace packages
524+
const allDetectedFrameworks = new Set<Framework>(detectFramework(rootDir));
525+
for (const pkg of packages ?? []) {
526+
for (const framework of detectFramework(path.join(rootDir, pkg.path))) {
527+
allDetectedFrameworks.add(framework);
528+
}
529+
}
524530
const frameworkShimFrameworks: Framework[] = [];
525-
for (const framework of detectedFrameworks) {
526-
if (!hasFrameworkShim(rootDir, framework)) {
531+
for (const framework of allDetectedFrameworks) {
532+
const anyMissingShim =
533+
!hasFrameworkShim(rootDir, framework) ||
534+
(packages ?? []).some((pkg) => !hasFrameworkShim(path.join(rootDir, pkg.path), framework));
535+
if (anyMissingShim) {
527536
const addShim = await confirmFrameworkShim(framework, options.interactive);
528537
if (addShim) {
529538
frameworkShimFrameworks.push(framework);
@@ -854,7 +863,15 @@ async function executeMigrationPlan(
854863
if (plan.frameworkShimFrameworks) {
855864
updateMigrationProgress('Adding TypeScript shim');
856865
for (const framework of plan.frameworkShimFrameworks) {
857-
addFrameworkShim(workspaceInfo.rootDir, framework, report);
866+
if (!hasFrameworkShim(workspaceInfo.rootDir, framework)) {
867+
addFrameworkShim(workspaceInfo.rootDir, framework, report);
868+
}
869+
for (const pkg of workspaceInfo.packages) {
870+
const pkgPath = path.join(workspaceInfo.rootDir, pkg.path);
871+
if (detectFramework(pkgPath).includes(framework) && !hasFrameworkShim(pkgPath, framework)) {
872+
addFrameworkShim(pkgPath, framework, report);
873+
}
874+
}
858875
}
859876
}
860877

0 commit comments

Comments
 (0)