@leverege/build-tools 2.50.15 → 2.50.17
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 +5 -5
- package/src/Utils.mjs +3 -1
- package/src/bash-funcs +5 -1
- package/src/git-tar.sh +10 -3
- package/src/helm-charts/redis/helmup.plugin +1 -1
- package/src/helm-charts/velero/helmup.plugin +1 -1
- package/src/helmup.sh +1 -1
- package/src/overwhelm.mjs +4 -1
- package/src/zx-testing +0 -216
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.50.
|
|
3
|
+
"version": "2.50.17",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"command-line-usage": "^7.0.1",
|
|
62
62
|
"deepmerge": "^4.3.1",
|
|
63
63
|
"enquirer": "^2.4.1",
|
|
64
|
-
"execa": "^9.
|
|
65
|
-
"glob": "^10.4.
|
|
64
|
+
"execa": "^9.3.0",
|
|
65
|
+
"glob": "^10.4.2",
|
|
66
66
|
"handlebars": "^4.7.8",
|
|
67
|
-
"inquirer": "^9.2
|
|
67
|
+
"inquirer": "^9.3.2",
|
|
68
68
|
"js-yaml": "^4.1.0",
|
|
69
69
|
"ms": "^2.1.3",
|
|
70
70
|
"npm-registry-fetch": "^17.1.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"readline-sync": "^1.4.10",
|
|
75
75
|
"semver": "^7.6.2",
|
|
76
76
|
"simple-git": "^3.25.0",
|
|
77
|
-
"zx": "^8.1.
|
|
77
|
+
"zx": "^8.1.3"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@leverege/eslint-config-leverege": "^4.2.0",
|
package/src/Utils.mjs
CHANGED
|
@@ -7,7 +7,9 @@ import { glob } from 'glob'
|
|
|
7
7
|
import { packageUp } from 'package-up'
|
|
8
8
|
import YAML from 'js-yaml'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
let debugEnabled = process.env.BUILD_TOOLS_DEBUG === '1'
|
|
11
|
+
|
|
12
|
+
export const disableDebug = () => debugEnabled = false
|
|
11
13
|
|
|
12
14
|
/* eslint-disable no-console */
|
|
13
15
|
export const err = console.error
|
package/src/bash-funcs
CHANGED
|
@@ -29,8 +29,12 @@ RED_ERROR=`color r '***ERROR:'`
|
|
|
29
29
|
YELO_WARN="`color y '***WARNING:'`"
|
|
30
30
|
GREEN_INFO=`color g '***INFO:'`
|
|
31
31
|
|
|
32
|
+
function clearScreen() {
|
|
33
|
+
[ "$BUILD_TOOLS_DEBUG" != "1" ] && clear
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
function clearlyWarn() {
|
|
33
|
-
|
|
37
|
+
clearScreen
|
|
34
38
|
cat<<CLEARWARN
|
|
35
39
|
|
|
36
40
|
`color y '*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING ***'`
|
package/src/git-tar.sh
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
# Load the standard helper functions
|
|
4
|
+
. `build-tools --bashfun`
|
|
5
|
+
|
|
3
6
|
# If it isn't already set use the default ~/work/.gitar
|
|
4
7
|
#
|
|
5
8
|
[ -z $GITAR ] && GITAR="${HOME}/.gitar"
|
|
@@ -65,12 +68,13 @@ REPO=`basename ${GTOP}`
|
|
|
65
68
|
#
|
|
66
69
|
DTS="`date +\"%Y%m%d-%H%M%S\"`"
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
TARS=${GITAR}/${REPO}
|
|
72
|
+
TARB=${TARS}/${DTS}.tar # Craft the target tarball name.
|
|
69
73
|
|
|
70
74
|
# Now do the work
|
|
71
75
|
#
|
|
72
76
|
cd ${GTOP}/..
|
|
73
|
-
printf "\n*** Tarring $TARB
|
|
77
|
+
printf "\n*** Tarring `color g $TARB`\n"
|
|
74
78
|
tar cf $TARB -X $TARX $REPO
|
|
75
79
|
chmod 0640 $TARB
|
|
76
80
|
|
|
@@ -84,6 +88,9 @@ then
|
|
|
84
88
|
FIZ=xz
|
|
85
89
|
fi
|
|
86
90
|
|
|
87
|
-
printf "*** Compressing $TARB.$FIZ (background)\n
|
|
91
|
+
printf "\n*** Compressing `color y $TARB.$FIZ` (background)\n"
|
|
88
92
|
$ZIPPER $TARB &
|
|
93
|
+
|
|
94
|
+
printf "\n*** Tarballs in `color g ${TARS}`\n\n"
|
|
95
|
+
ls -lh ${TARS}
|
|
89
96
|
cd - 2>&1 >/dev/null
|
|
@@ -4,7 +4,7 @@ showInstalling "Redis"
|
|
|
4
4
|
|
|
5
5
|
OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
|
|
6
6
|
|
|
7
|
-
[ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="19.
|
|
7
|
+
[ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="19.6.0"
|
|
8
8
|
|
|
9
9
|
helm upgrade --install redis $OCI_CHART \
|
|
10
10
|
--values redis/redis-local.yaml \
|
|
@@ -4,7 +4,7 @@ showInstalling "Velero Backup System"
|
|
|
4
4
|
|
|
5
5
|
addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
|
|
6
6
|
|
|
7
|
-
[ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="
|
|
7
|
+
[ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="7"
|
|
8
8
|
#
|
|
9
9
|
# Build the bucket, region and SA email variables and use --set to mod the
|
|
10
10
|
# chart values as opposed to using an OVH:<label> approach. This eliminates
|
package/src/helmup.sh
CHANGED
|
@@ -666,7 +666,7 @@ function installVeleroEnvironment() {
|
|
|
666
666
|
gcloud config set project $GCP_PROJECT_ID
|
|
667
667
|
|
|
668
668
|
## The major chart version will determine the bucket suffix
|
|
669
|
-
[ -z "$VELERO_HELM_CHART" ] && VELERO_HELM_CHART="
|
|
669
|
+
[ -z "$VELERO_HELM_CHART" ] && VELERO_HELM_CHART="7"
|
|
670
670
|
|
|
671
671
|
## Create a bucket
|
|
672
672
|
BUCKET="$GCP_PROJECT_ID-velero-$VELERO_HELM_CHART"
|
package/src/overwhelm.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import parse from 'parse-gitignore'
|
|
|
15
15
|
import ask from 'readline-sync'
|
|
16
16
|
import YAML from 'js-yaml'
|
|
17
17
|
|
|
18
|
-
import { debug, err, log, shellCmd } from './Utils.mjs'
|
|
18
|
+
import { debug, disableDebug, err, log, shellCmd } from './Utils.mjs'
|
|
19
19
|
|
|
20
20
|
const optionsDefinitions = [
|
|
21
21
|
/* eslint-disable no-multi-spaces */
|
|
@@ -33,6 +33,9 @@ const optionsDefinitions = [
|
|
|
33
33
|
]
|
|
34
34
|
const args = cliArgs( optionsDefinitions )
|
|
35
35
|
|
|
36
|
+
// when using --key we only want the key contents w/o debug info
|
|
37
|
+
if ( args.key ) { disableDebug() }
|
|
38
|
+
|
|
36
39
|
// See if we are in a monorepo, which changes some of the rules.
|
|
37
40
|
const gitTop = await shellCmd( 'git rev-parse --show-toplevel' )
|
|
38
41
|
|
package/src/zx-testing
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
// https://github.com/google/zx
|
|
4
|
-
/* eslint-disable max-len */
|
|
5
|
-
import pkg from 'enquirer'
|
|
6
|
-
import colors from 'ansi-colors'
|
|
7
|
-
import { $, fs, argv, path, chalk } from 'zx'
|
|
8
|
-
|
|
9
|
-
const { prompt } = pkg
|
|
10
|
-
|
|
11
|
-
// This will preserve coloration from spawned child processes
|
|
12
|
-
process.env.FORCE_COLORS = 3
|
|
13
|
-
process.env.FORCE_COLOR = '1'
|
|
14
|
-
|
|
15
|
-
let TARGET
|
|
16
|
-
let CHANNEL
|
|
17
|
-
|
|
18
|
-
// A single unnamed parameter is assumed to be a deploy target.
|
|
19
|
-
// If named parameters exist, they may not be stored in argv,
|
|
20
|
-
// so don't look for a larger length of argv to decide whether to look for named paramters
|
|
21
|
-
if ( argv._.length === 1 ) {
|
|
22
|
-
TARGET = argv._[0]
|
|
23
|
-
} else {
|
|
24
|
-
TARGET = argv.target
|
|
25
|
-
|
|
26
|
-
if ( argv.channelName ) {
|
|
27
|
-
CHANNEL = {}
|
|
28
|
-
CHANNEL.name = argv.channelName
|
|
29
|
-
CHANNEL.expiration = argv.channelExpiration ?? '7d'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// If target has not been defined on the command line,
|
|
34
|
-
// then enter interactive mode
|
|
35
|
-
const INTERACTIVE_MODE = !TARGET
|
|
36
|
-
|
|
37
|
-
let exited = false
|
|
38
|
-
|
|
39
|
-
const SECRETS_DIR = 'secrets'
|
|
40
|
-
const EXIT_EVENTS = [ 'SIGINT', 'exit', 'uncaughException', 'unhandledRejection' ]
|
|
41
|
-
|
|
42
|
-
const [
|
|
43
|
-
firebaserc,
|
|
44
|
-
firebaseJson,
|
|
45
|
-
gitBranch
|
|
46
|
-
] = await Promise.all( [
|
|
47
|
-
fs.exists( path.join( process.cwd(), '.firebaserc' ) ),
|
|
48
|
-
fs.exists( path.join( process.cwd(), 'firebase.json' ) ),
|
|
49
|
-
$`git rev-parse --abbrev-ref HEAD -C ${process.cwd()}`
|
|
50
|
-
.then( ( { stdout } ) => {
|
|
51
|
-
return stdout.split( '\n' )[0]
|
|
52
|
-
} )
|
|
53
|
-
] )
|
|
54
|
-
|
|
55
|
-
if ( !firebaserc ) {
|
|
56
|
-
console.log( chalk.red( 'No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if ( !firebaseJson ) {
|
|
60
|
-
console.log( chalk.red( 'No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if ( !firebaserc || !firebaseJson ) {
|
|
64
|
-
process.exit()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const firebasercContent = JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) )
|
|
68
|
-
|
|
69
|
-
let maxSiteIdLength = 0
|
|
70
|
-
|
|
71
|
-
const targets = Object
|
|
72
|
-
.entries( firebasercContent.targets )
|
|
73
|
-
.reduce( ( prev, [ projectId, config ] ) => {
|
|
74
|
-
Object
|
|
75
|
-
.entries( config.hosting )
|
|
76
|
-
.forEach( ( [ siteId, aliases ] ) => {
|
|
77
|
-
aliases.forEach( ( alias ) => {
|
|
78
|
-
// Store the longest length of site id for formatting later on
|
|
79
|
-
maxSiteIdLength = Math.max( siteId.length, maxSiteIdLength )
|
|
80
|
-
|
|
81
|
-
// eslint-disable-next-line no-param-reassign
|
|
82
|
-
prev[alias] = {
|
|
83
|
-
projectId,
|
|
84
|
-
siteId,
|
|
85
|
-
alias,
|
|
86
|
-
production : config.production
|
|
87
|
-
}
|
|
88
|
-
} )
|
|
89
|
-
} )
|
|
90
|
-
|
|
91
|
-
return prev
|
|
92
|
-
}, {} )
|
|
93
|
-
|
|
94
|
-
if ( INTERACTIVE_MODE ) {
|
|
95
|
-
const { targetEnv } = await prompt( [ {
|
|
96
|
-
type : 'autocomplete',
|
|
97
|
-
name : 'targetEnv',
|
|
98
|
-
message : 'To which environment would you like to deploy?',
|
|
99
|
-
choices : Object.values( targets ).map( ( t ) => {
|
|
100
|
-
const productionLabel = t.production ? colors.bold.red( '--PRODUCTION--' ) : ''
|
|
101
|
-
return { message : `${colors.bold.cyan( 'Site: ' )}${t.siteId.padEnd( maxSiteIdLength )} ${colors.bold.green( 'Project: ' )}${t.projectId} ${productionLabel}`, value : t.alias }
|
|
102
|
-
} )
|
|
103
|
-
} ] )
|
|
104
|
-
|
|
105
|
-
TARGET = targets[targetEnv]
|
|
106
|
-
|
|
107
|
-
if ( TARGET.production ) {
|
|
108
|
-
const { confirmProductionDeploy } = await prompt( [ {
|
|
109
|
-
type : 'confirm',
|
|
110
|
-
name : 'confirmProductionDeploy',
|
|
111
|
-
message : `${colors.bold.red( 'WARNING: ' )} This is a ${colors.bold.yellow( 'PRODUCTION' )} environment. Are you sure you want to deploy here?`
|
|
112
|
-
} ] )
|
|
113
|
-
if ( !confirmProductionDeploy ) {
|
|
114
|
-
console.log( 'Cancelling deployment...' )
|
|
115
|
-
process.exit()
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const { useChannel } = await prompt( [ {
|
|
120
|
-
type : 'confirm',
|
|
121
|
-
name : 'useChannel',
|
|
122
|
-
message : 'Do you want to deploy to a temporary preview channel?'
|
|
123
|
-
} ] )
|
|
124
|
-
|
|
125
|
-
if ( useChannel ) {
|
|
126
|
-
const { channelName, channelExpiration } = await prompt( [ {
|
|
127
|
-
type : 'input',
|
|
128
|
-
name : 'channelName',
|
|
129
|
-
message : 'To which channel would you like to deploy?',
|
|
130
|
-
initial : gitBranch ?? 'temp-deploy'
|
|
131
|
-
}, {
|
|
132
|
-
type : 'input',
|
|
133
|
-
name : 'channelExpiration',
|
|
134
|
-
message : 'When should the channel expire?',
|
|
135
|
-
initial : '7d'
|
|
136
|
-
} ] )
|
|
137
|
-
|
|
138
|
-
CHANNEL = { name : channelName, expiration : channelExpiration }
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
TARGET = targets[TARGET]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if ( !TARGET ) {
|
|
145
|
-
console.log( chalk.red( 'No such target exists in .firebaserc config.' ) )
|
|
146
|
-
process.exit()
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const [ aliasFileExists, siteIdFileExists, sharedFileExists ] = await Promise.all( [
|
|
150
|
-
fs.exists( path.join( process.cwd(), SECRETS_DIR, `${TARGET.alias}.env` ) ),
|
|
151
|
-
fs.exists( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ) ),
|
|
152
|
-
fs.exists( path.join( process.cwd(), SECRETS_DIR, 'shared.env' ) )
|
|
153
|
-
] )
|
|
154
|
-
|
|
155
|
-
if ( !aliasFileExists && !siteIdFileExists ) {
|
|
156
|
-
console.log( chalk.red( `No env file for ${TARGET.alias} exists. Check your secrets directory and try again` ) )
|
|
157
|
-
process.exit()
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const exec = []
|
|
161
|
-
|
|
162
|
-
if ( sharedFileExists ) {
|
|
163
|
-
exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, 'shared.env' ), { encoding : 'utf-8' } ) )
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if ( aliasFileExists ) {
|
|
167
|
-
exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.alias}.env` ), { encoding : 'utf-8' } ) )
|
|
168
|
-
} else {
|
|
169
|
-
exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ), { encoding : 'utf-8' } ) )
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
console.log( `\n\n\n${colors.bold.green( '====== Deployment Summary ======' )}` )
|
|
173
|
-
console.log( `${colors.blue( 'Firebase project:' )} ${TARGET.projectId} ${TARGET.production ? colors.yellow( '--PRODUCTION--' ) : ''}` )
|
|
174
|
-
console.log( `${colors.blue( 'Site ID:' )} ${TARGET.siteId}` )
|
|
175
|
-
console.log( `${colors.blue( 'Channel Name:' )} ${CHANNEL?.name ?? colors.italic.gray( '(none)' )}` )
|
|
176
|
-
console.log( `${colors.blue( 'Channel Expiration date:' )} ${CHANNEL?.name ? CHANNEL.expiration ?? colors.italic.gray( '(none)' ) : colors.italic.gray( '(n/a)' )}` )
|
|
177
|
-
console.log( `${colors.blue( 'Shared .env file:' )} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : colors.italic.gray( '(none)' )}` )
|
|
178
|
-
console.log( `${colors.blue( 'Additional .env overrides:' )} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}` )
|
|
179
|
-
console.log( `${colors.bold.green( '===============================' )}` )
|
|
180
|
-
|
|
181
|
-
if ( INTERACTIVE_MODE ) {
|
|
182
|
-
const { confirmSelections } = await prompt( [ {
|
|
183
|
-
type : 'confirm',
|
|
184
|
-
name : 'confirmSelections',
|
|
185
|
-
message : 'Proceed with this deployment?'
|
|
186
|
-
} ] )
|
|
187
|
-
|
|
188
|
-
if ( !confirmSelections ) {
|
|
189
|
-
console.log( 'Cancelling deployment...' )
|
|
190
|
-
process.exit()
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const envFileContent = ( await Promise.all( exec ) ).join( '\n' )
|
|
194
|
-
|
|
195
|
-
EXIT_EVENTS
|
|
196
|
-
.forEach( ( event ) => {
|
|
197
|
-
process.on( event, () => {
|
|
198
|
-
if ( !exited ) {
|
|
199
|
-
exited = true
|
|
200
|
-
fs.removeSync( path.join( process.cwd(), '.env.temp' ) )
|
|
201
|
-
}
|
|
202
|
-
} )
|
|
203
|
-
} )
|
|
204
|
-
|
|
205
|
-
await fs.writeFile( path.join( process.cwd(), '.env.temp' ), envFileContent )
|
|
206
|
-
|
|
207
|
-
try {
|
|
208
|
-
|
|
209
|
-
// deploying to a channel requires slightly different parameter structure
|
|
210
|
-
const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split( ' ' ) : 'deploy'
|
|
211
|
-
const hostingPrefix = CHANNEL ? '' : 'hosting:'
|
|
212
|
-
|
|
213
|
-
await $`npm run clean && DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} DEPLOYMENT_TARGET=${TARGET.siteId} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`
|
|
214
|
-
} catch ( err ) {
|
|
215
|
-
console.error( err )
|
|
216
|
-
}
|