@leverege/build-tools 2.8.12 → 2.8.13
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/server/repo-init/config.tgz +0 -0
- package/package.json +5 -1
- package/src/anchor +41 -0
- package/src/dockreate +1 -1
- package/lib/server/service-man/Config.js +0 -45
- package/lib/server/service-man/ServiceMan.js +0 -42
- package/lib/server/service-man/index.js +0 -6
- package/lib/server/service-man/utils/Shell.js +0 -102
- package/lib/server/service-man/utils/VersionCheck.js +0 -82
- package/lib/server/service-man/utils/index.js +0 -67
- package/lib/web/service-man/Config.js +0 -45
- package/lib/web/service-man/ServiceMan.js +0 -42
- package/lib/web/service-man/index.js +0 -6
- package/lib/web/service-man/utils/Shell.js +0 -102
- package/lib/web/service-man/utils/VersionCheck.js +0 -82
- package/lib/web/service-man/utils/index.js +0 -67
- package/src/helm-starters/baseline/Chart.yaml +0 -4
- package/src/helm-starters/baseline/templates/NOTES.txt +0 -52
- package/src/helm-starters/baseline/templates/configmap.yaml +0 -6
- package/src/helm-starters/baseline/templates/deployment.yaml +0 -97
- package/src/helm-starters/baseline/templates/hpa.yaml +0 -12
- package/src/helm-starters/baseline/templates/ingress.yaml +0 -17
- package/src/helm-starters/baseline/templates/pdb.yaml +0 -9
- package/src/helm-starters/baseline/templates/service.yaml +0 -16
- package/src/helm-starters/baseline/templates/serviceaccount.yaml +0 -10
- package/src/helm-starters/baseline/values.yaml +0 -57
- package/src/helm-starters/deprecated/Chart.yaml +0 -4
- package/src/helm-starters/deprecated/templates/NOTES.txt +0 -52
- package/src/helm-starters/deprecated/templates/configmap.yaml +0 -11
- package/src/helm-starters/deprecated/templates/deployment.yaml +0 -103
- package/src/helm-starters/deprecated/templates/hpa.yaml +0 -12
- package/src/helm-starters/deprecated/templates/ingress.yaml +0 -17
- package/src/helm-starters/deprecated/templates/pdb.yaml +0 -9
- package/src/helm-starters/deprecated/templates/service.yaml +0 -13
- package/src/helm-starters/deprecated/templates/serviceaccount.yaml +0 -10
- package/src/helm-starters/deprecated/values.yaml +0 -44
- package/src/sa-tools/imp-sa +0 -26
- package/src/sa-tools/roles/baseline/leveregeBigQueryReader.json +0 -10
- package/src/sa-tools/roles/baseline/leveregeBigQueryWriter.json +0 -10
- package/src/sa-tools/roles/baseline/leveregeCloudFunctionsAdmin.json +0 -12
- package/src/sa-tools/roles/baseline/leveregeFirebaseUpdates.json +0 -8
- package/src/sa-tools/roles/baseline/leveregeLogsViewer.json +0 -8
- package/src/sa-tools/roles/baseline/leveregePubSub.json +0 -13
- package/src/sa-tools/roles/baseline/leveregeSecretsViewer.json +0 -8
- package/src/sa-tools/roles/baseline/leveregeStorageObjectAccess.json +0 -10
- package/src/sa-tools/roles/baseline/leveregeSvcAcctActor.json +0 -8
- package/src/sa-tools/roles/baseline/leveregeSvcAcctTokenCreator.json +0 -8
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeBigQueryReader.json +0 -10
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeBigQueryWriter.json +0 -10
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeCloudFunctionsAdmin.json +0 -12
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeFirebaseUpdates.json +0 -8
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeLogsViewer.json +0 -8
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregePubSub.json +0 -13
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeSecretsViewer.json +0 -8
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeStorageObjectAccess.json +0 -10
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeSvcAcctActor.json +0 -8
- package/src/sa-tools/roles/leverege-dev-john/20220113-121423/leveregeSvcAcctTokenCreator.json +0 -8
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeBigQueryReader.json +0 -10
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeBigQueryWriter.json +0 -10
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeCloudFunctionsAdmin.json +0 -12
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeFirebaseUpdates.json +0 -8
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeLogsViewer.json +0 -8
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregePubSub.json +0 -13
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeSecretsViewer.json +0 -8
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeStorageObjectAccess.json +0 -10
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeSvcAcctActor.json +0 -8
- package/src/sa-tools/roles/prd-indoor-zoning/20220113-121935/leveregeSvcAcctTokenCreator.json +0 -8
- package/src/sa-tools/roles-grab +0 -30
- package/src/sa-tools/roles-push +0 -19
- package/src/sa-tools/sh-make-sa +0 -58
- package/src/service-man/Config.js +0 -40
- package/src/service-man/ServiceMan.js +0 -32
- package/src/service-man/index.js +0 -5
- package/src/service-man/utils/Shell.js +0 -95
- package/src/service-man/utils/VersionCheck.js +0 -77
- package/src/service-man/utils/index.js +0 -54
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.13",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+ssh://git@bitbucket.org/leverege/build-tools.git"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
11
|
"build": "npm run compile",
|
|
8
12
|
"clean": "rm -rf lib",
|
package/src/anchor
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Load the standard helper functions
|
|
4
|
+
. `build-tools --bashfun`
|
|
5
|
+
|
|
6
|
+
if [ -z "$1" ] || [ -z "$2" ];
|
|
7
|
+
then
|
|
8
|
+
cat<<USAGE
|
|
9
|
+
|
|
10
|
+
$(color g "Usage: anchor <service name> <chart version>\n")
|
|
11
|
+
|
|
12
|
+
USAGE
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
SERVICE=$1
|
|
17
|
+
VERSION=$2
|
|
18
|
+
ANCHOR="${SERVICE}/Chart-${VERSION}"
|
|
19
|
+
|
|
20
|
+
if compgen -G "${SERVICE}/Chart-*" > /dev/null ;
|
|
21
|
+
then
|
|
22
|
+
cat<<ALREADY_ANCHORED
|
|
23
|
+
|
|
24
|
+
$(color r "$SERVICE is already anchored")
|
|
25
|
+
$(color y "Go remove the existing anchor from ${SERVICE} and try again")
|
|
26
|
+
|
|
27
|
+
`/bin/ls ${SERVICE}/Chart*`
|
|
28
|
+
|
|
29
|
+
ALREADY_ANCHORED
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
printf "Locking $SERVICE chart version at $VERSION\n"
|
|
34
|
+
touch ${ANCHOR}
|
|
35
|
+
|
|
36
|
+
if [ -f "${ANCHOR}" ];
|
|
37
|
+
then
|
|
38
|
+
printf "Service locked with creation of ${ANCHOR}\n"
|
|
39
|
+
else
|
|
40
|
+
printf "***ERROR: failed to create anchor ${ANCHOR}\n"
|
|
41
|
+
fi
|
package/src/dockreate
CHANGED
|
@@ -78,7 +78,7 @@ RUN apk --no-cache add openssh-client && \
|
|
|
78
78
|
apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
|
|
79
79
|
libstdc++ linux-headers make ${apkadds} && \
|
|
80
80
|
npm install -g npm@8 && \
|
|
81
|
-
npm ci --only
|
|
81
|
+
npm ci --only=production --ignore-scripts ${npmlogging} && \
|
|
82
82
|
rm -f /usr/src/app/.npmrc /root/.ssh/*
|
|
83
83
|
|
|
84
84
|
# --------------------------------------------------------------
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
|
|
7
|
-
class Config {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.configDir = `${__dirname}/config`;
|
|
10
|
-
const jsonText = fs.readFileSync(`${this.configDir}/config.json`);
|
|
11
|
-
this.config = JSON.parse(jsonText);
|
|
12
|
-
this.verifyConfig(this.config);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
verifyConfig(config) {
|
|
16
|
-
/**
|
|
17
|
-
* Verify reference sources exist.
|
|
18
|
-
*/
|
|
19
|
-
let errors;
|
|
20
|
-
config.templates.forEach(template => {
|
|
21
|
-
if (!template.enabled) return;
|
|
22
|
-
template.sources.forEach(source => {
|
|
23
|
-
if (typeof source === 'object') {
|
|
24
|
-
console.log(source, 'STILL TODO');
|
|
25
|
-
} else {
|
|
26
|
-
const fullName = `${this.configDir}/${source}`;
|
|
27
|
-
|
|
28
|
-
if (!fs.existsSync(fullName)) {
|
|
29
|
-
console.log(chalk.red(`***ERROR: missing source ${fullName}`));
|
|
30
|
-
errors = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (errors) {
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
Config
|
|
45
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
const cliArgs = require('command-line-args');
|
|
6
|
-
|
|
7
|
-
const cliHelp = require('command-line-usage');
|
|
8
|
-
|
|
9
|
-
const execa = require('execa');
|
|
10
|
-
|
|
11
|
-
const figlet = require('figlet');
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
Config
|
|
15
|
-
} = require('./Config');
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
clear,
|
|
19
|
-
condir,
|
|
20
|
-
proceed,
|
|
21
|
-
Shell,
|
|
22
|
-
VersionCheck
|
|
23
|
-
} = require('./utils');
|
|
24
|
-
|
|
25
|
-
const greet = async () => {
|
|
26
|
-
clear();
|
|
27
|
-
console.log(chalk.keyword('orange').bold(figlet.textSync('service-man', {
|
|
28
|
-
horizontalLayout: 'full'
|
|
29
|
-
})), chalk.green`
|
|
30
|
-
|
|
31
|
-
This utility attempts to ease the pain of managing IAM roles and the
|
|
32
|
-
creation of service accounts for new clusters and services.
|
|
33
|
-
`);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const start = async () => {
|
|
37
|
-
await greet();
|
|
38
|
-
await proceed();
|
|
39
|
-
console.log('Weeeeee....');
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.start = start;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Shell like things can go in here. I mostly created this to make it
|
|
5
|
-
* easier to push and pop around the directory trees for repo-init. It
|
|
6
|
-
* might make sense to add other things in here to make writing node CLI
|
|
7
|
-
* commands a little less painful.
|
|
8
|
-
*/
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
const process = require('process');
|
|
12
|
-
|
|
13
|
-
const dirStack = [];
|
|
14
|
-
/**
|
|
15
|
-
* Simple wrapper functions for debugging.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const cwd = () => {
|
|
19
|
-
return process.cwd();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const chdir = dir => {
|
|
23
|
-
return process.chdir(dir);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const dirs = () => {
|
|
27
|
-
console.log(dirStack);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const pushd = dir => {
|
|
31
|
-
if (!dir) {
|
|
32
|
-
throw new Error('pushd: no other directory');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
dirStack.push(cwd());
|
|
36
|
-
chdir(dir);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const throwIfEmptyStack = () => {
|
|
40
|
-
if (dirStack.length === 0) {
|
|
41
|
-
throw new Error('popd: directory stack empty');
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const popd = all => {
|
|
46
|
-
throwIfEmptyStack();
|
|
47
|
-
chdir(dirStack.pop());
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const popdAll = () => {
|
|
51
|
-
throwIfEmptyStack();
|
|
52
|
-
chdir(dirStack[0]);
|
|
53
|
-
dirStack.length = 0;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* This function will do an upwards traversal of a file tree looking for the
|
|
57
|
-
* specified file. An error will be thrown if the file is not found within
|
|
58
|
-
* maxLevels.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const reverseFindFile = (findFile, options) => {
|
|
63
|
-
pushd(options.startDir || cwd());
|
|
64
|
-
let maxLevels = options.maxLevels || 5;
|
|
65
|
-
let fileRoot;
|
|
66
|
-
|
|
67
|
-
while (maxLevels > 0) {
|
|
68
|
-
if (fs.existsSync(findFile)) {
|
|
69
|
-
fileRoot = cwd();
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
pushd('..'); // walk up the tree
|
|
74
|
-
|
|
75
|
-
maxLevels -= 1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
popdAll();
|
|
79
|
-
|
|
80
|
-
if (!fileRoot) {
|
|
81
|
-
throw new Error(`reverseFindFile: ${findFile} not found`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return fileRoot;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const findRepoRoot = () => {
|
|
88
|
-
return reverseFindFile('package.json', {
|
|
89
|
-
startDir: __dirname
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
module.exports = {
|
|
94
|
-
dirs,
|
|
95
|
-
pushd,
|
|
96
|
-
popd,
|
|
97
|
-
popdAll,
|
|
98
|
-
reverseFindFile,
|
|
99
|
-
findRepoRoot,
|
|
100
|
-
cwd,
|
|
101
|
-
chdir
|
|
102
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
const coerce = require('semver/functions/coerce');
|
|
6
|
-
|
|
7
|
-
const semverLt = require('semver/functions/lt');
|
|
8
|
-
|
|
9
|
-
const satisfies = require('semver/functions/satisfies');
|
|
10
|
-
/**
|
|
11
|
-
* This function verifies the specified version falls in this range:
|
|
12
|
-
*
|
|
13
|
-
* minimum >= current < maximum
|
|
14
|
-
*
|
|
15
|
-
* The params will be semver coerced where a version of 12 will be coerced
|
|
16
|
-
* to 12.0.0, a version of 12.18.4-beta.3 will be coerced to 12.18.4.
|
|
17
|
-
*
|
|
18
|
-
* Note that this function still has its references to node, but could be
|
|
19
|
-
* made entirely generic if need be.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} params
|
|
22
|
-
* @param {String} params.current - version to check
|
|
23
|
-
* @param {String} params.minimum - can be equal or greater to this
|
|
24
|
-
* @param {String} params.maximum - must be less than this
|
|
25
|
-
* @param {String} params.preferred - the most acceptable version
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function validate(params = {}) {
|
|
30
|
-
const throwChalk = error => {
|
|
31
|
-
const errorStr = chalk.red.bold('***ERROR =>');
|
|
32
|
-
throw new Error(chalk.keyword('orange').bold(`\n${errorStr} ${error}`));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
if (!params || !params.current || !params.minimum || !params.maximum) {
|
|
36
|
-
throwChalk('current, minimum and maximum parameters are required by validate');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const coercedVersions = sems => {
|
|
40
|
-
return Object.keys(sems).reduce((obj, key) => {
|
|
41
|
-
const coerced = obj; // avoid eslint warning
|
|
42
|
-
|
|
43
|
-
coerced[key] = coerce(sems[key]).version;
|
|
44
|
-
return coerced;
|
|
45
|
-
}, {});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const {
|
|
49
|
-
current,
|
|
50
|
-
minimum,
|
|
51
|
-
maximum,
|
|
52
|
-
preferred
|
|
53
|
-
} = coercedVersions(params);
|
|
54
|
-
/**
|
|
55
|
-
* Verify that the current version falls within the accepted ranges.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
const rangeStr = `>=${minimum} <${maximum}`;
|
|
59
|
-
|
|
60
|
-
if (!satisfies(current, rangeStr)) {
|
|
61
|
-
throwChalk(`Version ${current} is outside the accepted range of ${rangeStr}`);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Suggest upgrading to the currently recommended version.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (preferred && semverLt(current, preferred)) {
|
|
69
|
-
console.log(chalk.keyword('orange').bold(`
|
|
70
|
-
${chalk.yellow.bold(' *** HEADS UP ***')}
|
|
71
|
-
Running node version => ${chalk.yellow.bold(`v${current}`)} (which should work)
|
|
72
|
-
Preferred version is => ${chalk.green.bold(`v${preferred}`)}
|
|
73
|
-
|
|
74
|
-
Also, a reinstall of the build-tools may be necessary after any node upgrade
|
|
75
|
-
${chalk.cyan.bold('npm i -g @leverege/build-tools')}
|
|
76
|
-
`));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = {
|
|
81
|
-
validate
|
|
82
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const inquirer = require('inquirer');
|
|
4
|
-
|
|
5
|
-
const Shell = require('./Shell');
|
|
6
|
-
|
|
7
|
-
const VersionCheck = require('./VersionCheck');
|
|
8
|
-
/**
|
|
9
|
-
* Clears the screen and optionally homes the cursor.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const clear = (home = true) => {
|
|
14
|
-
// console.log( ( home ? '\x1B[0f' : '' ) + '\x1B[2J' )
|
|
15
|
-
console.log(`${home ? '\x1B[0f' : ''}\x1B[2J`);
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A simple object dumping convenience.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const condir = (log, thing) => {
|
|
23
|
-
console.dir({
|
|
24
|
-
log,
|
|
25
|
-
thing
|
|
26
|
-
}, {
|
|
27
|
-
depth: 8,
|
|
28
|
-
colors: true
|
|
29
|
-
}); // eslint-disable-line
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* General "yes" to proceed function.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const proceed = async (query = 'Do you wish to proceed?') => {
|
|
37
|
-
await inquirer.prompt([{
|
|
38
|
-
type: 'confirm',
|
|
39
|
-
name: 'proceed',
|
|
40
|
-
message: query,
|
|
41
|
-
default: true
|
|
42
|
-
}]).then(answer => {
|
|
43
|
-
if (!answer.proceed) {
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* A simple mS sleeper.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const sleep = (ms = 0) => {
|
|
54
|
-
return new Promise(resolve => {
|
|
55
|
-
setTimeout(resolve, ms);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
module.exports = {
|
|
60
|
-
clear,
|
|
61
|
-
condir,
|
|
62
|
-
proceed,
|
|
63
|
-
sleep,
|
|
64
|
-
pause: sleep,
|
|
65
|
-
Shell,
|
|
66
|
-
VersionCheck
|
|
67
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
|
|
7
|
-
class Config {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.configDir = `${__dirname}/config`;
|
|
10
|
-
const jsonText = fs.readFileSync(`${this.configDir}/config.json`);
|
|
11
|
-
this.config = JSON.parse(jsonText);
|
|
12
|
-
this.verifyConfig(this.config);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
verifyConfig(config) {
|
|
16
|
-
/**
|
|
17
|
-
* Verify reference sources exist.
|
|
18
|
-
*/
|
|
19
|
-
let errors;
|
|
20
|
-
config.templates.forEach(template => {
|
|
21
|
-
if (!template.enabled) return;
|
|
22
|
-
template.sources.forEach(source => {
|
|
23
|
-
if (typeof source === 'object') {
|
|
24
|
-
console.log(source, 'STILL TODO');
|
|
25
|
-
} else {
|
|
26
|
-
const fullName = `${this.configDir}/${source}`;
|
|
27
|
-
|
|
28
|
-
if (!fs.existsSync(fullName)) {
|
|
29
|
-
console.log(chalk.red(`***ERROR: missing source ${fullName}`));
|
|
30
|
-
errors = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (errors) {
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
Config
|
|
45
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
const cliArgs = require('command-line-args');
|
|
6
|
-
|
|
7
|
-
const cliHelp = require('command-line-usage');
|
|
8
|
-
|
|
9
|
-
const execa = require('execa');
|
|
10
|
-
|
|
11
|
-
const figlet = require('figlet');
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
Config
|
|
15
|
-
} = require('./Config');
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
clear,
|
|
19
|
-
condir,
|
|
20
|
-
proceed,
|
|
21
|
-
Shell,
|
|
22
|
-
VersionCheck
|
|
23
|
-
} = require('./utils');
|
|
24
|
-
|
|
25
|
-
const greet = async () => {
|
|
26
|
-
clear();
|
|
27
|
-
console.log(chalk.keyword('orange').bold(figlet.textSync('service-man', {
|
|
28
|
-
horizontalLayout: 'full'
|
|
29
|
-
})), chalk.green`
|
|
30
|
-
|
|
31
|
-
This utility attempts to ease the pain of managing IAM roles and the
|
|
32
|
-
creation of service accounts for new clusters and services.
|
|
33
|
-
`);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const start = async () => {
|
|
37
|
-
await greet();
|
|
38
|
-
await proceed();
|
|
39
|
-
console.log('Weeeeee....');
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.start = start;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Shell like things can go in here. I mostly created this to make it
|
|
5
|
-
* easier to push and pop around the directory trees for repo-init. It
|
|
6
|
-
* might make sense to add other things in here to make writing node CLI
|
|
7
|
-
* commands a little less painful.
|
|
8
|
-
*/
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
const process = require('process');
|
|
12
|
-
|
|
13
|
-
const dirStack = [];
|
|
14
|
-
/**
|
|
15
|
-
* Simple wrapper functions for debugging.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const cwd = () => {
|
|
19
|
-
return process.cwd();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const chdir = dir => {
|
|
23
|
-
return process.chdir(dir);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const dirs = () => {
|
|
27
|
-
console.log(dirStack);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const pushd = dir => {
|
|
31
|
-
if (!dir) {
|
|
32
|
-
throw new Error('pushd: no other directory');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
dirStack.push(cwd());
|
|
36
|
-
chdir(dir);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const throwIfEmptyStack = () => {
|
|
40
|
-
if (dirStack.length === 0) {
|
|
41
|
-
throw new Error('popd: directory stack empty');
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const popd = all => {
|
|
46
|
-
throwIfEmptyStack();
|
|
47
|
-
chdir(dirStack.pop());
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const popdAll = () => {
|
|
51
|
-
throwIfEmptyStack();
|
|
52
|
-
chdir(dirStack[0]);
|
|
53
|
-
dirStack.length = 0;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* This function will do an upwards traversal of a file tree looking for the
|
|
57
|
-
* specified file. An error will be thrown if the file is not found within
|
|
58
|
-
* maxLevels.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const reverseFindFile = (findFile, options) => {
|
|
63
|
-
pushd(options.startDir || cwd());
|
|
64
|
-
let maxLevels = options.maxLevels || 5;
|
|
65
|
-
let fileRoot;
|
|
66
|
-
|
|
67
|
-
while (maxLevels > 0) {
|
|
68
|
-
if (fs.existsSync(findFile)) {
|
|
69
|
-
fileRoot = cwd();
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
pushd('..'); // walk up the tree
|
|
74
|
-
|
|
75
|
-
maxLevels -= 1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
popdAll();
|
|
79
|
-
|
|
80
|
-
if (!fileRoot) {
|
|
81
|
-
throw new Error(`reverseFindFile: ${findFile} not found`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return fileRoot;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const findRepoRoot = () => {
|
|
88
|
-
return reverseFindFile('package.json', {
|
|
89
|
-
startDir: __dirname
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
module.exports = {
|
|
94
|
-
dirs,
|
|
95
|
-
pushd,
|
|
96
|
-
popd,
|
|
97
|
-
popdAll,
|
|
98
|
-
reverseFindFile,
|
|
99
|
-
findRepoRoot,
|
|
100
|
-
cwd,
|
|
101
|
-
chdir
|
|
102
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
const coerce = require('semver/functions/coerce');
|
|
6
|
-
|
|
7
|
-
const semverLt = require('semver/functions/lt');
|
|
8
|
-
|
|
9
|
-
const satisfies = require('semver/functions/satisfies');
|
|
10
|
-
/**
|
|
11
|
-
* This function verifies the specified version falls in this range:
|
|
12
|
-
*
|
|
13
|
-
* minimum >= current < maximum
|
|
14
|
-
*
|
|
15
|
-
* The params will be semver coerced where a version of 12 will be coerced
|
|
16
|
-
* to 12.0.0, a version of 12.18.4-beta.3 will be coerced to 12.18.4.
|
|
17
|
-
*
|
|
18
|
-
* Note that this function still has its references to node, but could be
|
|
19
|
-
* made entirely generic if need be.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} params
|
|
22
|
-
* @param {String} params.current - version to check
|
|
23
|
-
* @param {String} params.minimum - can be equal or greater to this
|
|
24
|
-
* @param {String} params.maximum - must be less than this
|
|
25
|
-
* @param {String} params.preferred - the most acceptable version
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function validate(params = {}) {
|
|
30
|
-
const throwChalk = error => {
|
|
31
|
-
const errorStr = chalk.red.bold('***ERROR =>');
|
|
32
|
-
throw new Error(chalk.keyword('orange').bold(`\n${errorStr} ${error}`));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
if (!params || !params.current || !params.minimum || !params.maximum) {
|
|
36
|
-
throwChalk('current, minimum and maximum parameters are required by validate');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const coercedVersions = sems => {
|
|
40
|
-
return Object.keys(sems).reduce((obj, key) => {
|
|
41
|
-
const coerced = obj; // avoid eslint warning
|
|
42
|
-
|
|
43
|
-
coerced[key] = coerce(sems[key]).version;
|
|
44
|
-
return coerced;
|
|
45
|
-
}, {});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const {
|
|
49
|
-
current,
|
|
50
|
-
minimum,
|
|
51
|
-
maximum,
|
|
52
|
-
preferred
|
|
53
|
-
} = coercedVersions(params);
|
|
54
|
-
/**
|
|
55
|
-
* Verify that the current version falls within the accepted ranges.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
const rangeStr = `>=${minimum} <${maximum}`;
|
|
59
|
-
|
|
60
|
-
if (!satisfies(current, rangeStr)) {
|
|
61
|
-
throwChalk(`Version ${current} is outside the accepted range of ${rangeStr}`);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Suggest upgrading to the currently recommended version.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (preferred && semverLt(current, preferred)) {
|
|
69
|
-
console.log(chalk.keyword('orange').bold(`
|
|
70
|
-
${chalk.yellow.bold(' *** HEADS UP ***')}
|
|
71
|
-
Running node version => ${chalk.yellow.bold(`v${current}`)} (which should work)
|
|
72
|
-
Preferred version is => ${chalk.green.bold(`v${preferred}`)}
|
|
73
|
-
|
|
74
|
-
Also, a reinstall of the build-tools may be necessary after any node upgrade
|
|
75
|
-
${chalk.cyan.bold('npm i -g @leverege/build-tools')}
|
|
76
|
-
`));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = {
|
|
81
|
-
validate
|
|
82
|
-
};
|