@automattic/vip 2.40.0-dev.3 → 2.40.0-dev.4

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.
@@ -24,6 +24,9 @@ const examples = [{
24
24
  const startProcessing = new Date();
25
25
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
26
26
  trackingInfo.vscode = Boolean(opt.vscode);
27
+ trackingInfo.docker = lando.config.versions.engine;
28
+ trackingInfo.docker_compose = lando.config.versions.compose;
29
+ trackingInfo.compose_plugin = lando.config.versions.composePlugin;
27
30
  await (0, _tracker.trackEvent)('dev_env_start_command_execute', trackingInfo);
28
31
  debug('Args: ', arg, 'Options: ', opt);
29
32
  const options = {
@@ -13,7 +13,6 @@ var _tracker = require("../lib/tracker");
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
  // eslint-disable-next-line no-duplicate-imports
15
15
 
16
- const API_VERSION = 'v2';
17
16
  const appQuery = `
18
17
  id,
19
18
  name,
@@ -117,8 +116,7 @@ Importing Media into your App...
117
116
  environmentId: env.id,
118
117
  archiveUrl: url,
119
118
  overwriteExistingFiles,
120
- importIntermediateImages,
121
- apiVersion: API_VERSION
119
+ importIntermediateImages
122
120
  }
123
121
  }
124
122
  });
@@ -126,7 +126,6 @@ const verifyDNSResolution = async slug => {
126
126
  const validateDependencies = async (lando, slug) => {
127
127
  const now = new Date();
128
128
  (0, _devEnvironmentLando.validateDockerInstalled)(lando);
129
- await (0, _devEnvironmentLando.validateDockerAccess)(lando);
130
129
  if (slug) {
131
130
  await verifyDNSResolution(slug);
132
131
  }
@@ -12,7 +12,6 @@ exports.landoRebuild = landoRebuild;
12
12
  exports.landoShell = landoShell;
13
13
  exports.landoStart = landoStart;
14
14
  exports.landoStop = landoStop;
15
- exports.validateDockerAccess = validateDockerAccess;
16
15
  exports.validateDockerInstalled = validateDockerInstalled;
17
16
  var _chalk = _interopRequireDefault(require("chalk"));
18
17
  var _debug = _interopRequireDefault(require("debug"));
@@ -23,12 +22,15 @@ var _build = _interopRequireDefault(require("lando/plugins/lando-tooling/lib/bui
23
22
  var _promises = require("node:dns/promises");
24
23
  var _promises2 = require("node:fs/promises");
25
24
  var _nodeOs = require("node:os");
26
- var _nodePath = _interopRequireDefault(require("node:path"));
25
+ var _nodePath = _interopRequireWildcard(require("node:path"));
26
+ var _semver = require("semver");
27
27
  var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
28
28
  var _devEnvironmentCore = require("./dev-environment-core");
29
29
  var _dockerUtils = require("./docker-utils");
30
30
  var _devEnvironment = require("../constants/dev-environment");
31
31
  var _userError = _interopRequireDefault(require("../user-error"));
32
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
33
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
  /**
34
36
  * This file will hold all the interactions with lando library
@@ -40,9 +42,10 @@ const debug = (0, _debug.default)(DEBUG_KEY);
40
42
  * @return {Promise<LandoConfig>} Lando configuration
41
43
  */
42
44
  async function getLandoConfig() {
43
- const nodeModulesPath = _nodePath.default.join(__dirname, '..', '..', '..', 'node_modules');
44
- const landoPath = _nodePath.default.join(nodeModulesPath, 'lando');
45
- const atLandoPath = _nodePath.default.join(nodeModulesPath, '@lando');
45
+ // The path will be smth like `yarn/global/node_modules/lando/lib/lando.js`; we need the path up to `lando` (inclusive)
46
+ const landoPath = (0, _nodePath.dirname)((0, _nodePath.dirname)(require.resolve('lando')));
47
+ // The path will be smth like `yarn/global/node_modules/@lando/compose/index.js`; we need the path up to `@lando` (inclusive)
48
+ const atLandoPath = (0, _nodePath.dirname)((0, _nodePath.dirname)(require.resolve('@lando/compose')));
46
49
  debug(`Getting Lando config, using paths '${landoPath}' and '${atLandoPath}' for plugins`);
47
50
  const isLandoDebugSelected = _debug.default.enabled(DEBUG_KEY);
48
51
  const isAllDebugSelected = _debug.default.enabled('"*"');
@@ -177,11 +180,13 @@ async function bootstrapLando() {
177
180
  registryResolvable = false;
178
181
  }
179
182
  const pull = registryResolvable && (instanceData.pullAfter ?? 0) < Date.now();
183
+ console.log(pull);
180
184
  if (Array.isArray(data.opts.pullable) && Array.isArray(data.opts.local) && data.opts.local.length === 0 && !pull) {
181
185
  // Setting `data.opts.pullable` to an empty array prevents Lando from pulling images with `docker pull`.
182
186
  // Note that if some of the images are not available, they will still be pulled by `docker-compose`.
183
187
  data.opts.local = data.opts.pullable;
184
188
  data.opts.pullable = [];
189
+ console.log(data.opts);
185
190
  }
186
191
  if (pull || !instanceData.pullAfter) {
187
192
  instanceData.pullAfter = Date.now() + 7 * 24 * 60 * 60 * 1000;
@@ -531,21 +536,26 @@ async function ensureNoOrphantProxyContainer(lando) {
531
536
  await proxyContainer.remove();
532
537
  }
533
538
  function validateDockerInstalled(lando) {
534
- lando.log.verbose('docker-engine exists: %s', lando.engine.dockerInstalled);
535
- if (!lando.engine.dockerInstalled) {
536
- throw new _userError.default('docker could not be located! Please follow the following instructions to install it - https://docs.docker.com/engine/install/');
537
- }
538
- lando.log.verbose('docker-compose exists: %s', lando.engine.composeInstalled);
539
- if (!lando.engine.composeInstalled) {
540
- throw Error('docker-compose could not be located! Please follow the following instructions to install it - https://docs.docker.com/compose/install/');
541
- }
542
- }
543
- async function validateDockerAccess(lando) {
544
- const docker = lando.engine.docker;
545
- lando.log.verbose('Fetching docker info to verify Docker connection');
546
- try {
547
- await docker.info();
548
- } catch (error) {
539
+ const {
540
+ engine,
541
+ composePlugin,
542
+ compose
543
+ } = lando.config.versions;
544
+ lando.log.verbose('docker-engine version: %s', engine);
545
+ if (!engine) {
546
+ if (!lando.config.dockerBin) {
547
+ throw new _userError.default('docker binary could not be located! Please follow the following instructions to install it - https://docs.docker.com/engine/install/');
548
+ }
549
549
  throw new _userError.default('Failed to connect to Docker. Please verify that Docker engine (service) is running and follow the troubleshooting instructions for your platform.');
550
550
  }
551
+ lando.log.verbose('docker-compose version: %s', compose);
552
+ lando.log.verbose('compose plugin version: %s', composePlugin);
553
+ if (!composePlugin) {
554
+ if (!compose) {
555
+ throw new Error('docker-compose binary could not be located! Please follow the following instructions to install it - https://docs.docker.com/compose/install/');
556
+ }
557
+ if (!(0, _semver.satisfies)(compose, '^2.0.0')) {
558
+ throw new Error(`docker-compose version ${compose} is not supported. Please upgrade to version 2.0.0 or higher - https://docs.docker.com/compose/install/`);
559
+ }
560
+ }
551
561
  }
@@ -5,7 +5,6 @@ exports.default = void 0;
5
5
  exports.getGlyphForStatus = getGlyphForStatus;
6
6
  exports.mediaImportCheckStatus = mediaImportCheckStatus;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
- var _enquirer = require("enquirer");
9
8
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
10
9
  var _promises = require("node:fs/promises");
11
10
  var _nodePath = require("node:path");
@@ -37,7 +36,6 @@ const IMPORT_MEDIA_PROGRESS_QUERY = (0, _graphqlTag.default)`
37
36
  fileName
38
37
  errors
39
38
  }
40
- fileErrorsUrl
41
39
  }
42
40
  }
43
41
  }
@@ -218,83 +216,25 @@ ${maybeExitPrompt}
218
216
  // Kick off the check
219
217
  void checkStatus(IMPORT_MEDIA_PROGRESS_POLL_INTERVAL);
220
218
  });
221
- async function exportFailureDetails(fileErrors) {
222
- const formattedData = buildFileErrors(fileErrors, exportFileErrorsToJson);
223
- const errorsFile = `media-import-${app.name ?? ''}-${Date.now()}${exportFileErrorsToJson ? '.json' : '.txt'}`;
224
- try {
225
- await (0, _promises.writeFile)(errorsFile, formattedData);
226
- progressTracker.suffix += `${_chalk.default.yellow(`⚠️ All errors have been exported to ${_chalk.default.bold((0, _nodePath.resolve)(errorsFile))}\n`)}`;
227
- } catch (writeFileErr) {
228
- progressTracker.suffix += `${_chalk.default.red(`Could not export errors to file\n${writeFileErr.message}`)}`;
229
- }
230
- }
231
- async function fetchFailureDetails(fileErrorsUrl) {
232
- progressTracker.suffix += `
233
- =============================================================
234
- Downloading errors details from ${fileErrorsUrl}
235
- \n`;
236
- progressTracker.print({
237
- clearAfter: true
238
- });
239
- try {
240
- const response = await fetch(fileErrorsUrl);
241
- return await response.json();
242
- } catch (err) {
243
- progressTracker.suffix += `${_chalk.default.red(`Could not download import errors report\n${err.message}`)}`;
244
- throw err;
245
- }
246
- }
247
- async function promptFailureDetailsDownload(fileErrorsUrl) {
248
- const failureDetails = await (0, _enquirer.prompt)({
249
- type: 'confirm',
250
- name: 'download',
251
- message: 'Download import errors report now? (Report will be downloadable for up to 7 days from the completion of the import)'
252
- });
253
- if (!failureDetails.download) {
254
- progressTracker.suffix += `${_chalk.default.yellow(`⚠️ An error report file has been generated for this media import. Access it within the next 15 minutes by clicking on the URL below.`)}`;
255
- progressTracker.suffix += `\n${_chalk.default.yellow(`Or, generate a new URL by running the ${_chalk.default.bgYellow('vip import media status')} command.`)} `;
256
- progressTracker.suffix += `\n${_chalk.default.yellow('The report will be downloadable for up to 7 days after the completion of the import or until a new media import is performed.')}`;
257
- progressTracker.suffix += `\n\n${_chalk.default.underline(fileErrorsUrl)}\n`;
258
- progressTracker.print({
259
- clearAfter: true
260
- });
261
- return;
262
- }
263
- const failureDetailsErrors = await fetchFailureDetails(fileErrorsUrl);
264
- await exportFailureDetails(failureDetailsErrors);
265
- }
266
- function printFileErrorsReportLinkExpiredError(results) {
267
- if (results.filesTotal && results.filesProcessed && results.filesTotal !== results.filesProcessed) {
268
- const errorsFound = results.filesTotal - results.filesProcessed;
269
- progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${errorsFound} error(s) were found. File import errors report link expired.`)}`;
270
- }
271
- }
272
- async function printFailureDetails(fileErrors, results) {
273
- progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${fileErrors.length} file import error(s) were found`)}`;
274
- if ((results.filesTotal ?? 0) - (results.filesProcessed ?? 0) !== fileErrors.length) {
275
- progressTracker.suffix += `. ${_chalk.default.italic.yellow('File import errors report size threshold reached.')}`;
276
- }
277
- await exportFailureDetails(fileErrors);
278
- }
279
219
  try {
280
220
  const results = await getResults();
281
221
  overallStatus = results.status ?? 'unknown';
282
222
  progressTracker.stopPrinting();
283
223
  setProgressTrackerSuffix();
284
224
  progressTracker.print();
285
- if (results.failureDetails?.fileErrorsUrl) {
286
- await promptFailureDetailsDownload(results.failureDetails.fileErrorsUrl);
287
- } else {
288
- const fileErrors = results.failureDetails?.fileErrors ?? [];
289
- if (fileErrors.length > 0) {
290
- // Errors were observed and are present in the dto
291
- // Fall back to exporting errors to local file
292
- await printFailureDetails(fileErrors, results);
293
- } else if ('ABORTED' !== overallStatus) {
294
- // Errors are not present in the dto
295
- // And file error details report link is not available
296
- // do not print this message if the import was aborted
297
- printFileErrorsReportLinkExpiredError(results);
225
+ const fileErrors = results.failureDetails?.fileErrors ?? [];
226
+ if (fileErrors.length > 0) {
227
+ progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${fileErrors.length} file error(s) have been extracted`)}`;
228
+ if ((results.filesTotal ?? 0) - (results.filesProcessed ?? 0) !== fileErrors.length) {
229
+ progressTracker.suffix += `. ${_chalk.default.italic.yellow('File-errors report size threshold reached.')}`;
230
+ }
231
+ const formattedData = buildFileErrors(fileErrors, exportFileErrorsToJson);
232
+ const errorsFile = `media-import-${app.name ?? ''}-${Date.now()}${exportFileErrorsToJson ? '.json' : '.txt'}`;
233
+ try {
234
+ await (0, _promises.writeFile)(errorsFile, formattedData);
235
+ progressTracker.suffix += `\n\n${_chalk.default.yellow(`All errors have been exported to ${_chalk.default.bold((0, _nodePath.resolve)(errorsFile))}`)}\n\n`;
236
+ } catch (writeFileErr) {
237
+ progressTracker.suffix += `\n\n${_chalk.default.red(`Could not export errors to file\n${writeFileErr.message}`)}\n\n`;
298
238
  }
299
239
  }
300
240
 
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.39.7
4
+
5
+ * Fix promptForBoolean to display the default initial value capitalized
6
+ * fix(dev-env): `vip dev-env info --all` should not ask for a slug
7
+ * build(deps-dev): bump rimraf from 5.0.5 to 5.0.7
8
+ * build(deps): bump cli-table3 from 0.6.4 to 0.6.5
9
+ * build(deps): bump semver from 7.6.0 to 7.6.2
10
+ * build(deps-dev): bump @types/node from 18.19.31 to 18.19.33
11
+ * build(deps-dev): bump @automattic/eslint-plugin-wpvip from 0.9.1 to 0.10/1832
12
+ * build(deps-dev): bump @automattic/eslint-plugin-wpvip from 0.10.0 to 0.11l/1835
13
+ * fix(dev-env): plugin loading when using yarn to install VIP CLI
14
+ * feat(dev-env): track versions of `docker` and `docker-compose`
15
+
16
+ **Full Changelog**: https://github.com/Automattic/vip-cli/compare/2.39.6...2.39.7
17
+
3
18
  ### 2.39.6
4
19
  * Custom Deploys: Update deploy validation to run fully off of the custom deploy token. There are breaking changes associated with these updates, so the VIP CLI must be updated to this latest version in order to continue using the custom deploy functionality.
5
20
 
@@ -23,7 +23,7 @@ const releaseTag = process.env.npm_config_tag ?? 'latest';
23
23
  }
24
24
  }
25
25
 
26
- if ( config.gitEnforceBranch && releaseTag !== 'next' ) {
26
+ if ( config.gitEnforceBranch && releaseTag === 'latest' ) {
27
27
  const currentBranch = await execAsync( 'git branch --show-current' );
28
28
 
29
29
  if ( currentBranch.trim() !== config.gitEnforceBranch ) {