forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-missing-libraries.sh
executable file
·163 lines (146 loc) · 3.64 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/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
*.d.ts
*.generated.ts
*.js
*.js.map
.jsii
.LAST_BUILD
.LAST_PACKAGE
.nycrc
.nyc_output
coverage
dist
tsconfig.json
tslint.json
EOM
cat <<EOM > packages/${P}/.npmignore
# The basics
*.ts
*.tgz
!*.d.ts
!*.js
# Coverage
coverage
.nyc_output
.nycrc
# Build gear
dist
.LAST_BUILD
.LAST_PACKAGE
.jsii
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": {
"dotnet": {
"namespace": "${S/AWS::/Amazon.CDK.AWS.}",
"packageId": "${S/AWS::/Amazon.CDK.AWS.}",
"signAssembly": true,
"assemblyOriginatorKeyFile": "../../key.snk"
},
"java": {
"package": "software.amazon.awscdk.${PB/aws-/services.}",
"maven": {
"groupId": "software.amazon.awscdk",
"artifactId": "${PB/aws-/}"
}
},
"sphinx": {}
}
},
"repository": {
"type": "git",
"url": "https://github.com/awslabs/aws-cdk.git"
},
"homepage": "https://github.com/awslabs/aws-cdk",
"scripts": {
"build": "cdk-build",
"integ": "cdk-integ",
"lint": "cdk-lint",
"package": "cdk-package",
"pkglint": "pkglint -f",
"test": "cdk-test",
"watch": "cdk-watch"
},
"cdk-build": {
"cloudformation": "${S}"
},
"keywords": [
"aws",
"cdk",
"constructs",
"${PB}"
],
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com",
"organization": true
},
"license": "Apache-2.0",
"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/aws-/}.generated';
EOM
cat <<EOM > packages/${P}/test/test.${PB/aws-/}.ts
import { Test, testCase } from 'nodeunit';
import {} from '../lib';
export = testCase({
notTested(test: Test) {
test.ok(true, 'No tests are specified for this package.');
test.done();
}
});
EOM
cat <<EOM > packages/${P}/README.md
## ${S/::/ } Construct Library
\`\`\`ts
const ${PB/aws-/} = require('${P}');
\`\`\`
EOM
cp LICENSE NOTICE packages/${P}/
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