fix(angular): add $schema property to generated project configs (#12031)
This commit is contained in:
parent
1c0bebf194
commit
e2bfaa68f7
@ -1,16 +1,15 @@
|
|||||||
import type { Tree } from '@nrwl/devkit';
|
import type { Tree } from '@nrwl/devkit';
|
||||||
import type { NormalizedSchema } from './normalized-schema';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
updateJson,
|
addProjectConfiguration,
|
||||||
getProjects,
|
getProjects,
|
||||||
readProjectConfiguration,
|
|
||||||
updateProjectConfiguration,
|
|
||||||
removeProjectConfiguration,
|
|
||||||
offsetFromRoot,
|
offsetFromRoot,
|
||||||
|
readProjectConfiguration,
|
||||||
|
removeProjectConfiguration,
|
||||||
|
updateJson,
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
|
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
|
||||||
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
|
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
|
||||||
|
import type { NormalizedSchema } from './normalized-schema';
|
||||||
|
|
||||||
export function updateConfigFiles(host: Tree, options: NormalizedSchema) {
|
export function updateConfigFiles(host: Tree, options: NormalizedSchema) {
|
||||||
updateTsConfigOptions(host, options);
|
updateTsConfigOptions(host, options);
|
||||||
@ -88,7 +87,23 @@ function updateAppAndE2EProjectConfigurations(
|
|||||||
|
|
||||||
project.tags = options.parsedTags;
|
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) {
|
if (options.unitTestRunner === UnitTestRunner.None) {
|
||||||
host.delete(`${options.appProjectRoot}/src/app/app.component.spec.ts`);
|
host.delete(`${options.appProjectRoot}/src/app/app.component.spec.ts`);
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
import {
|
import {
|
||||||
|
addProjectConfiguration,
|
||||||
generateFiles,
|
generateFiles,
|
||||||
getWorkspaceLayout,
|
getWorkspaceLayout,
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
offsetFromRoot,
|
offsetFromRoot,
|
||||||
readProjectConfiguration,
|
readProjectConfiguration,
|
||||||
|
removeProjectConfiguration,
|
||||||
Tree,
|
Tree,
|
||||||
updateJson,
|
updateJson,
|
||||||
updateProjectConfiguration,
|
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
|
|
||||||
import { getRelativePathToRootTsConfig } from '@nrwl/workspace/src/utilities/typescript';
|
import { getRelativePathToRootTsConfig } from '@nrwl/workspace/src/utilities/typescript';
|
||||||
|
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { NormalizedSchema } from './normalized-schema';
|
import { NormalizedSchema } from './normalized-schema';
|
||||||
import { updateNgPackage } from './update-ng-package';
|
import { updateNgPackage } from './update-ng-package';
|
||||||
@ -173,7 +174,23 @@ function fixProjectWorkspaceConfig(
|
|||||||
|
|
||||||
delete project.targets.test;
|
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(
|
function updateProjectTsConfig(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user