@automattic/vip 2.17.0 → 2.19.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,20 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.19.0 (23 Sep 2022)
4
+ - #1108 [dev-env] Validate import file and add debug lines
5
+ - #1107 [dev-env] Validate dns lookup
6
+ - #1104 [dev-env] fetch php and wordpress versions for creation wizard
7
+ - #1049 Fix security issues
8
+
9
+ ### 2.18.0 (15 Sep 2022)
10
+ - #1103 Force the preference for WebSocket in case we see an error during connection
11
+ - #1102 Remove http proxy support
12
+ - #1096 [dev-env] Supports extended information table
13
+ - #1100 Add GitHub action to mark inactive issues and PRs as stale
14
+ - #1099 Add @app.env to commands help
15
+ - #1092 Improve login + logout
16
+ - #1097 Don't pipe output through less
17
+
3
18
  ### 2.17.0 (06 Sep 2022)
4
19
  - #1093 [dev-env] use latest proxy image
5
20
  - #1091 Extract http helper into standalone function
@@ -34,7 +34,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34
34
  /**
35
35
  * Internal dependencies
36
36
  */
37
- const baseUsage = 'vip config envvar delete'; // Command examples
37
+ const baseUsage = 'vip @mysite.develop config envvar delete'; // Command examples
38
38
 
39
39
  const examples = [{
40
40
  usage: `${baseUsage} MY_VARIABLE`,
@@ -34,7 +34,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34
34
  /**
35
35
  * Internal dependencies
36
36
  */
37
- const usage = 'vip config envvar get-all'; // Command examples
37
+ const usage = 'vip @mysite.develop config envvar get-all'; // Command examples
38
38
 
39
39
  const examples = [{
40
40
  usage,
@@ -32,7 +32,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
32
32
  /**
33
33
  * Internal dependencies
34
34
  */
35
- const baseUsage = 'vip config envvar get'; // Command examples
35
+ const baseUsage = 'vip @mysite.develop config envvar get'; // Command examples
36
36
 
37
37
  const examples = [{
38
38
  usage: `${baseUsage} MY_VARIABLE`,
@@ -34,7 +34,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34
34
  /**
35
35
  * Internal dependencies
36
36
  */
37
- const usage = 'vip config envvar list'; // Command examples
37
+ const usage = 'vip @mysite.develop config envvar list'; // Command examples
38
38
 
39
39
  const examples = [{
40
40
  usage,
@@ -36,7 +36,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
36
36
  /**
37
37
  * Internal dependencies
38
38
  */
39
- const baseUsage = 'vip config envvar set';
39
+ const baseUsage = 'vip @mysite.develop config envvar set';
40
40
  const NEW_RELIC_ENVVAR_KEY = 'NEW_RELIC_LICENSE_KEY'; // Command examples
41
41
 
42
42
  const examples = [{
@@ -28,10 +28,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
28
 
29
29
  // Command examples
30
30
  const examples = [{
31
- usage: 'vip config software get wordpress --format json',
31
+ usage: 'vip @mysite.develop config software get wordpress --format json',
32
32
  description: 'Read current software settings for WordPress in JSON format'
33
33
  }, {
34
- usage: 'vip config software get',
34
+ usage: 'vip @mysite.develop config software get',
35
35
  description: 'Read current software settings for all components'
36
36
  }];
37
37
  (0, _command.default)({
@@ -41,7 +41,7 @@ const examples = [{
41
41
  envContext: true,
42
42
  wildcardCommand: true,
43
43
  format: true,
44
- usage: 'vip config software get <wordpress|php|nodejs|muplugins>'
44
+ usage: 'vip @mysite.develop config software get <wordpress|php|nodejs|muplugins>'
45
45
  }).examples(examples).argv(process.argv, async (arg, opt) => {
46
46
  var _opt$env;
47
47
 
@@ -43,12 +43,12 @@ const cmd = (0, _command.default)({
43
43
  appQueryFragments: _software.appQueryFragments,
44
44
  envContext: true,
45
45
  wildcardCommand: true,
46
- usage: 'vip config software update <wordpress|php|nodejs|muplugins> <version>'
46
+ usage: 'vip @mysite.develop config software update <wordpress|php|nodejs|muplugins> <version>'
47
47
  }).examples([{
48
- usage: 'vip config software update wordpress 6.0',
48
+ usage: 'vip @mysite.develop config software update wordpress 6.0',
49
49
  description: 'Update WordPress to 6.0.x'
50
50
  }, {
51
- usage: 'vip config software update nodejs 16',
51
+ usage: 'vip @mysite.develop config software update nodejs 16',
52
52
  description: 'Update Node.js to v16'
53
53
  }]);
54
54
  cmd.option('force', 'Auto-confirm update');
@@ -20,8 +20,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
20
20
 
21
21
  (0, _command.default)({
22
22
  requiredArgs: 1,
23
- usage: 'vip config software <action>'
24
- }).command('get', 'Read current software settings').command('update', 'Update software settings').examples([{
25
- usage: 'vip config software update <wordpress|php|nodejs|muplugins> <version>',
26
- description: 'Update <component> to <version>'
27
- }]).argv(process.argv);
23
+ usage: 'vip @mysite.develop config software <action>'
24
+ }).command('get', 'Read current software settings').command('update', 'Update software settings').argv(process.argv);
@@ -56,7 +56,6 @@ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev envir
56
56
  (0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
57
57
  cmd.examples(examples);
58
58
  cmd.argv(process.argv, async (arg, opt) => {
59
- await (0, _devEnvironmentCli.validateDependencies)();
60
59
  const environmentNameOptions = {
61
60
  slug: opt.slug,
62
61
  app: opt.app,
@@ -64,6 +63,7 @@ cmd.argv(process.argv, async (arg, opt) => {
64
63
  allowAppEnv: true
65
64
  };
66
65
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(environmentNameOptions);
66
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
67
67
  debug('Args: ', arg, 'Options: ', opt);
68
68
  const trackingInfo = {
69
69
  slug
@@ -97,7 +97,9 @@ cmd.argv(process.argv, async (arg, opt) => {
97
97
 
98
98
  try {
99
99
  await (0, _devEnvironmentCore.createEnvironment)(instanceData);
100
- await (0, _devEnvironmentCore.printEnvironmentInfo)(slug);
100
+ await (0, _devEnvironmentCore.printEnvironmentInfo)(slug, {
101
+ extended: false
102
+ });
101
103
  const message = '\n' + _chalk.default.green('✓') + ` environment created.\n\nTo start it please run:\n\n${startCommand}\n`;
102
104
  console.log(message);
103
105
  await (0, _tracker.trackEvent)('dev_env_create_command_success', trackingInfo);
@@ -38,8 +38,8 @@ const examples = [{
38
38
  description: 'Destroys a local dev environment named foo'
39
39
  }];
40
40
  (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) => {
41
- await (0, _devEnvironmentCli.validateDependencies)();
42
41
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
42
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
43
43
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
44
44
  await (0, _tracker.trackEvent)('dev_env_destroy_command_execute', trackingInfo);
45
45
  debug('Args: ', arg, 'Options: ', opt);
@@ -43,8 +43,8 @@ const examples = [{
43
43
 
44
44
  return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
45
45
  }).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
46
- await (0, _devEnvironmentCli.validateDependencies)();
47
46
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
47
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
48
48
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
49
49
  await (0, _tracker.trackEvent)('dev_env_exec_command_execute', trackingInfo);
50
50
 
@@ -36,9 +36,9 @@ const examples = [{
36
36
  (0, _command.default)({
37
37
  requiredArgs: 1
38
38
  }).examples(examples).option('slug', 'Custom name of the dev environment').argv(process.argv, async (unmatchedArgs, opt) => {
39
- await (0, _devEnvironmentCli.validateDependencies)();
40
39
  const [filePath] = unmatchedArgs;
41
40
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
41
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
42
42
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
43
43
  await (0, _tracker.trackEvent)('dev_env_import_media_command_execute', trackingInfo);
44
44
 
@@ -45,13 +45,13 @@ const examples = [{
45
45
  (0, _command.default)({
46
46
  requiredArgs: 1
47
47
  }).option('slug', 'Custom name of the dev environment').option(['r', 'search-replace'], 'Perform Search and Replace on the specified SQL file').option('in-place', 'Search and Replace explicitly on the given input file').option('skip-validate', 'Do not perform file validation.').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
48
- await (0, _devEnvironmentCli.validateDependencies)();
49
48
  const [fileName] = unmatchedArgs;
50
49
  const {
51
50
  searchReplace,
52
51
  inPlace
53
52
  } = opt;
54
53
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
54
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
55
55
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
56
56
  await (0, _tracker.trackEvent)('dev_env_import_sql_command_execute', trackingInfo);
57
57
 
@@ -35,9 +35,9 @@ const examples = [{
35
35
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} info --slug=my_site`,
36
36
  description: 'Return information about a local dev environment named "my_site"'
37
37
  }];
38
- (0, _command.default)().option('slug', 'Custom name of the dev environment').option('all', 'Show Info for all local dev environments').examples(examples).argv(process.argv, async (arg, opt) => {
39
- await (0, _devEnvironmentCli.validateDependencies)();
38
+ (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) => {
40
39
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
40
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
41
41
  const trackingInfo = opt.all ? {
42
42
  all: true
43
43
  } : (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
@@ -45,10 +45,14 @@ const examples = [{
45
45
  debug('Args: ', arg, 'Options: ', opt);
46
46
 
47
47
  try {
48
+ const options = {
49
+ extended: !!opt.extended
50
+ };
51
+
48
52
  if (opt.all) {
49
- await (0, _devEnvironmentCore.printAllEnvironmentsInfo)();
53
+ await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(options);
50
54
  } else {
51
- await (0, _devEnvironmentCore.printEnvironmentInfo)(slug);
55
+ await (0, _devEnvironmentCore.printEnvironmentInfo)(slug, options);
52
56
  }
53
57
 
54
58
  await (0, _tracker.trackEvent)('dev_env_info_command_success', trackingInfo);
@@ -38,7 +38,7 @@ const examples = [{
38
38
  await (0, _tracker.trackEvent)('dev_env_list_command_execute', trackingInfo);
39
39
 
40
40
  try {
41
- await (0, _devEnvironmentCore.printAllEnvironmentsInfo)();
41
+ await (0, _devEnvironmentCore.printAllEnvironmentsInfo)({});
42
42
  await (0, _tracker.trackEvent)('dev_env_list_command_success', trackingInfo);
43
43
  } catch (error) {
44
44
  (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_list_command_error', trackingInfo);
@@ -39,9 +39,9 @@ const examples = [{
39
39
  description: 'Starts a local dev environment'
40
40
  }];
41
41
  (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) => {
42
- await (0, _devEnvironmentCli.validateDependencies)();
43
- const startProcessing = new Date();
44
42
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
43
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
44
+ const startProcessing = new Date();
45
45
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
46
46
  await (0, _tracker.trackEvent)('dev_env_start_command_execute', trackingInfo);
47
47
  debug('Args: ', arg, 'Options: ', opt);
@@ -35,8 +35,8 @@ const examples = [{
35
35
  description: 'Stops a local dev environment'
36
36
  }];
37
37
  (0, _command.default)().option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
38
- await (0, _devEnvironmentCli.validateDependencies)();
39
38
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
39
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
40
40
  debug('Args: ', arg, 'Options: ', opt);
41
41
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
42
42
  await (0, _tracker.trackEvent)('dev_env_stop_command_execute', trackingInfo);
@@ -38,8 +38,8 @@ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev envir
38
38
  (0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
39
39
  cmd.examples(examples);
40
40
  cmd.argv(process.argv, async (arg, opt) => {
41
- await (0, _devEnvironmentCli.validateDependencies)();
42
41
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
42
+ await (0, _devEnvironmentCli.validateDependencies)(slug);
43
43
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
44
44
  await (0, _tracker.trackEvent)('dev_env_update_command_execute', trackingInfo);
45
45
 
@@ -229,6 +229,7 @@ const bindReconnectEvents = ({
229
229
  currentJob.socket.io.removeAllListeners('reconnect');
230
230
  currentJob.socket.io.removeAllListeners('reconnect_attempt');
231
231
  currentJob.socket.removeAllListeners('retry');
232
+ currentJob.socket.removeAllListeners('connect_error');
232
233
  currentJob.socket.io.on('reconnect', async () => {
233
234
  debug('socket.io: reconnect');
234
235
 
@@ -286,6 +287,20 @@ const bindReconnectEvents = ({
286
287
  currentJob.socket.io.engine.close();
287
288
  }, 5000);
288
289
  });
290
+ currentJob.socket.on('connect_error', () => {
291
+ debug('socket: connect_error; forcing the preference for websocket');
292
+
293
+ _rollbar.rollbar.info('WP-CLI socket.on( \'connect_error\' )', {
294
+ custom: {
295
+ code: 'wp-cli-on-connect_error',
296
+ commandGuid: cliCommand.guid
297
+ }
298
+ }); // Force the preference for WebSocket in case we see an error during connection
299
+ // https://socket.io/docs/v3/client-initialization/#low-level-engine-options
300
+
301
+
302
+ currentJob.socket.io.opts.transports = ['websocket', 'polling'];
303
+ });
289
304
  currentJob.socket.on('exit', async ({
290
305
  exitCode,
291
306
  message
@@ -479,12 +494,16 @@ const bindReconnectEvents = ({
479
494
  }
480
495
 
481
496
  const token = await _token.default.get();
497
+ const extraHeaders = {
498
+ Authorization: `Bearer ${token.raw}`
499
+ };
482
500
  const socket = (0, _socket.default)(`${_api.API_HOST}/wp-cli`, {
483
501
  transportOptions: {
484
502
  polling: {
485
- extraHeaders: {
486
- Authorization: `Bearer ${token.raw}`
487
- }
503
+ extraHeaders
504
+ },
505
+ websocket: {
506
+ extraHeaders
488
507
  }
489
508
  },
490
509
  agent: (0, _proxyAgent.createProxyAgent)(_api.API_HOST)
package/dist/bin/vip.js CHANGED
@@ -23,6 +23,8 @@ var _tracker = require("../lib/tracker");
23
23
 
24
24
  var _rollbar = require("../lib/rollbar");
25
25
 
26
+ var _logout = _interopRequireDefault(require("../lib/logout"));
27
+
26
28
  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
29
 
28
30
  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; }
@@ -45,8 +47,7 @@ const tokenURL = 'https://dashboard.wpvip.com/me/cli/token';
45
47
  const runCmd = async function () {
46
48
  const cmd = (0, _command.default)();
47
49
  cmd.command('logout', 'Logout from your current session', async () => {
48
- await _token.default.purge();
49
- await (0, _tracker.trackEvent)('logout_command_execute');
50
+ await (0, _logout.default)();
50
51
  console.log('You are successfully logged out.');
51
52
  }).command('app', 'List and modify your VIP applications').command('cache', 'Manage page cache for your VIP applications').command('config', 'Set configuration for your VIP applications').command('dev-env', 'Use local dev-environment').command('import', 'Import media or SQL files into your VIP applications').command('logs', 'Get logs from your VIP applications').command('search-replace', 'Perform search and replace tasks on files').command('sync', 'Sync production to a development environment').command('whoami', 'Display details about the currently logged-in user').command('wp', 'Run WP CLI commands against an environment');
52
53
  cmd.argv(process.argv);
@@ -56,10 +57,11 @@ const rootCmd = async function () {
56
57
  let token = await _token.default.get();
57
58
  const isHelpCommand = process.argv.some(arg => arg === 'help' || arg === '-h' || arg === '--help');
58
59
  const isLogoutCommand = process.argv.some(arg => arg === 'logout');
60
+ const isLoginCommand = process.argv.some(arg => arg === 'login');
59
61
  const isDevEnvCommandWithoutEnv = process.argv.some(arg => arg === 'dev-env') && !(0, _command.containsAppEnvArgument)(process.argv);
60
62
  debug('Argv:', process.argv);
61
63
 
62
- if (isLogoutCommand || isHelpCommand || isDevEnvCommandWithoutEnv || token && token.valid()) {
64
+ if (!isLoginCommand && (isLogoutCommand || isHelpCommand || isDevEnvCommandWithoutEnv || token && token.valid())) {
63
65
  runCmd();
64
66
  } else {
65
67
  console.log();
@@ -142,6 +144,12 @@ const rootCmd = async function () {
142
144
 
143
145
  await (0, _tracker.aliasUser)(token.id);
144
146
  await (0, _tracker.trackEvent)('login_command_token_submit_success');
147
+
148
+ if (isLoginCommand) {
149
+ console.log('You are now logged in - see `vip -h` for a list of available commands.');
150
+ process.exit();
151
+ }
152
+
145
153
  runCmd();
146
154
  }
147
155
  };
@@ -29,8 +29,6 @@ var _package = _interopRequireDefault(require("../../../package.json"));
29
29
 
30
30
  var _tracker = require("../tracker");
31
31
 
32
- var _pager = _interopRequireDefault(require("./pager"));
33
-
34
32
  var _envAlias = require("./envAlias");
35
33
 
36
34
  var _rollbar = require("../rollbar");
@@ -526,9 +524,7 @@ _args.default.argv = async function (argv, cb) {
526
524
  format: options.format
527
525
  });
528
526
  const formattedOut = (0, _format.formatData)(res, options.format);
529
- const page = (0, _pager.default)();
530
- page.write(formattedOut + '\n');
531
- page.end();
527
+ console.log(formattedOut);
532
528
  return {};
533
529
  }
534
530
  }
@@ -39,7 +39,7 @@ var _xml2js = require("xml2js");
39
39
 
40
40
  var _debug = _interopRequireDefault(require("debug"));
41
41
 
42
- var _api = _interopRequireDefault(require("./api"));
42
+ var _http = _interopRequireDefault(require("./api/http"));
43
43
 
44
44
  var _fileSize = require("./constants/file-size");
45
45
 
@@ -308,10 +308,7 @@ async function getSignedUploadRequestData({
308
308
  uploadId = undefined,
309
309
  partNumber = undefined
310
310
  }) {
311
- const {
312
- apiFetch
313
- } = await (0, _api.default)();
314
- const response = await apiFetch('/upload/site-import-presigned-url', {
311
+ const response = await (0, _http.default)('/upload/site-import-presigned-url', {
315
312
  method: 'POST',
316
313
  body: {
317
314
  action,
@@ -71,7 +71,10 @@ const DEFAULT_SLUG = 'vip-local';
71
71
  async function handleCLIException(exception, trackKey, trackBaseInfo = {}) {
72
72
  const errorPrefix = _chalk.default.red('Error:');
73
73
 
74
- if (_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND === exception.message) {
74
+ if (exception instanceof _userError.default) {
75
+ // User errors are handled in global error handler
76
+ throw exception;
77
+ } else if (_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND === exception.message) {
75
78
  const createCommand = _chalk.default.bold(_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND + ' create');
76
79
 
77
80
  const message = `Environment doesn't exist.\n\n\nTo create a new environment run:\n\n${createCommand}\n`;
@@ -104,12 +107,38 @@ async function handleCLIException(exception, trackKey, trackBaseInfo = {}) {
104
107
  }
105
108
  }
106
109
 
107
- const validateDependencies = async () => {
110
+ const verifyDNSResolution = slug => {
111
+ const dns = require('dns');
112
+
113
+ const expectedIP = '127.0.0.1';
114
+ const testDomain = `${slug}.vipdev.lndo.site`;
115
+ const advice = `Please add following line to hosts file on your system:\n${expectedIP} ${testDomain}`;
116
+ debug(`Verifying DNS resolution for ${testDomain}`);
117
+ return new Promise((resolve, reject) => {
118
+ dns.lookup(testDomain, (error, address) => {
119
+ debug(`Got DNS response ${address}`);
120
+
121
+ if (error) {
122
+ reject(new _userError.default(`DNS resolution for ${testDomain} failed. ${advice}`));
123
+ }
124
+
125
+ if (address !== expectedIP) {
126
+ reject(new _userError.default(`DNS resolution for ${testDomain} returned unexpected IP ${address}. Expected value is ${expectedIP}. ${advice}`));
127
+ }
128
+
129
+ resolve();
130
+ });
131
+ });
132
+ };
133
+
134
+ const validateDependencies = async slug => {
108
135
  try {
109
136
  await (0, _devEnvironmentLando.validateDockerInstalled)();
110
137
  } catch (exception) {
111
- exit.withError(exception.message);
138
+ throw new _userError.default(exception.message);
112
139
  }
140
+
141
+ await verifyDNSResolution(slug);
113
142
  };
114
143
 
115
144
  exports.validateDependencies = validateDependencies;
@@ -170,12 +199,14 @@ function processComponentOptionInput(passedParam, allowLocal) {
170
199
  }
171
200
 
172
201
  function getOptionsFromAppInfo(appInfo) {
173
- var _appInfo$environment, _appInfo$environment2, _appInfo$environment3;
202
+ var _appInfo$environment, _appInfo$environment2, _appInfo$environment3, _appInfo$environment4, _appInfo$environment5;
174
203
 
175
204
  return {
176
205
  title: ((_appInfo$environment = appInfo.environment) === null || _appInfo$environment === void 0 ? void 0 : _appInfo$environment.name) || appInfo.name || '',
177
206
  multisite: !!(appInfo !== null && appInfo !== void 0 && (_appInfo$environment2 = appInfo.environment) !== null && _appInfo$environment2 !== void 0 && _appInfo$environment2.isMultisite),
178
- mediaRedirectDomain: (_appInfo$environment3 = appInfo.environment) === null || _appInfo$environment3 === void 0 ? void 0 : _appInfo$environment3.primaryDomain
207
+ mediaRedirectDomain: (_appInfo$environment3 = appInfo.environment) === null || _appInfo$environment3 === void 0 ? void 0 : _appInfo$environment3.primaryDomain,
208
+ php: ((_appInfo$environment4 = appInfo.environment) === null || _appInfo$environment4 === void 0 ? void 0 : _appInfo$environment4.php) || '',
209
+ wordpress: ((_appInfo$environment5 = appInfo.environment) === null || _appInfo$environment5 === void 0 ? void 0 : _appInfo$environment5.wordpress) || ''
179
210
  };
180
211
  }
181
212
  /**
@@ -50,6 +50,10 @@ var _app = _interopRequireDefault(require("../api/app"));
50
50
 
51
51
  var _devEnvironment = require("../constants/dev-environment");
52
52
 
53
+ var _software = require("../config/software");
54
+
55
+ var _userError = _interopRequireDefault(require("../user-error"));
56
+
53
57
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54
58
 
55
59
  /**
@@ -100,7 +104,9 @@ async function startEnvironment(slug, options) {
100
104
  await (0, _devEnvironmentLando.landoRebuild)(instancePath);
101
105
  }
102
106
 
103
- await printEnvironmentInfo(slug);
107
+ await printEnvironmentInfo(slug, {
108
+ extended: false
109
+ });
104
110
  }
105
111
 
106
112
  async function stopEnvironment(slug) {
@@ -191,18 +197,26 @@ async function destroyEnvironment(slug, removeFiles) {
191
197
  }
192
198
  }
193
199
 
194
- async function printAllEnvironmentsInfo() {
200
+ async function printAllEnvironmentsInfo(options) {
195
201
  const allEnvNames = getAllEnvironmentNames();
196
202
  debug('Will print info for all environments. Names found: ', allEnvNames);
197
203
  console.log('Found ' + _chalk.default.bold(allEnvNames.length) + ' environments' + (allEnvNames.length ? ':' : '.'));
198
204
 
199
205
  for (const envName of allEnvNames) {
200
206
  console.log('\n');
201
- await printEnvironmentInfo(envName);
207
+ await printEnvironmentInfo(envName, options);
202
208
  }
203
209
  }
204
210
 
205
- async function printEnvironmentInfo(slug) {
211
+ function parseComponentForInfo(component) {
212
+ if (component.mode === 'local') {
213
+ return component.dir || '';
214
+ }
215
+
216
+ return component.tag || '[demo-image]';
217
+ }
218
+
219
+ async function printEnvironmentInfo(slug, options) {
206
220
  debug('Will get info for an environment', slug);
207
221
  const instancePath = getEnvironmentPath(slug);
208
222
  debug('Instance path for', slug, 'is:', instancePath);
@@ -214,6 +228,21 @@ async function printEnvironmentInfo(slug) {
214
228
  }
215
229
 
216
230
  const appInfo = await (0, _devEnvironmentLando.landoInfo)(instancePath);
231
+
232
+ if (options.extended) {
233
+ const environmentData = readEnvironmentData(slug);
234
+ appInfo.title = environmentData.wpTitle;
235
+ appInfo.multisite = !!environmentData.multisite;
236
+ appInfo.php = environmentData.php.split(':')[1];
237
+ appInfo.wordpress = parseComponentForInfo(environmentData.wordpress);
238
+ appInfo['Mu plugins'] = parseComponentForInfo(environmentData.muPlugins);
239
+ appInfo['App Code'] = parseComponentForInfo(environmentData.appCode);
240
+
241
+ if (environmentData.mediaRedirectDomain) {
242
+ appInfo['Media Redirect'] = environmentData.mediaRedirectDomain;
243
+ }
244
+ }
245
+
217
246
  (0, _devEnvironmentCli.printTable)(appInfo);
218
247
  }
219
248
 
@@ -355,9 +384,17 @@ async function getApplicationInformation(appId, envType) {
355
384
  isMultisite,
356
385
  primaryDomain {
357
386
  name
387
+ },
388
+ softwareSettings {
389
+ php {
390
+ ...Software
391
+ }
392
+ wordpress {
393
+ ...Software
394
+ }
358
395
  }
359
396
  }`;
360
- const queryResult = await (0, _app.default)(appId, fieldsQuery);
397
+ const queryResult = await (0, _app.default)(appId, fieldsQuery, _software.appQueryFragments);
361
398
  const appData = {};
362
399
 
363
400
  if (queryResult) {
@@ -387,14 +424,16 @@ async function getApplicationInformation(appId, envType) {
387
424
  }
388
425
 
389
426
  if (envData) {
390
- var _envData$primaryDomai;
427
+ var _envData$primaryDomai, _envData$softwareSett, _envData$softwareSett2, _envData$softwareSett3, _envData$softwareSett4, _envData$softwareSett5, _envData$softwareSett6;
391
428
 
392
429
  appData.environment = {
393
430
  name: envData.name,
394
431
  branch: envData.branch,
395
432
  type: envData.type,
396
433
  isMultisite: envData.isMultisite,
397
- primaryDomain: ((_envData$primaryDomai = envData.primaryDomain) === null || _envData$primaryDomai === void 0 ? void 0 : _envData$primaryDomai.name) || ''
434
+ primaryDomain: ((_envData$primaryDomai = envData.primaryDomain) === null || _envData$primaryDomai === void 0 ? void 0 : _envData$primaryDomai.name) || '',
435
+ php: ((_envData$softwareSett = envData.softwareSettings) === null || _envData$softwareSett === void 0 ? void 0 : (_envData$softwareSett2 = _envData$softwareSett.php) === null || _envData$softwareSett2 === void 0 ? void 0 : (_envData$softwareSett3 = _envData$softwareSett2.current) === null || _envData$softwareSett3 === void 0 ? void 0 : _envData$softwareSett3.version) || '',
436
+ wordpress: ((_envData$softwareSett4 = envData.softwareSettings) === null || _envData$softwareSett4 === void 0 ? void 0 : (_envData$softwareSett5 = _envData$softwareSett4.wordpress) === null || _envData$softwareSett5 === void 0 ? void 0 : (_envData$softwareSett6 = _envData$softwareSett5.current) === null || _envData$softwareSett6 === void 0 ? void 0 : _envData$softwareSett6.version) || ''
398
437
  };
399
438
  }
400
439
  }
@@ -403,10 +442,16 @@ async function getApplicationInformation(appId, envType) {
403
442
  }
404
443
 
405
444
  async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
445
+ debug(`Will try to resolve path - ${fileName}`);
406
446
  let resolvedPath = (0, _devEnvironmentCli.resolvePath)(fileName);
447
+ debug(`Filename ${fileName} resolved to ${resolvedPath}`);
407
448
 
408
449
  if (!_fs.default.existsSync(resolvedPath)) {
409
- throw new Error('The provided file does not exist or it is not valid (see "--help" for examples)');
450
+ throw new _userError.default(`The provided file ${resolvedPath} does not exist or it is not valid (see "--help" for examples)`);
451
+ }
452
+
453
+ if (_fs.default.lstatSync(resolvedPath).isDirectory()) {
454
+ throw new _userError.default(`The provided file ${resolvedPath} is a directory. Please point to a sql file.`);
410
455
  } // Run Search and Replace if the --search-replace flag was provided
411
456
 
412
457