Skip to content

Commit

Permalink
chore: remove awkward cfn2ts script entries
Browse files Browse the repository at this point in the history
Packages that are not containers of L1 libraries (`Cfn~` classes) have
no point in having a `cfn2ts` script registered. This causes problems
when trying to generate L1s across the whole repository using
`lerna run cfn2ts`.

This adds a `pkglint` rule that mandates the `cfn2ts` script is only
present when the related other metadata is also required to be present.
  • Loading branch information
RomainMuller committed May 27, 2020
1 parent 0028778 commit 127dca2
Show file tree
Hide file tree
Showing 27 changed files with 32 additions and 35 deletions.
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",
"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
8 changes: 2 additions & 6 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
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' }));
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.

0 comments on commit 127dca2

Please sign in to comment.