Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): handle paths correctly on windows when migrating angular cli workspaces to nx #10611

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 21 additions & 12 deletions packages/angular/src/generators/ng-add/utilities/app.migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,13 @@ export class AppMigrator extends ProjectMigrator<SupportedTargets> {
this.logger.warn(
`The "${this.targetNames.build}" target does not have the "tsConfig" option configured. Skipping updating the tsConfig file.`
);
} else if (!this.tree.exists(buildDevTsConfig)) {
this.logger.warn(
`The tsConfig file "${buildDevTsConfig}" specified in the "${this.targetNames.build}" target could not be found. Skipping updating the tsConfig file.`
);
} else {
const newBuildDevTsConfig = this.convertPath(buildDevTsConfig);
if (!this.tree.exists(newBuildDevTsConfig)) {
this.logger.warn(
`The tsConfig file "${buildDevTsConfig}" specified in the "${this.targetNames.build}" target could not be found. Skipping updating the tsConfig file.`
);
}
}

this.convertBuildOptions(buildTarget.options ?? {});
Expand Down Expand Up @@ -467,10 +470,13 @@ export class AppMigrator extends ProjectMigrator<SupportedTargets> {
this.logger.warn(
`The "${this.targetNames.server}" target does not have the "tsConfig" option configured. Skipping updating the tsConfig file.`
);
} else if (!this.tree.exists(serverDevTsConfig)) {
this.logger.warn(
`The tsConfig file "${serverDevTsConfig}" specified in the "${this.targetNames.server}" target could not be found. Skipping updating the tsConfig file.`
);
} else {
const newServerDevTsConfig = this.convertPath(serverDevTsConfig);
if (!this.tree.exists(newServerDevTsConfig)) {
this.logger.warn(
`The tsConfig file "${serverDevTsConfig}" specified in the "${this.targetNames.server}" target could not be found. Skipping updating the tsConfig file.`
);
}
}

this.convertServerOptions(serverTarget.options ?? {});
Expand Down Expand Up @@ -534,10 +540,13 @@ export class AppMigrator extends ProjectMigrator<SupportedTargets> {
this.logger.warn(
`The "${this.targetNames.test}" target does not have the "tsConfig" option configured. Skipping updating the tsConfig file.`
);
} else if (!this.tree.exists(testOptions.tsConfig)) {
this.logger.warn(
`The tsConfig file "${testOptions.tsConfig}" specified in the "${this.targetNames.test}" target could not be found. Skipping updating the tsConfig file.`
);
} else {
const newTestTsConfig = this.convertPath(testOptions.tsConfig);
if (!this.tree.exists(newTestTsConfig)) {
this.logger.warn(
`The tsConfig file "${testOptions.tsConfig}" specified in the "${this.targetNames.test}" target could not be found. Skipping updating the tsConfig file.`
);
}
}

testOptions.main = testOptions.main && this.convertAsset(testOptions.main);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class LibMigrator extends ProjectMigrator<SupportedTargets> {
}

async migrate(): Promise<void> {
this.moveProjectFiles();
await this.updateProjectConfiguration();
this.moveProjectFiles();
this.updateNgPackageJson();
this.updateTsConfigs();
this.updateEsLintConfig();
Expand Down Expand Up @@ -259,19 +259,15 @@ export class LibMigrator extends ProjectMigrator<SupportedTargets> {
return;
}

const existEsLintConfigPath = this.tree.exists(this.newEsLintConfigPath);
const existEsLintConfigPath = this.tree.exists(this.oldEsLintConfigPath);
if (!existEsLintConfigPath) {
this.logger.warn(
`The ESLint config file "${this.oldEsLintConfigPath}" could not be found. Skipping updating the file.`
);
}

lintOptions.eslintConfig =
lintOptions.eslintConfig &&
joinPathFragments(
this.project.newRoot,
basename(lintOptions.eslintConfig)
);
lintOptions.eslintConfig && this.newEsLintConfigPath;
lintOptions.lintFilePatterns =
lintOptions.lintFilePatterns &&
lintOptions.lintFilePatterns.map((pattern) => {
Expand Down Expand Up @@ -304,7 +300,7 @@ export class LibMigrator extends ProjectMigrator<SupportedTargets> {
return;
}

const eslintConfig = readJson(this.tree, this.newEsLintConfigPath);
const eslintConfig = readJson(this.tree, this.oldEsLintConfigPath);
if (hasRulesRequiringTypeChecking(eslintConfig)) {
lintOptions.hasTypeAwareRules = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
joinPathFragments,
normalizePath,
offsetFromRoot,
ProjectConfiguration,
readWorkspaceConfiguration,
Expand Down Expand Up @@ -289,7 +290,7 @@ export abstract class ProjectMigrator<TargetType extends string = any> {

protected moveDir(from: string, to: string): void {
visitNotIgnoredFiles(this.tree, from, (file) => {
this.moveFile(file, file.replace(from, to), true);
this.moveFile(file, normalizePath(file).replace(from, to), true);
});
}

Expand Down