@automattic/vip 2.39.6 → 2.40.0-dev.1
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,79 @@ ${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
|
+
const failureDetails = await (0, _enquirer.prompt)({
|
|
246
|
+
type: 'confirm',
|
|
247
|
+
name: 'download',
|
|
248
|
+
message: 'Download file import errors report now?'
|
|
249
|
+
});
|
|
250
|
+
if (!failureDetails.download) {
|
|
251
|
+
progressTracker.suffix += `${_chalk.default.yellow(`⚠️ Click on the following link to download the file import errors report`)}`;
|
|
252
|
+
progressTracker.suffix += `\n${_chalk.default.italic.yellow('(The link will be valid for the next 15 minutes & the data is retained for 7 days since the completion of the import)')} `;
|
|
253
|
+
progressTracker.suffix += `\n\n${_chalk.default.bold.yellow(fileErrorsUrl)}`;
|
|
254
|
+
progressTracker.print({
|
|
255
|
+
clearAfter: true
|
|
256
|
+
});
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const failureDetailsErrors = await fetchFailureDetails(fileErrorsUrl);
|
|
260
|
+
await exportFailureDetails(failureDetailsErrors);
|
|
261
|
+
}
|
|
262
|
+
function printFileErrorsReportLinkExpiredError(results) {
|
|
263
|
+
if (results.filesTotal && results.filesProcessed && results.filesTotal !== results.filesProcessed) {
|
|
264
|
+
const errorsFound = results.filesTotal - results.filesProcessed;
|
|
265
|
+
progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${errorsFound} error(s) were found. File import errors report link expired.`)}`;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async function printFailureDetails(fileErrors, results) {
|
|
269
|
+
progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${fileErrors.length} file import error(s) were found`)}`;
|
|
270
|
+
if ((results.filesTotal ?? 0) - (results.filesProcessed ?? 0) !== fileErrors.length) {
|
|
271
|
+
progressTracker.suffix += `. ${_chalk.default.italic.yellow('File import errors report size threshold reached.')}`;
|
|
272
|
+
}
|
|
273
|
+
await exportFailureDetails(fileErrors);
|
|
274
|
+
}
|
|
219
275
|
try {
|
|
220
276
|
const results = await getResults();
|
|
221
277
|
overallStatus = results.status ?? 'unknown';
|
|
222
278
|
progressTracker.stopPrinting();
|
|
223
279
|
setProgressTrackerSuffix();
|
|
224
280
|
progressTracker.print();
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
281
|
+
if (results.failureDetails?.fileErrorsUrl) {
|
|
282
|
+
await promptFailureDetailsDownload(results.failureDetails.fileErrorsUrl);
|
|
283
|
+
} else {
|
|
284
|
+
const fileErrors = results.failureDetails?.fileErrors ?? [];
|
|
285
|
+
if (fileErrors.length > 0) {
|
|
286
|
+
// Errors were observed and are present in the dto
|
|
287
|
+
// Fall back to exporting errors to local file
|
|
288
|
+
await printFailureDetails(fileErrors, results);
|
|
289
|
+
} else if ('ABORTED' !== overallStatus) {
|
|
290
|
+
// Errors are not present in the dto
|
|
291
|
+
// And file error details report link is not available
|
|
292
|
+
// do not print this message if the import was aborted
|
|
293
|
+
printFileErrorsReportLinkExpiredError(results);
|
|
238
294
|
}
|
|
239
295
|
}
|
|
240
296
|
|
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
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.40.0-dev.1",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@automattic/vip",
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.40.0-dev.1",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|