@automattic/vip 2.39.6 → 2.40.0-dev.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.
@@ -13,6 +13,7 @@ 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';
16
17
  const appQuery = `
17
18
  id,
18
19
  name,
@@ -116,7 +117,8 @@ Importing Media into your App...
116
117
  environmentId: env.id,
117
118
  archiveUrl: url,
118
119
  overwriteExistingFiles,
119
- importIntermediateImages
120
+ importIntermediateImages,
121
+ apiVersion: API_VERSION
120
122
  }
121
123
  }
122
124
  });
@@ -5,6 +5,7 @@ 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");
8
9
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
9
10
  var _promises = require("node:fs/promises");
10
11
  var _nodePath = require("node:path");
@@ -36,6 +37,7 @@ const IMPORT_MEDIA_PROGRESS_QUERY = (0, _graphqlTag.default)`
36
37
  fileName
37
38
  errors
38
39
  }
40
+ fileErrorsUrl
39
41
  }
40
42
  }
41
43
  }
@@ -216,25 +218,76 @@ ${maybeExitPrompt}
216
218
  // Kick off the check
217
219
  void checkStatus(IMPORT_MEDIA_PROGRESS_POLL_INTERVAL);
218
220
  });
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))}`)}`;
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
+ try {
237
+ const response = await fetch(fileErrorsUrl);
238
+ return await response.json();
239
+ } catch (err) {
240
+ progressTracker.suffix += `${_chalk.default.red(`Could not download file import errors report\n${err.message}`)}`;
241
+ throw err;
242
+ }
243
+ }
244
+ async function promptFailureDetailsDownload(fileErrorsUrl) {
245
+ progressTracker.suffix += `${_chalk.default.yellow(`⚠️ Error details can be found on ${_chalk.default.bold(fileErrorsUrl)}\n${_chalk.default.italic.yellow('(This link will be valid for the next 15 minutes. The report is retained for 7 days from the completion of the import.)')}. `)}\n`;
246
+ progressTracker.print({
247
+ clearAfter: true
248
+ });
249
+ const failureDetails = await (0, _enquirer.prompt)({
250
+ type: 'confirm',
251
+ name: 'download',
252
+ message: 'Download file import errors report now?'
253
+ });
254
+ if (!failureDetails.download) {
255
+ return;
256
+ }
257
+ const failureDetailsErrors = await fetchFailureDetails(fileErrorsUrl);
258
+ await exportFailureDetails(failureDetailsErrors);
259
+ }
260
+ function printFileErrorsReportLinkExpiredError(results) {
261
+ if (results.filesTotal && results.filesProcessed && results.filesTotal !== results.filesProcessed) {
262
+ const errorsFound = results.filesTotal - results.filesProcessed;
263
+ progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${errorsFound} error(s) were found. File import errors report link expired.`)}`;
264
+ }
265
+ }
266
+ async function printFailureDetails(fileErrors, results) {
267
+ progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${fileErrors.length} file import error(s) were found`)}`;
268
+ if ((results.filesTotal ?? 0) - (results.filesProcessed ?? 0) !== fileErrors.length) {
269
+ progressTracker.suffix += `. ${_chalk.default.italic.yellow('File import errors report size threshold reached.')}`;
270
+ }
271
+ await exportFailureDetails(fileErrors);
272
+ }
219
273
  try {
220
274
  const results = await getResults();
221
275
  overallStatus = results.status ?? 'unknown';
222
276
  progressTracker.stopPrinting();
223
277
  setProgressTrackerSuffix();
224
278
  progressTracker.print();
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`;
279
+ if (results.failureDetails?.fileErrorsUrl) {
280
+ await promptFailureDetailsDownload(results.failureDetails.fileErrorsUrl);
281
+ } else {
282
+ const fileErrors = results.failureDetails?.fileErrors ?? [];
283
+ if (fileErrors.length > 0) {
284
+ // Errors were observed and are present in the dto
285
+ // Fall back to exporting errors to local file
286
+ await printFailureDetails(fileErrors, results);
287
+ } else {
288
+ // Errors are not present in the dto
289
+ // And file error details report link is not available
290
+ printFileErrorsReportLinkExpiredError(results);
238
291
  }
239
292
  }
240
293
 
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.39.6
4
+ * 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
+
6
+ **Full Changelog**: https://github.com/Automattic/vip-cli/compare/2.39.5...2.39.6
7
+
3
8
  ### 2.39.5
4
9
  * Custom Deploys: Pass in deploy token to StartCustomDeploy mutation and allow `getSignedUploadRequestData()` to accept another bearer token
5
10
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.39.6",
3
+ "version": "2.40.0-dev.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "2.39.6",
9
+ "version": "2.40.0-dev.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.39.6",
3
+ "version": "2.40.0-dev.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {