@automattic/vip 2.22.0 → 2.23.0
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/CHANGELOG.md +7 -0
- package/automattic-vip-2.23.0.tgz +0 -0
- package/dist/bin/vip-app-list.js +0 -12
- package/dist/bin/vip-app.js +6 -13
- package/dist/bin/vip-cache-purge-url.js +4 -19
- package/dist/bin/vip-cache.js +0 -2
- package/dist/bin/vip-config-envvar-delete.js +4 -19
- package/dist/bin/vip-config-envvar-get-all.js +6 -19
- package/dist/bin/vip-config-envvar-get.js +4 -15
- package/dist/bin/vip-config-envvar-list.js +8 -20
- package/dist/bin/vip-config-envvar-set.js +4 -23
- package/dist/bin/vip-config-envvar.js +0 -2
- package/dist/bin/vip-config-software-get.js +0 -17
- package/dist/bin/vip-config-software-update.js +6 -22
- package/dist/bin/vip-config-software.js +0 -2
- package/dist/bin/vip-config.js +0 -2
- package/dist/bin/vip-dev-env-create.js +0 -18
- package/dist/bin/vip-dev-env-destroy.js +0 -9
- package/dist/bin/vip-dev-env-exec.js +0 -12
- package/dist/bin/vip-dev-env-import-media.js +0 -7
- package/dist/bin/vip-dev-env-import-sql.js +2 -17
- package/dist/bin/vip-dev-env-import.js +0 -3
- package/dist/bin/vip-dev-env-info.js +0 -10
- package/dist/bin/vip-dev-env-list.js +0 -7
- package/dist/bin/vip-dev-env-start.js +4 -14
- package/dist/bin/vip-dev-env-stop.js +0 -9
- package/dist/bin/vip-dev-env-update.js +0 -11
- package/dist/bin/vip-dev-env.js +0 -2
- package/dist/bin/vip-import-media-abort.js +0 -18
- package/dist/bin/vip-import-media-status.js +0 -12
- package/dist/bin/vip-import-media.js +6 -23
- package/dist/bin/vip-import-sql-status.js +0 -12
- package/dist/bin/vip-import-sql.js +33 -99
- package/dist/bin/vip-import-validate-files.js +21 -42
- package/dist/bin/vip-import-validate-sql.js +0 -8
- package/dist/bin/vip-import.js +0 -3
- package/dist/bin/vip-logs.js +20 -50
- package/dist/bin/vip-search-replace.js +8 -14
- package/dist/bin/vip-sync.js +2 -25
- package/dist/bin/vip-validate-preflight.js +427 -0
- package/dist/bin/vip-validate.js +19 -0
- package/dist/bin/vip-whoami.js +2 -14
- package/dist/bin/vip-wp.js +39 -89
- package/dist/bin/vip.js +5 -35
- package/dist/lib/analytics/clients/pendo.js +9 -18
- package/dist/lib/analytics/clients/stub.js +1 -3
- package/dist/lib/analytics/clients/tracks.js +11 -20
- package/dist/lib/analytics/index.js +4 -11
- package/dist/lib/api/app.js +1 -11
- package/dist/lib/api/cache-purge.js +4 -7
- package/dist/lib/api/feature-flags.js +1 -4
- package/dist/lib/api/http.js +9 -15
- package/dist/lib/api/user.js +1 -7
- package/dist/lib/api.js +7 -18
- package/dist/lib/app-logs/app-logs.js +2 -9
- package/dist/lib/app.js +2 -5
- package/dist/lib/cli/apiConfig.js +4 -19
- package/dist/lib/cli/command.js +43 -133
- package/dist/lib/cli/config.js +1 -5
- package/dist/lib/cli/envAlias.js +14 -15
- package/dist/lib/cli/exit.js +4 -6
- package/dist/lib/cli/format.js +8 -50
- package/dist/lib/cli/progress.js +13 -42
- package/dist/lib/cli/prompt.js +1 -5
- package/dist/lib/cli/repo.js +7 -20
- package/dist/lib/client-file-uploader.js +44 -97
- package/dist/lib/config/software.js +2 -52
- package/dist/lib/constants/dev-environment.js +1 -2
- package/dist/lib/constants/file-size.js +1 -1
- package/dist/lib/constants/vipgo.js +1 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +31 -134
- package/dist/lib/dev-environment/dev-environment-core.js +63 -171
- package/dist/lib/dev-environment/dev-environment-lando.js +16 -71
- package/dist/lib/env.js +1 -4
- package/dist/lib/envvar/api-delete.js +1 -4
- package/dist/lib/envvar/api-get-all.js +1 -4
- package/dist/lib/envvar/api-get.js +1 -2
- package/dist/lib/envvar/api-list.js +3 -4
- package/dist/lib/envvar/api-set.js +1 -4
- package/dist/lib/envvar/api.js +5 -16
- package/dist/lib/envvar/input.js +1 -8
- package/dist/lib/envvar/logging.js +2 -6
- package/dist/lib/envvar/read-file.js +1 -3
- package/dist/lib/http/proxy-agent.js +17 -22
- package/dist/lib/keychain/browser.js +1 -4
- package/dist/lib/keychain/insecure.js +1 -10
- package/dist/lib/keychain/secure.js +1 -8
- package/dist/lib/keychain.js +4 -8
- package/dist/lib/logout.js +0 -6
- package/dist/lib/media-import/media-file-import.js +3 -7
- package/dist/lib/media-import/progress.js +6 -17
- package/dist/lib/media-import/status.js +14 -65
- package/dist/lib/read-file.js +1 -6
- package/dist/lib/rollbar.js +1 -7
- package/dist/lib/search-and-replace.js +9 -41
- package/dist/lib/site-import/db-file-import.js +3 -9
- package/dist/lib/site-import/status.js +17 -74
- package/dist/lib/token.js +1 -33
- package/dist/lib/tracker.js +4 -20
- package/dist/lib/user-error.js +0 -2
- package/dist/lib/validations/is-multi-site-sql-dump.js +4 -12
- package/dist/lib/validations/is-multi-site.js +5 -21
- package/dist/lib/validations/is-multisite-domain-mapped.js +5 -31
- package/dist/lib/validations/line-by-line.js +4 -16
- package/dist/lib/validations/site-type.js +10 -19
- package/dist/lib/validations/sql.js +11 -76
- package/dist/lib/validations/utils.js +1 -6
- package/dist/lib/vip-import-validate-files.js +82 -109
- package/npm-shrinkwrap.json +837 -67
- package/package.json +4 -1
|
@@ -3,35 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.landoStart = landoStart;
|
|
7
|
-
exports.landoRebuild = landoRebuild;
|
|
8
|
-
exports.landoStop = landoStop;
|
|
9
6
|
exports.landoDestroy = landoDestroy;
|
|
10
|
-
exports.landoInfo = landoInfo;
|
|
11
7
|
exports.landoExec = landoExec;
|
|
12
|
-
exports.
|
|
8
|
+
exports.landoInfo = landoInfo;
|
|
9
|
+
exports.landoRebuild = landoRebuild;
|
|
10
|
+
exports.landoStart = landoStart;
|
|
11
|
+
exports.landoStop = landoStop;
|
|
13
12
|
exports.validateDockerAccess = validateDockerAccess;
|
|
14
|
-
|
|
13
|
+
exports.validateDockerInstalled = validateDockerInstalled;
|
|
15
14
|
var _debug = _interopRequireDefault(require("debug"));
|
|
16
|
-
|
|
17
15
|
var _os = _interopRequireDefault(require("os"));
|
|
18
|
-
|
|
19
16
|
var _path = _interopRequireDefault(require("path"));
|
|
20
|
-
|
|
21
17
|
var _lando = _interopRequireDefault(require("lando/lib/lando"));
|
|
22
|
-
|
|
23
18
|
var _utils = _interopRequireDefault(require("lando/plugins/lando-core/lib/utils"));
|
|
24
|
-
|
|
25
19
|
var _build = _interopRequireDefault(require("lando/plugins/lando-tooling/lib/build"));
|
|
26
|
-
|
|
27
20
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
28
|
-
|
|
29
21
|
var _app = _interopRequireDefault(require("lando/lib/app"));
|
|
30
|
-
|
|
31
22
|
var _userError = _interopRequireDefault(require("../user-error"));
|
|
32
|
-
|
|
33
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
|
-
|
|
35
24
|
/**
|
|
36
25
|
*
|
|
37
26
|
* @format
|
|
@@ -51,25 +40,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
51
40
|
const DEBUG_KEY = '@automattic/vip:bin:dev-environment';
|
|
52
41
|
const debug = (0, _debug.default)(DEBUG_KEY);
|
|
53
42
|
let landoConfRoot;
|
|
43
|
+
|
|
54
44
|
/**
|
|
55
45
|
* @returns {string} User configuration root directory (aka userConfRoot in Lando)
|
|
56
46
|
*/
|
|
57
|
-
|
|
58
47
|
function getLandoUserConfigurationRoot() {
|
|
59
48
|
if (!landoConfRoot) {
|
|
60
49
|
landoConfRoot = _path.default.join(_os.default.tmpdir(), 'lando');
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
return landoConfRoot;
|
|
64
52
|
}
|
|
53
|
+
|
|
65
54
|
/**
|
|
66
55
|
* @returns {object} Lando configuration
|
|
67
56
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
57
|
function getLandoConfig() {
|
|
71
58
|
const landoPath = _path.default.join(__dirname, '..', '..', '..', 'node_modules', 'lando');
|
|
72
|
-
|
|
73
59
|
debug(`Getting lando config, using path '${landoPath}' for plugins`);
|
|
74
60
|
const isLandoDebugSelected = (process.env.DEBUG || '').includes(DEBUG_KEY);
|
|
75
61
|
const isAllDebugSelected = process.env.DEBUG === '*';
|
|
@@ -87,7 +73,6 @@ function getLandoConfig() {
|
|
|
87
73
|
userConfRoot: getLandoUserConfigurationRoot()
|
|
88
74
|
};
|
|
89
75
|
}
|
|
90
|
-
|
|
91
76
|
async function landoStart(instancePath) {
|
|
92
77
|
debug('Will start lando app on path:', instancePath);
|
|
93
78
|
const lando = new _lando.default(getLandoConfig());
|
|
@@ -97,7 +82,6 @@ async function landoStart(instancePath) {
|
|
|
97
82
|
addHooks(app, lando);
|
|
98
83
|
await app.start();
|
|
99
84
|
}
|
|
100
|
-
|
|
101
85
|
async function landoRebuild(instancePath) {
|
|
102
86
|
debug('Will rebuild lando app on path:', instancePath);
|
|
103
87
|
const lando = new _lando.default(getLandoConfig());
|
|
@@ -108,17 +92,14 @@ async function landoRebuild(instancePath) {
|
|
|
108
92
|
addHooks(app, lando);
|
|
109
93
|
await app.rebuild();
|
|
110
94
|
}
|
|
111
|
-
|
|
112
95
|
function addHooks(app, lando) {
|
|
113
96
|
app.events.on('post-start', 1, () => healthcheckHook(app, lando));
|
|
114
97
|
}
|
|
115
|
-
|
|
116
98
|
const healthChecks = {
|
|
117
99
|
database: 'mysql -uroot --silent --execute "SHOW DATABASES;"',
|
|
118
100
|
'vip-search': "curl -s --noproxy '*' -XGET localhost:9200",
|
|
119
101
|
php: '[[ -f /wp/wp-includes/pomo/mo.php ]]'
|
|
120
102
|
};
|
|
121
|
-
|
|
122
103
|
async function healthcheckHook(app, lando) {
|
|
123
104
|
try {
|
|
124
105
|
await lando.Promise.retry(async () => {
|
|
@@ -126,7 +107,6 @@ async function healthcheckHook(app, lando) {
|
|
|
126
107
|
project: app.project
|
|
127
108
|
});
|
|
128
109
|
const notHealthyContainers = [];
|
|
129
|
-
|
|
130
110
|
for (const container of list) {
|
|
131
111
|
if (healthChecks[container.service]) {
|
|
132
112
|
try {
|
|
@@ -149,12 +129,10 @@ async function healthcheckHook(app, lando) {
|
|
|
149
129
|
}
|
|
150
130
|
}
|
|
151
131
|
}
|
|
152
|
-
|
|
153
132
|
if (notHealthyContainers.length) {
|
|
154
133
|
for (const container of notHealthyContainers) {
|
|
155
134
|
console.log(`Waiting for service ${container.service} ...`);
|
|
156
135
|
}
|
|
157
|
-
|
|
158
136
|
return Promise.reject(notHealthyContainers);
|
|
159
137
|
}
|
|
160
138
|
}, {
|
|
@@ -167,7 +145,6 @@ async function healthcheckHook(app, lando) {
|
|
|
167
145
|
}
|
|
168
146
|
}
|
|
169
147
|
}
|
|
170
|
-
|
|
171
148
|
async function landoStop(instancePath) {
|
|
172
149
|
debug('Will stop lando app on path:', instancePath);
|
|
173
150
|
const lando = new _lando.default(getLandoConfig());
|
|
@@ -176,7 +153,6 @@ async function landoStop(instancePath) {
|
|
|
176
153
|
await app.init();
|
|
177
154
|
await app.stop();
|
|
178
155
|
}
|
|
179
|
-
|
|
180
156
|
async function landoDestroy(instancePath) {
|
|
181
157
|
debug('Will destroy lando app on path:', instancePath);
|
|
182
158
|
const lando = new _lando.default(getLandoConfig());
|
|
@@ -185,17 +161,13 @@ async function landoDestroy(instancePath) {
|
|
|
185
161
|
await app.init();
|
|
186
162
|
await app.destroy();
|
|
187
163
|
}
|
|
188
|
-
|
|
189
164
|
async function landoInfo(instancePath) {
|
|
190
165
|
var _app$info$find;
|
|
191
|
-
|
|
192
166
|
const lando = new _lando.default(getLandoConfig());
|
|
193
167
|
await lando.bootstrap();
|
|
194
168
|
const app = lando.getApp(instancePath);
|
|
195
169
|
await app.init();
|
|
196
|
-
|
|
197
170
|
let appInfo = _utils.default.startTable(app);
|
|
198
|
-
|
|
199
171
|
const reachableServices = app.info.filter(service => service.urls.length);
|
|
200
172
|
reachableServices.forEach(service => appInfo[`${service.service} urls`] = service.urls);
|
|
201
173
|
const isUp = await isEnvUp(app);
|
|
@@ -207,20 +179,20 @@ async function landoInfo(instancePath) {
|
|
|
207
179
|
...extraService
|
|
208
180
|
};
|
|
209
181
|
delete appInfo.name;
|
|
210
|
-
appInfo.status = isUp ? _chalk.default.green('UP') : _chalk.default.yellow('DOWN');
|
|
182
|
+
appInfo.status = isUp ? _chalk.default.green('UP') : _chalk.default.yellow('DOWN');
|
|
211
183
|
|
|
184
|
+
// Add login information
|
|
212
185
|
if (frontEndUrl) {
|
|
213
186
|
const loginUrl = `${frontEndUrl}wp-admin/`;
|
|
214
187
|
appInfo['Login URL'] = loginUrl;
|
|
215
188
|
appInfo['Default username'] = 'vipgo';
|
|
216
189
|
appInfo['Default password'] = 'password';
|
|
217
|
-
}
|
|
218
|
-
|
|
190
|
+
}
|
|
219
191
|
|
|
192
|
+
// Add documentation link
|
|
220
193
|
appInfo.Documentation = 'https://docs.wpvip.com/technical-references/vip-local-development-environment/';
|
|
221
194
|
return appInfo;
|
|
222
195
|
}
|
|
223
|
-
|
|
224
196
|
const extraServiceDisplayConfiguration = [{
|
|
225
197
|
name: 'vip-search',
|
|
226
198
|
label: 'enterprise search',
|
|
@@ -230,27 +202,20 @@ const extraServiceDisplayConfiguration = [{
|
|
|
230
202
|
// Skipping, as the phpmyadmin was already printed by the regular services
|
|
231
203
|
skip: true
|
|
232
204
|
}];
|
|
233
|
-
|
|
234
205
|
async function getExtraServicesConnections(lando, app) {
|
|
235
206
|
const extraServices = {};
|
|
236
207
|
const allServices = await lando.engine.list({
|
|
237
208
|
project: app.project
|
|
238
209
|
});
|
|
239
|
-
|
|
240
210
|
for (const service of allServices) {
|
|
241
211
|
var _containerScan$Networ;
|
|
242
|
-
|
|
243
212
|
const displayConfiguration = extraServiceDisplayConfiguration.find(conf => conf.name === service.service) || {};
|
|
244
|
-
|
|
245
213
|
if (displayConfiguration.skip) {
|
|
246
214
|
continue;
|
|
247
215
|
}
|
|
248
|
-
|
|
249
216
|
const containerScan = service !== null && service !== void 0 && service.id ? await lando.engine.docker.scan(service === null || service === void 0 ? void 0 : service.id) : null;
|
|
250
|
-
|
|
251
217
|
if (containerScan !== null && containerScan !== void 0 && (_containerScan$Networ = containerScan.NetworkSettings) !== null && _containerScan$Networ !== void 0 && _containerScan$Networ.Ports) {
|
|
252
218
|
const mappings = Object.keys(containerScan.NetworkSettings.Ports).map(internalPort => containerScan.NetworkSettings.Ports[internalPort]).filter(externalMapping => externalMapping === null || externalMapping === void 0 ? void 0 : externalMapping.length);
|
|
253
|
-
|
|
254
219
|
if (mappings !== null && mappings !== void 0 && mappings.length) {
|
|
255
220
|
const {
|
|
256
221
|
HostIp: host,
|
|
@@ -262,56 +227,49 @@ async function getExtraServicesConnections(lando, app) {
|
|
|
262
227
|
}
|
|
263
228
|
}
|
|
264
229
|
}
|
|
265
|
-
|
|
266
230
|
return extraServices;
|
|
267
231
|
}
|
|
268
|
-
|
|
269
232
|
async function isEnvUp(app) {
|
|
270
233
|
const reachableServices = app.info.filter(service => service.urls.length);
|
|
271
234
|
const urls = reachableServices.map(service => service.urls).flat();
|
|
272
235
|
const scanResult = await app.scanUrls(urls, {
|
|
273
236
|
max: 1
|
|
274
|
-
});
|
|
275
|
-
|
|
237
|
+
});
|
|
238
|
+
// If all the URLs are reachable than the app is considered 'up'
|
|
276
239
|
return (scanResult === null || scanResult === void 0 ? void 0 : scanResult.length) && scanResult.filter(result => result.status).length === scanResult.length;
|
|
277
240
|
}
|
|
278
|
-
|
|
279
241
|
async function landoExec(instancePath, toolName, args, options) {
|
|
280
242
|
const lando = new _lando.default(getLandoConfig());
|
|
281
243
|
await lando.bootstrap();
|
|
282
244
|
const app = lando.getApp(instancePath);
|
|
283
245
|
await app.init();
|
|
284
|
-
|
|
285
246
|
if (!options.force) {
|
|
286
247
|
const isUp = await isEnvUp(app);
|
|
287
|
-
|
|
288
248
|
if (!isUp) {
|
|
289
249
|
throw new _userError.default('Environment needs to be started before running wp command');
|
|
290
250
|
}
|
|
291
251
|
}
|
|
292
|
-
|
|
293
252
|
const tool = app.config.tooling[toolName];
|
|
294
|
-
|
|
295
253
|
if (!tool) {
|
|
296
254
|
throw new Error('wp is not a known lando task');
|
|
297
255
|
}
|
|
256
|
+
|
|
298
257
|
/*
|
|
299
258
|
lando is looking in both passed args and process.argv so we need to do a bit of hack to fake process.argv
|
|
300
259
|
so that lando doesn't try to interpret args not meant for wp.
|
|
301
260
|
Lando drops first 3 args (<node> <lando> <command>) from process.argv and process rest, so we will fake 3 args + the real args
|
|
302
261
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
262
|
process.argv = ['0', '1', '3'].concat(args);
|
|
306
263
|
tool.app = app;
|
|
307
264
|
tool.name = toolName;
|
|
308
265
|
const task = (0, _build.default)(tool, lando);
|
|
309
266
|
const argv = {
|
|
310
267
|
_: args // eslint-disable-line
|
|
311
|
-
|
|
312
268
|
};
|
|
269
|
+
|
|
313
270
|
await task.run(argv);
|
|
314
271
|
}
|
|
272
|
+
|
|
315
273
|
/**
|
|
316
274
|
* Sometimes the proxy network seems to disapper leaving only orphant stopped proxy container.
|
|
317
275
|
* It seems to happen while restarting/powering off computer. This container would then failed
|
|
@@ -322,54 +280,41 @@ async function landoExec(instancePath, toolName, args, options) {
|
|
|
322
280
|
*
|
|
323
281
|
* @param {object} lando Bootstrapped Lando object
|
|
324
282
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
283
|
async function ensureNoOrphantProxyContainer(lando) {
|
|
328
284
|
var _status$State;
|
|
329
|
-
|
|
330
285
|
const proxyContainerName = lando.config.proxyContainer;
|
|
331
286
|
const docker = lando.engine.docker;
|
|
332
287
|
const containers = await docker.listContainers({
|
|
333
288
|
all: true
|
|
334
289
|
});
|
|
335
290
|
const proxyContainerExists = containers.some(container => container.Names.includes(`/${proxyContainerName}`));
|
|
336
|
-
|
|
337
291
|
if (!proxyContainerExists) {
|
|
338
292
|
return;
|
|
339
293
|
}
|
|
340
|
-
|
|
341
294
|
const proxyContainer = await docker.getContainer(proxyContainerName);
|
|
342
295
|
const status = await proxyContainer.inspect();
|
|
343
|
-
|
|
344
296
|
if (status !== null && status !== void 0 && (_status$State = status.State) !== null && _status$State !== void 0 && _status$State.Running) {
|
|
345
297
|
return;
|
|
346
298
|
}
|
|
347
|
-
|
|
348
299
|
await proxyContainer.remove();
|
|
349
300
|
}
|
|
350
|
-
|
|
351
301
|
async function validateDockerInstalled() {
|
|
352
302
|
const lando = new _lando.default(getLandoConfig());
|
|
353
303
|
await lando.bootstrap();
|
|
354
304
|
lando.log.verbose('docker-engine exists: %s', lando.engine.dockerInstalled);
|
|
355
|
-
|
|
356
305
|
if (lando.engine.dockerInstalled === false) {
|
|
357
306
|
throw Error('docker could not be located! Please follow the following instructions to install it - https://docs.docker.com/engine/install/');
|
|
358
307
|
}
|
|
359
|
-
|
|
360
308
|
lando.log.verbose('docker-compose exists: %s', lando.engine.composeInstalled);
|
|
361
|
-
|
|
362
309
|
if (lando.engine.composeInstalled === false) {
|
|
363
310
|
throw Error('docker-compose could not be located! Please follow the following instructions to install it - https://docs.docker.com/compose/install/');
|
|
364
311
|
}
|
|
365
312
|
}
|
|
366
|
-
|
|
367
313
|
async function validateDockerAccess() {
|
|
368
314
|
const lando = new _lando.default(getLandoConfig());
|
|
369
315
|
await lando.bootstrap();
|
|
370
316
|
const docker = lando.engine.docker;
|
|
371
317
|
lando.log.verbose('Fetching docker info to verify user is in docker group');
|
|
372
|
-
|
|
373
318
|
try {
|
|
374
319
|
await docker.info();
|
|
375
320
|
} catch (error) {
|
package/dist/lib/env.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _os = _interopRequireDefault(require("os"));
|
|
9
|
-
|
|
10
8
|
var _package = _interopRequireDefault(require("../../package.json"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* External dependencies
|
|
16
12
|
*/
|
|
@@ -18,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
14
|
/**
|
|
19
15
|
* Internal dependencies
|
|
20
16
|
*/
|
|
17
|
+
|
|
21
18
|
const env = {
|
|
22
19
|
app: {
|
|
23
20
|
name: _package.default.name,
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = deleteEnvVar;
|
|
7
|
-
|
|
8
7
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
-
|
|
10
8
|
var _api = _interopRequireDefault(require("../api"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
/**
|
|
19
16
|
* Internal dependencies
|
|
20
17
|
*/
|
|
18
|
+
|
|
21
19
|
const mutation = (0, _graphqlTag.default)`
|
|
22
20
|
mutation DeleteEnvironmentVariable(
|
|
23
21
|
$appId: Int!
|
|
@@ -41,7 +39,6 @@ const mutation = (0, _graphqlTag.default)`
|
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
`;
|
|
44
|
-
|
|
45
42
|
async function deleteEnvVar(appId, envId, name) {
|
|
46
43
|
const api = await (0, _api.default)();
|
|
47
44
|
const variables = {
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getEnvVars;
|
|
7
|
-
|
|
8
7
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
-
|
|
10
8
|
var _api = _interopRequireDefault(require("../api"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
/**
|
|
19
16
|
* Internal dependencies
|
|
20
17
|
*/
|
|
18
|
+
|
|
21
19
|
const query = (0, _graphqlTag.default)`
|
|
22
20
|
query GetEnvironmentVariablesWithValues(
|
|
23
21
|
$appId: Int!
|
|
@@ -42,7 +40,6 @@ const query = (0, _graphqlTag.default)`
|
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
`;
|
|
45
|
-
|
|
46
43
|
async function getEnvVars(appId, envId) {
|
|
47
44
|
const api = await (0, _api.default)();
|
|
48
45
|
const variables = {
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getEnvVar;
|
|
7
|
-
|
|
8
7
|
var _apiGetAll = _interopRequireDefault(require("./api-get-all"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -16,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
14
|
/**
|
|
17
15
|
* Internal dependencies
|
|
18
16
|
*/
|
|
17
|
+
|
|
19
18
|
async function getEnvVar(appId, envId, name) {
|
|
20
19
|
const envvars = await (0, _apiGetAll.default)(appId, envId);
|
|
21
20
|
return envvars.find(({
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = listEnvVars;
|
|
7
|
-
|
|
8
7
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
-
|
|
10
8
|
var _api = _interopRequireDefault(require("../api"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
/**
|
|
19
16
|
* Internal dependencies
|
|
20
17
|
*/
|
|
18
|
+
|
|
21
19
|
const query = (0, _graphqlTag.default)`
|
|
22
20
|
query GetEnvironmentVariables(
|
|
23
21
|
$appId: Int!
|
|
@@ -40,8 +38,9 @@ const query = (0, _graphqlTag.default)`
|
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
|
-
`;
|
|
41
|
+
`;
|
|
44
42
|
|
|
43
|
+
// List the names (but not values) of environment variables.
|
|
45
44
|
async function listEnvVars(appId, envId) {
|
|
46
45
|
const api = await (0, _api.default)();
|
|
47
46
|
const variables = {
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = setEnvVar;
|
|
7
|
-
|
|
8
7
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
-
|
|
10
8
|
var _api = _interopRequireDefault(require("../api"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
/**
|
|
19
16
|
* Internal dependencies
|
|
20
17
|
*/
|
|
18
|
+
|
|
21
19
|
const mutation = (0, _graphqlTag.default)`
|
|
22
20
|
mutation AddEnvironmentVariable(
|
|
23
21
|
$appId: Int!
|
|
@@ -42,7 +40,6 @@ const mutation = (0, _graphqlTag.default)`
|
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
`;
|
|
45
|
-
|
|
46
43
|
async function setEnvVar(appId, envId, name, value) {
|
|
47
44
|
const api = await (0, _api.default)();
|
|
48
45
|
const variables = {
|
package/dist/lib/envvar/api.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.validateNameWithMessage = validateNameWithMessage;
|
|
6
|
+
exports.appQuery = void 0;
|
|
8
7
|
Object.defineProperty(exports, "deleteEnvVar", {
|
|
9
8
|
enumerable: true,
|
|
10
9
|
get: function () {
|
|
@@ -35,24 +34,16 @@ Object.defineProperty(exports, "setEnvVar", {
|
|
|
35
34
|
return _apiSet.default;
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
|
-
exports.
|
|
39
|
-
|
|
37
|
+
exports.validateName = validateName;
|
|
38
|
+
exports.validateNameWithMessage = validateNameWithMessage;
|
|
40
39
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
41
|
-
|
|
42
40
|
var _logging = require("./logging");
|
|
43
|
-
|
|
44
41
|
var _apiDelete = _interopRequireDefault(require("./api-delete"));
|
|
45
|
-
|
|
46
42
|
var _apiGet = _interopRequireDefault(require("./api-get"));
|
|
47
|
-
|
|
48
43
|
var _apiGetAll = _interopRequireDefault(require("./api-get-all"));
|
|
49
|
-
|
|
50
44
|
var _apiList = _interopRequireDefault(require("./api-list"));
|
|
51
|
-
|
|
52
45
|
var _apiSet = _interopRequireDefault(require("./api-set"));
|
|
53
|
-
|
|
54
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
|
-
|
|
56
47
|
/**
|
|
57
48
|
*
|
|
58
49
|
* @format
|
|
@@ -65,7 +56,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
65
56
|
/**
|
|
66
57
|
* Internal dependencies
|
|
67
58
|
*/
|
|
59
|
+
|
|
68
60
|
// Reexport for convenience
|
|
61
|
+
|
|
69
62
|
// The subquery for environments lets users choose any environment, including production.
|
|
70
63
|
const appQuery = `
|
|
71
64
|
id
|
|
@@ -85,20 +78,16 @@ const appQuery = `
|
|
|
85
78
|
}
|
|
86
79
|
`;
|
|
87
80
|
exports.appQuery = appQuery;
|
|
88
|
-
|
|
89
81
|
function validateName(name) {
|
|
90
82
|
const sanitizedName = name.trim().toUpperCase().replace(/[^A-Z0-9_]/g, '');
|
|
91
83
|
return name === sanitizedName && /^[A-Z]/.test(sanitizedName);
|
|
92
84
|
}
|
|
93
|
-
|
|
94
85
|
function validateNameWithMessage(name) {
|
|
95
86
|
(0, _logging.debug)(`Validating environment variable name ${JSON.stringify(name)}`);
|
|
96
|
-
|
|
97
87
|
if (!validateName(name)) {
|
|
98
88
|
const message = ['Environment variable name must consist of A-Z, 0-9, or _,', 'and must start with an uppercase letter.'].join('\n');
|
|
99
89
|
console.log(_chalk.default.bold.red(message));
|
|
100
90
|
return false;
|
|
101
91
|
}
|
|
102
|
-
|
|
103
92
|
return true;
|
|
104
93
|
}
|
package/dist/lib/envvar/input.js
CHANGED
|
@@ -6,13 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.cancel = cancel;
|
|
7
7
|
exports.confirm = confirm;
|
|
8
8
|
exports.promptForValue = promptForValue;
|
|
9
|
-
|
|
10
9
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
-
|
|
12
10
|
var _enquirer = require("enquirer");
|
|
13
|
-
|
|
14
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
12
|
/**
|
|
17
13
|
*
|
|
18
14
|
* @format
|
|
@@ -25,20 +21,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
21
|
/**
|
|
26
22
|
* Internal dependencies
|
|
27
23
|
*/
|
|
24
|
+
|
|
28
25
|
function cancel() {
|
|
29
26
|
console.log(_chalk.default.yellow('Command cancelled by user.'));
|
|
30
27
|
process.exit();
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
function confirm(message) {
|
|
34
30
|
return new _enquirer.BooleanPrompt({
|
|
35
31
|
message
|
|
36
32
|
}).run().catch(() => false);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
async function promptForValue(message, mustMatch) {
|
|
40
35
|
var _response$str;
|
|
41
|
-
|
|
42
36
|
const response = await (0, _enquirer.prompt)({
|
|
43
37
|
message,
|
|
44
38
|
name: 'str',
|
|
@@ -47,7 +41,6 @@ async function promptForValue(message, mustMatch) {
|
|
|
47
41
|
if (mustMatch && input !== mustMatch) {
|
|
48
42
|
return `Please type ${mustMatch} to proceed or ESC to cancel`;
|
|
49
43
|
}
|
|
50
|
-
|
|
51
44
|
return true;
|
|
52
45
|
}
|
|
53
46
|
});
|
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getEnvContext = getEnvContext;
|
|
7
6
|
exports.debug = void 0;
|
|
8
|
-
|
|
7
|
+
exports.getEnvContext = getEnvContext;
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
-
|
|
11
9
|
var _command = require("../cli/command");
|
|
12
|
-
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
*
|
|
17
13
|
* @format
|
|
@@ -24,10 +20,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
20
|
/**
|
|
25
21
|
* Internal dependencies
|
|
26
22
|
*/
|
|
23
|
+
|
|
27
24
|
// Shared debugger.
|
|
28
25
|
const debug = (0, _debug.default)('@automattic/vip:bin:config:envvar');
|
|
29
26
|
exports.debug = debug;
|
|
30
|
-
|
|
31
27
|
function getEnvContext(app, env) {
|
|
32
28
|
return `@${app.id}.${(0, _command.getEnvIdentifier)(env)}`;
|
|
33
29
|
}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.readVariableFromFile = readVariableFromFile;
|
|
7
|
-
|
|
8
7
|
var _logging = require("./logging");
|
|
9
|
-
|
|
10
8
|
var _readFile = require("../read-file");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
*
|
|
14
11
|
* @format
|
|
@@ -21,6 +18,7 @@ var _readFile = require("../read-file");
|
|
|
21
18
|
/**
|
|
22
19
|
* Internal dependencies
|
|
23
20
|
*/
|
|
21
|
+
|
|
24
22
|
async function readVariableFromFile(path) {
|
|
25
23
|
(0, _logging.debug)(`Loading variable value from file ${JSON.stringify(path)}`);
|
|
26
24
|
return await (0, _readFile.readFromFile)(path);
|