From 89746adf61dad05bc2ba96270b98b9fa601749d7 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 11 Sep 2024 09:28:43 -0400 Subject: [PATCH] feat(core): import warns when source and destination directories are different --- packages/nx/src/command-line/import/import.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/nx/src/command-line/import/import.ts b/packages/nx/src/command-line/import/import.ts index 21d91e4cc7bd69..d9c18918c3c2cf 100644 --- a/packages/nx/src/command-line/import/import.ts +++ b/packages/nx/src/command-line/import/import.ts @@ -210,6 +210,8 @@ export async function importHandler(options: ImportOptions) { packageManager ); + const sourceIsNxWorkspace = existsSync(join(sourceGitClient.root, 'nx.json')); + const relativeDestination = relative( destinationGitClient.root, absDestination @@ -310,6 +312,19 @@ export async function importHandler(options: ImportOptions) { await warnOnMissingWorkspacesEntry(packageManager, pmc, relativeDestination); + if (source != destination) { + output.warn({ + title: `Check configuration files`, + bodyLines: [ + `The source directory (${source}) and destination directory (${destination}) are different.`, + `You may need to update configuration files to match the directory in this repository.`, + sourceIsNxWorkspace + ? `For example, path options in project.json such as "main", "tsConfig", "outputPath" need to be updated.` + : `For example, relative paths in tsconfig.json and other tooling config files may need to be updated.`, + ], + }); + } + // When only a subdirectory is imported, there might be devDependencies in the root package.json file // that needs to be ported over as well. if (ref) {