Skip to content

Commit 1292545

Browse files
committed
rm default value at cli-config.ts
1 parent 2507e8f commit 1292545

File tree

7 files changed

+37
-16
lines changed

7 files changed

+37
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CliHelpers, type CliConfig } from '@aws-cdk/user-input-gen';
44
import * as cdk_from_cfn from 'cdk-from-cfn';
55
import { StackActivityProgress } from '../commands/deploy';
66
import { availableInitLanguages } from '../commands/init';
7-
import { JS_PACKAGE_MANAGER } from '../commands/init/package-manager';
7+
import { JS_PACKAGE_MANAGERS } from '../commands/init/package-manager';
88
import { getLanguageAlias } from '../commands/language';
99

1010
export const YARGS_HELPERS = new CliHelpers('./util/yargs-helpers');
@@ -408,7 +408,7 @@ export async function makeConfig(): Promise<CliConfig> {
408408
'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.' },
409409
'from-path': { type: 'string', desc: 'Path to a local custom template directory or multi-template repository', requiresArg: true, conflicts: ['lib-version'] },
410410
'template-path': { type: 'string', desc: 'Path to a specific template within a multi-template repository', requiresArg: true },
411-
'package-manager': { type: 'string', desc: 'The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects.', default: JS_PACKAGE_MANAGER.NPM, choices: Object.values(JS_PACKAGE_MANAGER) },
411+
'package-manager': { type: 'string', desc: 'The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects. Defaults to npm in TypeScript and JavaScript projects.', choices: JS_PACKAGE_MANAGERS },
412412
},
413413
implies: { 'template-path': 'from-path' },
414414
},

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,7 @@
906906
},
907907
"package-manager": {
908908
"type": "string",
909-
"desc": "The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects.",
910-
"default": "npm",
909+
"desc": "The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects. Defaults to npm in TypeScript and JavaScript projects.",
911910
"choices": [
912911
"npm",
913912
"yarn",

packages/aws-cdk/lib/cli/parse-command-line-arguments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,9 @@ export function parseCommandLineArguments(args: Array<string>): any {
896896
requiresArg: true,
897897
})
898898
.option('package-manager', {
899-
default: 'npm',
899+
default: undefined,
900900
type: 'string',
901-
desc: 'The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects.',
901+
desc: 'The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects. Defaults to npm in TypeScript and JavaScript projects.',
902902
choices: ['npm', 'yarn', 'pnpm', 'bun'],
903903
}),
904904
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,9 +1409,9 @@ export interface InitOptions {
14091409
readonly templatePath?: string;
14101410

14111411
/**
1412-
* The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects.
1412+
* The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects. Defaults to npm in TypeScript and JavaScript projects.
14131413
*
1414-
* @default - "npm"
1414+
* @default - undefined
14151415
*/
14161416
readonly packageManager?: string;
14171417

packages/aws-cdk/lib/commands/init/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export interface CliInitOptions {
8080
/**
8181
* The package manager to use for installing dependencies.
8282
* Only applicable for TypeScript and JavaScript projects.
83-
* @default "npm"
83+
* @default - If specified language is 'typescript' or 'javascript', 'npm' is selected. Otherwise, no package manager is used.
8484
*/
8585
readonly packageManager?: JsPackageManager;
8686

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
export const JS_PACKAGE_MANAGER = {
2-
NPM: 'npm',
3-
YARN: 'yarn',
4-
PNPM: 'pnpm',
5-
BUN: 'bun',
6-
} as const;
1+
export const JS_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm', 'bun'] as const;
72

8-
export type JsPackageManager = typeof JS_PACKAGE_MANAGER[keyof typeof JS_PACKAGE_MANAGER];
3+
export type JsPackageManager = (typeof JS_PACKAGE_MANAGERS)[number];

packages/aws-cdk/test/commands/init.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,33 @@ describe('constructs version', () => {
14531453
});
14541454
});
14551455

1456+
test.each([
1457+
'python',
1458+
'java',
1459+
'go',
1460+
'csharp',
1461+
'fsharp',
1462+
])('does not warn when package-manager option is omitted for non-JS language=%s', async (language) => {
1463+
await withTempDir(async (workDir) => {
1464+
const warnSpy = jest.spyOn(ioHelper.defaults, 'warn');
1465+
1466+
await cliInit({
1467+
ioHelper,
1468+
type: 'app',
1469+
language,
1470+
canUseNetwork: false,
1471+
generateOnly: true,
1472+
workDir,
1473+
});
1474+
1475+
expect(warnSpy).not.toHaveBeenCalledWith(
1476+
expect.stringContaining('--package-manager option is only applicable for JavaScript and TypeScript projects'),
1477+
);
1478+
1479+
warnSpy.mockRestore();
1480+
});
1481+
});
1482+
14561483
test.each([
14571484
'typescript',
14581485
'javascript',

0 commit comments

Comments
 (0)