fix(angular): fix chalk import and correctly skip invalid projects in ng-add generator (#26667)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #26654
This commit is contained in:
parent
47dfdcfc6b
commit
8872ca5c8f
@ -52,6 +52,18 @@ describe('app migrator', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should not migrate project when validation fails', async () => {
|
||||
// add project with no root
|
||||
const project = addProject('app1', {} as any);
|
||||
const migrator = new AppMigrator(tree, {}, project);
|
||||
|
||||
await migrator.migrate();
|
||||
|
||||
expect(tree.exists('apps/app1/project.json')).toBe(false);
|
||||
const { projects } = readJson(tree, 'angular.json');
|
||||
expect(projects.app1).toBeDefined();
|
||||
});
|
||||
|
||||
describe('validation', () => {
|
||||
it('should fail validation when the project root is not specified', async () => {
|
||||
const project = addProject('app1', {} as any);
|
||||
|
||||
@ -103,12 +103,12 @@ export class AppMigrator extends ProjectMigrator<SupportedTargets> {
|
||||
}
|
||||
|
||||
override async migrate(): Promise<void> {
|
||||
await super.migrate();
|
||||
|
||||
if (this.skipMigration === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
await super.migrate();
|
||||
|
||||
this.updateProjectConfiguration();
|
||||
|
||||
await this.e2eMigrator.migrate();
|
||||
|
||||
@ -50,6 +50,18 @@ describe('lib migrator', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should not migrate project when validation fails', async () => {
|
||||
// add project with no root
|
||||
const project = addProject('lib1', {} as any);
|
||||
const migrator = new LibMigrator(tree, {}, project);
|
||||
|
||||
await migrator.migrate();
|
||||
|
||||
expect(tree.exists('libs/lib1/project.json')).toBe(false);
|
||||
const { projects } = readJson(tree, 'angular.json');
|
||||
expect(projects.lib1).toBeDefined();
|
||||
});
|
||||
|
||||
describe('validation', () => {
|
||||
it('should fail validation when the project root is not specified', async () => {
|
||||
const project = addProject('lib1', {} as any);
|
||||
|
||||
@ -41,12 +41,12 @@ export class LibMigrator extends ProjectMigrator {
|
||||
}
|
||||
|
||||
override async migrate(): Promise<void> {
|
||||
await super.migrate();
|
||||
|
||||
if (this.skipMigration === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
await super.migrate();
|
||||
|
||||
await this.updateProjectConfiguration();
|
||||
this.moveProjectFiles();
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import * as chalk from 'chalk';
|
||||
import chalk = require('chalk');
|
||||
import {
|
||||
arrayToString,
|
||||
getProjectValidationResultMessage,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import * as chalk from 'chalk';
|
||||
import chalk = require('chalk');
|
||||
import type { ValidationError } from './types';
|
||||
|
||||
export function arrayToString(array: string[]): string {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user