@automattic/vip 2.21.0 → 2.23.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.
Files changed (111) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/assets/dev-env.lando.template.yml.ejs +1 -1
  3. package/automattic-vip-2.23.0.tgz +0 -0
  4. package/dist/bin/vip-app-list.js +0 -12
  5. package/dist/bin/vip-app.js +6 -13
  6. package/dist/bin/vip-cache-purge-url.js +4 -19
  7. package/dist/bin/vip-cache.js +0 -2
  8. package/dist/bin/vip-config-envvar-delete.js +4 -19
  9. package/dist/bin/vip-config-envvar-get-all.js +6 -19
  10. package/dist/bin/vip-config-envvar-get.js +4 -15
  11. package/dist/bin/vip-config-envvar-list.js +8 -20
  12. package/dist/bin/vip-config-envvar-set.js +4 -23
  13. package/dist/bin/vip-config-envvar.js +0 -2
  14. package/dist/bin/vip-config-software-get.js +0 -17
  15. package/dist/bin/vip-config-software-update.js +6 -22
  16. package/dist/bin/vip-config-software.js +0 -2
  17. package/dist/bin/vip-config.js +0 -2
  18. package/dist/bin/vip-dev-env-create.js +0 -18
  19. package/dist/bin/vip-dev-env-destroy.js +0 -9
  20. package/dist/bin/vip-dev-env-exec.js +0 -12
  21. package/dist/bin/vip-dev-env-import-media.js +0 -7
  22. package/dist/bin/vip-dev-env-import-sql.js +2 -17
  23. package/dist/bin/vip-dev-env-import.js +0 -3
  24. package/dist/bin/vip-dev-env-info.js +0 -10
  25. package/dist/bin/vip-dev-env-list.js +0 -7
  26. package/dist/bin/vip-dev-env-start.js +4 -14
  27. package/dist/bin/vip-dev-env-stop.js +0 -9
  28. package/dist/bin/vip-dev-env-update.js +0 -11
  29. package/dist/bin/vip-dev-env.js +0 -2
  30. package/dist/bin/vip-import-media-abort.js +0 -18
  31. package/dist/bin/vip-import-media-status.js +0 -12
  32. package/dist/bin/vip-import-media.js +6 -23
  33. package/dist/bin/vip-import-sql-status.js +0 -12
  34. package/dist/bin/vip-import-sql.js +40 -103
  35. package/dist/bin/vip-import-validate-files.js +21 -42
  36. package/dist/bin/vip-import-validate-sql.js +0 -8
  37. package/dist/bin/vip-import.js +0 -3
  38. package/dist/bin/vip-logs.js +20 -50
  39. package/dist/bin/vip-search-replace.js +8 -14
  40. package/dist/bin/vip-sync.js +2 -25
  41. package/dist/bin/vip-validate-preflight.js +427 -0
  42. package/dist/bin/vip-validate.js +19 -0
  43. package/dist/bin/vip-whoami.js +2 -14
  44. package/dist/bin/vip-wp.js +39 -89
  45. package/dist/bin/vip.js +5 -35
  46. package/dist/lib/analytics/clients/pendo.js +9 -18
  47. package/dist/lib/analytics/clients/stub.js +1 -3
  48. package/dist/lib/analytics/clients/tracks.js +11 -20
  49. package/dist/lib/analytics/index.js +4 -11
  50. package/dist/lib/api/app.js +1 -11
  51. package/dist/lib/api/cache-purge.js +4 -7
  52. package/dist/lib/api/feature-flags.js +1 -4
  53. package/dist/lib/api/http.js +9 -15
  54. package/dist/lib/api/user.js +1 -7
  55. package/dist/lib/api.js +17 -19
  56. package/dist/lib/app-logs/app-logs.js +2 -9
  57. package/dist/lib/app.js +2 -5
  58. package/dist/lib/cli/apiConfig.js +4 -19
  59. package/dist/lib/cli/command.js +43 -133
  60. package/dist/lib/cli/config.js +1 -5
  61. package/dist/lib/cli/envAlias.js +14 -15
  62. package/dist/lib/cli/exit.js +4 -6
  63. package/dist/lib/cli/format.js +8 -50
  64. package/dist/lib/cli/progress.js +13 -42
  65. package/dist/lib/cli/prompt.js +1 -5
  66. package/dist/lib/cli/repo.js +7 -20
  67. package/dist/lib/client-file-uploader.js +44 -97
  68. package/dist/lib/config/software.js +2 -52
  69. package/dist/lib/constants/dev-environment.js +1 -2
  70. package/dist/lib/constants/file-size.js +1 -1
  71. package/dist/lib/constants/vipgo.js +1 -1
  72. package/dist/lib/dev-environment/dev-environment-cli.js +68 -155
  73. package/dist/lib/dev-environment/dev-environment-core.js +73 -194
  74. package/dist/lib/dev-environment/dev-environment-lando.js +16 -71
  75. package/dist/lib/env.js +1 -4
  76. package/dist/lib/envvar/api-delete.js +1 -4
  77. package/dist/lib/envvar/api-get-all.js +1 -4
  78. package/dist/lib/envvar/api-get.js +1 -2
  79. package/dist/lib/envvar/api-list.js +3 -4
  80. package/dist/lib/envvar/api-set.js +1 -4
  81. package/dist/lib/envvar/api.js +5 -16
  82. package/dist/lib/envvar/input.js +1 -8
  83. package/dist/lib/envvar/logging.js +2 -6
  84. package/dist/lib/envvar/read-file.js +1 -3
  85. package/dist/lib/http/proxy-agent.js +17 -22
  86. package/dist/lib/keychain/browser.js +1 -4
  87. package/dist/lib/keychain/insecure.js +1 -10
  88. package/dist/lib/keychain/secure.js +1 -8
  89. package/dist/lib/keychain.js +4 -8
  90. package/dist/lib/logout.js +0 -6
  91. package/dist/lib/media-import/media-file-import.js +3 -7
  92. package/dist/lib/media-import/progress.js +6 -17
  93. package/dist/lib/media-import/status.js +14 -65
  94. package/dist/lib/read-file.js +1 -6
  95. package/dist/lib/rollbar.js +1 -7
  96. package/dist/lib/search-and-replace.js +9 -41
  97. package/dist/lib/site-import/db-file-import.js +3 -9
  98. package/dist/lib/site-import/status.js +17 -74
  99. package/dist/lib/token.js +1 -33
  100. package/dist/lib/tracker.js +4 -20
  101. package/dist/lib/user-error.js +0 -2
  102. package/dist/lib/validations/is-multi-site-sql-dump.js +4 -12
  103. package/dist/lib/validations/is-multi-site.js +5 -21
  104. package/dist/lib/validations/is-multisite-domain-mapped.js +5 -31
  105. package/dist/lib/validations/line-by-line.js +4 -16
  106. package/dist/lib/validations/site-type.js +10 -19
  107. package/dist/lib/validations/sql.js +11 -76
  108. package/dist/lib/validations/utils.js +1 -6
  109. package/dist/lib/vip-import-validate-files.js +82 -109
  110. package/npm-shrinkwrap.json +2407 -1800
  111. package/package.json +18 -15
@@ -15,17 +15,11 @@
15
15
  "use strict";
16
16
 
17
17
  var _tracker = require("../lib/tracker");
18
-
19
18
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
19
  var _format = require("../lib/cli/format");
22
-
23
20
  var _software = require("../lib/config/software");
24
-
25
21
  var _userError = _interopRequireDefault(require("../lib/user-error"));
26
-
27
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
23
  // Command examples
30
24
  const examples = [{
31
25
  usage: 'vip @mysite.develop config software get wordpress --include available_versions --format json',
@@ -45,50 +39,39 @@ const VALID_INCLUDES = ['available_versions'];
45
39
  usage: 'vip @mysite.develop config software get <wordpress|php|nodejs|muplugins>'
46
40
  }).option('include', `Extra information to be included. Valida values: ${VALID_INCLUDES.join(',')}`).examples(examples).argv(process.argv, async (arg, opt) => {
47
41
  var _opt$env;
48
-
49
42
  const trackingInfo = {
50
43
  environment_id: (_opt$env = opt.env) === null || _opt$env === void 0 ? void 0 : _opt$env.id,
51
44
  args: JSON.stringify(arg)
52
45
  };
53
46
  await (0, _tracker.trackEvent)('config_software_get_execute', trackingInfo);
54
47
  let include = [];
55
-
56
48
  if (opt.include) {
57
49
  if (Array.isArray(opt.include)) {
58
50
  include = opt.include;
59
51
  } else {
60
52
  include = [opt.include];
61
53
  }
62
-
63
54
  const invalidIncludes = include.filter(includeKey => !VALID_INCLUDES.includes(includeKey));
64
-
65
55
  if (invalidIncludes.length > 0) {
66
56
  throw new _userError.default(`Invalid include value(s): ${invalidIncludes.join(',')}`);
67
57
  }
68
58
  }
69
-
70
59
  const {
71
60
  softwareSettings
72
61
  } = opt.env;
73
-
74
62
  if (softwareSettings === null) {
75
63
  throw new _userError.default('Software settings are not supported for this environment.');
76
64
  }
77
-
78
65
  let chosenSettings = [];
79
-
80
66
  if (arg.length > 0) {
81
67
  const component = arg[0];
82
-
83
68
  if (!softwareSettings[component]) {
84
69
  throw new _userError.default(`Software settings for ${component} are not supported for this environment.`);
85
70
  }
86
-
87
71
  chosenSettings = [softwareSettings[component]];
88
72
  } else {
89
73
  chosenSettings = [softwareSettings.wordpress, softwareSettings.php, softwareSettings.muplugins, softwareSettings.nodejs];
90
74
  }
91
-
92
75
  const preFormatted = chosenSettings.filter(softwareSetting => !!softwareSetting).map(softwareSetting => (0, _software.formatSoftwareSettings)(softwareSetting, include, opt.format));
93
76
  console.log((0, _format.formatData)(preFormatted, opt.format));
94
77
  await (0, _tracker.trackEvent)('config_software_get_success', trackingInfo);
@@ -11,21 +11,13 @@
11
11
  "use strict";
12
12
 
13
13
  var _chalk = _interopRequireDefault(require("chalk"));
14
-
15
14
  var _debug = _interopRequireDefault(require("debug"));
16
-
17
15
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
-
19
16
  var _software = require("../lib/config/software");
20
-
21
17
  var _progress = require("../lib/cli/progress");
22
-
23
18
  var _userError = _interopRequireDefault(require("../lib/user-error"));
24
-
25
19
  var _tracker = require("../lib/tracker");
26
-
27
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
21
  /**
30
22
  * Internal dependencies
31
23
  */
@@ -66,24 +58,19 @@ cmd.argv(process.argv, async (arg, opt) => {
66
58
  };
67
59
  await (0, _tracker.trackEvent)('config_software_update_execute', baseTrackingInfo);
68
60
  let updateData = {};
69
-
70
61
  try {
71
62
  if (softwareSettings === null) {
72
63
  throw new _userError.default('Software settings are not supported for this environment.');
73
64
  }
74
-
75
65
  const updateOptions = {
76
66
  force: !!opt.yes
77
67
  };
78
-
79
68
  if (arg.length > 0) {
80
69
  updateOptions.component = arg[0];
81
70
  }
82
-
83
71
  if (arg.length > 1) {
84
72
  updateOptions.version = arg[1];
85
73
  }
86
-
87
74
  updateData = await (0, _software.promptForUpdate)(app.typeId, updateOptions, softwareSettings);
88
75
  const hasProcessJob = updateData.component !== 'nodejs';
89
76
  const steps = hasProcessJob ? UPDATE_SOFTWARE_PROGRESS_STEPS : [UPDATE_SOFTWARE_PROGRESS_STEPS[0]];
@@ -97,22 +84,18 @@ cmd.argv(process.argv, async (arg, opt) => {
97
84
  });
98
85
  debug('Triggered update with result', triggerResult);
99
86
  progressTracker.stepSuccess('trigger');
100
-
101
87
  if (hasProcessJob) {
102
88
  const {
103
89
  ok,
104
90
  errorMessage
105
91
  } = await (0, _software.getUpdateResult)(app.id, env.id);
106
-
107
92
  if (ok) {
108
93
  progressTracker.stepSuccess('process');
109
94
  } else {
110
95
  progressTracker.stepFailed('process');
111
96
  }
112
-
113
97
  progressTracker.print();
114
98
  progressTracker.stopPrinting();
115
-
116
99
  if (ok) {
117
100
  console.log(_chalk.default.green('✓') + ' Software update complete');
118
101
  } else {
@@ -125,23 +108,24 @@ cmd.argv(process.argv, async (arg, opt) => {
125
108
  const message = ` A new build of the application code has been initiated and will be deployed using Node.js v${updateData.version} when the build is successful\n` + `View the deployments page in VIP Dashboard for progress updates. - ${deploymentsLink}`;
126
109
  console.log(_chalk.default.green('✓') + message);
127
110
  }
128
-
129
- await (0, _tracker.trackEvent)('config_software_update_success', { ...baseTrackingInfo,
111
+ await (0, _tracker.trackEvent)('config_software_update_success', {
112
+ ...baseTrackingInfo,
130
113
  ...updateData
131
114
  });
132
115
  } catch (error) {
133
116
  if (error instanceof _userError.default) {
134
- await (0, _tracker.trackEvent)('config_software_update_success', { ...baseTrackingInfo,
117
+ await (0, _tracker.trackEvent)('config_software_update_success', {
118
+ ...baseTrackingInfo,
135
119
  ...updateData,
136
120
  user_error: error === null || error === void 0 ? void 0 : error.message
137
121
  });
138
122
  } else {
139
- await (0, _tracker.trackEvent)('config_software_update_error', { ...baseTrackingInfo,
123
+ await (0, _tracker.trackEvent)('config_software_update_error', {
124
+ ...baseTrackingInfo,
140
125
  ...updateData,
141
126
  error: error === null || error === void 0 ? void 0 : error.message
142
127
  });
143
128
  }
144
-
145
129
  throw error;
146
130
  }
147
131
  });
@@ -15,9 +15,7 @@
15
15
  "use strict";
16
16
 
17
17
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
-
19
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
19
  (0, _command.default)({
22
20
  requiredArgs: 1,
23
21
  usage: 'vip @mysite.develop config software <action>'
@@ -10,9 +10,7 @@
10
10
  "use strict";
11
11
 
12
12
  var _command = _interopRequireDefault(require("../lib/cli/command"));
13
-
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
14
  (0, _command.default)({
17
15
  requiredArgs: 2
18
16
  }).command('envvar', 'Manage environment variables for an application environment').command('software', 'Software management').argv(process.argv, async () => {
@@ -11,27 +11,16 @@
11
11
  "use strict";
12
12
 
13
13
  var _debug = _interopRequireDefault(require("debug"));
14
-
15
14
  var _chalk = _interopRequireDefault(require("chalk"));
16
-
17
15
  var _tracker = require("../lib/tracker");
18
-
19
16
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
17
  var exit = _interopRequireWildcard(require("../lib/cli/exit"));
22
-
23
18
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
24
-
25
19
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
26
-
27
20
  var _devEnvironment = require("../lib/constants/dev-environment");
28
-
29
21
  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); }
30
-
31
22
  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; }
32
-
33
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
-
35
24
  /**
36
25
  * Internal dependencies
37
26
  */
@@ -71,18 +60,13 @@ cmd.argv(process.argv, async (arg, opt) => {
71
60
  env: opt.env
72
61
  };
73
62
  await (0, _tracker.trackEvent)('dev_env_create_command_execute', trackingInfo);
74
-
75
63
  const startCommand = _chalk.default.bold((0, _devEnvironmentCli.getEnvironmentStartCommand)(slug));
76
-
77
64
  const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
78
-
79
65
  if (environmentAlreadyExists) {
80
66
  const messageToShow = `Environment already exists\n\n\nTo start the environment run:\n\n${startCommand}\n\n` + `To create another environment use ${_chalk.default.bold('--slug')} option with a unique name.\n`;
81
67
  exit.withError(messageToShow);
82
68
  }
83
-
84
69
  let defaultOptions = {};
85
-
86
70
  try {
87
71
  if (opt.app) {
88
72
  const appInfo = await (0, _devEnvironmentCore.getApplicationInformation)(opt.app, opt.env);
@@ -93,10 +77,8 @@ cmd.argv(process.argv, async (arg, opt) => {
93
77
  debug(`WARNING: ${message}`, error.message);
94
78
  console.log(_chalk.default.yellow('Warning:'), message);
95
79
  }
96
-
97
80
  const instanceData = await (0, _devEnvironmentCli.promptForArguments)(opt, defaultOptions);
98
81
  instanceData.siteSlug = slug;
99
-
100
82
  try {
101
83
  await (0, _devEnvironmentCore.createEnvironment)(instanceData);
102
84
  await (0, _devEnvironmentCore.printEnvironmentInfo)(slug, {
@@ -11,21 +11,13 @@
11
11
  "use strict";
12
12
 
13
13
  var _debug = _interopRequireDefault(require("debug"));
14
-
15
14
  var _chalk = _interopRequireDefault(require("chalk"));
16
-
17
15
  var _tracker = require("../lib/tracker");
18
-
19
16
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
17
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
22
-
23
18
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
24
-
25
19
  var _devEnvironment = require("../lib/constants/dev-environment");
26
-
27
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
21
  /**
30
22
  * Internal dependencies
31
23
  */
@@ -43,7 +35,6 @@ const examples = [{
43
35
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
44
36
  await (0, _tracker.trackEvent)('dev_env_destroy_command_execute', trackingInfo);
45
37
  debug('Args: ', arg, 'Options: ', opt);
46
-
47
38
  try {
48
39
  const removeFiles = !(opt.soft || false);
49
40
  await (0, _devEnvironmentCore.destroyEnvironment)(slug, removeFiles);
@@ -15,17 +15,11 @@
15
15
  "use strict";
16
16
 
17
17
  var _tracker = require("../lib/tracker");
18
-
19
18
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
19
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
22
-
23
20
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
24
-
25
21
  var _devEnvironment = require("../lib/constants/dev-environment");
26
-
27
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
23
  const examples = [{
30
24
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} exec -- wp post list`,
31
25
  description: 'Use dev-environment to run `wp post list`'
@@ -40,29 +34,23 @@ const examples = [{
40
34
  wildcardCommand: true
41
35
  }).option('slug', 'Custom name of the dev environment').option('force', 'Disabling validations before task execution', undefined, value => {
42
36
  var _value$toLowerCase;
43
-
44
37
  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
38
  }).examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
46
39
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
47
40
  await (0, _devEnvironmentCli.validateDependencies)(slug);
48
41
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
49
42
  await (0, _tracker.trackEvent)('dev_env_exec_command_execute', trackingInfo);
50
-
51
43
  try {
52
44
  // to avoid confusion let's enforce -- as a splitter for arguments for this command and wp itself
53
45
  const argSplitterIx = process.argv.findIndex(argument => '--' === argument);
54
46
  const argSplitterFound = argSplitterIx > -1;
55
-
56
47
  if (unmatchedArgs.length > 0 && !argSplitterFound) {
57
48
  throw new Error('Please provide "--" argument to separate arguments for "vip" and command to be executed (see "--help" for examples)');
58
49
  }
59
-
60
50
  let arg = [];
61
-
62
51
  if (argSplitterFound && argSplitterIx + 1 < process.argv.length) {
63
52
  arg = process.argv.slice(argSplitterIx + 1);
64
53
  }
65
-
66
54
  const options = {
67
55
  force: opt.force
68
56
  };
@@ -15,17 +15,11 @@
15
15
  "use strict";
16
16
 
17
17
  var _tracker = require("../lib/tracker");
18
-
19
18
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
19
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
22
-
23
20
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
24
-
25
21
  var _devEnvironment = require("../lib/constants/dev-environment");
26
-
27
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
23
  const examples = [{
30
24
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import media path/to/wp-content/uploads`,
31
25
  description: 'Import contents of the given WP uploads folder file into the media library of the default dev environment'
@@ -41,7 +35,6 @@ const examples = [{
41
35
  await (0, _devEnvironmentCli.validateDependencies)(slug);
42
36
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
43
37
  await (0, _tracker.trackEvent)('dev_env_import_media_command_execute', trackingInfo);
44
-
45
38
  try {
46
39
  await (0, _devEnvironmentCore.importMediaPath)(slug, filePath);
47
40
  await (0, _tracker.trackEvent)('dev_env_import_media_command_success', trackingInfo);
@@ -11,21 +11,13 @@
11
11
  "use strict";
12
12
 
13
13
  var _fs = _interopRequireDefault(require("fs"));
14
-
15
14
  var _tracker = require("../lib/tracker");
16
-
17
15
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
-
19
16
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
20
-
21
17
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
22
-
23
18
  var _devEnvironment = require("../lib/constants/dev-environment");
24
-
25
19
  var _sql = require("../lib/validations/sql");
26
-
27
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
21
  /**
30
22
  * Internal dependencies
31
23
  */
@@ -54,13 +46,11 @@ const examples = [{
54
46
  await (0, _devEnvironmentCli.validateDependencies)(slug);
55
47
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
56
48
  await (0, _tracker.trackEvent)('dev_env_import_sql_command_execute', trackingInfo);
57
-
58
49
  try {
59
50
  const {
60
51
  resolvedPath,
61
52
  inContainerPath
62
53
  } = await (0, _devEnvironmentCore.resolveImportPath)(slug, fileName, searchReplace, inPlace);
63
-
64
54
  if (!opt.skipValidate) {
65
55
  const expectedDomain = `${slug}.vipdev.lndo.site`;
66
56
  await (0, _sql.validate)(resolvedPath, {
@@ -71,27 +61,22 @@ const examples = [{
71
61
  }
72
62
  });
73
63
  }
74
-
75
64
  const importArg = ['wp', 'db', 'import', inContainerPath];
76
65
  await (0, _devEnvironmentCore.exec)(slug, importArg);
77
-
78
66
  if (searchReplace && searchReplace.length && !inPlace) {
79
67
  _fs.default.unlinkSync(resolvedPath);
80
68
  }
81
-
82
69
  const cacheArg = ['wp', 'cache', 'flush'];
83
70
  await (0, _devEnvironmentCore.exec)(slug, cacheArg);
84
-
85
71
  try {
86
72
  await (0, _devEnvironmentCore.exec)(slug, ['wp', 'cli', 'has-command', 'vip-search']);
87
73
  const doIndex = await (0, _devEnvironmentCli.promptForBoolean)('Do you want to index data in ElasticSearch (used by enterprise search)?', true);
88
-
89
74
  if (doIndex) {
90
75
  await (0, _devEnvironmentCore.exec)(slug, ['wp', 'vip-search', 'index', '--setup', '--network-wide', '--skip-confirm']);
91
76
  }
92
- } catch (err) {// Exception means they don't have vip-search enabled.
77
+ } catch (err) {
78
+ // Exception means they don't have vip-search enabled.
93
79
  }
94
-
95
80
  const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'];
96
81
  await (0, _devEnvironmentCore.exec)(slug, addUserArg);
97
82
  await (0, _tracker.trackEvent)('dev_env_import_sql_command_success', trackingInfo);
@@ -15,11 +15,8 @@
15
15
  "use strict";
16
16
 
17
17
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
-
19
18
  var _devEnvironment = require("../lib/constants/dev-environment");
20
-
21
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
-
23
20
  const examples = [{
24
21
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql file.sql`,
25
22
  description: 'Import the given SQL file to your site'
@@ -11,19 +11,12 @@
11
11
  "use strict";
12
12
 
13
13
  var _debug = _interopRequireDefault(require("debug"));
14
-
15
14
  var _tracker = require("../lib/tracker");
16
-
17
15
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
-
19
16
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
20
-
21
17
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
22
-
23
18
  var _devEnvironment = require("../lib/constants/dev-environment");
24
-
25
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
-
27
20
  /**
28
21
  * Internal dependencies
29
22
  */
@@ -43,18 +36,15 @@ const examples = [{
43
36
  } : (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
44
37
  await (0, _tracker.trackEvent)('dev_env_info_command_execute', trackingInfo);
45
38
  debug('Args: ', arg, 'Options: ', opt);
46
-
47
39
  try {
48
40
  const options = {
49
41
  extended: !!opt.extended
50
42
  };
51
-
52
43
  if (opt.all) {
53
44
  await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(options);
54
45
  } else {
55
46
  await (0, _devEnvironmentCore.printEnvironmentInfo)(slug, options);
56
47
  }
57
-
58
48
  await (0, _tracker.trackEvent)('dev_env_info_command_success', trackingInfo);
59
49
  } catch (error) {
60
50
  (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_info_command_error', trackingInfo);
@@ -15,17 +15,11 @@
15
15
  "use strict";
16
16
 
17
17
  var _tracker = require("../lib/tracker");
18
-
19
18
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
19
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
22
-
23
20
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
24
-
25
21
  var _devEnvironment = require("../lib/constants/dev-environment");
26
-
27
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
23
  const examples = [{
30
24
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} list`,
31
25
  description: 'Return information about all local dev environments'
@@ -36,7 +30,6 @@ const examples = [{
36
30
  all: true
37
31
  };
38
32
  await (0, _tracker.trackEvent)('dev_env_list_command_execute', trackingInfo);
39
-
40
33
  try {
41
34
  await (0, _devEnvironmentCore.printAllEnvironmentsInfo)({});
42
35
  await (0, _tracker.trackEvent)('dev_env_list_command_success', trackingInfo);
@@ -11,28 +11,20 @@
11
11
  "use strict";
12
12
 
13
13
  var _chalk = _interopRequireDefault(require("chalk"));
14
-
15
14
  var _debug = _interopRequireDefault(require("debug"));
16
-
17
15
  var _child_process = require("child_process");
18
-
19
16
  var _tracker = require("../lib/tracker");
20
-
21
17
  var _command = _interopRequireDefault(require("../lib/cli/command"));
22
-
23
18
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
24
-
25
19
  var _devEnvironment = require("../lib/constants/dev-environment");
26
-
27
20
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
28
-
29
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
-
31
22
  /**
32
23
  * Internal dependencies
33
24
  */
34
- const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment'); // PowerShell command for Windows Docker patch
25
+ const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
35
26
 
27
+ // PowerShell command for Windows Docker patch
36
28
  const dockerWindowsPathCmd = 'wsl -d docker-desktop bash -c "sysctl -w vm.max_map_count=262144"';
37
29
  const examples = [{
38
30
  usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start`,
@@ -49,7 +41,6 @@ const examples = [{
49
41
  skipRebuild: !!opt.skipRebuild,
50
42
  skipWpVersionsCheck: !!opt.skipWpVersionsCheck
51
43
  };
52
-
53
44
  try {
54
45
  if (process.platform === 'win32') {
55
46
  debug('Windows platform detected. Applying Docker patch...');
@@ -65,11 +56,10 @@ const examples = [{
65
56
  }
66
57
  });
67
58
  }
68
-
69
59
  await (0, _devEnvironmentCore.startEnvironment)(slug, options);
70
60
  const processingTime = Math.ceil((new Date() - startProcessing) / 1000); // in seconds
71
-
72
- const successTrackingInfo = { ...trackingInfo,
61
+ const successTrackingInfo = {
62
+ ...trackingInfo,
73
63
  processing_time: processingTime
74
64
  };
75
65
  await (0, _tracker.trackEvent)('dev_env_start_command_success', successTrackingInfo);
@@ -11,21 +11,13 @@
11
11
  "use strict";
12
12
 
13
13
  var _debug = _interopRequireDefault(require("debug"));
14
-
15
14
  var _chalk = _interopRequireDefault(require("chalk"));
16
-
17
15
  var _tracker = require("../lib/tracker");
18
-
19
16
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
17
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
22
-
23
18
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
24
-
25
19
  var _devEnvironment = require("../lib/constants/dev-environment");
26
-
27
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
21
  /**
30
22
  * Internal dependencies
31
23
  */
@@ -40,7 +32,6 @@ const examples = [{
40
32
  debug('Args: ', arg, 'Options: ', opt);
41
33
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
42
34
  await (0, _tracker.trackEvent)('dev_env_stop_command_execute', trackingInfo);
43
-
44
35
  try {
45
36
  await (0, _devEnvironmentCore.stopEnvironment)(slug);
46
37
  const message = _chalk.default.green('✓') + ' environment stopped.\n';
@@ -11,21 +11,13 @@
11
11
  "use strict";
12
12
 
13
13
  var _debug = _interopRequireDefault(require("debug"));
14
-
15
14
  var _chalk = _interopRequireDefault(require("chalk"));
16
-
17
15
  var _tracker = require("../lib/tracker");
18
-
19
16
  var _command = _interopRequireDefault(require("../lib/cli/command"));
20
-
21
17
  var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
22
-
23
18
  var _devEnvironment = require("../lib/constants/dev-environment");
24
-
25
19
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
26
-
27
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
21
  /**
30
22
  * Internal dependencies
31
23
  */
@@ -42,14 +34,11 @@ cmd.argv(process.argv, async (arg, opt) => {
42
34
  await (0, _devEnvironmentCli.validateDependencies)(slug);
43
35
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
44
36
  await (0, _tracker.trackEvent)('dev_env_update_command_execute', trackingInfo);
45
-
46
37
  try {
47
38
  const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
48
-
49
39
  if (!environmentAlreadyExists) {
50
40
  throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
51
41
  }
52
-
53
42
  const currentInstanceData = (0, _devEnvironmentCore.readEnvironmentData)(slug);
54
43
  debug('Read instance data', currentInstanceData);
55
44
  const preselectedOptions = {
@@ -15,9 +15,7 @@
15
15
  "use strict";
16
16
 
17
17
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
-
19
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
19
  (0, _command.default)({
22
20
  requiredArgs: 1
23
21
  }).command('create', 'Create a new local dev environment').command('update', 'Update an already created local dev environment').command('start', 'Start a local dev environment').command('stop', 'Stop a local dev environment').command('destroy', 'Remove containers, networks, volumes and configuration files of a local dev environment').command('info', 'Provides basic info about one or multiple local dev environments').command('list', 'Provides basic info about all local dev environments').command('exec', 'Execute an operation on a dev environment').command('import', 'Import data into a local WordPress environment').argv(process.argv);