Skip to content

Commit

Permalink
feat(craete/new cmds): add --template option alias (#7532)
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoaldamav authored Jun 21, 2023
1 parent 583340b commit 3a35200
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion scopes/generator/generator/create.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ export class CreateCmd implements Command {
['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`],
['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],
['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'],
['t', 'template <string>', 'env-id of the template. alias for --aspect.'],
['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],
['e', 'env <string>', "set the component's environment. (overrides the env from variants and the template)"],
] as CommandOptions;

constructor(private generator: GeneratorMain, private docsDomain: string) {}

async report([templateName, componentNames]: [string, string[]], options: CreateOptions) {
async report(
[templateName, componentNames]: [string, string[]],
options: CreateOptions & {
template?: string;
}
) {
options.aspect = options.aspect ?? options.template;
const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);
const title = `${results.length} component(s) were created`;

Expand Down
4 changes: 3 additions & 1 deletion scopes/generator/generator/new.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class NewCmd implements Command {
'aspect <aspect-id>',
'aspect-id of the template. mandatory for non-core aspects. helpful for core aspects in case of a name collision',
],
['t', 'template <env-id>', 'env-id of the template. alias for --env.'],
['', 'env <env-id>', 'env-id of the template'],
['d', 'default-scope <scope-name>', `set defaultScope in the new workspace.jsonc`],
['', 'standalone', 'DEPRECATED. use --skip-git instead'],
Expand All @@ -49,10 +50,11 @@ export class NewCmd implements Command {
options: NewOptions & {
standalone: boolean;
env?: string;
template?: string;
}
) {
options.skipGit = options.skipGit ?? options.standalone;
options.aspect = options.aspect ?? options.env;
options.aspect = options.aspect ?? options.env ?? options.template;
const { workspacePath, appName } = await this.generator.generateWorkspaceTemplate(
workspaceName,
templateName,
Expand Down

0 comments on commit 3a35200

Please sign in to comment.