@automattic/vip 2.23.0 → 2.24.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  ## Changelog
2
2
 
3
+ ## 2.24.0 (06 Dec 2022)
4
+
5
+ - #1139 fix(dev-env): Fall back to copy when rename fails due to EXDEV
6
+ - #1170 [dev-env] Substitute the check for forward slash to with a cross-platform regex when processing component argument value
7
+ - #1174 Override WordPress image cache key in tests
8
+ - #1175 Dev-env: Throw error if more than one environment found when starting
9
+ - #1177 Logged out `vip --version`
10
+ - #1178 chore(deps): Fix some of vulnerable dependencies
11
+ - #1179 feat(dev-env): Do not prompt for missing values if stdin is not a TTY
12
+ - #1180 fix(dev-env): Fix a typo in parameter description
13
+ - #1181 fix(dev-env): Set SQL_MODE to match our production environment
14
+ - #1182 Dev-env: Throw UserError in getEnvironmentName() instead and default to first one if only one env
15
+ - #1184 Validate Preflight: Allow preflight checks to execute without explicit app and/or env
16
+ - #1185 feat(dev-env): Add support for MailHog
17
+ - #1186 feat(dev-env): Do not mount home directory into containers
18
+ - #1188 fix: Make bin files executables
19
+ - #1189 refactor(dev-env): Bootstrap Lando only once
20
+
3
21
  ## 2.23.0 (11 Nov 2022)
4
22
 
5
23
  - #1169 Preflight Validation: Change return code on error
@@ -9,19 +27,19 @@
9
27
 
10
28
  ## 2.22.0 (2 Nov 2022)
11
29
 
12
- #1165 Add caching type policy for `WPSite` data
13
- #1164 Fix regExp to categorize multisite tables during SQL Imports
14
- #1163 Pull correct environment's details from API when displaying Multisite SQL Import preflight details
15
- #1159 chore(deps): Bump debug from 4.3.3 to 4.3.4
16
- #1162 chore(deps): Bump update-notifier from 4.1.3 to 5.1.0
17
- #1160 chore(deps): Bump json2csv from 5.0.6 to 5.0.7
18
- #1158 chore(deps): Bump args from 5.0.1 to 5.0.3
19
- #1157 chore(deps): Bump semver from 7.3.5 to 7.3.8
20
- #1155 chore(deps): Bump uuid from 8.3.2 to 9.0.0
21
- #1154 chore(deps): Update Babel-related packages
22
- #1153 chore(deps): Fix security vulnerabilities in dependencies
23
- #1152 ci: Update workflows
24
- #1151 refactor(dev-env): Modify `verifyDNSResolution()` to use Promises API
30
+ #1165 Add caching type policy for `WPSite` data
31
+ #1164 Fix regExp to categorize multisite tables during SQL Imports
32
+ #1163 Pull correct environment's details from API when displaying Multisite SQL Import preflight details
33
+ #1159 chore(deps): Bump debug from 4.3.3 to 4.3.4
34
+ #1162 chore(deps): Bump update-notifier from 4.1.3 to 5.1.0
35
+ #1160 chore(deps): Bump json2csv from 5.0.6 to 5.0.7
36
+ #1158 chore(deps): Bump args from 5.0.1 to 5.0.3
37
+ #1157 chore(deps): Bump semver from 7.3.5 to 7.3.8
38
+ #1155 chore(deps): Bump uuid from 8.3.2 to 9.0.0
39
+ #1154 chore(deps): Update Babel-related packages
40
+ #1153 chore(deps): Fix security vulnerabilities in dependencies
41
+ #1152 ci: Update workflows
42
+ #1151 refactor(dev-env): Modify `verifyDNSResolution()` to use Promises API
25
43
 
26
44
  ### 2.21.0 (24 Oct 2022)
27
45
 
@@ -67,7 +67,7 @@ services:
67
67
  type: compose
68
68
  services:
69
69
  image: mariadb:<%= mariadb %>
70
- command: docker-entrypoint.sh mysqld
70
+ command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
71
71
  ports:
72
72
  - ":3306"
73
73
  environment:
@@ -174,6 +174,11 @@ services:
174
174
  clientcode_vipconfig: {}
175
175
  <% } %>
176
176
 
177
+ <% if ( mailhog ) { %>
178
+ mailhog:
179
+ type: mailhog
180
+ <% } %>
181
+
177
182
  tooling:
178
183
  wp:
179
184
  service: php
@@ -18,6 +18,7 @@ var exit = _interopRequireWildcard(require("../lib/cli/exit"));
18
18
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
19
19
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
20
20
  var _devEnvironment = require("../lib/constants/dev-environment");
21
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
21
22
  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); }
22
23
  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; }
23
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -51,8 +52,12 @@ cmd.argv(process.argv, async (arg, opt) => {
51
52
  env: opt.env,
52
53
  allowAppEnv: true
53
54
  };
54
- const slug = (0, _devEnvironmentCli.getEnvironmentName)(environmentNameOptions);
55
- await (0, _devEnvironmentCli.validateDependencies)(slug);
55
+ let slug = _devEnvironmentCli.DEFAULT_SLUG;
56
+ if (Object.keys(opt).length !== 0) {
57
+ slug = (0, _devEnvironmentCli.getEnvironmentName)(environmentNameOptions);
58
+ }
59
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
60
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
56
61
  debug('Args: ', arg, 'Options: ', opt);
57
62
  const trackingInfo = {
58
63
  slug,
@@ -81,7 +86,7 @@ cmd.argv(process.argv, async (arg, opt) => {
81
86
  instanceData.siteSlug = slug;
82
87
  try {
83
88
  await (0, _devEnvironmentCore.createEnvironment)(instanceData);
84
- await (0, _devEnvironmentCore.printEnvironmentInfo)(slug, {
89
+ await (0, _devEnvironmentCore.printEnvironmentInfo)(lando, slug, {
85
90
  extended: false
86
91
  });
87
92
  const message = '\n' + _chalk.default.green('✓') + ` environment created.\n\nTo start it please run:\n\n${startCommand}\n`;
@@ -17,6 +17,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
17
17
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
18
18
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
19
19
  var _devEnvironment = require("../lib/constants/dev-environment");
20
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  /**
22
23
  * Internal dependencies
@@ -31,13 +32,14 @@ const examples = [{
31
32
  }];
32
33
  (0, _command.default)().option('slug', 'Custom name of the dev environment').option('soft', 'Keep config files needed to start an environment intact').examples(examples).argv(process.argv, async (arg, opt) => {
33
34
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
34
- await (0, _devEnvironmentCli.validateDependencies)(slug);
35
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
36
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
35
37
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
36
38
  await (0, _tracker.trackEvent)('dev_env_destroy_command_execute', trackingInfo);
37
39
  debug('Args: ', arg, 'Options: ', opt);
38
40
  try {
39
41
  const removeFiles = !(opt.soft || false);
40
- await (0, _devEnvironmentCore.destroyEnvironment)(slug, removeFiles);
42
+ await (0, _devEnvironmentCore.destroyEnvironment)(lando, slug, removeFiles);
41
43
  const message = _chalk.default.green('✓') + ' Environment destroyed.\n';
42
44
  console.log(message);
43
45
  await (0, _tracker.trackEvent)('dev_env_destroy_command_success', trackingInfo);
@@ -19,6 +19,7 @@ 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");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
24
  const examples = [{
24
25
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} exec -- wp post list`,
@@ -37,7 +38,8 @@ const examples = [{
37
38
  return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
38
39
  }).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
39
40
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
40
- await (0, _devEnvironmentCli.validateDependencies)(slug);
41
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
42
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
41
43
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
42
44
  await (0, _tracker.trackEvent)('dev_env_exec_command_execute', trackingInfo);
43
45
  try {
@@ -54,7 +56,7 @@ const examples = [{
54
56
  const options = {
55
57
  force: opt.force
56
58
  };
57
- await (0, _devEnvironmentCore.exec)(slug, arg, options);
59
+ await (0, _devEnvironmentCore.exec)(lando, slug, arg, options);
58
60
  await (0, _tracker.trackEvent)('dev_env_exec_command_success', trackingInfo);
59
61
  } catch (error) {
60
62
  (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_exec_command_error', trackingInfo);
@@ -19,6 +19,7 @@ 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");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
24
  const examples = [{
24
25
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import media path/to/wp-content/uploads`,
@@ -32,7 +33,8 @@ const examples = [{
32
33
  }).examples(examples).option('slug', 'Custom name of the dev environment').argv(process.argv, async (unmatchedArgs, opt) => {
33
34
  const [filePath] = unmatchedArgs;
34
35
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
35
- await (0, _devEnvironmentCli.validateDependencies)(slug);
36
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
37
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
36
38
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
37
39
  await (0, _tracker.trackEvent)('dev_env_import_media_command_execute', trackingInfo);
38
40
  try {
@@ -17,6 +17,7 @@ var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
17
17
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
18
18
  var _devEnvironment = require("../lib/constants/dev-environment");
19
19
  var _sql = require("../lib/validations/sql");
20
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  /**
22
23
  * Internal dependencies
@@ -43,7 +44,8 @@ const examples = [{
43
44
  inPlace
44
45
  } = opt;
45
46
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
46
- await (0, _devEnvironmentCli.validateDependencies)(slug);
47
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
48
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
47
49
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
48
50
  await (0, _tracker.trackEvent)('dev_env_import_sql_command_execute', trackingInfo);
49
51
  try {
@@ -62,23 +64,23 @@ const examples = [{
62
64
  });
63
65
  }
64
66
  const importArg = ['wp', 'db', 'import', inContainerPath];
65
- await (0, _devEnvironmentCore.exec)(slug, importArg);
67
+ await (0, _devEnvironmentCore.exec)(lando, slug, importArg);
66
68
  if (searchReplace && searchReplace.length && !inPlace) {
67
69
  _fs.default.unlinkSync(resolvedPath);
68
70
  }
69
71
  const cacheArg = ['wp', 'cache', 'flush'];
70
- await (0, _devEnvironmentCore.exec)(slug, cacheArg);
72
+ await (0, _devEnvironmentCore.exec)(lando, slug, cacheArg);
71
73
  try {
72
- await (0, _devEnvironmentCore.exec)(slug, ['wp', 'cli', 'has-command', 'vip-search']);
74
+ await (0, _devEnvironmentCore.exec)(lando, slug, ['wp', 'cli', 'has-command', 'vip-search']);
73
75
  const doIndex = await (0, _devEnvironmentCli.promptForBoolean)('Do you want to index data in ElasticSearch (used by enterprise search)?', true);
74
76
  if (doIndex) {
75
- await (0, _devEnvironmentCore.exec)(slug, ['wp', 'vip-search', 'index', '--setup', '--network-wide', '--skip-confirm']);
77
+ await (0, _devEnvironmentCore.exec)(lando, slug, ['wp', 'vip-search', 'index', '--setup', '--network-wide', '--skip-confirm']);
76
78
  }
77
79
  } catch (err) {
78
80
  // Exception means they don't have vip-search enabled.
79
81
  }
80
82
  const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'];
81
- await (0, _devEnvironmentCore.exec)(slug, addUserArg);
83
+ await (0, _devEnvironmentCore.exec)(lando, slug, addUserArg);
82
84
  await (0, _tracker.trackEvent)('dev_env_import_sql_command_success', trackingInfo);
83
85
  } catch (error) {
84
86
  (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_sql_command_error', trackingInfo);
@@ -16,6 +16,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
16
16
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
17
17
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
18
18
  var _devEnvironment = require("../lib/constants/dev-environment");
19
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21
  /**
21
22
  * Internal dependencies
@@ -30,7 +31,8 @@ const examples = [{
30
31
  }];
31
32
  (0, _command.default)().option('slug', 'Custom name of the dev environment').option('all', 'Show Info for all local dev environments').option('extended', 'Show extended information about the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
32
33
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
33
- await (0, _devEnvironmentCli.validateDependencies)(slug);
34
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
35
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
34
36
  const trackingInfo = opt.all ? {
35
37
  all: true
36
38
  } : (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
@@ -41,9 +43,9 @@ const examples = [{
41
43
  extended: !!opt.extended
42
44
  };
43
45
  if (opt.all) {
44
- await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(options);
46
+ await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(lando, options);
45
47
  } else {
46
- await (0, _devEnvironmentCore.printEnvironmentInfo)(slug, options);
48
+ await (0, _devEnvironmentCore.printEnvironmentInfo)(lando, slug, options);
47
49
  }
48
50
  await (0, _tracker.trackEvent)('dev_env_info_command_success', trackingInfo);
49
51
  } catch (error) {
@@ -19,19 +19,21 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
19
19
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
20
20
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
21
21
  var _devEnvironment = require("../lib/constants/dev-environment");
22
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
24
  const examples = [{
24
25
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} list`,
25
26
  description: 'Return information about all local dev environments'
26
27
  }];
27
28
  (0, _command.default)().examples(examples).argv(process.argv, async () => {
28
- await (0, _devEnvironmentCli.validateDependencies)();
29
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
30
+ await (0, _devEnvironmentCli.validateDependencies)(lando, '');
29
31
  const trackingInfo = {
30
32
  all: true
31
33
  };
32
34
  await (0, _tracker.trackEvent)('dev_env_list_command_execute', trackingInfo);
33
35
  try {
34
- await (0, _devEnvironmentCore.printAllEnvironmentsInfo)({});
36
+ await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(lando, {});
35
37
  await (0, _tracker.trackEvent)('dev_env_list_command_success', trackingInfo);
36
38
  } catch (error) {
37
39
  (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_list_command_error', trackingInfo);
@@ -18,6 +18,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
18
18
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
19
19
  var _devEnvironment = require("../lib/constants/dev-environment");
20
20
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
21
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
21
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
23
  /**
23
24
  * Internal dependencies
@@ -30,9 +31,10 @@ const examples = [{
30
31
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start`,
31
32
  description: 'Starts a local dev environment'
32
33
  }];
33
- (0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip propting for wordpress update if non latest').examples(examples).argv(process.argv, async (arg, opt) => {
34
+ (0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip prompting for wordpress update if non latest').examples(examples).argv(process.argv, async (arg, opt) => {
34
35
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
35
- await (0, _devEnvironmentCli.validateDependencies)(slug);
36
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
37
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
36
38
  const startProcessing = new Date();
37
39
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
38
40
  await (0, _tracker.trackEvent)('dev_env_start_command_execute', trackingInfo);
@@ -56,7 +58,7 @@ const examples = [{
56
58
  }
57
59
  });
58
60
  }
59
- await (0, _devEnvironmentCore.startEnvironment)(slug, options);
61
+ await (0, _devEnvironmentCore.startEnvironment)(lando, slug, options);
60
62
  const processingTime = Math.ceil((new Date() - startProcessing) / 1000); // in seconds
61
63
  const successTrackingInfo = {
62
64
  ...trackingInfo,
@@ -17,6 +17,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
17
17
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
18
18
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
19
19
  var _devEnvironment = require("../lib/constants/dev-environment");
20
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  /**
22
23
  * Internal dependencies
@@ -28,12 +29,13 @@ const examples = [{
28
29
  }];
29
30
  (0, _command.default)().option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
30
31
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
31
- await (0, _devEnvironmentCli.validateDependencies)(slug);
32
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
33
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
32
34
  debug('Args: ', arg, 'Options: ', opt);
33
35
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
34
36
  await (0, _tracker.trackEvent)('dev_env_stop_command_execute', trackingInfo);
35
37
  try {
36
- await (0, _devEnvironmentCore.stopEnvironment)(slug);
38
+ await (0, _devEnvironmentCore.stopEnvironment)(lando, slug);
37
39
  const message = _chalk.default.green('✓') + ' environment stopped.\n';
38
40
  console.log(message);
39
41
  await (0, _tracker.trackEvent)('dev_env_stop_command_success', trackingInfo);
@@ -17,6 +17,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
17
17
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
18
18
  var _devEnvironment = require("../lib/constants/dev-environment");
19
19
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
20
+ var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  /**
22
23
  * Internal dependencies
@@ -31,7 +32,8 @@ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev envir
31
32
  cmd.examples(examples);
32
33
  cmd.argv(process.argv, async (arg, opt) => {
33
34
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
34
- await (0, _devEnvironmentCli.validateDependencies)(slug);
35
+ const lando = await (0, _devEnvironmentLando.bootstrapLando)();
36
+ await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
35
37
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
36
38
  await (0, _tracker.trackEvent)('dev_env_update_command_execute', trackingInfo);
37
39
  try {
@@ -57,6 +59,7 @@ cmd.argv(process.argv, async (arg, opt) => {
57
59
  statsd: currentInstanceData.statsd,
58
60
  phpmyadmin: currentInstanceData.phpmyadmin,
59
61
  xdebug: currentInstanceData.xdebug,
62
+ mailhog: currentInstanceData.mailhog,
60
63
  mediaRedirectDomain: currentInstanceData.mediaRedirectDomain,
61
64
  multisite: false,
62
65
  title: ''
@@ -16,7 +16,9 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
16
16
  var _fs = require("fs");
17
17
  var _ini = _interopRequireDefault(require("ini"));
18
18
  var _chalk = _interopRequireDefault(require("chalk"));
19
+ var _enquirer = require("enquirer");
19
20
  var _command = _interopRequireDefault(require("../lib/cli/command"));
21
+ var _envAlias = require("../lib/cli/envAlias");
20
22
  var exit = _interopRequireWildcard(require("../lib/cli/exit"));
21
23
  var _api = _interopRequireWildcard(require("../lib/api"));
22
24
  var _tracker = require("../lib/tracker");
@@ -26,6 +28,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
28
  /**
27
29
  * Internal dependencies
28
30
  */
31
+ const ALLOWED_NODEJS_VERSIONS = ['14', '16', '18'];
29
32
  const appQuery = `
30
33
  id
31
34
  name
@@ -108,11 +111,13 @@ async function getBuildConfiguration(application, environment) {
108
111
  }
109
112
  }
110
113
  async function vipValidatePreflightCommand(arg, opt) {
111
- var _opt$env$environmentV;
114
+ var _opt$env$appId, _opt$env, _opt$env$id, _opt$env2, _opt$app$repo, _opt$app, _opt$env3, _opt$env3$environment;
112
115
  harmoniaArgs = await validateArgs(opt);
116
+ const appId = (_opt$env$appId = (_opt$env = opt.env) === null || _opt$env === void 0 ? void 0 : _opt$env.appId) !== null && _opt$env$appId !== void 0 ? _opt$env$appId : 0;
117
+ const envId = (_opt$env$id = (_opt$env2 = opt.env) === null || _opt$env2 === void 0 ? void 0 : _opt$env2.id) !== null && _opt$env$id !== void 0 ? _opt$env$id : 0;
113
118
  const baseTrackingParams = {
114
- env_id: opt.env.id,
115
- app_id: opt.env.appId,
119
+ env_id: envId,
120
+ app_id: appId,
116
121
  command: 'vip validate preflight',
117
122
  ...sanitizeArgsForTracking(harmoniaArgs)
118
123
  };
@@ -137,9 +142,9 @@ async function vipValidatePreflightCommand(arg, opt) {
137
142
 
138
143
  // Create the Site Config objects
139
144
  const siteOptions = new _vipGoPreflightChecks.SiteConfig({
140
- siteID: opt.app.id,
145
+ siteID: envId,
141
146
  nodejsVersion: harmoniaArgs.nodejsVersion,
142
- repository: opt.app.repo,
147
+ repository: (_opt$app$repo = (_opt$app = opt.app) === null || _opt$app === void 0 ? void 0 : _opt$app.repo) !== null && _opt$app$repo !== void 0 ? _opt$app$repo : 'no-repo',
143
148
  baseURL: 'http://localhost:' + harmoniaArgs.port,
144
149
  dockerBuildEnvs: harmoniaArgs.nodeBuildDockerEnv,
145
150
  topRequests: [],
@@ -161,7 +166,7 @@ async function vipValidatePreflightCommand(arg, opt) {
161
166
  return exit.withError(`Could not find a 'package.json' in the current folder (${opt.path}).`);
162
167
  }
163
168
  const customEnvVars = {};
164
- if (((_opt$env$environmentV = opt.env.environmentVariables) === null || _opt$env$environmentV === void 0 ? void 0 : _opt$env$environmentV.nodes.length) > 0) {
169
+ if (((_opt$env3 = opt.env) === null || _opt$env3 === void 0 ? void 0 : (_opt$env3$environment = _opt$env3.environmentVariables) === null || _opt$env3$environment === void 0 ? void 0 : _opt$env3$environment.nodes.length) > 0) {
165
170
  opt.env.environmentVariables.nodes.forEach(envVar => {
166
171
  customEnvVars[envVar.name] = envVar.value;
167
172
  });
@@ -362,7 +367,7 @@ async function handleResults(harmonia, results) {
362
367
  process.exit(0);
363
368
  }
364
369
  async function validateArgs(opt) {
365
- var _opt$nodeVersion, _opt$wait, _opt$port;
370
+ var _opt$wait, _opt$port;
366
371
  const args = {};
367
372
 
368
373
  // Verbose
@@ -380,15 +385,39 @@ async function validateArgs(opt) {
380
385
  suppressOutput = true;
381
386
  outputJson = true;
382
387
  }
388
+ if (opt.app) {
389
+ var _opt$nodeVersion;
390
+ // Get build information from API and store it in the env object
391
+ const buildConfig = await getBuildConfiguration(opt.app, opt.env);
392
+ args.app_id = opt.app.id;
393
+ args.env_id = opt.env.id;
394
+ args.nodejsVersion = (_opt$nodeVersion = opt.nodeVersion) !== null && _opt$nodeVersion !== void 0 ? _opt$nodeVersion : buildConfig.nodeJSVersion;
395
+ args.buildType = buildConfig.buildType;
396
+ args.npmToken = buildConfig.npmToken;
397
+ args.nodeBuildDockerEnv = buildConfig.nodeBuildDockerEnv;
398
+ } else {
399
+ args.app_id = 0;
400
+ args.env_id = 0;
401
+ args.buildType = 'nodejs';
383
402
 
384
- // Get build information from API and store it in the env object
385
- const buildConfig = await getBuildConfiguration(opt.app, opt.env);
386
- args.app_id = opt.app.id;
387
- args.env_id = opt.env.id;
388
- args.nodejsVersion = (_opt$nodeVersion = opt.nodeVersion) !== null && _opt$nodeVersion !== void 0 ? _opt$nodeVersion : buildConfig.nodeJSVersion;
389
- args.buildType = buildConfig.buildType;
390
- args.npmToken = buildConfig.npmToken;
391
- args.nodeBuildDockerEnv = buildConfig.nodeBuildDockerEnv;
403
+ // If no node.js version is specified, prompt the user to select one
404
+ if (!opt.nodeVersion) {
405
+ // Ask for a node.js version
406
+ try {
407
+ const selection = await (0, _enquirer.prompt)({
408
+ type: 'select',
409
+ name: 'nodejsVersion',
410
+ message: 'Which Node.js version do you want to use?',
411
+ choices: ALLOWED_NODEJS_VERSIONS
412
+ });
413
+ args.nodejsVersion = selection.nodejsVersion;
414
+ } catch (err) {
415
+ exit.withError('No Node.js version selected. Aborting.');
416
+ }
417
+ } else {
418
+ args.nodejsVersion = opt.nodeVersion;
419
+ }
420
+ }
392
421
  args.wait = (_opt$wait = opt.wait) !== null && _opt$wait !== void 0 ? _opt$wait : 3000;
393
422
  args.port = (_opt$port = opt.port) !== null && _opt$port !== void 0 ? _opt$port : Math.floor(Math.random() * 1000) + 3001; // Get a PORT from 3001 and 3999
394
423
 
@@ -413,12 +442,23 @@ function sanitizeArgsForTracking(args) {
413
442
  });
414
443
  return sanitizedArgs;
415
444
  }
416
- (0, _command.default)({
417
- appContext: true,
418
- appQuery,
419
- envContext: true,
445
+ let commandOpts = {
420
446
  module: 'harmonia'
421
- }).option('verbose', 'Increase logging level to include app build and server boot up messages', false).option('node-version', 'Select a specific target Node.JS version in semver format (MAJOR.MINOR.PATCH) or a MAJOR').option('wait', 'Configure the time to wait in ms for the app to boot up. Do not change unless you have issues', 3000).option(['p', 'port'], 'Configure the port to use for the app (defaults to a random port between 3001 and 3999)').option('json', 'Output the results as JSON', false).option(['P', 'path'], 'Path to the app to be tested', process.cwd()).examples([{
447
+ };
448
+
449
+ // The @app.env selector is optional, so we need to check if it was passed
450
+ const parsedAlias = (0, _envAlias.parseEnvAliasFromArgv)(process.argv);
451
+ if (parsedAlias.app) {
452
+ commandOpts = {
453
+ ...commandOpts,
454
+ appQuery,
455
+ envContext: true,
456
+ appContext: true
457
+ };
458
+ } else {
459
+ logToConsole(_chalk.default.bold.yellow('Warning: ') + 'The preflight tests are running without a provided application and/or environment.\n' + 'Some app-dependent configurations, such as environment variables, might not defined.');
460
+ }
461
+ (0, _command.default)(commandOpts).option('verbose', 'Increase logging level to include app build and server boot up messages', false).option('node-version', 'Select a specific target Node.JS version in semver format (MAJOR.MINOR.PATCH) or a MAJOR').option('wait', 'Configure the time to wait in ms for the app to boot up. Do not change unless you have issues', 3000).option(['p', 'port'], 'Configure the port to use for the app (defaults to a random port between 3001 and 3999)').option('json', 'Output the results as JSON', false).option(['P', 'path'], 'Path to the app to be tested', process.cwd()).examples([{
422
462
  usage: 'vip @mysite.production validate preflight',
423
463
  description: 'Runs the preflight tests to validate if your application is ready to be deployed to VIP Go'
424
464
  }, {
package/dist/bin/vip.js CHANGED
@@ -37,14 +37,18 @@ const runCmd = async function () {
37
37
  }).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('validate', 'Validate your VIP application and environment').command('wp', 'Run WP CLI commands against an environment');
38
38
  cmd.argv(process.argv);
39
39
  };
40
+ function doesArgvHaveAtLeastOneParam(argv, params) {
41
+ return argv.some(arg => params.includes(arg));
42
+ }
40
43
  const rootCmd = async function () {
41
44
  let token = await _token.default.get();
42
- const isHelpCommand = process.argv.some(arg => arg === 'help' || arg === '-h' || arg === '--help');
43
- const isLogoutCommand = process.argv.some(arg => arg === 'logout');
44
- const isLoginCommand = process.argv.some(arg => arg === 'login');
45
- const isDevEnvCommandWithoutEnv = process.argv.some(arg => arg === 'dev-env') && !(0, _command.containsAppEnvArgument)(process.argv);
45
+ const isHelpCommand = doesArgvHaveAtLeastOneParam(process.argv, ['help', '-h', '--help']);
46
+ const isVersionCommand = doesArgvHaveAtLeastOneParam(process.argv, ['-v', '--version']);
47
+ const isLogoutCommand = doesArgvHaveAtLeastOneParam(process.argv, ['logout']);
48
+ const isLoginCommand = doesArgvHaveAtLeastOneParam(process.argv, ['login']);
49
+ const isDevEnvCommandWithoutEnv = doesArgvHaveAtLeastOneParam(process.argv, ['dev-env']) && !(0, _command.containsAppEnvArgument)(process.argv);
46
50
  debug('Argv:', process.argv);
47
- if (!isLoginCommand && (isLogoutCommand || isHelpCommand || isDevEnvCommandWithoutEnv || token && token.valid())) {
51
+ if (!isLoginCommand && (isLogoutCommand || isHelpCommand || isVersionCommand || isDevEnvCommandWithoutEnv || token && token.valid())) {
48
52
  runCmd();
49
53
  } else {
50
54
  console.log();