@automattic/vip 2.10.0 → 2.12.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/CONTRIBUTING.md +7 -2
- package/README.md +27 -0
- package/config/{config.json → config.publish.json} +0 -0
- package/dist/bin/vip-dev-env-create.js +1 -0
- package/dist/bin/vip-dev-env-destroy.js +1 -0
- package/dist/bin/vip-dev-env-exec.js +1 -0
- package/dist/bin/vip-dev-env-import-media.js +1 -0
- package/dist/bin/vip-dev-env-import-sql.js +1 -0
- package/dist/bin/vip-dev-env-info.js +1 -0
- package/dist/bin/vip-dev-env-list.js +1 -0
- package/dist/bin/vip-dev-env-start.js +4 -3
- package/dist/bin/vip-dev-env-stop.js +7 -1
- package/dist/bin/vip-dev-env-update.js +1 -0
- package/dist/bin/vip-import-sql.js +7 -1
- package/dist/bin/vip-wp.js +2 -2
- package/dist/bin/vip.js +1 -1
- package/dist/lib/analytics/clients/pendo.js +92 -0
- package/dist/lib/analytics/clients/stub.js +1 -1
- package/dist/lib/analytics/clients/tracks.js +0 -5
- package/dist/lib/analytics/index.js +21 -4
- package/dist/lib/api.js +2 -2
- package/dist/lib/cli/config.js +30 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +25 -2
- package/dist/lib/dev-environment/dev-environment-lando.js +17 -0
- package/dist/lib/http/proxy-agent.js +94 -0
- package/dist/lib/rollbar.js +1 -1
- package/dist/lib/tracker.js +13 -4
- package/npm-shrinkwrap.json +319 -133
- package/package/dist/bin/vip-app-list.js +73 -0
- package/package/dist/bin/vip-app.js +76 -0
- package/package/dist/bin/vip-config-envvar-delete.js +97 -0
- package/package/dist/bin/vip-config-envvar-get-all.js +94 -0
- package/package/dist/bin/vip-config-envvar-get.js +79 -0
- package/package/dist/bin/vip-config-envvar-list.js +91 -0
- package/package/dist/bin/vip-config-envvar-set.js +123 -0
- package/package/dist/bin/vip-config-envvar.js +23 -0
- package/package/dist/bin/vip-config.js +20 -0
- package/package/dist/bin/vip-dev-env-create.js +105 -0
- package/package/dist/bin/vip-dev-env-destroy.js +56 -0
- package/package/dist/bin/vip-dev-env-exec.js +67 -0
- package/package/dist/bin/vip-dev-env-import-media.js +51 -0
- package/package/dist/bin/vip-dev-env-import-sql.js +83 -0
- package/package/dist/bin/vip-dev-env-import.js +32 -0
- package/package/dist/bin/vip-dev-env-info.js +61 -0
- package/package/dist/bin/vip-dev-env-list.js +46 -0
- package/package/dist/bin/vip-dev-env-start.js +77 -0
- package/package/dist/bin/vip-dev-env-stop.js +52 -0
- package/package/dist/bin/vip-dev-env-update.js +89 -0
- package/package/dist/bin/vip-dev-env.js +23 -0
- package/package/dist/bin/vip-import-media-abort.js +132 -0
- package/package/dist/bin/vip-import-media-status.js +84 -0
- package/package/dist/bin/vip-import-media.js +168 -0
- package/package/dist/bin/vip-import-sql-status.js +83 -0
- package/package/dist/bin/vip-import-sql.js +580 -0
- package/package/dist/bin/vip-import-validate-files.js +191 -0
- package/package/dist/bin/vip-import-validate-sql.js +34 -0
- package/package/dist/bin/vip-import.js +20 -0
- package/package/dist/bin/vip-logs.js +232 -0
- package/package/dist/bin/vip-search-replace.js +71 -0
- package/package/dist/bin/vip-sync.js +191 -0
- package/package/dist/bin/vip-whoami.js +67 -0
- package/package/dist/bin/vip-wp.js +555 -0
- package/package/dist/bin/vip.js +149 -0
- package/package/dist/lib/analytics/clients/client.js +1 -0
- package/package/dist/lib/analytics/clients/pendo.js +92 -0
- package/package/dist/lib/analytics/clients/stub.js +19 -0
- package/package/dist/lib/analytics/clients/tracks.js +128 -0
- package/package/dist/lib/analytics/index.js +45 -0
- package/package/dist/lib/api/app.js +70 -0
- package/package/dist/lib/api/feature-flags.js +39 -0
- package/package/dist/lib/api/user.js +58 -0
- package/package/dist/lib/api.js +136 -0
- package/package/dist/lib/app-logs/app-logs.js +70 -0
- package/package/dist/lib/cli/apiConfig.js +90 -0
- package/package/dist/lib/cli/command.js +606 -0
- package/package/dist/lib/cli/envAlias.js +60 -0
- package/package/dist/lib/cli/exit.js +33 -0
- package/package/dist/lib/cli/format.js +213 -0
- package/package/dist/lib/cli/pager.js +52 -0
- package/package/dist/lib/cli/progress.js +208 -0
- package/package/dist/lib/cli/prompt.js +37 -0
- package/package/dist/lib/cli/repo.js +77 -0
- package/package/dist/lib/client-file-uploader.js +602 -0
- package/package/dist/lib/constants/dev-environment.js +42 -0
- package/package/dist/lib/constants/file-size.js +14 -0
- package/package/dist/lib/dev-environment/dev-environment-cli.js +508 -0
- package/package/dist/lib/dev-environment/dev-environment-core.js +620 -0
- package/package/dist/lib/dev-environment/dev-environment-lando.js +330 -0
- package/package/dist/lib/dev-environment/types.js +1 -0
- package/package/dist/lib/env.js +36 -0
- package/package/dist/lib/envvar/api-delete.js +56 -0
- package/package/dist/lib/envvar/api-get-all.js +59 -0
- package/package/dist/lib/envvar/api-get.js +24 -0
- package/package/dist/lib/envvar/api-list.js +60 -0
- package/package/dist/lib/envvar/api-set.js +58 -0
- package/package/dist/lib/envvar/api.js +104 -0
- package/package/dist/lib/envvar/input.js +55 -0
- package/package/dist/lib/envvar/logging.js +33 -0
- package/package/dist/lib/envvar/read-file.js +43 -0
- package/{dist → package/dist}/lib/http/socks-proxy-agent.js +0 -0
- package/package/dist/lib/keychain/browser.js +35 -0
- package/package/dist/lib/keychain/insecure.js +63 -0
- package/package/dist/lib/keychain/keychain.js +1 -0
- package/package/dist/lib/keychain/secure.js +36 -0
- package/package/dist/lib/keychain.js +36 -0
- package/package/dist/lib/media-import/media-file-import.js +34 -0
- package/package/dist/lib/media-import/progress.js +86 -0
- package/package/dist/lib/media-import/status.js +335 -0
- package/package/dist/lib/rollbar.js +35 -0
- package/package/dist/lib/search-and-replace.js +203 -0
- package/package/dist/lib/site-import/db-file-import.js +46 -0
- package/package/dist/lib/site-import/status.js +444 -0
- package/package/dist/lib/token.js +132 -0
- package/package/dist/lib/tracker.js +96 -0
- package/package/dist/lib/validations/is-multi-site-sql-dump.js +59 -0
- package/package/dist/lib/validations/is-multi-site.js +99 -0
- package/package/dist/lib/validations/line-by-line.js +92 -0
- package/package/dist/lib/validations/site-type.js +66 -0
- package/package/dist/lib/validations/sql.js +371 -0
- package/package/dist/lib/vip-import-validate-files.js +548 -0
- package/package/vip.iml +11 -0
- package/package.json +12 -9
- package/helpers/prepare-config.js +0 -19
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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);
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* External dependencies
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
14
|
+
|
|
15
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
16
|
+
|
|
17
|
+
var _child_process = require("child_process");
|
|
18
|
+
|
|
19
|
+
var _tracker = require("../lib/tracker");
|
|
20
|
+
|
|
21
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
22
|
+
|
|
23
|
+
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
24
|
+
|
|
25
|
+
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
+
|
|
27
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Internal dependencies
|
|
33
|
+
*/
|
|
34
|
+
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment'); // PowerShell command for Windows Docker patch
|
|
35
|
+
|
|
36
|
+
const dockerWindowsPathCmd = 'wsl -d docker-desktop bash -c "sysctl -w vm.max_map_count=262144"';
|
|
37
|
+
const examples = [{
|
|
38
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start`,
|
|
39
|
+
description: 'Starts a local dev environment'
|
|
40
|
+
}];
|
|
41
|
+
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
42
|
+
await (0, _devEnvironmentCli.validateDependencies)();
|
|
43
|
+
const startProcessing = new Date();
|
|
44
|
+
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
45
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
46
|
+
await (0, _tracker.trackEvent)('dev_env_start_command_execute', trackingInfo);
|
|
47
|
+
debug('Args: ', arg, 'Options: ', opt);
|
|
48
|
+
const options = {
|
|
49
|
+
skipRebuild: !!opt.skipRebuild
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
if (process.platform === 'win32') {
|
|
54
|
+
debug('Windows platform detected. Applying Docker patch...');
|
|
55
|
+
(0, _child_process.exec)(dockerWindowsPathCmd, {
|
|
56
|
+
shell: 'powershell.exe'
|
|
57
|
+
}, (error, stdout) => {
|
|
58
|
+
if (error != null) {
|
|
59
|
+
debug(error);
|
|
60
|
+
console.log(`${_chalk.default.red('✕')} There was an error while applying the Windows Docker patch.`);
|
|
61
|
+
} else {
|
|
62
|
+
debug(stdout);
|
|
63
|
+
console.log(`${_chalk.default.green('✓')} Docker patch for Windows applied.`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await (0, _devEnvironmentCore.startEnvironment)(slug, options);
|
|
69
|
+
const processingTime = new Date() - startProcessing;
|
|
70
|
+
const successTrackingInfo = { ...trackingInfo,
|
|
71
|
+
processing_time: processingTime
|
|
72
|
+
};
|
|
73
|
+
await (0, _tracker.trackEvent)('dev_env_start_command_success', successTrackingInfo);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_start_command_error', trackingInfo);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
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} stop`,
|
|
35
|
+
description: 'Stops a local dev environment'
|
|
36
|
+
}];
|
|
37
|
+
(0, _command.default)().option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
38
|
+
await (0, _devEnvironmentCli.validateDependencies)();
|
|
39
|
+
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
40
|
+
debug('Args: ', arg, 'Options: ', opt);
|
|
41
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
42
|
+
await (0, _tracker.trackEvent)('dev_env_stop_command_execute', trackingInfo);
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
await (0, _devEnvironmentCore.stopEnvironment)(slug);
|
|
46
|
+
const message = _chalk.default.green('✓') + ' environment stopped.\n';
|
|
47
|
+
console.log(message);
|
|
48
|
+
await (0, _tracker.trackEvent)('dev_env_stop_command_success', trackingInfo);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_stop_command_error', trackingInfo);
|
|
51
|
+
}
|
|
52
|
+
});
|