forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BREAKING] Move
@aws-cdk/resources
classes into L2 packages (aws#264)
The `create_missing_libraries.sh` script was used to bootstrap L2 packages for all the namespaces that didn't have one already. Existing L2 packages were manually edited to: - Invoke `cfn2ts` to generate the L1 class library for the service/scope - Depend on `@aws-cdk/runtime` (which used to be blended in `@aws-cdk/resources`, and was extracted out) - Export the L1 library as expected - Generated resource and property classes are namespaced under 'cloudformation' The `@aws-cdk/assert` behavior was changed to rely on `@aws-cdk/cdk-cfnspec` (formerly `@aws-cdk/cloudformation-resource-spec`) to determine the `UpdateType` of attributes, rendering the `registry` mechanism that was introduced to `@aws-cdk/resources` a while ago redundant (hence it got dropped). This required temporarily disabling use of '--reject-cycles' on 'lerna bootstrap' as it would blow up on the cycle created (see aws#293).
- Loading branch information
1 parent
9e711a3
commit aa404a0
Showing
446 changed files
with
4,938 additions
and
32,432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export PATH=node_modules/.bin:$PATH | ||
|
||
# Making sure the bare minimum packages allowing be able to test-build the generated packages is available: | ||
lerna exec --scope=cfn2ts \ | ||
--scope=pkglint \ | ||
--scope=@aws-cdk/cdk-cfnspec \ | ||
--scope=@aws-cdk/assert \ | ||
--scope=@aws-cdk/cloudformation-diff \ | ||
--scope=@aws-cdk/core \ | ||
--scope=@aws-cdk/cx-api \ | ||
--stream \ | ||
npm run build | ||
|
||
VERSION=$(node -e 'console.log(require("./lerna.json").version);') | ||
|
||
for S in $(node -e 'console.log(require("./packages/@aws-cdk/cdk-cfnspec").namespaces.join("\n"));'); do | ||
P=$(tr 'A-Z' 'a-z' <<< "${S/AWS::/@aws-cdk/}") | ||
PB=$(basename ${P}) | ||
if [ ! -d packages/${P} ]; then | ||
echo "⏳ Creating package ${P} for scope ${S}..." | ||
mkdir -p packages/${P}/test | ||
mkdir -p packages/${P}/lib | ||
cat <<EOM > packages/${P}/.gitignore | ||
*.js | ||
*.js.map | ||
*.d.ts | ||
*.generated.ts | ||
tsconfig.json | ||
tslint.json | ||
node_modules | ||
dist | ||
EOM | ||
|
||
cat <<EOM > packages/${P}/.npmignore | ||
# Don't include original .ts files when doing \`npm pack\` | ||
*.ts | ||
!*.d.ts | ||
coverage | ||
.nyc_output | ||
*.tgz | ||
EOM | ||
|
||
cat <<EOM > packages/${P}/package.json | ||
{ | ||
"name": "${P}", | ||
"version": "${VERSION}", | ||
"description": "The CDK Construct Library for ${S}", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"jsii": { | ||
"outdir": "dist", | ||
"bundledDependencies": [], | ||
"names": { | ||
"java": "com.amazonaws.cdk.${PB}", | ||
"dotnet": "${S/AWS::/Aws.Cdk.}" | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"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", | ||
"integ": "cdk-integ", | ||
"pkglint": "pkglint -f" | ||
}, | ||
"keywords": [ | ||
"aws", | ||
"cdk", | ||
"constructs", | ||
"${PB}" | ||
], | ||
"author": { | ||
"name": "Amazon Web Services", | ||
"url": "https://aws.amazon.com" | ||
}, | ||
"license": "LicenseRef-LICENSE", | ||
"devDependencies": { | ||
"@aws-cdk/assert": "^${VERSION}", | ||
"cfn2ts": "^${VERSION}", | ||
"pkglint": "^${VERSION}" | ||
}, | ||
"dependencies": { | ||
"@aws-cdk/core": "^${VERSION}" | ||
} | ||
} | ||
EOM | ||
|
||
cat <<EOM > packages/${P}/lib/index.ts | ||
// ${S} CloudFormation Resources: | ||
export * from './${PB}.generated'; | ||
EOM | ||
|
||
cat <<EOM > packages/${P}/test/test.${PB}.ts | ||
import { Test, testCase } from 'nodeunit'; | ||
import {} from '../lib'; | ||
exports = testCase({ | ||
notTested(test: Test) { | ||
test.ok(true, 'No tests are specified for this package.'); | ||
test.done(); | ||
} | ||
}); | ||
EOM | ||
|
||
echo "⌛️ Bootstrapping & building ${P}" | ||
lerna bootstrap --scope=${P} | ||
lerna run build --scope=${P} | ||
|
||
git add packages/${P} | ||
|
||
echo "✅ Have fun with your new package ${P} (⚠️ don't forget to add it to 'aws-cdk-all')" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
examples/cdk-examples-typescript/chat-app/DynamodbPostsTable.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
examples/cdk-examples-typescript/chat-app/dynamodb-posts-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Construct } from '@aws-cdk/core'; | ||
import { KeyAttributeType, Table } from '@aws-cdk/dynamodb'; | ||
|
||
export class DynamoPostsTable extends Construct { | ||
constructor(parent: Construct, name: string) { | ||
super(parent, name); | ||
|
||
const table = new Table(this, 'Table', { | ||
readCapacity: 5, writeCapacity: 5 | ||
}); | ||
|
||
table.addPartitionKey('Alias', KeyAttributeType.String); | ||
table.addSortKey('Timestamp', KeyAttributeType.String); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.