Skip to content

Commit c02abcb

Browse files
committed
feat(cli): add support for pulling custom templates from git repositories
1 parent e49fe62 commit c02abcb

File tree

6 files changed

+97
-179
lines changed

6 files changed

+97
-179
lines changed

packages/@aws-cdk/user-input-gen/lib/yargs-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface YargsCommand {
88
export interface CliAction extends YargsCommand {
99
options?: { [optionName: string]: CliOption };
1010
implies?: { [key: string]: string };
11-
//check?: string;
11+
// check?: string;
1212
}
1313

1414
interface YargsArg {

packages/aws-cdk/lib/cli/cli-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export async function makeConfig(): Promise<CliConfig> {
405405
'from-git-url': { type: 'string', desc: 'Git repository URL to clone custom template from', requiresArg: true, conflicts: ['lib-version', 'from-path'] },
406406
'template-path': { type: 'string', desc: 'Path to a specific template within a multi-template repository', requiresArg: true },
407407
},
408-
//implies: { 'template-path': 'from-path' },
408+
409409
},
410410
'migrate': {
411411
description: 'Migrate existing AWS resources into a CDK app',

packages/aws-cdk/lib/cli/cli-type-registry.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,17 +872,24 @@
872872
"desc": "Path to a local custom template directory or multi-template repository",
873873
"requiresArg": true,
874874
"conflicts": [
875-
"lib-version"
875+
"lib-version",
876+
"from-git-url"
877+
]
878+
},
879+
"from-git-url": {
880+
"type": "string",
881+
"desc": "Git repository URL to clone custom template from",
882+
"requiresArg": true,
883+
"conflicts": [
884+
"lib-version",
885+
"from-path"
876886
]
877887
},
878888
"template-path": {
879889
"type": "string",
880890
"desc": "Path to a specific template within a multi-template repository",
881891
"requiresArg": true
882892
}
883-
},
884-
"implies": {
885-
"template-path": "from-path"
886893
}
887894
},
888895
"migrate": {

packages/aws-cdk/lib/cli/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
517517
return printAvailableTemplates(ioHelper, language);
518518
} else {
519519
// Gate custom template support with unstable flag
520-
if (args['from-path'] && !configuration.settings.get(['unstable']).includes('init')) {
520+
if ((args['from-path'] || args['from-git-url']) && !configuration.settings.get(['unstable']).includes('init')) {
521521
throw new ToolkitError('Unstable feature use: \'init\' with custom templates is unstable. It must be opted in via \'--unstable\', e.g. \'cdk init --from-path=./my-template --unstable=init\'');
522522
}
523523
return cliInit({
@@ -528,6 +528,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
528528
generateOnly: args.generateOnly,
529529
libVersion: args.libVersion,
530530
fromPath: args['from-path'],
531+
fromGitUrl: args['from-git-url'],
531532
templatePath: args['template-path'],
532533
});
533534
}

0 commit comments

Comments
 (0)