@leverege/build-tools 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/circleate +26 -49
- package/src/helmup +1 -1
- package/lib/server/circleate +0 -570
- package/lib/server/decrypt-secrets +0 -108
- package/lib/server/dockreate +0 -353
- package/lib/server/encrypt-secrets +0 -49
- package/lib/server/getfbcfg +0 -23
- package/lib/server/getjson +0 -48
- package/lib/server/git-tar +0 -89
- package/lib/server/helmdn +0 -111
- package/lib/server/helmify +0 -283
- package/lib/server/helmup +0 -349
- package/lib/server/overwhelm +0 -320
- package/lib/server/pkgck +0 -136
- package/lib/server/pkglint +0 -35
- package/lib/server/test.json +0 -4
- package/src/dnsify/CloudflareAPI.js +0 -99
- package/src/dnsify/accounts.json.enc +0 -0
- package/src/dnsify/index.js +0 -82
- package/src/packleate/Packleator.js +0 -281
- package/src/packleate/index.js +0 -86
- package/src/packleate/logo-ansi.js +0 -16
- package/src/test.json +0 -4
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "A package for development build tools.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "npm run compile",
|
|
8
8
|
"compile": "rm -fr lib && npm run compile_server && npm run compile_web",
|
|
9
|
-
"compile_server": "NODE_ENV=server babel -d lib/server src/
|
|
9
|
+
"compile_server": "NODE_ENV=server babel -d lib/server src/ && cp src/dnsify/accounts.json.enc lib/server/dnsify/accounts.json.enc",
|
|
10
10
|
"compile_web": "NODE_ENV=web babel -d lib/web src/",
|
|
11
11
|
"licenseCheck": "license-checker --summary --failOn GPL",
|
|
12
12
|
"prepublintOnly": "npm run lint && npm run build",
|
package/src/circleate
CHANGED
|
@@ -45,44 +45,12 @@ create_server_config(){
|
|
|
45
45
|
version: 2.1
|
|
46
46
|
orbs:
|
|
47
47
|
gcp-gcr: circleci/gcp-gcr@0.6.1
|
|
48
|
-
anchore: anchore/anchore-engine@1.2.0
|
|
49
48
|
executors:
|
|
50
49
|
default:
|
|
51
50
|
description: >
|
|
52
51
|
A debian-based machine executor.
|
|
53
52
|
machine: true
|
|
54
|
-
anchore_engine:
|
|
55
|
-
description: Machine runner with anchore engine default environment variables set.
|
|
56
|
-
parameters:
|
|
57
|
-
anchore_engine_version:
|
|
58
|
-
description: Version of anchore-engine container to run (recommended to keep default value)
|
|
59
|
-
type: string
|
|
60
|
-
default: "v0.3.2"
|
|
61
|
-
environment:
|
|
62
|
-
ANCHORE_CLI_USER: admin
|
|
63
|
-
ANCHORE_CLI_PASS: foobar
|
|
64
|
-
ANCHORE_CLI_SSL_VERIFY: 'n'
|
|
65
|
-
ANCHORE_VERSION: << parameters.anchore_engine_version >>
|
|
66
|
-
machine:
|
|
67
|
-
image: circleci/classic:201808-01
|
|
68
53
|
jobs:
|
|
69
|
-
docker-scan:
|
|
70
|
-
# runs anchore image scan for vulnerabilities
|
|
71
|
-
executor: anchore/anchore_engine
|
|
72
|
-
steps:
|
|
73
|
-
- attach_workspace:
|
|
74
|
-
at: ~/project
|
|
75
|
-
- run:
|
|
76
|
-
name: build container
|
|
77
|
-
command: 'docker build -t "\${CIRCLE_PROJECT_REPONAME}:ci" ~/project/docker/'
|
|
78
|
-
- anchore/analyze_local_image:
|
|
79
|
-
image_name: '\${CIRCLE_PROJECT_REPONAME}:ci'
|
|
80
|
-
timeout: '500'
|
|
81
|
-
policy_failure: true
|
|
82
|
-
- anchore/parse_reports
|
|
83
|
-
- store_artifacts:
|
|
84
|
-
path: anchore-report
|
|
85
|
-
|
|
86
54
|
gcr:
|
|
87
55
|
# gcr build docker image and pushes to gcr
|
|
88
56
|
executor: default
|
|
@@ -93,16 +61,28 @@ jobs:
|
|
|
93
61
|
echo "export CONTAINER_NAME=\$(cat ~/project/container_name)" >> \$BASH_ENV
|
|
94
62
|
echo "export PACKAGE_VERSION=\$(cat ~/project/package_version)" >> \$BASH_ENV
|
|
95
63
|
echo "export NODE_IMAGE=\$(cat ~/project/node_img)" >> \$BASH_ENV
|
|
96
|
-
- gcp-gcr/
|
|
97
|
-
- gcp-gcr/build-
|
|
64
|
+
- gcp-gcr/gcr-auth
|
|
65
|
+
- gcp-gcr/build-image:
|
|
98
66
|
image: \$CONTAINER_NAME
|
|
99
67
|
tag: \$PACKAGE_VERSION
|
|
100
68
|
path: docker
|
|
101
|
-
|
|
69
|
+
dockerfile: docker/Dockerfile
|
|
70
|
+
- gcp-gcr/push-image:
|
|
71
|
+
image: \$CONTAINER_NAME
|
|
72
|
+
tag: \$PACKAGE_VERSION
|
|
73
|
+
- run:
|
|
74
|
+
name: Check if branch is master
|
|
75
|
+
command: |
|
|
76
|
+
if [ \$CIRCLE_BRANCH == 'master' ]; then
|
|
77
|
+
echo "export GCR_TAG=stable" >> \$BASH_ENV;
|
|
78
|
+
else
|
|
79
|
+
echo "export GCR_TAG=latest" >> \$BASH_ENV;
|
|
80
|
+
fi
|
|
81
|
+
- gcp-gcr/tag-image:
|
|
102
82
|
image: \$CONTAINER_NAME
|
|
103
83
|
source-tag: \$PACKAGE_VERSION
|
|
104
|
-
target-tag:
|
|
105
|
-
- gcp-gcr/
|
|
84
|
+
target-tag: \$GCR_TAG
|
|
85
|
+
- gcp-gcr/tag-image:
|
|
106
86
|
image: \$CONTAINER_NAME
|
|
107
87
|
source-tag: \$PACKAGE_VERSION
|
|
108
88
|
target-tag: circle-\$NODE_IMAGE-\$CIRCLE_USERNAME
|
|
@@ -244,7 +224,7 @@ jobs:
|
|
|
244
224
|
echo \${NODE_IMAGE} > node_img
|
|
245
225
|
- run:
|
|
246
226
|
name: Create Dockerfile and build dist directory
|
|
247
|
-
command: npm run dockerize \$PACKAGE_VERSION
|
|
227
|
+
command: mkdir -p docker && npm run dockerize \$PACKAGE_VERSION
|
|
248
228
|
|
|
249
229
|
- persist_to_workspace:
|
|
250
230
|
root: ~/project
|
|
@@ -270,27 +250,24 @@ workflows:
|
|
|
270
250
|
context: npm
|
|
271
251
|
filters:
|
|
272
252
|
branches:
|
|
273
|
-
only:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
filters:
|
|
278
|
-
branches:
|
|
279
|
-
only: master
|
|
253
|
+
only:
|
|
254
|
+
- development
|
|
255
|
+
- /release-.*/
|
|
256
|
+
- master
|
|
280
257
|
requires:
|
|
281
258
|
- smoke-test
|
|
282
|
-
- coverage
|
|
283
|
-
- build
|
|
284
259
|
- gcr:
|
|
285
260
|
context: google
|
|
286
261
|
filters:
|
|
287
262
|
branches:
|
|
288
|
-
only:
|
|
263
|
+
only:
|
|
264
|
+
- development
|
|
265
|
+
- /release-.*/
|
|
266
|
+
- master
|
|
289
267
|
requires:
|
|
290
268
|
- smoke-test
|
|
291
269
|
- build
|
|
292
270
|
- coverage
|
|
293
|
-
- docker-scan
|
|
294
271
|
EOCIRCLE
|
|
295
272
|
}
|
|
296
273
|
|
package/src/helmup
CHANGED
|
@@ -149,7 +149,7 @@ function installVelero() {
|
|
|
149
149
|
--set schedules.timescale.schedule="0 3 * * *" \
|
|
150
150
|
--set schedules.timescale.template.ttl="720h" \
|
|
151
151
|
--set schedules.timescale.template.labelSelector.matchLabels.app="postgresql" \
|
|
152
|
-
--set schedules.timescale.template.snapshotVolumes="true"
|
|
152
|
+
--set schedules.timescale.template.snapshotVolumes="true"
|
|
153
153
|
|
|
154
154
|
## Instruct users to move velero keys
|
|
155
155
|
printf "\n$YELO_WARN MOVE THE SERVICE ACCOUNT TO YOUR KEYS FOLDER"
|
package/lib/server/circleate
DELETED
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
if [ -z "$1" ]; then
|
|
3
|
-
echo " Usage: repo type <ui/server/lib>"
|
|
4
|
-
exit 1
|
|
5
|
-
fi
|
|
6
|
-
|
|
7
|
-
if [ "$1" != "server" ] && [ "$1" != "ui" ] && [ "$1" != "lib" ]; then
|
|
8
|
-
echo " Only ui, server, or lib accepted currently"
|
|
9
|
-
exit 1
|
|
10
|
-
fi
|
|
11
|
-
|
|
12
|
-
repo_type=$1
|
|
13
|
-
|
|
14
|
-
check_circle_config(){
|
|
15
|
-
if [ -d "./.circleci" ];
|
|
16
|
-
then
|
|
17
|
-
printf "\nThere is an existing CircleCI config, do you want to override?\n\n"
|
|
18
|
-
printf "Hit return to continue or ^C to exit\n\n"; read ANS
|
|
19
|
-
rm -rf ./.circleci
|
|
20
|
-
fi
|
|
21
|
-
|
|
22
|
-
mkdir -p ./.circleci
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
strip_undefined() {
|
|
26
|
-
local result="$1"
|
|
27
|
-
[ "$1" == "undefined" ] && result=""
|
|
28
|
-
printf "$result"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
create_circle_config(){
|
|
32
|
-
echo "Creating the CircleCI config file"
|
|
33
|
-
cd .circleci
|
|
34
|
-
if [ "$repo_type" = "server" ]; then
|
|
35
|
-
create_server_config
|
|
36
|
-
elif [ "$repo_type" = "lib" ]; then
|
|
37
|
-
create_lib_config
|
|
38
|
-
else
|
|
39
|
-
create_ui_config
|
|
40
|
-
fi
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
create_server_config(){
|
|
44
|
-
cat<<EOCIRCLE > config.yml
|
|
45
|
-
version: 2.1
|
|
46
|
-
orbs:
|
|
47
|
-
gcp-gcr: circleci/gcp-gcr@0.6.1
|
|
48
|
-
anchore: anchore/anchore-engine@1.2.0
|
|
49
|
-
executors:
|
|
50
|
-
default:
|
|
51
|
-
description: >
|
|
52
|
-
A debian-based machine executor.
|
|
53
|
-
machine: true
|
|
54
|
-
anchore_engine:
|
|
55
|
-
description: Machine runner with anchore engine default environment variables set.
|
|
56
|
-
parameters:
|
|
57
|
-
anchore_engine_version:
|
|
58
|
-
description: Version of anchore-engine container to run (recommended to keep default value)
|
|
59
|
-
type: string
|
|
60
|
-
default: "v0.3.2"
|
|
61
|
-
environment:
|
|
62
|
-
ANCHORE_CLI_USER: admin
|
|
63
|
-
ANCHORE_CLI_PASS: foobar
|
|
64
|
-
ANCHORE_CLI_SSL_VERIFY: 'n'
|
|
65
|
-
ANCHORE_VERSION: << parameters.anchore_engine_version >>
|
|
66
|
-
machine:
|
|
67
|
-
image: circleci/classic:201808-01
|
|
68
|
-
jobs:
|
|
69
|
-
docker-scan:
|
|
70
|
-
# runs anchore image scan for vulnerabilities
|
|
71
|
-
executor: anchore/anchore_engine
|
|
72
|
-
steps:
|
|
73
|
-
- attach_workspace:
|
|
74
|
-
at: ~/project
|
|
75
|
-
- run:
|
|
76
|
-
name: build container
|
|
77
|
-
command: 'docker build -t "\${CIRCLE_PROJECT_REPONAME}:ci" ~/project/docker/'
|
|
78
|
-
- anchore/analyze_local_image:
|
|
79
|
-
image_name: '\${CIRCLE_PROJECT_REPONAME}:ci'
|
|
80
|
-
timeout: '500'
|
|
81
|
-
policy_failure: true
|
|
82
|
-
- anchore/parse_reports
|
|
83
|
-
- store_artifacts:
|
|
84
|
-
path: anchore-report
|
|
85
|
-
|
|
86
|
-
gcr:
|
|
87
|
-
# gcr build docker image and pushes to gcr
|
|
88
|
-
executor: default
|
|
89
|
-
steps:
|
|
90
|
-
- attach_workspace:
|
|
91
|
-
at: ~/project
|
|
92
|
-
- run: |
|
|
93
|
-
echo "export CONTAINER_NAME=\$(cat ~/project/container_name)" >> \$BASH_ENV
|
|
94
|
-
echo "export PACKAGE_VERSION=\$(cat ~/project/package_version)" >> \$BASH_ENV
|
|
95
|
-
echo "export NODE_IMAGE=\$(cat ~/project/node_img)" >> \$BASH_ENV
|
|
96
|
-
- gcp-gcr/build-and-push-image
|
|
97
|
-
- gcp-gcr/build-and-push-image
|
|
98
|
-
image: \$CONTAINER_NAME
|
|
99
|
-
tag: \$PACKAGE_VERSION
|
|
100
|
-
path: docker
|
|
101
|
-
- gcp-gcr/add-image-tag:
|
|
102
|
-
image: \$CONTAINER_NAME
|
|
103
|
-
source-tag: \$PACKAGE_VERSION
|
|
104
|
-
target-tag: latest
|
|
105
|
-
- gcp-gcr/add-image-tag:
|
|
106
|
-
image: \$CONTAINER_NAME
|
|
107
|
-
source-tag: \$PACKAGE_VERSION
|
|
108
|
-
target-tag: circle-\$NODE_IMAGE-\$CIRCLE_USERNAME
|
|
109
|
-
|
|
110
|
-
smoke-test:
|
|
111
|
-
# smoke test checks for license, security, and linting
|
|
112
|
-
docker:
|
|
113
|
-
- image: circleci/node:12.10.0
|
|
114
|
-
steps:
|
|
115
|
-
- checkout
|
|
116
|
-
- restore_cache:
|
|
117
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
118
|
-
- run:
|
|
119
|
-
name: Setup @leverege Token
|
|
120
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
121
|
-
- run: npm install
|
|
122
|
-
|
|
123
|
-
- save_cache:
|
|
124
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
125
|
-
paths:
|
|
126
|
-
- ./node_modules
|
|
127
|
-
|
|
128
|
-
- run:
|
|
129
|
-
name: Check for vulnerabilities
|
|
130
|
-
command: npm audit --production
|
|
131
|
-
|
|
132
|
-
- run:
|
|
133
|
-
name: Check for LICENSE and README files
|
|
134
|
-
command: npm run pkglint
|
|
135
|
-
|
|
136
|
-
- run:
|
|
137
|
-
name: Check for license violations (e.g. GPL)
|
|
138
|
-
command: |
|
|
139
|
-
npm install license-checker
|
|
140
|
-
npm run licenseCheck
|
|
141
|
-
|
|
142
|
-
- run:
|
|
143
|
-
name: Lint and save results
|
|
144
|
-
command: npm run lint-ci
|
|
145
|
-
|
|
146
|
-
- store_test_results:
|
|
147
|
-
path: reports
|
|
148
|
-
|
|
149
|
-
coverage:
|
|
150
|
-
# coverage runs tests, generates coverage, and saves docs
|
|
151
|
-
environment:
|
|
152
|
-
TZ: 'America/New_York'
|
|
153
|
-
docker:
|
|
154
|
-
- image: circleci/node:12.10.0
|
|
155
|
-
# IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
|
|
156
|
-
# - image: redis
|
|
157
|
-
# - image: circleci/mysql:5.7
|
|
158
|
-
# environment:
|
|
159
|
-
# MYSQL_USER: root
|
|
160
|
-
# MYSQL_ROOT_PASSWORD: root
|
|
161
|
-
# MYSQL_ALLOW_EMPTY_PASSWORD: true
|
|
162
|
-
# MYSQL_HOST: 127.0.0.1
|
|
163
|
-
# - image: nsqio/nsq
|
|
164
|
-
# command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
|
|
165
|
-
|
|
166
|
-
# - image: nsqio/nsq
|
|
167
|
-
# command: >
|
|
168
|
-
# /nsqd
|
|
169
|
-
# -broadcast-address localhost:4150
|
|
170
|
-
# -tcp-address 0.0.0.0:4150
|
|
171
|
-
# -http-address 0.0.0.0:4151
|
|
172
|
-
# -lookupd-tcp-address localhost:4160
|
|
173
|
-
|
|
174
|
-
steps:
|
|
175
|
-
- checkout
|
|
176
|
-
- restore_cache:
|
|
177
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
178
|
-
|
|
179
|
-
- run:
|
|
180
|
-
name: Setup @leverege Token
|
|
181
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
182
|
-
|
|
183
|
-
- run: npm install
|
|
184
|
-
|
|
185
|
-
# UNCOMMENT IF YOU NEED DECRYPTING SECRETS
|
|
186
|
-
# - run:
|
|
187
|
-
# name: Load secrets
|
|
188
|
-
# command: npm run decrypt
|
|
189
|
-
|
|
190
|
-
- run:
|
|
191
|
-
name: Run Tests and Generate Code Coverage
|
|
192
|
-
command: npm run coverage
|
|
193
|
-
|
|
194
|
-
- run:
|
|
195
|
-
name: Check if coverage meets at least 70%
|
|
196
|
-
command: ./node_modules/.bin/nyc check-coverage --functions 70 --lines 70 --statements 70
|
|
197
|
-
|
|
198
|
-
- run:
|
|
199
|
-
name: Generate docs
|
|
200
|
-
command: |
|
|
201
|
-
npm install jsdoc
|
|
202
|
-
npm run docs
|
|
203
|
-
|
|
204
|
-
- store_artifacts:
|
|
205
|
-
path: coverage
|
|
206
|
-
prefix: coverage
|
|
207
|
-
|
|
208
|
-
- store_artifacts:
|
|
209
|
-
path: docs
|
|
210
|
-
prefix: docs
|
|
211
|
-
|
|
212
|
-
build:
|
|
213
|
-
# build should make dist image and prepare docker file
|
|
214
|
-
docker:
|
|
215
|
-
- image: circleci/node:12.10.0
|
|
216
|
-
|
|
217
|
-
steps:
|
|
218
|
-
- checkout
|
|
219
|
-
- restore_cache:
|
|
220
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
221
|
-
|
|
222
|
-
- run:
|
|
223
|
-
name: Setup @leverege Token
|
|
224
|
-
command: |
|
|
225
|
-
echo \${NPMRC} > ~/.npmrc
|
|
226
|
-
echo \${NPMRC} > ~/.npmrc.ro
|
|
227
|
-
|
|
228
|
-
- run: npm install
|
|
229
|
-
|
|
230
|
-
- run:
|
|
231
|
-
name: Determine version number and container name
|
|
232
|
-
command: |
|
|
233
|
-
PACKAGE_VERSION=\$(node -p "require('./package.json').version")
|
|
234
|
-
container="\`node -p \"require('./package.json').leverege.container\"\`"
|
|
235
|
-
if [ "\$container" == "undefined" ];
|
|
236
|
-
then
|
|
237
|
-
container=\$CIRCLE_PROJECT_REPONAME
|
|
238
|
-
fi
|
|
239
|
-
NODE_IMAGE="\`node -p \"require('./package.json').leverege.nodeimg\"\`"
|
|
240
|
-
|
|
241
|
-
echo v\${PACKAGE_VERSION} > package_version
|
|
242
|
-
echo "export PACKAGE_VERSION=v\${PACKAGE_VERSION}" >> \$BASH_ENV
|
|
243
|
-
echo \${container} > container_name
|
|
244
|
-
echo \${NODE_IMAGE} > node_img
|
|
245
|
-
- run:
|
|
246
|
-
name: Create Dockerfile and build dist directory
|
|
247
|
-
command: npm run dockerize \$PACKAGE_VERSION
|
|
248
|
-
|
|
249
|
-
- persist_to_workspace:
|
|
250
|
-
root: ~/project
|
|
251
|
-
paths:
|
|
252
|
-
- dist/*
|
|
253
|
-
- docker/*
|
|
254
|
-
- package_version
|
|
255
|
-
- container_name
|
|
256
|
-
- node_img
|
|
257
|
-
- package*json
|
|
258
|
-
|
|
259
|
-
workflows:
|
|
260
|
-
version: 2.1
|
|
261
|
-
test-build-deploy:
|
|
262
|
-
jobs:
|
|
263
|
-
- smoke-test:
|
|
264
|
-
context: npm
|
|
265
|
-
- coverage:
|
|
266
|
-
context: npm
|
|
267
|
-
requires:
|
|
268
|
-
- smoke-test
|
|
269
|
-
- build:
|
|
270
|
-
context: npm
|
|
271
|
-
filters:
|
|
272
|
-
branches:
|
|
273
|
-
only: master
|
|
274
|
-
requires:
|
|
275
|
-
- smoke-test
|
|
276
|
-
- docker-scan:
|
|
277
|
-
filters:
|
|
278
|
-
branches:
|
|
279
|
-
only: master
|
|
280
|
-
requires:
|
|
281
|
-
- smoke-test
|
|
282
|
-
- coverage
|
|
283
|
-
- build
|
|
284
|
-
- gcr:
|
|
285
|
-
context: google
|
|
286
|
-
filters:
|
|
287
|
-
branches:
|
|
288
|
-
only: master
|
|
289
|
-
requires:
|
|
290
|
-
- smoke-test
|
|
291
|
-
- build
|
|
292
|
-
- coverage
|
|
293
|
-
- docker-scan
|
|
294
|
-
EOCIRCLE
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
create_lib_config(){
|
|
298
|
-
cat<<EOCIRCLE > config.yml
|
|
299
|
-
version: 2.1
|
|
300
|
-
jobs:
|
|
301
|
-
smoke-test:
|
|
302
|
-
# smoke test checks for license, security, and linting
|
|
303
|
-
docker:
|
|
304
|
-
- image: circleci/node:12.10.0
|
|
305
|
-
steps:
|
|
306
|
-
- checkout
|
|
307
|
-
- restore_cache:
|
|
308
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
309
|
-
- run:
|
|
310
|
-
name: Setup @leverege Token
|
|
311
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
312
|
-
- run: npm install
|
|
313
|
-
|
|
314
|
-
- save_cache:
|
|
315
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
316
|
-
paths:
|
|
317
|
-
- ./node_modules
|
|
318
|
-
|
|
319
|
-
- run:
|
|
320
|
-
name: Check for vulnerabilities
|
|
321
|
-
command: npm audit --production
|
|
322
|
-
|
|
323
|
-
- run:
|
|
324
|
-
name: Check for LICENSE and README files
|
|
325
|
-
command: npm run pkglint
|
|
326
|
-
|
|
327
|
-
- run:
|
|
328
|
-
name: Check for license violations (e.g. GPL)
|
|
329
|
-
command: |
|
|
330
|
-
npm install license-checker
|
|
331
|
-
npm run licenseCheck
|
|
332
|
-
|
|
333
|
-
- run:
|
|
334
|
-
name: Lint and save results
|
|
335
|
-
command: npm run lint-ci
|
|
336
|
-
|
|
337
|
-
- store_test_results:
|
|
338
|
-
path: reports
|
|
339
|
-
|
|
340
|
-
coverage:
|
|
341
|
-
# coverage runs tests, generates coverage, and saves docs
|
|
342
|
-
docker:
|
|
343
|
-
- image: circleci/node:12.10.0
|
|
344
|
-
# IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
|
|
345
|
-
# - image: redis
|
|
346
|
-
# - image: circleci/mysql:5.7
|
|
347
|
-
# environment:
|
|
348
|
-
# MYSQL_USER: root
|
|
349
|
-
# MYSQL_ROOT_PASSWORD: root
|
|
350
|
-
# MYSQL_ALLOW_EMPTY_PASSWORD: true
|
|
351
|
-
# MYSQL_HOST: 127.0.0.1
|
|
352
|
-
# - image: nsqio/nsq
|
|
353
|
-
# command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
|
|
354
|
-
|
|
355
|
-
# - image: nsqio/nsq
|
|
356
|
-
# command: >
|
|
357
|
-
# /nsqd
|
|
358
|
-
# -broadcast-address localhost:4150
|
|
359
|
-
# -tcp-address 0.0.0.0:4150
|
|
360
|
-
# -http-address 0.0.0.0:4151
|
|
361
|
-
# -lookupd-tcp-address localhost:4160
|
|
362
|
-
|
|
363
|
-
steps:
|
|
364
|
-
- checkout
|
|
365
|
-
- restore_cache:
|
|
366
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
367
|
-
|
|
368
|
-
- run:
|
|
369
|
-
name: Setup @leverege Token
|
|
370
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
371
|
-
|
|
372
|
-
- run: npm install
|
|
373
|
-
|
|
374
|
-
# UNCOMMENT IF YOU NEED DECRYPTING SECRETS
|
|
375
|
-
# - run:
|
|
376
|
-
# name: Load secrets
|
|
377
|
-
# command: npm run decrypt
|
|
378
|
-
|
|
379
|
-
- run:
|
|
380
|
-
name: Run Tests and Generate Code Coverage
|
|
381
|
-
command: npm run coverage
|
|
382
|
-
|
|
383
|
-
- run:
|
|
384
|
-
name: Check if coverage meets at least 70%
|
|
385
|
-
command: ./node_modules/.bin/nyc check-coverage --functions 70 --lines 70 --statements 70
|
|
386
|
-
|
|
387
|
-
- run:
|
|
388
|
-
name: Generate docs
|
|
389
|
-
command: |
|
|
390
|
-
npm install jsdoc
|
|
391
|
-
npm run docs
|
|
392
|
-
|
|
393
|
-
- store_artifacts:
|
|
394
|
-
path: coverage
|
|
395
|
-
prefix: coverage
|
|
396
|
-
|
|
397
|
-
- store_artifacts:
|
|
398
|
-
path: docs
|
|
399
|
-
prefix: docs
|
|
400
|
-
|
|
401
|
-
# publish:
|
|
402
|
-
# # publish the package to npm registry - CURRENTLY DISABLED
|
|
403
|
-
|
|
404
|
-
workflows:
|
|
405
|
-
version: 2.1
|
|
406
|
-
test-build-deploy:
|
|
407
|
-
jobs:
|
|
408
|
-
- smoke-test:
|
|
409
|
-
context: npm
|
|
410
|
-
- coverage:
|
|
411
|
-
context: npm
|
|
412
|
-
requires:
|
|
413
|
-
- smoke-test
|
|
414
|
-
# - publish:
|
|
415
|
-
# context: npm
|
|
416
|
-
# filters:
|
|
417
|
-
# branches:
|
|
418
|
-
# only: master
|
|
419
|
-
# requires:
|
|
420
|
-
# - smoke-test
|
|
421
|
-
# - coverage
|
|
422
|
-
EOCIRCLE
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
create_ui_config(){
|
|
426
|
-
# Determine URLs per environment
|
|
427
|
-
echo "Please provide the dev site URL"
|
|
428
|
-
read DEV_URL
|
|
429
|
-
|
|
430
|
-
echo "Please provide the prod site URL"
|
|
431
|
-
read PROD_URL
|
|
432
|
-
|
|
433
|
-
# Determine GCP project
|
|
434
|
-
echo "Please provide the dev GCP project id"
|
|
435
|
-
read DEV_PROJECT
|
|
436
|
-
|
|
437
|
-
echo "Please provide the prod GCP project id"
|
|
438
|
-
read PROD_PROJECT
|
|
439
|
-
|
|
440
|
-
# Build circle config based on variables
|
|
441
|
-
cat<<EOCIRCLE > config.yml
|
|
442
|
-
version: 2.1
|
|
443
|
-
orbs:
|
|
444
|
-
gcp-gcr: circleci/gcp-cli@1.0.4
|
|
445
|
-
executors:
|
|
446
|
-
google:
|
|
447
|
-
description: The official Google docker container with gcloud SDK pre-installed
|
|
448
|
-
docker:
|
|
449
|
-
- image: google/cloud-sdk
|
|
450
|
-
|
|
451
|
-
jobs:
|
|
452
|
-
gcs-dev:
|
|
453
|
-
executor: google
|
|
454
|
-
steps:
|
|
455
|
-
- attach_workspace:
|
|
456
|
-
at: ~/project
|
|
457
|
-
# https://gist.github.com/DarrenN/8c6a5b969481725a4413
|
|
458
|
-
- run: |
|
|
459
|
-
echo "export PACKAGE_VERSION=v\$(grep -m1 version package.json | awk -F: '{ print \$2 }' | sed 's/[", ]//g')" >> \$BASH_ENV
|
|
460
|
-
- gcp-gcr/initialize
|
|
461
|
-
- run: |
|
|
462
|
-
gsutil mb gs://\$PACKAGE_VERSION.$DEV_URL
|
|
463
|
-
gsutil -m cp -r ./project/image/* gs://\$PACKAGE_VERSION.$DEV_URL
|
|
464
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://\$PACKAGE_VERSION.$DEV_URL/bundle.js
|
|
465
|
-
gsutil iam ch allUsers:objectViewer gs://$DEV_URL
|
|
466
|
-
- run: |
|
|
467
|
-
gsutil mb gs://$DEV_URL
|
|
468
|
-
gsutil -m rm gs://$DEV_URL/**
|
|
469
|
-
gsutil -m cp -r gs://\$PACKAGE_VERSION.$DEV_URL/* gs://$DEV_URL
|
|
470
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://$DEV_URL/bundle.js
|
|
471
|
-
gsutil iam ch allUsers:objectViewer gs://$DEV_URL
|
|
472
|
-
|
|
473
|
-
gcs-prod:
|
|
474
|
-
executor: google
|
|
475
|
-
steps:
|
|
476
|
-
- attach_workspace:
|
|
477
|
-
at: ~/project
|
|
478
|
-
# https://gist.github.com/DarrenN/8c6a5b969481725a4413
|
|
479
|
-
- run: |
|
|
480
|
-
echo "export PACKAGE_VERSION=v\$(grep -m1 version package.json | awk -F: '{ print \$2 }' | sed 's/[", ]//g')" >> \$BASH_ENV
|
|
481
|
-
- gcp-gcr/initialize
|
|
482
|
-
- run: |
|
|
483
|
-
gsutil mb gs://\$PACKAGE_VERSION.$PROD_URL
|
|
484
|
-
gsutil -m cp -r ./project/image/* gs://\$PACKAGE_VERSION.$PROD_URL
|
|
485
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://\$PACKAGE_VERSION.$PROD_URL/bundle.js
|
|
486
|
-
gsutil iam ch allUsers:objectViewer gs://$PROD_URL
|
|
487
|
-
- run: |
|
|
488
|
-
gsutil mb gs://$PROD_URL
|
|
489
|
-
gsutil -m rm gs://$PROD_URL/**
|
|
490
|
-
gsutil -m cp -r gs://\$PACKAGE_VERSION.$PROD_URL/* gs://$PROD_URL
|
|
491
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://$PROD_URL/bundle.js
|
|
492
|
-
gsutil iam ch allUsers:objectViewer gs://$PROD_URL
|
|
493
|
-
|
|
494
|
-
build:
|
|
495
|
-
docker:
|
|
496
|
-
- image: circleci/node:12.10.0
|
|
497
|
-
steps:
|
|
498
|
-
- checkout
|
|
499
|
-
- restore_cache:
|
|
500
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
501
|
-
|
|
502
|
-
- run:
|
|
503
|
-
name: Setup @leverege Token
|
|
504
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
505
|
-
|
|
506
|
-
- run: npm install
|
|
507
|
-
|
|
508
|
-
- save_cache:
|
|
509
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
510
|
-
paths:
|
|
511
|
-
- ./node_modules
|
|
512
|
-
|
|
513
|
-
- run:
|
|
514
|
-
name: Install license-checker
|
|
515
|
-
command: npm install license-checker
|
|
516
|
-
|
|
517
|
-
- run:
|
|
518
|
-
name: Check for license violations (e.g. GPL)
|
|
519
|
-
command: npm run licenseCheck
|
|
520
|
-
|
|
521
|
-
- run:
|
|
522
|
-
name: Bundle using webpack
|
|
523
|
-
command: |
|
|
524
|
-
npm run clean
|
|
525
|
-
npm run build
|
|
526
|
-
rm -fr ./image
|
|
527
|
-
mkdir ./image
|
|
528
|
-
cp -fr ./dist/* ./image/
|
|
529
|
-
gzip ./image/bundle.js
|
|
530
|
-
mv ./image/bundle.js.gz ./image/bundle.js
|
|
531
|
-
|
|
532
|
-
- persist_to_workspace:
|
|
533
|
-
root: ~/project
|
|
534
|
-
paths:
|
|
535
|
-
- image/*
|
|
536
|
-
- package.json
|
|
537
|
-
|
|
538
|
-
workflows:
|
|
539
|
-
version: 2.1
|
|
540
|
-
build-deploy-dev:
|
|
541
|
-
jobs:
|
|
542
|
-
- build:
|
|
543
|
-
context: npm
|
|
544
|
-
- gcs-dev:
|
|
545
|
-
context: $DEV_PROJECT
|
|
546
|
-
filters:
|
|
547
|
-
branches:
|
|
548
|
-
only: /release-.*/
|
|
549
|
-
requires:
|
|
550
|
-
- build
|
|
551
|
-
build-deploy-prod:
|
|
552
|
-
jobs:
|
|
553
|
-
- build:
|
|
554
|
-
context: npm
|
|
555
|
-
filters:
|
|
556
|
-
branches:
|
|
557
|
-
only: master
|
|
558
|
-
- gcs-prod:
|
|
559
|
-
context: $PROD_PROJECT
|
|
560
|
-
filters:
|
|
561
|
-
branches:
|
|
562
|
-
only: master
|
|
563
|
-
requires:
|
|
564
|
-
- build
|
|
565
|
-
|
|
566
|
-
EOCIRCLE
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
check_circle_config
|
|
570
|
-
create_circle_config
|