forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-missing-libraries.sh
executable file
·135 lines (123 loc) · 3.21 KB
/
create-missing-libraries.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/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 \
--scope=@aws-cdk/assert \
--scope=@aws-cdk/cfnspec \
--scope=@aws-cdk/cloudformation-diff \
--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/cfnspec").namespaces.join("\n"));'); do
P=$(tr 'A-Z' 'a-z' <<< "${S/AWS::/@aws-cdk/aws-}")
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
.jsii
.nyc_output
coverage
.LAST_BUILD
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",
"targets": {
"java": {
"package": "software.amazon.awscdk.services.${PB}",
"maven": {
"groupId": "software.amazon.awscdk",
"artifactId": "${PB}"
}
},
"dotnet": {
"namespace": "${S/AWS::/Amazon.CDK.AWS.}"
}
}
},
"repository": {
"type": "git",
"url": "git://github.com/awslabs/aws-cdk"
},
"scripts": {
"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",
"constructs",
"${PB}"
],
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com"
},
"license": "LicenseRef-LICENSE",
"devDependencies": {
"@aws-cdk/assert": "^${VERSION}",
"cdk-build-tools": "^${VERSION}",
"cfn2ts": "^${VERSION}",
"pkglint": "^${VERSION}"
},
"dependencies": {
"@aws-cdk/cdk": "^${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