@leverege/build-tools 2.0.5 → 2.0.7
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/lib/web/dnsify/index.js +3 -1
- package/lib/web/packleate/Packleator.js +3 -1
- package/lib/web/packleate/index.js +3 -1
- package/package.json +7 -7
- package/src/circleate +20 -46
- package/src/helmup +6 -24
- package/src/overwhelm +1 -1
- package/lib/server/circleate +0 -573
- 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/lib/server/circleate
DELETED
|
@@ -1,573 +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/gcr-auth
|
|
97
|
-
- gcp-gcr/build-image:
|
|
98
|
-
image: \$CONTAINER_NAME
|
|
99
|
-
tag: \$PACKAGE_VERSION
|
|
100
|
-
path: docker
|
|
101
|
-
- gcp-gcr/push-image:
|
|
102
|
-
image: \$CONTAINER_NAME
|
|
103
|
-
tag: \$PACKAGE_VERSION
|
|
104
|
-
- gcp-gcr/add-image-tag:
|
|
105
|
-
image: \$CONTAINER_NAME
|
|
106
|
-
source-tag: \$PACKAGE_VERSION
|
|
107
|
-
target-tag: latest
|
|
108
|
-
- gcp-gcr/add-image-tag:
|
|
109
|
-
image: \$CONTAINER_NAME
|
|
110
|
-
source-tag: \$PACKAGE_VERSION
|
|
111
|
-
target-tag: circle-\$NODE_IMAGE-\$CIRCLE_USERNAME
|
|
112
|
-
|
|
113
|
-
smoke-test:
|
|
114
|
-
# smoke test checks for license, security, and linting
|
|
115
|
-
docker:
|
|
116
|
-
- image: circleci/node:12.10.0
|
|
117
|
-
steps:
|
|
118
|
-
- checkout
|
|
119
|
-
- restore_cache:
|
|
120
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
121
|
-
- run:
|
|
122
|
-
name: Setup @leverege Token
|
|
123
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
124
|
-
- run: npm install
|
|
125
|
-
|
|
126
|
-
- save_cache:
|
|
127
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
128
|
-
paths:
|
|
129
|
-
- ./node_modules
|
|
130
|
-
|
|
131
|
-
- run:
|
|
132
|
-
name: Check for vulnerabilities
|
|
133
|
-
command: npm audit --production
|
|
134
|
-
|
|
135
|
-
- run:
|
|
136
|
-
name: Check for LICENSE and README files
|
|
137
|
-
command: npm run pkglint
|
|
138
|
-
|
|
139
|
-
- run:
|
|
140
|
-
name: Check for license violations (e.g. GPL)
|
|
141
|
-
command: |
|
|
142
|
-
npm install license-checker
|
|
143
|
-
npm run licenseCheck
|
|
144
|
-
|
|
145
|
-
- run:
|
|
146
|
-
name: Lint and save results
|
|
147
|
-
command: npm run lint-ci
|
|
148
|
-
|
|
149
|
-
- store_test_results:
|
|
150
|
-
path: reports
|
|
151
|
-
|
|
152
|
-
coverage:
|
|
153
|
-
# coverage runs tests, generates coverage, and saves docs
|
|
154
|
-
environment:
|
|
155
|
-
TZ: 'America/New_York'
|
|
156
|
-
docker:
|
|
157
|
-
- image: circleci/node:12.10.0
|
|
158
|
-
# IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
|
|
159
|
-
# - image: redis
|
|
160
|
-
# - image: circleci/mysql:5.7
|
|
161
|
-
# environment:
|
|
162
|
-
# MYSQL_USER: root
|
|
163
|
-
# MYSQL_ROOT_PASSWORD: root
|
|
164
|
-
# MYSQL_ALLOW_EMPTY_PASSWORD: true
|
|
165
|
-
# MYSQL_HOST: 127.0.0.1
|
|
166
|
-
# - image: nsqio/nsq
|
|
167
|
-
# command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
|
|
168
|
-
|
|
169
|
-
# - image: nsqio/nsq
|
|
170
|
-
# command: >
|
|
171
|
-
# /nsqd
|
|
172
|
-
# -broadcast-address localhost:4150
|
|
173
|
-
# -tcp-address 0.0.0.0:4150
|
|
174
|
-
# -http-address 0.0.0.0:4151
|
|
175
|
-
# -lookupd-tcp-address localhost:4160
|
|
176
|
-
|
|
177
|
-
steps:
|
|
178
|
-
- checkout
|
|
179
|
-
- restore_cache:
|
|
180
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
181
|
-
|
|
182
|
-
- run:
|
|
183
|
-
name: Setup @leverege Token
|
|
184
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
185
|
-
|
|
186
|
-
- run: npm install
|
|
187
|
-
|
|
188
|
-
# UNCOMMENT IF YOU NEED DECRYPTING SECRETS
|
|
189
|
-
# - run:
|
|
190
|
-
# name: Load secrets
|
|
191
|
-
# command: npm run decrypt
|
|
192
|
-
|
|
193
|
-
- run:
|
|
194
|
-
name: Run Tests and Generate Code Coverage
|
|
195
|
-
command: npm run coverage
|
|
196
|
-
|
|
197
|
-
- run:
|
|
198
|
-
name: Check if coverage meets at least 70%
|
|
199
|
-
command: ./node_modules/.bin/nyc check-coverage --functions 70 --lines 70 --statements 70
|
|
200
|
-
|
|
201
|
-
- run:
|
|
202
|
-
name: Generate docs
|
|
203
|
-
command: |
|
|
204
|
-
npm install jsdoc
|
|
205
|
-
npm run docs
|
|
206
|
-
|
|
207
|
-
- store_artifacts:
|
|
208
|
-
path: coverage
|
|
209
|
-
prefix: coverage
|
|
210
|
-
|
|
211
|
-
- store_artifacts:
|
|
212
|
-
path: docs
|
|
213
|
-
prefix: docs
|
|
214
|
-
|
|
215
|
-
build:
|
|
216
|
-
# build should make dist image and prepare docker file
|
|
217
|
-
docker:
|
|
218
|
-
- image: circleci/node:12.10.0
|
|
219
|
-
|
|
220
|
-
steps:
|
|
221
|
-
- checkout
|
|
222
|
-
- restore_cache:
|
|
223
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
224
|
-
|
|
225
|
-
- run:
|
|
226
|
-
name: Setup @leverege Token
|
|
227
|
-
command: |
|
|
228
|
-
echo \${NPMRC} > ~/.npmrc
|
|
229
|
-
echo \${NPMRC} > ~/.npmrc.ro
|
|
230
|
-
|
|
231
|
-
- run: npm install
|
|
232
|
-
|
|
233
|
-
- run:
|
|
234
|
-
name: Determine version number and container name
|
|
235
|
-
command: |
|
|
236
|
-
PACKAGE_VERSION=\$(node -p "require('./package.json').version")
|
|
237
|
-
container="\`node -p \"require('./package.json').leverege.container\"\`"
|
|
238
|
-
if [ "\$container" == "undefined" ];
|
|
239
|
-
then
|
|
240
|
-
container=\$CIRCLE_PROJECT_REPONAME
|
|
241
|
-
fi
|
|
242
|
-
NODE_IMAGE="\`node -p \"require('./package.json').leverege.nodeimg\"\`"
|
|
243
|
-
|
|
244
|
-
echo v\${PACKAGE_VERSION} > package_version
|
|
245
|
-
echo "export PACKAGE_VERSION=v\${PACKAGE_VERSION}" >> \$BASH_ENV
|
|
246
|
-
echo \${container} > container_name
|
|
247
|
-
echo \${NODE_IMAGE} > node_img
|
|
248
|
-
- run:
|
|
249
|
-
name: Create Dockerfile and build dist directory
|
|
250
|
-
command: mkdir -p docker && npm run dockerize \$PACKAGE_VERSION
|
|
251
|
-
|
|
252
|
-
- persist_to_workspace:
|
|
253
|
-
root: ~/project
|
|
254
|
-
paths:
|
|
255
|
-
- dist/*
|
|
256
|
-
- docker/*
|
|
257
|
-
- package_version
|
|
258
|
-
- container_name
|
|
259
|
-
- node_img
|
|
260
|
-
- package*json
|
|
261
|
-
|
|
262
|
-
workflows:
|
|
263
|
-
version: 2.1
|
|
264
|
-
test-build-deploy:
|
|
265
|
-
jobs:
|
|
266
|
-
- smoke-test:
|
|
267
|
-
context: npm
|
|
268
|
-
- coverage:
|
|
269
|
-
context: npm
|
|
270
|
-
requires:
|
|
271
|
-
- smoke-test
|
|
272
|
-
- build:
|
|
273
|
-
context: npm
|
|
274
|
-
filters:
|
|
275
|
-
branches:
|
|
276
|
-
only: master
|
|
277
|
-
requires:
|
|
278
|
-
- smoke-test
|
|
279
|
-
- docker-scan:
|
|
280
|
-
filters:
|
|
281
|
-
branches:
|
|
282
|
-
only: master
|
|
283
|
-
requires:
|
|
284
|
-
- smoke-test
|
|
285
|
-
- coverage
|
|
286
|
-
- build
|
|
287
|
-
- gcr:
|
|
288
|
-
context: google
|
|
289
|
-
filters:
|
|
290
|
-
branches:
|
|
291
|
-
only: master
|
|
292
|
-
requires:
|
|
293
|
-
- smoke-test
|
|
294
|
-
- build
|
|
295
|
-
- coverage
|
|
296
|
-
- docker-scan
|
|
297
|
-
EOCIRCLE
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
create_lib_config(){
|
|
301
|
-
cat<<EOCIRCLE > config.yml
|
|
302
|
-
version: 2.1
|
|
303
|
-
jobs:
|
|
304
|
-
smoke-test:
|
|
305
|
-
# smoke test checks for license, security, and linting
|
|
306
|
-
docker:
|
|
307
|
-
- image: circleci/node:12.10.0
|
|
308
|
-
steps:
|
|
309
|
-
- checkout
|
|
310
|
-
- restore_cache:
|
|
311
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
312
|
-
- run:
|
|
313
|
-
name: Setup @leverege Token
|
|
314
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
315
|
-
- run: npm install
|
|
316
|
-
|
|
317
|
-
- save_cache:
|
|
318
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
319
|
-
paths:
|
|
320
|
-
- ./node_modules
|
|
321
|
-
|
|
322
|
-
- run:
|
|
323
|
-
name: Check for vulnerabilities
|
|
324
|
-
command: npm audit --production
|
|
325
|
-
|
|
326
|
-
- run:
|
|
327
|
-
name: Check for LICENSE and README files
|
|
328
|
-
command: npm run pkglint
|
|
329
|
-
|
|
330
|
-
- run:
|
|
331
|
-
name: Check for license violations (e.g. GPL)
|
|
332
|
-
command: |
|
|
333
|
-
npm install license-checker
|
|
334
|
-
npm run licenseCheck
|
|
335
|
-
|
|
336
|
-
- run:
|
|
337
|
-
name: Lint and save results
|
|
338
|
-
command: npm run lint-ci
|
|
339
|
-
|
|
340
|
-
- store_test_results:
|
|
341
|
-
path: reports
|
|
342
|
-
|
|
343
|
-
coverage:
|
|
344
|
-
# coverage runs tests, generates coverage, and saves docs
|
|
345
|
-
docker:
|
|
346
|
-
- image: circleci/node:12.10.0
|
|
347
|
-
# IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
|
|
348
|
-
# - image: redis
|
|
349
|
-
# - image: circleci/mysql:5.7
|
|
350
|
-
# environment:
|
|
351
|
-
# MYSQL_USER: root
|
|
352
|
-
# MYSQL_ROOT_PASSWORD: root
|
|
353
|
-
# MYSQL_ALLOW_EMPTY_PASSWORD: true
|
|
354
|
-
# MYSQL_HOST: 127.0.0.1
|
|
355
|
-
# - image: nsqio/nsq
|
|
356
|
-
# command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
|
|
357
|
-
|
|
358
|
-
# - image: nsqio/nsq
|
|
359
|
-
# command: >
|
|
360
|
-
# /nsqd
|
|
361
|
-
# -broadcast-address localhost:4150
|
|
362
|
-
# -tcp-address 0.0.0.0:4150
|
|
363
|
-
# -http-address 0.0.0.0:4151
|
|
364
|
-
# -lookupd-tcp-address localhost:4160
|
|
365
|
-
|
|
366
|
-
steps:
|
|
367
|
-
- checkout
|
|
368
|
-
- restore_cache:
|
|
369
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
370
|
-
|
|
371
|
-
- run:
|
|
372
|
-
name: Setup @leverege Token
|
|
373
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
374
|
-
|
|
375
|
-
- run: npm install
|
|
376
|
-
|
|
377
|
-
# UNCOMMENT IF YOU NEED DECRYPTING SECRETS
|
|
378
|
-
# - run:
|
|
379
|
-
# name: Load secrets
|
|
380
|
-
# command: npm run decrypt
|
|
381
|
-
|
|
382
|
-
- run:
|
|
383
|
-
name: Run Tests and Generate Code Coverage
|
|
384
|
-
command: npm run coverage
|
|
385
|
-
|
|
386
|
-
- run:
|
|
387
|
-
name: Check if coverage meets at least 70%
|
|
388
|
-
command: ./node_modules/.bin/nyc check-coverage --functions 70 --lines 70 --statements 70
|
|
389
|
-
|
|
390
|
-
- run:
|
|
391
|
-
name: Generate docs
|
|
392
|
-
command: |
|
|
393
|
-
npm install jsdoc
|
|
394
|
-
npm run docs
|
|
395
|
-
|
|
396
|
-
- store_artifacts:
|
|
397
|
-
path: coverage
|
|
398
|
-
prefix: coverage
|
|
399
|
-
|
|
400
|
-
- store_artifacts:
|
|
401
|
-
path: docs
|
|
402
|
-
prefix: docs
|
|
403
|
-
|
|
404
|
-
# publish:
|
|
405
|
-
# # publish the package to npm registry - CURRENTLY DISABLED
|
|
406
|
-
|
|
407
|
-
workflows:
|
|
408
|
-
version: 2.1
|
|
409
|
-
test-build-deploy:
|
|
410
|
-
jobs:
|
|
411
|
-
- smoke-test:
|
|
412
|
-
context: npm
|
|
413
|
-
- coverage:
|
|
414
|
-
context: npm
|
|
415
|
-
requires:
|
|
416
|
-
- smoke-test
|
|
417
|
-
# - publish:
|
|
418
|
-
# context: npm
|
|
419
|
-
# filters:
|
|
420
|
-
# branches:
|
|
421
|
-
# only: master
|
|
422
|
-
# requires:
|
|
423
|
-
# - smoke-test
|
|
424
|
-
# - coverage
|
|
425
|
-
EOCIRCLE
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
create_ui_config(){
|
|
429
|
-
# Determine URLs per environment
|
|
430
|
-
echo "Please provide the dev site URL"
|
|
431
|
-
read DEV_URL
|
|
432
|
-
|
|
433
|
-
echo "Please provide the prod site URL"
|
|
434
|
-
read PROD_URL
|
|
435
|
-
|
|
436
|
-
# Determine GCP project
|
|
437
|
-
echo "Please provide the dev GCP project id"
|
|
438
|
-
read DEV_PROJECT
|
|
439
|
-
|
|
440
|
-
echo "Please provide the prod GCP project id"
|
|
441
|
-
read PROD_PROJECT
|
|
442
|
-
|
|
443
|
-
# Build circle config based on variables
|
|
444
|
-
cat<<EOCIRCLE > config.yml
|
|
445
|
-
version: 2.1
|
|
446
|
-
orbs:
|
|
447
|
-
gcp-gcr: circleci/gcp-cli@1.0.4
|
|
448
|
-
executors:
|
|
449
|
-
google:
|
|
450
|
-
description: The official Google docker container with gcloud SDK pre-installed
|
|
451
|
-
docker:
|
|
452
|
-
- image: google/cloud-sdk
|
|
453
|
-
|
|
454
|
-
jobs:
|
|
455
|
-
gcs-dev:
|
|
456
|
-
executor: google
|
|
457
|
-
steps:
|
|
458
|
-
- attach_workspace:
|
|
459
|
-
at: ~/project
|
|
460
|
-
# https://gist.github.com/DarrenN/8c6a5b969481725a4413
|
|
461
|
-
- run: |
|
|
462
|
-
echo "export PACKAGE_VERSION=v\$(grep -m1 version package.json | awk -F: '{ print \$2 }' | sed 's/[", ]//g')" >> \$BASH_ENV
|
|
463
|
-
- gcp-gcr/initialize
|
|
464
|
-
- run: |
|
|
465
|
-
gsutil mb gs://\$PACKAGE_VERSION.$DEV_URL
|
|
466
|
-
gsutil -m cp -r ./project/image/* gs://\$PACKAGE_VERSION.$DEV_URL
|
|
467
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://\$PACKAGE_VERSION.$DEV_URL/bundle.js
|
|
468
|
-
gsutil iam ch allUsers:objectViewer gs://$DEV_URL
|
|
469
|
-
- run: |
|
|
470
|
-
gsutil mb gs://$DEV_URL
|
|
471
|
-
gsutil -m rm gs://$DEV_URL/**
|
|
472
|
-
gsutil -m cp -r gs://\$PACKAGE_VERSION.$DEV_URL/* gs://$DEV_URL
|
|
473
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://$DEV_URL/bundle.js
|
|
474
|
-
gsutil iam ch allUsers:objectViewer gs://$DEV_URL
|
|
475
|
-
|
|
476
|
-
gcs-prod:
|
|
477
|
-
executor: google
|
|
478
|
-
steps:
|
|
479
|
-
- attach_workspace:
|
|
480
|
-
at: ~/project
|
|
481
|
-
# https://gist.github.com/DarrenN/8c6a5b969481725a4413
|
|
482
|
-
- run: |
|
|
483
|
-
echo "export PACKAGE_VERSION=v\$(grep -m1 version package.json | awk -F: '{ print \$2 }' | sed 's/[", ]//g')" >> \$BASH_ENV
|
|
484
|
-
- gcp-gcr/initialize
|
|
485
|
-
- run: |
|
|
486
|
-
gsutil mb gs://\$PACKAGE_VERSION.$PROD_URL
|
|
487
|
-
gsutil -m cp -r ./project/image/* gs://\$PACKAGE_VERSION.$PROD_URL
|
|
488
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://\$PACKAGE_VERSION.$PROD_URL/bundle.js
|
|
489
|
-
gsutil iam ch allUsers:objectViewer gs://$PROD_URL
|
|
490
|
-
- run: |
|
|
491
|
-
gsutil mb gs://$PROD_URL
|
|
492
|
-
gsutil -m rm gs://$PROD_URL/**
|
|
493
|
-
gsutil -m cp -r gs://\$PACKAGE_VERSION.$PROD_URL/* gs://$PROD_URL
|
|
494
|
-
gsutil setmeta -h "Content-Encoding:gzip" gs://$PROD_URL/bundle.js
|
|
495
|
-
gsutil iam ch allUsers:objectViewer gs://$PROD_URL
|
|
496
|
-
|
|
497
|
-
build:
|
|
498
|
-
docker:
|
|
499
|
-
- image: circleci/node:12.10.0
|
|
500
|
-
steps:
|
|
501
|
-
- checkout
|
|
502
|
-
- restore_cache:
|
|
503
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
504
|
-
|
|
505
|
-
- run:
|
|
506
|
-
name: Setup @leverege Token
|
|
507
|
-
command: echo \${NPMRC} > ~/.npmrc
|
|
508
|
-
|
|
509
|
-
- run: npm install
|
|
510
|
-
|
|
511
|
-
- save_cache:
|
|
512
|
-
key: dependency-cache-{{ checksum "package.json" }}
|
|
513
|
-
paths:
|
|
514
|
-
- ./node_modules
|
|
515
|
-
|
|
516
|
-
- run:
|
|
517
|
-
name: Install license-checker
|
|
518
|
-
command: npm install license-checker
|
|
519
|
-
|
|
520
|
-
- run:
|
|
521
|
-
name: Check for license violations (e.g. GPL)
|
|
522
|
-
command: npm run licenseCheck
|
|
523
|
-
|
|
524
|
-
- run:
|
|
525
|
-
name: Bundle using webpack
|
|
526
|
-
command: |
|
|
527
|
-
npm run clean
|
|
528
|
-
npm run build
|
|
529
|
-
rm -fr ./image
|
|
530
|
-
mkdir ./image
|
|
531
|
-
cp -fr ./dist/* ./image/
|
|
532
|
-
gzip ./image/bundle.js
|
|
533
|
-
mv ./image/bundle.js.gz ./image/bundle.js
|
|
534
|
-
|
|
535
|
-
- persist_to_workspace:
|
|
536
|
-
root: ~/project
|
|
537
|
-
paths:
|
|
538
|
-
- image/*
|
|
539
|
-
- package.json
|
|
540
|
-
|
|
541
|
-
workflows:
|
|
542
|
-
version: 2.1
|
|
543
|
-
build-deploy-dev:
|
|
544
|
-
jobs:
|
|
545
|
-
- build:
|
|
546
|
-
context: npm
|
|
547
|
-
- gcs-dev:
|
|
548
|
-
context: $DEV_PROJECT
|
|
549
|
-
filters:
|
|
550
|
-
branches:
|
|
551
|
-
only: /release-.*/
|
|
552
|
-
requires:
|
|
553
|
-
- build
|
|
554
|
-
build-deploy-prod:
|
|
555
|
-
jobs:
|
|
556
|
-
- build:
|
|
557
|
-
context: npm
|
|
558
|
-
filters:
|
|
559
|
-
branches:
|
|
560
|
-
only: master
|
|
561
|
-
- gcs-prod:
|
|
562
|
-
context: $PROD_PROJECT
|
|
563
|
-
filters:
|
|
564
|
-
branches:
|
|
565
|
-
only: master
|
|
566
|
-
requires:
|
|
567
|
-
- build
|
|
568
|
-
|
|
569
|
-
EOCIRCLE
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
check_circle_config
|
|
573
|
-
create_circle_config
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
display_usage() {
|
|
3
|
-
echo "This script decrypts files using Google KMS."
|
|
4
|
-
echo -e "\nInputs: .env.enc and secrets.tar.gz.enc (if it exists) \n"
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
install_gcloud() {
|
|
8
|
-
install () {
|
|
9
|
-
# Set sudo to work whether logged in as root user or non-root user
|
|
10
|
-
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
|
|
11
|
-
|
|
12
|
-
# Create an environment variable for the correct distribution
|
|
13
|
-
if [[ $(command -v lsb_release) == "" ]]; then
|
|
14
|
-
$SUDO apt-get update && $SUDO apt-get -y install lsb-release
|
|
15
|
-
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
|
|
16
|
-
else
|
|
17
|
-
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
# Add the Google Cloud SDK distribution URI as a package source
|
|
21
|
-
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | $SUDO tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
|
|
22
|
-
|
|
23
|
-
# Import the Google Cloud public key
|
|
24
|
-
if [[ $(command -v curl) == "" ]]; then
|
|
25
|
-
$SUDO apt-get update && $SUDO apt-get -y install curl
|
|
26
|
-
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | $SUDO apt-key add -
|
|
27
|
-
else
|
|
28
|
-
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | $SUDO apt-key add -
|
|
29
|
-
fi
|
|
30
|
-
|
|
31
|
-
# Update and install the Cloud SDK
|
|
32
|
-
$SUDO apt-get update && $SUDO apt-get -y install google-cloud-sdk
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if grep 'docker\|lxc' /proc/1/cgroup; then
|
|
36
|
-
if [[ $(command -v gcloud) == "" ]]; then
|
|
37
|
-
install
|
|
38
|
-
else
|
|
39
|
-
echo "gcloud CLI is already installed."
|
|
40
|
-
fi
|
|
41
|
-
else
|
|
42
|
-
echo "----------------------------------------------------------------------------------------------------"
|
|
43
|
-
echo "this is a machine executor job, replacing default installation of gcloud CLI"
|
|
44
|
-
echo "----------------------------------------------------------------------------------------------------"
|
|
45
|
-
sudo rm -rf /opt/google-cloud-sdk
|
|
46
|
-
install
|
|
47
|
-
fi
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
initialize_gcloud() {
|
|
51
|
-
echo ${GCLOUD_SERVICE_KEY} > ${HOME}/gcloud-service-key.json
|
|
52
|
-
|
|
53
|
-
# Initialize gcloud CLI
|
|
54
|
-
gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
|
|
55
|
-
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
|
|
56
|
-
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if [ "$1" == "-h" ]; then
|
|
60
|
-
display_usage
|
|
61
|
-
exit 1
|
|
62
|
-
fi
|
|
63
|
-
|
|
64
|
-
if [ "$CIRCLECI" == "true" ]; then
|
|
65
|
-
install_gcloud
|
|
66
|
-
initialize_gcloud
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
# Attempt to grab org name from git remote origin
|
|
70
|
-
git_orgname=`git config --get remote.origin.url | cut -d ":" -f 2 | cut -d "/" -f 1`
|
|
71
|
-
|
|
72
|
-
# Set project based on org name
|
|
73
|
-
printf "\nDetecting organization name...\n"
|
|
74
|
-
|
|
75
|
-
if [ "$git_orgname" = "leverege" ]; then
|
|
76
|
-
printf "\nUsing leverege\n\n"
|
|
77
|
-
gcp_project=leverege-docker-images
|
|
78
|
-
elif [ "$git_orgname" = "cox2m" ]; then
|
|
79
|
-
printf "\nUsing cox2m\n\n"
|
|
80
|
-
gcp_project=cox2m-docker-images
|
|
81
|
-
else
|
|
82
|
-
printf "\nDid not recognize organization name...\n"
|
|
83
|
-
printf "\nDefaulting to leverege\n\n"
|
|
84
|
-
gcp_project=leverege-docker-images
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# decrypt .env.enc file
|
|
88
|
-
gcloud kms decrypt \
|
|
89
|
-
--project $gcp_project \
|
|
90
|
-
--key circle-ci \
|
|
91
|
-
--keyring build-tools \
|
|
92
|
-
--location us-east4 \
|
|
93
|
-
--plaintext-file .env \
|
|
94
|
-
--ciphertext-file .env.enc
|
|
95
|
-
|
|
96
|
-
if [ -f "secrets.tar.gz.enc" ]; then
|
|
97
|
-
# decrypt the secrets.tar.gz.enc
|
|
98
|
-
gcloud kms decrypt \
|
|
99
|
-
--project $gcp_project \
|
|
100
|
-
--key circle-ci \
|
|
101
|
-
--keyring build-tools \
|
|
102
|
-
--location us-east4 \
|
|
103
|
-
--plaintext-file secrets.tar.gz \
|
|
104
|
-
--ciphertext-file secrets.tar.gz.enc
|
|
105
|
-
|
|
106
|
-
# untar secrets.tar.gz
|
|
107
|
-
tar xvzf secrets.tar.gz
|
|
108
|
-
fi
|