@automattic/vip 2.11.2 → 2.13.1
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 +30 -2
- package/config/{config.json → config.publish.json} +0 -0
- 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-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-wp.js +2 -2
- package/dist/bin/vip.js +2 -2
- package/dist/lib/analytics/clients/stub.js +1 -1
- package/dist/lib/analytics/clients/tracks.js +0 -5
- package/dist/lib/analytics/index.js +13 -1
- package/dist/lib/api/cache-purge.js +76 -0
- package/dist/lib/api.js +2 -2
- package/dist/lib/cli/config.js +30 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +3 -0
- package/dist/lib/dev-environment/dev-environment-lando.js +31 -3
- package/dist/lib/envvar/read-file.js +2 -18
- package/dist/lib/http/proxy-agent.js +94 -0
- package/{package/dist/lib/envvar → dist/lib}/read-file.js +3 -6
- package/dist/lib/rollbar.js +1 -1
- package/dist/lib/tracker.js +1 -1
- package/dist/lib/validations/sql.js +134 -52
- package/npm-shrinkwrap.json +388 -202
- package/package.json +14 -9
- package/.circleci/config.yml +0 -67
- package/dist/lib/http/socks-proxy-agent.js +0 -25
- package/helpers/prepare-config.js +0 -19
- 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/vip.iml +0 -11
package/CONTRIBUTING.md
CHANGED
|
@@ -10,6 +10,11 @@ Tests are powered by [Jest](https://jestjs.io).
|
|
|
10
10
|
|
|
11
11
|
## Developing
|
|
12
12
|
|
|
13
|
+
### Node version
|
|
14
|
+
|
|
15
|
+
To develop use the minimum supported node version. You can take a look in the `package.json` `engines` configuration
|
|
16
|
+
or, if you use tools like `nvm` you can run `nvm use` to ensure you're running the right one.
|
|
17
|
+
|
|
13
18
|
### Local Dev
|
|
14
19
|
|
|
15
20
|
To test against a local instance of Parker, you can use the `API_HOST` env var. You'll also want to nullify the `VIP_PROXY` env var as well.
|
|
@@ -91,7 +96,7 @@ Then, let's publish:
|
|
|
91
96
|
1. Push the tag to GitHub (`git push --tags`)
|
|
92
97
|
1. Push the master branch `git push`
|
|
93
98
|
1. Make sure you're part of the Automattic organization in npm
|
|
94
|
-
1. Publish the release to npm (`npm run publish-please --access public`)
|
|
99
|
+
1. Publish the release to npm (`npm run publish-please --access public`) the script will do some extra checks (npm version, branch, etc) to ensure everything is correct. If all looks good, proceed.
|
|
95
100
|
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).
|
|
96
101
|
1. Push `master` changes (mostly the version bump) to `develop` (`git checkout develop && git merge master` )
|
|
97
102
|
|
|
@@ -127,4 +132,4 @@ Then, repeat for any additional versions that we need to patch.
|
|
|
127
132
|
|
|
128
133
|
Some unit tests require some go-search-replace executable binary files to run. Binaries files for several OS architectures can be downloaded from https://github.com/Automattic/go-search-replace/releases/
|
|
129
134
|
|
|
130
|
-
If, for some reason, you need to compile these binaries yourself, please follow instructions at https://github.com/Automattic/go-search-replace
|
|
135
|
+
If, for some reason, you need to compile these binaries yourself, please follow instructions at https://github.com/Automattic/go-search-replace
|
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,34 @@ By default, we record information about the usage of this tool using an in-house
|
|
|
26
26
|
|
|
27
27
|
## Changelog
|
|
28
28
|
|
|
29
|
+
### 2.13.1 (20 Jun 2022)
|
|
30
|
+
|
|
31
|
+
- #1052 [dev-env] Update/lando compose version
|
|
32
|
+
- #1045 README: Fix Typo `VIP CLI` => `VIP-CLI`
|
|
33
|
+
- #1048 Switch to GitHub Actions
|
|
34
|
+
|
|
35
|
+
### 2.13.0 (16 Jun 2022)
|
|
36
|
+
|
|
37
|
+
- #1046 Add Cache Purge Command
|
|
38
|
+
- #1050 [dev-env] Change docs link
|
|
39
|
+
- #1047 [dev-env] Bump lando package
|
|
40
|
+
- #1044 [dev-env] Fix healthchecks No. 2
|
|
41
|
+
- #1043 [dev-env] add docker-compose v2 support
|
|
42
|
+
- #1042 [dev-env] Fix search popup during wizard
|
|
43
|
+
- #1038 [dev-env] Adds domain validation during sql import
|
|
44
|
+
- #1040 [dev-env] track dev-env start time in seconds
|
|
45
|
+
|
|
46
|
+
### 2.12.0 (19 May 2022)
|
|
47
|
+
|
|
48
|
+
- #1035 and #1032 Improved publishing checks to publish on npm
|
|
49
|
+
- #1037 [dev-env] only record the php version numbers update/clean_php_version
|
|
50
|
+
- #999 Add Feature to Support HTTPS/HTTP/NO_PROXY Settings
|
|
51
|
+
- #1036 Move DO_NOT_TRACK handling to Analytics lib
|
|
52
|
+
- #1033 [dev-env] Bump lando in order to support node 18
|
|
53
|
+
|
|
54
|
+
#### Special thanks
|
|
55
|
+
frank-cerny for the contribution on #999
|
|
56
|
+
|
|
29
57
|
### 2.11.2 (12 May 2022)
|
|
30
58
|
|
|
31
59
|
- Hotfix to use correct production config.json in the NPM published package caused by a different NPM version in the build process.
|
|
@@ -201,7 +229,7 @@ Fixes:
|
|
|
201
229
|
- #844 Expose DB and expose extra services in info table
|
|
202
230
|
- #865 spawn WP-CLI as root to allow for FS operations
|
|
203
231
|
- #895 Fix rmdir deprecation warning
|
|
204
|
-
- #870 Add the VIP
|
|
232
|
+
- #870 Add the VIP-CLI release process and release schedule
|
|
205
233
|
|
|
206
234
|
Dependencies updates:
|
|
207
235
|
|
|
File without changes
|
|
@@ -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);
|
|
@@ -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-wp.js
CHANGED
|
@@ -35,7 +35,7 @@ var _token = _interopRequireDefault(require("../lib/token"));
|
|
|
35
35
|
|
|
36
36
|
var _rollbar = require("../lib/rollbar");
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _proxyAgent = require("../lib/http/proxy-agent");
|
|
39
39
|
|
|
40
40
|
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); }
|
|
41
41
|
|
|
@@ -487,7 +487,7 @@ const bindReconnectEvents = ({
|
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
},
|
|
490
|
-
agent: (0,
|
|
490
|
+
agent: (0, _proxyAgent.createProxyAgent)(_api.API_HOST)
|
|
491
491
|
});
|
|
492
492
|
currentJob = await launchCommandAndGetStreams({
|
|
493
493
|
socket,
|
package/dist/bin/vip.js
CHANGED
|
@@ -13,7 +13,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
13
13
|
|
|
14
14
|
var _debug = _interopRequireDefault(require("debug"));
|
|
15
15
|
|
|
16
|
-
var _config = _interopRequireDefault(require("
|
|
16
|
+
var _config = _interopRequireDefault(require("../lib/cli/config"));
|
|
17
17
|
|
|
18
18
|
var _command = _interopRequireWildcard(require("../lib/cli/command"));
|
|
19
19
|
|
|
@@ -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
|
|
|
@@ -100,11 +100,6 @@ class Tracks {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
send(extraParams) {
|
|
103
|
-
if (process.env.DO_NOT_TRACK) {
|
|
104
|
-
debug('send() => skipping per DO_NOT_TRACK variable');
|
|
105
|
-
return Promise.resolve('tracks disabled per DO_NOT_TRACK variable');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
103
|
const params = Object.assign({}, this.baseParams, extraParams);
|
|
109
104
|
const method = 'POST';
|
|
110
105
|
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
+
|
|
8
10
|
var _stub = _interopRequireDefault(require("./clients/stub"));
|
|
9
11
|
|
|
10
12
|
var _env = _interopRequireDefault(require("../env"));
|
|
@@ -12,10 +14,15 @@ var _env = _interopRequireDefault(require("../env"));
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
17
|
+
* External dependencies
|
|
16
18
|
*/
|
|
17
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
const debug = (0, _debug.default)('@automattic/vip:analytics');
|
|
18
24
|
/* eslint-disable camelcase */
|
|
25
|
+
|
|
19
26
|
const client_info = {
|
|
20
27
|
cli_version: _env.default.app.version,
|
|
21
28
|
os_name: _env.default.os.name,
|
|
@@ -32,6 +39,11 @@ class Analytics {
|
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
async trackEvent(name, props = {}) {
|
|
42
|
+
if (process.env.DO_NOT_TRACK) {
|
|
43
|
+
debug(`trackEvent() for ${name} => skipping per DO_NOT_TRACK variable`);
|
|
44
|
+
return Promise.resolve(`Skipping trackEvent for ${name} (DO_NOT_TRACK)`);
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
return Promise.all(this.clients.map(client => {
|
|
36
48
|
return client.trackEvent(name, { // eslint-disable-next-line camelcase
|
|
37
49
|
...client_info,
|
|
@@ -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
|
+
}
|
package/dist/lib/api.js
CHANGED
|
@@ -23,7 +23,7 @@ var _token = _interopRequireDefault(require("./token"));
|
|
|
23
23
|
|
|
24
24
|
var _env = _interopRequireDefault(require("./env"));
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _proxyAgent = require("./http/proxy-agent");
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
29
|
|
|
@@ -96,7 +96,7 @@ async function API({
|
|
|
96
96
|
});
|
|
97
97
|
return forward(operation);
|
|
98
98
|
});
|
|
99
|
-
const proxyAgent = (0,
|
|
99
|
+
const proxyAgent = (0, _proxyAgent.createProxyAgent)(API_URL);
|
|
100
100
|
const httpLink = new _core.HttpLink({
|
|
101
101
|
uri: API_URL,
|
|
102
102
|
headers,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* External dependencies
|
|
14
|
+
*/
|
|
15
|
+
const debug = (0, _debug.default)('@automattic/vip:lib:cli:config');
|
|
16
|
+
let configFromFile = {};
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
// Get `local` config first; this will only exist in dev as it's npmignore-d.
|
|
20
|
+
configFromFile = require("../../../config/config.local.json");
|
|
21
|
+
debug('Loaded config data from config.local.json');
|
|
22
|
+
} catch {
|
|
23
|
+
// Fall back to `publish` config file.
|
|
24
|
+
configFromFile = require("../../../config/config.publish.json");
|
|
25
|
+
debug('Loaded config data from config.publish.json');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const config = Object.assign({}, configFromFile);
|
|
29
|
+
var _default = config;
|
|
30
|
+
exports.default = _default;
|
|
@@ -487,6 +487,8 @@ async function getTagChoices() {
|
|
|
487
487
|
|
|
488
488
|
function getEnvTrackingInfo(slug) {
|
|
489
489
|
try {
|
|
490
|
+
var _result$php;
|
|
491
|
+
|
|
490
492
|
const envData = (0, _devEnvironmentCore.readEnvironmentData)(slug);
|
|
491
493
|
const result = {
|
|
492
494
|
slug
|
|
@@ -499,6 +501,7 @@ function getEnvTrackingInfo(slug) {
|
|
|
499
501
|
result[snakeCasedKey] = value;
|
|
500
502
|
}
|
|
501
503
|
|
|
504
|
+
result.php = (_result$php = result.php) === null || _result$php === void 0 ? void 0 : _result$php.replace(/.*:/, '');
|
|
502
505
|
return result;
|
|
503
506
|
} catch (err) {
|
|
504
507
|
return {
|
|
@@ -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 (e) {
|
|
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
|
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _socksProxyAgent = require("socks-proxy-agent");
|
|
4
|
+
|
|
5
|
+
var _httpsProxyAgent = require("https-proxy-agent");
|
|
6
|
+
|
|
7
|
+
var _httpProxyAgent = require("http-proxy-agent");
|
|
8
|
+
|
|
9
|
+
var _proxyFromEnv = require("proxy-from-env");
|
|
10
|
+
|
|
11
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/
|
|
18
|
+
const debug = (0, _debug.default)('vip:proxy-agent');
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
// Note: This module requires the use of a special environment variable "VIP_USE_SYSTEM_PROXY"
|
|
23
|
+
// The setting of it to any value allows this module to create a proxy agent based on proxy environment variables
|
|
24
|
+
// If not set, this module will revert back to the previous functionality (hence being fully backward compatible and non-breaking for users)
|
|
25
|
+
// This function returns a proxy given a few scenarios (in order of precedence):
|
|
26
|
+
// 1. VIP_PROXY is set: a SOCKS proxy is returned same as the previous version of this module
|
|
27
|
+
// 2. No applicable variables are set: null is returned (thus, no proxy agent is returned)
|
|
28
|
+
// 3. VIP_USE_SYSTEM_PROXY and SOCKS_PROXY are set: a SOCKS_PROXY is returned
|
|
29
|
+
// 4. VIP_USE_SYSTEM_PROXY and HTTPS_PROXY are set: an HTTPS_PROXY is returned
|
|
30
|
+
// 5. VIP_USE_SYSTEM_PROXY and HTTP_PROXY are set: an HTTP_PROXY is returned
|
|
31
|
+
// 6. NO_PROXY is set along with VIP_USE_SYSTEM_PROXY and any system proxy: null is returned if the no proxy applies, otherwise the first active proxy is used
|
|
32
|
+
// This allows near full customization by the client of what proxy should be used, instead of making assumptions based on the URL string
|
|
33
|
+
|
|
34
|
+
function createProxyAgent(url) {
|
|
35
|
+
const VIP_PROXY = process.env.VIP_PROXY || process.env.vip_proxy || null;
|
|
36
|
+
const SOCKS_PROXY = process.env.SOCKS_PROXY || process.env.socks_proxy || null;
|
|
37
|
+
const HTTPS_PROXY = process.env.HTTPS_PROXY || process.env.https_proxy || null;
|
|
38
|
+
const HTTP_PROXY = process.env.HTTP_PROXY || process.env.http_proxy || null;
|
|
39
|
+
const NO_PROXY = process.env.NO_PROXY || process.env.no_proxy || null; // VIP Socks Proxy should take precedence and should be fully backward compatible
|
|
40
|
+
|
|
41
|
+
if (VIP_PROXY) {
|
|
42
|
+
debug(`Enabling VIP_PROXY proxy support using config: ${VIP_PROXY}`);
|
|
43
|
+
return new _socksProxyAgent.SocksProxyAgent(VIP_PROXY);
|
|
44
|
+
} // Now check for any system proxy usage
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if (process.env.VIP_USE_SYSTEM_PROXY && !coveredInNoProxy(url, NO_PROXY)) {
|
|
48
|
+
if (SOCKS_PROXY) {
|
|
49
|
+
debug(`Enabling SOCKS proxy support using config: ${SOCKS_PROXY}`);
|
|
50
|
+
return new _socksProxyAgent.SocksProxyAgent(SOCKS_PROXY);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (HTTPS_PROXY) {
|
|
54
|
+
debug(`Enabling HTTPS proxy support using config: ${HTTPS_PROXY}`);
|
|
55
|
+
return new _httpsProxyAgent.HttpsProxyAgent(HTTPS_PROXY);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (HTTP_PROXY) {
|
|
59
|
+
debug(`Enabling HTTP proxy support using config: ${HTTP_PROXY}`);
|
|
60
|
+
return new _httpProxyAgent.HttpProxyAgent(HTTP_PROXY);
|
|
61
|
+
}
|
|
62
|
+
} // If no environment variables are set, the no proxy is in effect, or if the proxy enable is not set return null (equivilant of no Proxy agent)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
return null;
|
|
66
|
+
} // Determine if a NO_PROXY variable is applicable to a given URL
|
|
67
|
+
// Parameters:
|
|
68
|
+
// - url (string): absolute desintation URL (including the protocol)
|
|
69
|
+
// - noProxyString (string | null): string representation of the environments current NO_PROXY or no_proxy variable (NO_PROXY takes precedence)
|
|
70
|
+
// Returns:
|
|
71
|
+
// - (boolean) true/false depending on result
|
|
72
|
+
// NO_PROXY Rules (based directly on underlying dependency):
|
|
73
|
+
// 1. * (alone): proxy nothing
|
|
74
|
+
// 2. *.site: do not proxy any subdomain of a domain (top level domain must still be given)
|
|
75
|
+
// Example: '.api' does NOT match wp.api.org, but '.api.org' does (see tests)
|
|
76
|
+
// 3. abc.com: do not proxy www.abc.com, abc.com, etc.
|
|
77
|
+
// See proxy-from-env on npmjs.org for full "ruleset"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function coveredInNoProxy(url, noProxyString) {
|
|
81
|
+
// If the NO_PROXY env variable is not set, then the URL is not covered in the NO_PROXY (utility below does not handle this case)
|
|
82
|
+
if (!noProxyString) {
|
|
83
|
+
return false;
|
|
84
|
+
} // If getProxyForUrl returns an empty string, then the host should not be proxied
|
|
85
|
+
// This isn't the most straight forward way to determine if a NO_PROXY is applicable, but the only package I could find that is relatively new and maintained
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
return (0, _proxyFromEnv.getProxyForUrl)(url) === '';
|
|
89
|
+
} // Exports
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
createProxyAgent
|
|
94
|
+
};
|