@leverege/build-tools 2.38.0 → 2.38.2
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/leverege-build-tools-2.21.13.tgz +0 -0
- package/lib/server/firebaseDeploy.js +1 -1
- package/lib/server/firebaseServe.js +1 -1
- package/lib/server/overwhelm.js +57 -55
- package/lib/web/firebaseDeploy.js +1 -1
- package/lib/web/firebaseServe.js +1 -1
- package/lib/web/overwhelm.js +57 -55
- package/package.json +1 -1
- package/src/bash-funcs +2 -1
- package/src/firebaseDeploy.mjs +1 -1
- package/src/firebaseServe.mjs +1 -1
- package/src/overwhelm.mjs +397 -0
- package/src/circle-lib.yml +0 -150
- package/src/circle-srv.yml +0 -213
- package/src/helm-charts/geotile-server/.nohelm +0 -0
- package/src/helm-charts/geotile-server/gitignore +0 -1
- package/src/helm-charts/geotile-server/helmup.plugin +0 -6
|
Binary file
|
|
@@ -189,7 +189,7 @@ try {
|
|
|
189
189
|
// deploying to a channel requires slightly different parameter structure
|
|
190
190
|
const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split(' ') : 'deploy';
|
|
191
191
|
const hostingPrefix = CHANNEL ? '' : 'hosting:';
|
|
192
|
-
await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`;
|
|
192
|
+
await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} DEPLOYMENT_TARGET=${TARGET.siteId} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`;
|
|
193
193
|
} catch (err) {
|
|
194
194
|
console.error(err);
|
|
195
195
|
}
|
|
@@ -110,7 +110,7 @@ EXIT_EVENTS.forEach(event => {
|
|
|
110
110
|
});
|
|
111
111
|
await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
|
|
112
112
|
try {
|
|
113
|
-
await (0, _zx.$)`DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run serve --colors`;
|
|
113
|
+
await (0, _zx.$)`DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} DEPLOYMENT_TARGET=${TARGET.siteId} npm run serve --colors`;
|
|
114
114
|
} catch (err) {
|
|
115
115
|
console.error(err);
|
|
116
116
|
}
|
package/lib/server/overwhelm.js
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
|
+
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
5
6
|
"use strict";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
|
+
var _nodeChild_process = require("node:child_process");
|
|
10
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
11
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
|
+
var _commandLineArgs = _interopRequireDefault(require("command-line-args"));
|
|
13
|
+
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
14
|
+
var _glob = _interopRequireDefault(require("glob"));
|
|
15
|
+
var _parseGitignore = _interopRequireDefault(require("parse-gitignore"));
|
|
16
|
+
var _readlineSync = _interopRequireDefault(require("readline-sync"));
|
|
17
|
+
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
19
|
// const cliHelp = require( 'command-line-usage' )
|
|
13
|
-
const deepmerge = require('deepmerge');
|
|
14
|
-
const glob = require('glob');
|
|
15
|
-
const parse = require('parse-gitignore');
|
|
16
|
-
const ask = require('readline-sync');
|
|
17
|
-
const YAML = require('js-yaml');
|
|
18
20
|
const optionsDefinitions = [/* eslint-disable no-multi-spaces */
|
|
19
21
|
{
|
|
20
22
|
name: 'context',
|
|
@@ -76,20 +78,20 @@ const optionsDefinitions = [/* eslint-disable no-multi-spaces */
|
|
|
76
78
|
}
|
|
77
79
|
/* eslint-enable no-multi-spaces */];
|
|
78
80
|
|
|
79
|
-
const args =
|
|
81
|
+
const args = (0, _commandLineArgs.default)(optionsDefinitions);
|
|
80
82
|
|
|
81
83
|
// See if we are in a monorepo, which changes some of the rules.
|
|
82
|
-
const gitTop =
|
|
84
|
+
const gitTop = (0, _nodeChild_process.execSync)('git rev-parse --show-toplevel', {
|
|
83
85
|
stdio: [undefined]
|
|
84
86
|
}).toString().trim();
|
|
85
87
|
let monoTop;
|
|
86
|
-
if (
|
|
87
|
-
monoTop =
|
|
88
|
+
if (_nodeFs.default.existsSync(`${gitTop}/packages`)) {
|
|
89
|
+
monoTop = _nodePath.default.basename(_nodePath.default.resolve()); // process.env.PWD
|
|
88
90
|
console.log(`MONO=[${monoTop}]`);
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
// The kubernetes context is equal to the git branch name.
|
|
92
|
-
const gitBranch =
|
|
94
|
+
const gitBranch = (0, _nodeChild_process.execSync)('git rev-parse --abbrev-ref HEAD', {
|
|
93
95
|
stdio: [undefined]
|
|
94
96
|
}).toString().trim();
|
|
95
97
|
const context = args.context || monoTop || gitBranch;
|
|
@@ -97,8 +99,8 @@ if (context === 'master') {
|
|
|
97
99
|
console.log('***ERROR: master context is forbidden; change to a different branch\n\n');
|
|
98
100
|
process.exit(1);
|
|
99
101
|
}
|
|
100
|
-
if (!
|
|
101
|
-
console.log(
|
|
102
|
+
if (!_nodeFs.default.existsSync('overwhelm.yaml')) {
|
|
103
|
+
console.log(_chalk.default.red.bold(`
|
|
102
104
|
|
|
103
105
|
***ERROR overwhelm => missing the overwhelm.yaml file - this command expects
|
|
104
106
|
to execute from within a platform-k8s branch
|
|
@@ -119,7 +121,7 @@ if (!fs.existsSync('overwhelm.yaml')) {
|
|
|
119
121
|
// approach in order to keep us cognizant of exactly where a cluster is
|
|
120
122
|
// being formed.
|
|
121
123
|
//
|
|
122
|
-
const yaml =
|
|
124
|
+
const yaml = _jsYaml.default.load(_nodeFs.default.readFileSync('overwhelm.yaml', 'utf-8'));
|
|
123
125
|
const over = yaml.default;
|
|
124
126
|
if (process.env.OVERWHELM_DEBUG) {
|
|
125
127
|
console.log({
|
|
@@ -205,7 +207,7 @@ if (varErrors.length > 0) {
|
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
// Grab a list of the existing yaml templates.
|
|
208
|
-
const yams =
|
|
210
|
+
const yams = _glob.default.sync('values-*.yaml');
|
|
209
211
|
|
|
210
212
|
// A function to apply the replacements to all of the matching yaml which
|
|
211
213
|
// will error out if it runs into an unknown OVH<tag>.
|
|
@@ -242,13 +244,13 @@ const buildYaml = (yamls, replacements) => {
|
|
|
242
244
|
const loaded = [];
|
|
243
245
|
let allYamls = '';
|
|
244
246
|
values.forEach(yaml => {
|
|
245
|
-
if (!
|
|
247
|
+
if (!_nodeFs.default.existsSync(yaml)) {
|
|
246
248
|
console.log(`\n***ERROR: yaml file missing => ${yaml}\n`);
|
|
247
249
|
process.exit(1);
|
|
248
250
|
}
|
|
249
251
|
if (!loaded.includes(yaml)) {
|
|
250
252
|
allYamls += `\n# AHOY => ${yaml}\n\n`;
|
|
251
|
-
allYamls +=
|
|
253
|
+
allYamls += _nodeFs.default.readFileSync(yaml, {
|
|
252
254
|
encoding: 'utf-8'
|
|
253
255
|
});
|
|
254
256
|
loaded.push(yaml);
|
|
@@ -279,28 +281,28 @@ if (args.key) {
|
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
// Find all of the potential target dirs. Utilize .gitignore to ignore files
|
|
282
|
-
const gitignore =
|
|
284
|
+
const gitignore = (0, _parseGitignore.default)(_nodeFs.default.readFileSync('.gitignore'));
|
|
283
285
|
const opt = {
|
|
284
286
|
ignore: gitignore.patterns
|
|
285
287
|
};
|
|
286
|
-
const ahoy =
|
|
288
|
+
const ahoy = _glob.default.sync('*/', opt);
|
|
287
289
|
|
|
288
290
|
// .noahoy = skips generation of values.yaml but allows helmup to run
|
|
289
291
|
// .nohelm = overwhelm and helmup will skip the deployment entirely
|
|
290
292
|
ahoy.forEach(dir => {
|
|
291
|
-
if (
|
|
292
|
-
!args.fetchctx && console.log(
|
|
293
|
-
} else if (!
|
|
293
|
+
if (_nodeFs.default.existsSync(`${dir}/.noahoy`)) {
|
|
294
|
+
!args.fetchctx && console.log(_chalk.default.yellow(`***WARNING: .noahoy detected, not regenerating ${dir}values.yaml`));
|
|
295
|
+
} else if (!_nodeFs.default.existsSync(`${dir}/.nohelm`)) {
|
|
294
296
|
args.verbose && console.log(`Generating values in ${dir}`); // eslint-disable-line no-unused-expressions
|
|
295
297
|
|
|
296
298
|
let valuesOut = []; // An accumulator for all of the output values.
|
|
297
299
|
|
|
298
300
|
// Add support for localized values for things like keel (or whatever)
|
|
299
301
|
const valuesLocal = `${dir}values-local.yaml`;
|
|
300
|
-
if (
|
|
302
|
+
if (_nodeFs.default.existsSync(valuesLocal)) {
|
|
301
303
|
args.verbose && console.log(` Local values in ${valuesLocal}`); // eslint-disable-line no-unused-expressions
|
|
302
304
|
valuesOut += '\n# AHOY => values-local.yaml\n\n';
|
|
303
|
-
valuesOut +=
|
|
305
|
+
valuesOut += _nodeFs.default.readFileSync(valuesLocal, {
|
|
304
306
|
encoding: 'utf-8'
|
|
305
307
|
});
|
|
306
308
|
}
|
|
@@ -309,7 +311,7 @@ ahoy.forEach(dir => {
|
|
|
309
311
|
// Augment the default service section of the YAML with settings that
|
|
310
312
|
// usually come from the top level overwhelm.yaml file.
|
|
311
313
|
//
|
|
312
|
-
const valuesAll =
|
|
314
|
+
const valuesAll = _jsYaml.default.load(valuesOut) || {};
|
|
313
315
|
const valuesSvc = {
|
|
314
316
|
service: {
|
|
315
317
|
project_id: 'OVH:<PROJECT_ID>',
|
|
@@ -318,7 +320,7 @@ ahoy.forEach(dir => {
|
|
|
318
320
|
ingress: 'OVH:<INGRESS>'
|
|
319
321
|
}
|
|
320
322
|
};
|
|
321
|
-
const valuesMerged =
|
|
323
|
+
const valuesMerged = _jsYaml.default.dump((0, _deepmerge.default)(valuesSvc, valuesAll), {
|
|
322
324
|
quotingType: '"'
|
|
323
325
|
});
|
|
324
326
|
valuesOut = doReplacements(valuesMerged, over);
|
|
@@ -327,30 +329,30 @@ ahoy.forEach(dir => {
|
|
|
327
329
|
// If we are going to override then we need to convert it to YAML and
|
|
328
330
|
// do a deepmerge to combine the values.
|
|
329
331
|
const valuesOverride = `${dir}/values-override.yaml`;
|
|
330
|
-
if (
|
|
332
|
+
if (_nodeFs.default.existsSync(valuesOverride)) {
|
|
331
333
|
console.log(`===>Applying Overrides=> ${valuesOverride}`);
|
|
332
|
-
const overrides =
|
|
334
|
+
const overrides = _jsYaml.default.load(_nodeFs.default.readFileSync(valuesOverride, {
|
|
333
335
|
encofind: 'utf-8'
|
|
334
336
|
}));
|
|
335
|
-
const allValues =
|
|
336
|
-
valuesOut =
|
|
337
|
+
const allValues = _jsYaml.default.load(valuesOut);
|
|
338
|
+
valuesOut = _jsYaml.default.dump((0, _deepmerge.default)(allValues, overrides), {
|
|
337
339
|
quotingType: '"'
|
|
338
340
|
});
|
|
339
341
|
}
|
|
340
342
|
// DEPRECATED
|
|
341
343
|
|
|
342
|
-
|
|
344
|
+
_nodeFs.default.writeFileSync(`${dir}/values.yaml`, valuesOut);
|
|
343
345
|
}
|
|
344
346
|
});
|
|
345
347
|
|
|
346
348
|
// we can also apply replaceables to any top level .ovh files to support top level config maps
|
|
347
|
-
|
|
349
|
+
_glob.default.sync('**/*.ovh').forEach(cfgmap => {
|
|
348
350
|
const target = cfgmap.replace(/.ovh$/, '');
|
|
349
|
-
let valuesOut =
|
|
351
|
+
let valuesOut = _nodeFs.default.readFileSync(cfgmap, {
|
|
350
352
|
encoding: 'utf-8'
|
|
351
353
|
});
|
|
352
354
|
valuesOut = doReplacements(valuesOut, over);
|
|
353
|
-
|
|
355
|
+
_nodeFs.default.writeFileSync(target, valuesOut);
|
|
354
356
|
});
|
|
355
357
|
if (args.genvals) {
|
|
356
358
|
process.exit(0);
|
|
@@ -362,9 +364,9 @@ if (over.PROJECT_NAME === 'minikube') {
|
|
|
362
364
|
process.exit(0);
|
|
363
365
|
}
|
|
364
366
|
const projectId = over.PROJECT_ID;
|
|
365
|
-
|
|
367
|
+
const zone = over.GCE_REGION + (over.GCE_ZONE ? `-${over.GCE_ZONE}` : '');
|
|
366
368
|
if (!clusterName) {
|
|
367
|
-
console.log(
|
|
369
|
+
console.log(_chalk.default.yellow(`
|
|
368
370
|
|
|
369
371
|
The overwhelm.yaml file in this branch is missing a CLUSTER_NAME setting,
|
|
370
372
|
which was added to support cluster names that do not match the project
|
|
@@ -372,10 +374,10 @@ if (!clusterName) {
|
|
|
372
374
|
adding this line following PROJECT_NAME in the default section of
|
|
373
375
|
overwhelm.yaml:
|
|
374
376
|
|
|
375
|
-
${
|
|
377
|
+
${_chalk.default.bold.green('CLUSTER_NAME : \'${PROJECT_NAME}\'')}
|
|
376
378
|
|
|
377
379
|
However, if the CLUSTER_NAME is not the same as the PROJECT_NAME then go
|
|
378
|
-
ahead and add the CLUSTER_NAME setting to the ${
|
|
380
|
+
ahead and add the CLUSTER_NAME setting to the ${_chalk.default.bold.green(projectId)} section of the
|
|
379
381
|
overwhelm.yaml file.
|
|
380
382
|
|
|
381
383
|
`));
|
|
@@ -383,15 +385,15 @@ if (!clusterName) {
|
|
|
383
385
|
}
|
|
384
386
|
let kubeout = '_no_current_context_';
|
|
385
387
|
try {
|
|
386
|
-
kubeout =
|
|
388
|
+
kubeout = (0, _nodeChild_process.execSync)('kubectl config current-context', {
|
|
387
389
|
stdio: [undefined]
|
|
388
390
|
});
|
|
389
391
|
} catch (err) {
|
|
390
392
|
// err && console.log( `Caught Error =>[${err}]` )
|
|
391
393
|
}
|
|
392
394
|
const currentCtx = kubeout.toString().trim();
|
|
393
|
-
|
|
394
|
-
|
|
395
|
+
const desiredCtx = `gke_${projectId}_${zone}_${clusterName}`;
|
|
396
|
+
const cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`;
|
|
395
397
|
const matchedCtx = currentCtx === desiredCtx;
|
|
396
398
|
if (args.matchk8s) {
|
|
397
399
|
process.exit(matchedCtx ? 0 : 1);
|
|
@@ -401,7 +403,7 @@ if (args.matchk8s) {
|
|
|
401
403
|
if (args.fetchctx) {
|
|
402
404
|
if (!matchedCtx) {
|
|
403
405
|
try {
|
|
404
|
-
|
|
406
|
+
(0, _nodeChild_process.execSync)(`${cmd}`, {
|
|
405
407
|
stdio: [undefined]
|
|
406
408
|
});
|
|
407
409
|
} catch (err) {
|
|
@@ -414,30 +416,30 @@ if (args.fetchctx) {
|
|
|
414
416
|
if (matchedCtx) {
|
|
415
417
|
console.log(`
|
|
416
418
|
|
|
417
|
-
Current context matches => ${
|
|
419
|
+
Current context matches => ${_chalk.default.bold.green(currentCtx)}
|
|
418
420
|
|
|
419
421
|
`);
|
|
420
422
|
} else {
|
|
421
423
|
console.log(`
|
|
422
424
|
You are about to change your Kubernetes context to:
|
|
423
|
-
CLUSTER_NAME => ${
|
|
424
|
-
PROJECT_ID => ${
|
|
425
|
-
REGION => ${
|
|
425
|
+
CLUSTER_NAME => ${_chalk.default.bold.green(clusterName)}
|
|
426
|
+
PROJECT_ID => ${_chalk.default.bold.green(projectId)}
|
|
427
|
+
REGION => ${_chalk.default.bold.green(zone)}
|
|
426
428
|
|
|
427
429
|
`);
|
|
428
430
|
}
|
|
429
431
|
const operation = matchedCtx ? 'refetch the credentials' : 'switch your context';
|
|
430
|
-
const ans =
|
|
432
|
+
const ans = _readlineSync.default.question(`Enter "${_chalk.default.bold.green('yes')}" if you wish to ${operation} => `);
|
|
431
433
|
if (ans !== 'yes') {
|
|
432
434
|
if (matchedCtx) {
|
|
433
|
-
console.log(
|
|
435
|
+
console.log(_chalk.default.bold.yellow('\n\nSkipping a refetch of your Kubernetes context and credentials\n\n'));
|
|
434
436
|
process.exit(0);
|
|
435
437
|
}
|
|
436
|
-
console.log(
|
|
438
|
+
console.log(_chalk.default.bold.red('\n\nYour Kubernetes context and credentials do NOT match - this could be bad!\n\n'));
|
|
437
439
|
process.exit(1);
|
|
438
440
|
}
|
|
439
|
-
console.log(`\n\nExecuting: ${
|
|
440
|
-
|
|
441
|
+
console.log(`\n\nExecuting: ${_chalk.default.bold.yellow(cmd)}\n\n`);
|
|
442
|
+
(0, _nodeChild_process.execSync)(`${cmd}`, (error, out) => {
|
|
441
443
|
if (error) {
|
|
442
444
|
console.log(`\n\n***ERROR ${error}\n\n`);
|
|
443
445
|
process.exit(1);
|
|
@@ -189,7 +189,7 @@ try {
|
|
|
189
189
|
// deploying to a channel requires slightly different parameter structure
|
|
190
190
|
const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split(' ') : 'deploy';
|
|
191
191
|
const hostingPrefix = CHANNEL ? '' : 'hosting:';
|
|
192
|
-
await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`;
|
|
192
|
+
await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} DEPLOYMENT_TARGET=${TARGET.siteId} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`;
|
|
193
193
|
} catch (err) {
|
|
194
194
|
console.error(err);
|
|
195
195
|
}
|
package/lib/web/firebaseServe.js
CHANGED
|
@@ -110,7 +110,7 @@ EXIT_EVENTS.forEach(event => {
|
|
|
110
110
|
});
|
|
111
111
|
await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
|
|
112
112
|
try {
|
|
113
|
-
await (0, _zx.$)`DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run serve --colors`;
|
|
113
|
+
await (0, _zx.$)`DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} DEPLOYMENT_TARGET=${TARGET.siteId} npm run serve --colors`;
|
|
114
114
|
} catch (err) {
|
|
115
115
|
console.error(err);
|
|
116
116
|
}
|
package/lib/web/overwhelm.js
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
|
+
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
5
6
|
"use strict";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
|
+
var _nodeChild_process = require("node:child_process");
|
|
10
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
11
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
|
+
var _commandLineArgs = _interopRequireDefault(require("command-line-args"));
|
|
13
|
+
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
14
|
+
var _glob = _interopRequireDefault(require("glob"));
|
|
15
|
+
var _parseGitignore = _interopRequireDefault(require("parse-gitignore"));
|
|
16
|
+
var _readlineSync = _interopRequireDefault(require("readline-sync"));
|
|
17
|
+
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
19
|
// const cliHelp = require( 'command-line-usage' )
|
|
13
|
-
const deepmerge = require('deepmerge');
|
|
14
|
-
const glob = require('glob');
|
|
15
|
-
const parse = require('parse-gitignore');
|
|
16
|
-
const ask = require('readline-sync');
|
|
17
|
-
const YAML = require('js-yaml');
|
|
18
20
|
const optionsDefinitions = [/* eslint-disable no-multi-spaces */
|
|
19
21
|
{
|
|
20
22
|
name: 'context',
|
|
@@ -76,20 +78,20 @@ const optionsDefinitions = [/* eslint-disable no-multi-spaces */
|
|
|
76
78
|
}
|
|
77
79
|
/* eslint-enable no-multi-spaces */];
|
|
78
80
|
|
|
79
|
-
const args =
|
|
81
|
+
const args = (0, _commandLineArgs.default)(optionsDefinitions);
|
|
80
82
|
|
|
81
83
|
// See if we are in a monorepo, which changes some of the rules.
|
|
82
|
-
const gitTop =
|
|
84
|
+
const gitTop = (0, _nodeChild_process.execSync)('git rev-parse --show-toplevel', {
|
|
83
85
|
stdio: [undefined]
|
|
84
86
|
}).toString().trim();
|
|
85
87
|
let monoTop;
|
|
86
|
-
if (
|
|
87
|
-
monoTop =
|
|
88
|
+
if (_nodeFs.default.existsSync(`${gitTop}/packages`)) {
|
|
89
|
+
monoTop = _nodePath.default.basename(_nodePath.default.resolve()); // process.env.PWD
|
|
88
90
|
console.log(`MONO=[${monoTop}]`);
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
// The kubernetes context is equal to the git branch name.
|
|
92
|
-
const gitBranch =
|
|
94
|
+
const gitBranch = (0, _nodeChild_process.execSync)('git rev-parse --abbrev-ref HEAD', {
|
|
93
95
|
stdio: [undefined]
|
|
94
96
|
}).toString().trim();
|
|
95
97
|
const context = args.context || monoTop || gitBranch;
|
|
@@ -97,8 +99,8 @@ if (context === 'master') {
|
|
|
97
99
|
console.log('***ERROR: master context is forbidden; change to a different branch\n\n');
|
|
98
100
|
process.exit(1);
|
|
99
101
|
}
|
|
100
|
-
if (!
|
|
101
|
-
console.log(
|
|
102
|
+
if (!_nodeFs.default.existsSync('overwhelm.yaml')) {
|
|
103
|
+
console.log(_chalk.default.red.bold(`
|
|
102
104
|
|
|
103
105
|
***ERROR overwhelm => missing the overwhelm.yaml file - this command expects
|
|
104
106
|
to execute from within a platform-k8s branch
|
|
@@ -119,7 +121,7 @@ if (!fs.existsSync('overwhelm.yaml')) {
|
|
|
119
121
|
// approach in order to keep us cognizant of exactly where a cluster is
|
|
120
122
|
// being formed.
|
|
121
123
|
//
|
|
122
|
-
const yaml =
|
|
124
|
+
const yaml = _jsYaml.default.load(_nodeFs.default.readFileSync('overwhelm.yaml', 'utf-8'));
|
|
123
125
|
const over = yaml.default;
|
|
124
126
|
if (process.env.OVERWHELM_DEBUG) {
|
|
125
127
|
console.log({
|
|
@@ -205,7 +207,7 @@ if (varErrors.length > 0) {
|
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
// Grab a list of the existing yaml templates.
|
|
208
|
-
const yams =
|
|
210
|
+
const yams = _glob.default.sync('values-*.yaml');
|
|
209
211
|
|
|
210
212
|
// A function to apply the replacements to all of the matching yaml which
|
|
211
213
|
// will error out if it runs into an unknown OVH<tag>.
|
|
@@ -242,13 +244,13 @@ const buildYaml = (yamls, replacements) => {
|
|
|
242
244
|
const loaded = [];
|
|
243
245
|
let allYamls = '';
|
|
244
246
|
values.forEach(yaml => {
|
|
245
|
-
if (!
|
|
247
|
+
if (!_nodeFs.default.existsSync(yaml)) {
|
|
246
248
|
console.log(`\n***ERROR: yaml file missing => ${yaml}\n`);
|
|
247
249
|
process.exit(1);
|
|
248
250
|
}
|
|
249
251
|
if (!loaded.includes(yaml)) {
|
|
250
252
|
allYamls += `\n# AHOY => ${yaml}\n\n`;
|
|
251
|
-
allYamls +=
|
|
253
|
+
allYamls += _nodeFs.default.readFileSync(yaml, {
|
|
252
254
|
encoding: 'utf-8'
|
|
253
255
|
});
|
|
254
256
|
loaded.push(yaml);
|
|
@@ -279,28 +281,28 @@ if (args.key) {
|
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
// Find all of the potential target dirs. Utilize .gitignore to ignore files
|
|
282
|
-
const gitignore =
|
|
284
|
+
const gitignore = (0, _parseGitignore.default)(_nodeFs.default.readFileSync('.gitignore'));
|
|
283
285
|
const opt = {
|
|
284
286
|
ignore: gitignore.patterns
|
|
285
287
|
};
|
|
286
|
-
const ahoy =
|
|
288
|
+
const ahoy = _glob.default.sync('*/', opt);
|
|
287
289
|
|
|
288
290
|
// .noahoy = skips generation of values.yaml but allows helmup to run
|
|
289
291
|
// .nohelm = overwhelm and helmup will skip the deployment entirely
|
|
290
292
|
ahoy.forEach(dir => {
|
|
291
|
-
if (
|
|
292
|
-
!args.fetchctx && console.log(
|
|
293
|
-
} else if (!
|
|
293
|
+
if (_nodeFs.default.existsSync(`${dir}/.noahoy`)) {
|
|
294
|
+
!args.fetchctx && console.log(_chalk.default.yellow(`***WARNING: .noahoy detected, not regenerating ${dir}values.yaml`));
|
|
295
|
+
} else if (!_nodeFs.default.existsSync(`${dir}/.nohelm`)) {
|
|
294
296
|
args.verbose && console.log(`Generating values in ${dir}`); // eslint-disable-line no-unused-expressions
|
|
295
297
|
|
|
296
298
|
let valuesOut = []; // An accumulator for all of the output values.
|
|
297
299
|
|
|
298
300
|
// Add support for localized values for things like keel (or whatever)
|
|
299
301
|
const valuesLocal = `${dir}values-local.yaml`;
|
|
300
|
-
if (
|
|
302
|
+
if (_nodeFs.default.existsSync(valuesLocal)) {
|
|
301
303
|
args.verbose && console.log(` Local values in ${valuesLocal}`); // eslint-disable-line no-unused-expressions
|
|
302
304
|
valuesOut += '\n# AHOY => values-local.yaml\n\n';
|
|
303
|
-
valuesOut +=
|
|
305
|
+
valuesOut += _nodeFs.default.readFileSync(valuesLocal, {
|
|
304
306
|
encoding: 'utf-8'
|
|
305
307
|
});
|
|
306
308
|
}
|
|
@@ -309,7 +311,7 @@ ahoy.forEach(dir => {
|
|
|
309
311
|
// Augment the default service section of the YAML with settings that
|
|
310
312
|
// usually come from the top level overwhelm.yaml file.
|
|
311
313
|
//
|
|
312
|
-
const valuesAll =
|
|
314
|
+
const valuesAll = _jsYaml.default.load(valuesOut) || {};
|
|
313
315
|
const valuesSvc = {
|
|
314
316
|
service: {
|
|
315
317
|
project_id: 'OVH:<PROJECT_ID>',
|
|
@@ -318,7 +320,7 @@ ahoy.forEach(dir => {
|
|
|
318
320
|
ingress: 'OVH:<INGRESS>'
|
|
319
321
|
}
|
|
320
322
|
};
|
|
321
|
-
const valuesMerged =
|
|
323
|
+
const valuesMerged = _jsYaml.default.dump((0, _deepmerge.default)(valuesSvc, valuesAll), {
|
|
322
324
|
quotingType: '"'
|
|
323
325
|
});
|
|
324
326
|
valuesOut = doReplacements(valuesMerged, over);
|
|
@@ -327,30 +329,30 @@ ahoy.forEach(dir => {
|
|
|
327
329
|
// If we are going to override then we need to convert it to YAML and
|
|
328
330
|
// do a deepmerge to combine the values.
|
|
329
331
|
const valuesOverride = `${dir}/values-override.yaml`;
|
|
330
|
-
if (
|
|
332
|
+
if (_nodeFs.default.existsSync(valuesOverride)) {
|
|
331
333
|
console.log(`===>Applying Overrides=> ${valuesOverride}`);
|
|
332
|
-
const overrides =
|
|
334
|
+
const overrides = _jsYaml.default.load(_nodeFs.default.readFileSync(valuesOverride, {
|
|
333
335
|
encofind: 'utf-8'
|
|
334
336
|
}));
|
|
335
|
-
const allValues =
|
|
336
|
-
valuesOut =
|
|
337
|
+
const allValues = _jsYaml.default.load(valuesOut);
|
|
338
|
+
valuesOut = _jsYaml.default.dump((0, _deepmerge.default)(allValues, overrides), {
|
|
337
339
|
quotingType: '"'
|
|
338
340
|
});
|
|
339
341
|
}
|
|
340
342
|
// DEPRECATED
|
|
341
343
|
|
|
342
|
-
|
|
344
|
+
_nodeFs.default.writeFileSync(`${dir}/values.yaml`, valuesOut);
|
|
343
345
|
}
|
|
344
346
|
});
|
|
345
347
|
|
|
346
348
|
// we can also apply replaceables to any top level .ovh files to support top level config maps
|
|
347
|
-
|
|
349
|
+
_glob.default.sync('**/*.ovh').forEach(cfgmap => {
|
|
348
350
|
const target = cfgmap.replace(/.ovh$/, '');
|
|
349
|
-
let valuesOut =
|
|
351
|
+
let valuesOut = _nodeFs.default.readFileSync(cfgmap, {
|
|
350
352
|
encoding: 'utf-8'
|
|
351
353
|
});
|
|
352
354
|
valuesOut = doReplacements(valuesOut, over);
|
|
353
|
-
|
|
355
|
+
_nodeFs.default.writeFileSync(target, valuesOut);
|
|
354
356
|
});
|
|
355
357
|
if (args.genvals) {
|
|
356
358
|
process.exit(0);
|
|
@@ -362,9 +364,9 @@ if (over.PROJECT_NAME === 'minikube') {
|
|
|
362
364
|
process.exit(0);
|
|
363
365
|
}
|
|
364
366
|
const projectId = over.PROJECT_ID;
|
|
365
|
-
|
|
367
|
+
const zone = over.GCE_REGION + (over.GCE_ZONE ? `-${over.GCE_ZONE}` : '');
|
|
366
368
|
if (!clusterName) {
|
|
367
|
-
console.log(
|
|
369
|
+
console.log(_chalk.default.yellow(`
|
|
368
370
|
|
|
369
371
|
The overwhelm.yaml file in this branch is missing a CLUSTER_NAME setting,
|
|
370
372
|
which was added to support cluster names that do not match the project
|
|
@@ -372,10 +374,10 @@ if (!clusterName) {
|
|
|
372
374
|
adding this line following PROJECT_NAME in the default section of
|
|
373
375
|
overwhelm.yaml:
|
|
374
376
|
|
|
375
|
-
${
|
|
377
|
+
${_chalk.default.bold.green('CLUSTER_NAME : \'${PROJECT_NAME}\'')}
|
|
376
378
|
|
|
377
379
|
However, if the CLUSTER_NAME is not the same as the PROJECT_NAME then go
|
|
378
|
-
ahead and add the CLUSTER_NAME setting to the ${
|
|
380
|
+
ahead and add the CLUSTER_NAME setting to the ${_chalk.default.bold.green(projectId)} section of the
|
|
379
381
|
overwhelm.yaml file.
|
|
380
382
|
|
|
381
383
|
`));
|
|
@@ -383,15 +385,15 @@ if (!clusterName) {
|
|
|
383
385
|
}
|
|
384
386
|
let kubeout = '_no_current_context_';
|
|
385
387
|
try {
|
|
386
|
-
kubeout =
|
|
388
|
+
kubeout = (0, _nodeChild_process.execSync)('kubectl config current-context', {
|
|
387
389
|
stdio: [undefined]
|
|
388
390
|
});
|
|
389
391
|
} catch (err) {
|
|
390
392
|
// err && console.log( `Caught Error =>[${err}]` )
|
|
391
393
|
}
|
|
392
394
|
const currentCtx = kubeout.toString().trim();
|
|
393
|
-
|
|
394
|
-
|
|
395
|
+
const desiredCtx = `gke_${projectId}_${zone}_${clusterName}`;
|
|
396
|
+
const cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`;
|
|
395
397
|
const matchedCtx = currentCtx === desiredCtx;
|
|
396
398
|
if (args.matchk8s) {
|
|
397
399
|
process.exit(matchedCtx ? 0 : 1);
|
|
@@ -401,7 +403,7 @@ if (args.matchk8s) {
|
|
|
401
403
|
if (args.fetchctx) {
|
|
402
404
|
if (!matchedCtx) {
|
|
403
405
|
try {
|
|
404
|
-
|
|
406
|
+
(0, _nodeChild_process.execSync)(`${cmd}`, {
|
|
405
407
|
stdio: [undefined]
|
|
406
408
|
});
|
|
407
409
|
} catch (err) {
|
|
@@ -414,30 +416,30 @@ if (args.fetchctx) {
|
|
|
414
416
|
if (matchedCtx) {
|
|
415
417
|
console.log(`
|
|
416
418
|
|
|
417
|
-
Current context matches => ${
|
|
419
|
+
Current context matches => ${_chalk.default.bold.green(currentCtx)}
|
|
418
420
|
|
|
419
421
|
`);
|
|
420
422
|
} else {
|
|
421
423
|
console.log(`
|
|
422
424
|
You are about to change your Kubernetes context to:
|
|
423
|
-
CLUSTER_NAME => ${
|
|
424
|
-
PROJECT_ID => ${
|
|
425
|
-
REGION => ${
|
|
425
|
+
CLUSTER_NAME => ${_chalk.default.bold.green(clusterName)}
|
|
426
|
+
PROJECT_ID => ${_chalk.default.bold.green(projectId)}
|
|
427
|
+
REGION => ${_chalk.default.bold.green(zone)}
|
|
426
428
|
|
|
427
429
|
`);
|
|
428
430
|
}
|
|
429
431
|
const operation = matchedCtx ? 'refetch the credentials' : 'switch your context';
|
|
430
|
-
const ans =
|
|
432
|
+
const ans = _readlineSync.default.question(`Enter "${_chalk.default.bold.green('yes')}" if you wish to ${operation} => `);
|
|
431
433
|
if (ans !== 'yes') {
|
|
432
434
|
if (matchedCtx) {
|
|
433
|
-
console.log(
|
|
435
|
+
console.log(_chalk.default.bold.yellow('\n\nSkipping a refetch of your Kubernetes context and credentials\n\n'));
|
|
434
436
|
process.exit(0);
|
|
435
437
|
}
|
|
436
|
-
console.log(
|
|
438
|
+
console.log(_chalk.default.bold.red('\n\nYour Kubernetes context and credentials do NOT match - this could be bad!\n\n'));
|
|
437
439
|
process.exit(1);
|
|
438
440
|
}
|
|
439
|
-
console.log(`\n\nExecuting: ${
|
|
440
|
-
|
|
441
|
+
console.log(`\n\nExecuting: ${_chalk.default.bold.yellow(cmd)}\n\n`);
|
|
442
|
+
(0, _nodeChild_process.execSync)(`${cmd}`, (error, out) => {
|
|
441
443
|
if (error) {
|
|
442
444
|
console.log(`\n\n***ERROR ${error}\n\n`);
|
|
443
445
|
process.exit(1);
|
package/package.json
CHANGED
package/src/bash-funcs
CHANGED
|
@@ -145,7 +145,8 @@ function postToSlack() {
|
|
|
145
145
|
local dts="`date +\"%c\"`"
|
|
146
146
|
local slackURL="https://hooks.slack.com/services/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"
|
|
147
147
|
local channel="#dev-ops-helm"
|
|
148
|
-
local
|
|
148
|
+
local account="`gcloud config get account`"
|
|
149
|
+
local slackmsg="\n--- $running by \`$account\` in \`$GCP_PROJECT_ID\` @ $dts\n \`$toPost\`\n node `node --version` / `build-tools --version` / helm `helm version --short`\n"
|
|
149
150
|
|
|
150
151
|
curl -X POST -H 'Content-type: application/json' \
|
|
151
152
|
--data "{\"text\":\"$slackmsg\",\"channel\":\"$channel\"}" \
|
package/src/firebaseDeploy.mjs
CHANGED
|
@@ -209,7 +209,7 @@ try {
|
|
|
209
209
|
const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split( ' ' ) : 'deploy'
|
|
210
210
|
const hostingPrefix = CHANNEL ? '' : 'hosting:'
|
|
211
211
|
|
|
212
|
-
await $`npm run clean && DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`
|
|
212
|
+
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}`
|
|
213
213
|
} catch ( err ) {
|
|
214
214
|
console.error( err )
|
|
215
215
|
}
|
package/src/firebaseServe.mjs
CHANGED
|
@@ -138,7 +138,7 @@ EXIT_EVENTS
|
|
|
138
138
|
await fs.writeFile( path.join( process.cwd(), '.env.temp' ), envFileContent )
|
|
139
139
|
|
|
140
140
|
try {
|
|
141
|
-
await $`DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} npm run serve --colors`
|
|
141
|
+
await $`DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} DEPLOYMENT_TARGET=${TARGET.siteId} npm run serve --colors`
|
|
142
142
|
} catch ( err ) {
|
|
143
143
|
console.error( err )
|
|
144
144
|
}
|