@automattic/vip 2.2.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +11 -8
- package/README.md +20 -0
- package/assets/dev-env.lando.template.yml.ejs +26 -9
- package/dist/bin/vip-config-envvar-delete.js +4 -0
- package/dist/bin/vip-config-envvar-set.js +4 -0
- package/dist/bin/vip-dev-env-create.js +3 -4
- package/dist/bin/vip-dev-env-update.js +72 -0
- package/dist/bin/vip.js +7 -2
- package/dist/lib/cli/command.js +6 -0
- package/dist/lib/constants/dev-environment.js +2 -26
- package/dist/lib/dev-environment/dev-environment-cli.js +26 -20
- package/dist/lib/dev-environment/dev-environment-core.js +23 -3
- package/dist/lib/dev-environment/dev-environment-lando.js +4 -2
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
Thanks for contributing to the VIP
|
|
3
|
+
Thanks for contributing to the VIP-CLI. There are some guidelines to ensure we have consistency across the CLI and web interfaces.
|
|
4
4
|
|
|
5
5
|
## Coding Standards
|
|
6
6
|
|
|
@@ -49,14 +49,15 @@ Our release flow for VIP CLI follows this pattern:
|
|
|
49
49
|
- Any team member that is part of our NPM organization can release new minor or major versions, but please have a Customer Experience (Pâtisserie) team member look over the changes first.
|
|
50
50
|
|
|
51
51
|
### Changelogs
|
|
52
|
-
Changelogs allow customers to keep up with all the changes happening across our VIP Platform. Changelogs for VIP CLI are posted to the
|
|
52
|
+
Changelogs allow customers to keep up with all the changes happening across our VIP Platform. Changelogs for VIP CLI are posted to the [VIP Cloud Changelog P2](https://wpvipchangelog.wordpress.com/), along with the repository’s `README.md`.
|
|
53
53
|
|
|
54
54
|
### Release Schedule
|
|
55
|
-
We deploy changes from our `develop` branch to the `master` branch on Tuesdays from 4AM to 5PM Pacific Time.
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
The VIP Customer Experience squad conducts releases on Tuesdays from 4AM to 5PM Pacific Time (US). Releases are regular but do not happen every Tuesday. Please coordinate with the VIP Customer Experience squad if you'd like to lead your own release.
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
As part of the release process, our squad merges changes from the `develop` branch to the `master` branch. Therefore, do not merge changes into `develop` unless it is ready for release (or use a feature flag to disable it).
|
|
59
|
+
|
|
60
|
+
Fixes for urgent or breaking bugs may be merged straight to the `master` branch and released publicly via `npm` at any time outside of our release window. All other changes should participate in our release window.
|
|
60
61
|
|
|
61
62
|
## Releasing / Publishing
|
|
62
63
|
|
|
@@ -93,13 +94,15 @@ gh pr list --search "is:merged sort:updated-desc closed:>$LAST_RELEASE_DATE" | s
|
|
|
93
94
|
|
|
94
95
|
Then, let's publish:
|
|
95
96
|
|
|
97
|
+
1. Make sure master branch is up to date `git pull`
|
|
96
98
|
1. Set the version (via `npm version minor` or `npm version major` or `npm version patch`)
|
|
97
99
|
1. For most regular releases, this will be `npm version minor`.
|
|
98
100
|
1. Push the tag to GitHub (`git push --tags`)
|
|
99
|
-
1.
|
|
101
|
+
1. Push the master branch `git push`
|
|
102
|
+
1. Make sure you're part of the Automattic organization in npm
|
|
103
|
+
1. Publish the release to npm (`npm run publish-please --access public`)
|
|
100
104
|
1. Edit [the release on GitHub](https://github.com/Automattic/vip/releases) to include a description of the changes and publish (this can just copy the details from the changelog).
|
|
101
|
-
1.
|
|
102
|
-
1. Commit and push (`git add -u` + `git commit` + `git push origin master`).
|
|
105
|
+
1. Push `master` changes (mostly the version bump) to `develop` (`git checkout develop && git merge master` )
|
|
103
106
|
|
|
104
107
|
Once released, it's worth running `npm i -g @automattic/vip` to install / upgrade the released version to make sure everything looks good.
|
|
105
108
|
|
package/README.md
CHANGED
|
@@ -27,6 +27,26 @@ By default, we record information about the usage of this tool using an in-house
|
|
|
27
27
|
|
|
28
28
|
## Changelog
|
|
29
29
|
|
|
30
|
+
### 2.5.0 (9 November 2021)
|
|
31
|
+
- #919 [dev-env] Expose lando core logs
|
|
32
|
+
- #916 [dev-env] Save instance data state
|
|
33
|
+
- #914 [dev-env] update help wording for dev env
|
|
34
|
+
- #915 Add warning message when an envvar is set/deleted
|
|
35
|
+
|
|
36
|
+
### 2.4.0 (5 November 2021)
|
|
37
|
+
- #913 [dev-env] No login required for dev-env
|
|
38
|
+
- #911 Adds more release instructions
|
|
39
|
+
|
|
40
|
+
### 2.3.1 (2 November 2021)
|
|
41
|
+
- Fixes an issue with the 2.3.0 where the intended changes didn't get published correctly.
|
|
42
|
+
|
|
43
|
+
### 2.3.0 (2 November 2021)
|
|
44
|
+
- #908 [dev-env] Custom user permissions setup
|
|
45
|
+
- #897 [dev-env] Primary domain prompt for primary domain redirect
|
|
46
|
+
- #902 [dev-env] Delete file permissions
|
|
47
|
+
- #900 Clarify CONTRIBUTING guidelines
|
|
48
|
+
- #905 Update contribution steps
|
|
49
|
+
|
|
30
50
|
### 2.2.0 (27 October 2021)
|
|
31
51
|
|
|
32
52
|
New: Environment variables command
|
|
@@ -12,12 +12,14 @@ services:
|
|
|
12
12
|
devtools:
|
|
13
13
|
type: compose
|
|
14
14
|
services:
|
|
15
|
-
image: ghcr.io/automattic/vip-container-images/dev-tools:0.
|
|
15
|
+
image: ghcr.io/automattic/vip-container-images/dev-tools:0.8
|
|
16
16
|
command: sleep infinity
|
|
17
17
|
volumes:
|
|
18
18
|
- devtools:/dev-tools
|
|
19
|
+
- scripts:/scripts
|
|
19
20
|
volumes:
|
|
20
21
|
devtools: {}
|
|
22
|
+
scripts:
|
|
21
23
|
|
|
22
24
|
nginx:
|
|
23
25
|
type: compose
|
|
@@ -40,18 +42,23 @@ services:
|
|
|
40
42
|
XDEBUG: <%= xdebug ? 'enable' : 'disable' %>
|
|
41
43
|
STATSD: <%= statsd ? 'enable' : 'disable' %>
|
|
42
44
|
|
|
45
|
+
LANDO_NO_USER_PERMS: 'enable'
|
|
46
|
+
|
|
47
|
+
|
|
43
48
|
volumes:
|
|
44
49
|
- type: volume
|
|
45
50
|
source: devtools
|
|
46
51
|
target: /dev-tools
|
|
47
52
|
volume:
|
|
48
53
|
nocopy: true
|
|
54
|
+
- type: volume
|
|
55
|
+
source: scripts
|
|
56
|
+
target: /scripts
|
|
57
|
+
volume:
|
|
58
|
+
nocopy: true
|
|
49
59
|
<% wpVolumes() %>
|
|
50
60
|
run:
|
|
51
61
|
- sh /dev-tools/setup.sh database root "http://<%= siteSlug %>.vipdev.lndo.site/" "<%= wpTitle %>" <% if ( multisite ) { %> <%= siteSlug %>.vipdev.lndo.site <% } %>
|
|
52
|
-
run_as_root:
|
|
53
|
-
- echo "Copying dev-env-plugin.php to mu-plugins"
|
|
54
|
-
- cp /dev-tools/dev-env-plugin.php /wp/wp-content/mu-plugins/
|
|
55
62
|
|
|
56
63
|
database:
|
|
57
64
|
type: compose
|
|
@@ -116,19 +123,29 @@ services:
|
|
|
116
123
|
wordpress:
|
|
117
124
|
type: compose
|
|
118
125
|
services:
|
|
119
|
-
image:
|
|
120
|
-
command: sh -c "rsync -a /wp/ /shared/; sleep infinity"
|
|
126
|
+
image: ghcr.io/automattic/vip-container-images/wordpress:<%= wordpress.tag %>
|
|
127
|
+
command: sh -c "rsync -a /wp/ /shared/; chown www-data -R /shared; sleep infinity"
|
|
121
128
|
volumes:
|
|
122
129
|
- ./wordpress:/shared
|
|
130
|
+
- type: volume
|
|
131
|
+
source: scripts
|
|
132
|
+
target: /scripts
|
|
133
|
+
volume:
|
|
134
|
+
nocopy: true
|
|
123
135
|
|
|
124
136
|
<% if ( muPlugins.mode == 'image' ) { %>
|
|
125
137
|
mu-plugins:
|
|
126
138
|
type: compose
|
|
127
139
|
services:
|
|
128
|
-
image:
|
|
129
|
-
command: sh
|
|
140
|
+
image: ghcr.io/automattic/vip-container-images/mu-plugins:0.1
|
|
141
|
+
command: sh /run.sh
|
|
130
142
|
volumes:
|
|
131
143
|
- mu-plugins:/shared
|
|
144
|
+
- type: volume
|
|
145
|
+
source: scripts
|
|
146
|
+
target: /scripts
|
|
147
|
+
volume:
|
|
148
|
+
nocopy: true
|
|
132
149
|
volumes:
|
|
133
150
|
mu-plugins: {}
|
|
134
151
|
<% } %>
|
|
@@ -137,7 +154,7 @@ services:
|
|
|
137
154
|
client-code:
|
|
138
155
|
type: compose
|
|
139
156
|
services:
|
|
140
|
-
image:
|
|
157
|
+
image: ghcr.io/automattic/vip-container-images/skeleton:latest
|
|
141
158
|
command: sleep infinity
|
|
142
159
|
volumes:
|
|
143
160
|
- clientcode_clientmuPlugins:/clientcode/client-mu-plugins
|
|
@@ -82,6 +82,10 @@ async function deleteEnvVarCommand(arg, opt) {
|
|
|
82
82
|
});
|
|
83
83
|
await (0, _tracker.trackEvent)('envvar_delete_command_success', trackingParams);
|
|
84
84
|
console.log(_chalk.default.green(`Successfully deleted environment variable ${JSON.stringify(name)}`));
|
|
85
|
+
|
|
86
|
+
if (!opt.skipConfirmation) {
|
|
87
|
+
console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
(0, _command.default)({
|
|
@@ -101,6 +101,10 @@ async function setEnvVarCommand(arg, opt) {
|
|
|
101
101
|
});
|
|
102
102
|
await (0, _tracker.trackEvent)('envvar_set_command_success', trackingParams);
|
|
103
103
|
console.log(_chalk.default.green(`Successfully set environment variable ${JSON.stringify(name)}`));
|
|
104
|
+
|
|
105
|
+
if (!opt.skipConfirmation) {
|
|
106
|
+
console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
(0, _command.default)({
|
|
@@ -50,11 +50,11 @@ const examples = [{
|
|
|
50
50
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite --wordpress "5.8" --client-code "~/git/my_code"`,
|
|
51
51
|
description: 'Creates a local multisite dev environment using WP 5.8 and client code is expected to be in "~/git/my_code"'
|
|
52
52
|
}];
|
|
53
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site
|
|
53
|
+
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site').option('multisite', 'Enable multisite install', undefined, value => {
|
|
54
54
|
var _value$toLowerCase;
|
|
55
55
|
|
|
56
56
|
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
57
|
-
}).option('wordpress', 'Use a specific WordPress version
|
|
57
|
+
}).option('wordpress', 'Use a specific WordPress version').option(['u', 'mu-plugins'], 'Use a specific mu-plugins changeset or local directory').option('client-code', 'Use the client code from a local directory or VIP skeleton').option('statsd', 'Enable statsd component. By default it is disabled', undefined, value => {
|
|
58
58
|
var _value$toLowerCase2;
|
|
59
59
|
|
|
60
60
|
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase2 = value.toLowerCase) === null || _value$toLowerCase2 === void 0 ? void 0 : _value$toLowerCase2.call(value));
|
|
@@ -96,8 +96,7 @@ const examples = [{
|
|
|
96
96
|
siteSlug: slug,
|
|
97
97
|
statsd: opt.statsd || false,
|
|
98
98
|
phpmyadmin: opt.phpmyadmin || false,
|
|
99
|
-
xdebug: opt.xdebug || false
|
|
100
|
-
mediaRedirectDomain: opt.mediaRedirectDomain || ''
|
|
99
|
+
xdebug: opt.xdebug || false
|
|
101
100
|
};
|
|
102
101
|
|
|
103
102
|
try {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* External dependencies
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
+
|
|
15
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
+
|
|
17
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
+
|
|
19
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
20
|
+
|
|
21
|
+
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
22
|
+
|
|
23
|
+
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
24
|
+
|
|
25
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Internal dependencies
|
|
29
|
+
*/
|
|
30
|
+
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
31
|
+
const examples = [{
|
|
32
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} update`,
|
|
33
|
+
description: 'Retriggers setup wizard in order to change environment configuration'
|
|
34
|
+
}];
|
|
35
|
+
const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment');
|
|
36
|
+
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
37
|
+
cmd.examples(examples);
|
|
38
|
+
cmd.argv(process.argv, async (arg, opt) => {
|
|
39
|
+
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
43
|
+
|
|
44
|
+
if (!environmentAlreadyExists) {
|
|
45
|
+
throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const currentInstanceData = (0, _devEnvironmentCore.readEnvironmentData)(slug);
|
|
49
|
+
debug('Read instance data', currentInstanceData);
|
|
50
|
+
const preselectedOptions = {
|
|
51
|
+
// Title and multisite can't be changed during update
|
|
52
|
+
title: currentInstanceData.wpTitle,
|
|
53
|
+
multisite: currentInstanceData.multisite,
|
|
54
|
+
...opt
|
|
55
|
+
};
|
|
56
|
+
debug('Combined preselected data are', preselectedOptions);
|
|
57
|
+
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(preselectedOptions, {}); // const instanceDataWithSlug = {
|
|
58
|
+
// ...currentInstanceData,
|
|
59
|
+
// siteSlug: slug,
|
|
60
|
+
// statsd: opt.statsd || false,
|
|
61
|
+
// phpmyadmin: opt.phpmyadmin || false,
|
|
62
|
+
// xdebug: opt.xdebug || false,
|
|
63
|
+
// };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if ('ENOENT' === error.code) {
|
|
66
|
+
const message = 'Environment was created before update was supported.\n\nTo update environment please destroy it and create a new one.';
|
|
67
|
+
(0, _devEnvironmentCli.handleCLIException)(new Error(message));
|
|
68
|
+
} else {
|
|
69
|
+
(0, _devEnvironmentCli.handleCLIException)(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
package/dist/bin/vip.js
CHANGED
|
@@ -15,7 +15,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
15
15
|
|
|
16
16
|
var _config = _interopRequireDefault(require("../../config/config.json"));
|
|
17
17
|
|
|
18
|
-
var _command =
|
|
18
|
+
var _command = _interopRequireWildcard(require("../lib/cli/command"));
|
|
19
19
|
|
|
20
20
|
var _token = _interopRequireDefault(require("../lib/token"));
|
|
21
21
|
|
|
@@ -23,6 +23,10 @@ var _tracker = require("../lib/tracker");
|
|
|
23
23
|
|
|
24
24
|
var _rollbar = require("../lib/rollbar");
|
|
25
25
|
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
26
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
31
|
|
|
28
32
|
/**
|
|
@@ -52,9 +56,10 @@ const rootCmd = async function () {
|
|
|
52
56
|
let token = await _token.default.get();
|
|
53
57
|
const isHelpCommand = process.argv.some(arg => arg === 'help' || arg === '-h' || arg === '--help');
|
|
54
58
|
const isLogoutCommand = process.argv.some(arg => arg === 'logout');
|
|
59
|
+
const isDevEnvCommandWithoutEnv = process.argv.some(arg => arg === 'dev-env') && !(0, _command.containsAppEnvArgument)(process.argv);
|
|
55
60
|
debug('Argv:', process.argv);
|
|
56
61
|
|
|
57
|
-
if (isLogoutCommand || isHelpCommand || token && token.valid()) {
|
|
62
|
+
if (isLogoutCommand || isHelpCommand || isDevEnvCommandWithoutEnv || token && token.valid()) {
|
|
58
63
|
runCmd();
|
|
59
64
|
} else {
|
|
60
65
|
console.log();
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
7
|
exports.getEnvIdentifier = getEnvIdentifier;
|
|
8
|
+
exports.containsAppEnvArgument = containsAppEnvArgument;
|
|
8
9
|
|
|
9
10
|
var _args = _interopRequireDefault(require("args"));
|
|
10
11
|
|
|
@@ -587,4 +588,9 @@ function getEnvIdentifier(env) {
|
|
|
587
588
|
}
|
|
588
589
|
|
|
589
590
|
return identifier;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function containsAppEnvArgument(argv) {
|
|
594
|
+
const parsedAlias = (0, _envAlias.parseEnvAliasFromArgv)(argv);
|
|
595
|
+
return !!(parsedAlias.app || parsedAlias.env || argv.includes('--app') || argv.includes('--env'));
|
|
590
596
|
}
|
|
@@ -3,42 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DEV_ENVIRONMENT_COMPONENTS = exports.DEV_ENVIRONMENT_PROMPT_INTRO = exports.DEV_ENVIRONMENT_DEFAULTS = exports.
|
|
6
|
+
exports.DEV_ENVIRONMENT_COMPONENTS = exports.DEV_ENVIRONMENT_PROMPT_INTRO = exports.DEV_ENVIRONMENT_DEFAULTS = exports.DEV_ENVIRONMENT_FULL_COMMAND = exports.DEV_ENVIRONMENT_SUBCOMMAND = void 0;
|
|
7
7
|
const DEV_ENVIRONMENT_SUBCOMMAND = 'dev-env';
|
|
8
8
|
exports.DEV_ENVIRONMENT_SUBCOMMAND = DEV_ENVIRONMENT_SUBCOMMAND;
|
|
9
9
|
const DEV_ENVIRONMENT_FULL_COMMAND = `vip ${DEV_ENVIRONMENT_SUBCOMMAND}`;
|
|
10
10
|
exports.DEV_ENVIRONMENT_FULL_COMMAND = DEV_ENVIRONMENT_FULL_COMMAND;
|
|
11
|
-
const DEV_ENVIRONMENT_CONTAINER_IMAGES = {
|
|
12
|
-
wordpress: {
|
|
13
|
-
image: 'ghcr.io/automattic/vip-container-images/wordpress'
|
|
14
|
-
},
|
|
15
|
-
muPlugins: {
|
|
16
|
-
image: 'ghcr.io/automattic/vip-container-images/mu-plugins',
|
|
17
|
-
tag: 'latest'
|
|
18
|
-
},
|
|
19
|
-
clientCode: {
|
|
20
|
-
image: 'ghcr.io/automattic/vip-container-images/skeleton',
|
|
21
|
-
tag: 'latest'
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.DEV_ENVIRONMENT_CONTAINER_IMAGES = DEV_ENVIRONMENT_CONTAINER_IMAGES;
|
|
25
11
|
const DEV_ENVIRONMENT_DEFAULTS = {
|
|
26
12
|
title: 'VIP Dev',
|
|
27
13
|
multisite: false,
|
|
28
14
|
elasticsearchVersion: '7.10.1',
|
|
29
|
-
mariadbVersion: '10.3'
|
|
30
|
-
wordpress: {},
|
|
31
|
-
muPlugins: {},
|
|
32
|
-
clientCode: {}
|
|
15
|
+
mariadbVersion: '10.3'
|
|
33
16
|
};
|
|
34
17
|
exports.DEV_ENVIRONMENT_DEFAULTS = DEV_ENVIRONMENT_DEFAULTS;
|
|
35
|
-
['muPlugins', 'clientCode'].forEach(type => {
|
|
36
|
-
DEV_ENVIRONMENT_DEFAULTS[type] = {
|
|
37
|
-
mode: 'image',
|
|
38
|
-
image: DEV_ENVIRONMENT_CONTAINER_IMAGES[type].image,
|
|
39
|
-
tag: DEV_ENVIRONMENT_CONTAINER_IMAGES[type].tag
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
18
|
const DEV_ENVIRONMENT_PROMPT_INTRO = 'This is a wizard to help you set up your local dev environment.\n\n' + 'Sensible default values were pre-selected for convenience. ' + 'You may also choose to create multiple environments with different settings using the --slug option.\n\n';
|
|
43
19
|
exports.DEV_ENVIRONMENT_PROMPT_INTRO = DEV_ENVIRONMENT_PROMPT_INTRO;
|
|
44
20
|
const DEV_ENVIRONMENT_COMPONENTS = ['wordpress', 'muPlugins', 'clientCode'];
|
|
@@ -104,7 +104,7 @@ function printTable(data) {
|
|
|
104
104
|
console.log(formattedData);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function processComponentOptionInput(passedParam,
|
|
107
|
+
function processComponentOptionInput(passedParam, allowLocal) {
|
|
108
108
|
// cast to string
|
|
109
109
|
const param = passedParam + '';
|
|
110
110
|
|
|
@@ -117,13 +117,12 @@ function processComponentOptionInput(passedParam, type, allowLocal) {
|
|
|
117
117
|
|
|
118
118
|
return {
|
|
119
119
|
mode: 'image',
|
|
120
|
-
image: _devEnvironment.DEV_ENVIRONMENT_CONTAINER_IMAGES[type].image,
|
|
121
120
|
tag: param
|
|
122
121
|
};
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
async function promptForArguments(providedOptions, appInfo) {
|
|
126
|
-
var _appInfo$environment;
|
|
125
|
+
var _appInfo$environment, _appInfo$environment3;
|
|
127
126
|
|
|
128
127
|
debug('Provided options', providedOptions);
|
|
129
128
|
console.log(_devEnvironment.DEV_ENVIRONMENT_PROMPT_INTRO);
|
|
@@ -144,10 +143,21 @@ async function promptForArguments(providedOptions, appInfo) {
|
|
|
144
143
|
multisite: 'multisite' in providedOptions ? providedOptions.multisite : await promptForBoolean(multisiteText, multisiteDefault),
|
|
145
144
|
elasticsearch: providedOptions.elasticsearch || _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.elasticsearchVersion,
|
|
146
145
|
mariadb: providedOptions.mariadb || _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.mariadbVersion,
|
|
146
|
+
mediaRedirectDomain: '',
|
|
147
147
|
wordpress: {},
|
|
148
148
|
muPlugins: {},
|
|
149
149
|
clientCode: {}
|
|
150
150
|
};
|
|
151
|
+
const primaryDomain = appInfo === null || appInfo === void 0 ? void 0 : (_appInfo$environment3 = appInfo.environment) === null || _appInfo$environment3 === void 0 ? void 0 : _appInfo$environment3.primaryDomain;
|
|
152
|
+
|
|
153
|
+
if (primaryDomain) {
|
|
154
|
+
const mediaRedirectPromptText = `Would you like to redirect to ${primaryDomain} for missing media files?`;
|
|
155
|
+
const setMediaRedirectDomain = await promptForBoolean(mediaRedirectPromptText, true);
|
|
156
|
+
|
|
157
|
+
if (setMediaRedirectDomain) {
|
|
158
|
+
instanceData.mediaRedirectDomain = primaryDomain;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
151
161
|
|
|
152
162
|
for (const component of _devEnvironment.DEV_ENVIRONMENT_COMPONENTS) {
|
|
153
163
|
const option = providedOptions[component];
|
|
@@ -162,7 +172,7 @@ async function processComponent(component, option) {
|
|
|
162
172
|
const allowLocal = component !== 'wordpress';
|
|
163
173
|
|
|
164
174
|
if (option) {
|
|
165
|
-
result = processComponentOptionInput(option,
|
|
175
|
+
result = processComponentOptionInput(option, allowLocal);
|
|
166
176
|
} else {
|
|
167
177
|
result = await promptForComponent(component, allowLocal);
|
|
168
178
|
}
|
|
@@ -182,7 +192,7 @@ async function processComponent(component, option) {
|
|
|
182
192
|
} else {
|
|
183
193
|
const message = `Provided path "${resolvedPath}" does not point to a valid or existing directory.`;
|
|
184
194
|
console.log(_chalk.default.yellow('Warning:'), message);
|
|
185
|
-
result = await promptForComponent(component);
|
|
195
|
+
result = await promptForComponent(component, allowLocal);
|
|
186
196
|
}
|
|
187
197
|
}
|
|
188
198
|
|
|
@@ -230,6 +240,7 @@ const componentDisplayNames = {
|
|
|
230
240
|
};
|
|
231
241
|
|
|
232
242
|
async function promptForComponent(component, allowLocal) {
|
|
243
|
+
debug(`Prompting for ${component}`);
|
|
233
244
|
const componentDisplayName = componentDisplayNames[component] || component;
|
|
234
245
|
const choices = [];
|
|
235
246
|
|
|
@@ -280,29 +291,24 @@ async function promptForComponent(component, allowLocal) {
|
|
|
280
291
|
} // image
|
|
281
292
|
|
|
282
293
|
|
|
283
|
-
|
|
284
|
-
const componentsWithPredefinedImageTag = ['muPlugins', 'clientCode'];
|
|
285
|
-
|
|
286
|
-
if (!componentsWithPredefinedImageTag.includes(component)) {
|
|
294
|
+
if (component === 'wordpress') {
|
|
287
295
|
const message = `${messagePrefix}Which version would you like`;
|
|
288
296
|
const selectTag = new _enquirer.Select({
|
|
289
297
|
message,
|
|
290
|
-
choices:
|
|
298
|
+
choices: getWordpressImageTags()
|
|
291
299
|
});
|
|
292
|
-
tag = await selectTag.run();
|
|
300
|
+
const tag = await selectTag.run();
|
|
301
|
+
return {
|
|
302
|
+
mode: modeResult,
|
|
303
|
+
tag
|
|
304
|
+
};
|
|
293
305
|
}
|
|
294
306
|
|
|
295
307
|
return {
|
|
296
|
-
mode: modeResult
|
|
297
|
-
image: _devEnvironment.DEV_ENVIRONMENT_CONTAINER_IMAGES[component].image,
|
|
298
|
-
tag
|
|
308
|
+
mode: modeResult
|
|
299
309
|
};
|
|
300
310
|
}
|
|
301
311
|
|
|
302
|
-
function
|
|
303
|
-
|
|
304
|
-
return ['5.8.1', '5.8', '5.7.3', '5.7.2'];
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return [];
|
|
312
|
+
function getWordpressImageTags() {
|
|
313
|
+
return ['5.8.1', '5.8', '5.7.3', '5.7.2'];
|
|
308
314
|
}
|
|
@@ -64,6 +64,7 @@ const nginxFileTemplatePath = _path.default.join(__dirname, '..', '..', '..', 'a
|
|
|
64
64
|
|
|
65
65
|
const landoFileName = '.lando.yml';
|
|
66
66
|
const nginxFileName = 'extra.conf';
|
|
67
|
+
const instanceDataFileName = 'instance_data.json';
|
|
67
68
|
const homeDirPathInsideContainers = '/user';
|
|
68
69
|
const uploadPathString = 'uploads';
|
|
69
70
|
const nginxPathString = 'nginx';
|
|
@@ -133,7 +134,14 @@ async function destroyEnvironment(slug, removeFiles) {
|
|
|
133
134
|
throw new Error('Environment not found.');
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
const landoFilePath = _path.default.join(instancePath, landoFileName);
|
|
138
|
+
|
|
139
|
+
if (_fs.default.existsSync(landoFilePath)) {
|
|
140
|
+
debug('Lando file exists, will lando destroy.');
|
|
141
|
+
await (0, _devEnvironmentLando.landoDestroy)(instancePath);
|
|
142
|
+
} else {
|
|
143
|
+
debug("Lando file doesn't exist, skipping lando destroy.");
|
|
144
|
+
}
|
|
137
145
|
|
|
138
146
|
if (removeFiles) {
|
|
139
147
|
await _fs.default.promises.rm(instancePath, {
|
|
@@ -200,6 +208,7 @@ function doesEnvironmentExist(slug) {
|
|
|
200
208
|
async function prepareLandoEnv(instanceData, instancePath) {
|
|
201
209
|
const landoFile = await _ejs.default.renderFile(landoFileTemplatePath, instanceData);
|
|
202
210
|
const nginxFile = await _ejs.default.renderFile(nginxFileTemplatePath, instanceData);
|
|
211
|
+
const instanceDataFile = JSON.stringify(instanceData);
|
|
203
212
|
|
|
204
213
|
const landoFileTargetPath = _path.default.join(instancePath, landoFileName);
|
|
205
214
|
|
|
@@ -207,6 +216,8 @@ async function prepareLandoEnv(instanceData, instancePath) {
|
|
|
207
216
|
|
|
208
217
|
const nginxFileTargetPath = _path.default.join(nginxFolderPath, nginxFileName);
|
|
209
218
|
|
|
219
|
+
const instanceDataTargetPath = _path.default.join(instancePath, instanceDataFileName);
|
|
220
|
+
|
|
210
221
|
_fs.default.mkdirSync(instancePath, {
|
|
211
222
|
recursive: true
|
|
212
223
|
});
|
|
@@ -219,8 +230,11 @@ async function prepareLandoEnv(instanceData, instancePath) {
|
|
|
219
230
|
|
|
220
231
|
_fs.default.writeFileSync(nginxFileTargetPath, nginxFile);
|
|
221
232
|
|
|
233
|
+
_fs.default.writeFileSync(instanceDataTargetPath, instanceDataFile);
|
|
234
|
+
|
|
222
235
|
debug(`Lando file created in ${landoFileTargetPath}`);
|
|
223
236
|
debug(`Nginx file created in ${nginxFileTargetPath}`);
|
|
237
|
+
debug(`Instance data file created in ${instanceDataTargetPath}`);
|
|
224
238
|
}
|
|
225
239
|
|
|
226
240
|
function getAllEnvironmentNames() {
|
|
@@ -269,7 +283,10 @@ async function getApplicationInformation(appId, envType) {
|
|
|
269
283
|
name,
|
|
270
284
|
type,
|
|
271
285
|
branch,
|
|
272
|
-
isMultisite
|
|
286
|
+
isMultisite,
|
|
287
|
+
primaryDomain {
|
|
288
|
+
name
|
|
289
|
+
}
|
|
273
290
|
}`;
|
|
274
291
|
const queryResult = await (0, _app.default)(appId, fieldsQuery);
|
|
275
292
|
const appData = {};
|
|
@@ -290,11 +307,14 @@ async function getApplicationInformation(appId, envType) {
|
|
|
290
307
|
}
|
|
291
308
|
|
|
292
309
|
if (envData) {
|
|
310
|
+
var _envData$primaryDomai;
|
|
311
|
+
|
|
293
312
|
appData.environment = {
|
|
294
313
|
name: envData.name,
|
|
295
314
|
branch: envData.branch,
|
|
296
315
|
type: envData.type,
|
|
297
|
-
isMultisite: envData.isMultisite
|
|
316
|
+
isMultisite: envData.isMultisite,
|
|
317
|
+
primaryDomain: ((_envData$primaryDomai = envData.primaryDomain) === null || _envData$primaryDomai === void 0 ? void 0 : _envData$primaryDomai.name) || ''
|
|
298
318
|
};
|
|
299
319
|
}
|
|
300
320
|
}
|
|
@@ -42,14 +42,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
42
42
|
/**
|
|
43
43
|
* This file will hold all the interactions with lando library
|
|
44
44
|
*/
|
|
45
|
-
const
|
|
45
|
+
const DEBUG_KEY = '@automattic/vip:bin:dev-environment-lando';
|
|
46
|
+
const debug = (0, _debug.default)(DEBUG_KEY);
|
|
46
47
|
|
|
47
48
|
function getLandoConfig() {
|
|
48
49
|
const landoPath = _path.default.join(__dirname, '..', '..', '..', 'node_modules', 'lando');
|
|
49
50
|
|
|
50
51
|
debug(`Getting lando config, using path '${landoPath}' for plugins`);
|
|
52
|
+
const logLevelConsole = (process.env.DEBUG || '').includes(DEBUG_KEY) ? 'debug' : 'warn';
|
|
51
53
|
return {
|
|
52
|
-
logLevelConsole
|
|
54
|
+
logLevelConsole,
|
|
53
55
|
landoFile: '.lando.yml',
|
|
54
56
|
preLandoFiles: ['.lando.base.yml', '.lando.dist.yml', '.lando.upstream.yml'],
|
|
55
57
|
postLandoFiles: ['.lando.local.yml'],
|