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: add "gen" target as a pre build script #10648

Merged
merged 23 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
6 changes: 5 additions & 1 deletion packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we put the arguments to cfn2ts here as well? Let's make this

Suggested change
"gen": "cfn2ts"
"gen": "cfn2ts --scope=Alexa::Ask"

etc.

Copy link
Contributor Author

@NetaNir NetaNir Oct 2, 2020

Choose a reason for hiding this comment

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

We don't need it, cfn2ts already gets this from the pacakge.json file:

async function tryAutoDetectScope(pkg: any): Promise<undefined | string[]> {
const value = pkg['cdk-build'] && pkg['cdk-build'].cloudformation;
return value && (typeof value === 'string' ? [value] : value);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I know, but it gets it from the cdk-build section. Don't you agree that's kinda confusing because we're not using cdk-build to invoke cfn2ts anymore?

In any case, fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's confusing, as evident by having to read through cfn2ts code to understand why calling it without the scope name even works. I think we can add it to the gen directive for clarity, not sure about removing the logic from cfn2ts, it is a private package so technically we wont be breaking anyone.

},
"cdk-build": {
"cloudformation": "Alexa::ASK",
"jest": true,
"pre": [
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels unnecessary. We can just code knowledge of the gen target into cdk-build, and get rid of cdk-build.pre altogether.

(Yes, that means moving everything that's currently in cdk-build.pre into scripts.gen. If you don't want to that, I'm okay with leaving cdk-build.pre in, but I'd still prefer that the tool knows about genning so we don't have to repeat this in every package file).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I removed npm run gen from all pre directive. cdk-build will now execute gen unless --skip-gen was provided.

I moved all code generation logic to gen, this include code generation commands in non cfn modules as well. I didn't remove pre completely since there are cases in which it is used for things like cleaning folders, which are not code generation related.

"npm run gen"
],
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-accessanalyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"compat": "cdk-compat",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package"
"build+test+package": "npm run build+test && npm run package",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AccessAnalyzer",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-acmpca/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ACMPCA",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-amazonmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AmazonMQ",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@
"cfn2ts": "cfn2ts",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Amplify",
"jest": true,
"pre": [
"npm run gen"
],
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ApiGateway",
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-apigatewayv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"compat": "cdk-compat",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package"
"build+test+package": "npm run build+test && npm run package",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ApiGatewayV2",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-appconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppConfig",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-appflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppFlow",
"pre": [
"npm run gen"
],
"jest": true
},
"keywords": [
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationAutoScaling",
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-applicationinsights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationInsights",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-appmesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppMesh",
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"nyc": {
"statements": 75
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-appstream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppStream",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppSync",
"jest": true,
"pre": [
"npm run gen"
],
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"repository": {
"type": "git",
Expand All @@ -56,7 +59,8 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-autoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AutoScaling",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-autoscalingplans/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AutoScalingPlans",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@
"cfn2ts": "cfn2ts",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Backup",
"jest": true,
"pre": [
"npm run gen"
],
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-batch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Batch",
"jest": true,
"pre": [
"npm run gen"
],
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-budgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"gen": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Budgets",
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"npm run gen"
]
},
"keywords": [
"aws",
Expand Down
Loading