Skip to content

Commit

Permalink
Merge pull request #1695 from nestjs/feat/schematics-v14
Browse files Browse the repository at this point in the history
chore(deps): support angular schematics v14
  • Loading branch information
kamilmysliwiec committed Jul 8, 2022
2 parents 07d0278 + d31cd59 commit e6354e6
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 19,265 deletions.
5 changes: 1 addition & 4 deletions actions/generate.action.ts
Expand Up @@ -121,10 +121,7 @@ const mapSchematicOptions = (inputs: Input[]): SchematicOption[] => {
const options: SchematicOption[] = [];
inputs.forEach((input) => {
if (!excludedInputNames.includes(input.name) && input.value !== undefined) {
const keepInputName = input.options
? 'keepInputNameFormat' in input.options
: false;
options.push(new SchematicOption(input.name, input.value, keepInputName));
options.push(new SchematicOption(input.name, input.value));
}
});
return options;
Expand Down
3 changes: 0 additions & 3 deletions commands/generate.command.ts
Expand Up @@ -81,9 +81,6 @@ export class GenerateCommand extends AbstractCommand {
options.push({
name: 'skipImport',
value: command.skipImport,
options: {
keepInputNameFormat: true,
},
});

const inputs: Input[] = [];
Expand Down
22 changes: 10 additions & 12 deletions lib/schematics/schematic.option.ts
@@ -1,28 +1,26 @@
import { normalizeToKebabOrSnakeCase } from '../utils/formatting';

export class SchematicOption {
constructor(
private name: string,
private value: boolean | string,
private keepInputNameFormat: boolean = false,
) {}
constructor(private name: string, private value: boolean | string) {}

get normalizedName() {
return normalizeToKebabOrSnakeCase(this.name);
}

public toCommandString(): string {
if (typeof this.value === 'string') {
if (this.name === 'name') {
return `--${this.name}=${this.format()}`;
return `--${this.normalizedName}=${this.format()}`;
} else if (this.name === 'version' || this.name === 'path') {
return `--${this.name}=${this.value}`;
return `--${this.normalizedName}=${this.value}`;
} else {
return `--${this.name}="${this.value}"`;
return `--${this.normalizedName}="${this.value}"`;
}
} else if (typeof this.value === 'boolean') {
const str = this.keepInputNameFormat
? this.name
: normalizeToKebabOrSnakeCase(this.name);
const str = this.normalizedName;
return this.value ? `--${str}` : `--no-${str}`;
} else {
return `--${normalizeToKebabOrSnakeCase(this.name)}=${this.value}`;
return `--${this.normalizedName}=${this.value}`;
}
}

Expand Down

0 comments on commit e6354e6

Please sign in to comment.