From b06421d15e4b5e6daffcb73ee1c2c8703b72cb47 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 7 Oct 2022 11:27:14 +0000 Subject: [PATCH] feat(@schematics/angular): mark `projectRoot` as non hidden option in application schematic This option is useful to create an application outside of the `newProjectRoot`. Related to https://github.com/angular/angular-cli/pull/23994 --- packages/schematics/angular/application/index.ts | 10 +++++----- packages/schematics/angular/application/schema.json | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index 680c2b8091..fdf7ae347c 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -247,7 +247,6 @@ export default function (options: ApplicationOptions): Rule { const workspace = await getWorkspace(host); const newProjectRoot = (workspace.extensions.newProjectRoot as string | undefined) || ''; - const isRootApp = options.projectRoot !== undefined; // If scoped project (i.e. "@foo/bar"), convert dir to "foo/bar". let folderName = options.name.startsWith('@') ? options.name.slice(1) : options.name; @@ -255,9 +254,11 @@ export default function (options: ApplicationOptions): Rule { folderName = strings.dasherize(folderName); } - const appDir = isRootApp - ? normalize(options.projectRoot || '') - : join(normalize(newProjectRoot), folderName); + const appDir = + options.projectRoot === undefined + ? join(normalize(newProjectRoot), folderName) + : normalize(options.projectRoot); + const sourceDir = `${appDir}/src/app`; return chain([ @@ -270,7 +271,6 @@ export default function (options: ApplicationOptions): Rule { ...options, relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(appDir), appName: options.name, - isRootApp, folderName, }), move(appDir), diff --git a/packages/schematics/angular/application/schema.json b/packages/schematics/angular/application/schema.json index f98934c0f7..b4ffa981cb 100644 --- a/packages/schematics/angular/application/schema.json +++ b/packages/schematics/angular/application/schema.json @@ -7,12 +7,11 @@ "additionalProperties": false, "properties": { "projectRoot": { - "description": "The root directory of the new app.", - "type": "string", - "visible": false + "description": "The root directory of the new application.", + "type": "string" }, "name": { - "description": "The name of the new app.", + "description": "The name of the new application.", "type": "string", "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$", "$default": {