Skip to content

Commit

Permalink
feat(@schematics/angular): mark projectRoot as non hidden option in…
Browse files Browse the repository at this point in the history
… application schematic

This option is useful to create an application outside of the `newProjectRoot`.

Related to #23994
  • Loading branch information
alan-agius4 authored and clydin committed Oct 7, 2022
1 parent d8bff4f commit b06421d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/schematics/angular/application/index.ts
Expand Up @@ -247,17 +247,18 @@ 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;
if (/[A-Z]/.test(folderName)) {
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([
Expand All @@ -270,7 +271,6 @@ export default function (options: ApplicationOptions): Rule {
...options,
relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(appDir),
appName: options.name,
isRootApp,
folderName,
}),
move(appDir),
Expand Down
7 changes: 3 additions & 4 deletions packages/schematics/angular/application/schema.json
Expand Up @@ -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": {
Expand Down

0 comments on commit b06421d

Please sign in to comment.