@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
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Then, launch the command and follow the prompts:
|
|
|
14
14
|
vip
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
If you need more information, check out our [VIP
|
|
17
|
+
If you need more information, check out our [VIP-CLI documentation](https://docs.wpvip.com/technical-references/vip-cli/).
|
|
18
18
|
|
|
19
19
|
## Contributing
|
|
20
20
|
|
|
@@ -26,6 +26,30 @@ By default, we record information about the usage of this tool using an in-house
|
|
|
26
26
|
|
|
27
27
|
## Changelog
|
|
28
28
|
|
|
29
|
+
### 2.14.0 (19 Jul 2022)
|
|
30
|
+
|
|
31
|
+
- #1059 Update engines to show support for npm > 6
|
|
32
|
+
- #1058 [dev-env] switch dev-env error during import to warning
|
|
33
|
+
- #1057 [dev-env] Update debug instruction example
|
|
34
|
+
- #1055 [dev-env] Makes exec attempt to run the task even if env seems to be down
|
|
35
|
+
|
|
36
|
+
### 2.13.1 (20 Jun 2022)
|
|
37
|
+
|
|
38
|
+
- #1052 [dev-env] Update/lando compose version
|
|
39
|
+
- #1045 README: Fix Typo `VIP CLI` => `VIP-CLI`
|
|
40
|
+
- #1048 Switch to GitHub Actions
|
|
41
|
+
|
|
42
|
+
### 2.13.0 (16 Jun 2022)
|
|
43
|
+
|
|
44
|
+
- #1046 Add Cache Purge Command
|
|
45
|
+
- #1050 [dev-env] Change docs link
|
|
46
|
+
- #1047 [dev-env] Bump lando package
|
|
47
|
+
- #1044 [dev-env] Fix healthchecks No. 2
|
|
48
|
+
- #1043 [dev-env] add docker-compose v2 support
|
|
49
|
+
- #1042 [dev-env] Fix search popup during wizard
|
|
50
|
+
- #1038 [dev-env] Adds domain validation during sql import
|
|
51
|
+
- #1040 [dev-env] track dev-env start time in seconds
|
|
52
|
+
|
|
29
53
|
### 2.12.0 (19 May 2022)
|
|
30
54
|
|
|
31
55
|
- #1035 and #1032 Improved publishing checks to publish on npm
|
|
@@ -35,7 +59,7 @@ By default, we record information about the usage of this tool using an in-house
|
|
|
35
59
|
- #1033 [dev-env] Bump lando in order to support node 18
|
|
36
60
|
|
|
37
61
|
#### Special thanks
|
|
38
|
-
frank-cerny for the contribution on #
|
|
62
|
+
frank-cerny for the contribution on #999
|
|
39
63
|
|
|
40
64
|
### 2.11.2 (12 May 2022)
|
|
41
65
|
|
|
@@ -212,7 +236,7 @@ Fixes:
|
|
|
212
236
|
- #844 Expose DB and expose extra services in info table
|
|
213
237
|
- #865 spawn WP-CLI as root to allow for FS operations
|
|
214
238
|
- #895 Fix rmdir deprecation warning
|
|
215
|
-
- #870 Add the VIP
|
|
239
|
+
- #870 Add the VIP-CLI release process and release schedule
|
|
216
240
|
|
|
217
241
|
Dependencies updates:
|
|
218
242
|
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", {
|
|
18
|
+
value: true
|
|
19
|
+
});
|
|
20
|
+
exports.cachePurgeCommand = cachePurgeCommand;
|
|
21
|
+
|
|
22
|
+
var _cachePurge = require("../lib/api/cache-purge");
|
|
23
|
+
|
|
24
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
25
|
+
|
|
26
|
+
var _tracker = require("../lib/tracker");
|
|
27
|
+
|
|
28
|
+
var _readFile = require("../lib/read-file");
|
|
29
|
+
|
|
30
|
+
var exit = _interopRequireWildcard(require("../lib/cli/exit"));
|
|
31
|
+
|
|
32
|
+
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); }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
|
|
38
|
+
const examples = [{
|
|
39
|
+
usage: 'vip cache purge-url <URL>',
|
|
40
|
+
description: 'Purge a URL from page cache'
|
|
41
|
+
}, {
|
|
42
|
+
usage: 'vip cache purge-url --from-file=/dev/vip/urls.txt',
|
|
43
|
+
description: 'Purge multiple URLs from page cache'
|
|
44
|
+
}];
|
|
45
|
+
|
|
46
|
+
async function cachePurgeCommand(urls = [], opt = {}) {
|
|
47
|
+
const trackingParams = {
|
|
48
|
+
app_id: opt.app.id,
|
|
49
|
+
command: 'vip cache purge-url',
|
|
50
|
+
env_id: opt.env.id,
|
|
51
|
+
from_file: !!opt.fromFile
|
|
52
|
+
};
|
|
53
|
+
await (0, _tracker.trackEvent)('cache_purge_url_command_execute', trackingParams);
|
|
54
|
+
|
|
55
|
+
if (opt.fromFile) {
|
|
56
|
+
const value = await (0, _readFile.readFromFile)(opt.fromFile);
|
|
57
|
+
|
|
58
|
+
if (value) {
|
|
59
|
+
urls = value.split('\n').map(url => url.trim());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!urls.length) {
|
|
64
|
+
await (0, _tracker.trackEvent)('cache_purge_url_command_error', { ...trackingParams,
|
|
65
|
+
error: 'No URL provided'
|
|
66
|
+
});
|
|
67
|
+
exit.withError('Please supply at least one URL.');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let purgeCacheObject = {};
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
purgeCacheObject = await (0, _cachePurge.purgeCache)(opt.app.id, opt.env.id, urls);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
await (0, _tracker.trackEvent)('cache_purge_url_command_error', { ...trackingParams,
|
|
76
|
+
error: err.message
|
|
77
|
+
});
|
|
78
|
+
exit.withError(`Failed to purge URL(s) from page cache: ${err.message}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await (0, _tracker.trackEvent)('cache_purge_url_command_success', trackingParams);
|
|
82
|
+
purgeCacheObject.urls.forEach(url => {
|
|
83
|
+
console.log(`- Purged URL: ${url}`);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
(0, _command.default)({
|
|
88
|
+
appContext: true,
|
|
89
|
+
appQuery: _cachePurge.appQuery,
|
|
90
|
+
envContext: true,
|
|
91
|
+
wildcardCommand: true,
|
|
92
|
+
usage: 'vip cache purge-url <URL>'
|
|
93
|
+
}).option('from-file', 'Read URLs from file (useful to purge multiple URLs)').examples(examples).argv(process.argv, cachePurgeCommand);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
9
|
* External dependencies
|
|
5
10
|
*/
|
|
@@ -15,6 +20,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
20
|
|
|
16
21
|
(0, _command.default)({
|
|
17
22
|
requiredArgs: 2
|
|
18
|
-
}).command('
|
|
19
|
-
process.exit(0);
|
|
20
|
-
});
|
|
23
|
+
}).command('purge-url', 'Purge page cache').argv(process.argv);
|
|
@@ -38,7 +38,11 @@ const examples = [{
|
|
|
38
38
|
}];
|
|
39
39
|
(0, _command.default)({
|
|
40
40
|
wildcardCommand: true
|
|
41
|
-
}).option('slug', 'Custom name of the dev environment').
|
|
41
|
+
}).option('slug', 'Custom name of the dev environment').option('force', 'Disabling validations before task execution', undefined, value => {
|
|
42
|
+
var _value$toLowerCase;
|
|
43
|
+
|
|
44
|
+
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
45
|
+
}).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
|
|
42
46
|
await (0, _devEnvironmentCli.validateDependencies)();
|
|
43
47
|
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
44
48
|
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
@@ -59,7 +63,10 @@ const examples = [{
|
|
|
59
63
|
arg = process.argv.slice(argSplitterIx + 1);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
const options = {
|
|
67
|
+
force: opt.force
|
|
68
|
+
};
|
|
69
|
+
await (0, _devEnvironmentCore.exec)(slug, arg, options);
|
|
63
70
|
await (0, _tracker.trackEvent)('dev_env_exec_command_success', trackingInfo);
|
|
64
71
|
} catch (error) {
|
|
65
72
|
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_exec_command_error', trackingInfo);
|
|
@@ -62,7 +62,14 @@ const examples = [{
|
|
|
62
62
|
} = await (0, _devEnvironmentCore.resolveImportPath)(slug, fileName, searchReplace, inPlace);
|
|
63
63
|
|
|
64
64
|
if (!opt.skipValidate) {
|
|
65
|
-
|
|
65
|
+
const expectedDomain = `${slug}.vipdev.lndo.site`;
|
|
66
|
+
await (0, _sql.validate)(resolvedPath, {
|
|
67
|
+
isImport: false,
|
|
68
|
+
skipChecks: [],
|
|
69
|
+
extraCheckParams: {
|
|
70
|
+
siteHomeUrlLando: expectedDomain
|
|
71
|
+
}
|
|
72
|
+
});
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
const importArg = ['wp', 'db', 'import', inContainerPath];
|
|
@@ -66,7 +66,8 @@ const examples = [{
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
await (0, _devEnvironmentCore.startEnvironment)(slug, options);
|
|
69
|
-
const processingTime = new Date() - startProcessing;
|
|
69
|
+
const processingTime = Math.ceil((new Date() - startProcessing) / 1000); // in seconds
|
|
70
|
+
|
|
70
71
|
const successTrackingInfo = { ...trackingInfo,
|
|
71
72
|
processing_time: processingTime
|
|
72
73
|
};
|
|
@@ -68,6 +68,7 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
68
68
|
statsd: currentInstanceData.statsd,
|
|
69
69
|
phpmyadmin: currentInstanceData.phpmyadmin,
|
|
70
70
|
xdebug: currentInstanceData.xdebug,
|
|
71
|
+
enterpriseSearchEnabled: currentInstanceData.enterpriseSearchEnabled,
|
|
71
72
|
mediaRedirectDomain: currentInstanceData.mediaRedirectDomain,
|
|
72
73
|
multisite: false,
|
|
73
74
|
title: ''
|
package/dist/bin/vip.js
CHANGED
|
@@ -48,7 +48,7 @@ const runCmd = async function () {
|
|
|
48
48
|
await _token.default.purge();
|
|
49
49
|
await (0, _tracker.trackEvent)('logout_command_execute');
|
|
50
50
|
console.log('You are successfully logged out.');
|
|
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('whoami', 'Display details about the currently logged-in user').command('wp', 'Run WP CLI commands against an environment');
|
|
51
|
+
}).command('app', 'List and modify your VIP applications').command('cache', 'Manage page cache for 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('whoami', 'Display details about the currently logged-in user').command('wp', 'Run WP CLI commands against an environment');
|
|
52
52
|
cmd.argv(process.argv);
|
|
53
53
|
};
|
|
54
54
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.purgeCache = purgeCache;
|
|
7
|
+
exports.appQuery = void 0;
|
|
8
|
+
|
|
9
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
10
|
+
|
|
11
|
+
var _api = _interopRequireDefault(require("../api"));
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @format
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* External dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
const mutation = (0, _graphqlTag.default)`
|
|
28
|
+
mutation PurgePageCacheMutation(
|
|
29
|
+
$appId: Int!
|
|
30
|
+
$envId: Int!
|
|
31
|
+
$urls: [String!]!
|
|
32
|
+
) {
|
|
33
|
+
purgePageCache( input: {
|
|
34
|
+
appId: $appId
|
|
35
|
+
environmentId: $envId
|
|
36
|
+
urls: $urls
|
|
37
|
+
} ) {
|
|
38
|
+
success
|
|
39
|
+
urls
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`; // The subquery for environments lets users choose any environment, including production.
|
|
43
|
+
|
|
44
|
+
const appQuery = `
|
|
45
|
+
id
|
|
46
|
+
name
|
|
47
|
+
environments {
|
|
48
|
+
id
|
|
49
|
+
appId
|
|
50
|
+
name
|
|
51
|
+
primaryDomain {
|
|
52
|
+
name
|
|
53
|
+
}
|
|
54
|
+
type
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
exports.appQuery = appQuery;
|
|
58
|
+
|
|
59
|
+
async function purgeCache(appId, envId, urls) {
|
|
60
|
+
const api = await (0, _api.default)();
|
|
61
|
+
const variables = {
|
|
62
|
+
appId,
|
|
63
|
+
envId,
|
|
64
|
+
urls
|
|
65
|
+
};
|
|
66
|
+
const response = await api.mutate({
|
|
67
|
+
mutation,
|
|
68
|
+
variables
|
|
69
|
+
});
|
|
70
|
+
const {
|
|
71
|
+
data: {
|
|
72
|
+
purgePageCache
|
|
73
|
+
}
|
|
74
|
+
} = response;
|
|
75
|
+
return purgePageCache;
|
|
76
|
+
}
|
|
@@ -91,9 +91,9 @@ async function handleCLIException(exception, trackKey, trackBaseInfo = {}) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (!process.env.DEBUG) {
|
|
94
|
-
console.log(
|
|
94
|
+
console.log(`\nPlease re-run the command with "--debug ${_chalk.default.bold('@automattic/vip:bin:dev-environment')}" appended to it and provide the stack trace on the support ticket.`);
|
|
95
95
|
console.log(_chalk.default.bold('\nExample:\n'));
|
|
96
|
-
console.log('vip dev-env
|
|
96
|
+
console.log('vip dev-env <command> <arguments> --debug @automattic/vip:bin:dev-environment \n');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
debug(exception);
|
|
@@ -213,8 +213,8 @@ async function printEnvironmentInfo(slug) {
|
|
|
213
213
|
(0, _devEnvironmentCli.printTable)(appInfo);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
async function exec(slug, args) {
|
|
217
|
-
debug('Will run a wp command on env', slug, 'with args', args);
|
|
216
|
+
async function exec(slug, args, options = {}) {
|
|
217
|
+
debug('Will run a wp command on env', slug, 'with args', args, ' and options', options);
|
|
218
218
|
const instancePath = getEnvironmentPath(slug);
|
|
219
219
|
debug('Instance path for', slug, 'is:', instancePath);
|
|
220
220
|
|
|
@@ -231,7 +231,7 @@ async function exec(slug, args) {
|
|
|
231
231
|
commandArgs = [...args.map(argument => argument.replace('--new-site-', '--'))];
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
await (0, _devEnvironmentLando.landoExec)(instancePath, command, commandArgs);
|
|
234
|
+
await (0, _devEnvironmentLando.landoExec)(instancePath, command, commandArgs, options);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
function doesEnvironmentExist(slug) {
|
|
@@ -110,14 +110,42 @@ function addHooks(app, lando) {
|
|
|
110
110
|
app.events.on('post-start', 1, () => healthcheckHook(app, lando));
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
const healthChecks = {
|
|
114
|
+
database: 'mysql -uroot --silent --execute "SHOW DATABASES;"',
|
|
115
|
+
'vip-search': "curl -s --noproxy '*' -XGET localhost:9200",
|
|
116
|
+
php: '[[ -f /wp/wp-includes/pomo/mo.php ]]'
|
|
117
|
+
};
|
|
118
|
+
|
|
113
119
|
async function healthcheckHook(app, lando) {
|
|
114
120
|
try {
|
|
115
121
|
await lando.Promise.retry(async () => {
|
|
116
122
|
const list = await lando.engine.list({
|
|
117
123
|
project: app.project
|
|
118
124
|
});
|
|
119
|
-
const
|
|
120
|
-
|
|
125
|
+
const notHealthyContainers = [];
|
|
126
|
+
|
|
127
|
+
for (const container of list) {
|
|
128
|
+
if (healthChecks[container.service]) {
|
|
129
|
+
try {
|
|
130
|
+
debug(`Testing ${container.service}: ${healthChecks[container.service]}`);
|
|
131
|
+
await app.engine.run({
|
|
132
|
+
id: container.id,
|
|
133
|
+
cmd: healthChecks[container.service],
|
|
134
|
+
compose: app.compose,
|
|
135
|
+
project: app.project,
|
|
136
|
+
opts: {
|
|
137
|
+
silent: true,
|
|
138
|
+
noTTY: true,
|
|
139
|
+
cstdio: 'pipe',
|
|
140
|
+
services: [container.service]
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
} catch (exception) {
|
|
144
|
+
debug(`${container.service} Health check failed`);
|
|
145
|
+
notHealthyContainers.push(container);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
121
149
|
|
|
122
150
|
if (notHealthyContainers.length) {
|
|
123
151
|
for (const container of notHealthyContainers) {
|
|
@@ -185,7 +213,7 @@ async function landoInfo(instancePath) {
|
|
|
185
213
|
} // Add documentation link
|
|
186
214
|
|
|
187
215
|
|
|
188
|
-
appInfo.Documentation = 'https://docs.wpvip.com/technical-references/vip-local-development-environment/
|
|
216
|
+
appInfo.Documentation = 'https://docs.wpvip.com/technical-references/vip-local-development-environment/';
|
|
189
217
|
return appInfo;
|
|
190
218
|
}
|
|
191
219
|
|
|
@@ -244,15 +272,18 @@ async function isEnvUp(app) {
|
|
|
244
272
|
return (scanResult === null || scanResult === void 0 ? void 0 : scanResult.length) && scanResult.filter(result => result.status).length === scanResult.length;
|
|
245
273
|
}
|
|
246
274
|
|
|
247
|
-
async function landoExec(instancePath, toolName, args) {
|
|
275
|
+
async function landoExec(instancePath, toolName, args, options) {
|
|
248
276
|
const lando = new _lando.default(getLandoConfig());
|
|
249
277
|
await lando.bootstrap();
|
|
250
278
|
const app = lando.getApp(instancePath);
|
|
251
279
|
await app.init();
|
|
252
|
-
const isUp = await isEnvUp(app);
|
|
253
280
|
|
|
254
|
-
if (!
|
|
255
|
-
|
|
281
|
+
if (!options.force) {
|
|
282
|
+
const isUp = await isEnvUp(app);
|
|
283
|
+
|
|
284
|
+
if (!isUp) {
|
|
285
|
+
throw new Error('environment needs to be started before running wp command');
|
|
286
|
+
}
|
|
256
287
|
}
|
|
257
288
|
|
|
258
289
|
const tool = app.config.tooling[toolName];
|
|
@@ -5,15 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.readVariableFromFile = readVariableFromFile;
|
|
7
7
|
|
|
8
|
-
var _fs = require("fs");
|
|
9
|
-
|
|
10
|
-
var exit = _interopRequireWildcard(require("../cli/exit"));
|
|
11
|
-
|
|
12
8
|
var _logging = require("./logging");
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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; }
|
|
10
|
+
var _readFile = require("../read-file");
|
|
17
11
|
|
|
18
12
|
/**
|
|
19
13
|
*
|
|
@@ -29,15 +23,5 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
29
23
|
*/
|
|
30
24
|
async function readVariableFromFile(path) {
|
|
31
25
|
(0, _logging.debug)(`Loading variable value from file ${JSON.stringify(path)}`);
|
|
32
|
-
|
|
33
|
-
message
|
|
34
|
-
}) => {
|
|
35
|
-
// Provide friendly version of common error.
|
|
36
|
-
if (message.startsWith('ENOENT: no such file or directory')) {
|
|
37
|
-
exit.withError(`Could not load file ${JSON.stringify(path)}.`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exit.withError(message);
|
|
41
|
-
});
|
|
42
|
-
return Buffer.from(data).toString().trim();
|
|
26
|
+
return await (0, _readFile.readFromFile)(path);
|
|
43
27
|
}
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.readFromFile = readFromFile;
|
|
7
7
|
|
|
8
8
|
var _fs = require("fs");
|
|
9
9
|
|
|
10
|
-
var exit = _interopRequireWildcard(require("
|
|
11
|
-
|
|
12
|
-
var _logging = require("./logging");
|
|
10
|
+
var exit = _interopRequireWildcard(require("./cli/exit"));
|
|
13
11
|
|
|
14
12
|
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); }
|
|
15
13
|
|
|
@@ -27,8 +25,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
25
|
/**
|
|
28
26
|
* Internal dependencies
|
|
29
27
|
*/
|
|
30
|
-
async function
|
|
31
|
-
(0, _logging.debug)(`Loading variable value from file ${JSON.stringify(path)}`);
|
|
28
|
+
async function readFromFile(path) {
|
|
32
29
|
const data = await _fs.promises.readFile(path, 'binary').catch(({
|
|
33
30
|
message
|
|
34
31
|
}) => {
|