@automattic/vip 2.24.2 → 2.25.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/CHANGELOG.md +39 -0
- package/CONTRIBUTING.md +38 -8
- package/README.md +6 -0
- package/assets/dev-env.lando.template.yml.ejs +3 -11
- package/dist/bin/vip-dev-env-create.js +2 -1
- package/dist/bin/vip-dev-env-destroy.js +2 -1
- package/dist/bin/vip-dev-env-exec.js +25 -10
- package/dist/bin/vip-dev-env-import-media.js +2 -4
- package/dist/bin/vip-dev-env-import-sql.js +30 -8
- package/dist/bin/vip-dev-env-info.js +2 -1
- package/dist/bin/vip-dev-env-list.js +3 -1
- package/dist/bin/vip-dev-env-start.js +1 -0
- package/dist/bin/vip-dev-env-stop.js +2 -1
- package/dist/bin/vip-dev-env-update.js +5 -5
- package/dist/bin/vip-import-sql.js +11 -0
- package/dist/lib/cli/command.js +9 -0
- package/dist/lib/cli/exit.js +1 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +36 -29
- package/dist/lib/dev-environment/dev-environment-core.js +37 -41
- package/dist/lib/dev-environment/dev-environment-lando.js +101 -70
- package/npm-shrinkwrap.json +2546 -2843
- package/package.json +21 -14
- package/.prettierrc +0 -9
- package/jest.setupMocks.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
# 2.25.1
|
|
4
|
+
|
|
5
|
+
- #1239 Downgrade Apollo client to 3.3.6
|
|
6
|
+
|
|
7
|
+
# 2.25.0
|
|
8
|
+
|
|
9
|
+
- #1233 Update @automattic/vip-go-preflight-checks to 2.0.16
|
|
10
|
+
- #1232 fix(dev-env): Make environment existence check more robust
|
|
11
|
+
- #1231 fix(dev-env): Inherit stdio descriptors for 'dev-env exec'
|
|
12
|
+
- #1230 Dev-env: Fix ES service reference
|
|
13
|
+
- #1229 fix(dev-env): Perform ES healthcheck properly
|
|
14
|
+
- #1209 refactor(dev-env): Run health checks in parallel
|
|
15
|
+
- #1201 fix(dev-env): Do not check env is up for every action
|
|
16
|
+
- #1224 fix(tests): do not fail when `DO_NOT_TRACK` is set
|
|
17
|
+
- #1211 fix(dev-env)!: remove support for statsd
|
|
18
|
+
- #1183 feat(dev-env): Add support for the most recent Lando
|
|
19
|
+
- #1203 test(dev-env): Add E2E tests for dev env
|
|
20
|
+
- #1222 chore(deps): Update babel to 7.20.7
|
|
21
|
+
- #1223 chore(deps): Update flow to 0.196.3
|
|
22
|
+
- #1226 Add some additional info on installation
|
|
23
|
+
- #1225 chore: Update dot files
|
|
24
|
+
- #1197 feat(dev-env): Pipe files to Docker instead of copying them when doing SQL import
|
|
25
|
+
- #1221 dev-env: Fix Mailhog being undefined in instance data from older versisons of VIP-CLI
|
|
26
|
+
- #1218 Fix a grammatical mistake in the error message
|
|
27
|
+
- #1217 Add filename validation to sql import
|
|
28
|
+
- #1213 chore(deps): Update jest to 29.3.1 and nock to 13.2.9
|
|
29
|
+
- #1214 chore(deps): Update babel to 7.20
|
|
30
|
+
- #1208 feat(dev-env): Add quiet mode to `vip dev-env exec`
|
|
31
|
+
- #1212 fix(dev-env): Errors should go to stderr, not stdout
|
|
32
|
+
- #1206 fix(dev-env): await handleCLIException() and set proper exit code
|
|
33
|
+
- #1202 fix(dev-env): Do not load integrations for Acquia, Lagoon, Pantheon
|
|
34
|
+
- #1200 fix(dev-env): Reuse Lando App instead of recreating it every time
|
|
35
|
+
- #1204 Dev-env: Update ES to 7.17.8 to match prod
|
|
36
|
+
- #1205 ci: Pass correct node-version in CI workflow
|
|
37
|
+
- #1199 fix(dev-env): Update `max_allowed_packet` to mirror prod envs
|
|
38
|
+
- #1194 Add debugger instructions
|
|
39
|
+
- #1196 fix(dev-env): Fix ambiguous short option for MailHog/MariaDB
|
|
40
|
+
- #1195 fix(dev-env): increase max number of event listeners for AsyncEvents
|
|
41
|
+
|
|
3
42
|
## 2.24.2 (22 Dec 2022)
|
|
4
43
|
|
|
5
44
|
- #1219 fix(dev-env): Fix search/replace on SQL file import
|
package/CONTRIBUTING.md
CHANGED
|
@@ -29,6 +29,36 @@ VIP_PROXY="" API_HOST=http://localhost:4000 node ./dist/bin/vip app
|
|
|
29
29
|
VIP_PROXY="" API_HOST=http://localhost:4000 node ./dist/bin/vip -- wp option get home
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
### Using debugger
|
|
33
|
+
|
|
34
|
+
Who doesn't like a good console.log for debugging?
|
|
35
|
+
Well, sometimes it's insufficient, luckily it's not too complicated to use a debugger.
|
|
36
|
+
|
|
37
|
+
1. First, make sure to run the `npm run build:watch`, this will generate source maps
|
|
38
|
+
2. Run the command you want via `node --inspect`, like so: `node --inspect ./dist/bin/vip-dev-env-import-sql.js`
|
|
39
|
+
3. Note the port the debugger is listening on:
|
|
40
|
+
```
|
|
41
|
+
Debugger listening on ws://127.0.0.1:9229/db6c03e9-2585-4a08-a1c6-1fee0295c9ff
|
|
42
|
+
For help, see: https://nodejs.org/en/docs/inspector
|
|
43
|
+
```
|
|
44
|
+
4. In your editor of choice attach to the debugger. For VSCode: Hit 'Run and Debug' panel, hit the "gear" icon (open launch.json), make your `Attach` configuration entry to look like so:
|
|
45
|
+
Make sure the `port` matches the port from step 3, and the `runtimeExecutable` matches the exact `node` executable you ran. If you use a version manager like `nvm`, its especially important to check this.
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"name": "Attach",
|
|
50
|
+
"port": 9229,
|
|
51
|
+
"request": "attach",
|
|
52
|
+
"skipFiles": ["<node_internals>/**"],
|
|
53
|
+
"type": "node",
|
|
54
|
+
"runtimeExecutable": "/Users/user/.nvm/versions/node/v14.18.2/bin/node"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
5. Set your breakpoints and whatnot, hit the play button.
|
|
59
|
+
6. Confirm that you attached the debugger to continue command execution
|
|
60
|
+
7. Squash them bugs 🐛🔨.
|
|
61
|
+
8. [Optional but recommended] Pay it forward and implement a similar approach to other internal/external tooling.
|
|
32
62
|
### Adding commands
|
|
33
63
|
|
|
34
64
|
* New command names should use the singular form (e.g. site vs sites).
|
|
@@ -43,13 +73,13 @@ New libraries should generally support both CLI and web contexts, though some ca
|
|
|
43
73
|
|
|
44
74
|
Our release flow for VIP CLI follows this pattern:
|
|
45
75
|
|
|
46
|
-
**_feature branch -> develop branch ->
|
|
76
|
+
**_feature branch -> develop branch -> trunk branch -> NPM release_**
|
|
47
77
|
|
|
48
78
|
- For feature branches, please follow A8C branch naming conventions (e.g.- `add/data-sync-command`, `fix/subsite-launch-command`, etc.)
|
|
49
79
|
- Include a Changelog for all npm version releases, including any minor or major versions
|
|
50
80
|
- This is a public repository. Please do not include any internal links in PRs, changelogs, testing instructions, etc.
|
|
51
81
|
- Merge changes from your feature branch to the `develop` branch
|
|
52
|
-
- If you are ready to release your changes publicly, merge your changes from the `develop` branch to the `
|
|
82
|
+
- If you are ready to release your changes publicly, merge your changes from the `develop` branch to the `trunk` branch. All changes that are not ready to be public should be feature flagged or stay in the `develop` branch to avoid conflicts when releasing urgent fixes (not recommended).
|
|
53
83
|
- Finally, release your changes as a new minor or major NPM version. Ping in the #vip-platform channel to notify folks of a new release, but please feel free to release your changes without any blockers from the team. Any team member that is part of the Automattic NPM organization can release a new version; if you aren't a member, generic credentials are available in the Secret Store.
|
|
54
84
|
|
|
55
85
|
### Changelogs
|
|
@@ -78,7 +108,7 @@ Prepare the release by making sure that:
|
|
|
78
108
|
|
|
79
109
|
1. All relevant PRs have been merged.
|
|
80
110
|
1. The release has been tested across macOS, Windows, and Linux.
|
|
81
|
-
1. The [changelog](https://github.com/Automattic/vip/blob/
|
|
111
|
+
1. The [changelog](https://github.com/Automattic/vip/blob/trunk/CHANGELOG.md) has been updated on `trunk`.
|
|
82
112
|
1. All tests pass and your working directory is clean (we have pre-publish checks to catch this, just-in-case).
|
|
83
113
|
|
|
84
114
|
#### Changelog Generator Hint:
|
|
@@ -90,15 +120,15 @@ gh pr list --search "is:merged sort:updated-desc closed:>$LAST_RELEASE_DATE" | s
|
|
|
90
120
|
|
|
91
121
|
Then, let's publish:
|
|
92
122
|
|
|
93
|
-
1. Make sure
|
|
123
|
+
1. Make sure trunk branch is up to date `git pull`
|
|
94
124
|
1. Set the version (via `npm version minor` or `npm version major` or `npm version patch`)
|
|
95
125
|
1. For most regular releases, this will be `npm version minor`.
|
|
96
126
|
1. Push the tag to GitHub (`git push --tags`)
|
|
97
|
-
1. Push the
|
|
127
|
+
1. Push the trunk branch `git push`
|
|
98
128
|
1. Make sure you're part of the Automattic organization in npm
|
|
99
129
|
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.
|
|
100
130
|
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).
|
|
101
|
-
1. Push `
|
|
131
|
+
1. Push `trunk` changes (mostly the version bump) to `develop` (`git checkout develop && git merge trunk` )
|
|
102
132
|
|
|
103
133
|
Once released, it's worth running `npm i -g @automattic/vip` to install / upgrade the released version to make sure everything looks good.
|
|
104
134
|
|
|
@@ -111,14 +141,14 @@ In order to do that, please follow this:
|
|
|
111
141
|
1. Manually change the version in `package.json` and `package-lock.json` to a dev version. Example: `1.4.0-dev1`
|
|
112
142
|
2. Go to publish-please's config in `.publishrc`
|
|
113
143
|
3. Change the `publishTag` to `next` and `gitTag` to `false` (publish-please will expect the latest commit to have a git tag, but we don't want it in this case)
|
|
114
|
-
4. Commit your changes to `
|
|
144
|
+
4. Commit your changes to `trunk`
|
|
115
145
|
5. Run `npm run publish-please`
|
|
116
146
|
|
|
117
147
|
You can repeat this with every new version until you're happy with your version and ready to a public release. We currently don't support multiple branches for multiple versions. When it's the case, this process needs to be done for every version in every branch.
|
|
118
148
|
|
|
119
149
|
### Patching Old Releases
|
|
120
150
|
|
|
121
|
-
There may be times when we need to push out a critical fix to the most recent release (or several past releases) such as for patching security issues or major bugs. This can be complicated by the fact that we may have some larger changes already merged into the `
|
|
151
|
+
There may be times when we need to push out a critical fix to the most recent release (or several past releases) such as for patching security issues or major bugs. This can be complicated by the fact that we may have some larger changes already merged into the `trunk` branch.
|
|
122
152
|
|
|
123
153
|
For these cases:
|
|
124
154
|
|
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@ First, install the package:
|
|
|
8
8
|
npm install -g @automattic/vip
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
The above command may fail in linux if you do not have `make` and `g++` installed. In that case, install them first:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
sudo apt install make g++
|
|
15
|
+
```
|
|
16
|
+
|
|
11
17
|
Then, launch the command and follow the prompts:
|
|
12
18
|
|
|
13
19
|
```
|
|
@@ -40,7 +40,6 @@ services:
|
|
|
40
40
|
command: run.sh
|
|
41
41
|
working_dir: /wp
|
|
42
42
|
environment:
|
|
43
|
-
STATSD: <%= statsd ? 'enable' : 'disable' %>
|
|
44
43
|
XDEBUG: <%= xdebug ? 'enable' : 'disable' %>
|
|
45
44
|
<% if ( xdebugConfig ) { %>
|
|
46
45
|
XDEBUG_CONFIG: "<%= xdebugConfig %>"
|
|
@@ -67,7 +66,7 @@ services:
|
|
|
67
66
|
type: compose
|
|
68
67
|
services:
|
|
69
68
|
image: mariadb:<%= mariadb %>
|
|
70
|
-
command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
|
|
69
|
+
command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION --max_allowed_packet=67M
|
|
71
70
|
ports:
|
|
72
71
|
- ":3306"
|
|
73
72
|
environment:
|
|
@@ -96,7 +95,7 @@ services:
|
|
|
96
95
|
elasticsearch:
|
|
97
96
|
type: compose
|
|
98
97
|
services:
|
|
99
|
-
image: elasticsearch:7.17.
|
|
98
|
+
image: elasticsearch:7.17.8
|
|
100
99
|
command: /usr/local/bin/docker-entrypoint.sh
|
|
101
100
|
environment:
|
|
102
101
|
ELASTICSEARCH_IS_DEDICATED_NODE: 'no'
|
|
@@ -112,13 +111,6 @@ services:
|
|
|
112
111
|
volumes:
|
|
113
112
|
search_data:
|
|
114
113
|
<% } %>
|
|
115
|
-
<% if ( statsd ) { %>
|
|
116
|
-
statsd:
|
|
117
|
-
type: compose
|
|
118
|
-
services:
|
|
119
|
-
image: ghcr.io/automattic/vip-container-images/statsd:v0.9.0
|
|
120
|
-
command: node stats.js /config/statsd-config.js
|
|
121
|
-
<% } %>
|
|
122
114
|
|
|
123
115
|
wordpress:
|
|
124
116
|
type: compose
|
|
@@ -191,7 +183,7 @@ tooling:
|
|
|
191
183
|
service: php
|
|
192
184
|
description: "Connect to the DB using mysql client (e.g. allow to run imports)"
|
|
193
185
|
cmd:
|
|
194
|
-
- mysql -hdatabase -uwordpress -pwordpress
|
|
186
|
+
- mysql -hdatabase -uwordpress -pwordpress -Dwordpress
|
|
195
187
|
|
|
196
188
|
<% function wpVolumes() { %>
|
|
197
189
|
- ./config:/wp/config
|
|
@@ -66,7 +66,7 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
66
66
|
};
|
|
67
67
|
await (0, _tracker.trackEvent)('dev_env_create_command_execute', trackingInfo);
|
|
68
68
|
const startCommand = _chalk.default.bold((0, _devEnvironmentCli.getEnvironmentStartCommand)(slug));
|
|
69
|
-
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
69
|
+
const environmentAlreadyExists = await (0, _devEnvironmentCore.doesEnvironmentExist)((0, _devEnvironmentCore.getEnvironmentPath)(slug));
|
|
70
70
|
if (environmentAlreadyExists) {
|
|
71
71
|
const messageToShow = `Environment already exists\n\n\nTo start the environment run:\n\n${startCommand}\n\n` + `To create another environment use ${_chalk.default.bold('--slug')} option with a unique name.\n`;
|
|
72
72
|
exit.withError(messageToShow);
|
|
@@ -94,5 +94,6 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
94
94
|
await (0, _tracker.trackEvent)('dev_env_create_command_success', trackingInfo);
|
|
95
95
|
} catch (error) {
|
|
96
96
|
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_create_command_error', trackingInfo);
|
|
97
|
+
process.exitCode = 1;
|
|
97
98
|
}
|
|
98
99
|
});
|
|
@@ -15,8 +15,8 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
15
15
|
var _tracker = require("../lib/tracker");
|
|
16
16
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
17
17
|
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
18
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
19
18
|
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
19
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
20
20
|
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
/**
|
|
@@ -45,5 +45,6 @@ const examples = [{
|
|
|
45
45
|
await (0, _tracker.trackEvent)('dev_env_destroy_command_success', trackingInfo);
|
|
46
46
|
} catch (error) {
|
|
47
47
|
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_destroy_command_error', trackingInfo);
|
|
48
|
+
process.exitCode = 1;
|
|
48
49
|
}
|
|
49
50
|
});
|
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
8
|
/**
|
|
13
9
|
* Internal dependencies
|
|
14
10
|
*/
|
|
@@ -20,6 +16,7 @@ var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
|
20
16
|
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
21
17
|
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
22
18
|
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
19
|
+
var _userError = _interopRequireDefault(require("../lib/user-error"));
|
|
23
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
21
|
const examples = [{
|
|
25
22
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} exec -- wp post list`,
|
|
@@ -36,10 +33,13 @@ const examples = [{
|
|
|
36
33
|
}).option('slug', 'Custom name of the dev environment').option('force', 'Disabling validations before task execution', undefined, value => {
|
|
37
34
|
var _value$toLowerCase;
|
|
38
35
|
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
36
|
+
}).option('quiet', 'Suppress output', undefined, value => {
|
|
37
|
+
var _value$toLowerCase2;
|
|
38
|
+
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase2 = value.toLowerCase) === null || _value$toLowerCase2 === void 0 ? void 0 : _value$toLowerCase2.call(value));
|
|
39
39
|
}).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
|
|
40
40
|
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
41
41
|
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
42
|
-
await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
|
|
42
|
+
await (0, _devEnvironmentCli.validateDependencies)(lando, slug, opt.quiet);
|
|
43
43
|
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
44
44
|
await (0, _tracker.trackEvent)('dev_env_exec_command_execute', trackingInfo);
|
|
45
45
|
try {
|
|
@@ -53,12 +53,27 @@ const examples = [{
|
|
|
53
53
|
if (argSplitterFound && argSplitterIx + 1 < process.argv.length) {
|
|
54
54
|
arg = process.argv.slice(argSplitterIx + 1);
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
if (!opt.force) {
|
|
57
|
+
const isUp = await (0, _devEnvironmentLando.isEnvUp)(lando, (0, _devEnvironmentCore.getEnvironmentPath)(slug));
|
|
58
|
+
if (!isUp) {
|
|
59
|
+
throw new _userError.default('Environment needs to be started before running a command');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
await (0, _devEnvironmentCore.exec)(lando, slug, arg, {
|
|
64
|
+
stdio: 'inherit'
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (error instanceof _userError.default) {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Unfortunately, we are unable to get the exit code from Lando :-(
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
}
|
|
60
74
|
await (0, _tracker.trackEvent)('dev_env_exec_command_success', trackingInfo);
|
|
61
75
|
} catch (error) {
|
|
62
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_exec_command_error', trackingInfo);
|
|
76
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_exec_command_error', trackingInfo);
|
|
77
|
+
process.exitCode = 1;
|
|
63
78
|
}
|
|
64
79
|
});
|
|
@@ -19,7 +19,6 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
|
19
19
|
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
20
20
|
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
21
21
|
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
22
|
-
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
23
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
23
|
const examples = [{
|
|
25
24
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import media path/to/wp-content/uploads`,
|
|
@@ -33,14 +32,13 @@ const examples = [{
|
|
|
33
32
|
}).examples(examples).option('slug', 'Custom name of the dev environment').argv(process.argv, async (unmatchedArgs, opt) => {
|
|
34
33
|
const [filePath] = unmatchedArgs;
|
|
35
34
|
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
36
|
-
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
37
|
-
await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
|
|
38
35
|
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
39
36
|
await (0, _tracker.trackEvent)('dev_env_import_media_command_execute', trackingInfo);
|
|
40
37
|
try {
|
|
41
38
|
await (0, _devEnvironmentCore.importMediaPath)(slug, filePath);
|
|
42
39
|
await (0, _tracker.trackEvent)('dev_env_import_media_command_success', trackingInfo);
|
|
43
40
|
} catch (error) {
|
|
44
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_media_command_error', trackingInfo);
|
|
41
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_media_command_error', trackingInfo);
|
|
42
|
+
process.exitCode = 1;
|
|
45
43
|
}
|
|
46
44
|
});
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"use strict";
|
|
12
12
|
|
|
13
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
14
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
14
15
|
var _tracker = require("../lib/tracker");
|
|
15
16
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
16
17
|
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
@@ -18,6 +19,7 @@ var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core")
|
|
|
18
19
|
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
19
20
|
var _sql = require("../lib/validations/sql");
|
|
20
21
|
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
22
|
+
var _userError = _interopRequireDefault(require("../lib/user-error"));
|
|
21
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
24
|
/**
|
|
23
25
|
* Internal dependencies
|
|
@@ -49,11 +51,11 @@ const examples = [{
|
|
|
49
51
|
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
50
52
|
await (0, _tracker.trackEvent)('dev_env_import_sql_command_execute', trackingInfo);
|
|
51
53
|
try {
|
|
52
|
-
const
|
|
53
|
-
resolvedPath,
|
|
54
|
-
inContainerPath
|
|
55
|
-
} = await (0, _devEnvironmentCore.resolveImportPath)(slug, fileName, searchReplace, inPlace);
|
|
54
|
+
const resolvedPath = await (0, _devEnvironmentCore.resolveImportPath)(slug, fileName, searchReplace, inPlace);
|
|
56
55
|
if (!opt.skipValidate) {
|
|
56
|
+
if (!(0, _devEnvironmentLando.isEnvUp)(lando, (0, _devEnvironmentCore.getEnvironmentPath)(slug))) {
|
|
57
|
+
throw new _userError.default('Environment needs to be started first');
|
|
58
|
+
}
|
|
57
59
|
const expectedDomain = `${slug}.vipdev.lndo.site`;
|
|
58
60
|
await (0, _sql.validate)(resolvedPath, {
|
|
59
61
|
isImport: false,
|
|
@@ -63,9 +65,28 @@ const examples = [{
|
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
const fd = await _fs.default.promises.open(resolvedPath, 'r');
|
|
69
|
+
const importArg = ['db', '--disable-auto-rehash'];
|
|
70
|
+
const origIsTTY = process.stdin.isTTY;
|
|
71
|
+
try {
|
|
72
|
+
/**
|
|
73
|
+
* When stdin is a TTY, Lando passes the `--tty` flag to Docker.
|
|
74
|
+
* This breaks our code when we pass the stream as stdin to Docker.
|
|
75
|
+
* exec() then fails with "the input device is not a TTY".
|
|
76
|
+
*
|
|
77
|
+
* Therefore, for the things to work, we have to pretend that stdin is not a TTY :-)
|
|
78
|
+
*/
|
|
79
|
+
process.stdin.isTTY = false;
|
|
80
|
+
await (0, _devEnvironmentCore.exec)(lando, slug, importArg, {
|
|
81
|
+
stdio: [fd, 'pipe', 'pipe']
|
|
82
|
+
});
|
|
83
|
+
console.log(`${_chalk.default.green.bold('Success:')} Database imported.`);
|
|
84
|
+
} finally {
|
|
85
|
+
process.stdin.isTTY = origIsTTY;
|
|
86
|
+
}
|
|
87
|
+
if (searchReplace && searchReplace.length && !inPlace) {
|
|
88
|
+
_fs.default.unlinkSync(resolvedPath);
|
|
89
|
+
}
|
|
69
90
|
const cacheArg = ['wp', 'cache', 'flush'];
|
|
70
91
|
await (0, _devEnvironmentCore.exec)(lando, slug, cacheArg);
|
|
71
92
|
try {
|
|
@@ -81,6 +102,7 @@ const examples = [{
|
|
|
81
102
|
await (0, _devEnvironmentCore.exec)(lando, slug, addUserArg);
|
|
82
103
|
await (0, _tracker.trackEvent)('dev_env_import_sql_command_success', trackingInfo);
|
|
83
104
|
} catch (error) {
|
|
84
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_sql_command_error', trackingInfo);
|
|
105
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_sql_command_error', trackingInfo);
|
|
106
|
+
process.exitCode = 1;
|
|
85
107
|
}
|
|
86
108
|
});
|
|
@@ -49,6 +49,7 @@ const examples = [{
|
|
|
49
49
|
}
|
|
50
50
|
await (0, _tracker.trackEvent)('dev_env_info_command_success', trackingInfo);
|
|
51
51
|
} catch (error) {
|
|
52
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_info_command_error', trackingInfo);
|
|
52
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_info_command_error', trackingInfo);
|
|
53
|
+
process.exitCode = 1;
|
|
53
54
|
}
|
|
54
55
|
});
|
|
@@ -27,6 +27,7 @@ const examples = [{
|
|
|
27
27
|
}];
|
|
28
28
|
(0, _command.default)().examples(examples).argv(process.argv, async () => {
|
|
29
29
|
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
30
|
+
lando.events.constructor.prototype.setMaxListeners(1024);
|
|
30
31
|
await (0, _devEnvironmentCli.validateDependencies)(lando, '');
|
|
31
32
|
const trackingInfo = {
|
|
32
33
|
all: true
|
|
@@ -36,6 +37,7 @@ const examples = [{
|
|
|
36
37
|
await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(lando, {});
|
|
37
38
|
await (0, _tracker.trackEvent)('dev_env_list_command_success', trackingInfo);
|
|
38
39
|
} catch (error) {
|
|
39
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_list_command_error', trackingInfo);
|
|
40
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_list_command_error', trackingInfo);
|
|
41
|
+
process.exitCode = 1;
|
|
40
42
|
}
|
|
41
43
|
});
|
|
@@ -67,5 +67,6 @@ const examples = [{
|
|
|
67
67
|
await (0, _tracker.trackEvent)('dev_env_start_command_success', successTrackingInfo);
|
|
68
68
|
} catch (error) {
|
|
69
69
|
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_start_command_error', trackingInfo);
|
|
70
|
+
process.exitCode = 1;
|
|
70
71
|
}
|
|
71
72
|
});
|
|
@@ -40,6 +40,7 @@ const examples = [{
|
|
|
40
40
|
console.log(message);
|
|
41
41
|
await (0, _tracker.trackEvent)('dev_env_stop_command_success', trackingInfo);
|
|
42
42
|
} catch (error) {
|
|
43
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_stop_command_error', trackingInfo);
|
|
43
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_stop_command_error', trackingInfo);
|
|
44
|
+
process.exitCode = 1;
|
|
44
45
|
}
|
|
45
46
|
});
|
|
@@ -14,8 +14,8 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
14
14
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
15
|
var _tracker = require("../lib/tracker");
|
|
16
16
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
17
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
18
17
|
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
18
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
19
19
|
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
20
20
|
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -37,7 +37,7 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
37
37
|
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
38
38
|
await (0, _tracker.trackEvent)('dev_env_update_command_execute', trackingInfo);
|
|
39
39
|
try {
|
|
40
|
-
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
40
|
+
const environmentAlreadyExists = await (0, _devEnvironmentCore.doesEnvironmentExist)((0, _devEnvironmentCore.getEnvironmentPath)(slug));
|
|
41
41
|
if (!environmentAlreadyExists) {
|
|
42
42
|
throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
|
|
43
43
|
}
|
|
@@ -56,7 +56,6 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
56
56
|
elasticsearch: currentInstanceData.elasticsearch,
|
|
57
57
|
php: currentInstanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS.default,
|
|
58
58
|
mariadb: currentInstanceData.mariadb,
|
|
59
|
-
statsd: currentInstanceData.statsd,
|
|
60
59
|
phpmyadmin: currentInstanceData.phpmyadmin,
|
|
61
60
|
xdebug: currentInstanceData.xdebug,
|
|
62
61
|
mailhog: currentInstanceData.mailhog,
|
|
@@ -77,9 +76,10 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
77
76
|
} catch (error) {
|
|
78
77
|
if ('ENOENT' === error.code) {
|
|
79
78
|
const message = 'Environment was created before update was supported.\n\nTo update environment please destroy it and create a new one.';
|
|
80
|
-
(0, _devEnvironmentCli.handleCLIException)(new Error(message), 'dev_env_update_command_error', trackingInfo);
|
|
79
|
+
await (0, _devEnvironmentCli.handleCLIException)(new Error(message), 'dev_env_update_command_error', trackingInfo);
|
|
81
80
|
} else {
|
|
82
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_update_command_error', trackingInfo);
|
|
81
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_update_command_error', trackingInfo);
|
|
83
82
|
}
|
|
83
|
+
process.exitCode = 1;
|
|
84
84
|
}
|
|
85
85
|
});
|
|
@@ -232,6 +232,14 @@ If you are confident the file does not contain unsupported statements, you can r
|
|
|
232
232
|
// this can only be called after static validation of the SQL file
|
|
233
233
|
return (0, _sql.getTableNames)();
|
|
234
234
|
}
|
|
235
|
+
function validateFilename(filename) {
|
|
236
|
+
const re = /^[a-z0-9\-\_\.]+$/i;
|
|
237
|
+
|
|
238
|
+
// Exits if filename contains anything outside a-z A-Z - _ .
|
|
239
|
+
if (!re.test(filename)) {
|
|
240
|
+
exit.withError('Error: The characters used in the name of a file for import are limited to [0-9,a-z,A-Z,-,_,.]');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
235
243
|
const displayPlaybook = ({
|
|
236
244
|
launched,
|
|
237
245
|
tableNames,
|
|
@@ -347,6 +355,9 @@ const displayPlaybook = ({
|
|
|
347
355
|
const launched = opts.env.launched;
|
|
348
356
|
let fileNameToUpload = fileName;
|
|
349
357
|
|
|
358
|
+
// Exit if filename contains unsafe character
|
|
359
|
+
validateFilename(fileNameToUpload);
|
|
360
|
+
|
|
350
361
|
// SQL file validations
|
|
351
362
|
const tableNames = await validateAndGetTableNames({
|
|
352
363
|
skipValidate,
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -44,7 +44,16 @@ function uncaughtError(err) {
|
|
|
44
44
|
process.on('uncaughtException', uncaughtError);
|
|
45
45
|
process.on('unhandledRejection', uncaughtError);
|
|
46
46
|
let _opts = {};
|
|
47
|
+
let alreadyConfirmedDebugAttachment = false;
|
|
47
48
|
_args.default.argv = async function (argv, cb) {
|
|
49
|
+
if (process.execArgv.includes('--inspect') && !alreadyConfirmedDebugAttachment) {
|
|
50
|
+
await (0, _enquirer.prompt)({
|
|
51
|
+
type: 'confirm',
|
|
52
|
+
name: 'confirm',
|
|
53
|
+
message: "\nAttach the debugger, once you see 'Debugger attached' above hit 'y' to continue"
|
|
54
|
+
});
|
|
55
|
+
alreadyConfirmedDebugAttachment = true;
|
|
56
|
+
}
|
|
48
57
|
const parsedAlias = (0, _envAlias.parseEnvAliasFromArgv)(argv);
|
|
49
58
|
|
|
50
59
|
// A usage option allows us to override the default usage text, which isn't
|
package/dist/lib/cli/exit.js
CHANGED
|
@@ -21,7 +21,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
function withError(message) {
|
|
24
|
-
console.
|
|
24
|
+
console.error(`${_chalk.default.red('Error: ')} ${message.toString().replace(/^Error:\s*/, '')}`);
|
|
25
25
|
|
|
26
26
|
// Debug ouput is printed below error output both for information
|
|
27
27
|
// hierarchy and to make it more likely that the user copies it to their
|