@automattic/vip 3.17.0 → 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/docs/CHANGELOG.md +23 -13
- package/npm-shrinkwrap.json +427 -161
- package/package.json +10 -4
|
@@ -33,6 +33,7 @@ async function deleteEnvVarCommand(arg, opt) {
|
|
|
33
33
|
command: `${baseUsage} ${name}`,
|
|
34
34
|
env_id: opt.env.id,
|
|
35
35
|
org_id: opt.app.organization.id,
|
|
36
|
+
org_sfid: opt.app.organization.salesforceId,
|
|
36
37
|
skip_confirm: Boolean(opt.skipConfirmation),
|
|
37
38
|
variable_name: name
|
|
38
39
|
};
|
|
@@ -39,7 +39,8 @@ async function getAllEnvVarsCommand(arg, opt) {
|
|
|
39
39
|
command: usage,
|
|
40
40
|
env_id: opt.env.id,
|
|
41
41
|
format: opt.format,
|
|
42
|
-
org_id: opt.app.organization.id
|
|
42
|
+
org_id: opt.app.organization.id,
|
|
43
|
+
org_sfid: opt.app.organization.salesforceId
|
|
43
44
|
};
|
|
44
45
|
(0, _logging.debug)(`Request: Get all environment variables for ${(0, _logging.getEnvContext)(opt.app, opt.env)}`);
|
|
45
46
|
await (0, _tracker.trackEvent)('envvar_get_all_command_execute', trackingParams);
|
|
@@ -31,6 +31,7 @@ async function getEnvVarCommand(arg, opt) {
|
|
|
31
31
|
command: `${baseUsage} ${name}`,
|
|
32
32
|
env_id: opt.env.id,
|
|
33
33
|
org_id: opt.app.organization.id,
|
|
34
|
+
org_sfid: opt.app.organization.salesforceId,
|
|
34
35
|
variable_name: name
|
|
35
36
|
};
|
|
36
37
|
(0, _logging.debug)(`Request: Get environment variable ${JSON.stringify(name)} for ${(0, _logging.getEnvContext)(opt.app, opt.env)}`);
|
|
@@ -30,7 +30,8 @@ async function listEnvVarsCommand(arg, opt) {
|
|
|
30
30
|
command: usage,
|
|
31
31
|
env_id: opt.env.id,
|
|
32
32
|
format: opt.format,
|
|
33
|
-
org_id: opt.app.organization.id
|
|
33
|
+
org_id: opt.app.organization.id,
|
|
34
|
+
org_sfid: opt.app.organization.salesforceId
|
|
34
35
|
};
|
|
35
36
|
(0, _logging.debug)(`Request: list environment variables for ${(0, _logging.getEnvContext)(opt.app, opt.env)}`);
|
|
36
37
|
await (0, _tracker.trackEvent)('envvar_list_command_execute', trackingParams);
|
|
@@ -33,6 +33,7 @@ async function setEnvVarCommand(arg, opt) {
|
|
|
33
33
|
env_id: opt.env.id,
|
|
34
34
|
from_file: Boolean(opt.fromFile),
|
|
35
35
|
org_id: opt.app.organization.id,
|
|
36
|
+
org_sfid: opt.app.organization.salesforceId,
|
|
36
37
|
skip_confirm: Boolean(opt.skipConfirmation),
|
|
37
38
|
variable_name: name
|
|
38
39
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
5
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
6
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
7
|
+
var _envVars = require("../lib/dev-environment/env-vars");
|
|
8
|
+
var _logging = require("../lib/envvar/logging");
|
|
9
|
+
var _tracker = require("../lib/tracker");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const exampleUsage = 'vip dev-env envvar delete';
|
|
12
|
+
const usage = 'vip dev-env envvar delete -s vip-local';
|
|
13
|
+
const examples = [{
|
|
14
|
+
usage: `${exampleUsage} MY_VARIABLE`,
|
|
15
|
+
description: 'Delete the environment variable "MY_VARIABLE" from the environment.'
|
|
16
|
+
}];
|
|
17
|
+
async function deleteEnvVarCommand(args, opt) {
|
|
18
|
+
(0, _logging.debug)('args: %o, opt: %o', args, opt);
|
|
19
|
+
const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
20
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
21
|
+
const name = args[0]?.trim() ?? '';
|
|
22
|
+
const trackingPrefix = 'dev_env_envvar_delete_command_';
|
|
23
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}execute`, trackingInfo);
|
|
24
|
+
try {
|
|
25
|
+
let removed = false;
|
|
26
|
+
const data = await (0, _envVars.readEnvFile)(slug);
|
|
27
|
+
const envVars = [];
|
|
28
|
+
data.forEach(line => {
|
|
29
|
+
const [key] = line.split('=', 2).map(part => part.trim());
|
|
30
|
+
if (key !== name) {
|
|
31
|
+
envVars.push(line);
|
|
32
|
+
} else {
|
|
33
|
+
removed = true;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!removed) {
|
|
37
|
+
const message = `The environment variable "${name}" does not exist\n`;
|
|
38
|
+
process.stderr.write(_chalk.default.yellow(message));
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
} else {
|
|
41
|
+
const updatedData = envVars.join('\n');
|
|
42
|
+
await (0, _envVars.updateEnvFile)(slug, updatedData);
|
|
43
|
+
process.stdout.write(_chalk.default.green(`The variable "${name}" has been successfully deleted.\n`));
|
|
44
|
+
process.stdout.write(_chalk.default.bgYellow(_chalk.default.bold('Important:')) + ' Please restart the environment for the changes to take effect.\n');
|
|
45
|
+
}
|
|
46
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}success`, trackingInfo);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, `${trackingPrefix}error`, trackingInfo);
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
(0, _command.default)({
|
|
53
|
+
requiredArgs: 1,
|
|
54
|
+
usage
|
|
55
|
+
}).option('slug', 'A unique name for a local environment. Default is "vip-local".', undefined, _devEnvironmentCli.processSlug).examples(examples).argv(process.argv, deleteEnvVarCommand);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
5
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
6
|
+
var _format = require("../lib/cli/format");
|
|
7
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
8
|
+
var _envVars = require("../lib/dev-environment/env-vars");
|
|
9
|
+
var _logging = require("../lib/envvar/logging");
|
|
10
|
+
var _tracker = require("../lib/tracker");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const exampleUsage = 'vip dev-env envvar get-all';
|
|
13
|
+
const usage = 'vip dev-env envvar get-all -s vip-local';
|
|
14
|
+
const examples = [{
|
|
15
|
+
usage: exampleUsage,
|
|
16
|
+
description: 'Retrieve a list of all environment variables in the default table format.'
|
|
17
|
+
}, {
|
|
18
|
+
usage: `${exampleUsage} --format=csv`,
|
|
19
|
+
description: 'Retrieve a list of all environment variables in CSV format.'
|
|
20
|
+
}];
|
|
21
|
+
async function getAllEnvVarsCommand(args, opt) {
|
|
22
|
+
(0, _logging.debug)('args: %o, opt: %o', args, opt);
|
|
23
|
+
const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
24
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
25
|
+
const format = opt.format ?? 'table';
|
|
26
|
+
const trackingPrefix = 'dev_env_envvar_get_all_command_';
|
|
27
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}execute`, trackingInfo);
|
|
28
|
+
try {
|
|
29
|
+
const data = await (0, _envVars.readEnvFile)(slug);
|
|
30
|
+
const envVars = data.map(line => {
|
|
31
|
+
const [key, value] = line.split('=', 2).map(part => part.trim());
|
|
32
|
+
return {
|
|
33
|
+
name: key,
|
|
34
|
+
value: (0, _envVars.parseEnvValue)(value)
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
if (envVars.length === 0) {
|
|
38
|
+
process.stderr.write(_chalk.default.yellow('There are no environment variables\n'));
|
|
39
|
+
} else {
|
|
40
|
+
process.stdout.write(`${(0, _format.formatData)(envVars, format)}\n`);
|
|
41
|
+
}
|
|
42
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}success`, trackingInfo);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, `${trackingPrefix}error`, trackingInfo);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
(0, _command.default)({
|
|
49
|
+
format: true,
|
|
50
|
+
usage
|
|
51
|
+
}).option('slug', 'A unique name for a local environment. Default is "vip-local".', undefined, _devEnvironmentCli.processSlug).examples(examples).argv(process.argv, getAllEnvVarsCommand);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
5
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
6
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
7
|
+
var _envVars = require("../lib/dev-environment/env-vars");
|
|
8
|
+
var _logging = require("../lib/envvar/logging");
|
|
9
|
+
var _tracker = require("../lib/tracker");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const exampleUsage = 'vip dev-env envvar get';
|
|
12
|
+
const usage = 'vip dev-env envvar get -s vip-local';
|
|
13
|
+
const examples = [{
|
|
14
|
+
usage: `${exampleUsage} MY_VARIABLE`,
|
|
15
|
+
description: 'Retrieve the value of the environment variable "MY_VARIABLE".'
|
|
16
|
+
}];
|
|
17
|
+
async function getEnvVarsCommand(args, opt) {
|
|
18
|
+
(0, _logging.debug)('args: %o, opt: %o', args, opt);
|
|
19
|
+
const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
20
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
21
|
+
const name = args[0]?.trim() ?? '';
|
|
22
|
+
const trackingPrefix = 'dev_env_envvar_get_command_';
|
|
23
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}execute`, trackingInfo);
|
|
24
|
+
try {
|
|
25
|
+
const data = await (0, _envVars.readEnvFile)(slug);
|
|
26
|
+
const envVar = data.map(line => line.split('=', 2)).find(([key]) => name === key.trim());
|
|
27
|
+
if (undefined === envVar) {
|
|
28
|
+
process.stderr.write(_chalk.default.yellow(`The environment variable "${name}" does not exist\n`));
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
} else {
|
|
31
|
+
const value = (0, _envVars.parseEnvValue)(envVar[1]);
|
|
32
|
+
process.stdout.write(`${value}\n`);
|
|
33
|
+
}
|
|
34
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}success`, trackingInfo);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, `${trackingPrefix}error`, trackingInfo);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
(0, _command.default)({
|
|
41
|
+
requiredArgs: 1,
|
|
42
|
+
usage
|
|
43
|
+
}).option('slug', 'A unique name for a local environment. Default is "vip-local".', undefined, _devEnvironmentCli.processSlug).examples(examples).argv(process.argv, getEnvVarsCommand);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
5
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
6
|
+
var _format = require("../lib/cli/format");
|
|
7
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
8
|
+
var _envVars = require("../lib/dev-environment/env-vars");
|
|
9
|
+
var _logging = require("../lib/envvar/logging");
|
|
10
|
+
var _tracker = require("../lib/tracker");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const usage = 'vip dev-env envvar list';
|
|
13
|
+
const examples = [{
|
|
14
|
+
usage: 'vip dev-env envvar list -s vip-local',
|
|
15
|
+
description: 'List the names of all environment variables.'
|
|
16
|
+
}];
|
|
17
|
+
async function listEnvVarsCommand(args, opt) {
|
|
18
|
+
(0, _logging.debug)('args: %o, opt: %o', args, opt);
|
|
19
|
+
const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
20
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
21
|
+
const format = opt.format ?? 'table';
|
|
22
|
+
const trackingPrefix = 'dev_env_envvar_list_command_';
|
|
23
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}execute`, trackingInfo);
|
|
24
|
+
try {
|
|
25
|
+
const data = await (0, _envVars.readEnvFile)(slug);
|
|
26
|
+
const envVars = data.map(line => {
|
|
27
|
+
const [key] = line.split('=', 2);
|
|
28
|
+
return {
|
|
29
|
+
name: key.trim()
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
if (envVars.length === 0) {
|
|
33
|
+
process.stderr.write(_chalk.default.yellow('There are no environment variables\n'));
|
|
34
|
+
} else {
|
|
35
|
+
process.stdout.write(`${(0, _format.formatData)(envVars, format)}\n`);
|
|
36
|
+
}
|
|
37
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}success`, trackingInfo);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, `${trackingPrefix}error`, trackingInfo);
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
(0, _command.default)({
|
|
44
|
+
format: true,
|
|
45
|
+
usage
|
|
46
|
+
}).option('slug', 'A unique name for a local environment. Default is "vip-local".', undefined, _devEnvironmentCli.processSlug).examples(examples).argv(process.argv, listEnvVarsCommand);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
5
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
6
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
7
|
+
var _envVars = require("../lib/dev-environment/env-vars");
|
|
8
|
+
var _api = require("../lib/envvar/api");
|
|
9
|
+
var _input = require("../lib/envvar/input");
|
|
10
|
+
var _logging = require("../lib/envvar/logging");
|
|
11
|
+
var _readFile = require("../lib/envvar/read-file");
|
|
12
|
+
var _tracker = require("../lib/tracker");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const exampleUsage = 'vip dev-env envvar set';
|
|
15
|
+
const usage = 'vip dev-env envvar set -s vip-local';
|
|
16
|
+
const examples = [{
|
|
17
|
+
usage: `${exampleUsage} MY_VARIABLE`,
|
|
18
|
+
description: 'Add or update the environment variable "MY_VARIABLE" and assign its value at the prompt.'
|
|
19
|
+
}, {
|
|
20
|
+
usage: `${exampleUsage} MY_VARIABLE MY_VALUE`,
|
|
21
|
+
description: 'Add or update the environment variable "MY_VARIABLE" and assign its value to "MY_VALUE".'
|
|
22
|
+
}, {
|
|
23
|
+
usage: `${exampleUsage} MULTILINE_ENV_VAR --from-file=envvar-value.txt`,
|
|
24
|
+
description: 'Add or update the environment variable "MULTILINE_ENV_VAR" and assign the multiline contents of local file envvar-value.txt as its value.'
|
|
25
|
+
}];
|
|
26
|
+
async function deleteEnvVarCommand(args, opt) {
|
|
27
|
+
(0, _logging.debug)('args: %o, opt: %o', args, opt);
|
|
28
|
+
const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
29
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
30
|
+
const name = args[0]?.trim() ?? '';
|
|
31
|
+
let newValue = args[1];
|
|
32
|
+
const trackingPrefix = 'dev_env_envvar_set_command_';
|
|
33
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}execute`, trackingInfo);
|
|
34
|
+
if (!(0, _api.validateNameWithMessage)(name)) {
|
|
35
|
+
await (0, _tracker.trackEvent)('dev_env_envvar_set_invalid_name', trackingInfo);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const data = await (0, _envVars.readEnvFile)(slug);
|
|
40
|
+
if (newValue === undefined) {
|
|
41
|
+
if (opt.fromFile) {
|
|
42
|
+
newValue = await (0, _readFile.readVariableFromFile)(opt.fromFile);
|
|
43
|
+
} else {
|
|
44
|
+
process.stdout.write(`For multiline input, please use the ${_chalk.default.bold('--from-file')} option.\n\n`);
|
|
45
|
+
newValue = await (0, _input.promptForValue)(`Enter the value for ${name}:`).catch(async () => {
|
|
46
|
+
await (0, _tracker.trackEvent)('dev_env_envvar_set_user_cancelled_input', trackingInfo);
|
|
47
|
+
(0, _input.cancel)();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newValue = (0, _envVars.quoteEnvValue)(newValue);
|
|
52
|
+
let replaced = false;
|
|
53
|
+
const envVars = data.map(line => {
|
|
54
|
+
const [key] = line.split('=', 2).map(part => part.trim());
|
|
55
|
+
if (key === name) {
|
|
56
|
+
replaced = true;
|
|
57
|
+
return `${key}=${newValue}`;
|
|
58
|
+
}
|
|
59
|
+
return line;
|
|
60
|
+
});
|
|
61
|
+
if (!replaced) {
|
|
62
|
+
envVars.push(`${name}=${newValue}`);
|
|
63
|
+
}
|
|
64
|
+
const updatedData = envVars.join('\n');
|
|
65
|
+
await (0, _envVars.updateEnvFile)(slug, updatedData);
|
|
66
|
+
process.stdout.write(_chalk.default.green(`The variable "${name}" has been successfully updated.\n`));
|
|
67
|
+
process.stdout.write(_chalk.default.bgYellow(_chalk.default.bold('Important:')) + ' Please restart the environment for the changes to take effect.\n');
|
|
68
|
+
await (0, _tracker.trackEvent)(`${trackingPrefix}success`, trackingInfo);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, `${trackingPrefix}error`, trackingInfo);
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
(0, _command.default)({
|
|
75
|
+
requiredArgs: 1,
|
|
76
|
+
wildcardCommand: true,
|
|
77
|
+
usage
|
|
78
|
+
}).option('slug', 'A unique name for a local environment. Default is "vip-local".', undefined, _devEnvironmentCli.processSlug).option('from-file', 'Read environment variable value from a UTF-8-encoded text file (useful for multiline input). Accepts a relative or absolute path.').examples(examples).argv(process.argv, deleteEnvVarCommand);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
5
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
const usage = 'vip dev-env envvar';
|
|
7
|
+
const exampleUsage = 'vip dev-env envvar --slug vip-local';
|
|
8
|
+
const examples = [{
|
|
9
|
+
usage: `${exampleUsage} set MY_VARIABLE`,
|
|
10
|
+
description: 'Add or update the environment variable "MY_VARIABLE" and assign its value at the prompt.'
|
|
11
|
+
}, {
|
|
12
|
+
usage: `${exampleUsage} get MY_VARIABLE`,
|
|
13
|
+
description: 'Retrieve the value of the environment variable "MY_VARIABLE".'
|
|
14
|
+
}, {
|
|
15
|
+
usage: `${exampleUsage} get-all`,
|
|
16
|
+
description: 'Retrieve a list of all environment variables in the default table format.'
|
|
17
|
+
}, {
|
|
18
|
+
usage: `${exampleUsage} list`,
|
|
19
|
+
description: 'List the names of all environment variables.'
|
|
20
|
+
}, {
|
|
21
|
+
usage: `${exampleUsage} delete MY_VARIABLE`,
|
|
22
|
+
description: 'Delete the environment variable "MY_VARIABLE" from the environment.'
|
|
23
|
+
}];
|
|
24
|
+
(0, _command.default)({
|
|
25
|
+
requiredArgs: 0,
|
|
26
|
+
usage
|
|
27
|
+
}).command('delete', 'Delete an environment variable.').command('get', 'Retrieve the value of an environment variable.').command('get-all', 'Retrieve the names and values of all environment variables.').command('list', 'List the names of all environment variables.').command('set', 'Add or update an environment variable.').examples(examples).argv(process.argv);
|
package/dist/bin/vip-dev-env.js
CHANGED
|
@@ -9,4 +9,4 @@ if (process.getuid?.() === 0) {
|
|
|
9
9
|
}
|
|
10
10
|
(0, _command.default)({
|
|
11
11
|
requiredArgs: 0
|
|
12
|
-
}).command('create', 'Create a new local environment.').command('update', 'Update the settings of a local environment.').command('start', 'Start a local environment.').command('stop', 'Stop a local environment.').command('destroy', 'Remove a local environment.').command('info', 'Retrieve information about a local environment.').command('list', 'Retrieve information about all local environments.').command('exec', 'Run a WP-CLI command against a local environment.').command('import', 'Import media or database files to a local environment.').command('shell', 'Create a shell and run commands against a local environment.').command('logs', 'Retrieve logs for a local environment.').command('sync', 'Sync the database of a VIP Platform environment to a local environment.').command('purge', 'Remove all local environments.').argv(process.argv);
|
|
12
|
+
}).command('create', 'Create a new local environment.').command('update', 'Update the settings of a local environment.').command('start', 'Start a local environment.').command('stop', 'Stop a local environment.').command('destroy', 'Remove a local environment.').command('info', 'Retrieve information about a local environment.').command('list', 'Retrieve information about all local environments.').command('exec', 'Run a WP-CLI command against a local environment.').command('import', 'Import media or database files to a local environment.').command('shell', 'Create a shell and run commands against a local environment.').command('logs', 'Retrieve logs for a local environment.').command('sync', 'Sync the database of a VIP Platform environment to a local environment.').command('purge', 'Remove all local environments.').command('envvar', 'Manage environment variables for a local environment.').argv(process.argv);
|
|
@@ -108,29 +108,14 @@ function isValidMd5(md5) {
|
|
|
108
108
|
* @param {string} fileNameOrURL
|
|
109
109
|
* @param {boolean} isUrl
|
|
110
110
|
* @param {string|null} md5
|
|
111
|
-
* @param searchReplace
|
|
112
111
|
*/
|
|
113
112
|
// eslint-disable-next-line complexity
|
|
114
|
-
async function gates(app, env, fileNameOrURL, isUrl = false, md5 = null
|
|
113
|
+
async function gates(app, env, fileNameOrURL, isUrl = false, md5 = null) {
|
|
115
114
|
const {
|
|
116
115
|
id: envId,
|
|
117
116
|
appId
|
|
118
117
|
} = env;
|
|
119
118
|
const track = _tracker.trackEventWithEnv.bind(null, appId, envId);
|
|
120
|
-
if (isUrl) {
|
|
121
|
-
if (!md5) {
|
|
122
|
-
await track('import_sql_command_error', {
|
|
123
|
-
error_type: 'missing-md5'
|
|
124
|
-
});
|
|
125
|
-
exit.withError('MD5 hash is required when importing from a URL. Please provide the --md5 parameter with a valid MD5 hash of the remote file.');
|
|
126
|
-
}
|
|
127
|
-
if (searchReplace.length > 0) {
|
|
128
|
-
await track('import_sql_command_error', {
|
|
129
|
-
error_type: 'search-replace-with-url'
|
|
130
|
-
});
|
|
131
|
-
exit.withError('Search and replace operations are not supported when importing from a URL. Please remove the --search-replace option.');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
119
|
if (md5 && !isValidMd5(md5)) {
|
|
135
120
|
await track('import_sql_command_error', {
|
|
136
121
|
error_type: 'invalid-md5'
|
|
@@ -238,7 +223,7 @@ const examples = [
|
|
|
238
223
|
},
|
|
239
224
|
// URL import
|
|
240
225
|
{
|
|
241
|
-
usage: 'vip @example-app.develop import sql https://example.org/file.sql
|
|
226
|
+
usage: 'vip @example-app.develop import sql https://example.org/file.sql',
|
|
242
227
|
description: 'Import a remote SQL database backup file from the URL with MD5 hash verification to the develop environment of the "example-app" application.'
|
|
243
228
|
},
|
|
244
229
|
// `search-replace` flag
|
|
@@ -389,7 +374,7 @@ void (0, _command.default)({
|
|
|
389
374
|
requiredArgs: 1,
|
|
390
375
|
module: 'import-sql',
|
|
391
376
|
usage
|
|
392
|
-
}).command('status', 'Check the status of a SQL database import currently in progress.').option('skip-validate', 'Do not perform file validation prior to import. If the file contains unsupported entries, the import is likely to fail.').option('search-replace', 'Search for a string in the SQL file and replace it with a new string. Separate the values by a comma only; no spaces (e.g. --search-replace="from,to").').option('in-place', 'Overwrite the local input file with the results of the search and replace operation prior to import.').option('output', 'The local file path to save a copy of the results from the search and replace operation when the --search-replace option is passed. Ignored when used with the --in-place option.').option('skip-maintenance-mode', 'Imports data without putting the environment in maintenance mode. Available only for unlaunched environments. Caution: This may cause site instability during import.').option('md5', 'MD5 hash of the remote SQL file for verification.
|
|
377
|
+
}).command('status', 'Check the status of a SQL database import currently in progress.').option('skip-validate', 'Do not perform file validation prior to import. If the file contains unsupported entries, the import is likely to fail.').option('search-replace', 'Search for a string in the SQL file and replace it with a new string. Separate the values by a comma only; no spaces (e.g. --search-replace="from,to").').option('in-place', 'Overwrite the local input file with the results of the search and replace operation prior to import.').option('output', 'The local file path to save a copy of the results from the search and replace operation when the --search-replace option is passed. Ignored when used with the --in-place option.').option('skip-maintenance-mode', 'Imports data without putting the environment in maintenance mode. Available only for unlaunched environments. Caution: This may cause site instability during import.').option('md5', 'MD5 hash of the remote SQL file for verification. If not provided, the verification will not be performed.').examples(examples)
|
|
393
378
|
// eslint-disable-next-line complexity
|
|
394
379
|
.argv(process.argv, async (arg, opts) => {
|
|
395
380
|
const {
|
|
@@ -425,7 +410,7 @@ void (0, _command.default)({
|
|
|
425
410
|
});
|
|
426
411
|
|
|
427
412
|
// halt operation of the import based on some rules
|
|
428
|
-
await gates(app, env, fileNameOrURL, isUrl, md5
|
|
413
|
+
await gates(app, env, fileNameOrURL, isUrl, md5);
|
|
429
414
|
|
|
430
415
|
// Log summary of import details
|
|
431
416
|
const domain = env?.primaryDomain?.name ? env.primaryDomain.name : `#${env.id}`;
|
package/dist/bin/vip-logs.js
CHANGED
package/dist/bin/vip-slowlogs.js
CHANGED
|
@@ -32,6 +32,7 @@ class Pendo {
|
|
|
32
32
|
...this.context,
|
|
33
33
|
org_id: eventProps.org_slug,
|
|
34
34
|
org_slug: eventProps.org_slug,
|
|
35
|
+
org_sfid: eventProps.org_sfid,
|
|
35
36
|
userAgent: this.userAgent,
|
|
36
37
|
userId: this.userId
|
|
37
38
|
};
|
|
@@ -49,7 +50,8 @@ class Pendo {
|
|
|
49
50
|
properties: eventProps,
|
|
50
51
|
timestamp: Date.now(),
|
|
51
52
|
type: 'track',
|
|
52
|
-
visitorId: `${this.context.userId}
|
|
53
|
+
visitorId: `${this.context.userId}`,
|
|
54
|
+
accountId: `${this.context.org_sfid}`
|
|
53
55
|
};
|
|
54
56
|
debug('send()', body);
|
|
55
57
|
const response = await (0, _http.default)(Pendo.ENDPOINT, {
|
package/dist/lib/api/user.js
CHANGED
package/dist/lib/cli/format.js
CHANGED
|
@@ -10,8 +10,6 @@ exports.formatEnvironment = formatEnvironment;
|
|
|
10
10
|
exports.formatMetricBytes = void 0;
|
|
11
11
|
exports.formatSearchReplaceValues = formatSearchReplaceValues;
|
|
12
12
|
exports.getGlyphForStatus = getGlyphForStatus;
|
|
13
|
-
exports.isJson = isJson;
|
|
14
|
-
exports.isJsonObject = isJsonObject;
|
|
15
13
|
exports.keyValue = keyValue;
|
|
16
14
|
exports.requoteArgs = requoteArgs;
|
|
17
15
|
exports.table = table;
|
|
@@ -108,26 +106,7 @@ function keyValue(values) {
|
|
|
108
106
|
return lines.join('\n');
|
|
109
107
|
}
|
|
110
108
|
function requoteArgs(args) {
|
|
111
|
-
return args.map(arg => {
|
|
112
|
-
if (arg.includes('--') && arg.includes('=') && arg.includes(' ')) {
|
|
113
|
-
return arg.replace(/"/g, '\\"').replace(/^--([^=]*)=(.*)$/, '--$1="$2"');
|
|
114
|
-
}
|
|
115
|
-
if (arg.includes(' ') && !isJsonObject(arg)) {
|
|
116
|
-
return `"${arg.replace(/"/g, '\\"')}"`;
|
|
117
|
-
}
|
|
118
|
-
return arg;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function isJsonObject(str) {
|
|
122
|
-
return typeof str === 'string' && str.trim().startsWith('{') && isJson(str);
|
|
123
|
-
}
|
|
124
|
-
function isJson(str) {
|
|
125
|
-
try {
|
|
126
|
-
JSON.parse(str);
|
|
127
|
-
return true;
|
|
128
|
-
} catch (error) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
109
|
+
return args.map(arg => `"${arg.replace(/"/g, '\\"')}"`);
|
|
131
110
|
}
|
|
132
111
|
function capitalize(str) {
|
|
133
112
|
if (typeof str !== 'string' || !str.length) {
|
|
@@ -252,7 +252,7 @@ async function promptForArguments(preselectedOptions, defaultOptions, suppressPr
|
|
|
252
252
|
if (setMediaRedirectDomain) {
|
|
253
253
|
instanceData.mediaRedirectDomain = defaultOptions.mediaRedirectDomain;
|
|
254
254
|
}
|
|
255
|
-
} else if (!create && defaultOptions.mediaRedirectDomain) {
|
|
255
|
+
} else if (!create && defaultOptions.mediaRedirectDomain && !preselectedOptions.mediaRedirectDomain) {
|
|
256
256
|
const mediaRedirectPromptText = 'URL to redirect for missing media files ("n" to disable)?';
|
|
257
257
|
const mediaRedirectDomain = await promptForURL(mediaRedirectPromptText, defaultOptions.mediaRedirectDomain);
|
|
258
258
|
instanceData.mediaRedirectDomain = mediaRedirectDomain;
|
|
@@ -736,7 +736,7 @@ function getEnvTrackingInfo(slug) {
|
|
|
736
736
|
}
|
|
737
737
|
result.php = result.php.replace(/^[^:]+:/, '');
|
|
738
738
|
return result;
|
|
739
|
-
} catch
|
|
739
|
+
} catch {
|
|
740
740
|
return {
|
|
741
741
|
slug
|
|
742
742
|
};
|
|
@@ -82,6 +82,10 @@ async function startEnvironment(lando, slug, options) {
|
|
|
82
82
|
updated = await maybeUpdateWordPressImage(lando, slug);
|
|
83
83
|
}
|
|
84
84
|
updated = updated || (await maybeUpdateVersion(lando, slug));
|
|
85
|
+
const proxyContainer = await (0, _devEnvironmentLando.getProxyContainer)(lando);
|
|
86
|
+
if (!proxyContainer?.State.Running) {
|
|
87
|
+
await (0, _devEnvironmentLando.removeProxyCache)(lando);
|
|
88
|
+
}
|
|
85
89
|
if (options.skipRebuild && !updated) {
|
|
86
90
|
await (0, _devEnvironmentLando.landoStart)(lando, instancePath);
|
|
87
91
|
} else {
|
|
@@ -265,12 +269,12 @@ function exec(lando, slug, args, options = {}) {
|
|
|
265
269
|
return (0, _devEnvironmentLando.landoExec)(lando, instancePath, command, commandArgs, options);
|
|
266
270
|
}
|
|
267
271
|
async function doesEnvironmentExist(instancePath) {
|
|
268
|
-
debug('Will check for environment at', instancePath);
|
|
272
|
+
debug('Will check for environment at %s', instancePath);
|
|
269
273
|
const file = _nodePath.default.join(instancePath, instanceDataFileName);
|
|
270
274
|
try {
|
|
271
275
|
const stats = await _nodeFs.default.promises.stat(file);
|
|
272
276
|
return stats.isFile();
|
|
273
|
-
} catch
|
|
277
|
+
} catch {
|
|
274
278
|
return false;
|
|
275
279
|
}
|
|
276
280
|
}
|