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: remove awkward cfn2ts script entries #8231

Merged
merged 4 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-autoscaling-hooktargets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent this from happening in the future, should we have a linter rule that cross-references against 'CloudFormation' key under 'cdk-build' in the package.json?

Copy link
Contributor Author

@RomainMuller RomainMuller Jun 9, 2020

Choose a reason for hiding this comment

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

Well in fact, the isAWS condition on the rule I modified is that cross-reference against the cdk-build.cloudformation key...

"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-docdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"cloudformation": "AWS::DocDB",
"jest": true
},
"keywords": [
"keywords": [
"aws",
"cdk",
"constructs",
Expand Down
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-dynamodb-global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0"
},
Expand All @@ -77,7 +76,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-ecs-patterns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-lambda-destinations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-logs-destinations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-route53-patterns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-route53-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-ses-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-sns-subscriptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-stepfunctions-tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/custom-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
],
"homepage": "https://github.com/aws/aws-cdk",
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
"node": ">= 10.13.0 <13 || >=13.7.0"
},
"stability": "stable",
"maturity": "stable"
Expand Down
1 change: 0 additions & 1 deletion packages/cdk-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"pkglint": "pkglint -f",
"test": "cdk-test",
"watch": "cdk-watch",
"cfn2ts": "cfn2ts",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"compat": "cdk-compat"
Expand Down
10 changes: 3 additions & 7 deletions tools/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,12 +1005,8 @@ export class Cfn2Ts extends ValidationRule {
public readonly name = 'cfn2ts';

public validate(pkg: PackageJson) {
if (!isJSII(pkg)) {
return;
}

if (!isAWS(pkg)) {
return;
if (!isJSII(pkg) || !isAWS(pkg)) {
return expectJSON(this.name, pkg, 'scripts.cfn2ts', undefined);
}

expectJSON(this.name, pkg, 'scripts.cfn2ts', 'cfn2ts');
Expand Down Expand Up @@ -1253,7 +1249,7 @@ function isJSII(pkg: PackageJson): boolean {
* @param pkg
*/
function isAWS(pkg: PackageJson): boolean {
return pkg.json['cdk-build'] && pkg.json['cdk-build'].cloudformation;
return pkg.json['cdk-build']?.cloudformation != null;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tools/pkglint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
},
"scripts": {
"build": "tsc -b && tslint -p . && chmod +x bin/pkglint",
"test": "echo success",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test",
"build+test": "npm run build",
"build+test+package": "npm run build",
"watch": "tsc -b -w",
"lint": "tsc -b && tslint -p . --force"
},
Expand All @@ -37,7 +36,8 @@
"devDependencies": {
"@types/fs-extra": "^8.1.0",
"@types/semver": "^7.2.0",
"@types/yargs": "^15.0.5"
"@types/yargs": "^15.0.5",
"typescript": "~3.8.3"
},
"dependencies": {
"case": "^1.6.3",
Expand Down
3 changes: 3 additions & 0 deletions tools/yarn-cling/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../tools/cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
5 changes: 5 additions & 0 deletions tools/yarn-cling/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ dist
.LAST_BUILD
*.snk
!jest.config.js

.nyc_output
coverage
nyc.config.js
!.eslintrc.js
2 changes: 2 additions & 0 deletions tools/yarn-cling/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ coverage
.LAST_BUILD
*.snk
jest.config.js

.eslintrc.js
6 changes: 3 additions & 3 deletions tools/yarn-cling/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function generateShrinkwrap(options: ShrinkwrapOptions): Promise<Pa
const packageJsonDir = path.dirname(packageJsonFile);

const yarnLockLoc = await findYarnLock(packageJsonDir);
const yarnLock: YarnLock = lockfile.parse(await fs.readFile(yarnLockLoc, { encoding: 'utf-8' }));
const yarnLock: YarnLock = lockfile.parse(await fs.readFile(yarnLockLoc, { encoding: 'utf8' }));
Copy link
Contributor

Choose a reason for hiding this comment

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

Yuck. Someone missed the ball on strong typing here.

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 think this might be some stuff in @types/node somehow becoming a little stricter than before (possibly due to changes in newer versions of node).

const pkgJson = await loadPackageJson(packageJsonFile);

const lock = await generateLockFile(pkgJson, yarnLock, packageJsonDir);
Expand All @@ -42,7 +42,7 @@ export async function generateShrinkwrap(options: ShrinkwrapOptions): Promise<Pa

if (options.outputFile) {
// Write the shrinkwrap file
await fs.writeFile(options.outputFile, JSON.stringify(lock, undefined, 2), { encoding: 'utf-8'} );
await fs.writeFile(options.outputFile, JSON.stringify(lock, undefined, 2), { encoding: 'utf8'} );
}

return lock;
Expand Down Expand Up @@ -123,7 +123,7 @@ async function findUp(fileName: string, start: string) {
}

async function loadPackageJson(fileName: string): Promise<PackageJson> {
return JSON.parse(await fs.readFile(fileName, { encoding: 'utf-8' }));
return JSON.parse(await fs.readFile(fileName, { encoding: 'utf8' }));
}

async function fileExists(fullPath: string): Promise<boolean> {
Expand Down
12 changes: 10 additions & 2 deletions tools/yarn-cling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@
"organization": true
},
"license": "Apache-2.0",
"pkglint": {
"exclude": [
"dependencies/build-tools",
"package-info/scripts/build",
"package-info/scripts/watch",
"package-info/scripts/test"
]
},
"devDependencies": {
"@types/yarnpkg__lockfile": "^1.1.3",
"@types/jest": "^25.2.3",
"jest": "^25.5.4",
"@types/node": "^13.9.1",
"@types/node": "^10.17.5",
"typescript": "~3.8.3",
"pkglint": "0.0.0"
},
Expand All @@ -46,6 +54,6 @@
],
"homepage": "https://github.com/aws/aws-cdk",
"engines": {
"node": ">= 10.3.0"
"node": ">= 10.13.0 <13 || >=13.7.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test fixtures should not be affected.