@leverege/build-tools 2.99.1 → 2.100.0

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/src/circleate.sh DELETED
@@ -1,599 +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
- CIRCLE_NODE_IMG="cimg/node:lts"
14
- DOC_CREATOR_ENDPOINT="https://doc-creator.leverege.com/buildDocs/$(basename $npm_package_name)"
15
-
16
- check_circle_config(){
17
- if [ -d "./.circleci" ];
18
- then
19
- printf "\nThere is an existing CircleCI config, do you want to override?\n\n"
20
- printf "Hit return to continue or ^C to exit\n\n"; read ANS
21
- rm -rf ./.circleci
22
- fi
23
-
24
- mkdir -p ./.circleci
25
- }
26
-
27
- strip_undefined() {
28
- local result="$1"
29
- [ "$1" == "undefined" ] && result=""
30
- printf "$result"
31
- }
32
-
33
- create_circle_config(){
34
- echo "Creating the CircleCI config file"
35
- cd .circleci
36
- if [ "$repo_type" = "server" ]; then
37
- create_server_config
38
- elif [ "$repo_type" = "lib" ]; then
39
- create_lib_config
40
- else
41
- create_ui_config
42
- fi
43
- }
44
-
45
- create_server_config(){
46
- cat<<EOCIRCLE > config.yml
47
- version: 2.1
48
- #orbs:
49
- # gcp-gcr: circleci/gcp-gcr@0.6.1
50
- executors:
51
- default:
52
- description: >
53
- A debian-based machine executor.
54
- machine: true
55
- jobs:
56
- install:
57
- docker:
58
- - image: $CIRCLE_NODE_IMG
59
- steps:
60
- - checkout
61
- - restore_cache:
62
- keys:
63
- - v1-npm-deps-{{ checksum "package-lock.json" }}
64
- - v1-npm-deps-
65
-
66
- - run:
67
- name: Setup @leverege Token
68
- command: echo \${NPMRC} > ~/.npmrc
69
-
70
- - run: npm install
71
-
72
- - save_cache:
73
- key: v1-npm-deps-{{ checksum "package-lock.json" }}
74
- paths:
75
- - ./node_modules
76
-
77
- - persist_to_workspace:
78
- root: /home/circleci/project
79
- paths:
80
- - ./node_modules
81
-
82
- security-check:
83
- docker:
84
- - image: $CIRCLE_NODE_IMG
85
- steps:
86
- - checkout
87
- - attach_workspace:
88
- at: ~/project
89
- - run:
90
- name: Check for vulnerabilities
91
- command: npm audit --omit=dev --audit-level=moderate
92
-
93
- license-check:
94
- docker:
95
- - image: $CIRCLE_NODE_IMG
96
- steps:
97
- - checkout
98
- - attach_workspace:
99
- at: ~/project
100
- - run:
101
- name: Check for LICENSE and README files
102
- command: npm run pkglint
103
-
104
- - run:
105
- name: Check for license violations (e.g. GPL)
106
- command: npx license-checker --production --summary --failOn GPL
107
-
108
- lint:
109
- docker:
110
- - image: $CIRCLE_NODE_IMG
111
- steps:
112
- - checkout
113
- - attach_workspace:
114
- at: ~/project
115
- - run:
116
- name: Lint and save results
117
- command: npm run lint-ci
118
-
119
- - store_test_results:
120
- path: reports
121
-
122
- docs:
123
- circleci_ip_ranges: true
124
- docker:
125
- - image: $CIRCLE_NODE_IMG
126
- steps:
127
- - checkout
128
- - attach_workspace:
129
- at: ~/project
130
- - run:
131
- name: Generate docs
132
- command: npm run docs
133
- - store_artifacts:
134
- path: docs
135
- prefix: docs
136
- - run:
137
- name: Initiate document creation
138
- command: curl -X GET "$DOC_CREATOR_ENDPOINT"
139
-
140
- coverage:
141
- # coverage runs tests, generates coverage, and saves docs
142
- environment:
143
- TZ: 'America/New_York'
144
- CACHE_CONFIG: '{"type":"inMemory"}'
145
- docker:
146
- - image: $CIRCLE_NODE_IMG
147
- # IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
148
- # Only enable redis if inMemory is insufficient
149
- # - image: redis
150
- # - image: circleci/mysql:5.7
151
- # environment:
152
- # MYSQL_USER: root
153
- # MYSQL_ROOT_PASSWORD: root
154
- # MYSQL_ALLOW_EMPTY_PASSWORD: true
155
- # MYSQL_HOST: 127.0.0.1
156
- # - image: nsqio/nsq
157
- # command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
158
-
159
- # - image: nsqio/nsq
160
- # command: >
161
- # /nsqd
162
- # -broadcast-address localhost:4150
163
- # -tcp-address 0.0.0.0:4150
164
- # -http-address 0.0.0.0:4151
165
- # -lookupd-tcp-address localhost:4160
166
-
167
- steps:
168
- - checkout
169
- - attach_workspace:
170
- at: ~/project
171
-
172
- # UNCOMMENT IF YOU NEED DECRYPTING SECRETS
173
- # - run:
174
- # name: Load secrets
175
- # command: npm run decrypt
176
-
177
- - run:
178
- name: Run Tests and Generate Code Coverage
179
- command: npm run coverage
180
-
181
- - run:
182
- name: Check if coverage meets at least 70%
183
- command: npx c8 check-coverage --functions 70 --lines 70 --statements 70
184
-
185
- - store_artifacts:
186
- path: coverage
187
- prefix: coverage
188
-
189
- build:
190
- # build should make dist image and prepare docker file
191
- docker:
192
- - image: $CIRCLE_NODE_IMG
193
-
194
- steps:
195
- - run:
196
- name: CircleCI image build process - DEPRECATED 07/01/2023
197
- command: echo "***CircleCI image builds deprecated 07/01/2023"
198
- # - checkout
199
- # - attach_workspace:
200
- # at: ~/project
201
-
202
- # - run:
203
- # name: Setup @leverege Token
204
- # command: echo \${NPMRC} > ~/.npmrc.ro
205
-
206
- # - run:
207
- # name: Determine version number and container name
208
- # command: |
209
- # container="\`node -p \"require('./package.json').leverege.container\"\`"
210
- # if [ "\$container" == "undefined" ];
211
- # then
212
- # container=\$CIRCLE_PROJECT_REPONAME
213
- # fi
214
- # NODE_IMAGE="\`node -p \"require('./package.json').leverege.nodeimg\"\`"
215
-
216
- # echo \$(git describe --tags) > package_version
217
- # echo \${container} > container_name
218
- # echo \${NODE_IMAGE} > node_img
219
-
220
- # - run:
221
- # name: Create Dockerfile and build dist directory
222
- # command: mkdir -p docker && npm run dockerize \$(git describe --tags)
223
-
224
- # - persist_to_workspace:
225
- # root: ~/project
226
- # paths:
227
- # - docker/*
228
- # - package_version
229
- # - container_name
230
- # - node_img
231
-
232
- workflows:
233
- version: 2.1
234
- circle-srv-config:
235
- jobs:
236
- - install:
237
- context: npm
238
- - security-check:
239
- requires:
240
- - install
241
- - license-check:
242
- requires:
243
- - install
244
- - lint:
245
- requires:
246
- - install
247
- - coverage:
248
- context: npm
249
- requires:
250
- - install
251
- - docs:
252
- requires:
253
- - install
254
- # - build:
255
- # context: npm
256
- # filters:
257
- # branches:
258
- # only:
259
- # - development
260
- # - /release-.*/
261
- # - master
262
- # requires:
263
- # - install
264
- # - security-check
265
- # - license-check
266
- # - lint
267
- # - coverage
268
- # - docs
269
- EOCIRCLE
270
- }
271
-
272
- create_lib_config(){
273
- cat<<EOCIRCLE > config.yml
274
- version: 2.1
275
- jobs:
276
- install:
277
- docker:
278
- - image: $CIRCLE_NODE_IMG
279
- steps:
280
- - checkout
281
- - restore_cache:
282
- keys:
283
- - v1-npm-deps-{{ checksum "package-lock.json" }}
284
- - v1-npm-deps-
285
-
286
- - run:
287
- name: Setup @leverege Token
288
- command: echo \${NPMRC} > ~/.npmrc
289
-
290
- - run: npm install
291
-
292
- - save_cache:
293
- key: v1-npm-deps-{{ checksum "package-lock.json" }}
294
- paths:
295
- - ./node_modules
296
-
297
- - persist_to_workspace:
298
- root: /home/circleci/project
299
- paths:
300
- - ./node_modules
301
-
302
- security-check:
303
- docker:
304
- - image: $CIRCLE_NODE_IMG
305
- steps:
306
- - checkout
307
- - attach_workspace:
308
- at: ~/project
309
- - run:
310
- name: Check for vulnerabilities
311
- command: npm audit --omit=dev --audit-level=moderate
312
-
313
- license-check:
314
- docker:
315
- - image: $CIRCLE_NODE_IMG
316
- steps:
317
- - checkout
318
- - attach_workspace:
319
- at: ~/project
320
- - run:
321
- name: Check for LICENSE and README files
322
- command: npm run pkglint
323
-
324
- - run:
325
- name: Check for license violations (e.g. GPL)
326
- command: npx license-checker --production --summary --failOn GPL
327
-
328
- lint:
329
- docker:
330
- - image: $CIRCLE_NODE_IMG
331
- steps:
332
- - checkout
333
- - attach_workspace:
334
- at: ~/project
335
- - run:
336
- name: Lint and save results
337
- command: npm run lint-ci
338
-
339
- - store_test_results:
340
- path: reports
341
-
342
- docs:
343
- circleci_ip_ranges: true
344
- docker:
345
- - image: $CIRCLE_NODE_IMG
346
- steps:
347
- - checkout
348
- - attach_workspace:
349
- at: ~/project
350
- - run:
351
- name: Generate docs
352
- command: npm run docs
353
- - store_artifacts:
354
- path: docs
355
- prefix: docs
356
- - run:
357
- name: Initiate document creation
358
- command: curl -X GET "$DOC_CREATOR_ENDPOINT"
359
-
360
- coverage:
361
- # coverage runs tests, generates coverage, and saves docs
362
- environment:
363
- TZ: 'America/New_York'
364
- CACHE_CONFIG: '{"type":"inMemory"}'
365
- docker:
366
- - image: $CIRCLE_NODE_IMG
367
- # IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
368
- # Only enable redis if inMemory is insufficient
369
- # - image: redis
370
- # - image: circleci/mysql:5.7
371
- # environment:
372
- # MYSQL_USER: root
373
- # MYSQL_ROOT_PASSWORD: root
374
- # MYSQL_ALLOW_EMPTY_PASSWORD: true
375
- # MYSQL_HOST: 127.0.0.1
376
- # - image: nsqio/nsq
377
- # command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
378
-
379
- # - image: nsqio/nsq
380
- # command: >
381
- # /nsqd
382
- # -broadcast-address localhost:4150
383
- # -tcp-address 0.0.0.0:4150
384
- # -http-address 0.0.0.0:4151
385
- # -lookupd-tcp-address localhost:4160
386
-
387
- steps:
388
- - checkout
389
- - attach_workspace:
390
- at: ~/project
391
-
392
- # UNCOMMENT IF YOU NEED DECRYPTING SECRETS
393
- # - run:
394
- # name: Load secrets
395
- # command: npm run decrypt
396
-
397
- - run:
398
- name: Run Tests and Generate Code Coverage
399
- command: npm run coverage
400
-
401
- - run:
402
- name: Check if coverage meets at least 70%
403
- command: npx c8 check-coverage --functions 70 --lines 70 --statements 70
404
-
405
- - store_artifacts:
406
- path: coverage
407
- prefix: coverage
408
-
409
- workflows:
410
- version: 2.1
411
- circle-lib-config:
412
- jobs:
413
- - install:
414
- context: npm
415
- - security-check:
416
- requires:
417
- - install
418
- - license-check:
419
- requires:
420
- - install
421
- - lint:
422
- requires:
423
- - install
424
- - coverage:
425
- context: npm
426
- requires:
427
- - install
428
- - docs:
429
- requires:
430
- - install
431
- EOCIRCLE
432
- }
433
-
434
- create_ui_config(){
435
- cat<<FIREBASEINFO
436
-
437
- You need to setup Firebase hosting using the cli tool before configuring CI.
438
- Please make sure .firebaserc and firebase.json are configured with targets set like:
439
-
440
- {
441
- "projects": {
442
- "default": "leverege-jumpstart"
443
- },
444
- "targets": {
445
- "leverege-jumpstart": {
446
- "hosting": {
447
- "unique-target-name": [
448
- "target-name-on-firebase-console"
449
- ]
450
- }
451
- }
452
- }
453
- }
454
-
455
- You can add target using:
456
-
457
- $ firebase target:apply hosting <unique-target-name> <target-name-on-firebase-console>
458
-
459
- (See https://firebase.google.com/docs/hosting/quickstart for more info)
460
-
461
- Enter "yes" if everything is set up & ready to go.
462
-
463
- FIREBASEINFO
464
-
465
- read ANS && [ "$ANS" != "yes" ] && exit 1
466
-
467
- # Determine dev environment
468
- printf "\n\nCommits to the dev branch will trigger deployment approval to the dev site.\n"
469
- printf "\nPlease provide the Firebase Project name to be used for dev/testing UI: "
470
- read DEV_PROJ
471
-
472
- printf "\nPlease provide the host target for the dev site (target name in .firebaserc): "
473
- read DEV_TARGET
474
-
475
- # Determine prod environment
476
- printf "\nPlease provide the Firebase Project name to be used for production UI: "
477
- read PRD_PROJ
478
-
479
- # Determine GCP project
480
- printf "\nPlease provide the host target for the production site (target name in .firebaserc): "
481
- read PRD_TARGET
482
-
483
- # Build circle config based on variables
484
- cat<<EOCIRCLE > config.yml
485
- version: 2.1
486
- orbs:
487
- slack: circleci/slack@3.4.2
488
-
489
- jobs:
490
- status:
491
- docker:
492
- - image: cimg/base:2020.01
493
- steps:
494
- - slack/status
495
-
496
- build:
497
- docker:
498
- - image: $CIRCLE_NODE_IMG
499
- steps:
500
- - checkout
501
- - restore_cache:
502
- keys:
503
- - v1-npm-deps-{{ checksum "package-lock.json" }}
504
- - v1-npm-deps-
505
-
506
- - run:
507
- name: Setup @leverege Token
508
- command: echo \${NPMRC} > ~/.npmrc
509
-
510
- - run: npm install
511
-
512
- - save_cache:
513
- key: v1-npm-deps-{{ checksum "package-lock.json" }}
514
- paths:
515
- - ./node_modules
516
-
517
- - run:
518
- name: Bundle using webpack
519
- command: |
520
- npm run clean
521
- npm run build
522
- gzip ./dist/bundle.js
523
- mv ./dist/bundle.js.gz ./dist/bundle.js
524
-
525
- - persist_to_workspace:
526
- root: ~/project
527
- paths:
528
- - dist
529
-
530
- deploy-dev:
531
- docker:
532
- - image: $CIRCLE_NODE_IMG
533
- steps:
534
- - attach_workspace:
535
- at: ~/project
536
- - run: npm install -g firebase-tools
537
- - run:
538
- name: Deploy to dev site
539
- command: firebase use $DEV_PROJ && firebase deploy --token "\$FIREBASE_TOKEN" --only hosting:$DEV_TARGET
540
-
541
- deploy-prod:
542
- docker:
543
- - image: $CIRCLE_NODE_IMG
544
- steps:
545
- - attach_workspace:
546
- at: ~/project
547
- - run: npm install -g firebase-tools
548
- - run:
549
- name: Deploy to dev site
550
- command: firebase use $PRD_PROJ && firebase deploy --token "\$FIREBASE_TOKEN" --only hosting:$PRD_TARGET
551
-
552
- workflows:
553
- version: 2.1
554
- build-deploy-dev:
555
- jobs:
556
- - build:
557
- context: npm
558
- - slack/approval-notification:
559
- context: slack
560
- - deploy-dev:
561
- context: firebase
562
- type: approval
563
- filters:
564
- branches:
565
- only: development
566
- requires:
567
- - build
568
- - status:
569
- context: slack
570
- requires:
571
- - deploy-dev
572
-
573
- build-deploy-prod:
574
- jobs:
575
- - build:
576
- context: npm
577
- filters:
578
- branches:
579
- only: master
580
- - slack/approval-notification:
581
- context: slack
582
- - deploy-prod:
583
- context: firebase
584
- type: approval
585
- filters:
586
- branches:
587
- only: master
588
- requires:
589
- - build
590
- - status:
591
- context: slack
592
- requires:
593
- - deploy-prod
594
-
595
- EOCIRCLE
596
- }
597
-
598
- check_circle_config
599
- create_circle_config