@automattic/vip 3.17.1 → 3.19.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-media.js +1 -1
- package/dist/bin/vip-import-sql.js +5 -20
- package/dist/bin/vip-logs.js +1 -0
- package/dist/bin/vip-slowlogs.js +1 -0
- package/dist/bin/vip.js +1 -1
- package/dist/commands/backup-db.js +2 -5
- package/dist/commands/dev-env-sync-sql.js +13 -4
- package/dist/commands/phpmyadmin.js +2 -5
- package/dist/commands/wp-ssh.js +3 -5
- package/dist/lib/analytics/clients/pendo.js +3 -1
- package/dist/lib/analytics/clients/tracks.js +0 -1
- package/dist/lib/analytics/index.js +0 -1
- package/dist/lib/api/http.js +2 -0
- package/dist/lib/api/user.js +1 -0
- package/dist/lib/backup-storage-availability/backup-storage-availability.js +0 -1
- package/dist/lib/cli/format.js +1 -22
- package/dist/lib/custom-deploy/custom-deploy.js +2 -2
- package/dist/lib/database.js +6 -6
- package/dist/lib/dev-environment/dev-environment-cli.js +7 -5
- package/dist/lib/dev-environment/dev-environment-core.js +9 -4
- package/dist/lib/dev-environment/dev-environment-database.js +4 -0
- package/dist/lib/dev-environment/dev-environment-lando.js +37 -17
- package/dist/lib/dev-environment/env-vars.js +75 -0
- package/dist/lib/keychain/insecure.js +0 -1
- package/dist/lib/media-import/config.js +1 -1
- package/dist/lib/site-import/status.js +2 -7
- package/dist/lib/validations/is-multisite-domain-mapped.js +3 -2
- package/dist/lib/validations/line-by-line.js +1 -1
- package/docs/CHANGELOG.md +55 -0
- package/npm-shrinkwrap.json +3623 -3854
- package/package.json +18 -15
- package/dist/bin/vip-validate-preflight.js +0 -481
- package/dist/bin/vip-validate.js +0 -11
|
@@ -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'
|
|
@@ -162,7 +147,7 @@ async function gates(app, env, fileNameOrURL, isUrl = false, md5 = null, searchR
|
|
|
162
147
|
}
|
|
163
148
|
try {
|
|
164
149
|
await (0, _clientFileUploader.checkFileAccess)(fileName);
|
|
165
|
-
} catch
|
|
150
|
+
} catch {
|
|
166
151
|
await track('import_sql_command_error', {
|
|
167
152
|
error_type: 'sqlfile-unreadable'
|
|
168
153
|
});
|
|
@@ -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
package/dist/bin/vip.js
CHANGED
|
@@ -21,7 +21,7 @@ const tokenURL = 'https://dashboard.wpvip.com/me/cli/token';
|
|
|
21
21
|
const customDeployToken = process.env.WPVIP_DEPLOY_TOKEN;
|
|
22
22
|
const runCmd = async function () {
|
|
23
23
|
const cmd = (0, _command.default)();
|
|
24
|
-
cmd.command('logout', 'Log out the current authenticated VIP-CLI user.').command('app', 'Interact with applications that the current authenticated VIP-CLI user has permission to access.').command('backup', 'Generate a backup of an environment.').command('cache', 'Manage page cache for an environment.').command('config', 'Manage environment configurations.').command('dev-env', 'Create and manage VIP Local Development Environments.').command('export', 'Export a copy of data associated with an environment.').command('import', 'Import media or SQL database files to an environment.').command('logs', 'Retrieve Runtime Logs from an environment.').command('search-replace', 'Search for a string in a local SQL file and replace it with a new string.').command('slowlogs', 'Retrieve MySQL slow query logs from an environment.').command('db', "Access an environment's database.").command('sync', 'Sync the database from production to a non-production environment.').command('whoami', 'Retrieve details about the current authenticated VIP-CLI user.').command('
|
|
24
|
+
cmd.command('logout', 'Log out the current authenticated VIP-CLI user.').command('app', 'Interact with applications that the current authenticated VIP-CLI user has permission to access.').command('backup', 'Generate a backup of an environment.').command('cache', 'Manage page cache for an environment.').command('config', 'Manage environment configurations.').command('dev-env', 'Create and manage VIP Local Development Environments.').command('export', 'Export a copy of data associated with an environment.').command('import', 'Import media or SQL database files to an environment.').command('logs', 'Retrieve Runtime Logs from an environment.').command('search-replace', 'Search for a string in a local SQL file and replace it with a new string.').command('slowlogs', 'Retrieve MySQL slow query logs from an environment.').command('db', "Access an environment's database.").command('sync', 'Sync the database from production to a non-production environment.').command('whoami', 'Retrieve details about the current authenticated VIP-CLI user.').command('wp', 'Execute a WP-CLI command against an environment.');
|
|
25
25
|
cmd.argv(process.argv);
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -80,8 +80,6 @@ async function createBackupJob(appId, envId) {
|
|
|
80
80
|
|
|
81
81
|
// Library for a possible command in the future: vip backup db @app.env
|
|
82
82
|
class BackupDBCommand {
|
|
83
|
-
app;
|
|
84
|
-
env;
|
|
85
83
|
job;
|
|
86
84
|
jobStatus;
|
|
87
85
|
jobAge;
|
|
@@ -91,11 +89,11 @@ class BackupDBCommand {
|
|
|
91
89
|
PREPARE: 'prepare',
|
|
92
90
|
GENERATE: 'generate'
|
|
93
91
|
};
|
|
94
|
-
track;
|
|
95
92
|
progressTracker;
|
|
96
|
-
constructor(app, env,
|
|
93
|
+
constructor(app, env, track = async () => {}) {
|
|
97
94
|
this.app = app;
|
|
98
95
|
this.env = env;
|
|
96
|
+
this.track = track;
|
|
99
97
|
this.progressTracker = new _progress.ProgressTracker([{
|
|
100
98
|
id: this.steps.PREPARE,
|
|
101
99
|
name: 'Preparing for backup generation'
|
|
@@ -103,7 +101,6 @@ class BackupDBCommand {
|
|
|
103
101
|
id: this.steps.GENERATE,
|
|
104
102
|
name: 'Generating backup'
|
|
105
103
|
}]);
|
|
106
|
-
this.track = trackerFn;
|
|
107
104
|
}
|
|
108
105
|
log(msg) {
|
|
109
106
|
if (this.silent) {
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.DevEnvSyncSQLCommand = void 0;
|
|
6
|
+
exports.findSiteHomeUrl = findSiteHomeUrl;
|
|
6
7
|
var _vipSearchReplace = require("@automattic/vip-search-replace");
|
|
7
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
8
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
11
|
var _promises = require("node:stream/promises");
|
|
10
12
|
var _devEnvImportSql = require("./dev-env-import-sql");
|
|
@@ -17,6 +19,8 @@ var _utils = require("../lib/utils");
|
|
|
17
19
|
var _lineByLine = require("../lib/validations/line-by-line");
|
|
18
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
25
|
* Replaces the domain in the given URL
|
|
22
26
|
*
|
|
@@ -44,11 +48,11 @@ function stripProtocol(url) {
|
|
|
44
48
|
* @return Site home url. null if not found
|
|
45
49
|
*/
|
|
46
50
|
function findSiteHomeUrl(sql) {
|
|
47
|
-
const regex =
|
|
48
|
-
const url =
|
|
51
|
+
const regex = /(['"])(?:siteurl|home)\1,\s*\1([Hh][Tt][Tt][Pp][Ss]?:\/\/.+?)\1/;
|
|
52
|
+
const url = regex.exec(sql)?.[2] ?? '';
|
|
49
53
|
try {
|
|
50
|
-
new URL(url);
|
|
51
|
-
return url;
|
|
54
|
+
const parsed = new URL(url);
|
|
55
|
+
return parsed.hostname ? url : null;
|
|
52
56
|
} catch {
|
|
53
57
|
return null;
|
|
54
58
|
}
|
|
@@ -174,6 +178,10 @@ class DevEnvSyncSQLCommand {
|
|
|
174
178
|
if (!networkSites) return;
|
|
175
179
|
const primaryUrl = networkSites.find(site => site?.blogId === 1)?.homeUrl;
|
|
176
180
|
const primaryDomain = primaryUrl ? new URL(primaryUrl).hostname : '';
|
|
181
|
+
debug('Network sites: %j, primary URL: %s, primary domain: %s', networkSites.map(site => ({
|
|
182
|
+
blogId: site?.blogId,
|
|
183
|
+
homeUrl: site?.homeUrl
|
|
184
|
+
})), primaryUrl, primaryDomain);
|
|
177
185
|
for (const site of networkSites) {
|
|
178
186
|
if (!site?.blogId || site.blogId === 1) continue;
|
|
179
187
|
const url = site?.homeUrl;
|
|
@@ -285,6 +293,7 @@ DROP PROCEDURE vip_sync_update_blog_domains;
|
|
|
285
293
|
try {
|
|
286
294
|
console.log('Extracting site urls from the SQL file...');
|
|
287
295
|
this.siteUrls = await extractSiteUrls(this.sqlFile);
|
|
296
|
+
debug('Extracted site URLs: %j', this.siteUrls);
|
|
288
297
|
} catch (err) {
|
|
289
298
|
const error = err;
|
|
290
299
|
await this.track('error', {
|
|
@@ -106,19 +106,16 @@ async function getPhpMyAdminStatus(appId, envId) {
|
|
|
106
106
|
return resp?.data?.app?.environments?.[0]?.phpMyAdminStatus?.status;
|
|
107
107
|
}
|
|
108
108
|
class PhpMyAdminCommand {
|
|
109
|
-
app;
|
|
110
|
-
env;
|
|
111
109
|
silent;
|
|
112
|
-
track;
|
|
113
110
|
steps = {
|
|
114
111
|
ENABLE: 'enable',
|
|
115
112
|
GENERATE: 'generate'
|
|
116
113
|
};
|
|
117
114
|
progressTracker;
|
|
118
|
-
constructor(app, env,
|
|
115
|
+
constructor(app, env, track = async () => {}) {
|
|
119
116
|
this.app = app;
|
|
120
117
|
this.env = env;
|
|
121
|
-
this.track =
|
|
118
|
+
this.track = track;
|
|
122
119
|
this.progressTracker = new _progress.ProgressTracker([{
|
|
123
120
|
id: this.steps.ENABLE,
|
|
124
121
|
name: 'Enabling PHPMyAdmin for this environment'
|
package/dist/commands/wp-ssh.js
CHANGED
|
@@ -49,15 +49,13 @@ class NonZeroExitCodeError extends Error {
|
|
|
49
49
|
}
|
|
50
50
|
exports.NonZeroExitCodeError = NonZeroExitCodeError;
|
|
51
51
|
class WPCliCommandOverSSH {
|
|
52
|
-
app;
|
|
53
|
-
env;
|
|
54
52
|
track;
|
|
55
53
|
constructor(app, env) {
|
|
56
54
|
this.app = app;
|
|
57
55
|
this.env = env;
|
|
58
56
|
this.track = (0, _tracker.makeCommandTracker)('wp', {
|
|
59
|
-
app:
|
|
60
|
-
env:
|
|
57
|
+
app: app.id,
|
|
58
|
+
env: env.id,
|
|
61
59
|
execution_type: 'ssh'
|
|
62
60
|
});
|
|
63
61
|
}
|
|
@@ -188,7 +186,7 @@ class WPCliCommandOverSSH {
|
|
|
188
186
|
async getSSHAuthForCommand(command, extraTrackingInfo) {
|
|
189
187
|
const api = (0, _api.default)();
|
|
190
188
|
try {
|
|
191
|
-
return api.mutate({
|
|
189
|
+
return await api.mutate({
|
|
192
190
|
mutation: TRIGGER_WP_CLI_COMMAND_MUTATION,
|
|
193
191
|
variables: {
|
|
194
192
|
input: {
|
|
@@ -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, {
|
|
@@ -18,7 +18,6 @@ const validEventOrPropNamePattern = /^[a-z_][a-z0-9_]*$/;
|
|
|
18
18
|
// TODO: add batch support (can include multiples in `events` array)
|
|
19
19
|
|
|
20
20
|
class Tracks {
|
|
21
|
-
eventPrefix;
|
|
22
21
|
userAgent;
|
|
23
22
|
baseParams;
|
|
24
23
|
static ENDPOINT = 'https://public-api.wordpress.com/rest/v1.1/tracks/record';
|