mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 20:02:40 +08:00
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
This commit is contained in:
parent
d8bff4f1e6
commit
b06421d15e
@ -247,7 +247,6 @@ export default function (options: ApplicationOptions): Rule {
|
|||||||
|
|
||||||
const workspace = await getWorkspace(host);
|
const workspace = await getWorkspace(host);
|
||||||
const newProjectRoot = (workspace.extensions.newProjectRoot as string | undefined) || '';
|
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".
|
// If scoped project (i.e. "@foo/bar"), convert dir to "foo/bar".
|
||||||
let folderName = options.name.startsWith('@') ? options.name.slice(1) : options.name;
|
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);
|
folderName = strings.dasherize(folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
const appDir = isRootApp
|
const appDir =
|
||||||
? normalize(options.projectRoot || '')
|
options.projectRoot === undefined
|
||||||
: join(normalize(newProjectRoot), folderName);
|
? join(normalize(newProjectRoot), folderName)
|
||||||
|
: normalize(options.projectRoot);
|
||||||
|
|
||||||
const sourceDir = `${appDir}/src/app`;
|
const sourceDir = `${appDir}/src/app`;
|
||||||
|
|
||||||
return chain([
|
return chain([
|
||||||
@ -270,7 +271,6 @@ export default function (options: ApplicationOptions): Rule {
|
|||||||
...options,
|
...options,
|
||||||
relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(appDir),
|
relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(appDir),
|
||||||
appName: options.name,
|
appName: options.name,
|
||||||
isRootApp,
|
|
||||||
folderName,
|
folderName,
|
||||||
}),
|
}),
|
||||||
move(appDir),
|
move(appDir),
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
"projectRoot": {
|
"projectRoot": {
|
||||||
"description": "The root directory of the new app.",
|
"description": "The root directory of the new application.",
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"visible": false
|
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"description": "The name of the new app.",
|
"description": "The name of the new application.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
|
"pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
|
||||||
"$default": {
|
"$default": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user