Skip to content

Commit

Permalink
cleanup(angular): address pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Oct 11, 2023
1 parent 93e16fb commit c75ab8c
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 240 deletions.
8 changes: 1 addition & 7 deletions docs/generated/packages/angular/generators/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@
"directory": {
"type": "string",
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
"aliases": ["dir"],
"aliases": ["dir", "path"],
"x-priority": "important"
},
"nameAndDirectoryFormat": {
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"path": {
"type": "string",
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
"visible": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
},
"project": {
"type": "string",
"description": "The name of the project.",
Expand Down
31 changes: 18 additions & 13 deletions packages/angular/src/generators/component/lib/normalize-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ export async function normalizeOptions(
options: Schema
): Promise<NormalizedSchema> {
options.type ??= 'component';
const { directory, file, name, project } =
await determineArtifactNameAndDirectoryOptions(tree, {
artifactName: 'component',
callingGenerator: '@nx/angular:component',
name: options.name,
directory: options.directory ?? options.path,
flat: options.flat,
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
project: options.project,
suffix: options.type ?? 'component',
});
const {
artifactName: name,
directory,
fileName,
filePath,
project,
} = await determineArtifactNameAndDirectoryOptions(tree, {
artifactType: 'component',
callingGenerator: '@nx/angular:component',
name: options.name,
directory: options.directory ?? options.path,
flat: options.flat,
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
project: options.project,
suffix: options.type ?? 'component',
});

const { className } = names(name);
const { className: suffixClassName } = names(options.type);
Expand All @@ -42,8 +47,8 @@ export async function normalizeOptions(
changeDetection: options.changeDetection ?? 'Default',
style: options.style ?? 'css',
directory,
fileName: file.name,
filePath: file.path,
fileName,
filePath,
symbolName,
projectSourceRoot: sourceRoot,
projectRoot: root,
Expand Down
8 changes: 1 addition & 7 deletions packages/angular/src/generators/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@
"directory": {
"type": "string",
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
"aliases": ["dir"],
"aliases": ["dir", "path"],
"x-priority": "important"
},
"nameAndDirectoryFormat": {
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"path": {
"type": "string",
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
"visible": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
},
"project": {
"type": "string",
"description": "The name of the project.",
Expand Down
Loading

0 comments on commit c75ab8c

Please sign in to comment.