Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
87d361d
feat: add local template support with --from-path option
rohang9000 Aug 4, 2025
75602da
chore: fix code style and functionality based on code review feedback
rohang9000 Aug 7, 2025
6a487e3
chore: cleaned up some extraneous comments
rohang9000 Aug 7, 2025
dd5139e
chore: modified error handling and fixed flag conflicts with yargs
rohang9000 Aug 8, 2025
54e20f1
fix: correct JSDoc @default comments to show actual values
rohang9000 Aug 8, 2025
8c4058e
chore: self mutation
invalid-email-address Aug 8, 2025
86a8d81
chore: fixed code clarity and documentation based on CR feedback
rohang9000 Aug 8, 2025
c337e83
chore: gate --from-path functionality with unstable flag
rohang9000 Aug 11, 2025
8ba0fa9
chore: correct JSDoc syntax in init.ts
rohang9000 Aug 11, 2025
058e6cf
chore: self mutation
invalid-email-address Aug 11, 2025
33a0ee0
fix: remove auto-detection message for local templates
rohang9000 Aug 12, 2025
0f25a88
chore: revised local template support to also allow multi-template re…
rohang9000 Aug 15, 2025
31423ad
chore: self mutation
invalid-email-address Aug 15, 2025
4bf690c
chore: update code to support multi-template local repository
rohang9000 Aug 15, 2025
3d55b34
chore: seperate test data from test code with fixtures
rohang9000 Aug 18, 2025
34b313a
chore: seperated test data from test code and resolved other issues b…
rohang9000 Aug 18, 2025
1b87c79
chore: add validation for templatePath requiring fromPath at function…
rohang9000 Aug 18, 2025
7ce094d
chore: self mutation
invalid-email-address Aug 18, 2025
b4587fa
chore: refactored check function with implies for template-path valid…
rohang9000 Aug 19, 2025
4660864
chore: self mutation
invalid-email-address Aug 19, 2025
2c5bca3
chore: update test file to remove incorrect test and add test to veri…
rohang9000 Aug 19, 2025
f2e5b03
chore: self mutation
invalid-email-address Aug 19, 2025
5f447d9
chore: remove unused check function code and clean up old validation …
rohang9000 Aug 19, 2025
fcda0b4
chore: self mutation
invalid-email-address Aug 19, 2025
7578eb3
removing "requires --from-path" description from cli-config.ts
rohang9000 Aug 22, 2025
5b132b9
chore: add additional test coverage for misc.
rohang9000 Aug 22, 2025
23dec99
chore: update test for unstable flag
rohang9000 Aug 22, 2025
39041ec
chore: update to unstable flag test
rohang9000 Aug 22, 2025
e26f524
chore: merge conflict
rohang9000 Aug 22, 2025
019f38b
chore: self mutation
invalid-email-address Aug 22, 2025
569128c
chore: updated default cdk init behavior without template type or lan…
rohang9000 Aug 25, 2025
aeef412
chore: self mutation
invalid-email-address Aug 25, 2025
b7d8408
chore: add test for cdk init --language=[language]
rohang9000 Aug 26, 2025
e00e12d
modified test for cdk init --language=[language]
rohang9000 Aug 26, 2025
2d54fe8
chore: update test for cdk init --language=[language]
rohang9000 Aug 26, 2025
33dee82
Merge branch 'main' into feat/local-template-support
iankhou Aug 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/@aws-cdk/user-input-gen/lib/yargs-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ function makeYargs(config: CliConfig, helpers: CliHelpers): Statement {
commandCallArgs.push(optionsExpr);
}

// Add implies calls if present
if (commandFacts.implies) {
for (const [key, value] of Object.entries(commandFacts.implies)) {
optionsExpr = optionsExpr.callMethod('implies', lit(key), lit(value));
}
}

yargsExpr = yargsExpr.callMethod('command', ...commandCallArgs);
}

Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/user-input-gen/lib/yargs-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface YargsCommand {

export interface CliAction extends YargsCommand {
options?: { [optionName: string]: CliOption };
implies?: { [key: string]: string };
}

interface YargsArg {
Expand Down
5 changes: 4 additions & 1 deletion packages/aws-cdk/lib/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,11 @@ export async function makeConfig(): Promise<CliConfig> {
'language': { type: 'string', alias: 'l', desc: 'The language to be used for the new project (default can be configured in ~/.cdk.json)', choices: await availableInitLanguages() },
'list': { type: 'boolean', desc: 'List the available templates' },
'generate-only': { type: 'boolean', default: false, desc: 'If true, only generates project files, without executing additional operations such as setting up a git repo, installing dependencies or compiling the project' },
'lib-version': { type: 'string', alias: 'V', default: undefined, desc: 'The version of the CDK library (aws-cdk-lib) to initialize the project with. Defaults to the version that was current when this CLI was built.' },
'lib-version': { type: 'string', alias: 'V', default: undefined, desc: 'The version of the CDK library (aws-cdk-lib) to initialize built-in templates with. Defaults to the version that was current when this CLI was built.' },
'from-path': { type: 'string', desc: 'Path to a local custom template directory or multi-template repository', requiresArg: true, conflicts: ['lib-version'] },
'template-path': { type: 'string', desc: 'Path to a specific template within a multi-template repository', requiresArg: true },
},
implies: { 'template-path': 'from-path' },
},
'migrate': {
description: 'Migrate existing AWS resources into a CDK app',
Expand Down
18 changes: 17 additions & 1 deletion packages/aws-cdk/lib/cli/cli-type-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,24 @@
"lib-version": {
"type": "string",
"alias": "V",
"desc": "The version of the CDK library (aws-cdk-lib) to initialize the project with. Defaults to the version that was current when this CLI was built."
"desc": "The version of the CDK library (aws-cdk-lib) to initialize built-in templates with. Defaults to the version that was current when this CLI was built."
},
"from-path": {
"type": "string",
"desc": "Path to a local custom template directory or multi-template repository",
"requiresArg": true,
"conflicts": [
"lib-version"
]
},
"template-path": {
"type": "string",
"desc": "Path to a specific template within a multi-template repository",
"requiresArg": true
}
},
"implies": {
"template-path": "from-path"
}
},
"migrate": {
Expand Down
6 changes: 6 additions & 0 deletions packages/aws-cdk/lib/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,19 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
if (args.list) {
return printAvailableTemplates(ioHelper, language);
} else {
// Gate custom template support with unstable flag
if (args['from-path'] && !configuration.settings.get(['unstable']).includes('init')) {
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\'');
}
return cliInit({
ioHelper,
type: args.TEMPLATE,
language,
canUseNetwork: undefined,
generateOnly: args.generateOnly,
libVersion: args.libVersion,
fromPath: args['from-path'],
templatePath: args['template-path'],
});
}
case 'migrate':
Expand Down
4 changes: 4 additions & 0 deletions packages/aws-cdk/lib/cli/convert-to-user-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ export function convertYargsToUserInput(args: any): UserInput {
list: args.list,
generateOnly: args.generateOnly,
libVersion: args.libVersion,
fromPath: args.fromPath,
templatePath: args.templatePath,
TEMPLATE: args.TEMPLATE,
};
break;
Expand Down Expand Up @@ -481,6 +483,8 @@ export function convertConfigToUserInput(config: any): UserInput {
list: config.init?.list,
generateOnly: config.init?.generateOnly,
libVersion: config.init?.libVersion,
fromPath: config.init?.fromPath,
templatePath: config.init?.templatePath,
};
const migrateOptions = {
stackName: config.migrate?.stackName,
Expand Down
15 changes: 14 additions & 1 deletion packages/aws-cdk/lib/cli/parse-command-line-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,20 @@ export function parseCommandLineArguments(args: Array<string>): any {
default: undefined,
type: 'string',
alias: 'V',
desc: 'The version of the CDK library (aws-cdk-lib) to initialize the project with. Defaults to the version that was current when this CLI was built.',
desc: 'The version of the CDK library (aws-cdk-lib) to initialize built-in templates with. Defaults to the version that was current when this CLI was built.',
})
.option('from-path', {
default: undefined,
type: 'string',
desc: 'Path to a local custom template directory or multi-template repository',
requiresArg: true,
conflicts: ['lib-version'],
})
.option('template-path', {
default: undefined,
type: 'string',
desc: 'Path to a specific template within a multi-template repository',
requiresArg: true,
}),
)
.command('migrate', 'Migrate existing AWS resources into a CDK app', (yargs: Argv) =>
Expand Down
16 changes: 15 additions & 1 deletion packages/aws-cdk/lib/cli/user-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,14 +1363,28 @@ export interface InitOptions {
readonly generateOnly?: boolean;

/**
* The version of the CDK library (aws-cdk-lib) to initialize the project with. Defaults to the version that was current when this CLI was built.
* The version of the CDK library (aws-cdk-lib) to initialize built-in templates with. Defaults to the version that was current when this CLI was built.
*
* aliases: V
*
* @default - undefined
*/
readonly libVersion?: string;

/**
* Path to a local custom template directory or multi-template repository
*
* @default - undefined
*/
readonly fromPath?: string;

/**
* Path to a specific template within a multi-template repository
*
* @default - undefined
*/
readonly templatePath?: string;

/**
* Positional argument for init
*/
Expand Down
Loading
Loading