diff --git a/.gitallowed b/.gitallowed new file mode 100644 index 0000000000000..619a5ec396616 --- /dev/null +++ b/.gitallowed @@ -0,0 +1,2 @@ +# The only AWS account number allowed to be used in tests (used by git-secrets) +123456789012 diff --git a/.gitignore b/.gitignore index c7edf94689791..1fbe3c6115686 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ lerna-debug.log dist pack .BUILD_COMPLETED -.local-npm \ No newline at end of file +.local-npm +coverage +.nyc_output +.LAST_BUILD diff --git a/build.sh b/build.sh index 9499fb3e52b5e..1441b741334c0 100755 --- a/build.sh +++ b/build.sh @@ -10,14 +10,17 @@ rm -rf $BUILD_INDICATOR export PATH=node_modules/.bin:$PATH +# Speed up build by reusing calculated tree hashes +# On dev machine, this speeds up the TypeScript part of the build by ~30%. +export MERKLE_BUILD_CACHE=$(mktemp -d) +trap "rm -rf $MERKLE_BUILD_CACHE" EXIT + echo "=============================================================================================" echo "building..." -lerna exec --stream "npm run build" +time lerna exec --stream "npm run build" echo "=============================================================================================" echo "testing..." lerna run --stream test touch $BUILD_INDICATOR - - diff --git a/create-missing-libraries.sh b/create-missing-libraries.sh index c5809f1ebb010..69e9757184e96 100755 --- a/create-missing-libraries.sh +++ b/create-missing-libraries.sh @@ -33,6 +33,9 @@ tslint.json node_modules dist .jsii +.nyc_output +coverage +.LAST_BUILD EOM cat < packages/${P}/.npmignore @@ -63,13 +66,16 @@ EOM "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=${S} && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "${S}" + }, "keywords": [ "aws", "cdk", @@ -83,6 +89,7 @@ EOM "license": "LicenseRef-LICENSE", "devDependencies": { "@aws-cdk/assert": "^${VERSION}", + "cdk-build-tools": "^${VERSION}", "cfn2ts": "^${VERSION}", "pkglint": "^${VERSION}" }, diff --git a/examples/cdk-examples-typescript/.gitignore b/examples/cdk-examples-typescript/.gitignore new file mode 100644 index 0000000000000..f191b23ce81b5 --- /dev/null +++ b/examples/cdk-examples-typescript/.gitignore @@ -0,0 +1 @@ +.LAST_BUILD \ No newline at end of file diff --git a/examples/cdk-examples-typescript/package.json b/examples/cdk-examples-typescript/package.json index 8a2c820f641fd..4517daa0f4895 100644 --- a/examples/cdk-examples-typescript/package.json +++ b/examples/cdk-examples-typescript/package.json @@ -4,10 +4,10 @@ "description": "A bunch of CDK examples", "private": true, "scripts": { - "build": "tsc && tslint -p . && pkglint", - "watch": "tsc -w", - "lint": "tsc && tslint -p . --force", - "test": "echo ok", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "cdk": "cdk", "pkglint": "pkglint -f" }, @@ -18,7 +18,8 @@ "license": "LicenseRef-LICENSE", "devDependencies": { "aws-cdk": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cloudformation": "^0.7.3-beta", diff --git a/packages/@aws-cdk/apigateway/.gitignore b/packages/@aws-cdk/apigateway/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/apigateway/.gitignore +++ b/packages/@aws-cdk/apigateway/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/apigateway/package.json b/packages/@aws-cdk/apigateway/package.json index 717f15ba71ed2..1829b4c6f73b3 100644 --- a/packages/@aws-cdk/apigateway/package.json +++ b/packages/@aws-cdk/apigateway/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ApiGateway && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ApiGateway" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/applet-js/.gitignore b/packages/@aws-cdk/applet-js/.gitignore index fc82cb7946d82..e2e805a7d84d5 100644 --- a/packages/@aws-cdk/applet-js/.gitignore +++ b/packages/@aws-cdk/applet-js/.gitignore @@ -3,3 +3,7 @@ *.d.ts node_modules dist + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/applet-js/package.json b/packages/@aws-cdk/applet-js/package.json index 514dce872eaf0..6f0e8650ca7d5 100644 --- a/packages/@aws-cdk/applet-js/package.json +++ b/packages/@aws-cdk/applet-js/package.json @@ -8,10 +8,10 @@ "cdk-applet-js": "bin/cdk-applet-js" }, "scripts": { - "build": "tslint -p . && tsc && chmod +x bin/cdk-applet-js && pkglint", - "watch": "tsc -w", - "lint": "tsc && tslint -p . --force", - "test": "/bin/bash test/test-applet.sh", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, "author": { @@ -21,7 +21,8 @@ "license": "LicenseRef-LICENSE", "devDependencies": { "@types/yamljs": "^0.2.0", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/applicationautoscaling/.gitignore b/packages/@aws-cdk/applicationautoscaling/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/applicationautoscaling/.gitignore +++ b/packages/@aws-cdk/applicationautoscaling/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/applicationautoscaling/package.json b/packages/@aws-cdk/applicationautoscaling/package.json index 756b03e61e519..98e144d635bc5 100644 --- a/packages/@aws-cdk/applicationautoscaling/package.json +++ b/packages/@aws-cdk/applicationautoscaling/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ApplicationAutoScaling && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ApplicationAutoScaling" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/appsync/.gitignore b/packages/@aws-cdk/appsync/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/appsync/.gitignore +++ b/packages/@aws-cdk/appsync/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/appsync/package.json b/packages/@aws-cdk/appsync/package.json index 0b8148d51fdd1..6048238eeaf2c 100644 --- a/packages/@aws-cdk/appsync/package.json +++ b/packages/@aws-cdk/appsync/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::AppSync && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::AppSync" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/assert/.gitignore b/packages/@aws-cdk/assert/.gitignore index fc82cb7946d82..e2e805a7d84d5 100644 --- a/packages/@aws-cdk/assert/.gitignore +++ b/packages/@aws-cdk/assert/.gitignore @@ -3,3 +3,7 @@ *.d.ts node_modules dist + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/assert/package.json b/packages/@aws-cdk/assert/package.json index c5cde37ce544b..29ddf4f399de8 100644 --- a/packages/@aws-cdk/assert/package.json +++ b/packages/@aws-cdk/assert/package.json @@ -5,15 +5,15 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { - "build": "tslint -p . && tsc && chmod +x bin/cdk-integ bin/cdk-integ-assert && pkglint", - "watch": "tsc -w", - "lint": "tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, - "bin": { - "cdk-integ": "bin/cdk-integ", - "cdk-integ-assert": "bin/cdk-integ-assert" + "nyc": { + "lines": 40, + "branches": 30 }, "author": { "name": "Amazon Web Services", @@ -21,13 +21,13 @@ }, "license": "LicenseRef-LICENSE", "devDependencies": { - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { + "@aws-cdk/cx-api": "^0.7.3-beta", "@aws-cdk/cloudformation-diff": "^0.7.3-beta", "@aws-cdk/core": "^0.7.3-beta", - "@aws-cdk/cx-api": "^0.7.3-beta", - "aws-cdk": "^0.7.3-beta", "source-map-support": "^0.5.6" }, "repository": { diff --git a/packages/@aws-cdk/athena/.gitignore b/packages/@aws-cdk/athena/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/athena/.gitignore +++ b/packages/@aws-cdk/athena/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/athena/package.json b/packages/@aws-cdk/athena/package.json index 93d6807852e8e..6d098b1e6fac6 100644 --- a/packages/@aws-cdk/athena/package.json +++ b/packages/@aws-cdk/athena/package.json @@ -11,15 +11,18 @@ "dotnet": "Aws.Cdk.Athena" } }, + "cdk-build": { + "cloudformation": "AWS::Athena" + }, "repository": { "type": "git", "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Athena && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, @@ -36,6 +39,7 @@ "license": "LicenseRef-LICENSE", "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", "pkglint": "^0.7.3-beta" }, diff --git a/packages/@aws-cdk/autoscaling/.gitignore b/packages/@aws-cdk/autoscaling/.gitignore index 11fd849f2e8c6..4225b2aef0f20 100644 --- a/packages/@aws-cdk/autoscaling/.gitignore +++ b/packages/@aws-cdk/autoscaling/.gitignore @@ -7,3 +7,7 @@ tslint.json node_modules dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/autoscaling/package.json b/packages/@aws-cdk/autoscaling/package.json index edc3aa953a784..0ce2a8f82e729 100644 --- a/packages/@aws-cdk/autoscaling/package.json +++ b/packages/@aws-cdk/autoscaling/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::AutoScaling && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::AutoScaling" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/autoscalingplans/.gitignore b/packages/@aws-cdk/autoscalingplans/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/autoscalingplans/.gitignore +++ b/packages/@aws-cdk/autoscalingplans/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/autoscalingplans/package.json b/packages/@aws-cdk/autoscalingplans/package.json index 83f553ae1c76f..ad524155073e5 100644 --- a/packages/@aws-cdk/autoscalingplans/package.json +++ b/packages/@aws-cdk/autoscalingplans/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::AutoScalingPlans && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::AutoScalingPlans" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/batch/.gitignore b/packages/@aws-cdk/batch/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/batch/.gitignore +++ b/packages/@aws-cdk/batch/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/batch/package.json b/packages/@aws-cdk/batch/package.json index 5c03f3d79c330..6d41c2b672ae4 100644 --- a/packages/@aws-cdk/batch/package.json +++ b/packages/@aws-cdk/batch/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Batch && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Batch" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/budgets/.gitignore b/packages/@aws-cdk/budgets/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/budgets/.gitignore +++ b/packages/@aws-cdk/budgets/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/budgets/package.json b/packages/@aws-cdk/budgets/package.json index ce6d1fda3051b..a04d5d26caf60 100644 --- a/packages/@aws-cdk/budgets/package.json +++ b/packages/@aws-cdk/budgets/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Budgets && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Budgets" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/cdk-cfnspec/package.json b/packages/@aws-cdk/cdk-cfnspec/package.json index 46e1d8316c3f8..07c32383fa2e6 100644 --- a/packages/@aws-cdk/cdk-cfnspec/package.json +++ b/packages/@aws-cdk/cdk-cfnspec/package.json @@ -5,10 +5,13 @@ "scripts": { "update": "/bin/bash build-tools/update.sh", "build": "tsc && tslint -p . && node build-tools/build", - "test": "nodeunit test/test.*.js", + "test": "nyc nodeunit test/test.*.js", "watch": "tsc -w", "lint": "tslint -p ." }, + "nyc": { + "lines": 50 + }, "main": "lib/index.js", "types": "lib/index.d.ts", "devDependencies": { diff --git a/packages/@aws-cdk/certificatemanager/.gitignore b/packages/@aws-cdk/certificatemanager/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/certificatemanager/.gitignore +++ b/packages/@aws-cdk/certificatemanager/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/certificatemanager/package.json b/packages/@aws-cdk/certificatemanager/package.json index 2acce15e4bc75..e90cb4d85c92d 100644 --- a/packages/@aws-cdk/certificatemanager/package.json +++ b/packages/@aws-cdk/certificatemanager/package.json @@ -16,12 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CertificateManager && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", + "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CertificateManager" + }, "keywords": [ "aws", "cdk", @@ -36,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/cloud9/.gitignore b/packages/@aws-cdk/cloud9/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/cloud9/.gitignore +++ b/packages/@aws-cdk/cloud9/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/cloud9/package.json b/packages/@aws-cdk/cloud9/package.json index 81c05e14169f2..1d3100db3dfae 100644 --- a/packages/@aws-cdk/cloud9/package.json +++ b/packages/@aws-cdk/cloud9/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Cloud9 && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Cloud9" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/cloudformation-diff/.gitignore b/packages/@aws-cdk/cloudformation-diff/.gitignore index fc82cb7946d82..e2e805a7d84d5 100644 --- a/packages/@aws-cdk/cloudformation-diff/.gitignore +++ b/packages/@aws-cdk/cloudformation-diff/.gitignore @@ -3,3 +3,7 @@ *.d.ts node_modules dist + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/cloudformation-diff/package.json b/packages/@aws-cdk/cloudformation-diff/package.json index 73b82c81b1c0c..a6aee328084a5 100644 --- a/packages/@aws-cdk/cloudformation-diff/package.json +++ b/packages/@aws-cdk/cloudformation-diff/package.json @@ -5,25 +5,30 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { - "build": "tslint -p . && tsc && pkglint", - "watch": "tsc -w", - "lint": "tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, + "nyc": { + "lines": 45, + "branches": 44 + }, "author": { "name": "Amazon Web Services", "url": "https://aws.amazon.com" }, "license": "LicenseRef-LICENSE", - "devDependencies": { - "pkglint": "^0.7.3-beta" - }, "dependencies": { "@aws-cdk/cdk-cfnspec": "^0.7.3-beta", "colors": "^1.2.1", "source-map-support": "^0.5.6" }, + "devDependencies": { + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" + }, "repository": { "url": "git://github.com/awslabs/aws-cdk", "type": "git" diff --git a/packages/@aws-cdk/cloudformation/.gitignore b/packages/@aws-cdk/cloudformation/.gitignore index 4db2bafc5ec17..38f587620d774 100644 --- a/packages/@aws-cdk/cloudformation/.gitignore +++ b/packages/@aws-cdk/cloudformation/.gitignore @@ -7,3 +7,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/cloudformation/package.json b/packages/@aws-cdk/cloudformation/package.json index 2504eb4a8a6b3..0e03a4daa6bc6 100644 --- a/packages/@aws-cdk/cloudformation/package.json +++ b/packages/@aws-cdk/cloudformation/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CloudFormation && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CloudFormation" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/cloudfront/.gitignore b/packages/@aws-cdk/cloudfront/.gitignore index b44325f8e6f04..5bf9782abf6ea 100644 --- a/packages/@aws-cdk/cloudfront/.gitignore +++ b/packages/@aws-cdk/cloudfront/.gitignore @@ -8,3 +8,5 @@ dist coverage .nyc_output .jsii + +.LAST_BUILD \ No newline at end of file diff --git a/packages/@aws-cdk/cloudfront/package.json b/packages/@aws-cdk/cloudfront/package.json index bdc4761a8c909..d39c3250893d1 100644 --- a/packages/@aws-cdk/cloudfront/package.json +++ b/packages/@aws-cdk/cloudfront/package.json @@ -16,12 +16,15 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CloudFront && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CloudFront" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "@aws-cdk/assert": "^0.7.3-beta", "aws-sdk": "^2.259.1", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/certificatemanager": "^0.7.3-beta", diff --git a/packages/@aws-cdk/cloudtrail/.gitignore b/packages/@aws-cdk/cloudtrail/.gitignore index 2dd59aa98044f..0359061a90171 100644 --- a/packages/@aws-cdk/cloudtrail/.gitignore +++ b/packages/@aws-cdk/cloudtrail/.gitignore @@ -6,3 +6,7 @@ tslint.json *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/cloudtrail/package.json b/packages/@aws-cdk/cloudtrail/package.json index 71fecb5ce74c4..41cd9aa81e3c2 100644 --- a/packages/@aws-cdk/cloudtrail/package.json +++ b/packages/@aws-cdk/cloudtrail/package.json @@ -16,12 +16,15 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CloudTrail && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CloudTrail" + }, "keywords": [ "aws", "cdk", @@ -38,7 +41,8 @@ "aws-sdk": "^2.259.1", "cfn2ts": "^0.7.3-beta", "colors": "^1.2.1", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/cloudwatch/.gitignore b/packages/@aws-cdk/cloudwatch/.gitignore index d12ff11bc647d..fb88c88de4b21 100644 --- a/packages/@aws-cdk/cloudwatch/.gitignore +++ b/packages/@aws-cdk/cloudwatch/.gitignore @@ -8,3 +8,7 @@ dist lib/generated/resources.ts *.tgz .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/cloudwatch/package.json b/packages/@aws-cdk/cloudwatch/package.json index 2e1990fe3fc04..c4bcc9f39dec7 100644 --- a/packages/@aws-cdk/cloudwatch/package.json +++ b/packages/@aws-cdk/cloudwatch/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CloudWatch && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CloudWatch" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/codebuild/.gitignore b/packages/@aws-cdk/codebuild/.gitignore index 4db2bafc5ec17..38f587620d774 100644 --- a/packages/@aws-cdk/codebuild/.gitignore +++ b/packages/@aws-cdk/codebuild/.gitignore @@ -7,3 +7,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/codebuild/package.json b/packages/@aws-cdk/codebuild/package.json index 21ccf7a51ddee..e02bad51040e2 100644 --- a/packages/@aws-cdk/codebuild/package.json +++ b/packages/@aws-cdk/codebuild/package.json @@ -16,13 +16,19 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CodeBuild && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CodeBuild" + }, + "nyc": { + "lines": 74 + }, "keywords": [ "aws", "cdk", @@ -39,7 +45,9 @@ "@aws-cdk/sns": "^0.7.3-beta", "aws-sdk": "^2.259.1", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/codecommit": "^0.7.3-beta", diff --git a/packages/@aws-cdk/codebuild/test/test.pipeline.ts b/packages/@aws-cdk/codebuild/test/test.pipeline.ts index 08d16f84df5b5..3ce068f58fbf8 100644 --- a/packages/@aws-cdk/codebuild/test/test.pipeline.ts +++ b/packages/@aws-cdk/codebuild/test/test.pipeline.ts @@ -32,6 +32,7 @@ export = { }); test.notDeepEqual(stack.toCloudFormation(), {}); + test.deepEqual([], pipeline.validate()); test.done(); }, @@ -116,6 +117,7 @@ export = { ] })); + test.deepEqual([], p.validate()); test.done(); }, @@ -193,6 +195,8 @@ export = { } ] })); + + test.deepEqual([], pipeline.validate()); test.done(); } }; diff --git a/packages/@aws-cdk/codecommit/.gitignore b/packages/@aws-cdk/codecommit/.gitignore index c8e1606b47c6a..d80ae42bd489f 100644 --- a/packages/@aws-cdk/codecommit/.gitignore +++ b/packages/@aws-cdk/codecommit/.gitignore @@ -7,3 +7,7 @@ dist tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/codecommit/package.json b/packages/@aws-cdk/codecommit/package.json index e72db57c595b6..c46d1af07de38 100644 --- a/packages/@aws-cdk/codecommit/package.json +++ b/packages/@aws-cdk/codecommit/package.json @@ -16,13 +16,19 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CodeCommit && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CodeCommit" + }, + "nyc": { + "lines": 40 + }, "keywords": [ "aws", "cdk", @@ -39,7 +45,9 @@ "@aws-cdk/sns": "^0.7.3-beta", "aws-sdk": "^2.259.1", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/codepipeline": "^0.7.3-beta", diff --git a/packages/@aws-cdk/codedeploy/.gitignore b/packages/@aws-cdk/codedeploy/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/codedeploy/.gitignore +++ b/packages/@aws-cdk/codedeploy/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/codedeploy/package.json b/packages/@aws-cdk/codedeploy/package.json index 1b1a90ca5a2e0..e42cacd718fa5 100644 --- a/packages/@aws-cdk/codedeploy/package.json +++ b/packages/@aws-cdk/codedeploy/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CodeDeploy && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CodeDeploy" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/codepipeline/.gitignore b/packages/@aws-cdk/codepipeline/.gitignore index d12ff11bc647d..fb88c88de4b21 100644 --- a/packages/@aws-cdk/codepipeline/.gitignore +++ b/packages/@aws-cdk/codepipeline/.gitignore @@ -8,3 +8,7 @@ dist lib/generated/resources.ts *.tgz .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/codepipeline/package.json b/packages/@aws-cdk/codepipeline/package.json index 4d431053fcb19..d8c48f7ea38fb 100644 --- a/packages/@aws-cdk/codepipeline/package.json +++ b/packages/@aws-cdk/codepipeline/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::CodePipeline && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::CodePipeline" + }, "keywords": [ "aws", "cdk", @@ -39,7 +42,9 @@ "@aws-cdk/assert": "^0.7.3-beta", "@aws-cdk/sns": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/cognito/.gitignore b/packages/@aws-cdk/cognito/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/cognito/.gitignore +++ b/packages/@aws-cdk/cognito/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/cognito/package.json b/packages/@aws-cdk/cognito/package.json index e9bf42523f922..3455499d32296 100644 --- a/packages/@aws-cdk/cognito/package.json +++ b/packages/@aws-cdk/cognito/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Cognito && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Cognito" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/config/.gitignore b/packages/@aws-cdk/config/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/config/.gitignore +++ b/packages/@aws-cdk/config/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/config/package.json b/packages/@aws-cdk/config/package.json index b7531522de43b..9ae22a72a56f1 100644 --- a/packages/@aws-cdk/config/package.json +++ b/packages/@aws-cdk/config/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Config && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Config" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/core/.gitignore b/packages/@aws-cdk/core/.gitignore index 28132689e3f1d..5f41f849e6006 100644 --- a/packages/@aws-cdk/core/.gitignore +++ b/packages/@aws-cdk/core/.gitignore @@ -7,3 +7,5 @@ dist coverage .nyc_output .jsii + +.LAST_BUILD \ No newline at end of file diff --git a/packages/@aws-cdk/core/package.json b/packages/@aws-cdk/core/package.json index b94d9bae22c5c..942ae4b486882 100644 --- a/packages/@aws-cdk/core/package.json +++ b/packages/@aws-cdk/core/package.json @@ -16,10 +16,10 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nyc --reporter html --reporter text nodeunit --output junit test/**/test.*.js test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, "keywords": [ @@ -36,7 +36,8 @@ "devDependencies": { "@types/js-base64": "^2.3.1", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cx-api": "^0.7.3-beta", diff --git a/packages/@aws-cdk/custom-resources/.gitignore b/packages/@aws-cdk/custom-resources/.gitignore index 4bba46dd9ffbb..c858ecc8d5845 100644 --- a/packages/@aws-cdk/custom-resources/.gitignore +++ b/packages/@aws-cdk/custom-resources/.gitignore @@ -5,3 +5,7 @@ tslint.json *.d.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/custom-resources/package.json b/packages/@aws-cdk/custom-resources/package.json index 7e715d508906d..5244af92c557b 100644 --- a/packages/@aws-cdk/custom-resources/package.json +++ b/packages/@aws-cdk/custom-resources/package.json @@ -16,10 +16,10 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, @@ -36,7 +36,9 @@ "license": "LicenseRef-LICENSE", "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cloudformation": "^0.7.3-beta", diff --git a/packages/@aws-cdk/cx-api/.gitignore b/packages/@aws-cdk/cx-api/.gitignore index f192366c2cd54..ba7c4d4678dec 100644 --- a/packages/@aws-cdk/cx-api/.gitignore +++ b/packages/@aws-cdk/cx-api/.gitignore @@ -6,3 +6,5 @@ dist tsconfig.json tslint.json .jsii + +.LAST_BUILD \ No newline at end of file diff --git a/packages/@aws-cdk/cx-api/package.json b/packages/@aws-cdk/cx-api/package.json index 0bea4e5664263..897998e4065a7 100644 --- a/packages/@aws-cdk/cx-api/package.json +++ b/packages/@aws-cdk/cx-api/package.json @@ -12,10 +12,10 @@ } }, "scripts": { - "build": "jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "echo ok", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, "author": { @@ -24,7 +24,8 @@ }, "license": "LicenseRef-LICENSE", "devDependencies": { - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "repository": { "url": "git://github.com/awslabs/aws-cdk", diff --git a/packages/@aws-cdk/datapipeline/.gitignore b/packages/@aws-cdk/datapipeline/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/datapipeline/.gitignore +++ b/packages/@aws-cdk/datapipeline/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/datapipeline/package.json b/packages/@aws-cdk/datapipeline/package.json index 93903cc7aa25b..015c0eb2f756c 100644 --- a/packages/@aws-cdk/datapipeline/package.json +++ b/packages/@aws-cdk/datapipeline/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::DataPipeline && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::DataPipeline" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/dax/.gitignore b/packages/@aws-cdk/dax/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/dax/.gitignore +++ b/packages/@aws-cdk/dax/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/dax/package.json b/packages/@aws-cdk/dax/package.json index 086312f632b38..ec94d7b607f7e 100644 --- a/packages/@aws-cdk/dax/package.json +++ b/packages/@aws-cdk/dax/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::DAX && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::DAX" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/directoryservice/.gitignore b/packages/@aws-cdk/directoryservice/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/directoryservice/.gitignore +++ b/packages/@aws-cdk/directoryservice/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/directoryservice/package.json b/packages/@aws-cdk/directoryservice/package.json index 6c3cd31c150b2..8367563dec91a 100644 --- a/packages/@aws-cdk/directoryservice/package.json +++ b/packages/@aws-cdk/directoryservice/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::DirectoryService && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::DirectoryService" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/dms/.gitignore b/packages/@aws-cdk/dms/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/dms/.gitignore +++ b/packages/@aws-cdk/dms/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/dms/package.json b/packages/@aws-cdk/dms/package.json index ef32e649d007b..9123cb0838f5a 100644 --- a/packages/@aws-cdk/dms/package.json +++ b/packages/@aws-cdk/dms/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::DMS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::DMS" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/dynamodb/.gitignore b/packages/@aws-cdk/dynamodb/.gitignore index 28c915a91d7d1..0ff077398ca80 100644 --- a/packages/@aws-cdk/dynamodb/.gitignore +++ b/packages/@aws-cdk/dynamodb/.gitignore @@ -8,3 +8,7 @@ tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/dynamodb/package.json b/packages/@aws-cdk/dynamodb/package.json index aea13df4a95ac..668e416c49e84 100644 --- a/packages/@aws-cdk/dynamodb/package.json +++ b/packages/@aws-cdk/dynamodb/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::DynamoDB && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::DynamoDB" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/ec2/.gitignore b/packages/@aws-cdk/ec2/.gitignore index cc1035284d5ed..4797041a73ae5 100644 --- a/packages/@aws-cdk/ec2/.gitignore +++ b/packages/@aws-cdk/ec2/.gitignore @@ -7,3 +7,7 @@ tslint.json dist test/cdk.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/ec2/lib/util.ts b/packages/@aws-cdk/ec2/lib/util.ts index f06953acc3e85..f3d3edd216fd1 100644 --- a/packages/@aws-cdk/ec2/lib/util.ts +++ b/packages/@aws-cdk/ec2/lib/util.ts @@ -1,36 +1,3 @@ -import { Token } from '@aws-cdk/core'; - -export function normalizeStackParameters(props: any) { - const params: { [key: string]: any } = { }; - - for (const prop of Object.keys(props)) { - let value = (props as any)[prop]; - - if (Array.isArray(value)) { - // We can't ACTUALLY pass token values here (must be literal strings), but in the case where this is a MissingContext - // token we also don't want to fail, since the template will be resynthesized later - // FIXME: Make a distinction between those two cases. - value = value.map(el => el instanceof Token ? "(token value)" : el).join(','); - } else if (typeof value === 'boolean') { - value = value.toString(); - } else if (typeof value === 'object' && !(value instanceof Token)) { - throw new Error(`Object parameters are not supported for property ${prop}: ${JSON.stringify(value)}`); - } else if (typeof value === 'function') { - throw new Error(`Property ${prop} is a function`); - } - - // Since we're going to plug this into a stack template that is expecting - // pascalcased parameter names, uppercase the first letter here. - params[upperCaseFirst(prop)] = value; - } - - return params; -} - -function upperCaseFirst(x: string): string { - return x.substr(0, 1).toUpperCase() + x.substr(1); -} - /** * Turn an arbitrary string into one that can be used as a CloudFormation identifier by stripping special characters * diff --git a/packages/@aws-cdk/ec2/package.json b/packages/@aws-cdk/ec2/package.json index 1205b244b68d6..5c44c37839ecf 100644 --- a/packages/@aws-cdk/ec2/package.json +++ b/packages/@aws-cdk/ec2/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::EC2 && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::EC2" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/autoscaling": "^0.7.3-beta", diff --git a/packages/@aws-cdk/ecr/.gitignore b/packages/@aws-cdk/ecr/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/ecr/.gitignore +++ b/packages/@aws-cdk/ecr/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/ecr/package.json b/packages/@aws-cdk/ecr/package.json index a078bcd5b4af3..650b3d4d9e8f9 100644 --- a/packages/@aws-cdk/ecr/package.json +++ b/packages/@aws-cdk/ecr/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ECR && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ECR" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/ecs/.gitignore b/packages/@aws-cdk/ecs/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/ecs/.gitignore +++ b/packages/@aws-cdk/ecs/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/ecs/package.json b/packages/@aws-cdk/ecs/package.json index 3b2e08fe118db..8316189c4439c 100644 --- a/packages/@aws-cdk/ecs/package.json +++ b/packages/@aws-cdk/ecs/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ECS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ECS" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/efs/.gitignore b/packages/@aws-cdk/efs/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/efs/.gitignore +++ b/packages/@aws-cdk/efs/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/efs/package.json b/packages/@aws-cdk/efs/package.json index 9d50aa3f4ba64..b36f03177b984 100644 --- a/packages/@aws-cdk/efs/package.json +++ b/packages/@aws-cdk/efs/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::EFS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::EFS" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/eks/.gitignore b/packages/@aws-cdk/eks/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/eks/.gitignore +++ b/packages/@aws-cdk/eks/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/eks/package.json b/packages/@aws-cdk/eks/package.json index 907b9d1ce5a1a..029dc2b83df5c 100644 --- a/packages/@aws-cdk/eks/package.json +++ b/packages/@aws-cdk/eks/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::EKS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::EKS" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/elasticache/.gitignore b/packages/@aws-cdk/elasticache/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/elasticache/.gitignore +++ b/packages/@aws-cdk/elasticache/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/elasticache/package.json b/packages/@aws-cdk/elasticache/package.json index b8f9126f5166b..870b4f474b350 100644 --- a/packages/@aws-cdk/elasticache/package.json +++ b/packages/@aws-cdk/elasticache/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ElastiCache && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ElastiCache" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/elasticbeanstalk/.gitignore b/packages/@aws-cdk/elasticbeanstalk/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/elasticbeanstalk/.gitignore +++ b/packages/@aws-cdk/elasticbeanstalk/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/elasticbeanstalk/package.json b/packages/@aws-cdk/elasticbeanstalk/package.json index 0235a0eb18d1d..61f8bba190954 100644 --- a/packages/@aws-cdk/elasticbeanstalk/package.json +++ b/packages/@aws-cdk/elasticbeanstalk/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ElasticBeanstalk && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ElasticBeanstalk" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/elasticloadbalancing/.gitignore b/packages/@aws-cdk/elasticloadbalancing/.gitignore index 4db2bafc5ec17..38f587620d774 100644 --- a/packages/@aws-cdk/elasticloadbalancing/.gitignore +++ b/packages/@aws-cdk/elasticloadbalancing/.gitignore @@ -7,3 +7,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/elasticloadbalancing/package.json b/packages/@aws-cdk/elasticloadbalancing/package.json index 25575db792a58..ea23bc2431803 100644 --- a/packages/@aws-cdk/elasticloadbalancing/package.json +++ b/packages/@aws-cdk/elasticloadbalancing/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ElasticLoadBalancing && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ElasticLoadBalancing" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/elasticloadbalancingv2/.gitignore b/packages/@aws-cdk/elasticloadbalancingv2/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/elasticloadbalancingv2/.gitignore +++ b/packages/@aws-cdk/elasticloadbalancingv2/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/elasticloadbalancingv2/package.json b/packages/@aws-cdk/elasticloadbalancingv2/package.json index b9d8dff5d4422..52b9f6c761739 100644 --- a/packages/@aws-cdk/elasticloadbalancingv2/package.json +++ b/packages/@aws-cdk/elasticloadbalancingv2/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ElasticLoadBalancingV2 && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ElasticLoadBalancingV2" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/elasticsearch/.gitignore b/packages/@aws-cdk/elasticsearch/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/elasticsearch/.gitignore +++ b/packages/@aws-cdk/elasticsearch/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/elasticsearch/package.json b/packages/@aws-cdk/elasticsearch/package.json index c29187c2d2a8a..fea9a686a9d7f 100644 --- a/packages/@aws-cdk/elasticsearch/package.json +++ b/packages/@aws-cdk/elasticsearch/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Elasticsearch && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Elasticsearch" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/emr/.gitignore b/packages/@aws-cdk/emr/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/emr/.gitignore +++ b/packages/@aws-cdk/emr/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/emr/package.json b/packages/@aws-cdk/emr/package.json index e34b195a6d62f..f03ad7849d667 100644 --- a/packages/@aws-cdk/emr/package.json +++ b/packages/@aws-cdk/emr/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::EMR && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::EMR" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/events/.gitignore b/packages/@aws-cdk/events/.gitignore index 4db2bafc5ec17..38f587620d774 100644 --- a/packages/@aws-cdk/events/.gitignore +++ b/packages/@aws-cdk/events/.gitignore @@ -7,3 +7,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/events/package.json b/packages/@aws-cdk/events/package.json index cc9fdfcb4b034..19d59f94e78bf 100644 --- a/packages/@aws-cdk/events/package.json +++ b/packages/@aws-cdk/events/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Events && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Events" + }, "keywords": [ "aws", "cdk", @@ -38,7 +41,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "pkglint": "^0.7.3-beta", - "cfn2ts": "^0.7.3-beta" + "cfn2ts": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/gamelift/.gitignore b/packages/@aws-cdk/gamelift/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/gamelift/.gitignore +++ b/packages/@aws-cdk/gamelift/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/gamelift/package.json b/packages/@aws-cdk/gamelift/package.json index 714c8666183fa..7765fa7cc2267 100644 --- a/packages/@aws-cdk/gamelift/package.json +++ b/packages/@aws-cdk/gamelift/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::GameLift && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::GameLift" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/glue/.gitignore b/packages/@aws-cdk/glue/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/glue/.gitignore +++ b/packages/@aws-cdk/glue/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/glue/package.json b/packages/@aws-cdk/glue/package.json index f3c004e338359..07186ff394ddd 100644 --- a/packages/@aws-cdk/glue/package.json +++ b/packages/@aws-cdk/glue/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Glue && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Glue" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/guardduty/.gitignore b/packages/@aws-cdk/guardduty/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/guardduty/.gitignore +++ b/packages/@aws-cdk/guardduty/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/guardduty/package.json b/packages/@aws-cdk/guardduty/package.json index 2776e0ab3ec06..3a9021f306693 100644 --- a/packages/@aws-cdk/guardduty/package.json +++ b/packages/@aws-cdk/guardduty/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::GuardDuty && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::GuardDuty" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/iam/.gitignore b/packages/@aws-cdk/iam/.gitignore index 2dd59aa98044f..0359061a90171 100644 --- a/packages/@aws-cdk/iam/.gitignore +++ b/packages/@aws-cdk/iam/.gitignore @@ -6,3 +6,7 @@ tslint.json *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/iam/package.json b/packages/@aws-cdk/iam/package.json index 93f09a4f84d0a..112107daa5711 100644 --- a/packages/@aws-cdk/iam/package.json +++ b/packages/@aws-cdk/iam/package.json @@ -16,11 +16,15 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::IAM && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js", - "pkglint": "pkglint -f" + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", + "pkglint": "pkglint -f", + "integ": "cdk-integ" + }, + "cdk-build": { + "cloudformation": "AWS::IAM" }, "keywords": [ "aws", @@ -38,7 +42,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/iam/test/integ.group.expected.json b/packages/@aws-cdk/iam/test/integ.group.expected.json new file mode 100644 index 0000000000000..772debd602c16 --- /dev/null +++ b/packages/@aws-cdk/iam/test/integ.group.expected.json @@ -0,0 +1,7 @@ +{ + "Resources": { + "MyGroupCBA54B1B": { + "Type": "AWS::IAM::Group" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/iam/test/integ.policy.expected.json b/packages/@aws-cdk/iam/test/integ.policy.expected.json new file mode 100644 index 0000000000000..44880c4131467 --- /dev/null +++ b/packages/@aws-cdk/iam/test/integ.policy.expected.json @@ -0,0 +1,49 @@ +{ + "Resources": { + "MyUserDC45028B": { + "Type": "AWS::IAM::User" + }, + "HelloPolicyD59007DF": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "sqs:SendMessage", + "Effect": "Allow", + "Resource": "*" + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "Default", + "Users": [ + { + "Ref": "MyUserDC45028B" + } + ] + } + }, + "GoodbyePolicy739B8974": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "lambda:InvokeFunction", + "Effect": "Allow", + "Resource": "*" + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "GoodbyePolicy739B8974", + "Users": [ + { + "Ref": "MyUserDC45028B" + } + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/iam/test/integ.policy.ts b/packages/@aws-cdk/iam/test/integ.policy.ts index 916dc6a3fc15e..2ad451ff59d89 100644 --- a/packages/@aws-cdk/iam/test/integ.policy.ts +++ b/packages/@aws-cdk/iam/test/integ.policy.ts @@ -14,5 +14,6 @@ policy.attachToUser(user); const policy2 = new Policy(stack, 'GoodbyePolicy'); policy2.addStatement(new PolicyStatement().addResource('*').addAction('lambda:InvokeFunction')); +policy2.attachToUser(user); process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/iam/test/integ.role.expected.json b/packages/@aws-cdk/iam/test/integ.role.expected.json new file mode 100644 index 0000000000000..e22731b253dd9 --- /dev/null +++ b/packages/@aws-cdk/iam/test/integ.role.expected.json @@ -0,0 +1,63 @@ +{ + "Resources": { + "TestRole6C9272DF": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "sqs.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "TestRoleDefaultPolicyD1C92014": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "sqs:SendMessage", + "Effect": "Allow", + "Resource": "*" + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "TestRoleDefaultPolicyD1C92014", + "Roles": [ + { + "Ref": "TestRole6C9272DF" + } + ] + } + }, + "HelloPolicyD59007DF": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "ec2:*", + "Effect": "Allow", + "Resource": "*" + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "Default", + "Roles": [ + { + "Ref": "TestRole6C9272DF" + } + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/iam/test/integ.role.ts b/packages/@aws-cdk/iam/test/integ.role.ts index 4ccceb0f8ccbe..40ecde060244c 100644 --- a/packages/@aws-cdk/iam/test/integ.role.ts +++ b/packages/@aws-cdk/iam/test/integ.role.ts @@ -12,6 +12,7 @@ const role = new Role(stack, 'TestRole', { role.addToPolicy(new PolicyStatement().addResource('*').addAction('sqs:SendMessage')); const policy = new Policy(stack, 'HelloPolicy', { policyName: 'Default' }); +policy.addStatement(new PolicyStatement().addAction('ec2:*').addResource('*')); policy.attachToRole(role); process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/iam/test/integ.user.expected.json b/packages/@aws-cdk/iam/test/integ.user.expected.json new file mode 100644 index 0000000000000..2c4bc6c9b52c0 --- /dev/null +++ b/packages/@aws-cdk/iam/test/integ.user.expected.json @@ -0,0 +1,14 @@ +{ + "Resources": { + "MyUserDC45028B": { + "Type": "AWS::IAM::User", + "Properties": { + "LoginProfile": { + "Password": "1234", + "PasswordResetRequired": true + }, + "UserName": "benisrae" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/iam/test/integ.users-and-groups.expected.json b/packages/@aws-cdk/iam/test/integ.users-and-groups.expected.json new file mode 100644 index 0000000000000..b690806aea03f --- /dev/null +++ b/packages/@aws-cdk/iam/test/integ.users-and-groups.expected.json @@ -0,0 +1,101 @@ +{ + "Resources": { + "MyGroupCBA54B1B": { + "Type": "AWS::IAM::Group" + }, + "YourGroup1005140B": { + "Type": "AWS::IAM::Group" + }, + "User1E278A736": { + "Type": "AWS::IAM::User", + "Properties": { + "Groups": [ + { + "Ref": "MyGroupCBA54B1B" + }, + { + "Ref": "YourGroup1005140B" + } + ] + } + }, + "User21F1486D1": { + "Type": "AWS::IAM::User", + "Properties": { + "Groups": [ + { + "Ref": "MyGroupCBA54B1B" + }, + { + "Ref": "YourGroup1005140B" + } + ] + } + }, + "User3493EC043": { + "Type": "AWS::IAM::User", + "Properties": { + "Groups": [ + { + "Ref": "MyGroupCBA54B1B" + }, + { + "Ref": "YourGroup1005140B" + } + ] + } + }, + "User4BBBA4836": { + "Type": "AWS::IAM::User", + "Properties": { + "Groups": [ + { + "Ref": "MyGroupCBA54B1B" + }, + { + "Ref": "YourGroup1005140B" + } + ] + } + }, + "User5F9E592FE": { + "Type": "AWS::IAM::User", + "Properties": { + "Groups": [ + { + "Ref": "MyGroupCBA54B1B" + }, + { + "Ref": "YourGroup1005140B" + } + ] + } + }, + "MyPolicy39D66CF6": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "iam:*", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "YourGroup1005140B", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "MyPolicy39D66CF6", + "Groups": [ + { + "Ref": "MyGroupCBA54B1B" + } + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/inspector/.gitignore b/packages/@aws-cdk/inspector/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/inspector/.gitignore +++ b/packages/@aws-cdk/inspector/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/inspector/package.json b/packages/@aws-cdk/inspector/package.json index c82ba5c78e8e0..39fe3406132ac 100644 --- a/packages/@aws-cdk/inspector/package.json +++ b/packages/@aws-cdk/inspector/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Inspector && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Inspector" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/iot/.gitignore b/packages/@aws-cdk/iot/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/iot/.gitignore +++ b/packages/@aws-cdk/iot/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/iot/package.json b/packages/@aws-cdk/iot/package.json index f54fddb6beac4..c92b710cc63d4 100644 --- a/packages/@aws-cdk/iot/package.json +++ b/packages/@aws-cdk/iot/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::IoT && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::IoT" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/kinesis/.gitignore b/packages/@aws-cdk/kinesis/.gitignore index c8e1606b47c6a..d80ae42bd489f 100644 --- a/packages/@aws-cdk/kinesis/.gitignore +++ b/packages/@aws-cdk/kinesis/.gitignore @@ -7,3 +7,7 @@ dist tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/kinesis/package.json b/packages/@aws-cdk/kinesis/package.json index ad5620e03b1e9..fc1cdee94b7b8 100644 --- a/packages/@aws-cdk/kinesis/package.json +++ b/packages/@aws-cdk/kinesis/package.json @@ -16,12 +16,15 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Kinesis && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Kinesis" + }, "keywords": [ "aws", "cdk", @@ -36,7 +39,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/kinesisanalytics/.gitignore b/packages/@aws-cdk/kinesisanalytics/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/kinesisanalytics/.gitignore +++ b/packages/@aws-cdk/kinesisanalytics/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/kinesisanalytics/package.json b/packages/@aws-cdk/kinesisanalytics/package.json index d847f92de6527..71ee973281ebd 100644 --- a/packages/@aws-cdk/kinesisanalytics/package.json +++ b/packages/@aws-cdk/kinesisanalytics/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::KinesisAnalytics && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::KinesisAnalytics" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/kinesisfirehose/.gitignore b/packages/@aws-cdk/kinesisfirehose/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/kinesisfirehose/.gitignore +++ b/packages/@aws-cdk/kinesisfirehose/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/kinesisfirehose/package.json b/packages/@aws-cdk/kinesisfirehose/package.json index 200b70c9b10b9..e2a88edacdd3b 100644 --- a/packages/@aws-cdk/kinesisfirehose/package.json +++ b/packages/@aws-cdk/kinesisfirehose/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::KinesisFirehose && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::KinesisFirehose" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/kms/.gitignore b/packages/@aws-cdk/kms/.gitignore index c8e1606b47c6a..d80ae42bd489f 100644 --- a/packages/@aws-cdk/kms/.gitignore +++ b/packages/@aws-cdk/kms/.gitignore @@ -7,3 +7,7 @@ dist tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/kms/package.json b/packages/@aws-cdk/kms/package.json index 96403f920a20e..baf81938eb0e2 100644 --- a/packages/@aws-cdk/kms/package.json +++ b/packages/@aws-cdk/kms/package.json @@ -16,11 +16,15 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::KMS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p .", - "test": "nodeunit test/test.*.js", - "pkglint": "pkglint -f" + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", + "pkglint": "pkglint -f", + "integ": "cdk-integ" + }, + "cdk-build": { + "cloudformation": "AWS::KMS" }, "keywords": [ "aws", @@ -36,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/kms/test/integ.key.expected.json b/packages/@aws-cdk/kms/test/integ.key.expected.json new file mode 100644 index 0000000000000..5394998c556aa --- /dev/null +++ b/packages/@aws-cdk/kms/test/integ.key.expected.json @@ -0,0 +1,73 @@ +{ + "Resources": { + "MyKey6AB29FA6": { + "Type": "AWS::KMS::Key", + "Properties": { + "KeyPolicy": { + "Statement": [ + { + "Action": [ + "kms:Create*", + "kms:Describe*", + "kms:Enable*", + "kms:List*", + "kms:Put*", + "kms:Update*", + "kms:Revoke*", + "kms:Disable*", + "kms:Get*", + "kms:Delete*", + "kms:ScheduleKeyDeletion", + "kms:CancelKeyDeletion" + ], + "Effect": "Allow", + "Principal": { + "AWS": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::", + { + "Ref": "AWS::AccountId" + }, + ":root" + ] + ] + } + }, + "Resource": "*" + }, + { + "Action": "kms:encrypt", + "Effect": "Allow", + "Principal": { + "AWS": { + "Ref": "AWS::AccountId" + } + }, + "Resource": "*" + } + ], + "Version": "2012-10-17" + } + }, + "DeletionPolicy": "Retain" + }, + "MyKeyAlias1B45D9DA": { + "Type": "AWS::KMS::Alias", + "Properties": { + "AliasName": "alias/bar", + "TargetKeyId": { + "Fn::GetAtt": [ + "MyKey6AB29FA6", + "Arn" + ] + } + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/kms/test/integ.key.ts b/packages/@aws-cdk/kms/test/integ.key.ts index 971b67be07de6..f70f89c35d3ed 100644 --- a/packages/@aws-cdk/kms/test/integ.key.ts +++ b/packages/@aws-cdk/kms/test/integ.key.ts @@ -12,7 +12,6 @@ key.addToResourcePolicy(new PolicyStatement() .addAction('kms:encrypt') .addAwsPrincipal(new AwsAccountId())); -key.addAlias('alias/foo'); key.addAlias('alias/bar'); process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/lambda/.gitignore b/packages/@aws-cdk/lambda/.gitignore index 28c915a91d7d1..0ff077398ca80 100644 --- a/packages/@aws-cdk/lambda/.gitignore +++ b/packages/@aws-cdk/lambda/.gitignore @@ -8,3 +8,7 @@ tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/lambda/lib/lambda-ref.ts b/packages/@aws-cdk/lambda/lib/lambda-ref.ts index 7224273fa1135..47003ab6e70bd 100644 --- a/packages/@aws-cdk/lambda/lib/lambda-ref.ts +++ b/packages/@aws-cdk/lambda/lib/lambda-ref.ts @@ -1,6 +1,6 @@ import { Metric, MetricCustomization } from '@aws-cdk/cloudwatch'; import { AccountPrincipal, Arn, AwsRegion, Construct, FnConcat, FnSelect, FnSplit, - PolicyPrincipal, PolicyStatement, resolve, ServicePrincipal, Token } from '@aws-cdk/core'; + Output, PolicyPrincipal, PolicyStatement, resolve, ServicePrincipal, Token } from '@aws-cdk/core'; import { EventRuleTarget, IEventRuleTarget } from '@aws-cdk/events'; import { Role } from '@aws-cdk/iam'; import logs = require('@aws-cdk/logs'); @@ -235,6 +235,15 @@ export abstract class LambdaRef extends Construct implements IEventRuleTarget, l return { arn: this.functionArn }; } + /** + * Export this Function (without the role) + */ + public export(): LambdaRefProps { + return { + functionArn: new Output(this, 'FunctionArn', { value: this.functionArn }).makeImportValue(), + }; + } + private parsePermissionPrincipal(principal?: PolicyPrincipal) { if (!principal) { return undefined; diff --git a/packages/@aws-cdk/lambda/package.json b/packages/@aws-cdk/lambda/package.json index acbbd1d534a63..7de9c95003043 100644 --- a/packages/@aws-cdk/lambda/package.json +++ b/packages/@aws-cdk/lambda/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Lambda && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Lambda" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cloudwatch": "^0.7.3-beta", diff --git a/packages/@aws-cdk/lambda/test/test.lambda.ts b/packages/@aws-cdk/lambda/test/test.lambda.ts index b95cbd4f6f15a..b3488e75df5fb 100644 --- a/packages/@aws-cdk/lambda/test/test.lambda.ts +++ b/packages/@aws-cdk/lambda/test/test.lambda.ts @@ -3,7 +3,7 @@ import { AccountPrincipal, Arn, ArnPrincipal, AwsAccountId, Construct, PolicySta import { EventRule } from '@aws-cdk/events'; import { Role } from '@aws-cdk/iam'; import { Test } from 'nodeunit'; -import { Lambda, LambdaInlineCode, LambdaRuntime } from '../lib'; +import { Lambda, LambdaInlineCode, LambdaRef, LambdaRuntime } from '../lib'; // tslint:disable:object-literal-key-quotes @@ -232,6 +232,20 @@ export = { 'import/export': { 'lambda.export() can be used to add Outputs to the stack and returns a LambdaRef object'(test: Test) { + // GIVEN + const stack1 = new Stack(); + const stack2 = new Stack(); + const lambda = newTestLambda(stack1); + + // WHEN + const props = lambda.export(); + const imported = LambdaRef.import(stack2, 'Imported', props); + + // Can call addPermission() but it won't do anything + imported.addPermission('Hello', { + principal: new ServicePrincipal('harry') + }); + test.done(); }, }, diff --git a/packages/@aws-cdk/logs/.gitignore b/packages/@aws-cdk/logs/.gitignore index 760493279d0cd..aaf21c305bc1b 100644 --- a/packages/@aws-cdk/logs/.gitignore +++ b/packages/@aws-cdk/logs/.gitignore @@ -8,3 +8,7 @@ lib/generated/resources.ts node_modules tsconfig.json tslint.json + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/logs/package.json b/packages/@aws-cdk/logs/package.json index 49d6916e8cd77..981f121fc4d67 100644 --- a/packages/@aws-cdk/logs/package.json +++ b/packages/@aws-cdk/logs/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Logs && jsii && tslint -p . && pkglint", - "lint": "jsii && tslint -p . --force", - "watch": "jsii -w", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "lint": "cdk-lint", + "watch": "cdk-watch", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Logs" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/neptune/.gitignore b/packages/@aws-cdk/neptune/.gitignore index 51745b9de9f92..d9a08bbd257d6 100644 --- a/packages/@aws-cdk/neptune/.gitignore +++ b/packages/@aws-cdk/neptune/.gitignore @@ -6,3 +6,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/neptune/package.json b/packages/@aws-cdk/neptune/package.json index d25b2634daec8..2e013abd91d0d 100644 --- a/packages/@aws-cdk/neptune/package.json +++ b/packages/@aws-cdk/neptune/package.json @@ -16,10 +16,10 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, "keywords": [ @@ -34,7 +34,8 @@ }, "license": "LicenseRef-LICENSE", "devDependencies": { - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/opsworks/.gitignore b/packages/@aws-cdk/opsworks/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/opsworks/.gitignore +++ b/packages/@aws-cdk/opsworks/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/opsworks/package.json b/packages/@aws-cdk/opsworks/package.json index 2881c42101d85..bb693a3c536ec 100644 --- a/packages/@aws-cdk/opsworks/package.json +++ b/packages/@aws-cdk/opsworks/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::OpsWorks && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::OpsWorks" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/quickstarts/.gitignore b/packages/@aws-cdk/quickstarts/.gitignore index 4bba46dd9ffbb..c45827883c117 100644 --- a/packages/@aws-cdk/quickstarts/.gitignore +++ b/packages/@aws-cdk/quickstarts/.gitignore @@ -5,3 +5,5 @@ tslint.json *.d.ts dist .jsii + +.LAST_BUILD \ No newline at end of file diff --git a/packages/@aws-cdk/quickstarts/package.json b/packages/@aws-cdk/quickstarts/package.json index 1bc07d640077c..f38b5e6cac274 100644 --- a/packages/@aws-cdk/quickstarts/package.json +++ b/packages/@aws-cdk/quickstarts/package.json @@ -16,10 +16,11 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "pkglint": "pkglint -f" + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "pkglint": "pkglint -f", + "test": "cdk-test" }, "keywords": [ "aws", @@ -33,7 +34,8 @@ }, "license": "LicenseRef-LICENSE", "devDependencies": { - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cloudformation": "^0.7.3-beta", diff --git a/packages/@aws-cdk/rds/.gitignore b/packages/@aws-cdk/rds/.gitignore index 4db2bafc5ec17..38f587620d774 100644 --- a/packages/@aws-cdk/rds/.gitignore +++ b/packages/@aws-cdk/rds/.gitignore @@ -7,3 +7,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/rds/package.json b/packages/@aws-cdk/rds/package.json index 208566373f083..2d066c806aa65 100644 --- a/packages/@aws-cdk/rds/package.json +++ b/packages/@aws-cdk/rds/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::RDS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::RDS" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/rds/test/test.cluster.ts b/packages/@aws-cdk/rds/test/test.cluster.ts index 4627781d34a87..4f8bf1343457c 100644 --- a/packages/@aws-cdk/rds/test/test.cluster.ts +++ b/packages/@aws-cdk/rds/test/test.cluster.ts @@ -1,15 +1,17 @@ +import { expect, haveResource } from '@aws-cdk/assert'; import { Stack } from '@aws-cdk/core'; import { InstanceClass, InstanceSize, InstanceTypePair } from '@aws-cdk/ec2'; import { VpcNetwork } from '@aws-cdk/ec2'; import { Test } from 'nodeunit'; import { DatabaseCluster, DatabaseClusterEngine, DatabaseClusterRef, Password, Username } from '../lib'; -exports = { +export = { 'check that instantiation works'(test: Test) { - const stack = new Stack(); - - const vpc = new VpcNetwork(this, 'VPC'); + // GIVEN + const stack = testStack(); + const vpc = new VpcNetwork(stack, 'VPC'); + // WHEN new DatabaseCluster(stack, 'Database', { engine: DatabaseClusterEngine.Aurora, masterUser: { @@ -22,10 +24,21 @@ exports = { } }); + // THEN + expect(stack).to(haveResource('AWS::RDS::DBCluster', { + Engine: "aurora", + DBSubnetGroupName: { Ref: "DatabaseSubnets56F17B9A" }, + MasterUsername: "admin", + MasterUserPassword: "tooshort", + VpcSecurityGroupIds: [ {"Fn::GetAtt": ["DatabaseSecurityGroup5C91FDCB", "GroupId"]}] + })); + test.done(); }, 'check that exporting/importing works'(test: Test) { - const stack1 = new Stack(); + // GIVEN + const stack1 = testStack(); + const stack2 = testStack(); const cluster = new DatabaseCluster(stack1, 'Database', { engine: DatabaseClusterEngine.Aurora, @@ -35,13 +48,21 @@ exports = { }, instanceProps: { instanceType: new InstanceTypePair(InstanceClass.Burstable2, InstanceSize.Small), - vpc: new VpcNetwork(this, 'VPC') + vpc: new VpcNetwork(stack1, 'VPC') } }); - const stack2 = new Stack(); + // WHEN DatabaseClusterRef.import(stack2, 'Database', cluster.export()); + // THEN: No error + test.done(); } }; + +function testStack() { + const stack = new Stack(undefined, undefined, { env: { account: '12345', region: 'us-test-1' }}); + stack.setContext('availability-zones:12345:us-test-1', ['us-test-1a', 'us-test-1b']); + return stack; +} \ No newline at end of file diff --git a/packages/@aws-cdk/redshift/.gitignore b/packages/@aws-cdk/redshift/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/redshift/.gitignore +++ b/packages/@aws-cdk/redshift/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/redshift/package.json b/packages/@aws-cdk/redshift/package.json index 27af1199e384f..22340d6689c3e 100644 --- a/packages/@aws-cdk/redshift/package.json +++ b/packages/@aws-cdk/redshift/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Redshift && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Redshift" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/route53/.gitignore b/packages/@aws-cdk/route53/.gitignore index c8e1606b47c6a..d80ae42bd489f 100644 --- a/packages/@aws-cdk/route53/.gitignore +++ b/packages/@aws-cdk/route53/.gitignore @@ -7,3 +7,7 @@ dist tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/route53/package.json b/packages/@aws-cdk/route53/package.json index 3d4124a8fca13..12dcd6ef5eaf2 100644 --- a/packages/@aws-cdk/route53/package.json +++ b/packages/@aws-cdk/route53/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Route53 && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Route53" + }, "keywords": [ "aws", "cdk", @@ -38,7 +41,9 @@ "@aws-cdk/assert": "^0.7.3-beta", "aws-sdk": "^2.259.1", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/rtv/.gitignore b/packages/@aws-cdk/rtv/.gitignore index fbb58e3bc9816..ecea52b35953c 100644 --- a/packages/@aws-cdk/rtv/.gitignore +++ b/packages/@aws-cdk/rtv/.gitignore @@ -8,3 +8,5 @@ lib/generated/resources.ts .nyc_output coverage .jsii + +.LAST_BUILD \ No newline at end of file diff --git a/packages/@aws-cdk/rtv/package.json b/packages/@aws-cdk/rtv/package.json index e41689ef48259..df1dad6a9782e 100644 --- a/packages/@aws-cdk/rtv/package.json +++ b/packages/@aws-cdk/rtv/package.json @@ -16,10 +16,10 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nyc nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f", "integ": "cdk-integ" }, @@ -38,7 +38,9 @@ "@aws-cdk/assert": "^0.7.3-beta", "@aws-cdk/ec2": "^0.7.3-beta", "@aws-cdk/sqs": "^0.7.3-beta", - "@aws-cdk/lambda": "^0.7.3-beta" + "@aws-cdk/lambda": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/s3/.gitignore b/packages/@aws-cdk/s3/.gitignore index 4db2bafc5ec17..38f587620d774 100644 --- a/packages/@aws-cdk/s3/.gitignore +++ b/packages/@aws-cdk/s3/.gitignore @@ -7,3 +7,7 @@ tslint.json dist lib/generated/resources.ts .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/s3/package.json b/packages/@aws-cdk/s3/package.json index e4ff54681a06c..ef90bd90299ef 100644 --- a/packages/@aws-cdk/s3/package.json +++ b/packages/@aws-cdk/s3/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::S3 && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::S3" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/sdb/.gitignore b/packages/@aws-cdk/sdb/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/sdb/.gitignore +++ b/packages/@aws-cdk/sdb/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/sdb/package.json b/packages/@aws-cdk/sdb/package.json index c82d8112e25c6..6cbd506946e64 100644 --- a/packages/@aws-cdk/sdb/package.json +++ b/packages/@aws-cdk/sdb/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::SDB && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::SDB" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/serverless/.gitignore b/packages/@aws-cdk/serverless/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/serverless/.gitignore +++ b/packages/@aws-cdk/serverless/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/serverless/package.json b/packages/@aws-cdk/serverless/package.json index cf85b8c248d80..3c2bcd322d6ca 100644 --- a/packages/@aws-cdk/serverless/package.json +++ b/packages/@aws-cdk/serverless/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::Serverless && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::Serverless" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/servicecatalog/.gitignore b/packages/@aws-cdk/servicecatalog/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/servicecatalog/.gitignore +++ b/packages/@aws-cdk/servicecatalog/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/servicecatalog/package.json b/packages/@aws-cdk/servicecatalog/package.json index c1119ae0dcb7d..89a4c62e936de 100644 --- a/packages/@aws-cdk/servicecatalog/package.json +++ b/packages/@aws-cdk/servicecatalog/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ServiceCatalog && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ServiceCatalog" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/servicediscovery/.gitignore b/packages/@aws-cdk/servicediscovery/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/servicediscovery/.gitignore +++ b/packages/@aws-cdk/servicediscovery/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/servicediscovery/package.json b/packages/@aws-cdk/servicediscovery/package.json index 8b40f22fe950f..4a568b36b717a 100644 --- a/packages/@aws-cdk/servicediscovery/package.json +++ b/packages/@aws-cdk/servicediscovery/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::ServiceDiscovery && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::ServiceDiscovery" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/ses/.gitignore b/packages/@aws-cdk/ses/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/ses/.gitignore +++ b/packages/@aws-cdk/ses/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/ses/package.json b/packages/@aws-cdk/ses/package.json index 8219c65f05641..247cac0cadbe7 100644 --- a/packages/@aws-cdk/ses/package.json +++ b/packages/@aws-cdk/ses/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::SES && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::SES" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/sns/.gitignore b/packages/@aws-cdk/sns/.gitignore index c8e1606b47c6a..d80ae42bd489f 100644 --- a/packages/@aws-cdk/sns/.gitignore +++ b/packages/@aws-cdk/sns/.gitignore @@ -7,3 +7,7 @@ dist tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/sns/package.json b/packages/@aws-cdk/sns/package.json index ac5045ab5ccb6..9256f336ae023 100644 --- a/packages/@aws-cdk/sns/package.json +++ b/packages/@aws-cdk/sns/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::SNS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::SNS" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,9 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cloudwatch": "^0.7.3-beta", diff --git a/packages/@aws-cdk/sns/test/test.sns.ts b/packages/@aws-cdk/sns/test/test.sns.ts index 5a077efff5dfc..22ab4153be4fa 100644 --- a/packages/@aws-cdk/sns/test/test.sns.ts +++ b/packages/@aws-cdk/sns/test/test.sns.ts @@ -5,7 +5,7 @@ import { User } from '@aws-cdk/iam'; import { InlineJavaScriptLambda } from '@aws-cdk/lambda'; import { Queue } from '@aws-cdk/sqs'; import { Test } from 'nodeunit'; -import { Topic } from '../lib'; +import { Topic, TopicRef } from '../lib'; // tslint:disable:object-literal-key-quotes @@ -650,5 +650,42 @@ export = { }); test.done(); + }, + + 'export/import'(test: Test) { + // GIVEN + const stack1 = new Stack(); + const topic = new Topic(stack1, 'Topic'); + + const stack2 = new Stack(); + const queue = new Queue(stack2, 'Queue'); + + // WHEN + const ref = topic.export(); + const imported = TopicRef.import(stack2, 'Imported', ref); + imported.subscribeQueue(queue); + + // THEN + expect(stack2).to(haveResource('AWS::SNS::Subscription', { + "TopicArn": { "Fn::ImportValue": "TopicTopicArnB66B79C2" }, + })); + expect(stack2).to(haveResource('AWS::SQS::QueuePolicy', { + "PolicyDocument": { + "Statement": [ + { + "Action": "sqs:SendMessage", + "Condition": { + "ArnEquals": { + "aws:SourceArn": { "Fn::ImportValue": "TopicTopicArnB66B79C2" } + } + }, + "Principal": { "Service": "sns.amazonaws.com" }, + "Effect": "Allow", + } + ], + }, + })); + + test.done(); } }; diff --git a/packages/@aws-cdk/sqs/.gitignore b/packages/@aws-cdk/sqs/.gitignore index 28c915a91d7d1..0ff077398ca80 100644 --- a/packages/@aws-cdk/sqs/.gitignore +++ b/packages/@aws-cdk/sqs/.gitignore @@ -8,3 +8,7 @@ tsconfig.json tslint.json .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/sqs/package.json b/packages/@aws-cdk/sqs/package.json index 8e16fdc8e385a..0c9a5a82f6228 100644 --- a/packages/@aws-cdk/sqs/package.json +++ b/packages/@aws-cdk/sqs/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::SQS && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::SQS" + }, "keywords": [ "aws", "cdk", @@ -38,7 +41,9 @@ "@aws-cdk/assert": "^0.7.3-beta", "aws-sdk": "^2.259.1", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta", + "cdk-integ-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta", diff --git a/packages/@aws-cdk/ssm/.gitignore b/packages/@aws-cdk/ssm/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/ssm/.gitignore +++ b/packages/@aws-cdk/ssm/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/ssm/package.json b/packages/@aws-cdk/ssm/package.json index a5f5853c53ebb..26196956312ed 100644 --- a/packages/@aws-cdk/ssm/package.json +++ b/packages/@aws-cdk/ssm/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::SSM && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::SSM" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/stepfunctions/.gitignore b/packages/@aws-cdk/stepfunctions/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/stepfunctions/.gitignore +++ b/packages/@aws-cdk/stepfunctions/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/stepfunctions/package.json b/packages/@aws-cdk/stepfunctions/package.json index 7c19573e97966..25d1c715336aa 100644 --- a/packages/@aws-cdk/stepfunctions/package.json +++ b/packages/@aws-cdk/stepfunctions/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::StepFunctions && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::StepFunctions" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/util/.gitignore b/packages/@aws-cdk/util/.gitignore index 645838749181d..fd9c7f5c4a38a 100644 --- a/packages/@aws-cdk/util/.gitignore +++ b/packages/@aws-cdk/util/.gitignore @@ -2,3 +2,7 @@ *.js.map *.d.ts dist + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/util/package.json b/packages/@aws-cdk/util/package.json index ec1eaee37d51b..34fd942012dc7 100644 --- a/packages/@aws-cdk/util/package.json +++ b/packages/@aws-cdk/util/package.json @@ -9,10 +9,10 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "tslint -p . && tsc && pkglint", - "watch": "tsc -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, "keywords": [ @@ -27,10 +27,9 @@ }, "license": "LicenseRef-LICENSE", "devDependencies": { - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { - "@aws-cdk/core": "^0.7.3-beta", - "@aws-cdk/iam": "^0.7.3-beta" } } diff --git a/packages/@aws-cdk/waf/.gitignore b/packages/@aws-cdk/waf/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/waf/.gitignore +++ b/packages/@aws-cdk/waf/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/waf/package.json b/packages/@aws-cdk/waf/package.json index 58693e9f92bfc..7dcd2bb686bac 100644 --- a/packages/@aws-cdk/waf/package.json +++ b/packages/@aws-cdk/waf/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::WAF && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::WAF" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/wafregional/.gitignore b/packages/@aws-cdk/wafregional/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/wafregional/.gitignore +++ b/packages/@aws-cdk/wafregional/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/wafregional/package.json b/packages/@aws-cdk/wafregional/package.json index e1c8930ac111b..a83ce4cc270a0 100644 --- a/packages/@aws-cdk/wafregional/package.json +++ b/packages/@aws-cdk/wafregional/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::WAFRegional && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::WAFRegional" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/@aws-cdk/workspaces/.gitignore b/packages/@aws-cdk/workspaces/.gitignore index bec015f14d203..9c8fb63b20abb 100644 --- a/packages/@aws-cdk/workspaces/.gitignore +++ b/packages/@aws-cdk/workspaces/.gitignore @@ -7,3 +7,7 @@ node_modules *.generated.ts dist .jsii + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/@aws-cdk/workspaces/package.json b/packages/@aws-cdk/workspaces/package.json index 0382f3c8669aa..9ceb0ce631945 100644 --- a/packages/@aws-cdk/workspaces/package.json +++ b/packages/@aws-cdk/workspaces/package.json @@ -16,13 +16,16 @@ "url": "git://github.com/awslabs/aws-cdk" }, "scripts": { - "build": "cfn2ts --scope=AWS::WorkSpaces && jsii && tslint -p . && pkglint", - "watch": "jsii -w", - "lint": "jsii && tslint -p . --force", - "test": "nodeunit test/test.*.js && cdk-integ-assert", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "integ": "cdk-integ", "pkglint": "pkglint -f" }, + "cdk-build": { + "cloudformation": "AWS::WorkSpaces" + }, "keywords": [ "aws", "cdk", @@ -37,7 +40,8 @@ "devDependencies": { "@aws-cdk/assert": "^0.7.3-beta", "cfn2ts": "^0.7.3-beta", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/core": "^0.7.3-beta" diff --git a/packages/aws-cdk/.gitignore b/packages/aws-cdk/.gitignore index 46946eb3b0e36..0408eec6101ca 100644 --- a/packages/aws-cdk/.gitignore +++ b/packages/aws-cdk/.gitignore @@ -6,3 +6,7 @@ dist # Generated by generate.sh lib/version.ts + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index 223a4a8945402..49722035c859f 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -8,11 +8,18 @@ "cdk": "bin/cdk" }, "scripts": { - "build": "/bin/bash generate.sh && tslint -p . && tsc && chmod +x bin/cdk && pkglint", - "watch": "tsc -w", - "lint": "tsc && tslint -p . --force", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", "pkglint": "pkglint -f", - "test": "nodeunit test/test.*.js" + "test": "cdk-test" + }, + "cdk-build": { + "pre": ["./generate.sh"] + }, + "nyc": { + "lines": 8, + "branches": 3 }, "author": { "name": "Amazon Web Services", @@ -28,7 +35,8 @@ "@types/yamljs": "^0.2.0", "@types/yargs": "^8.0.3", "mockery": "^2.1.0", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@aws-cdk/cloudformation": "^0.7.3-beta", diff --git a/packages/simple-resource-bundler/.gitignore b/packages/simple-resource-bundler/.gitignore index 6d80b21dce503..7cf0bbc725b2f 100644 --- a/packages/simple-resource-bundler/.gitignore +++ b/packages/simple-resource-bundler/.gitignore @@ -1,3 +1,5 @@ *.js *.js.map dist + +.LAST_BUILD \ No newline at end of file diff --git a/packages/simple-resource-bundler/package.json b/packages/simple-resource-bundler/package.json index 3221330c51801..bfa93dff704d9 100644 --- a/packages/simple-resource-bundler/package.json +++ b/packages/simple-resource-bundler/package.json @@ -8,10 +8,11 @@ "simple-resource-bundler": "bin/simple-resource-bundler" }, "scripts": { - "build": "tsc && chmod +x bin/simple-resource-bundler && tslint -p . && pkglint", - "lint": "tsc && tslint *.ts --force", - "watch": "tsc -w", - "pkglint": "pkglint -f" + "build": "cdk-build", + "lint": "cdk-lint", + "watch": "cdk-watch", + "pkglint": "pkglint -f", + "test": "cdk-test" }, "author": { "name": "Amazon Web Services", @@ -21,7 +22,8 @@ "devDependencies": { "@types/fs-extra": "^4.0.8", "@types/yargs": "^8.0.3", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "fs-extra": "^4.0.2", diff --git a/tools/cdk-build-tools/.gitignore b/tools/cdk-build-tools/.gitignore new file mode 100644 index 0000000000000..645838749181d --- /dev/null +++ b/tools/cdk-build-tools/.gitignore @@ -0,0 +1,4 @@ +*.js +*.js.map +*.d.ts +dist diff --git a/tools/cdk-build-tools/.npmignore b/tools/cdk-build-tools/.npmignore new file mode 100644 index 0000000000000..414172bb772ec --- /dev/null +++ b/tools/cdk-build-tools/.npmignore @@ -0,0 +1,6 @@ +# Don't include original .ts files when doing `npm pack` +*.ts +!*.d.ts +coverage +.nyc_output +*.tgz diff --git a/tools/cdk-build-tools/README.md b/tools/cdk-build-tools/README.md new file mode 100644 index 0000000000000..8b7dd248752ec --- /dev/null +++ b/tools/cdk-build-tools/README.md @@ -0,0 +1,9 @@ +CDK Build Tools +================ + +These scripts wrap the common operations that need to happen +during a CDK build, in a common place so it's easy to change +the build for all packages. + +Written in TypeScript instead of shell so that they can work +on Windows with no extra effort. diff --git a/tools/cdk-build-tools/bin/cdk-build b/tools/cdk-build-tools/bin/cdk-build new file mode 100755 index 0000000000000..4a9ad6b9a4b34 --- /dev/null +++ b/tools/cdk-build-tools/bin/cdk-build @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./cdk-build.js'); \ No newline at end of file diff --git a/tools/cdk-build-tools/bin/cdk-build.ts b/tools/cdk-build-tools/bin/cdk-build.ts new file mode 100644 index 0000000000000..d64a701c9e0a8 --- /dev/null +++ b/tools/cdk-build-tools/bin/cdk-build.ts @@ -0,0 +1,38 @@ +import yargs = require('yargs'); +import { compileCurrentPackage } from '../lib/compile'; +import { shell } from '../lib/os'; +import { cdkBuildOptions } from '../lib/package-info'; +import { Timers } from '../lib/timer'; + +async function main() { + const args = yargs + .usage('Usage: cdk-build') + .option('force', { type: 'boolean', alias: 'f', desc: 'Force a rebuild' }) + .argv; + + const options = cdkBuildOptions(); + + if (options.pre) { + await shell(options.pre, timers); + } + + // See if we need to call cfn2ts + if (options.cloudformation) { + await shell(['cfn2ts', `--scope=${options.cloudformation}`], timers); + } + + await compileCurrentPackage(timers, args.force); +} + +const timers = new Timers(); +const buildTimer = timers.start('Total time'); + +main().then(() => { + buildTimer.end(); + process.stdout.write(`Build complete. ${timers.display()}\n`); +}).catch(e => { + buildTimer.end(); + process.stderr.write(`${e.toString()}\n`); + process.stderr.write(`Build failed. ${timers.display()}\n`); + process.exit(1); +}); diff --git a/tools/cdk-build-tools/bin/cdk-test b/tools/cdk-build-tools/bin/cdk-test new file mode 100755 index 0000000000000..113d44af00c21 --- /dev/null +++ b/tools/cdk-build-tools/bin/cdk-test @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./cdk-test.js'); diff --git a/tools/cdk-build-tools/bin/cdk-test.ts b/tools/cdk-build-tools/bin/cdk-test.ts new file mode 100644 index 0000000000000..af43dd5afb78a --- /dev/null +++ b/tools/cdk-build-tools/bin/cdk-test.ts @@ -0,0 +1,60 @@ +import path = require('path'); +import { compileCurrentPackage } from '../lib/compile'; +import { shell } from '../lib/os'; +import { configFilePath, hasIntegTests, hasOnlyAutogeneratedTests, unitTestFiles } from '../lib/package-info'; +import { Timers } from '../lib/timer'; + +async function main() { + // Always recompile before running tests, so it's impossible to forget. + // During a normal build, this means we'll compile twice, but the + // hash calculation makes that cheaper on CPU (if not on disk). + await compileCurrentPackage(timers); + + const testFiles = await unitTestFiles(); + if (testFiles.length > 0) { + const testCommand: string[] = []; + + const nycrc = configFilePath('nycrc'); + + // We always run the tests, but include an 'nyc' run (for coverage) + // if and only if the package is not completely autogenerated. + // + // The nyc configuration file is passed, in a silly way. The '--nycrc-path' + // is always appended to the current directory (whether prefixed with a '/' + // or not). So we need to split the actual filename into dirname and + // basename to pass it correctly. '--cwd' does not actually cwd(), it + // just changes the base path that the '--nycrc-path' is appended to. + // + // Coverage tresholds can be overridden in the per-package package.json + // if necessary. + if (!await hasOnlyAutogeneratedTests()) { + testCommand.push(...['nyc', + '--clean', + '--cwd', path.dirname(nycrc), + '--nycrc-path', path.basename(nycrc) + ]); + } + testCommand.push('nodeunit'); + testCommand.push(...testFiles); + + await shell(testCommand, timers); + } + + // Run integration test if the package has integ test files + if (await hasIntegTests()) { + await shell(['cdk-integ-assert'], timers); + } +} + +const timers = new Timers(); +const buildTimer = timers.start('Total time'); + +main().then(() => { + buildTimer.end(); + process.stdout.write(`Tests successful. ${timers.display()}\n`); +}).catch(e => { + buildTimer.end(); + process.stderr.write(`${e.toString()}\n`); + process.stderr.write(`Tests failed. ${timers.display()}\n`); + process.exit(1); +}); diff --git a/tools/cdk-build-tools/bin/cdk-watch b/tools/cdk-build-tools/bin/cdk-watch new file mode 100755 index 0000000000000..2943181e75a1f --- /dev/null +++ b/tools/cdk-build-tools/bin/cdk-watch @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./cdk-watch.js'); diff --git a/tools/cdk-build-tools/bin/cdk-watch.ts b/tools/cdk-build-tools/bin/cdk-watch.ts new file mode 100644 index 0000000000000..0c2d7bdf00073 --- /dev/null +++ b/tools/cdk-build-tools/bin/cdk-watch.ts @@ -0,0 +1,11 @@ +import { shell } from '../lib/os'; +import { packageCompiler } from '../lib/package-info'; + +async function main() { + await shell([packageCompiler(), '-w']); +} + +main().catch(e => { + process.stderr.write(`${e.toString()}\n`); + process.exit(1); +}); \ No newline at end of file diff --git a/tools/cdk-build-tools/chmod.bat b/tools/cdk-build-tools/chmod.bat new file mode 100644 index 0000000000000..59ac42c0974a0 --- /dev/null +++ b/tools/cdk-build-tools/chmod.bat @@ -0,0 +1,2 @@ +@rem Just here so that running 'chmod' doesn't fail on Windows. +@rem Doesn't actually do anything, because it doesn't need to. diff --git a/tools/cdk-build-tools/config/nycrc b/tools/cdk-build-tools/config/nycrc new file mode 100644 index 0000000000000..7c2fb84485c29 --- /dev/null +++ b/tools/cdk-build-tools/config/nycrc @@ -0,0 +1,16 @@ +{ + "check-coverage": true, + "all": true, + "lines": 80, + "branches": 50, + "reporter": [ + "html", + "text-summary" + ], + "cache": true, + "exclude": [ + "coverage/**", + "test/**", + "lib/*.generated.js" + ] +} diff --git a/tools/cdk-build-tools/lib/compile.ts b/tools/cdk-build-tools/lib/compile.ts new file mode 100644 index 0000000000000..c9827618cc966 --- /dev/null +++ b/tools/cdk-build-tools/lib/compile.ts @@ -0,0 +1,57 @@ +import { ChangeDetector } from "merkle-build"; +import { makeExecutable, shell } from "./os"; +import { currentPackageJson, packageCompiler } from "./package-info"; +import { Timers } from "./timer"; + +/** + * Run the compiler on the current package + */ +export async function compileCurrentPackage(timers: Timers, force?: boolean): Promise { + // We don't need to do the rest if the folder hash didn't change + // NOTE: This happens post-cfn2ts on purpose, since a change in cfn2ts or the spec might lead + // to different generated sources, in which case we DO need to recompile. + // + // Otherwise, we assume that changes in the compiler don't affect the output too much. + // + // (Which might be false in case the compiler is jsii, but what can we do?) + const detector = new ChangeDetector('.', { + ignore: [ + // Output directories that are not part of the build dependencies + 'coverage', 'dist', + + // Slight hack: we have a dependency cycle of + // + // aws-cdk => @aws-cdk/* => cdk-integ-tools => aws-cdk + // + // This cycle manifests itself as a symlink cycle. In the general + // case, we cannot calculate the source hash of the source tree now, + // but we can apply more knowledge: we know that 'aws-cdk' cannot affect + // the build output of the package, because it's never a source dependency. + // + // We break the cycle by excluding that package. + // + // https://github.com/awslabs/aws-cdk/pull/32 + 'aws-cdk' + ] + }); + + const isChanged = await timers.recordAsync('detectChanges', () => detector.isChanged()); + if (!isChanged && !force) { + process.stdout.write('Sources and dependencies unchanged since last build; skipping.\n'); + return; + } + + await shell([packageCompiler()], timers); + + // Find files in bin/ that look like they should be executable, and make them so. + const scripts = currentPackageJson().bin || {}; + for (const script of Object.values(scripts) as any) { + await makeExecutable(script); + } + + // Always call linters + await shell(['tslint', '--project', '.'], timers); + await shell(['pkglint'], timers); + + await timers.recordAsync('markBuilt', () => detector.markClean()); +} diff --git a/tools/cdk-build-tools/lib/os.ts b/tools/cdk-build-tools/lib/os.ts new file mode 100644 index 0000000000000..1bdea96a8c9a8 --- /dev/null +++ b/tools/cdk-build-tools/lib/os.ts @@ -0,0 +1,126 @@ +import child_process = require("child_process"); +import fs = require('fs'); +import util = require('util'); +import { Timers } from "./timer"; + +/** + * A shell command that does what you want + * + * Is platform-aware, handles errors nicely. + */ +export async function shell(command: string[], timers?: Timers): Promise { + const timer = (timers || new Timers()).start(command[0]); + + await makeShellScriptExecutable(command[0]); + + const child = child_process.spawn(command[0], command.slice(1), { + // Need this for Windows where we want .cmd and .bat to be found as well. + shell: true, + }); + + return new Promise((resolve, reject) => { + child.stdout.on('data', process.stdout.write.bind(process.stdout)); + child.stderr.on('data', process.stderr.write.bind(process.stderr)); + child.on('error', reject); + + child.on('exit', code => { + timer.end(); + if (code === 0) { + resolve(); + } else { + reject(new Error(`${renderCommandLine(command)} exited with ${code}`)); + } + }); + }); +} + +/** + * Render the given command line as a string + * + * Probably missing some cases but giving it a good effort. + */ +function renderCommandLine(cmd: string[]) { + if (process.platform !== 'win32') { + return doRender(cmd, hasAnyChars(' ', '\\', '!', '"', "'", '&', '$'), posixEscape); + } else { + return doRender(cmd, hasAnyChars(' ', '"', '&', '^', '%'), windowsEscape); + } +} + +/** + * Render a UNIX command line + */ +function doRender(cmd: string[], needsEscaping: (x: string) => boolean, doEscape: (x: string) => string): string { + return cmd.map(x => needsEscaping(x) ? doEscape(x) : x).join(' '); +} + +/** + * Return a predicate that checks if a string has any of the indicated chars in it + */ +function hasAnyChars(...chars: string[]): (x: string) => boolean { + return (str: string) => { + return chars.some(c => str.indexOf(c) !== -1); + }; +} + +/** + * Escape a shell argument for POSIX shells + * + * Wrapping in single quotes and escaping single quotes inside will do it for us. + */ +function posixEscape(x: string) { + // Turn ' -> '"'"' + x = x.replace("'", "'\"'\"'"); + return `'${x}'`; +} + +/** + * Escape a shell argument for cmd.exe + * + * This is how to do it right, but I'm not following everything: + * + * https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/ + */ +function windowsEscape(x: string): string { + // First surround by double quotes, ignore the part about backslashes + x = `"${x}"`; + // Now escape all special characters + const shellMeta = ['"', '&', '^', '%']; + return x.split('').map(c => shellMeta.indexOf(x) !== -1 ? '^' + c : c).join(''); +} + +/** + * Make the script executable on the current platform + * + * On UNIX, we'll use chmod to directly execute the file. + * + * On Windows, we'll do nothing and expect our other tooling + * (npm/lerna) to generate appropriate .cmd files when linking. + */ +export async function makeExecutable(javascriptFile: string): Promise { + if (process.platform !== 'win32') { + await util.promisify(fs.chmod)(javascriptFile, 0o755); + } +} + +/** + * If the given file exists and looks like a shell script, make sure it's executable + */ +async function makeShellScriptExecutable(script: string) { + try { + if (await util.promisify(fs.access)(script, fs.constants.X_OK)) { return; } + if (!await isShellScript(script)) { return; } + await util.promisify(fs.chmod)(script, 0o755); + } catch (e) { + if (e.code === 'ENOENT') { return; } + throw e; + } +} + +async function isShellScript(script: string): Promise { + const f = await util.promisify(fs.open)(script, 'r'); + const buffer = Buffer.alloc(10); + await util.promisify(fs.read)(f, buffer, 0, 2, null); + + return buffer.toString('utf-8') === '#!'; +} \ No newline at end of file diff --git a/tools/cdk-build-tools/lib/package-info.ts b/tools/cdk-build-tools/lib/package-info.ts new file mode 100644 index 0000000000000..0fd94a849f81a --- /dev/null +++ b/tools/cdk-build-tools/lib/package-info.ts @@ -0,0 +1,96 @@ +import fs = require('fs'); +import path = require('path'); +import util = require('util'); + +/** + * Return the package JSON for the current package + */ +export function currentPackageJson(): any { + return require(path.join(process.cwd(), 'package.json')); +} + +/** + * Return the CDK build options + */ +export function cdkBuildOptions(): CDKBuildOptions { + // These could have been in a separate cdk-build.json but for + // now it's easiest to just read them from the package JSON. + // Our package directories are littered with .json files enough + // already. + return currentPackageJson()["cdk-build"] || {}; +} + +/** + * Whether this is a jsii package + */ +export function isJsii(): boolean { + return currentPackageJson().jsii !== undefined; +} + +export async function listFiles(dirName: string, predicate: (x: string) => boolean): Promise { + try { + return (await util.promisify(fs.readdir)(dirName)).filter(predicate).map(f => path.join(dirName, f)); + } catch (e) { + if (e.code === 'ENOENT') { return []; } + throw e; + } +} + +/** + * Return the unit test files for this package + */ +export async function unitTestFiles(): Promise { + return listFiles('test', f => f.startsWith('test.') && f.endsWith('.js')); +} + +/** + * The text that is in the test file if the test was an autogenerated no-op test + */ +const AUTOGENERATED_TEST_MARKER = 'No tests are specified for this package.'; + +/** + * Return whether the only tests that exist are autogenerated + */ +export async function hasOnlyAutogeneratedTests(): Promise { + const tests = await unitTestFiles(); + const packageName = path.basename(process.cwd()); + + return (tests.length === 1 + && tests[0] === `test/test.${packageName}.js` + && fs.readFileSync(tests[0], { encoding: 'utf-8' }).indexOf(AUTOGENERATED_TEST_MARKER) !== -1); +} + +export async function hasIntegTests(): Promise { + const files = await listFiles('test', f => f.startsWith('integ.') && f.endsWith('.js')); + return files.length > 0; +} + +/** + * Return the compiler for this package (either tsc or jsii) + */ +export function packageCompiler() { + return isJsii() ? 'jsii' : 'tsc'; +} + +export interface CDKBuildOptions { + /** + * What CloudFormation scope to generate resources for, if any + */ + cloudformation?: string; + + /** + * An optional command (formatted as a list of strings) to run before building + * + * (Typically a code generator) + */ + pre?: string[]; +} + +/** + * Return a full path to the config file in this package + * + * The addressed file is cdk-build-tools/config/FILE. + */ +export function configFilePath(fileName: string) { + return path.resolve(__dirname, '..', 'config', fileName); +} \ No newline at end of file diff --git a/tools/cdk-build-tools/lib/timer.ts b/tools/cdk-build-tools/lib/timer.ts new file mode 100644 index 0000000000000..170cfe5a18e25 --- /dev/null +++ b/tools/cdk-build-tools/lib/timer.ts @@ -0,0 +1,82 @@ +/** + * A single timer + */ +export class Timer { + public timeMs?: number; + private startTime: number; + + constructor(public readonly label: string) { + this.startTime = Date.now(); + } + + public start() { + this.startTime = Date.now(); + } + + public end() { + this.timeMs = (Date.now() - this.startTime) / 1000; + } + + public isSet() { + return this.timeMs !== undefined; + } + + public humanTime() { + if (!this.timeMs) { return '???'; } + + const parts = []; + + let time = this.timeMs; + if (time > 60) { + const mins = Math.floor(time / 60); + parts.push(mins + 'm'); + time -= mins * 60; + } + parts.push(time.toFixed(1) + 's'); + + return parts.join(''); + } +} + +/** + * A collection of Timers + */ +export class Timers { + private readonly timers: Timer[] = []; + + public record(label: string, operation: () => T): T { + const timer = this.start(label); + try { + const x = operation(); + timer.end(); + return x; + } catch (e) { + timer.end(); + throw e; + } + } + + public async recordAsync(label: string, operation: () => Promise) { + const timer = this.start(label); + try { + const x = await operation(); + timer.end(); + return x; + } catch (e) { + timer.end(); + throw e; + } + } + + public start(label: string) { + const timer = new Timer(label); + this.timers.push(timer); + return timer; + } + + public display(): string { + const timers = this.timers.filter(t => t.isSet()); + timers.sort((a: Timer, b: Timer) => b.timeMs! - a.timeMs!); + return timers.map(t => `${t.label} (${t.humanTime()})`).join(' | '); + } +} \ No newline at end of file diff --git a/tools/cdk-build-tools/package-lock.json b/tools/cdk-build-tools/package-lock.json new file mode 100644 index 0000000000000..2df423448eff4 --- /dev/null +++ b/tools/cdk-build-tools/package-lock.json @@ -0,0 +1,549 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@types/fs-extra": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-4.0.8.tgz", + "integrity": "sha512-Z5nu9Pbxj9yNeXIK3UwGlRdJth4cZ5sCq05nI7FaI6B0oz28nxkOtp6Lsz0ZnmLHJGvOJfB/VHxSTbVq/i6ujA==", + "requires": { + "@types/node": "10.5.2" + } + }, + "@types/node": { + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==" + }, + "@types/yargs": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-8.0.3.tgz", + "integrity": "sha512-YdxO7zGQf2qJeMgR0fNO8QTlj88L2zCP5GOddovoTyetgLiNDOUXcWzhWKb4EdZZlOjLQUA0JM8lW7VcKQL+9w==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "4.1.3", + "shebang-command": "1.2.0", + "which": "1.3.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "0.2.1" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "requires": { + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "requires": { + "locate-path": "2.0.0" + } + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.2" + } + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "hosted-git-info": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "requires": { + "builtin-modules": "1.1.1" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "4.1.11" + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "1.0.0" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "strip-bom": "3.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "requires": { + "p-locate": "2.0.0", + "path-exists": "3.0.0" + } + }, + "lru-cache": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", + "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "requires": { + "mimic-fn": "1.2.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "requires": { + "hosted-git-info": "2.7.1", + "is-builtin-module": "1.0.0", + "semver": "5.5.0", + "validate-npm-package-license": "3.0.3" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "requires": { + "path-key": "2.0.1" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "requires": { + "execa": "0.7.0", + "lcid": "1.0.0", + "mem": "1.1.0" + } + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "requires": { + "p-try": "1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "requires": { + "p-limit": "1.3.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "requires": { + "error-ex": "1.3.2" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "requires": { + "pify": "2.3.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "requires": { + "load-json-file": "2.0.0", + "normalize-package-data": "2.4.0", + "path-type": "2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "requires": { + "find-up": "2.1.0", + "read-pkg": "2.0.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "spdx-correct": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "requires": { + "spdx-expression-parse": "3.0.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "requires": { + "spdx-exceptions": "2.1.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "validate-npm-package-license": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "requires": { + "spdx-correct": "3.0.0", + "spdx-expression-parse": "3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } + } + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yargs": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-9.0.1.tgz", + "integrity": "sha1-UqzCP+7Kw0BCB47njAwAf1CF20w=", + "requires": { + "camelcase": "4.1.0", + "cliui": "3.2.0", + "decamelize": "1.2.0", + "get-caller-file": "1.0.3", + "os-locale": "2.1.0", + "read-pkg-up": "2.0.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "3.2.1", + "yargs-parser": "7.0.0" + } + }, + "yargs-parser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", + "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", + "requires": { + "camelcase": "4.1.0" + } + } + } +} diff --git a/tools/cdk-build-tools/package.json b/tools/cdk-build-tools/package.json new file mode 100644 index 0000000000000..5aec6288136c6 --- /dev/null +++ b/tools/cdk-build-tools/package.json @@ -0,0 +1,38 @@ +{ + "name": "cdk-build-tools", + "private": true, + "version": "0.7.3-beta", + "description": "Tools package with shared build scripts for CDK packages", + "main": "index.js", + "repository": { + "type": "git", + "url": "git://github.com/awslabs/aws-cdk" + }, + "bin": { + "cdk-build": "bin/cdk-build", + "cdk-watch": "bin/cdk-watch", + "cdk-test": "bin/cdk-test" + }, + "scripts": { + "build": "tsc && tslint -p . && chmod +x bin/cdk-build && chmod +x bin/cdk-test && chmod +x bin/cdk-watch && pkglint", + "watch": "tsc -w", + "pkglint": "pkglint -f" + }, + "author": { + "name": "Amazon Web Services", + "url": "https://aws.amazon.com" + }, + "license": "LicenseRef-LICENSE", + "devDependencies": { + "pkglint": "^0.7.3-beta" + }, + "dependencies": { + "@types/yargs": "^8.0.3", + "yargs": "^9.0.1", + "merkle-build": "^0.7.3-beta" + }, + "keywords": [ + "aws", + "cdk" + ] +} diff --git a/tools/cdk-build-tools/tsconfig.json b/tools/cdk-build-tools/tsconfig.json new file mode 100644 index 0000000000000..0c0d4afb8615a --- /dev/null +++ b/tools/cdk-build-tools/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2018", + "lib": ["es2016", "es2017.object", "es2017.string"], + "module": "commonjs", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "inlineSourceMap": true, + "inlineSources": true + }, + "exclude": [ + "test/enrichments/**", + "module-template/**" + ] +} diff --git a/tools/cdk-integ-tools/.gitignore b/tools/cdk-integ-tools/.gitignore new file mode 100644 index 0000000000000..05d90bf6140e1 --- /dev/null +++ b/tools/cdk-integ-tools/.gitignore @@ -0,0 +1,6 @@ +*.js +*.js.map +*.d.ts +dist + +.LAST_BUILD \ No newline at end of file diff --git a/tools/cdk-integ-tools/.npmignore b/tools/cdk-integ-tools/.npmignore new file mode 100644 index 0000000000000..414172bb772ec --- /dev/null +++ b/tools/cdk-integ-tools/.npmignore @@ -0,0 +1,6 @@ +# Don't include original .ts files when doing `npm pack` +*.ts +!*.d.ts +coverage +.nyc_output +*.tgz diff --git a/tools/cdk-integ-tools/README.md b/tools/cdk-integ-tools/README.md new file mode 100644 index 0000000000000..8b7dd248752ec --- /dev/null +++ b/tools/cdk-integ-tools/README.md @@ -0,0 +1,9 @@ +CDK Build Tools +================ + +These scripts wrap the common operations that need to happen +during a CDK build, in a common place so it's easy to change +the build for all packages. + +Written in TypeScript instead of shell so that they can work +on Windows with no extra effort. diff --git a/packages/@aws-cdk/assert/bin/cdk-integ b/tools/cdk-integ-tools/bin/cdk-integ similarity index 100% rename from packages/@aws-cdk/assert/bin/cdk-integ rename to tools/cdk-integ-tools/bin/cdk-integ diff --git a/packages/@aws-cdk/assert/bin/cdk-integ-assert b/tools/cdk-integ-tools/bin/cdk-integ-assert similarity index 100% rename from packages/@aws-cdk/assert/bin/cdk-integ-assert rename to tools/cdk-integ-tools/bin/cdk-integ-assert diff --git a/packages/@aws-cdk/assert/bin/cdk-integ-assert.ts b/tools/cdk-integ-tools/bin/cdk-integ-assert.ts similarity index 100% rename from packages/@aws-cdk/assert/bin/cdk-integ-assert.ts rename to tools/cdk-integ-tools/bin/cdk-integ-assert.ts diff --git a/packages/@aws-cdk/assert/bin/cdk-integ.ts b/tools/cdk-integ-tools/bin/cdk-integ.ts similarity index 100% rename from packages/@aws-cdk/assert/bin/cdk-integ.ts rename to tools/cdk-integ-tools/bin/cdk-integ.ts diff --git a/tools/cdk-integ-tools/chmod.bat b/tools/cdk-integ-tools/chmod.bat new file mode 100644 index 0000000000000..59ac42c0974a0 --- /dev/null +++ b/tools/cdk-integ-tools/chmod.bat @@ -0,0 +1,2 @@ +@rem Just here so that running 'chmod' doesn't fail on Windows. +@rem Doesn't actually do anything, because it doesn't need to. diff --git a/packages/@aws-cdk/assert/lib/integ-helpers.ts b/tools/cdk-integ-tools/lib/integ-helpers.ts similarity index 100% rename from packages/@aws-cdk/assert/lib/integ-helpers.ts rename to tools/cdk-integ-tools/lib/integ-helpers.ts diff --git a/tools/cdk-integ-tools/package-lock.json b/tools/cdk-integ-tools/package-lock.json new file mode 100644 index 0000000000000..52458742aab50 --- /dev/null +++ b/tools/cdk-integ-tools/package-lock.json @@ -0,0 +1,513 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@types/yargs": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-8.0.3.tgz", + "integrity": "sha512-YdxO7zGQf2qJeMgR0fNO8QTlj88L2zCP5GOddovoTyetgLiNDOUXcWzhWKb4EdZZlOjLQUA0JM8lW7VcKQL+9w==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "4.1.3", + "shebang-command": "1.2.0", + "which": "1.3.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "0.2.1" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "requires": { + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "requires": { + "locate-path": "2.0.0" + } + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "hosted-git-info": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "requires": { + "builtin-modules": "1.1.1" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "1.0.0" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "strip-bom": "3.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "requires": { + "p-locate": "2.0.0", + "path-exists": "3.0.0" + } + }, + "lru-cache": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", + "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "requires": { + "mimic-fn": "1.2.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "requires": { + "hosted-git-info": "2.7.1", + "is-builtin-module": "1.0.0", + "semver": "5.5.0", + "validate-npm-package-license": "3.0.3" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "requires": { + "path-key": "2.0.1" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "requires": { + "execa": "0.7.0", + "lcid": "1.0.0", + "mem": "1.1.0" + } + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "requires": { + "p-try": "1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "requires": { + "p-limit": "1.3.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "requires": { + "error-ex": "1.3.2" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "requires": { + "pify": "2.3.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "requires": { + "load-json-file": "2.0.0", + "normalize-package-data": "2.4.0", + "path-type": "2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "requires": { + "find-up": "2.1.0", + "read-pkg": "2.0.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "spdx-correct": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "requires": { + "spdx-expression-parse": "3.0.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "requires": { + "spdx-exceptions": "2.1.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + }, + "validate-npm-package-license": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "requires": { + "spdx-correct": "3.0.0", + "spdx-expression-parse": "3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } + } + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yargs": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-9.0.1.tgz", + "integrity": "sha1-UqzCP+7Kw0BCB47njAwAf1CF20w=", + "requires": { + "camelcase": "4.1.0", + "cliui": "3.2.0", + "decamelize": "1.2.0", + "get-caller-file": "1.0.3", + "os-locale": "2.1.0", + "read-pkg-up": "2.0.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "3.2.1", + "yargs-parser": "7.0.0" + } + }, + "yargs-parser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", + "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", + "requires": { + "camelcase": "4.1.0" + } + } + } +} diff --git a/tools/cdk-integ-tools/package.json b/tools/cdk-integ-tools/package.json new file mode 100644 index 0000000000000..8373a9f6d75b1 --- /dev/null +++ b/tools/cdk-integ-tools/package.json @@ -0,0 +1,42 @@ +{ + "name": "cdk-integ-tools", + "private": true, + "version": "0.7.3-beta", + "description": "Package with integration test scripts for CDK packages", + "main": "index.js", + "repository": { + "type": "git", + "url": "git://github.com/awslabs/aws-cdk" + }, + "bin": { + "cdk-integ": "bin/cdk-integ", + "cdk-integ-assert": "bin/cdk-integ-assert" + }, + "scripts": { + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", + "pkglint": "pkglint -f" + }, + "author": { + "name": "Amazon Web Services", + "url": "https://aws.amazon.com" + }, + "license": "LicenseRef-LICENSE", + "devDependencies": { + "@types/yargs": "^8.0.3", + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" + }, + "dependencies": { + "@aws-cdk/cx-api": "^0.7.3-beta", + "@aws-cdk/cloudformation-diff": "^0.7.3-beta", + "aws-cdk": "^0.7.3-beta", + "yargs": "^9.0.1" + }, + "keywords": [ + "aws", + "cdk" + ] +} diff --git a/tools/cdk-integ-tools/tsconfig.json b/tools/cdk-integ-tools/tsconfig.json new file mode 100644 index 0000000000000..0c0d4afb8615a --- /dev/null +++ b/tools/cdk-integ-tools/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2018", + "lib": ["es2016", "es2017.object", "es2017.string"], + "module": "commonjs", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "inlineSourceMap": true, + "inlineSources": true + }, + "exclude": [ + "test/enrichments/**", + "module-template/**" + ] +} diff --git a/tools/cfn2ts/.gitignore b/tools/cfn2ts/.gitignore index ab6fc3c4dde48..7f2681ff06b36 100644 --- a/tools/cfn2ts/.gitignore +++ b/tools/cfn2ts/.gitignore @@ -2,3 +2,7 @@ node_modules *.js.map *.d.ts + +.LAST_BUILD +.nyc_output +coverage \ No newline at end of file diff --git a/tools/cfn2ts/package.json b/tools/cfn2ts/package.json index 2a4b44a18b522..22fc07db36ee6 100644 --- a/tools/cfn2ts/package.json +++ b/tools/cfn2ts/package.json @@ -13,12 +13,16 @@ "cfn2ts": "bin/cfn2ts" }, "scripts": { - "build": "tslint -p . && tsc && chmod +x bin/cfn2ts && pkglint", - "watch": "tsc -w", - "lint": "tsc && tslint -p . --force", - "test": "nodeunit test/test.*.js", + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", "pkglint": "pkglint -f" }, + "nyc": { + "lines": 0, + "branches": 0 + }, "author": { "name": "Amazon Web Services", "url": "https://aws.amazon.com" @@ -35,7 +39,8 @@ "devDependencies": { "@types/fs-extra": "^4.0.8", "@types/yargs": "^8.0.3", - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "keywords": [ "aws", diff --git a/tools/merkle-build/.gitignore b/tools/merkle-build/.gitignore new file mode 100644 index 0000000000000..645838749181d --- /dev/null +++ b/tools/merkle-build/.gitignore @@ -0,0 +1,4 @@ +*.js +*.js.map +*.d.ts +dist diff --git a/tools/merkle-build/.npmignore b/tools/merkle-build/.npmignore new file mode 100644 index 0000000000000..414172bb772ec --- /dev/null +++ b/tools/merkle-build/.npmignore @@ -0,0 +1,6 @@ +# Don't include original .ts files when doing `npm pack` +*.ts +!*.d.ts +coverage +.nyc_output +*.tgz diff --git a/tools/merkle-build/README.md b/tools/merkle-build/README.md new file mode 100644 index 0000000000000..bca0c2dd14d91 --- /dev/null +++ b/tools/merkle-build/README.md @@ -0,0 +1,23 @@ +merkle-build +============ + +Simple routines to speed up build by only rebuilding packages whose source +(or in-tree dependencies) have changed. + +Optimization +------------- + +Since our build involves a lot of separate invocations of build tools on the +same (symlinked) directories over and over, it's a bit wasteful to keep on +calculating the same checksums. + +Speed up the build by setting the environment variable: + + MERKLE_BUILD_CACHE + +To point to a temporary directory. If set, that directory will be used +as an out-of-process cache for the `merkle-build` library. + +Since cache invalidation is one of the hard problems of computer science, +you should be careful to not introduce inconsistencies by (accidentally) +sharing the cache between build runs. diff --git a/tools/merkle-build/lib/calculate.ts b/tools/merkle-build/lib/calculate.ts new file mode 100644 index 0000000000000..c64b920f7b024 --- /dev/null +++ b/tools/merkle-build/lib/calculate.ts @@ -0,0 +1,149 @@ +import crypto = require('crypto'); +import fs = require('fs-extra'); +import path = require('path'); +import { atomicRead, atomicWrite } from './file-ops'; + +/** + * Calculate a hash of the given file or directory + */ +export async function calculateHash(fileOrDirectory: string, options: MerkleOptions = {}): Promise { + const cache = new HashCache(); + + const ignore = options.ignore || []; + + async function calculate(fileName: string): Promise { + fileName = await absolutePath(fileName); + + const stat = await fs.stat(fileName); + if (stat.isFile()) { + // Hash of a file is the hash of the contents. + // + // We don't use the cache since we never hit the same file twice. + const hash = crypto.createHash('sha1'); + hash.update(await fs.readFile(fileName)); + return hash.digest('hex'); + } else { + // Hash of a directory is the hash of an entry table. + // + // We do use the cache since we could encounter the same directory + // multiple times through symlinks. + const cachedHash = await cache.get(fileName); + if (cachedHash !== undefined) { return cachedHash; } + cache.markCalculating(fileName); + + const hash = crypto.createHash('sha1'); + for (const entry of await fs.readdir(fileName)) { + if (entry.startsWith('.') && !options.includeHidden) { continue; } + if (ignore.indexOf(entry) !== -1) { continue; } + hash.update(entry); + hash.update("|"); + hash.update(await calculate(path.join(fileName, entry))); + hash.update("|"); + } + + const hashString = hash.digest('hex'); + await cache.store(fileName, hashString); + return hashString; + } + } + + return calculate(fileOrDirectory); +} + +/** + * Return the absolute path of a file, resolving symlinks if it's a symlink + * + * NOTE: This does not resolve symlinks in the middle of the absolute path. + */ +async function absolutePath(fileName: string): Promise { + const stat = await fs.lstat(fileName); + if (!stat.isSymbolicLink()) { return path.resolve(fileName); } + const link = await fs.readlink(fileName); + return path.resolve(path.dirname(fileName), link); +} + +export interface MerkleOptions { + /** + * Files/directories to not include in hash + */ + ignore?: string[]; + + /** + * Whether include hidden files in the hash + * + * @default false + */ + includeHidden?: boolean; +} + +/** + * This value is put into the cache if we are currently calculating a directory hash + * + * This is used to detect symlink cycles. + */ +const CALCULATING_MARKER = '*calculating*'; + +/** + * Hash cache + * + * Because of monorepo symlinks, it's expected that we'll encounter the + * same directory more than once. We store the hash of already-visited + * directories in the cache to save time. + * + * At the same time, we use the cache for cycle detection. + * + * In principle this cache is in memory, but it can be persisted to + * disk if an environment variable point to a directory is set. + */ +class HashCache { + private readonly cache: {[fileName: string]: string} = {}; + private readonly persistentCacheDir?: string; + + public constructor() { + this.persistentCacheDir = process.env.MERKLE_BUILD_CACHE; + } + + public async get(fullPath: string): Promise { + if (this.cache[fullPath] === CALCULATING_MARKER) { + throw new Error(`${fullPath}: symlink loop detected, cannot calculate directory hash`); + } + + if (fullPath in this.cache) { + return this.cache[fullPath]; + } + + if (this.persistentCacheDir) { + return await atomicRead(path.join(this.persistentCacheDir, safeFileName(fullPath))); + } + + return undefined; + } + + public async store(fullPath: string, hash: string): Promise { + this.cache[fullPath] = hash; + + if (this.persistentCacheDir) { + await atomicWrite(path.join(this.persistentCacheDir, safeFileName(fullPath)), hash); + } + } + + public markCalculating(fullPath: string) { + this.cache[fullPath] = CALCULATING_MARKER; + } +} + +/** + * Make a filename that's safe to store on disk + * + * Typically the full path name is too long so we take the end + * and append a hash for the whole name. + */ +function safeFileName(fileName: string) { + const h = crypto.createHash('sha1'); + h.update(fileName); + + const encodedName = encodeURIComponent(fileName); + + const maxLength = 150; + return encodedName.substr(Math.max(0, encodedName.length - maxLength)) + h.digest('hex'); +} \ No newline at end of file diff --git a/tools/merkle-build/lib/change-detector.ts b/tools/merkle-build/lib/change-detector.ts new file mode 100644 index 0000000000000..6dfd6943acd44 --- /dev/null +++ b/tools/merkle-build/lib/change-detector.ts @@ -0,0 +1,38 @@ +import path = require('path'); +import { calculateHash, MerkleOptions } from "./calculate"; +import { atomicRead, atomicWrite } from './file-ops'; + +/** + * Calculate the folder hash and see if it changed since the last build + */ +export class ChangeDetector { + private readonly markerFileName: string; + + constructor(private directory: string, private options: ChangeDetectorOptions = {}) { + this.markerFileName = path.join(directory, options.markerFile || '.LAST_BUILD'); + } + + /** + * Return whether the folder hash changed since last time + */ + public async isChanged(): Promise { + const marker = await atomicRead(this.markerFileName); + if (marker === undefined) { return true; } + const actual = await calculateHash(this.directory, this.options); + return marker !== actual; + } + + public async markClean(): Promise { + const hash = await calculateHash(this.directory, this.options); + await atomicWrite(this.markerFileName, hash); + } +} + +export interface ChangeDetectorOptions extends MerkleOptions { + /** + * What file name to use to store hash data in + * + * @default .LAST_BUILD + */ + markerFile?: string; +} \ No newline at end of file diff --git a/tools/merkle-build/lib/file-ops.ts b/tools/merkle-build/lib/file-ops.ts new file mode 100644 index 0000000000000..f104b1c6c488c --- /dev/null +++ b/tools/merkle-build/lib/file-ops.ts @@ -0,0 +1,25 @@ +import crypto = require('crypto'); +import fs = require('fs-extra'); +import path = require('path'); + +/** + * Return actual file contents or undefined if not exists + */ +export async function atomicRead(fileName: string): Promise { + try { + return await fs.readFile(fileName, { encoding: 'utf-8' }); + } catch (e) { + if (e.code === 'ENOENT') { return undefined; } + throw e; + } +} + +/** + * Atomically write a file + */ +export async function atomicWrite(fileName: string, contents: string) { + // NodeJS has no tempfile API :/ + const tempFile = path.join(path.dirname(fileName), path.basename(fileName) + '.' + crypto.randomBytes(8).toString('hex')); + await fs.writeFile(tempFile, contents, { encoding: 'utf-8' }); + await fs.rename(tempFile, fileName); +} \ No newline at end of file diff --git a/tools/merkle-build/lib/index.ts b/tools/merkle-build/lib/index.ts new file mode 100644 index 0000000000000..fd345b4e6f75f --- /dev/null +++ b/tools/merkle-build/lib/index.ts @@ -0,0 +1,2 @@ +export * from './calculate'; +export * from './change-detector'; diff --git a/tools/merkle-build/package-lock.json b/tools/merkle-build/package-lock.json new file mode 100644 index 0000000000000..26e610de07137 --- /dev/null +++ b/tools/merkle-build/package-lock.json @@ -0,0 +1,47 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@types/fs-extra": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-4.0.8.tgz", + "integrity": "sha512-Z5nu9Pbxj9yNeXIK3UwGlRdJth4cZ5sCq05nI7FaI6B0oz28nxkOtp6Lsz0ZnmLHJGvOJfB/VHxSTbVq/i6ujA==", + "requires": { + "@types/node": "10.5.2" + } + }, + "@types/node": { + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==" + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.2" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "4.1.11" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + } + } +} diff --git a/tools/merkle-build/package.json b/tools/merkle-build/package.json new file mode 100644 index 0000000000000..e80b39de80e94 --- /dev/null +++ b/tools/merkle-build/package.json @@ -0,0 +1,33 @@ +{ + "name": "merkle-build", + "private": true, + "version": "0.7.3-beta", + "description": "Build tool helper for calculating hashes of a Merkle tree", + "main": "lib/index.js", + "types": "lib/index.ts", + "repository": { + "type": "git", + "url": "git://github.com/awslabs/aws-cdk" + }, + "scripts": { + "build": "tsc && tslint -p . && pkglint", + "watch": "tsc -w", + "pkglint": "pkglint -f" + }, + "author": { + "name": "Amazon Web Services", + "url": "https://aws.amazon.com" + }, + "license": "LicenseRef-LICENSE", + "devDependencies": { + "pkglint": "^0.7.3-beta", + "@types/fs-extra": "^4.0.8" + }, + "dependencies": { + "fs-extra": "^4.0.2" + }, + "keywords": [ + "aws", + "cdk" + ] +} diff --git a/tools/merkle-build/tsconfig.json b/tools/merkle-build/tsconfig.json new file mode 100644 index 0000000000000..0c0d4afb8615a --- /dev/null +++ b/tools/merkle-build/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2018", + "lib": ["es2016", "es2017.object", "es2017.string"], + "module": "commonjs", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "inlineSourceMap": true, + "inlineSources": true + }, + "exclude": [ + "test/enrichments/**", + "module-template/**" + ] +} diff --git a/tools/pkglint/lib/packagejson.ts b/tools/pkglint/lib/packagejson.ts index 10c7ca755fff2..8ae4e7e9c3c96 100644 --- a/tools/pkglint/lib/packagejson.ts +++ b/tools/pkglint/lib/packagejson.ts @@ -47,11 +47,13 @@ export interface Report { export class PackageJson { public readonly json: any; public readonly packageRoot: string; + public readonly packageName: string; private reports: Report[] = []; constructor(public readonly fullPath: string) { this.json = JSON.parse(fs.readFileSync(fullPath, { encoding: 'utf-8' })); this.packageRoot = path.dirname(path.resolve(fullPath)); + this.packageName = this.json.name; } public save() { @@ -97,12 +99,19 @@ export class PackageJson { return (this.json.scripts || {})[name] || ''; } - public replaceNpmScript(name: string, command: string) { + /** + * Apply a function the script + * + * If you want to change a script, use this to prevent multiple + * fixes going { read, read, write, write } on the same script. + */ + public changeNpmScript(name: string, fn: (script: string) => string) { + const script = this.npmScript(name); + if (!('scripts' in this.json)) { this.json.scripts = {}; } - - this.json.scripts[name] = command; + this.json.scripts[name] = fn(script); } /** @@ -122,11 +131,11 @@ export class PackageJson { } /** - * @returns True if the package has a devDependency on `module`. + * Return the version of the devDependency on `module`. */ - public hasDevDependency(moduleOrPredicate: ((s: string) => boolean) | string) { + public getDevDependency(moduleOrPredicate: ((s: string) => boolean) | string): string | undefined { if (!('devDependencies' in this.json)) { - return false; + return undefined; } const predicate: (s: string) => boolean = typeof(moduleOrPredicate) === 'string' @@ -134,7 +143,8 @@ export class PackageJson { : moduleOrPredicate; const deps = this.json.devDependencies; - return Object.keys(deps).find(predicate); + const key = Object.keys(deps).find(predicate); + return key !== undefined ? deps[key] : undefined; } /** @@ -163,6 +173,37 @@ export class PackageJson { } } } + + /** + * Whether the package-level file contains the given line + */ + public fileContainsSync(fileName: string, line: string): boolean { + const lines = this.readFileLinesSync(fileName); + return lines.indexOf(line) !== -1; + } + + /** + * Add the given line to the package-level file + */ + public addToFileSync(fileName: string, line: string) { + const lines = this.readFileLinesSync(fileName); + if (lines.indexOf(line) === -1) { + lines.push(line); + this.writeFileLinesSync(fileName, lines); + } + } + + private readFileLinesSync(fileName: string): string[] { + const fullPath = path.join(this.packageRoot, fileName); + if (!fs.existsSync(fileName)) { return []; } + return fs.readFileSync(fullPath, { encoding: 'utf-8' }).split('\n'); + } + + private writeFileLinesSync(fileName: string, lines: string[]) { + const fullPath = path.join(this.packageRoot, fileName); + const body = lines.join('\n'); + fs.writeFileSync(fullPath, body, { encoding: 'utf-8' }); + } } /** diff --git a/tools/pkglint/lib/rules.ts b/tools/pkglint/lib/rules.ts index 3190d2af393f2..b03fcd12a9cb5 100644 --- a/tools/pkglint/lib/rules.ts +++ b/tools/pkglint/lib/rules.ts @@ -1,6 +1,7 @@ +import fs = require('fs'); import path = require('path'); import { PackageJson, ValidationRule } from './packagejson'; -import { deepGet, expectJSON } from './util'; +import { deepGet, expectDevDependency, expectJSON, fileShouldContain, monoRepoVersion } from './util'; /** * Verify that the package name matches the directory name @@ -144,7 +145,7 @@ export class NoJsiiDep extends ValidationRule { public validate(pkg: PackageJson): void { const predicate = (s: string) => s.startsWith('jsii'); - if (pkg.hasDevDependency(predicate)) { + if (pkg.getDevDependency(predicate)) { pkg.report({ message: 'packages should not have a devDep on jsii since it is defined at the repo level', fix: () => pkg.removeDevDependency(predicate) @@ -203,45 +204,27 @@ export class JSIIDotNetNamespaceIsRequired extends ValidationRule { } /** - * Build script must mention tslint + * The package must depend on cdk-build-tools */ -export class BuildScriptMustLint extends ValidationRule { +export class MustDependOnBuildTools extends ValidationRule { public validate(pkg: PackageJson): void { - const build = pkg.npmScript('build'); + if (!shouldUseCDKBuildTools(pkg)) { return; } - if (!build) { - pkg.report({ - message: 'Must have a "build" script' - }); - return; - } - - if (build.indexOf('tslint') === -1) { - pkg.report({ - message: '"build" script must use tslint', - fix: () => { pkg.appendToNpmScript('build', 'tslint -p .'); } - }); - } + expectDevDependency(pkg, 'cdk-build-tools', '^' + monoRepoVersion()); } } /** - * Must have lint command + * Build script must be 'cdk-build' */ -export class MustHaveLintScript extends ValidationRule { +export class MustUseCDKBuild extends ValidationRule { public validate(pkg: PackageJson): void { - const lint = pkg.npmScript('lint'); + if (!shouldUseCDKBuildTools(pkg)) { return; } - if (!pkg.json.scripts) { - pkg.json.scripts = {}; - } + expectJSON(pkg, 'scripts.build', 'cdk-build'); - if (!lint) { - pkg.report({ - message: 'Package must have a "lint" script', - fix: () => { pkg.json.scripts.lint = 'tsc && tslint -p . --force'; } - }); - } + // cdk-build will write a hash file that we have to ignore. + fileShouldContain(pkg, '.gitignore', '.LAST_BUILD'); } } @@ -262,7 +245,7 @@ export class GlobalDevDependencies extends ValidationRule { ]; for (const dep of deps) { - if (pkg.hasDevDependency(dep)) { + if (pkg.getDevDependency(dep)) { pkg.report({ message: `devDependency ${dep} is defined at the repo level`, fix: () => pkg.removeDevDependency(dep) @@ -273,55 +256,44 @@ export class GlobalDevDependencies extends ValidationRule { } /** - * Must have watch command + * Must use 'cdk-watch' command */ -export class MustHaveWatchCommand extends ValidationRule { +export class MustUseCDKWatch extends ValidationRule { public validate(pkg: PackageJson): void { - if (isJSII(pkg)) { - expectJSON(pkg, 'scripts.watch', 'jsii -w'); - } else { - expectJSON(pkg, 'scripts.watch', 'tsc -w'); - } + if (!shouldUseCDKBuildTools(pkg)) { return; } + + expectJSON(pkg, 'scripts.watch', 'cdk-watch'); } } /** - * Scripts that run integ tests must also have the individual 'integ' script to update them + * Must use 'cdk-test' command */ -export class MustHaveIntegCommand extends ValidationRule { +export class MustUseCDKTest extends ValidationRule { public validate(pkg: PackageJson): void { - if (hasInteg(pkg)) { - expectJSON(pkg, 'scripts.integ', 'cdk-integ'); - } + if (!shouldUseCDKBuildTools(pkg)) { return; } + if (!hasTestDirectory(pkg)) { return; } + + expectJSON(pkg, 'scripts.test', 'cdk-test'); + + // 'cdk-test' will calculate coverage, so have the appropriate + // files in .gitignore. + fileShouldContain(pkg, '.gitignore', '.nyc_output'); + fileShouldContain(pkg, '.gitignore', 'coverage'); } } /** - * All packages must use the validator as part of their build step + * Scripts that run integ tests must also have the individual 'integ' script to update them * - * (Except the validator itself) + * This commands comes from the dev-dependency cdk-integ-tools. */ -export class PkgLintInBuild extends ValidationRule { +export class MustHaveIntegCommand extends ValidationRule { public validate(pkg: PackageJson): void { - if (pkg.json.name === 'pkglint') { - return; - } + if (!hasIntegTests(pkg)) { return; } - const build = pkg.npmScript('build'); - - if (build.indexOf('pkglint') === -1) { - pkg.report({ - message: 'Package must use validator as part of build', - fix: () => { pkg.appendToNpmScript('build', 'pkglint'); } - }); - } - - if (!pkg.hasDevDependency('pkglint')) { - pkg.report({ - message: 'pkglint must be defined as a devDep', - fix: () => { pkg.addDevDependency('pkglint', '^' + require('../package.json').version); } - }); - } + expectJSON(pkg, 'scripts.integ', 'cdk-integ'); + expectDevDependency(pkg, 'cdk-integ-tools', '^' + monoRepoVersion()); } } @@ -332,14 +304,14 @@ export class PkgLintAsScript extends ValidationRule { if (!pkg.npmScript('pkglint')) { pkg.report({ message: 'a script called "pkglint" must be included to allow fixing package linting issues', - fix: () => pkg.replaceNpmScript('pkglint', script) + fix: () => pkg.changeNpmScript('pkglint', () => script) }); } if (pkg.npmScript('pkglint') !== script) { pkg.report({ message: 'the pkglint script should be: ' + script, - fix: () => pkg.replaceNpmScript('pkglint', script) + fix: () => pkg.changeNpmScript('pkglint', () => script) }); } } @@ -445,11 +417,19 @@ export class AllVersionsTheSame extends ValidationRule { /** * Determine whether this is a JSII package * - * A package is a JSII package if the 'build' script mentions JSII. + * A package is a JSII package if there is 'jsii' section in the package.json */ -function isJSII(pkg: PackageJson) { - const buildScript = (pkg.json.scripts || {}).build || ''; - return buildScript.indexOf('jsii ') >= 0; +function isJSII(pkg: PackageJson): boolean { + return pkg.json.jsii; +} + +/** + * Determine whether the package has tests + * + * A package has tests if the root/test directory exists + */ +function hasTestDirectory(pkg: PackageJson) { + return fs.existsSync(path.join(pkg.packageRoot, 'test')); } /** @@ -457,7 +437,18 @@ function isJSII(pkg: PackageJson) { * * A package has integ tests if it mentions 'cdk-integ' in the "test" script. */ -function hasInteg(pkg: PackageJson) { - const testScript = (pkg.json.scripts || {}).test || ''; - return testScript.indexOf('cdk-integ') >= 0; +function hasIntegTests(pkg: PackageJson) { + if (!hasTestDirectory(pkg)) { return false; } + + const files = fs.readdirSync(path.join(pkg.packageRoot, 'test')); + return files.some(p => p.startsWith('integ.')); +} + +/** + * Return whether this package should use CDK build tools + */ +function shouldUseCDKBuildTools(pkg: PackageJson) { + // The packages that DON'T use CDKBuildTools are the package itself + // and the packages used by it. + return pkg.packageName !== 'cdk-build-tools' && pkg.packageName !== 'merkle-build'; } diff --git a/tools/pkglint/lib/util.ts b/tools/pkglint/lib/util.ts index 9b7529cc4e92b..30db9073d773b 100644 --- a/tools/pkglint/lib/util.ts +++ b/tools/pkglint/lib/util.ts @@ -1,19 +1,47 @@ +import fs = require('fs'); +import path = require('path'); import { PackageJson } from "./packagejson"; /** * Expect a particular JSON key to be a given value */ -export function expectJSON(pkg: PackageJson, path: string, expected: any) { - const parts = path.split('.'); +export function expectJSON(pkg: PackageJson, jsonPath: string, expected: any) { + const parts = jsonPath.split('.'); const actual = deepGet(pkg.json, parts); if (actual !== expected) { pkg.report({ - message: `${path} should be '${expected}', is '${actual}'`, + message: `${jsonPath} should be '${expected}', is '${actual}'`, fix: () => { deepSet(pkg.json, parts, expected); } }); } } +/** + * Export a package-level file to contain a given line + */ +export function fileShouldContain(pkg: PackageJson, fileName: string, line: string) { + const doesContain = pkg.fileContainsSync(fileName, line); + if (!doesContain) { + pkg.report({ + message: `${fileName} should contain '${line}'`, + fix: () => pkg.addToFileSync(fileName, line) + }); + } +} + +/** + * Enforce a dev dependency + */ +export function expectDevDependency(pkg: PackageJson, packageName: string, version: string) { + const actualVersion = pkg.getDevDependency(packageName); + if (version !== actualVersion) { + pkg.report({ + message: `Missing devDependency: ${packageName} @ ${version}`, + fix: () => pkg.addDevDependency(packageName, version) + }); + } +} + /** * Return whether the given value is an object * @@ -30,14 +58,14 @@ export function isObject(x: any) { * Returns undefined if any part of the path was unset or * not an object. */ -export function deepGet(x: any, path: string[]): any { - path = path.slice(); +export function deepGet(x: any, jsonPath: string[]): any { + jsonPath = jsonPath.slice(); - while (path.length > 0 && isObject(x)) { - const key = path.shift()!; + while (jsonPath.length > 0 && isObject(x)) { + const key = jsonPath.shift()!; x = x[key]; } - return path.length === 0 ? x : undefined; + return jsonPath.length === 0 ? x : undefined; } /** @@ -45,15 +73,15 @@ export function deepGet(x: any, path: string[]): any { * * Throws an error if any part of the path is not an object. */ -export function deepSet(x: any, path: string[], value: any) { - path = path.slice(); +export function deepSet(x: any, jsonPath: string[], value: any) { + jsonPath = jsonPath.slice(); - if (path.length === 0) { + if (jsonPath.length === 0) { throw new Error('Path may not be empty'); } - while (path.length > 1 && isObject(x)) { - const key = path.shift()!; + while (jsonPath.length > 1 && isObject(x)) { + const key = jsonPath.shift()!; if (!(key in x)) { x[key] = {}; } x = x[key]; } @@ -62,5 +90,31 @@ export function deepSet(x: any, path: string[], value: any) { throw new Error(`Expected an object, got '${x}'`); } - x[path[0]] = value; -} \ No newline at end of file + x[jsonPath[0]] = value; +} + +/** + * Find 'lerna.json' and read the global package version from there + */ +export function monoRepoVersion() { + const found = findLernaJSON(); + const lernaJson = require(found); + return lernaJson.version; +} + +function findLernaJSON() { + let dir = process.cwd(); + while (true) { + const fullPath = path.join(dir, 'lerna.json'); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parent = path.dirname(dir); + if (parent === dir) { + throw new Error('Could not find lerna.json'); + } + + dir = parent; + } +} diff --git a/tools/pkgtools/.gitignore b/tools/pkgtools/.gitignore index 645838749181d..05d90bf6140e1 100644 --- a/tools/pkgtools/.gitignore +++ b/tools/pkgtools/.gitignore @@ -2,3 +2,5 @@ *.js.map *.d.ts dist + +.LAST_BUILD \ No newline at end of file diff --git a/tools/pkgtools/package.json b/tools/pkgtools/package.json index e9c1f10a21e4f..a36702191e3d1 100644 --- a/tools/pkgtools/package.json +++ b/tools/pkgtools/package.json @@ -13,10 +13,11 @@ "find-jsii-packages": "bin/find-jsii-packages" }, "scripts": { - "build": "tsc && tslint -p . && chmod +x bin/find-jsii-packages && chmod +x bin/cdk-version && pkglint", - "watch": "tsc -w", - "lint": "tslint -p . --force", - "pkglint": "pkglint -f" + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "pkglint": "pkglint -f", + "test": "cdk-test" }, "author": { "name": "Amazon Web Services", @@ -24,7 +25,8 @@ }, "license": "LicenseRef-LICENSE", "devDependencies": { - "pkglint": "^0.7.3-beta" + "pkglint": "^0.7.3-beta", + "cdk-build-tools": "^0.7.3-beta" }, "dependencies": { "@types/fs-extra": "^4.0.8",