@automattic/vip 2.22.0 → 2.24.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 +38 -13
- package/assets/dev-env.lando.template.yml.ejs +6 -1
- 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 +8 -21
- package/dist/bin/vip-dev-env-destroy.js +4 -11
- package/dist/bin/vip-dev-env-exec.js +4 -14
- package/dist/bin/vip-dev-env-import-media.js +3 -8
- package/dist/bin/vip-dev-env-import-sql.js +10 -23
- package/dist/bin/vip-dev-env-import.js +0 -3
- package/dist/bin/vip-dev-env-info.js +5 -13
- package/dist/bin/vip-dev-env-list.js +4 -9
- package/dist/bin/vip-dev-env-start.js +9 -17
- package/dist/bin/vip-dev-env-stop.js +4 -11
- package/dist/bin/vip-dev-env-update.js +4 -12
- 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 +467 -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 +14 -40
- 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 +140 -195
- package/dist/lib/dev-environment/dev-environment-core.js +91 -186
- package/dist/lib/dev-environment/dev-environment-lando.js +32 -96
- 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 +894 -357
- package/package.json +5 -2
|
@@ -3,35 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.landoRebuild = landoRebuild;
|
|
8
|
-
exports.landoStop = landoStop;
|
|
6
|
+
exports.bootstrapLando = bootstrapLando;
|
|
9
7
|
exports.landoDestroy = landoDestroy;
|
|
10
|
-
exports.landoInfo = landoInfo;
|
|
11
8
|
exports.landoExec = landoExec;
|
|
12
|
-
exports.
|
|
9
|
+
exports.landoInfo = landoInfo;
|
|
10
|
+
exports.landoRebuild = landoRebuild;
|
|
11
|
+
exports.landoStart = landoStart;
|
|
12
|
+
exports.landoStop = landoStop;
|
|
13
13
|
exports.validateDockerAccess = validateDockerAccess;
|
|
14
|
-
|
|
14
|
+
exports.validateDockerInstalled = validateDockerInstalled;
|
|
15
15
|
var _debug = _interopRequireDefault(require("debug"));
|
|
16
|
-
|
|
17
16
|
var _os = _interopRequireDefault(require("os"));
|
|
18
|
-
|
|
19
17
|
var _path = _interopRequireDefault(require("path"));
|
|
20
|
-
|
|
21
18
|
var _lando = _interopRequireDefault(require("lando/lib/lando"));
|
|
22
|
-
|
|
23
19
|
var _utils = _interopRequireDefault(require("lando/plugins/lando-core/lib/utils"));
|
|
24
|
-
|
|
25
20
|
var _build = _interopRequireDefault(require("lando/plugins/lando-tooling/lib/build"));
|
|
26
|
-
|
|
27
21
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
28
|
-
|
|
29
22
|
var _app = _interopRequireDefault(require("lando/lib/app"));
|
|
30
|
-
|
|
31
23
|
var _userError = _interopRequireDefault(require("../user-error"));
|
|
32
|
-
|
|
33
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
|
-
|
|
35
25
|
/**
|
|
36
26
|
*
|
|
37
27
|
* @format
|
|
@@ -51,25 +41,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
51
41
|
const DEBUG_KEY = '@automattic/vip:bin:dev-environment';
|
|
52
42
|
const debug = (0, _debug.default)(DEBUG_KEY);
|
|
53
43
|
let landoConfRoot;
|
|
44
|
+
|
|
54
45
|
/**
|
|
55
46
|
* @returns {string} User configuration root directory (aka userConfRoot in Lando)
|
|
56
47
|
*/
|
|
57
|
-
|
|
58
48
|
function getLandoUserConfigurationRoot() {
|
|
59
49
|
if (!landoConfRoot) {
|
|
60
50
|
landoConfRoot = _path.default.join(_os.default.tmpdir(), 'lando');
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
return landoConfRoot;
|
|
64
53
|
}
|
|
54
|
+
|
|
65
55
|
/**
|
|
66
56
|
* @returns {object} Lando configuration
|
|
67
57
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
58
|
function getLandoConfig() {
|
|
71
59
|
const landoPath = _path.default.join(__dirname, '..', '..', '..', 'node_modules', 'lando');
|
|
72
|
-
|
|
73
60
|
debug(`Getting lando config, using path '${landoPath}' for plugins`);
|
|
74
61
|
const isLandoDebugSelected = (process.env.DEBUG || '').includes(DEBUG_KEY);
|
|
75
62
|
const isAllDebugSelected = process.env.DEBUG === '*';
|
|
@@ -84,41 +71,38 @@ function getLandoConfig() {
|
|
|
84
71
|
subdir: '.'
|
|
85
72
|
}],
|
|
86
73
|
proxyName: 'vip-dev-env-proxy',
|
|
87
|
-
userConfRoot: getLandoUserConfigurationRoot()
|
|
74
|
+
userConfRoot: getLandoUserConfigurationRoot(),
|
|
75
|
+
home: ''
|
|
88
76
|
};
|
|
89
77
|
}
|
|
90
|
-
|
|
91
|
-
async function landoStart(instancePath) {
|
|
92
|
-
debug('Will start lando app on path:', instancePath);
|
|
78
|
+
async function bootstrapLando() {
|
|
93
79
|
const lando = new _lando.default(getLandoConfig());
|
|
94
80
|
await lando.bootstrap();
|
|
81
|
+
return lando;
|
|
82
|
+
}
|
|
83
|
+
async function landoStart(lando, instancePath) {
|
|
84
|
+
debug('Will start lando app on path:', instancePath);
|
|
95
85
|
const app = lando.getApp(instancePath);
|
|
96
86
|
await app.init();
|
|
97
87
|
addHooks(app, lando);
|
|
98
88
|
await app.start();
|
|
99
89
|
}
|
|
100
|
-
|
|
101
|
-
async function landoRebuild(instancePath) {
|
|
90
|
+
async function landoRebuild(lando, instancePath) {
|
|
102
91
|
debug('Will rebuild lando app on path:', instancePath);
|
|
103
|
-
const lando = new _lando.default(getLandoConfig());
|
|
104
|
-
await lando.bootstrap();
|
|
105
92
|
const app = lando.getApp(instancePath);
|
|
106
93
|
await app.init();
|
|
107
94
|
await ensureNoOrphantProxyContainer(lando);
|
|
108
95
|
addHooks(app, lando);
|
|
109
96
|
await app.rebuild();
|
|
110
97
|
}
|
|
111
|
-
|
|
112
98
|
function addHooks(app, lando) {
|
|
113
99
|
app.events.on('post-start', 1, () => healthcheckHook(app, lando));
|
|
114
100
|
}
|
|
115
|
-
|
|
116
101
|
const healthChecks = {
|
|
117
102
|
database: 'mysql -uroot --silent --execute "SHOW DATABASES;"',
|
|
118
103
|
'vip-search': "curl -s --noproxy '*' -XGET localhost:9200",
|
|
119
104
|
php: '[[ -f /wp/wp-includes/pomo/mo.php ]]'
|
|
120
105
|
};
|
|
121
|
-
|
|
122
106
|
async function healthcheckHook(app, lando) {
|
|
123
107
|
try {
|
|
124
108
|
await lando.Promise.retry(async () => {
|
|
@@ -126,7 +110,6 @@ async function healthcheckHook(app, lando) {
|
|
|
126
110
|
project: app.project
|
|
127
111
|
});
|
|
128
112
|
const notHealthyContainers = [];
|
|
129
|
-
|
|
130
113
|
for (const container of list) {
|
|
131
114
|
if (healthChecks[container.service]) {
|
|
132
115
|
try {
|
|
@@ -149,12 +132,10 @@ async function healthcheckHook(app, lando) {
|
|
|
149
132
|
}
|
|
150
133
|
}
|
|
151
134
|
}
|
|
152
|
-
|
|
153
135
|
if (notHealthyContainers.length) {
|
|
154
136
|
for (const container of notHealthyContainers) {
|
|
155
137
|
console.log(`Waiting for service ${container.service} ...`);
|
|
156
138
|
}
|
|
157
|
-
|
|
158
139
|
return Promise.reject(notHealthyContainers);
|
|
159
140
|
}
|
|
160
141
|
}, {
|
|
@@ -167,35 +148,23 @@ async function healthcheckHook(app, lando) {
|
|
|
167
148
|
}
|
|
168
149
|
}
|
|
169
150
|
}
|
|
170
|
-
|
|
171
|
-
async function landoStop(instancePath) {
|
|
151
|
+
async function landoStop(lando, instancePath) {
|
|
172
152
|
debug('Will stop lando app on path:', instancePath);
|
|
173
|
-
const lando = new _lando.default(getLandoConfig());
|
|
174
|
-
await lando.bootstrap();
|
|
175
153
|
const app = lando.getApp(instancePath);
|
|
176
154
|
await app.init();
|
|
177
155
|
await app.stop();
|
|
178
156
|
}
|
|
179
|
-
|
|
180
|
-
async function landoDestroy(instancePath) {
|
|
157
|
+
async function landoDestroy(lando, instancePath) {
|
|
181
158
|
debug('Will destroy lando app on path:', instancePath);
|
|
182
|
-
const lando = new _lando.default(getLandoConfig());
|
|
183
|
-
await lando.bootstrap();
|
|
184
159
|
const app = lando.getApp(instancePath);
|
|
185
160
|
await app.init();
|
|
186
161
|
await app.destroy();
|
|
187
162
|
}
|
|
188
|
-
|
|
189
|
-
async function landoInfo(instancePath) {
|
|
163
|
+
async function landoInfo(lando, instancePath) {
|
|
190
164
|
var _app$info$find;
|
|
191
|
-
|
|
192
|
-
const lando = new _lando.default(getLandoConfig());
|
|
193
|
-
await lando.bootstrap();
|
|
194
165
|
const app = lando.getApp(instancePath);
|
|
195
166
|
await app.init();
|
|
196
|
-
|
|
197
167
|
let appInfo = _utils.default.startTable(app);
|
|
198
|
-
|
|
199
168
|
const reachableServices = app.info.filter(service => service.urls.length);
|
|
200
169
|
reachableServices.forEach(service => appInfo[`${service.service} urls`] = service.urls);
|
|
201
170
|
const isUp = await isEnvUp(app);
|
|
@@ -207,20 +176,20 @@ async function landoInfo(instancePath) {
|
|
|
207
176
|
...extraService
|
|
208
177
|
};
|
|
209
178
|
delete appInfo.name;
|
|
210
|
-
appInfo.status = isUp ? _chalk.default.green('UP') : _chalk.default.yellow('DOWN');
|
|
179
|
+
appInfo.status = isUp ? _chalk.default.green('UP') : _chalk.default.yellow('DOWN');
|
|
211
180
|
|
|
181
|
+
// Add login information
|
|
212
182
|
if (frontEndUrl) {
|
|
213
183
|
const loginUrl = `${frontEndUrl}wp-admin/`;
|
|
214
184
|
appInfo['Login URL'] = loginUrl;
|
|
215
185
|
appInfo['Default username'] = 'vipgo';
|
|
216
186
|
appInfo['Default password'] = 'password';
|
|
217
|
-
}
|
|
218
|
-
|
|
187
|
+
}
|
|
219
188
|
|
|
189
|
+
// Add documentation link
|
|
220
190
|
appInfo.Documentation = 'https://docs.wpvip.com/technical-references/vip-local-development-environment/';
|
|
221
191
|
return appInfo;
|
|
222
192
|
}
|
|
223
|
-
|
|
224
193
|
const extraServiceDisplayConfiguration = [{
|
|
225
194
|
name: 'vip-search',
|
|
226
195
|
label: 'enterprise search',
|
|
@@ -230,27 +199,20 @@ const extraServiceDisplayConfiguration = [{
|
|
|
230
199
|
// Skipping, as the phpmyadmin was already printed by the regular services
|
|
231
200
|
skip: true
|
|
232
201
|
}];
|
|
233
|
-
|
|
234
202
|
async function getExtraServicesConnections(lando, app) {
|
|
235
203
|
const extraServices = {};
|
|
236
204
|
const allServices = await lando.engine.list({
|
|
237
205
|
project: app.project
|
|
238
206
|
});
|
|
239
|
-
|
|
240
207
|
for (const service of allServices) {
|
|
241
208
|
var _containerScan$Networ;
|
|
242
|
-
|
|
243
209
|
const displayConfiguration = extraServiceDisplayConfiguration.find(conf => conf.name === service.service) || {};
|
|
244
|
-
|
|
245
210
|
if (displayConfiguration.skip) {
|
|
246
211
|
continue;
|
|
247
212
|
}
|
|
248
|
-
|
|
249
213
|
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
214
|
if (containerScan !== null && containerScan !== void 0 && (_containerScan$Networ = containerScan.NetworkSettings) !== null && _containerScan$Networ !== void 0 && _containerScan$Networ.Ports) {
|
|
252
215
|
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
216
|
if (mappings !== null && mappings !== void 0 && mappings.length) {
|
|
255
217
|
const {
|
|
256
218
|
HostIp: host,
|
|
@@ -262,56 +224,47 @@ async function getExtraServicesConnections(lando, app) {
|
|
|
262
224
|
}
|
|
263
225
|
}
|
|
264
226
|
}
|
|
265
|
-
|
|
266
227
|
return extraServices;
|
|
267
228
|
}
|
|
268
|
-
|
|
269
229
|
async function isEnvUp(app) {
|
|
270
230
|
const reachableServices = app.info.filter(service => service.urls.length);
|
|
271
231
|
const urls = reachableServices.map(service => service.urls).flat();
|
|
272
232
|
const scanResult = await app.scanUrls(urls, {
|
|
273
233
|
max: 1
|
|
274
|
-
});
|
|
275
|
-
|
|
234
|
+
});
|
|
235
|
+
// If all the URLs are reachable then the app is considered 'up'
|
|
276
236
|
return (scanResult === null || scanResult === void 0 ? void 0 : scanResult.length) && scanResult.filter(result => result.status).length === scanResult.length;
|
|
277
237
|
}
|
|
278
|
-
|
|
279
|
-
async function landoExec(instancePath, toolName, args, options) {
|
|
280
|
-
const lando = new _lando.default(getLandoConfig());
|
|
281
|
-
await lando.bootstrap();
|
|
238
|
+
async function landoExec(lando, instancePath, toolName, args, options) {
|
|
282
239
|
const app = lando.getApp(instancePath);
|
|
283
240
|
await app.init();
|
|
284
|
-
|
|
285
241
|
if (!options.force) {
|
|
286
242
|
const isUp = await isEnvUp(app);
|
|
287
|
-
|
|
288
243
|
if (!isUp) {
|
|
289
244
|
throw new _userError.default('Environment needs to be started before running wp command');
|
|
290
245
|
}
|
|
291
246
|
}
|
|
292
|
-
|
|
293
247
|
const tool = app.config.tooling[toolName];
|
|
294
|
-
|
|
295
248
|
if (!tool) {
|
|
296
|
-
throw new Error(
|
|
249
|
+
throw new Error(`${toolName} is not a known lando task`);
|
|
297
250
|
}
|
|
251
|
+
|
|
298
252
|
/*
|
|
299
253
|
lando is looking in both passed args and process.argv so we need to do a bit of hack to fake process.argv
|
|
300
254
|
so that lando doesn't try to interpret args not meant for wp.
|
|
301
255
|
Lando drops first 3 args (<node> <lando> <command>) from process.argv and process rest, so we will fake 3 args + the real args
|
|
302
256
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
257
|
process.argv = ['0', '1', '3'].concat(args);
|
|
306
258
|
tool.app = app;
|
|
307
259
|
tool.name = toolName;
|
|
308
260
|
const task = (0, _build.default)(tool, lando);
|
|
309
261
|
const argv = {
|
|
310
262
|
_: args // eslint-disable-line
|
|
311
|
-
|
|
312
263
|
};
|
|
264
|
+
|
|
313
265
|
await task.run(argv);
|
|
314
266
|
}
|
|
267
|
+
|
|
315
268
|
/**
|
|
316
269
|
* Sometimes the proxy network seems to disapper leaving only orphant stopped proxy container.
|
|
317
270
|
* It seems to happen while restarting/powering off computer. This container would then failed
|
|
@@ -322,54 +275,37 @@ async function landoExec(instancePath, toolName, args, options) {
|
|
|
322
275
|
*
|
|
323
276
|
* @param {object} lando Bootstrapped Lando object
|
|
324
277
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
278
|
async function ensureNoOrphantProxyContainer(lando) {
|
|
328
279
|
var _status$State;
|
|
329
|
-
|
|
330
280
|
const proxyContainerName = lando.config.proxyContainer;
|
|
331
281
|
const docker = lando.engine.docker;
|
|
332
282
|
const containers = await docker.listContainers({
|
|
333
283
|
all: true
|
|
334
284
|
});
|
|
335
285
|
const proxyContainerExists = containers.some(container => container.Names.includes(`/${proxyContainerName}`));
|
|
336
|
-
|
|
337
286
|
if (!proxyContainerExists) {
|
|
338
287
|
return;
|
|
339
288
|
}
|
|
340
|
-
|
|
341
289
|
const proxyContainer = await docker.getContainer(proxyContainerName);
|
|
342
290
|
const status = await proxyContainer.inspect();
|
|
343
|
-
|
|
344
291
|
if (status !== null && status !== void 0 && (_status$State = status.State) !== null && _status$State !== void 0 && _status$State.Running) {
|
|
345
292
|
return;
|
|
346
293
|
}
|
|
347
|
-
|
|
348
294
|
await proxyContainer.remove();
|
|
349
295
|
}
|
|
350
|
-
|
|
351
|
-
async function validateDockerInstalled() {
|
|
352
|
-
const lando = new _lando.default(getLandoConfig());
|
|
353
|
-
await lando.bootstrap();
|
|
296
|
+
async function validateDockerInstalled(lando) {
|
|
354
297
|
lando.log.verbose('docker-engine exists: %s', lando.engine.dockerInstalled);
|
|
355
|
-
|
|
356
298
|
if (lando.engine.dockerInstalled === false) {
|
|
357
299
|
throw Error('docker could not be located! Please follow the following instructions to install it - https://docs.docker.com/engine/install/');
|
|
358
300
|
}
|
|
359
|
-
|
|
360
301
|
lando.log.verbose('docker-compose exists: %s', lando.engine.composeInstalled);
|
|
361
|
-
|
|
362
302
|
if (lando.engine.composeInstalled === false) {
|
|
363
303
|
throw Error('docker-compose could not be located! Please follow the following instructions to install it - https://docs.docker.com/compose/install/');
|
|
364
304
|
}
|
|
365
305
|
}
|
|
366
|
-
|
|
367
|
-
async function validateDockerAccess() {
|
|
368
|
-
const lando = new _lando.default(getLandoConfig());
|
|
369
|
-
await lando.bootstrap();
|
|
306
|
+
async function validateDockerAccess(lando) {
|
|
370
307
|
const docker = lando.engine.docker;
|
|
371
308
|
lando.log.verbose('Fetching docker info to verify user is in docker group');
|
|
372
|
-
|
|
373
309
|
try {
|
|
374
310
|
await docker.info();
|
|
375
311
|
} 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);
|