Skip to content
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

chore(cdk): init templates are major-version aware #11665

Merged
merged 4 commits into from Nov 24, 2020

Conversation

njlynch
Copy link
Contributor

@njlynch njlynch commented Nov 24, 2020

In preparation of non-trivial differences in the init templates between v1 and
v2 (see #11638), moving all of the existing init templates to a /v1 subdirectory
and making the init library major-version aware.

Note: This change only concerns the v1 template changes. The v2 init templates are
already broken, and I will adapt #11638 once this has been merged (and forward-
merged).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

In preparation of non-trivial differences in the init templates between v1 and
v2 (see #11638), moving all of the existing init templates to a /v1 subdirectory
and making the init library major-version aware.

Note: This change only concerns the v1 changes. The v2 init templates are
already broken, and I will adapt #11638 once this has been merged (and forward-
merged).
@njlynch njlynch requested a review from a team November 24, 2020 13:03
@njlynch njlynch self-assigned this Nov 24, 2020
@gitpod-io
Copy link

gitpod-io bot commented Nov 24, 2020

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 24, 2020
*/
function mockVersionNumber() {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const releaseJson = require(`${__dirname}/../../../release.json`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - I don't love this. I'm totally open to better ways to get the correct major version for the branch (if such a thing exists).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we instead run the tests for both v1 and v2? (maybe update cliTest so that there's no test case duplication?)
skimming through the tests, it seems it's just checking that specific files get created. I'm assuming it doesn't try to install dependencies, but maybe I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we instead run the tests for both v1 and v2?

I don't think this makes sense. v1 (master/this change) obviously can't run the v2 templates. We can add tests to ensure the v2 CLI can instantiate the v1 templates, but I'm not sure what value that provides, exactly.

I'm assuming it doesn't try to install dependencies, but maybe I'm wrong.

These tests do run npm install after initializing the template to prove the template is valid.

@njlynch njlynch requested a review from nija-at November 24, 2020 13:09
packages/aws-cdk/lib/init.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/init.ts Show resolved Hide resolved
@njlynch njlynch requested a review from nija-at November 24, 2020 14:23
packages/aws-cdk/lib/init.ts Outdated Show resolved Hide resolved
*/
function mockVersionNumber() {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const releaseJson = require(`${__dirname}/../../../release.json`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we instead run the tests for both v1 and v2? (maybe update cliTest so that there's no test case duplication?)
skimming through the tests, it seems it's just checking that specific files get created. I'm assuming it doesn't try to install dependencies, but maybe I'm wrong.

@njlynch njlynch requested a review from nija-at November 24, 2020 15:02
@nija-at nija-at changed the title chore: make CLI init templates major-version aware chore(cdk): init templates are major-version aware Nov 24, 2020
@mergify
Copy link
Contributor

mergify bot commented Nov 24, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Nov 24, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit ccf248f into master Nov 24, 2020
@mergify mergify bot deleted the njlynch/versionize-init-templates branch November 24, 2020 15:57
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 3f3788a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

njlynch added a commit that referenced this pull request Nov 24, 2020
I foolishly changed some of the ordering of .npmignore as part of #11665 to
logically group similar components together, without taking into account the
fact that ordering in .npmignore is *important*.

Fix the ordering to fix the pipeline. Tested via:
* Diffing the contents of `pack` between a recent release and what's generated here.
* Running `package/test/integ/run-against-dist package/test/integ/init/test-typescript.sh`
mergify bot pushed a commit that referenced this pull request Nov 24, 2020
I foolishly changed some of the ordering of .npmignore as part of #11665 to
logically group similar components together, without taking into account the
fact that ordering in .npmignore is *important*.

Fix the ordering to fix the pipeline. Tested via:
* Diffing the contents of `pack` between a recent release and what's generated here.
* Running `package/test/integ/run-against-dist package/test/integ/init/test-typescript.sh`

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
njlynch added a commit that referenced this pull request Nov 26, 2020
…ource

As part of the CDKv2 work, #11665 made the init templates version-aware
(allowing for different init templates for v1 and v2). This works when the CLI
\is run from a packaged distribution, but when run locally in development --
for example, when running `cdk-integ` -- the CLI was failing due to the local
version being 0.0.0, and the templates looking for a "v0" directory.

Fix the local experience by (currently) defaulting to v1 templates for local
development.
mergify bot pushed a commit that referenced this pull request Nov 29, 2020
…ource (#11731)

As part of the CDKv2 work, #11665 made the init templates version-aware
(allowing for different init templates for v1 and v2). This works when the CLI
\is run from a packaged distribution, but when run locally in development --
for example, when running `cdk-integ` -- the CLI was failing due to the local
version being 0.0.0, and the templates looking for a "v0" directory.

Fix the local experience by (currently) defaulting to v1 templates for local
development.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants