@automattic/vip 2.3.1 → 2.7.0-dev1
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 +3 -0
- package/README.md +20 -0
- package/automattic-vip-2.7.0-dev1.tgz +0 -0
- package/config/config.json +2 -2
- package/dist/bin/vip-config-envvar-delete.js +4 -0
- package/dist/bin/vip-config-envvar-set.js +4 -0
- package/dist/bin/vip-dev-env-create.js +11 -24
- package/dist/bin/vip-dev-env-import-sql.js +13 -2
- package/dist/bin/vip-dev-env-update.js +80 -0
- package/dist/bin/vip-dev-env.js +1 -1
- package/dist/bin/vip-dev-environment-start.js +41 -0
- package/dist/bin/vip-dev-environment.js +23 -0
- package/dist/bin/vip-import-media-abort.js +0 -0
- package/dist/bin/vip-import-media-status.js +0 -0
- package/dist/bin/vip-import-sql.js +2 -1
- package/dist/bin/vip-import.js +0 -0
- package/dist/bin/vip-logs.js +151 -0
- package/dist/bin/vip.js +8 -3
- package/dist/lib/cli/command.js +6 -0
- package/dist/lib/constants/dev-environment.js +3 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +107 -47
- package/dist/lib/dev-environment/dev-environment-core.js +54 -8
- package/dist/lib/dev-environment/dev-environment-lando.js +4 -2
- package/dist/lib/dev-environment/types.js +1 -0
- package/dist/lib/dev-environment.js +194 -0
- package/dist/lib/site-import/db-file-import.js +1 -1
- package/dist/lib/site-import/status.js +1 -1
- package/package.json +7 -5
package/CONTRIBUTING.md
CHANGED
|
@@ -94,12 +94,15 @@ gh pr list --search "is:merged sort:updated-desc closed:>$LAST_RELEASE_DATE" | s
|
|
|
94
94
|
|
|
95
95
|
Then, let's publish:
|
|
96
96
|
|
|
97
|
+
1. Make sure master branch is up to date `git pull`
|
|
97
98
|
1. Set the version (via `npm version minor` or `npm version major` or `npm version patch`)
|
|
98
99
|
1. For most regular releases, this will be `npm version minor`.
|
|
99
100
|
1. Push the tag to GitHub (`git push --tags`)
|
|
101
|
+
1. Push the master branch `git push`
|
|
100
102
|
1. Make sure you're part of the Automattic organization in npm
|
|
101
103
|
1. Publish the release to npm (`npm run publish-please --access public`)
|
|
102
104
|
1. Edit [the release on GitHub](https://github.com/Automattic/vip/releases) to include a description of the changes and publish (this can just copy the details from the changelog).
|
|
105
|
+
1. Push `master` changes (mostly the version bump) to `develop` (`git checkout develop && git merge master` )
|
|
103
106
|
|
|
104
107
|
Once released, it's worth running `npm i -g @automattic/vip` to install / upgrade the released version to make sure everything looks good.
|
|
105
108
|
|
package/README.md
CHANGED
|
@@ -27,6 +27,26 @@ By default, we record information about the usage of this tool using an in-house
|
|
|
27
27
|
|
|
28
28
|
## Changelog
|
|
29
29
|
|
|
30
|
+
### 2.6.0 (23 November 2021)
|
|
31
|
+
- #921 [dev-env] Introuces update to change existing environment
|
|
32
|
+
- #928 [dev-env] Switch lando to use our fork
|
|
33
|
+
- #927 [dev-env] Handles user already exists during sql import
|
|
34
|
+
- #925 [dev-env] Fix the issue with dev-env update
|
|
35
|
+
- #924 FORNO-985 Increase SQL Import limit for unlaunched sites to 100GB
|
|
36
|
+
- #923 FORNO-943 Fixes a bug which prevents displaying SQL Import error messages
|
|
37
|
+
- #922 Update eslint-config-wpvip commit hash to c6605d1
|
|
38
|
+
- #873 Pin dependencies
|
|
39
|
+
|
|
40
|
+
### 2.5.0 (9 November 2021)
|
|
41
|
+
- #919 [dev-env] Expose lando core logs
|
|
42
|
+
- #916 [dev-env] Save instance data state
|
|
43
|
+
- #914 [dev-env] update help wording for dev env
|
|
44
|
+
- #915 Add warning message when an envvar is set/deleted
|
|
45
|
+
|
|
46
|
+
### 2.4.0 (5 November 2021)
|
|
47
|
+
- #913 [dev-env] No login required for dev-env
|
|
48
|
+
- #911 Adds more release instructions
|
|
49
|
+
|
|
30
50
|
### 2.3.1 (2 November 2021)
|
|
31
51
|
- Fixes an issue with the 2.3.0 where the intended changes didn't get published correctly.
|
|
32
52
|
|
|
Binary file
|
package/config/config.json
CHANGED
|
@@ -82,6 +82,10 @@ async function deleteEnvVarCommand(arg, opt) {
|
|
|
82
82
|
});
|
|
83
83
|
await (0, _tracker.trackEvent)('envvar_delete_command_success', trackingParams);
|
|
84
84
|
console.log(_chalk.default.green(`Successfully deleted environment variable ${JSON.stringify(name)}`));
|
|
85
|
+
|
|
86
|
+
if (!opt.skipConfirmation) {
|
|
87
|
+
console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
(0, _command.default)({
|
|
@@ -101,6 +101,10 @@ async function setEnvVarCommand(arg, opt) {
|
|
|
101
101
|
});
|
|
102
102
|
await (0, _tracker.trackEvent)('envvar_set_command_success', trackingParams);
|
|
103
103
|
console.log(_chalk.default.green(`Successfully set environment variable ${JSON.stringify(name)}`));
|
|
104
|
+
|
|
105
|
+
if (!opt.skipConfirmation) {
|
|
106
|
+
console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
(0, _command.default)({
|
|
@@ -50,23 +50,14 @@ const examples = [{
|
|
|
50
50
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite --wordpress "5.8" --client-code "~/git/my_code"`,
|
|
51
51
|
description: 'Creates a local multisite dev environment using WP 5.8 and client code is expected to be in "~/git/my_code"'
|
|
52
52
|
}];
|
|
53
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site
|
|
53
|
+
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 => {
|
|
54
54
|
var _value$toLowerCase;
|
|
55
55
|
|
|
56
56
|
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}).option('phpmyadmin', 'Enable PHPMyAdmin component. By default it is disabled', undefined, value => {
|
|
62
|
-
var _value$toLowerCase3;
|
|
63
|
-
|
|
64
|
-
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase3 = value.toLowerCase) === null || _value$toLowerCase3 === void 0 ? void 0 : _value$toLowerCase3.call(value));
|
|
65
|
-
}).option('xdebug', 'Enable XDebug. By default it is disabled', undefined, value => {
|
|
66
|
-
var _value$toLowerCase4;
|
|
67
|
-
|
|
68
|
-
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase4 = value.toLowerCase) === null || _value$toLowerCase4 === void 0 ? void 0 : _value$toLowerCase4.call(value));
|
|
69
|
-
}).option('elasticsearch', 'Explicitly choose Elasticsearch version to use').option('mariadb', 'Explicitly choose MariaDB version to use').option('media-redirect-domain', 'Domain to redirect for missing media files. This can be used to still have images without the need to import them locally.').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
57
|
+
});
|
|
58
|
+
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
59
|
+
cmd.examples(examples);
|
|
60
|
+
cmd.argv(process.argv, async (arg, opt) => {
|
|
70
61
|
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
71
62
|
debug('Args: ', arg, 'Options: ', opt);
|
|
72
63
|
|
|
@@ -79,11 +70,12 @@ const examples = [{
|
|
|
79
70
|
exit.withError(messageToShow);
|
|
80
71
|
}
|
|
81
72
|
|
|
82
|
-
let
|
|
73
|
+
let defaultOptions = {};
|
|
83
74
|
|
|
84
75
|
try {
|
|
85
76
|
if (opt.app) {
|
|
86
|
-
appInfo = await (0, _devEnvironmentCore.getApplicationInformation)(opt.app, opt.env);
|
|
77
|
+
const appInfo = await (0, _devEnvironmentCore.getApplicationInformation)(opt.app, opt.env);
|
|
78
|
+
defaultOptions = (0, _devEnvironmentCli.getOptionsFromAppInfo)(appInfo);
|
|
87
79
|
}
|
|
88
80
|
} catch (error) {
|
|
89
81
|
const message = `failed to fetch application "${opt.app}" information`;
|
|
@@ -91,16 +83,11 @@ const examples = [{
|
|
|
91
83
|
console.log(_chalk.default.yellow('Warning:'), message);
|
|
92
84
|
}
|
|
93
85
|
|
|
94
|
-
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(opt,
|
|
95
|
-
|
|
96
|
-
siteSlug: slug,
|
|
97
|
-
statsd: opt.statsd || false,
|
|
98
|
-
phpmyadmin: opt.phpmyadmin || false,
|
|
99
|
-
xdebug: opt.xdebug || false
|
|
100
|
-
};
|
|
86
|
+
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(opt, defaultOptions);
|
|
87
|
+
instanceData.siteSlug = slug;
|
|
101
88
|
|
|
102
89
|
try {
|
|
103
|
-
await (0, _devEnvironmentCore.createEnvironment)(
|
|
90
|
+
await (0, _devEnvironmentCore.createEnvironment)(instanceData);
|
|
104
91
|
await (0, _devEnvironmentCore.printEnvironmentInfo)(slug);
|
|
105
92
|
const message = '\n' + _chalk.default.green('✓') + ` environment created.\n\nTo start it please run:\n\n${startCommand}\n`;
|
|
106
93
|
console.log(message);
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
14
14
|
|
|
15
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
+
|
|
15
17
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
16
18
|
|
|
17
19
|
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
@@ -62,8 +64,17 @@ const examples = [{
|
|
|
62
64
|
|
|
63
65
|
const cacheArg = ['wp', 'cache', 'flush'];
|
|
64
66
|
await (0, _devEnvironmentCore.exec)(slug, cacheArg);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const addUserArg = ['wp', 'user', 'create', 'vipgo', 'vipgo@go-vip.net', '--user_pass=password', '--role=administrator'];
|
|
70
|
+
await (0, _devEnvironmentCore.exec)(slug, addUserArg);
|
|
71
|
+
} catch (exception) {
|
|
72
|
+
if ((exception.message || '').includes('is already registered')) {
|
|
73
|
+
console.log(_chalk.default.bold(_chalk.default.green('Success: ')) + 'Skipping user vipgo provisioning');
|
|
74
|
+
} else {
|
|
75
|
+
throw exception;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
67
78
|
} catch (error) {
|
|
68
79
|
(0, _devEnvironmentCli.handleCLIException)(error);
|
|
69
80
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
+
|
|
19
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
20
|
+
|
|
21
|
+
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
22
|
+
|
|
23
|
+
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
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} update`,
|
|
33
|
+
description: 'Retriggers setup wizard in order to change environment configuration'
|
|
34
|
+
}];
|
|
35
|
+
const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment');
|
|
36
|
+
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
37
|
+
cmd.examples(examples);
|
|
38
|
+
cmd.argv(process.argv, async (arg, opt) => {
|
|
39
|
+
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
43
|
+
|
|
44
|
+
if (!environmentAlreadyExists) {
|
|
45
|
+
throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const currentInstanceData = (0, _devEnvironmentCore.readEnvironmentData)(slug);
|
|
49
|
+
debug('Read instance data', currentInstanceData);
|
|
50
|
+
const preselectedOptions = {
|
|
51
|
+
// Title and multisite can't be changed during update
|
|
52
|
+
title: currentInstanceData.wpTitle,
|
|
53
|
+
multisite: currentInstanceData.multisite,
|
|
54
|
+
...opt
|
|
55
|
+
};
|
|
56
|
+
const defaultOptions = {
|
|
57
|
+
clientCode: currentInstanceData.clientCode.dir || currentInstanceData.clientCode.tag || 'latest',
|
|
58
|
+
muPlugins: currentInstanceData.muPlugins.dir || currentInstanceData.muPlugins.tag || 'latest',
|
|
59
|
+
wordpress: currentInstanceData.wordpress.tag,
|
|
60
|
+
elasticsearch: currentInstanceData.elasticsearch,
|
|
61
|
+
mariadb: currentInstanceData.mariadb,
|
|
62
|
+
statsd: currentInstanceData.statsd,
|
|
63
|
+
phpmyadmin: currentInstanceData.phpmyadmin,
|
|
64
|
+
xdebug: currentInstanceData.xdebug,
|
|
65
|
+
mediaRedirectDomain: currentInstanceData.mediaRedirectDomain
|
|
66
|
+
};
|
|
67
|
+
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(preselectedOptions, defaultOptions);
|
|
68
|
+
instanceData.siteSlug = slug;
|
|
69
|
+
await (0, _devEnvironmentCore.updateEnvironment)(instanceData);
|
|
70
|
+
const message = '\n' + _chalk.default.green('✓') + ' environment updated. Restart environment for changes to take an affect.';
|
|
71
|
+
console.log(message);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if ('ENOENT' === error.code) {
|
|
74
|
+
const message = 'Environment was created before update was supported.\n\nTo update environment please destroy it and create a new one.';
|
|
75
|
+
(0, _devEnvironmentCli.handleCLIException)(new Error(message));
|
|
76
|
+
} else {
|
|
77
|
+
(0, _devEnvironmentCli.handleCLIException)(error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
package/dist/bin/vip-dev-env.js
CHANGED
|
@@ -20,4 +20,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
|
|
21
21
|
(0, _command.default)({
|
|
22
22
|
requiredArgs: 1
|
|
23
|
-
}).command('create', 'Create a new local dev environment').command('start', 'Start a local dev environment').command('stop', 'Stop a local dev environment').command('destroy', 'Remove containers, networks, volumes and configuration files of a local dev environment').command('info', 'Provides basic info about one or multiple local dev environments').command('exec', 'Execute an operation on a dev environment').command('import', 'Import data into a local WordPress environment').argv(process.argv);
|
|
23
|
+
}).command('create', 'Create a new local dev environment').command('update', 'Update an already created local dev environment').command('start', 'Start a local dev environment').command('stop', 'Stop a local dev environment').command('destroy', 'Remove containers, networks, volumes and configuration files of a local dev environment').command('info', 'Provides basic info about one or multiple local dev environments').command('exec', 'Execute an operation on a dev environment').command('import', 'Import data into a local WordPress environment').argv(process.argv);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @fomat
|
|
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 _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
+
|
|
19
|
+
var _devEnvironment = require("../lib/dev-environment");
|
|
20
|
+
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Internal dependencies
|
|
25
|
+
*/
|
|
26
|
+
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment'); // Command examples
|
|
27
|
+
|
|
28
|
+
const examples = [{
|
|
29
|
+
usage: 'vip dev-environment start',
|
|
30
|
+
description: 'Starts local dev environment\n' + ' * If the environment isn\'t built yet it will build it as well'
|
|
31
|
+
}];
|
|
32
|
+
(0, _command.default)().option('slug', `Custom name of the dev environment (default: "${_devEnvironment.defaults.environmentSlug}")`).option('title', 'Title for the WordPress site (default: "VIP Dev")').option('multisite', 'Enable multisite install').option('php', 'Use a specific PHP version').option('wordpress', 'Use a specific WordPress version or local directory (default: last stable)').option('mu-plugins', 'Use a specific mu-plugins changeset or local directory (default: "auto": last commit in master)').option('jetpack', 'Use a specific Jetpack from a local directory (default: "mu": use the version in mu-plugins)').option('client-code', 'Use the client code from a local directory or VIP skeleton (default: use the VIP skeleton)').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
33
|
+
const slug = opt.slug || _devEnvironment.defaults.environmentSlug;
|
|
34
|
+
debug('Args: ', arg, 'Options: ', opt);
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
await (0, _devEnvironment.startEnvironment)(slug, opt);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.log(_chalk.default.red('Error:'), e.message);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @fomat
|
|
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('start', 'Start the local dev environment').argv(process.argv);
|
|
File without changes
|
|
File without changes
|
package/dist/bin/vip-import.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal dependencies
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.getLogs = getLogs;
|
|
12
|
+
exports.validateInputs = validateInputs;
|
|
13
|
+
exports.appQuery = void 0;
|
|
14
|
+
|
|
15
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
16
|
+
|
|
17
|
+
var _rollbar = require("../lib/rollbar");
|
|
18
|
+
|
|
19
|
+
var _tracker = require("../lib/tracker");
|
|
20
|
+
|
|
21
|
+
var logsLib = _interopRequireWildcard(require("../lib/logs/logs"));
|
|
22
|
+
|
|
23
|
+
var exit = _interopRequireWildcard(require("../lib/cli/exit"));
|
|
24
|
+
|
|
25
|
+
var _format = require("../lib/cli/format");
|
|
26
|
+
|
|
27
|
+
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); }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
31
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
+
|
|
33
|
+
const LIMIT_MAX = 5000;
|
|
34
|
+
const LIMIT_MIN = 1;
|
|
35
|
+
const ALLOWED_TYPES = ['app', 'batch'];
|
|
36
|
+
const ALLOWED_FORMATS = ['csv', 'json', 'text'];
|
|
37
|
+
|
|
38
|
+
async function getLogs(arg, opt) {
|
|
39
|
+
validateInputs(opt.type, opt.limit, opt.format);
|
|
40
|
+
const trackingParams = {
|
|
41
|
+
command: 'vip logs',
|
|
42
|
+
org_id: opt.app.organization.id,
|
|
43
|
+
app_id: opt.app.id,
|
|
44
|
+
env_id: opt.env.id,
|
|
45
|
+
type: opt.type,
|
|
46
|
+
limit: opt.limit,
|
|
47
|
+
format: opt.format
|
|
48
|
+
};
|
|
49
|
+
await (0, _tracker.trackEvent)('logs_command_execute', trackingParams);
|
|
50
|
+
let logs = [];
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
logs = await logsLib.getRecentLogs(opt.app.id, opt.env.id, opt.type, opt.limit);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
_rollbar.rollbar.error(error);
|
|
56
|
+
|
|
57
|
+
await (0, _tracker.trackEvent)('logs_command_error', { ...trackingParams,
|
|
58
|
+
error: error.message
|
|
59
|
+
});
|
|
60
|
+
return exit.withError(error.message);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await (0, _tracker.trackEvent)('logs_command_success', { ...trackingParams,
|
|
64
|
+
logs_output: logs.length
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (!logs.length) {
|
|
68
|
+
console.error('No logs found');
|
|
69
|
+
return;
|
|
70
|
+
} // Strip out __typename
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
logs = logs.map(log => {
|
|
74
|
+
const {
|
|
75
|
+
timestamp,
|
|
76
|
+
message
|
|
77
|
+
} = log;
|
|
78
|
+
return {
|
|
79
|
+
timestamp,
|
|
80
|
+
message
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
let output = '';
|
|
84
|
+
|
|
85
|
+
if (opt.format && 'text' === opt.format) {
|
|
86
|
+
const rows = [];
|
|
87
|
+
|
|
88
|
+
for (const {
|
|
89
|
+
timestamp,
|
|
90
|
+
message
|
|
91
|
+
} of logs) {
|
|
92
|
+
rows.push(`${timestamp} ${message}`);
|
|
93
|
+
output = rows.join('\n');
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
output = (0, _format.formatData)(logs, opt.format);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
console.log(output);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function validateInputs(type, limit, format) {
|
|
103
|
+
if (!ALLOWED_TYPES.includes(type)) {
|
|
104
|
+
exit.withError(`Invalid type: ${type}. The supported types are: ${ALLOWED_TYPES.join(', ')}.`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!ALLOWED_FORMATS.includes(format)) {
|
|
108
|
+
exit.withError(`Invalid format: ${format}. The supported formats are: ${ALLOWED_FORMATS.join(', ')}.`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!Number.isInteger(limit) || limit < LIMIT_MIN || limit > LIMIT_MAX) {
|
|
112
|
+
exit.withError(`Invalid limit: ${limit}. It should be a number between ${LIMIT_MIN} and ${LIMIT_MAX}.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const appQuery = `
|
|
117
|
+
id
|
|
118
|
+
name
|
|
119
|
+
environments {
|
|
120
|
+
id
|
|
121
|
+
appId
|
|
122
|
+
name
|
|
123
|
+
type
|
|
124
|
+
}
|
|
125
|
+
organization {
|
|
126
|
+
id
|
|
127
|
+
name
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
exports.appQuery = appQuery;
|
|
131
|
+
(0, _command.default)({
|
|
132
|
+
appContext: true,
|
|
133
|
+
appQuery,
|
|
134
|
+
envContext: true,
|
|
135
|
+
module: 'logs'
|
|
136
|
+
}).option('type', 'The type of logs to be returned: "app" or "batch"', 'app').option('limit', 'The maximum number of log lines', 500).option('format', 'Output the log lines in CSV or JSON format', 'text').examples([{
|
|
137
|
+
usage: 'vip @mysite.production logs',
|
|
138
|
+
description: 'Get the most recent app logs'
|
|
139
|
+
}, {
|
|
140
|
+
usage: 'vip @mysite.production logs --type batch',
|
|
141
|
+
description: 'Get the most recent batch logs'
|
|
142
|
+
}, {
|
|
143
|
+
usage: 'vip @mysite.production logs --limit 100',
|
|
144
|
+
description: 'Get the most recent 100 log entries'
|
|
145
|
+
}, {
|
|
146
|
+
usage: 'vip @mysite.production logs --limit 100 --format csv',
|
|
147
|
+
description: 'Get the most recent 100 log entries formatted as comma-separated values (CSV)'
|
|
148
|
+
}, {
|
|
149
|
+
usage: 'vip @mysite.production logs --limit 100 --format json',
|
|
150
|
+
description: 'Get the most recent 100 log entries formatted as JSON'
|
|
151
|
+
}]).argv(process.argv, getLogs);
|
package/dist/bin/vip.js
CHANGED
|
@@ -15,7 +15,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
15
15
|
|
|
16
16
|
var _config = _interopRequireDefault(require("../../config/config.json"));
|
|
17
17
|
|
|
18
|
-
var _command =
|
|
18
|
+
var _command = _interopRequireWildcard(require("../lib/cli/command"));
|
|
19
19
|
|
|
20
20
|
var _token = _interopRequireDefault(require("../lib/token"));
|
|
21
21
|
|
|
@@ -23,6 +23,10 @@ var _tracker = require("../lib/tracker");
|
|
|
23
23
|
|
|
24
24
|
var _rollbar = require("../lib/rollbar");
|
|
25
25
|
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
26
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
31
|
|
|
28
32
|
/**
|
|
@@ -44,7 +48,7 @@ const runCmd = async function () {
|
|
|
44
48
|
await _token.default.purge();
|
|
45
49
|
await (0, _tracker.trackEvent)('logout_command_execute');
|
|
46
50
|
console.log('You are successfully logged out.');
|
|
47
|
-
}).command('app', 'List and modify your VIP applications').command('config', 'Set configuration for your VIP applications').command('dev-env', 'Use local dev-environment').command('import', 'Import media or SQL files into your VIP applications').command('search-replace', 'Perform search and replace tasks on files').command('sync', 'Sync production to a development environment').command('wp', 'Run WP CLI commands against an environment');
|
|
51
|
+
}).command('app', 'List and modify your VIP applications').command('config', 'Set configuration for your VIP applications').command('dev-env', 'Use local dev-environment').command('import', 'Import media or SQL files into your VIP applications').command('logs', 'Get logs from your VIP applications').command('search-replace', 'Perform search and replace tasks on files').command('sync', 'Sync production to a development environment').command('wp', 'Run WP CLI commands against an environment');
|
|
48
52
|
cmd.argv(process.argv);
|
|
49
53
|
};
|
|
50
54
|
|
|
@@ -52,9 +56,10 @@ const rootCmd = async function () {
|
|
|
52
56
|
let token = await _token.default.get();
|
|
53
57
|
const isHelpCommand = process.argv.some(arg => arg === 'help' || arg === '-h' || arg === '--help');
|
|
54
58
|
const isLogoutCommand = process.argv.some(arg => arg === 'logout');
|
|
59
|
+
const isDevEnvCommandWithoutEnv = process.argv.some(arg => arg === 'dev-env') && !(0, _command.containsAppEnvArgument)(process.argv);
|
|
55
60
|
debug('Argv:', process.argv);
|
|
56
61
|
|
|
57
|
-
if (isLogoutCommand || isHelpCommand || token && token.valid()) {
|
|
62
|
+
if (isLogoutCommand || isHelpCommand || isDevEnvCommandWithoutEnv || token && token.valid()) {
|
|
58
63
|
runCmd();
|
|
59
64
|
} else {
|
|
60
65
|
console.log();
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
7
|
exports.getEnvIdentifier = getEnvIdentifier;
|
|
8
|
+
exports.containsAppEnvArgument = containsAppEnvArgument;
|
|
8
9
|
|
|
9
10
|
var _args = _interopRequireDefault(require("args"));
|
|
10
11
|
|
|
@@ -587,4 +588,9 @@ function getEnvIdentifier(env) {
|
|
|
587
588
|
}
|
|
588
589
|
|
|
589
590
|
return identifier;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function containsAppEnvArgument(argv) {
|
|
594
|
+
const parsedAlias = (0, _envAlias.parseEnvAliasFromArgv)(argv);
|
|
595
|
+
return !!(parsedAlias.app || parsedAlias.env || argv.includes('--app') || argv.includes('--env'));
|
|
590
596
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DEV_ENVIRONMENT_COMPONENTS = exports.DEV_ENVIRONMENT_PROMPT_INTRO = exports.DEV_ENVIRONMENT_DEFAULTS = exports.DEV_ENVIRONMENT_FULL_COMMAND = exports.DEV_ENVIRONMENT_SUBCOMMAND = void 0;
|
|
6
|
+
exports.DEV_ENVIRONMENT_COMPONENTS = exports.DEV_ENVIRONMENT_NOT_FOUND = exports.DEV_ENVIRONMENT_PROMPT_INTRO = exports.DEV_ENVIRONMENT_DEFAULTS = exports.DEV_ENVIRONMENT_FULL_COMMAND = exports.DEV_ENVIRONMENT_SUBCOMMAND = void 0;
|
|
7
7
|
const DEV_ENVIRONMENT_SUBCOMMAND = 'dev-env';
|
|
8
8
|
exports.DEV_ENVIRONMENT_SUBCOMMAND = DEV_ENVIRONMENT_SUBCOMMAND;
|
|
9
9
|
const DEV_ENVIRONMENT_FULL_COMMAND = `vip ${DEV_ENVIRONMENT_SUBCOMMAND}`;
|
|
@@ -17,5 +17,7 @@ const DEV_ENVIRONMENT_DEFAULTS = {
|
|
|
17
17
|
exports.DEV_ENVIRONMENT_DEFAULTS = DEV_ENVIRONMENT_DEFAULTS;
|
|
18
18
|
const DEV_ENVIRONMENT_PROMPT_INTRO = 'This is a wizard to help you set up your local dev environment.\n\n' + 'Sensible default values were pre-selected for convenience. ' + 'You may also choose to create multiple environments with different settings using the --slug option.\n\n';
|
|
19
19
|
exports.DEV_ENVIRONMENT_PROMPT_INTRO = DEV_ENVIRONMENT_PROMPT_INTRO;
|
|
20
|
+
const DEV_ENVIRONMENT_NOT_FOUND = 'Environment not found.';
|
|
21
|
+
exports.DEV_ENVIRONMENT_NOT_FOUND = DEV_ENVIRONMENT_NOT_FOUND;
|
|
20
22
|
const DEV_ENVIRONMENT_COMPONENTS = ['wordpress', 'muPlugins', 'clientCode'];
|
|
21
23
|
exports.DEV_ENVIRONMENT_COMPONENTS = DEV_ENVIRONMENT_COMPONENTS;
|