fix(angular): add $schema property to generated project configs (#12031)

This commit is contained in:
Leosvel Pérez Espinosa 2022-09-16 10:11:46 +01:00 committed by GitHub
parent 1c0bebf194
commit e2bfaa68f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 10 deletions

View File

@ -1,16 +1,15 @@
import type { Tree } from '@nrwl/devkit';
import type { NormalizedSchema } from './normalized-schema';
import {
updateJson,
addProjectConfiguration,
getProjects,
readProjectConfiguration,
updateProjectConfiguration,
removeProjectConfiguration,
offsetFromRoot,
readProjectConfiguration,
removeProjectConfiguration,
updateJson,
} from '@nrwl/devkit';
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
import type { NormalizedSchema } from './normalized-schema';
export function updateConfigFiles(host: Tree, options: NormalizedSchema) {
updateTsConfigOptions(host, options);
@ -88,7 +87,23 @@ function updateAppAndE2EProjectConfigurations(
project.tags = options.parsedTags;
updateProjectConfiguration(host, options.name, project);
/**
* The "$schema" property on our configuration files is only added when the
* project configuration is added and not when updating it. It's done this
* way to avoid re-adding "$schema" when updating a project configuration
* and that property was intentionally removed by the devs.
*
* Since the project gets created by the Angular application schematic,
* the "$schema" property is not added, so we remove the project and add
* it back to workaround that.
*/
removeProjectConfiguration(host, options.name);
addProjectConfiguration(
host,
options.name,
project,
options.standaloneConfig
);
if (options.unitTestRunner === UnitTestRunner.None) {
host.delete(`${options.appProjectRoot}/src/app/app.component.spec.ts`);

View File

@ -1,15 +1,16 @@
import {
addProjectConfiguration,
generateFiles,
getWorkspaceLayout,
joinPathFragments,
offsetFromRoot,
readProjectConfiguration,
removeProjectConfiguration,
Tree,
updateJson,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
import { getRelativePathToRootTsConfig } from '@nrwl/workspace/src/utilities/typescript';
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
import * as path from 'path';
import { NormalizedSchema } from './normalized-schema';
import { updateNgPackage } from './update-ng-package';
@ -173,7 +174,23 @@ function fixProjectWorkspaceConfig(
delete project.targets.test;
updateProjectConfiguration(host, options.name, project);
/**
* The "$schema" property on our configuration files is only added when the
* project configuration is added and not when updating it. It's done this
* way to avoid re-adding "$schema" when updating a project configuration
* and that property was intentionally removed by the devs.
*
* Since the project gets created by the Angular application schematic,
* the "$schema" property is not added, so we remove the project and add
* it back to workaround that.
*/
removeProjectConfiguration(host, options.name);
addProjectConfiguration(
host,
options.name,
project,
options.standaloneConfig
);
}
function updateProjectTsConfig(