-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): --project-name init option #29695
base: main
Are you sure you want to change the base?
Conversation
if (this.languages.indexOf(language) === -1) { | ||
error(`The ${chalk.blue(language)} language is not supported for ${chalk.green(this.name)} ` | ||
+ `(it supports: ${this.languages.map(l => chalk.blue(l)).join(', ')})`); | ||
throw new Error(`Unsupported language: ${language}`); | ||
} | ||
|
||
const projectInfo: ProjectInfo = { | ||
name: decamelize(path.basename(path.resolve(targetDirectory))), | ||
name: projectName ?? decamelize(path.basename(path.resolve(targetDirectory))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any validation we need to do here? for example, are spaces allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is currently stopping a user from doing this:
mkdir "test folder with spaces"
cd "test folder with spaces"
npx cdk init --language=typescript
Which the CDK doesn't handle particularly well out of the box:
cdk.json
"app": "npx ts-node --prefer-ts-exts bin/test folder with spaces.ts",
npm run cdk deploy
> test folder with spaces@0.1.0 cdk
> cdk deploy
node:internal/modules/cjs/loader:1147
throw err;
^
Error: Cannot find module './test'
Manually quoting the path in "app"
does seem to result in the deploy
and destroy
working
@nmussy Can you include a README update with this as well please? |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
The documentation of the aws-cdk/packages/aws-cdk/README.md Lines 56 to 73 in b148e58
All of the options are listed in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼
Definitely closed due to our fault, not yours. We need to update our bot to not close PRs when the changes requested are because you're waiting on us. But also, we might have a bug because I thought I implemented that thing to not close when we have an exemption request or a clarification request. I could be misremembering, though. That was a hot minute ago. |
Oops. I used all the keywords the bot responds to. I only meant to add the do-not-close label. |
Anyway, I think I don't want to take this change as-is, not because your change isn't good but because of a previous one I (and others) made when making cdk migrate. We're verging a little on the side of spaghetti code here. Mistakes were made. I'm doing some investigations that are tangentially related to this change to gimme a few days or so and I'll provide a meaningful response here with a solid path forward. But also, thanks for giving our init templates some attention. They need it. |
Issue # (if applicable)
Closes #4865.
Reopened from #28979, which was automatically despite an exemption request being submitted
Reason for this change
Multiple requests have been made to allow the user to change the project name on
cdk init
, currently set to the working directory name, to a custom value.Description of changes
This PR documents, implements and tests a new
--project-name
for thecdk init
CLI. Its default value is the current behavior, i.e. the working directory name.This PR follows up my previous attempt, now stale (#4884)
Description of how you validated changes
The new CLI option is being validated by a test added in
init.test.ts
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license