@automattic/vip 2.12.0 → 2.14.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/README.md +27 -3
- package/dist/bin/vip-cache-purge-url.js +93 -0
- package/{package/dist/bin/vip-config.js → dist/bin/vip-cache.js} +6 -3
- package/dist/bin/vip-dev-env-exec.js +9 -2
- package/dist/bin/vip-dev-env-import-sql.js +8 -1
- package/dist/bin/vip-dev-env-start.js +2 -1
- package/dist/bin/vip-dev-env-update.js +1 -0
- package/dist/bin/vip.js +1 -1
- package/dist/lib/api/cache-purge.js +76 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +2 -2
- package/dist/lib/dev-environment/dev-environment-core.js +3 -3
- package/dist/lib/dev-environment/dev-environment-lando.js +38 -7
- package/dist/lib/envvar/read-file.js +2 -18
- package/{package/dist/lib/envvar → dist/lib}/read-file.js +3 -6
- package/dist/lib/validations/sql.js +175 -53
- package/npm-shrinkwrap.json +82 -82
- package/package.json +5 -3
- package/.circleci/config.yml +0 -67
- package/package/dist/bin/vip-app-list.js +0 -73
- package/package/dist/bin/vip-app.js +0 -76
- package/package/dist/bin/vip-config-envvar-delete.js +0 -97
- package/package/dist/bin/vip-config-envvar-get-all.js +0 -94
- package/package/dist/bin/vip-config-envvar-get.js +0 -79
- package/package/dist/bin/vip-config-envvar-list.js +0 -91
- package/package/dist/bin/vip-config-envvar-set.js +0 -123
- package/package/dist/bin/vip-config-envvar.js +0 -23
- package/package/dist/bin/vip-dev-env-create.js +0 -105
- package/package/dist/bin/vip-dev-env-destroy.js +0 -56
- package/package/dist/bin/vip-dev-env-exec.js +0 -67
- package/package/dist/bin/vip-dev-env-import-media.js +0 -51
- package/package/dist/bin/vip-dev-env-import-sql.js +0 -83
- package/package/dist/bin/vip-dev-env-import.js +0 -32
- package/package/dist/bin/vip-dev-env-info.js +0 -61
- package/package/dist/bin/vip-dev-env-list.js +0 -46
- package/package/dist/bin/vip-dev-env-start.js +0 -77
- package/package/dist/bin/vip-dev-env-stop.js +0 -52
- package/package/dist/bin/vip-dev-env-update.js +0 -89
- package/package/dist/bin/vip-dev-env.js +0 -23
- package/package/dist/bin/vip-import-media-abort.js +0 -132
- package/package/dist/bin/vip-import-media-status.js +0 -84
- package/package/dist/bin/vip-import-media.js +0 -168
- package/package/dist/bin/vip-import-sql-status.js +0 -83
- package/package/dist/bin/vip-import-sql.js +0 -580
- package/package/dist/bin/vip-import-validate-files.js +0 -191
- package/package/dist/bin/vip-import-validate-sql.js +0 -34
- package/package/dist/bin/vip-import.js +0 -20
- package/package/dist/bin/vip-logs.js +0 -232
- package/package/dist/bin/vip-search-replace.js +0 -71
- package/package/dist/bin/vip-sync.js +0 -191
- package/package/dist/bin/vip-whoami.js +0 -67
- package/package/dist/bin/vip-wp.js +0 -555
- package/package/dist/bin/vip.js +0 -149
- package/package/dist/lib/analytics/clients/client.js +0 -1
- package/package/dist/lib/analytics/clients/pendo.js +0 -92
- package/package/dist/lib/analytics/clients/stub.js +0 -19
- package/package/dist/lib/analytics/clients/tracks.js +0 -128
- package/package/dist/lib/analytics/index.js +0 -45
- package/package/dist/lib/api/app.js +0 -70
- package/package/dist/lib/api/feature-flags.js +0 -39
- package/package/dist/lib/api/user.js +0 -58
- package/package/dist/lib/api.js +0 -136
- package/package/dist/lib/app-logs/app-logs.js +0 -70
- package/package/dist/lib/cli/apiConfig.js +0 -90
- package/package/dist/lib/cli/command.js +0 -606
- package/package/dist/lib/cli/envAlias.js +0 -60
- package/package/dist/lib/cli/exit.js +0 -33
- package/package/dist/lib/cli/format.js +0 -213
- package/package/dist/lib/cli/pager.js +0 -52
- package/package/dist/lib/cli/progress.js +0 -208
- package/package/dist/lib/cli/prompt.js +0 -37
- package/package/dist/lib/cli/repo.js +0 -77
- package/package/dist/lib/client-file-uploader.js +0 -602
- package/package/dist/lib/constants/dev-environment.js +0 -42
- package/package/dist/lib/constants/file-size.js +0 -14
- package/package/dist/lib/dev-environment/dev-environment-cli.js +0 -508
- package/package/dist/lib/dev-environment/dev-environment-core.js +0 -620
- package/package/dist/lib/dev-environment/dev-environment-lando.js +0 -330
- package/package/dist/lib/dev-environment/types.js +0 -1
- package/package/dist/lib/env.js +0 -36
- package/package/dist/lib/envvar/api-delete.js +0 -56
- package/package/dist/lib/envvar/api-get-all.js +0 -59
- package/package/dist/lib/envvar/api-get.js +0 -24
- package/package/dist/lib/envvar/api-list.js +0 -60
- package/package/dist/lib/envvar/api-set.js +0 -58
- package/package/dist/lib/envvar/api.js +0 -104
- package/package/dist/lib/envvar/input.js +0 -55
- package/package/dist/lib/envvar/logging.js +0 -33
- package/package/dist/lib/http/socks-proxy-agent.js +0 -25
- package/package/dist/lib/keychain/browser.js +0 -35
- package/package/dist/lib/keychain/insecure.js +0 -63
- package/package/dist/lib/keychain/keychain.js +0 -1
- package/package/dist/lib/keychain/secure.js +0 -36
- package/package/dist/lib/keychain.js +0 -36
- package/package/dist/lib/media-import/media-file-import.js +0 -34
- package/package/dist/lib/media-import/progress.js +0 -86
- package/package/dist/lib/media-import/status.js +0 -335
- package/package/dist/lib/rollbar.js +0 -35
- package/package/dist/lib/search-and-replace.js +0 -203
- package/package/dist/lib/site-import/db-file-import.js +0 -46
- package/package/dist/lib/site-import/status.js +0 -444
- package/package/dist/lib/token.js +0 -132
- package/package/dist/lib/tracker.js +0 -96
- package/package/dist/lib/validations/is-multi-site-sql-dump.js +0 -59
- package/package/dist/lib/validations/is-multi-site.js +0 -99
- package/package/dist/lib/validations/line-by-line.js +0 -92
- package/package/dist/lib/validations/site-type.js +0 -66
- package/package/dist/lib/validations/sql.js +0 -371
- package/package/dist/lib/vip-import-validate-files.js +0 -548
- package/package/vip.iml +0 -11
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "__esModule", {
|
|
14
|
-
value: true
|
|
15
|
-
});
|
|
16
|
-
exports.setEnvVarCommand = setEnvVarCommand;
|
|
17
|
-
|
|
18
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
19
|
-
|
|
20
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
21
|
-
|
|
22
|
-
var _api = require("../lib/envvar/api");
|
|
23
|
-
|
|
24
|
-
var _input = require("../lib/envvar/input");
|
|
25
|
-
|
|
26
|
-
var _logging = require("../lib/envvar/logging");
|
|
27
|
-
|
|
28
|
-
var _readFile = require("../lib/envvar/read-file");
|
|
29
|
-
|
|
30
|
-
var _rollbar = require("../lib/rollbar");
|
|
31
|
-
|
|
32
|
-
var _tracker = require("../lib/tracker");
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal dependencies
|
|
38
|
-
*/
|
|
39
|
-
const baseUsage = 'vip config envvar set';
|
|
40
|
-
const NEW_RELIC_ENVVAR_KEY = 'NEW_RELIC_LICENSE_KEY'; // Command examples
|
|
41
|
-
|
|
42
|
-
const examples = [{
|
|
43
|
-
usage: `${baseUsage} MY_VARIABLE`,
|
|
44
|
-
description: 'Sets the environment variable "MY_VARIABLE" and prompts for its value'
|
|
45
|
-
}];
|
|
46
|
-
|
|
47
|
-
async function setEnvVarCommand(arg, opt) {
|
|
48
|
-
// Help the user by uppercasing input.
|
|
49
|
-
const name = arg[0].trim().toUpperCase();
|
|
50
|
-
const trackingParams = {
|
|
51
|
-
app_id: opt.app.id,
|
|
52
|
-
command: `${baseUsage} ${name}`,
|
|
53
|
-
env_id: opt.env.id,
|
|
54
|
-
from_file: !!opt.fromFile,
|
|
55
|
-
org_id: opt.app.organization.id,
|
|
56
|
-
skip_confirm: !!opt.skipConfirmation,
|
|
57
|
-
variable_name: name
|
|
58
|
-
};
|
|
59
|
-
(0, _logging.debug)(`Request: Set environment variable ${JSON.stringify(name)} for ${(0, _logging.getEnvContext)(opt.app, opt.env)}`);
|
|
60
|
-
await (0, _tracker.trackEvent)('envvar_set_command_execute', trackingParams);
|
|
61
|
-
|
|
62
|
-
if (!(0, _api.validateNameWithMessage)(name)) {
|
|
63
|
-
await (0, _tracker.trackEvent)('envvar_set_invalid_name', trackingParams);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (NEW_RELIC_ENVVAR_KEY === name) {
|
|
68
|
-
await (0, _tracker.trackEvent)('envvar_set_newrelic_key', trackingParams);
|
|
69
|
-
console.log(_chalk.default.bold.red('Setting the New Relic key is not permitted.'), 'If you want to set your own New Relic key, please contact our support team through the usual channels.');
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let value;
|
|
74
|
-
|
|
75
|
-
if (opt.fromFile) {
|
|
76
|
-
value = await (0, _readFile.readVariableFromFile)(opt.fromFile);
|
|
77
|
-
} else {
|
|
78
|
-
console.log(`For multiline input, use the ${_chalk.default.bold('--from-file')} option.`);
|
|
79
|
-
console.log();
|
|
80
|
-
value = await (0, _input.promptForValue)(`Enter the value for ${name}:`).catch(async () => {
|
|
81
|
-
await (0, _tracker.trackEvent)('envvar_set_user_cancelled_input', trackingParams);
|
|
82
|
-
(0, _input.cancel)();
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!opt.skipConfirmation) {
|
|
87
|
-
// Print input if it was loaded from file.
|
|
88
|
-
if (opt.fromFile) {
|
|
89
|
-
console.log('===== Received value printed below =====');
|
|
90
|
-
console.log(value);
|
|
91
|
-
console.log('===== Received value printed above =====');
|
|
92
|
-
console.log();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!(await (0, _input.confirm)(`Please ${_chalk.default.bold('confirm')} the input value above (y/N)`))) {
|
|
96
|
-
await (0, _tracker.trackEvent)('envvar_set_user_cancelled_confirmation', trackingParams);
|
|
97
|
-
(0, _input.cancel)();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
await (0, _api.setEnvVar)(opt.app.id, opt.env.id, name, value).catch(async err => {
|
|
102
|
-
_rollbar.rollbar.error(err);
|
|
103
|
-
|
|
104
|
-
await (0, _tracker.trackEvent)('envvar_set_mutation_error', { ...trackingParams,
|
|
105
|
-
error: err.message
|
|
106
|
-
});
|
|
107
|
-
throw err;
|
|
108
|
-
});
|
|
109
|
-
await (0, _tracker.trackEvent)('envvar_set_command_success', trackingParams);
|
|
110
|
-
console.log(_chalk.default.green(`Successfully set environment variable ${JSON.stringify(name)}`));
|
|
111
|
-
|
|
112
|
-
if (!opt.skipConfirmation) {
|
|
113
|
-
console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
(0, _command.default)({
|
|
118
|
-
appContext: true,
|
|
119
|
-
appQuery: _api.appQuery,
|
|
120
|
-
envContext: true,
|
|
121
|
-
requiredArgs: 1,
|
|
122
|
-
usage: `${baseUsage} <VARIABLE_NAME>`
|
|
123
|
-
}).option('from-file', 'Read environment variable value from file (useful for multiline input)').option('skip-confirmation', 'Skip manual confirmation of input (USE WITH CAUTION)', false).examples(examples).argv(process.argv, setEnvVarCommand);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
(0, _command.default)({
|
|
22
|
-
requiredArgs: 1
|
|
23
|
-
}).command('delete', 'Permanently delete an environment variable').command('get', 'Get the value of an environment variable').command('get-all', 'Get the values of all environment variable').command('list', 'List the names of all environment variables').command('set', 'Add or update an environment variable').argv(process.argv);
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var exit = _interopRequireWildcard(require("../lib/cli/exit"));
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
24
|
-
|
|
25
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
26
|
-
|
|
27
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
28
|
-
|
|
29
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
|
-
|
|
31
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
32
|
-
|
|
33
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Internal dependencies
|
|
37
|
-
*/
|
|
38
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
39
|
-
const examples = [{
|
|
40
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create`,
|
|
41
|
-
description: 'Creates a local dev environment'
|
|
42
|
-
}, {
|
|
43
|
-
usage: `vip @123.production ${_devEnvironment.DEV_ENVIRONMENT_SUBCOMMAND} create`,
|
|
44
|
-
description: 'Creates a local dev environment for production site for id 123'
|
|
45
|
-
}, {
|
|
46
|
-
usage: `vip ${_devEnvironment.DEV_ENVIRONMENT_SUBCOMMAND} create --slug=my_site`,
|
|
47
|
-
description: 'Creates a local dev environment aliased as "my_site"'
|
|
48
|
-
}, {
|
|
49
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --slug=test`,
|
|
50
|
-
description: 'Assigning unique slugs to environments allows multiple environments to be created.'
|
|
51
|
-
}, {
|
|
52
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite --wordpress="5.8" --client-code="~/git/my_code"`,
|
|
53
|
-
description: 'Creates a local multisite dev environment using WP 5.8 and client code is expected to be in "~/git/my_code"'
|
|
54
|
-
}];
|
|
55
|
-
const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site').option('multisite', 'Enable multisite install', undefined, value => {
|
|
56
|
-
var _value$toLowerCase;
|
|
57
|
-
|
|
58
|
-
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
59
|
-
});
|
|
60
|
-
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
61
|
-
cmd.examples(examples);
|
|
62
|
-
cmd.argv(process.argv, async (arg, opt) => {
|
|
63
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
64
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
65
|
-
debug('Args: ', arg, 'Options: ', opt);
|
|
66
|
-
const trackingInfo = {
|
|
67
|
-
slug
|
|
68
|
-
};
|
|
69
|
-
await (0, _tracker.trackEvent)('dev_env_create_command_execute', trackingInfo);
|
|
70
|
-
|
|
71
|
-
const startCommand = _chalk.default.bold((0, _devEnvironmentCli.getEnvironmentStartCommand)(opt));
|
|
72
|
-
|
|
73
|
-
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
74
|
-
|
|
75
|
-
if (environmentAlreadyExists) {
|
|
76
|
-
const messageToShow = `Environment already exists\n\n\nTo start the environment run:\n\n${startCommand}\n\n` + `To create another environment use ${_chalk.default.bold('--slug')} option with a unique name.\n`;
|
|
77
|
-
exit.withError(messageToShow);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let defaultOptions = {};
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
if (opt.app) {
|
|
84
|
-
const appInfo = await (0, _devEnvironmentCore.getApplicationInformation)(opt.app, opt.env);
|
|
85
|
-
defaultOptions = (0, _devEnvironmentCli.getOptionsFromAppInfo)(appInfo);
|
|
86
|
-
}
|
|
87
|
-
} catch (error) {
|
|
88
|
-
const message = `failed to fetch application "${opt.app}" information`;
|
|
89
|
-
debug(`WARNING: ${message}`, error.message);
|
|
90
|
-
console.log(_chalk.default.yellow('Warning:'), message);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(opt, defaultOptions);
|
|
94
|
-
instanceData.siteSlug = slug;
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
await (0, _devEnvironmentCore.createEnvironment)(instanceData);
|
|
98
|
-
await (0, _devEnvironmentCore.printEnvironmentInfo)(slug);
|
|
99
|
-
const message = '\n' + _chalk.default.green('✓') + ` environment created.\n\nTo start it please run:\n\n${startCommand}\n`;
|
|
100
|
-
console.log(message);
|
|
101
|
-
await (0, _tracker.trackEvent)('dev_env_create_command_success', trackingInfo);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_create_command_error', trackingInfo);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
24
|
-
|
|
25
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
33
|
-
const examples = [{
|
|
34
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} destroy`,
|
|
35
|
-
description: 'Destroys the default local dev environment'
|
|
36
|
-
}, {
|
|
37
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} destroy --slug=foo`,
|
|
38
|
-
description: 'Destroys a local dev environment named foo'
|
|
39
|
-
}];
|
|
40
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('soft', 'Keep config files needed to start an environment intact').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
41
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
42
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
43
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
44
|
-
await (0, _tracker.trackEvent)('dev_env_destroy_command_execute', trackingInfo);
|
|
45
|
-
debug('Args: ', arg, 'Options: ', opt);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const removeFiles = !(opt.soft || false);
|
|
49
|
-
await (0, _devEnvironmentCore.destroyEnvironment)(slug, removeFiles);
|
|
50
|
-
const message = _chalk.default.green('✓') + ' Environment destroyed.\n';
|
|
51
|
-
console.log(message);
|
|
52
|
-
await (0, _tracker.trackEvent)('dev_env_destroy_command_success', trackingInfo);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_destroy_command_error', trackingInfo);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
24
|
-
|
|
25
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
const examples = [{
|
|
30
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} exec -- wp post list`,
|
|
31
|
-
description: 'Use dev-environment to run `wp post list`'
|
|
32
|
-
}, {
|
|
33
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} exec --slug my_site -- wp shell`,
|
|
34
|
-
description: 'Use dev-environment "my_site" to run interactive wp shell'
|
|
35
|
-
}, {
|
|
36
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} exec -- add-site --new-site-slug subsite --new-site-title "New Subsite"`,
|
|
37
|
-
description: 'Execute script to add a subsite to multisite dev environment'
|
|
38
|
-
}];
|
|
39
|
-
(0, _command.default)({
|
|
40
|
-
wildcardCommand: true
|
|
41
|
-
}).option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
|
|
42
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
43
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
44
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
45
|
-
await (0, _tracker.trackEvent)('dev_env_exec_command_execute', trackingInfo);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
// to avoid confusion let's enforce -- as a splitter for arguments for this command and wp itself
|
|
49
|
-
const argSplitterIx = process.argv.findIndex(argument => '--' === argument);
|
|
50
|
-
const argSplitterFound = argSplitterIx > -1;
|
|
51
|
-
|
|
52
|
-
if (unmatchedArgs.length > 0 && !argSplitterFound) {
|
|
53
|
-
throw new Error('Please provide "--" argument to separate arguments for "vip" and command to be executed (see "--help" for examples)');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let arg = [];
|
|
57
|
-
|
|
58
|
-
if (argSplitterFound && argSplitterIx + 1 < process.argv.length) {
|
|
59
|
-
arg = process.argv.slice(argSplitterIx + 1);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
await (0, _devEnvironmentCore.exec)(slug, arg);
|
|
63
|
-
await (0, _tracker.trackEvent)('dev_env_exec_command_success', trackingInfo);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_exec_command_error', trackingInfo);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
24
|
-
|
|
25
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
const examples = [{
|
|
30
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import media path/to/wp-content/uploads`,
|
|
31
|
-
description: 'Import contents of the given WP uploads folder file into the media library of the default dev environment'
|
|
32
|
-
}, {
|
|
33
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import media path/to/wp-content/uploads --slug=mysite`,
|
|
34
|
-
description: 'Import contents of the given WP uploads folder file into the media library of a dev environment named `mysite`'
|
|
35
|
-
}];
|
|
36
|
-
(0, _command.default)({
|
|
37
|
-
requiredArgs: 1
|
|
38
|
-
}).examples(examples).option('slug', 'Custom name of the dev environment').argv(process.argv, async (unmatchedArgs, opt) => {
|
|
39
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
40
|
-
const [filePath] = unmatchedArgs;
|
|
41
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
42
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
43
|
-
await (0, _tracker.trackEvent)('dev_env_import_media_command_execute', trackingInfo);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
await (0, _devEnvironmentCore.importMediaPath)(slug, filePath);
|
|
47
|
-
await (0, _tracker.trackEvent)('dev_env_import_media_command_success', trackingInfo);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_media_command_error', trackingInfo);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
14
|
-
|
|
15
|
-
var _tracker = require("../lib/tracker");
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
22
|
-
|
|
23
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
24
|
-
|
|
25
|
-
var _sql = require("../lib/validations/sql");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
const examples = [{
|
|
33
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql some-wp-db-file.sql`,
|
|
34
|
-
description: 'Import the contents of a WordPress database from an SQL file'
|
|
35
|
-
}, {
|
|
36
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql wordpress.sql --slug=my_site`,
|
|
37
|
-
description: 'Import the contents of a WordPress database from an SQL file into `my_site`'
|
|
38
|
-
}, {
|
|
39
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql wordpress.sql --search-replace="testsite.com,test-site.go-vip.net"`,
|
|
40
|
-
description: 'Import the contents of a WordPress database from an SQL file and replace the occurrences of `testsite.com` with `test-site.go-vip.net`'
|
|
41
|
-
}, {
|
|
42
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql wordpress.sql --search-replace="testsite.com,test-site.go-vip.net" --in-place`,
|
|
43
|
-
description: 'Import the contents of a WordPress database from an SQL file and replace the occurrences of `testsite.com` with `test-site.go-vip.net` in place (modifies the original SQL file)'
|
|
44
|
-
}];
|
|
45
|
-
(0, _command.default)({
|
|
46
|
-
requiredArgs: 1
|
|
47
|
-
}).option('slug', 'Custom name of the dev environment').option('search-replace', 'Perform Search and Replace on the specified SQL file').option('in-place', 'Search and Replace explicitly on the given input file').option('skip-validate', 'Do not perform file validation.').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
|
|
48
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
49
|
-
const [fileName] = unmatchedArgs;
|
|
50
|
-
const {
|
|
51
|
-
searchReplace,
|
|
52
|
-
inPlace
|
|
53
|
-
} = opt;
|
|
54
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
55
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
56
|
-
await (0, _tracker.trackEvent)('dev_env_import_sql_command_execute', trackingInfo);
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const {
|
|
60
|
-
resolvedPath,
|
|
61
|
-
inContainerPath
|
|
62
|
-
} = await (0, _devEnvironmentCore.resolveImportPath)(slug, fileName, searchReplace, inPlace);
|
|
63
|
-
|
|
64
|
-
if (!opt.skipValidate) {
|
|
65
|
-
await (0, _sql.validate)(fileName, []);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const importArg = ['wp', 'db', 'import', inContainerPath];
|
|
69
|
-
await (0, _devEnvironmentCore.exec)(slug, importArg);
|
|
70
|
-
|
|
71
|
-
if (searchReplace && searchReplace.length && !inPlace) {
|
|
72
|
-
_fs.default.unlinkSync(resolvedPath);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const cacheArg = ['wp', 'cache', 'flush'];
|
|
76
|
-
await (0, _devEnvironmentCore.exec)(slug, cacheArg);
|
|
77
|
-
const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'];
|
|
78
|
-
await (0, _devEnvironmentCore.exec)(slug, addUserArg);
|
|
79
|
-
await (0, _tracker.trackEvent)('dev_env_import_sql_command_success', trackingInfo);
|
|
80
|
-
} catch (error) {
|
|
81
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_sql_command_error', trackingInfo);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
const examples = [{
|
|
24
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql file.sql`,
|
|
25
|
-
description: 'Import the given SQL file to your site'
|
|
26
|
-
}, {
|
|
27
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import media path/to/wp-content/uploads`,
|
|
28
|
-
description: 'Import contents of the given WP uploads folder file into the media library of the default dev environment'
|
|
29
|
-
}];
|
|
30
|
-
(0, _command.default)({
|
|
31
|
-
requiredArgs: 1
|
|
32
|
-
}).examples(examples).command('sql', 'Import SQL to your dev-env database from a file').command('media', 'Import media files to the dev environment of your application from a compressed web archive. ' + 'This command will copy the contents of a folder to the `uploads` folder of the target dev environment.').argv(process.argv);
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
|
-
var _tracker = require("../lib/tracker");
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
22
|
-
|
|
23
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
24
|
-
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal dependencies
|
|
29
|
-
*/
|
|
30
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
31
|
-
const examples = [{
|
|
32
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} info --all`,
|
|
33
|
-
description: 'Return information about all local dev environments'
|
|
34
|
-
}, {
|
|
35
|
-
usage: `vip @123 ${_devEnvironment.DEV_ENVIRONMENT_SUBCOMMAND} info`,
|
|
36
|
-
description: 'Return information about dev environment for site 123'
|
|
37
|
-
}, {
|
|
38
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} info --slug=my_site`,
|
|
39
|
-
description: 'Return information about a local dev environment named "my_site"'
|
|
40
|
-
}];
|
|
41
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('all', 'Show Info for all local dev environments').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
42
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
43
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
44
|
-
const trackingInfo = opt.all ? {
|
|
45
|
-
all: true
|
|
46
|
-
} : (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
47
|
-
await (0, _tracker.trackEvent)('dev_env_info_command_execute', trackingInfo);
|
|
48
|
-
debug('Args: ', arg, 'Options: ', opt);
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
if (opt.all) {
|
|
52
|
-
await (0, _devEnvironmentCore.printAllEnvironmentsInfo)();
|
|
53
|
-
} else {
|
|
54
|
-
await (0, _devEnvironmentCore.printEnvironmentInfo)(slug);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await (0, _tracker.trackEvent)('dev_env_info_command_success', trackingInfo);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_info_command_error', trackingInfo);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
24
|
-
|
|
25
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
const examples = [{
|
|
30
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} list`,
|
|
31
|
-
description: 'Return information about all local dev environments'
|
|
32
|
-
}];
|
|
33
|
-
(0, _command.default)().examples(examples).argv(process.argv, async () => {
|
|
34
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
35
|
-
const trackingInfo = {
|
|
36
|
-
all: true
|
|
37
|
-
};
|
|
38
|
-
await (0, _tracker.trackEvent)('dev_env_list_command_execute', trackingInfo);
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
await (0, _devEnvironmentCore.printAllEnvironmentsInfo)();
|
|
42
|
-
await (0, _tracker.trackEvent)('dev_env_list_command_success', trackingInfo);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_list_command_error', trackingInfo);
|
|
45
|
-
}
|
|
46
|
-
});
|