-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Describe the feature
cdk init doesn't have an option to pass package manager when initializing projects
$ cdk --version
2.1031.2 (build 779352d)
$ cdk init app --help
cdk init [TEMPLATE]
Create a new, empty CDK project from a template.
Options:
--app, -a REQUIRED WHEN RUNNING APP: command-line for
executing your app or a cloud assembly
directory (e.g. "node bin/my-app.js"). Can
also be specified in cdk.json or ~/.cdk.json
[string]
--build Command-line for a pre-synth build [string]
--context, -c Add contextual string parameter (KEY=VALUE)
[array]
--plugin, -p Name or path of a node package that extend
the CDK features. Can be specified multiple
times [array]
--trace Print trace for stack warnings [boolean]
--strict Do not construct stacks with warnings
[boolean]
--lookups Perform context lookups (synthesis fails if
this is disabled and context lookups need to
be performed) [boolean] [default: true]
--ignore-errors Ignores synthesis errors, which will likely
produce an invalid output
[boolean] [default: false]
--json, -j Use JSON output instead of YAML when
templates are printed to STDOUT
[boolean] [default: false]
--verbose, -v Show debug logs (specify multiple times to
increase verbosity) [count] [default: false]
--debug Debug the CDK app. Log additional
information during synthesis, such as
creation stack traces of tokens (sets
CDK_DEBUG, will slow down synthesis)
[boolean] [default: false]
--profile Use the indicated AWS profile as the default
environment [string]
--proxy Use the indicated proxy. Will read from
HTTPS_PROXY environment variable if not
specified [string]
--ca-bundle-path Path to CA certificate to use when
validating HTTPS requests. Will read from
AWS_CA_BUNDLE environment variable if not
specified [string]
--ec2creds, -i Force trying to fetch EC2 instance
credentials. Default: guess EC2 instance
status [boolean]
--version-reporting, --telemetry Disable CLI telemetry and do not include the
"AWS::CDK::Metadata" resource in synthesized
templates (enabled by default) [boolean]
--path-metadata Include "aws:cdk:path" CloudFormation
metadata for each resource (enabled by
default) [boolean]
--asset-metadata Include "aws:asset:*" CloudFormation
metadata for resources that uses assets
(enabled by default) [boolean]
--role-arn, -r ARN of Role to use when invoking
CloudFormation [string]
--staging Copy assets to the output directory (use
--no-staging to disable the copy of assets
which allows local debugging via the SAM CLI
to reference the original source files)
[boolean] [default: true]
--output, -o Emits the synthesized cloud assembly into a
directory (default: cdk.out) [string]
--notices Show relevant notices [boolean]
--no-color Removes colors and other style from console
output [boolean] [default: false]
--ci Force CI detection. If CI=true then logs
will be sent to stdout instead of stderr
[boolean] [default: false]
--unstable Opt in to unstable features. The flag
indicates that the scope and API of a
feature might still change. Otherwise the
feature is generally production ready and
fully supported. Can be specified multiple
times. [array] [default: []]
--telemetry-file Send telemetry data to a local file.[string]
--version Show version number [boolean]
--language, -l The language to be used for the new project
(default can be configured in ~/.cdk.json)
[string] [choices: "csharp", "cs", "fsharp", "fs", "go", "java", "javascript",
"js", "python", "py", "typescript", "ts"]
--list List the available templates [boolean]
--generate-only If true, only generates project files,
without executing additional operations such
as setting up a git repo, installing
dependencies or compiling the project
[boolean] [default: false]
--lib-version, -V 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. [string]
--from-path Path to a local custom template directory or
multi-template repository [string]
--template-path Path to a specific template within a
multi-template repository [string]
-h, --help Show help [boolean]The instructions in Tutorial: Create your first AWS CDK app provide the following command
$ hello-cdk> cdk init app --language typescriptIt use npm package manager by default
$ hello-cdk> ls package-lock.json
package-lock.jsonUse Case
There are alternative package managers in the JavaScript/TypeScript ecosystem which do better job in many ways.
The aws-cdk projects use yarn
- https://github.com/aws/aws-cdk-cli/blob/main/yarn.lock
- https://github.com/aws/aws-cdk/blob/main/yarn.lock
generative-ai-cdk-constructs-samples uses pnpm https://github.com/aws-samples/generative-ai-cdk-constructs-samples/blob/main/samples/code-expert/pnpm-lock.yaml
Proposed Solution
Provide an option to set package manager when creating a CDK app
Example API may look like:
cdk init app --language=[csharp|fsharp|go|java|javascript|python|typescript] --package-manager=[npm|yarn|pnpm]If user doesn't provide any option, it can select npm.
If other languages also have options for package managers, it can be added as an option in the field.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.1031.2
Environment details (OS name and version, etc.)
All