@automattic/vip 3.0.0 → 3.1.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/dist/bin/vip-import-media.js +3 -1
- package/dist/lib/media-import/status.js +73 -13
- package/docs/CHANGELOG.md +15 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ var _tracker = require("../lib/tracker");
|
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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,83 @@ ${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))}\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
|
+
}
|
|
219
279
|
try {
|
|
220
280
|
const results = await getResults();
|
|
221
281
|
overallStatus = results.status ?? 'unknown';
|
|
222
282
|
progressTracker.stopPrinting();
|
|
223
283
|
setProgressTrackerSuffix();
|
|
224
284
|
progressTracker.print();
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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);
|
|
238
298
|
}
|
|
239
299
|
}
|
|
240
300
|
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 3.0.0
|
|
4
|
+
|
|
5
|
+
* fix(dev-env): demo code is displayed as `[demo-image]`
|
|
6
|
+
* build(deps-dev): bump @types/node from 18.19.33 to 18.19.34
|
|
7
|
+
* build(deps): bump debug from 4.3.4 to 4.3.5
|
|
8
|
+
* ci: remove duplicate check
|
|
9
|
+
* Update the dev-env commands to follow the VIP-CLI style guide
|
|
10
|
+
* build(deps-dev): bump the babel group with 4 updates
|
|
11
|
+
* ci: add publish prerelease workflow
|
|
12
|
+
* build(deps): bump step-security/harden-runner from 2.7.1 to 2.8.0
|
|
13
|
+
* build(deps): bump ini from 4.1.2 to 4.1.3
|
|
14
|
+
* Integrate media import v2 flow and expand on media import error report messaging
|
|
15
|
+
|
|
16
|
+
**Full Changelog**: https://github.com/Automattic/vip-cli/compare/2.39.7...3.0.0
|
|
17
|
+
|
|
3
18
|
### 2.39.7
|
|
4
19
|
|
|
5
20
|
* Fix promptForBoolean to display the default initial value capitalized
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@automattic/vip",
|
|
9
|
-
"version": "3.
|
|
9
|
+
"version": "3.1.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|