@automattic/vip 2.4.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/README.md CHANGED
@@ -27,6 +27,12 @@ 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
+
30
36
  ### 2.4.0 (5 November 2021)
31
37
  - #913 [dev-env] No login required for dev-env
32
38
  - #911 Adds more release instructions
@@ -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 (default: "VIP Dev")').option('multisite', 'Enable multisite install', undefined, value => {
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 or local directory (default: last stable)').option(['u', 'mu-plugins'], 'Use a specific mu-plugins changeset or local directory (default: "auto": last commit in master)').option('client-code', 'Use the client code from a local directory or VIP skeleton (default: use the VIP skeleton)').option('statsd', 'Enable statsd component. By default it is disabled', undefined, value => {
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));
@@ -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
+ });
@@ -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';
@@ -207,6 +208,7 @@ function doesEnvironmentExist(slug) {
207
208
  async function prepareLandoEnv(instanceData, instancePath) {
208
209
  const landoFile = await _ejs.default.renderFile(landoFileTemplatePath, instanceData);
209
210
  const nginxFile = await _ejs.default.renderFile(nginxFileTemplatePath, instanceData);
211
+ const instanceDataFile = JSON.stringify(instanceData);
210
212
 
211
213
  const landoFileTargetPath = _path.default.join(instancePath, landoFileName);
212
214
 
@@ -214,6 +216,8 @@ async function prepareLandoEnv(instanceData, instancePath) {
214
216
 
215
217
  const nginxFileTargetPath = _path.default.join(nginxFolderPath, nginxFileName);
216
218
 
219
+ const instanceDataTargetPath = _path.default.join(instancePath, instanceDataFileName);
220
+
217
221
  _fs.default.mkdirSync(instancePath, {
218
222
  recursive: true
219
223
  });
@@ -226,8 +230,11 @@ async function prepareLandoEnv(instanceData, instancePath) {
226
230
 
227
231
  _fs.default.writeFileSync(nginxFileTargetPath, nginxFile);
228
232
 
233
+ _fs.default.writeFileSync(instanceDataTargetPath, instanceDataFile);
234
+
229
235
  debug(`Lando file created in ${landoFileTargetPath}`);
230
236
  debug(`Nginx file created in ${nginxFileTargetPath}`);
237
+ debug(`Instance data file created in ${instanceDataTargetPath}`);
231
238
  }
232
239
 
233
240
  function getAllEnvironmentNames() {
@@ -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 debug = (0, _debug.default)('@automattic/vip:bin:dev-environment-lando');
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: 'warn',
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'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {