-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BREAKING] Move @aws-cdk/resources
classes into L2 packages
#264
Changes from 1 commit
dcd89bc
bb7c332
1ba5f7f
27dad9a
e46f5f8
826dc09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use hyphens in file names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
set -euo pipefail | ||
|
||
VERSION=$(node -e 'console.log(require("./lerna.json").version);') | ||
|
||
for S in $(node -e 'console.log(require("./packages/@aws-cdk/cloudformation-resource-spec").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 | ||
echo '*.js' >> packages/${P}/.gitignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please use HEREDOCs instead? Will be wayyyy more readable... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I find the fact that HEREDOCs require you to break indentation very disturbing, BTW). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know. Me too, but they are still way better than this 😜 |
||
echo '*.js.map' >> packages/${P}/.gitignore | ||
echo '*.d.ts' >> packages/${P}/.gitignore | ||
echo 'tsconfig.json' >> packages/${P}/.gitignore | ||
echo 'tslint.json' >> packages/${P}/.gitignore | ||
echo 'node_modules' >> packages/${P}/.gitignore | ||
echo 'cfn' >> packages/${P}/.gitignore | ||
echo 'dist' >> packages/${P}/.gitignore | ||
|
||
echo "# Don't include original .ts files when doing \`npm pack\`" >> packages/${P}/.npmignore | ||
echo '*.ts' >> packages/${P}/.npmignore | ||
echo '!*.d.ts' >> packages/${P}/.npmignore | ||
echo 'coverage' >> packages/${P}/.npmignore | ||
echo '.nyc_output' >> packages/${P}/.npmignore | ||
echo '*.tgz' >> packages/${P}/.npmignore | ||
|
||
echo '{' >> packages/${P}/package.json | ||
echo " \"name\": \"${P}\"," >> packages/${P}/package.json | ||
echo " \"version\": \"${VERSION}\"," >> packages/${P}/package.json | ||
echo " \"description\": \"The CDK Construct Library for ${S}\"," >> packages/${P}/package.json | ||
echo " \"main\": \"lib/index.js\"," >> packages/${P}/package.json | ||
echo " \"types\": \"lib/index.d.ts\"," >> packages/${P}/package.json | ||
echo " \"jsii\": {" >> packages/${P}/package.json | ||
echo " \"outdir\": \"dist\"," >> packages/${P}/package.json | ||
echo " \"bundledDependencies\": []," >> packages/${P}/package.json | ||
echo " \"names\": {" >> packages/${P}/package.json | ||
echo " \"java\": \"com.amazonaws.cdk.${PB}\"," >> packages/${P}/package.json | ||
echo " \"dotnet\": \"${S/AWS::/Aws.Cdk.}\"" >> packages/${P}/package.json | ||
echo " }" >> packages/${P}/package.json | ||
echo " }," >> packages/${P}/package.json | ||
echo " \"repository\": {" >> packages/${P}/package.json | ||
echo " \"type\": \"git\"," >> packages/${P}/package.json | ||
echo " \"url\": \"git://github.com/awslabs/aws-cdk\"" >> packages/${P}/package.json | ||
echo " }," >> packages/${P}/package.json | ||
echo " \"scripts\": {" >> packages/${P}/package.json | ||
echo " \"build\": \"cfn2ts --scope=${S} && jsii && tslint -p . && pkglint\"," >> packages/${P}/package.json | ||
echo " \"watch\": \"jsii -w\"," >> packages/${P}/package.json | ||
echo " \"lint\": \"jsii && tslint -p . --force\"," >> packages/${P}/package.json | ||
echo " \"test\": \"nodeunit test/test.*.js && cdk-integ-assert\"," >> packages/${P}/package.json | ||
echo " \"integ\": \"cdk-integ\"," >> packages/${P}/package.json | ||
echo " \"pkglint\": \"pkglint -f\"" >> packages/${P}/package.json | ||
echo " }," >> packages/${P}/package.json | ||
echo " \"keywords\": [" >> packages/${P}/package.json | ||
echo " \"aws\"," >> packages/${P}/package.json | ||
echo " \"cdk\"," >> packages/${P}/package.json | ||
echo " \"constructs\"," >> packages/${P}/package.json | ||
echo " \"${PB}\"" >> packages/${P}/package.json | ||
echo " ]," >> packages/${P}/package.json | ||
echo " \"author\": {" >> packages/${P}/package.json | ||
echo " \"name\": \"Amazon Web Services\"," >> packages/${P}/package.json | ||
echo " \"url\": \"https://aws.amazon.com\"" >> packages/${P}/package.json | ||
echo " }," >> packages/${P}/package.json | ||
echo " \"license\": \"LicenseRef-LICENSE\"," >> packages/${P}/package.json | ||
echo " \"devDependencies\": {" >> packages/${P}/package.json | ||
echo " \"@aws-cdk/assert\": \"^${VERSION}\"," >> packages/${P}/package.json | ||
echo " \"cfn2ts\": \"^${VERSION}\"," >> packages/${P}/package.json | ||
echo " \"pkglint\": \"^${VERSION}\"" >> packages/${P}/package.json | ||
echo " }," >> packages/${P}/package.json | ||
echo " \"dependencies\": {" >> packages/${P}/package.json | ||
echo " \"@aws-cdk/core\": \"^${VERSION}\"," >> packages/${P}/package.json | ||
echo " \"@aws-cdk/runtime\": \"^${VERSION}\"" >> packages/${P}/package.json | ||
echo " }" >> packages/${P}/package.json | ||
echo '}' >> packages/${P}/package.json | ||
|
||
echo "// The L1 Library for ${S}:" >> packages/${P}/lib/index.ts | ||
echo "export * from '../cfn/${PB}';" >> packages/${P}/lib/index.ts | ||
|
||
echo "import { Test, testCase } from 'nodeunit';" >> packages/${P}/test/test.${PB}.ts | ||
echo "" >> packages/${P}/test/test.${PB}.ts | ||
echo "exports = testCase({" >> packages/${P}/test/test.${PB}.ts | ||
echo " notTested(test: Test) {" >> packages/${P}/test/test.${PB}.ts | ||
echo " test.ok(true, 'No tests are specified for this package.');" >> packages/${P}/test/test.${PB}.ts | ||
echo " test.done();" >> packages/${P}/test/test.${PB}.ts | ||
echo " }" >> packages/${P}/test/test.${PB}.ts | ||
echo "});" >> packages/${P}/test/test.${PB}.ts | ||
|
||
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}" | ||
fi | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { Construct } from '@aws-cdk/core'; | ||
import * as dynamodb from '@aws-cdk/dynamodb'; | ||
import { KeyAttributeType, Table } from '@aws-cdk/dynamodb'; | ||
|
||
export class DynamoPostsTable extends Construct { | ||
constructor(parent: Construct, name: string) { | ||
super(parent, name); | ||
|
||
const table = new dynamodb.Table(this, 'Table', { | ||
const table = new Table(this, 'Table', { | ||
readCapacity: 5, writeCapacity: 5 | ||
}); | ||
|
||
table.addPartitionKey('Alias', dynamodb.KeyAttributeType.String); | ||
table.addSortKey('Timestamp', dynamodb.KeyAttributeType.String); | ||
table.addPartitionKey('Alias', KeyAttributeType.String); | ||
table.addSortKey('Timestamp', KeyAttributeType.String); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ tsconfig.json | |
tslint.json | ||
*.js.map | ||
*.d.ts | ||
node_modules | ||
cfn | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from './certificate'; | ||
export * from './certificate-ref'; | ||
|
||
// The L1 library for AWS::CertificateManager: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the terminology There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
export * from '../cfn/certificatemanager'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.js | ||
*.js.map | ||
*.d.ts | ||
tsconfig.json | ||
tslint.json | ||
node_modules | ||
cfn | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// The L1 Library for AWS::ApiGateway: | ||
export * from '../cfn/apigateway'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the generated code should go under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, make sure cfn2ts creates a README file under the generated directory that says that it is generated and from which spec date There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That information is already included in the generated file itself... Do we really need it repeated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, you are right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this build symlinks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope,
lerna bootstrap
will have done that at theinstall.sh
step. I can duplicate the bootstrap command, though if you feel it's better... It's incredibly cheap to run.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should automatically run
./install.sh
isnode_modules
doesn't exist.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already do (L4-6 in
build.sh
).