@automattic/vip 3.17.1 → 3.18.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/assets/dev-env.lando.template.yml.ejs +1 -1
- package/dist/bin/vip-config-envvar-delete.js +1 -0
- package/dist/bin/vip-config-envvar-get-all.js +2 -1
- package/dist/bin/vip-config-envvar-get.js +1 -0
- package/dist/bin/vip-config-envvar-list.js +2 -1
- package/dist/bin/vip-config-envvar-set.js +1 -0
- package/dist/bin/vip-dev-env-envvar-delete.js +55 -0
- package/dist/bin/vip-dev-env-envvar-get-all.js +51 -0
- package/dist/bin/vip-dev-env-envvar-get.js +43 -0
- package/dist/bin/vip-dev-env-envvar-list.js +46 -0
- package/dist/bin/vip-dev-env-envvar-set.js +78 -0
- package/dist/bin/vip-dev-env-envvar.js +27 -0
- package/dist/bin/vip-dev-env.js +1 -1
- package/dist/bin/vip-import-sql.js +4 -19
- package/dist/bin/vip-logs.js +1 -0
- package/dist/bin/vip-slowlogs.js +1 -0
- package/dist/lib/analytics/clients/pendo.js +3 -1
- package/dist/lib/api/user.js +1 -0
- package/dist/lib/cli/format.js +1 -22
- package/dist/lib/dev-environment/dev-environment-cli.js +2 -2
- package/dist/lib/dev-environment/dev-environment-core.js +6 -2
- package/dist/lib/dev-environment/dev-environment-lando.js +34 -15
- package/dist/lib/dev-environment/env-vars.js +75 -0
- package/npm-shrinkwrap.json +388 -122
- package/package.json +9 -3
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.bootstrapLando = bootstrapLando;
|
|
5
5
|
exports.checkEnvHealth = checkEnvHealth;
|
|
6
|
+
exports.getProxyContainer = getProxyContainer;
|
|
6
7
|
exports.isEnvUp = isEnvUp;
|
|
7
8
|
exports.landoDestroy = landoDestroy;
|
|
8
9
|
exports.landoExec = landoExec;
|
|
@@ -12,6 +13,7 @@ exports.landoRebuild = landoRebuild;
|
|
|
12
13
|
exports.landoShell = landoShell;
|
|
13
14
|
exports.landoStart = landoStart;
|
|
14
15
|
exports.landoStop = landoStop;
|
|
16
|
+
exports.removeProxyCache = removeProxyCache;
|
|
15
17
|
exports.validateDockerInstalled = validateDockerInstalled;
|
|
16
18
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
17
19
|
var _debug = _interopRequireDefault(require("debug"));
|
|
@@ -63,7 +65,7 @@ async function getLandoConfig() {
|
|
|
63
65
|
await (0, _promises2.mkdir)(fakeHomeDir, {
|
|
64
66
|
recursive: true
|
|
65
67
|
});
|
|
66
|
-
} catch
|
|
68
|
+
} catch {
|
|
67
69
|
// Ignore
|
|
68
70
|
}
|
|
69
71
|
const config = {
|
|
@@ -246,6 +248,17 @@ async function getBridgeNetwork(lando) {
|
|
|
246
248
|
return null;
|
|
247
249
|
}
|
|
248
250
|
}
|
|
251
|
+
async function removeProxyCache(lando) {
|
|
252
|
+
const {
|
|
253
|
+
userConfRoot,
|
|
254
|
+
proxyCache
|
|
255
|
+
} = lando.config;
|
|
256
|
+
try {
|
|
257
|
+
await (0, _promises2.unlink)(_nodePath.default.join(userConfRoot, 'cache', proxyCache ?? 'proxyCache'));
|
|
258
|
+
} catch {
|
|
259
|
+
// Swallow
|
|
260
|
+
}
|
|
261
|
+
}
|
|
249
262
|
async function cleanUpLandoProxy(lando) {
|
|
250
263
|
const network = await getBridgeNetwork(lando);
|
|
251
264
|
if (network?.Containers && Object.keys(network.Containers).length === 1) {
|
|
@@ -257,6 +270,7 @@ async function cleanUpLandoProxy(lando) {
|
|
|
257
270
|
} catch (err) {
|
|
258
271
|
debug('Error removing proxy container: %s', err.message);
|
|
259
272
|
}
|
|
273
|
+
await removeProxyCache(lando);
|
|
260
274
|
}
|
|
261
275
|
}
|
|
262
276
|
async function landoStop(lando, instancePath) {
|
|
@@ -525,6 +539,20 @@ async function landoShell(lando, instancePath, service, user, command) {
|
|
|
525
539
|
_app: app
|
|
526
540
|
});
|
|
527
541
|
}
|
|
542
|
+
async function getProxyContainer(lando) {
|
|
543
|
+
const proxyContainerName = lando.config.proxyContainer;
|
|
544
|
+
const {
|
|
545
|
+
docker
|
|
546
|
+
} = lando.engine;
|
|
547
|
+
const containers = await docker.listContainers({
|
|
548
|
+
all: true
|
|
549
|
+
});
|
|
550
|
+
if (containers.some(container => container.Names.includes(`/${proxyContainerName}`))) {
|
|
551
|
+
const container = docker.getContainer(proxyContainerName);
|
|
552
|
+
return container.inspect();
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
528
556
|
|
|
529
557
|
/**
|
|
530
558
|
* Sometimes the proxy network seems to disapper leaving only orphant stopped proxy container.
|
|
@@ -535,21 +563,12 @@ async function landoShell(lando, instancePath, service, user, command) {
|
|
|
535
563
|
* can safely add a network and a new proxy container.
|
|
536
564
|
*/
|
|
537
565
|
async function ensureNoOrphantProxyContainer(lando) {
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const proxyContainerExists = containers.some(container => container.Names.includes(`/${proxyContainerName}`));
|
|
544
|
-
if (!proxyContainerExists) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
const proxyContainer = docker.getContainer(proxyContainerName);
|
|
548
|
-
const status = await proxyContainer.inspect();
|
|
549
|
-
if (status.State.Running) {
|
|
550
|
-
return;
|
|
566
|
+
const proxyContainer = await getProxyContainer(lando);
|
|
567
|
+
if (proxyContainer && !proxyContainer.State.Running) {
|
|
568
|
+
const containerName = proxyContainer.Name.startsWith('/') ? proxyContainer.Name.slice(1) : proxyContainer.Name;
|
|
569
|
+
const container = lando.engine.docker.getContainer(containerName);
|
|
570
|
+
await container.remove();
|
|
551
571
|
}
|
|
552
|
-
await proxyContainer.remove();
|
|
553
572
|
}
|
|
554
573
|
function validateDockerInstalled(lando) {
|
|
555
574
|
const {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getEnvFilePath = getEnvFilePath;
|
|
5
|
+
exports.parseEnvValue = parseEnvValue;
|
|
6
|
+
exports.preparseEnvData = preparseEnvData;
|
|
7
|
+
exports.quoteEnvValue = quoteEnvValue;
|
|
8
|
+
exports.readEnvFile = readEnvFile;
|
|
9
|
+
exports.updateEnvFile = updateEnvFile;
|
|
10
|
+
var _promises = require("node:fs/promises");
|
|
11
|
+
var _nodePath = require("node:path");
|
|
12
|
+
var _devEnvironmentCore = require("./dev-environment-core");
|
|
13
|
+
var _devEnvironment = require("../constants/dev-environment");
|
|
14
|
+
function preparseEnvData(data) {
|
|
15
|
+
return data.split(/\r?\n/).map(line => line.trim()).filter(line => line && !line.startsWith('#'));
|
|
16
|
+
}
|
|
17
|
+
function parseEnvValue(value) {
|
|
18
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
19
|
+
return value.slice(1, -1).replace(/\\(["$\\nrt])/g, (match, char) => {
|
|
20
|
+
switch (char) {
|
|
21
|
+
case '"':
|
|
22
|
+
case '$':
|
|
23
|
+
case '\\':
|
|
24
|
+
return char;
|
|
25
|
+
case 'n':
|
|
26
|
+
return '\n';
|
|
27
|
+
case 'r':
|
|
28
|
+
return '\r';
|
|
29
|
+
case 't':
|
|
30
|
+
return '\t';
|
|
31
|
+
default:
|
|
32
|
+
return match;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (value.startsWith("'") && value.endsWith("'")) {
|
|
37
|
+
return value.slice(1, -1).replace(/\\'/g, "'");
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function quoteEnvValue(value) {
|
|
42
|
+
return `"${value.replace(/[\\"$\n\r\t]/g, match => {
|
|
43
|
+
switch (match) {
|
|
44
|
+
case '\\':
|
|
45
|
+
case '"':
|
|
46
|
+
case '$':
|
|
47
|
+
return '\\' + match;
|
|
48
|
+
case '\n':
|
|
49
|
+
return '\\n';
|
|
50
|
+
case '\r':
|
|
51
|
+
return '\\r';
|
|
52
|
+
case '\t':
|
|
53
|
+
return '\\t';
|
|
54
|
+
default:
|
|
55
|
+
return match;
|
|
56
|
+
}
|
|
57
|
+
})}"`;
|
|
58
|
+
}
|
|
59
|
+
async function getEnvFilePath(slug, checkEnvExists = true) {
|
|
60
|
+
const environmentPath = (0, _devEnvironmentCore.getEnvironmentPath)(slug);
|
|
61
|
+
if (checkEnvExists && !(await (0, _devEnvironmentCore.doesEnvironmentExist)(environmentPath))) {
|
|
62
|
+
throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
|
|
63
|
+
}
|
|
64
|
+
return (0, _nodePath.join)(environmentPath, '.env');
|
|
65
|
+
}
|
|
66
|
+
async function readEnvFile(slug) {
|
|
67
|
+
const name = await getEnvFilePath(slug);
|
|
68
|
+
const content = await (0, _promises.readFile)(name, 'utf-8');
|
|
69
|
+
return preparseEnvData(content);
|
|
70
|
+
}
|
|
71
|
+
async function updateEnvFile(slug, content) {
|
|
72
|
+
const name = await getEnvFilePath(slug, false);
|
|
73
|
+
await (0, _promises.writeFile)(`${name}.tmp`, content, 'utf-8');
|
|
74
|
+
await (0, _promises.rename)(`${name}.tmp`, name);
|
|
75
|
+
}
|