@leverege/build-tools 2.38.2 → 2.39.0-beta.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/package.json +12 -16
- package/src/Utils.mjs +30 -0
- package/src/{build-tools.js → build-tools.mjs} +28 -12
- package/src/circle-lib.yml +150 -0
- package/src/circle-srv.yml +213 -0
- package/src/firebaseDeploy.mjs +2 -1
- package/src/firebaseServe.mjs +2 -1
- package/src/getjson.mjs +3 -3
- package/src/helm-charts/firebase-rules/.nohelm +0 -0
- package/src/helm-charts/firebase-rules/firebase.json +5 -0
- package/src/helm-charts/firebase-rules/firebaserc.ovh +24 -0
- package/src/helm-charts/firebase-rules/gitignore +2 -0
- package/src/helm-charts/firebase-rules/helmup.plugin +14 -0
- package/src/helm-charts/firebase-rules/leverege.rules.json +65 -0
- package/src/helm-charts/geotile-server/.nohelm +0 -0
- package/src/helm-charts/geotile-server/gitignore +1 -0
- package/src/helm-charts/geotile-server/helmup.plugin +6 -0
- package/src/helm-charts/velero/helmup.plugin +16 -0
- package/src/helmup.sh +47 -1
- package/src/overwhelm.mjs +55 -63
- package/src/push-my-chart.mjs +7 -6
- package/src/refresh-npm-token.mjs +142 -40
- package/src/unleash.mjs +4 -2
- package/leverege-build-tools-2.21.13.tgz +0 -0
- package/lib/server/build-tools.js +0 -138
- package/lib/server/firebaseDeploy.js +0 -195
- package/lib/server/firebaseServe.js +0 -116
- package/lib/server/getfbcfg.js +0 -25
- package/lib/server/getjson.js +0 -70
- package/lib/server/overwhelm.js +0 -447
- package/lib/server/push-my-chart.js +0 -18
- package/lib/server/refresh-npm-token.js +0 -135
- package/lib/server/tag-release.js +0 -681
- package/lib/server/unleash.js +0 -50
- package/lib/web/build-tools.js +0 -138
- package/lib/web/firebaseDeploy.js +0 -195
- package/lib/web/firebaseServe.js +0 -116
- package/lib/web/getfbcfg.js +0 -25
- package/lib/web/getjson.js +0 -70
- package/lib/web/overwhelm.js +0 -447
- package/lib/web/push-my-chart.js +0 -18
- package/lib/web/refresh-npm-token.js +0 -135
- package/lib/web/tag-release.js +0 -681
- package/lib/web/unleash.js +0 -50
- package/src/overwhelm.js +0 -396
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
* refresh-npm-token will check the access time of the $HOME/.npmrc npm token
|
|
4
|
-
* file and if it is older than 24 hours then it will be updated to whatever
|
|
5
|
-
* value is currently in the NPM_DEVELOPER_SECRET on leverege-artifacts. It
|
|
6
|
-
* will also check to see if the deprecated $HOME/.npmrc.ro file exists and
|
|
7
|
-
* will suggest to the user to remove it. If either of the token files exist
|
|
8
|
-
* the first 6 and last four characters of the token will be extracted and
|
|
9
|
-
* reported via slack to allow DevOps operators to clean up old tokens in npm.
|
|
10
|
-
*
|
|
11
|
-
* For testing the Unix touch command may be used to modify the access access
|
|
12
|
-
* time of the npmrc token. The REFRESH_NPM_TOKEN_DEBUG env variable may also
|
|
13
|
-
* be set to enable debugging and disable the slack channel spam.
|
|
14
|
-
*
|
|
15
|
-
* touch -d 2023-08-20 ~/.npmrc; REFRESH_NPM_TOKEN_DEBUG=1 refresh-npm-token.mjs
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
19
|
-
"use strict";
|
|
20
|
-
|
|
21
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
22
|
-
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
23
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
24
|
-
var _execa = _interopRequireDefault(require("execa"));
|
|
25
|
-
var _semver = require("semver");
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
// we can't use $ until we upgrade to ESM execa
|
|
28
|
-
if ((0, _semver.lt)(process.version, '18.0.0')) {
|
|
29
|
-
console.log(_chalk.default.red('\n\n***ERROR: must be running at least node 18\n')); // eslint-disable-line no-console
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// max age in seconds of the npmrc file before refresh
|
|
34
|
-
const refreshThreshold = 3600 * 24; // 1 day
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
|
-
const log = console.log;
|
|
38
|
-
const debug = (obj, text) => {
|
|
39
|
-
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
40
|
-
log(obj, _chalk.default.yellow(text));
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const fetchToken = filename => {
|
|
44
|
-
const results = {
|
|
45
|
-
filename,
|
|
46
|
-
exists: false,
|
|
47
|
-
token: 'none',
|
|
48
|
-
lastUpdated: -1
|
|
49
|
-
};
|
|
50
|
-
try {
|
|
51
|
-
if (_nodeFs.default.existsSync(filename)) {
|
|
52
|
-
results.exists = true;
|
|
53
|
-
const stat = _nodeFs.default.statSync(filename);
|
|
54
|
-
results.lastUpdated = Math.trunc((Date.now() - stat.mtimeMs) / 1000);
|
|
55
|
-
// grab the current token for logging a redacted version
|
|
56
|
-
const currentNpmrc = _nodeFs.default.readFileSync(filename, 'utf8');
|
|
57
|
-
const found = currentNpmrc.match(/_authToken=(.*)\n/);
|
|
58
|
-
if (found) {
|
|
59
|
-
results.token = `${found[1].slice(0, 8)}......${found[1].slice(-4)}`;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch (statErr) {
|
|
63
|
-
log({
|
|
64
|
-
statErr
|
|
65
|
-
}, `<==fs.statSync failed on file ${filename}`);
|
|
66
|
-
}
|
|
67
|
-
return results;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// fetch the tokens - note the RO token is deprecated and may not exist
|
|
71
|
-
const npmrc = fetchToken(`${_nodeOs.default.homedir()}/.npmrc`);
|
|
72
|
-
const npmrcRo = fetchToken(`${_nodeOs.default.homedir()}/.npmrc.ro`);
|
|
73
|
-
debug({
|
|
74
|
-
npmrc,
|
|
75
|
-
npmrcRo
|
|
76
|
-
}, '<==Your current tokens'); // debug
|
|
77
|
-
|
|
78
|
-
if (npmrc.exists && npmrc.lastUpdated < refreshThreshold) {
|
|
79
|
-
process.exit(0);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// fetch the contents of the npmrc secret stored on leverege-registry
|
|
83
|
-
let npmrcSecret;
|
|
84
|
-
const execaOpts = ['secrets', 'versions', 'access', 'latest', '--secret=NPM_DEVELOPER_NPMRC', '--project=leverege-registry'];
|
|
85
|
-
try {
|
|
86
|
-
const execaOut = await (0, _execa.default)('gcloud', execaOpts);
|
|
87
|
-
npmrcSecret = execaOut.stdout;
|
|
88
|
-
debug({
|
|
89
|
-
execaOut,
|
|
90
|
-
execaOpts
|
|
91
|
-
}, '<==exec info'); // debug
|
|
92
|
-
} catch (err) {
|
|
93
|
-
log(_chalk.default.yellow(`\nFailed Command => [${err.escapedCommand}]\n\n`), _chalk.default.red(err.stderr));
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// now update the user's npmrc file
|
|
98
|
-
log(_chalk.default.yellow('\n*** Refreshing your ~/.npmrc npm token file'));
|
|
99
|
-
try {
|
|
100
|
-
if (_nodeFs.default.existsSync(npmrc)) {
|
|
101
|
-
_nodeFs.default.copyFileSync(npmrc, `${npmrc}-BAK`); // make a backup for safety
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_nodeFs.default.writeFileSync(npmrc.filename, npmrcSecret);
|
|
105
|
-
} catch (fileErr) {
|
|
106
|
-
log(fileErr, 'fs failed');
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
const now = new Date().toLocaleString();
|
|
110
|
-
const slackURL = 'https://hooks.slack.com/services/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';
|
|
111
|
-
const execaAct = await (0, _execa.default)('gcloud', ['config', 'get', 'account']);
|
|
112
|
-
const account = execaAct.stdout;
|
|
113
|
-
const slackData = {
|
|
114
|
-
// eslint-disable-next-line max-len
|
|
115
|
-
text: `--- npmrc refreshed by \`${account}\` at ${now}\n tokens RW [\`${npmrc.token}\`] RO [\`${npmrcRo.token}\`]`,
|
|
116
|
-
channel: '#dev-ops-helm'
|
|
117
|
-
};
|
|
118
|
-
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
119
|
-
log({
|
|
120
|
-
slackURL,
|
|
121
|
-
slackData
|
|
122
|
-
}, '<==Slack skipped');
|
|
123
|
-
} else {
|
|
124
|
-
fetch(slackURL, {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
body: JSON.stringify(slackData),
|
|
127
|
-
headers: {
|
|
128
|
-
'Content-Type': 'application/json'
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (npmrcRo.exists) {
|
|
133
|
-
log(_chalk.default.red('\nWARNING - the need for the ~/.npmrc.ro file has been eliminated - please remove'));
|
|
134
|
-
process.exit(1);
|
|
135
|
-
}
|