@leverege/build-tools 2.12.0-john.3 → 2.12.0-john.5

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.12.0-john.3",
3
+ "version": "2.12.0-john.5",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/dockreate CHANGED
@@ -7,6 +7,7 @@ fi
7
7
  # Load common bash functions
8
8
  . `build-tools --bashfun`
9
9
  GITTOP=`git rev-parse --show-toplevel`
10
+ cd $GITTOP/docker
10
11
 
11
12
  if [ ! -x "$(command -v jq)" ];
12
13
  then
@@ -18,6 +19,16 @@ NO_JQ
18
19
  exit 1
19
20
  fi
20
21
 
22
+ if [ ! -d "$GITTOP/dist" ];
23
+ then
24
+ cat<<NO_DIST
25
+
26
+ `color r "***ERROR: Missing the dist directory, run this first => "``color g 'npm run build'`
27
+
28
+ NO_DIST
29
+ exit 1
30
+ fi
31
+
21
32
  function packageJson() {
22
33
  result=$(jq -r $1 $GITTOP/package.json)
23
34
  [ "$result" != "null" ] && echo $result
@@ -34,25 +45,6 @@ cleanup() {
34
45
  }
35
46
  trap cleanup INT
36
47
 
37
- # Usage: colorize <color> <string>
38
- # where: color = [red|green|yellow]
39
- # string = the thing to apply the color to
40
- colorize() {
41
- local C_green='\e[92m'
42
- local C_yellow='\e[93m'
43
- local C_red='\e[91m'
44
- local C_off='\e[0m'
45
-
46
- case "$1" in
47
- 'red' ) clr="$C_red" ;;
48
- 'green' ) clr="$C_green" ;;
49
- 'yellow') clr="$C_yellow" ;;
50
- *) clr=$C_off;;
51
- esac
52
-
53
- printf "$clr$2$C_off"
54
- }
55
-
56
48
  strip_undefined() {
57
49
  local result="$1"
58
50
  [ "$1" == "undefined" ] && result=""
@@ -180,13 +172,13 @@ if [ ! -f "$NPMRC" ];
180
172
  then
181
173
  cat<<ROTOKEN
182
174
 
183
- $(colorize 'red' '***ERROR: expecting to see a readonly npmjs token')
175
+ $(color r '***ERROR: expecting to see a readonly npmjs token')
184
176
 
185
177
  For security purposes, we deploy images with read-only npmjs tokens.
186
178
  These may be acquired from another developer, or can be created with the
187
179
  npmjs leverege account.
188
180
 
189
- Obtain the token and drop it here => $(colorize 'green' "$NPMRC")
181
+ Obtain the token and drop it here => $(color g "$NPMRC")
190
182
 
191
183
 
192
184
  ROTOKEN
@@ -199,7 +191,7 @@ if [ "$project" == "" ];
199
191
  then
200
192
  cat<<NOPROJ
201
193
 
202
- $(colorize 'red' '***ERROR: package.json missing a leverege project statement')
194
+ $(color r '***ERROR: package.json missing a leverege project statement')
203
195
 
204
196
  The package.json file must contain a project setting in the leverege
205
197
  namespace stating which GCP project the docker images are written to. It
@@ -234,11 +226,11 @@ then
234
226
  then
235
227
  cat<<NOCONTAINER
236
228
 
237
- $(colorize 'red' '***ERROR: attempting to build an unnamed container')
229
+ $(color r '***ERROR: attempting to build an unnamed container')
238
230
 
239
231
  You are attempting to create a docker image without a container name or
240
- a git remote setup. Either define a $(colorize 'yellow' 'container') statement in the leverege
241
- section of package.json, or add a $(colorize 'green' 'git remote') to this repository.
232
+ a git remote setup. Either define a $(color y 'container') statement in the leverege
233
+ section of package.json, or add a $(color g 'git remote') to this repository.
242
234
 
243
235
  NOCONTAINER
244
236
  exit 1
@@ -260,7 +252,7 @@ then
260
252
  if [[ `git status --porcelain` ]]; then
261
253
  cat<<DIRTAG
262
254
 
263
- $(colorize 'red' '***ERROR: attempting to tag a non-beta dirty git repository')
255
+ $(color r '***ERROR: attempting to tag a non-beta dirty git repository')
264
256
 
265
257
  You are attempting to create a tagged release image for pushing to the
266
258
  container registry, but there are locally modified files. This is not
@@ -269,9 +261,9 @@ then
269
261
 
270
262
  Available options for proceeding:
271
263
 
272
- $(colorize 'green' '1) cleanly commit all local mods assuming relevance')
273
- $(colorize 'yellow' '2) eliminate unwanted local modifications')
274
- $(colorize 'red' '3) stash anything that is irrelevant to this release')
264
+ $(color g '1) cleanly commit all local mods assuming relevance')
265
+ $(color y '2) eliminate unwanted local modifications')
266
+ $(color r '3) stash anything that is irrelevant to this release')
275
267
 
276
268
 
277
269
  DIRTAG
@@ -286,7 +278,7 @@ DIRTAG
286
278
  then
287
279
  cat<<NOUPSTR
288
280
 
289
- $(colorize 'red' '***ERROR: the current branch must have an upstream')
281
+ $(color r '***ERROR: the current branch must have an upstream')
290
282
 
291
283
  You are attempting to create a tagged release image for pushing to the
292
284
  container registry, but the current branch does not have an upstream to
@@ -295,54 +287,53 @@ DIRTAG
295
287
 
296
288
  Available options for proceeding:
297
289
 
298
- $(colorize 'green' '1) set an upstream for this branch via:')
299
- $(colorize 'green' " git push --set-upstream origin ${branch}")
290
+ $(color g '1) set an upstream for this branch via:')
291
+ $(color g " git push --set-upstream origin ${branch}")
300
292
 
301
- $(colorize 'yellow' '2) rebase, squash and merge onto a branch with an upstream')
293
+ $(color y '2) rebase, squash and merge onto a branch with an upstream')
302
294
 
303
295
  NOUPSTR
304
296
  exit 1
305
297
  fi
306
298
 
307
- tagstat=$(colorize 'yellow' 'will be tagged')
299
+ tagstat=$(color y 'will be tagged')
308
300
  else
309
- tagstat=$(colorize 'red' 'BETA RELEASE WILL NOT BE TAGGED')
301
+ tagstat=$(color r 'BETA RELEASE WILL NOT BE TAGGED')
310
302
  fi
311
303
 
312
- pluggedIn=$(colorize 'green' "no")
313
- [ -f "${pluginFile}" ] && pluggedIn=$(colorize 'yellow' "YES")
304
+ pluggedIn=$(color g "no")
305
+ [ -f "${pluginFile}" ] && pluggedIn=$(color y "YES")
314
306
 
315
307
  cat<<IMGINFO
316
- LOCAL LOCAL LOCAL
317
- Project: $(colorize 'green' "$project")
318
- Container: $(colorize 'green' "$container")
319
- NodeImage: $(colorize 'green' "$nodeimg")
320
- NopeOps: $(colorize 'yellow' "$nodeops")
321
- NPM Logs: $(colorize 'green' "$npmlogging")
322
- AddedPkgs: $(colorize 'green' "$apkadds")
308
+ Project: $(color g $project)
309
+ Container: $(color g $container)
310
+ NodeImage: $(color g $nodeimg)
311
+ NopeOps: $(color y $nodeops)
312
+ NPM Logs: $(color g $npmlogging)
313
+ AddedPkgs: $(color g $apkadds)
323
314
  PluggedIn: ${pluggedIn}
324
- Version: $(colorize 'green' "$version") $tagstat
325
- Run User: $(colorize 'green' "$runuser")
326
- Previous: $(colorize 'yellow' "$previous")
327
- DateStamp: $(colorize 'green' "$pckgdts")
328
- GCImage: $(colorize 'green' "$gcimage:$version")
329
- Registry: $(colorize 'yellow' "$registry:$version")
315
+ Version: $(color g $version) $tagstat
316
+ Run User: $(color g $runuser)
317
+ Previous: $(color y $previous)
318
+ DateStamp: $(color g $pckgdts)
319
+ GCImage: $(color g $gcimage:$version)
320
+ Registry: $(color y $registry:$version)
330
321
 
331
322
  IMGINFO
332
323
 
333
324
  if [ "$pckgver" != "$version" ];
334
325
  then
335
326
  cat<<EOPKG
336
- $(colorize 'yellow' '***WARNING: specified version does not match package.json version' )
337
- package.json => $(colorize 'green' "$pckgver")
338
- specified => $(colorize 'red' "$version")
327
+ $(color y '***WARNING: specified version does not match package.json version' )
328
+ package.json => $(color g "$pckgver")
329
+ specified => $(color r "$version")
339
330
 
340
331
  EOPKG
341
332
  if [ $tagging ];
342
333
  then
343
334
  cat<<EONOPE
344
335
 
345
- $(colorize 'red' '... and you are attempting to release so NOPE!' )
336
+ $(color r '... and you are attempting to release so NOPE!' )
346
337
 
347
338
  EONOPE
348
339
  exit 1
@@ -353,7 +344,7 @@ create_Dockerfile "$version" "$nodeimg" "$apkadds"
353
344
  create_bashrc "$version" "$nodeimg"
354
345
 
355
346
  rm -rf ./workspace && mkdir -p ./workspace
356
- cp -rfp ../package*json ../dist/* ./workspace
347
+ cp -rfp ${GITTOP}/package*json ${GITTOP}/dist/* ./workspace
357
348
 
358
349
  # grab the read only npmrc token for the image
359
350
  cp -f $NPMRC .npmrc
@@ -386,7 +377,7 @@ then
386
377
  bldErr=$?
387
378
  cat<<BUILDERR
388
379
 
389
- $(colorize 'red' '***ERROR: build failed! Aborting without tagging.')
380
+ $(color r '***ERROR: build failed! Aborting without tagging.')
390
381
 
391
382
  The gcloud build process seems to have run into a problem. Please fix the
392
383
  issue and rerun the dockerize process. This build will not be tagged, nor
@@ -399,18 +390,26 @@ fi
399
390
  # Tag the container with the node detailsand the culprit.
400
391
  gcloud container images add-tag --quiet $gcimage:$version $gcimage:$pckgdts-$nodeimg-$USER
401
392
  if [ "$USE_ARTIFACTORY" == "yes" ];
402
- printf "Background send `color y $gcimage:$version` to the artifactory - `color g 'thanks for testing!'`\n\n"
393
+ then
394
+ cat<<END_ARTY
395
+
396
+ Sending `color y $gcimage:$version` to the `color g artifactory`
397
+ in the background, which may take up to a minute to complete.
398
+
399
+ `color g 'Thank you for testing!'`
400
+
401
+ END_ARTY
403
402
  gcloud container images add-tag --quiet $gcimage:$version $registry:$version &
404
403
  fi
405
404
 
406
405
  if [ $tagging ];
407
406
  then
408
- printf "\n$(colorize 'green' "Tagging and Pushing $version")\n"
407
+ printf "\n$(color g "Tagging and Pushing $version")\n"
409
408
  git tag -af $1 -m "Docker version $1"
410
409
  git push --follow-tags
411
410
  gcloud container images add-tag --quiet $gcimage:$version $gcimage:latest
412
411
  else
413
- printf "\n$(colorize 'yellow' '*** Skipped git tagging - beta release')\n\n"
412
+ printf "\n$(color y '*** Skipped git tagging - beta release')\n\n"
414
413
  fi
415
414
 
416
415
  cleanup