@automattic/vip 2.33.0 → 2.35.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/CHANGELOG.md +45 -0
- package/dist/bin/vip-backup-db.js +0 -5
- package/dist/bin/vip-import-sql.js +1 -0
- package/dist/lib/cli/config.js +2 -0
- package/dist/lib/cli/progress.js +10 -13
- package/dist/lib/client-file-uploader.js +3 -3
- package/dist/lib/config/software.js +3 -2
- package/dist/lib/constants/vipgo.js +4 -2
- package/dist/lib/dev-environment/dev-environment-lando.js +4 -3
- package/dist/lib/envvar/logging.js +2 -5
- package/dist/lib/keychain.js +1 -0
- package/dist/lib/media-import/media-file-import.js +0 -5
- package/dist/lib/media-import/progress.js +11 -5
- package/dist/lib/media-import/status.js +27 -39
- package/dist/lib/site-import/db-file-import.js +8 -15
- package/dist/lib/site-import/status.js +28 -34
- package/dist/lib/utils.js +10 -5
- package/dist/lib/validations/is-multi-site.js +1 -1
- package/dist/lib/validations/is-multisite-domain-mapped.js +1 -1
- package/helpers/prepublishOnly.js +7 -4
- package/npm-shrinkwrap.json +2041 -1947
- package/package.json +22 -25
- package/tsconfig.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 2.35.0
|
|
4
|
+
|
|
5
|
+
- #1506 Allow imports for all sites with databases by @chriszarate in https://github.com/Automattic/vip-cli/pull/1507
|
|
6
|
+
- #1497 fix: remove import bypass for TypeScript by @sjinks in https://github.com/Automattic/vip-cli/pull/1497
|
|
7
|
+
- #1496 fix(dev-env): update certificate Common Name by @sjinks in https://github.com/Automattic/vip-cli/pull/1496
|
|
8
|
+
- #1513 refactor: use `semver` instead of `check-node-version` by @sjinks in https://github.com/Automattic/vip-cli/pull/1513
|
|
9
|
+
- #1514 chore(dev-deps): update TypeScript type definitions by @sjinks in https://github.com/Automattic/vip-cli/pull/1514
|
|
10
|
+
- #1508 chore(dev-deps): update jest-related packages to 29.7.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1508
|
|
11
|
+
- #1509 chore(dev-deps): update eslint from 8.47.0 to 8.49.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1509
|
|
12
|
+
- #1510 chore(deps): update uuid from 9.0.0 to 9.0.1 by @sjinks in https://github.com/Automattic/vip-cli/pull/1510
|
|
13
|
+
- #1512 chore(deps): update node-fetch from 2.6.12 to 2.7.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1512
|
|
14
|
+
- #1511 chore(deps): update graphql-tag from 2.12.5 to 2.12.6 by @sjinks in https://github.com/Automattic/vip-cli/pull/1511
|
|
15
|
+
- #1517 chore(dev-deps): update rimraf from 5.0.1 to 5.0.5 by @sjinks in https://github.com/Automattic/vip-cli/pull/1517
|
|
16
|
+
- #1516 chore(dev-deps): update eslint from 8.49.0 to 8.50.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1516
|
|
17
|
+
- #1499 chore(dev-deps): update @automattic/eslint-plugin-wpvip to 0.6.0 by @sjinks in https://github.com/Automattic/vip-cli/pull/1499
|
|
18
|
+
|
|
19
|
+
### 2.34.0
|
|
20
|
+
|
|
21
|
+
- #1503 chore(dev-deps): update nock to 13.3.3
|
|
22
|
+
- #1502 chore(dev-deps): update flow-bin to 0.216.1
|
|
23
|
+
- #1501 chore(deps): update jest-related packages
|
|
24
|
+
- #1500 chore(dev-deps): update babel-related packages
|
|
25
|
+
- #1498 ci: run tests and checks in parallel
|
|
26
|
+
- #1462 Fixed Slowlogs local unit test
|
|
27
|
+
- #1488 fix: do not abort if a temporary directory cannot be removed on exit
|
|
28
|
+
- #1495 refactor: convert `media-import` to TypeScript
|
|
29
|
+
- #1492 refactor: convert `site-import` directory to TypeScript
|
|
30
|
+
|
|
31
|
+
### 2.33.0
|
|
32
|
+
|
|
33
|
+
- #1475 Updating CONTRIBUTING.md with new publishing procedure
|
|
34
|
+
- #1477 Fetch environment name from server to fix environment selector label
|
|
35
|
+
- #1479 chore(dev-deps): update jest-related packages to 29.6.2
|
|
36
|
+
- #1480 chore(deps): update node-fetch to 2.6.12
|
|
37
|
+
- #1481 chore(deps): update socket.io-client to 4.7.2
|
|
38
|
+
- #1482 chore(deps): update enquirer to 2.4.1
|
|
39
|
+
- #1478 Fix False UP status for multisite dev-envs
|
|
40
|
+
- #1483 Disable Windows patch
|
|
41
|
+
- #1458 Add warning confirmation when there's not enough space on disk. by
|
|
42
|
+
- #1487 fix(dev-env): display ports exposed by services
|
|
43
|
+
- #1490 fix: CLI not respecting proxy settings when creating local dev environment by
|
|
44
|
+
- #1491 chore(dev-deps): update eslint from 8.43.0 to 8.47.0
|
|
45
|
+
- #1486 chore(dev-deps): update babel-related packages
|
|
46
|
+
- #1484 feat(backup): Add vip backup db command
|
|
47
|
+
|
|
3
48
|
### 2.32.4
|
|
4
49
|
|
|
5
50
|
- #1470 Rename prepare-release.yml to npm-prepare-release.yml
|
package/dist/lib/cli/config.js
CHANGED
|
@@ -14,10 +14,12 @@ const debug = (0, _debug.default)('@automattic/vip:lib:cli:config');
|
|
|
14
14
|
let configFromFile;
|
|
15
15
|
try {
|
|
16
16
|
// Get `local` config first; this will only exist in dev as it's npmignore-d.
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
18
|
configFromFile = require("../../../config/config.local.json");
|
|
18
19
|
debug('Loaded config data from config.local.json');
|
|
19
20
|
} catch {
|
|
20
21
|
// Fall back to `publish` config file.
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
23
|
configFromFile = require("../../../config/config.publish.json");
|
|
22
24
|
debug('Loaded config data from config.publish.json');
|
|
23
25
|
}
|
package/dist/lib/cli/progress.js
CHANGED
|
@@ -4,12 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.StepStatus = exports.ProgressTracker = void 0;
|
|
7
|
+
var _nodeOs = require("node:os");
|
|
7
8
|
var _singleLineLog = require("single-line-log");
|
|
8
9
|
var _format = require("../../lib/cli/format");
|
|
9
|
-
var _os = _interopRequireDefault(require("os"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
// @format
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* External dependencies
|
|
15
12
|
*/
|
|
@@ -68,7 +65,7 @@ class ProgressTracker {
|
|
|
68
65
|
map.set(id, {
|
|
69
66
|
id,
|
|
70
67
|
name,
|
|
71
|
-
status: status
|
|
68
|
+
status: status ?? StepStatus.PENDING
|
|
72
69
|
});
|
|
73
70
|
return map;
|
|
74
71
|
}, new Map());
|
|
@@ -104,10 +101,10 @@ class ProgressTracker {
|
|
|
104
101
|
}));
|
|
105
102
|
if (!steps.some(({
|
|
106
103
|
status
|
|
107
|
-
}) => status ===
|
|
104
|
+
}) => status === StepStatus.RUNNING)) {
|
|
108
105
|
const firstPendingStepIndex = steps.findIndex(({
|
|
109
106
|
status
|
|
110
|
-
}) => status ===
|
|
107
|
+
}) => status === StepStatus.PENDING);
|
|
111
108
|
if (firstPendingStepIndex !== -1) {
|
|
112
109
|
// "Promote" the first "pending" to "running"
|
|
113
110
|
formattedSteps[firstPendingStepIndex].status = StepStatus.RUNNING;
|
|
@@ -122,7 +119,7 @@ class ProgressTracker {
|
|
|
122
119
|
const steps = [...this.getSteps().values()];
|
|
123
120
|
return steps.find(({
|
|
124
121
|
status
|
|
125
|
-
}) => status ===
|
|
122
|
+
}) => status === StepStatus.PENDING);
|
|
126
123
|
}
|
|
127
124
|
getCurrentStep() {
|
|
128
125
|
if (this.allStepsSucceeded()) {
|
|
@@ -131,7 +128,7 @@ class ProgressTracker {
|
|
|
131
128
|
const steps = [...this.getSteps().values()];
|
|
132
129
|
return steps.find(({
|
|
133
130
|
status
|
|
134
|
-
}) => status ===
|
|
131
|
+
}) => status === StepStatus.RUNNING);
|
|
135
132
|
}
|
|
136
133
|
stepRunning(stepId) {
|
|
137
134
|
this.setStatusForStepId(stepId, StepStatus.RUNNING);
|
|
@@ -153,7 +150,7 @@ class ProgressTracker {
|
|
|
153
150
|
allStepsSucceeded() {
|
|
154
151
|
return [...this.getSteps().values()].every(({
|
|
155
152
|
status
|
|
156
|
-
}) => status ===
|
|
153
|
+
}) => status === StepStatus.SUCCESS);
|
|
157
154
|
}
|
|
158
155
|
setStatusForStepId(stepId, status) {
|
|
159
156
|
const step = this.stepsFromCaller.get(stepId);
|
|
@@ -164,7 +161,7 @@ class ProgressTracker {
|
|
|
164
161
|
if (COMPLETED_STEP_SLUGS.includes(step.status)) {
|
|
165
162
|
throw new Error(`Step name ${stepId} is already completed.`);
|
|
166
163
|
}
|
|
167
|
-
if (status ===
|
|
164
|
+
if (status === StepStatus.FAILED) {
|
|
168
165
|
this.hasFailure = true;
|
|
169
166
|
}
|
|
170
167
|
this.stepsFromCaller.set(stepId, {
|
|
@@ -199,7 +196,7 @@ class ProgressTracker {
|
|
|
199
196
|
// without this, any prompt, or any text in between will get overwritten by the progress tracker
|
|
200
197
|
let linesToSkip = '';
|
|
201
198
|
for (let iteration = 0; iteration < this.stepsFromCaller.size; iteration++) {
|
|
202
|
-
linesToSkip +=
|
|
199
|
+
linesToSkip += _nodeOs.EOL;
|
|
203
200
|
}
|
|
204
201
|
process.stdout.write(linesToSkip);
|
|
205
202
|
hasPrintedOnce = true;
|
|
@@ -230,7 +227,7 @@ class ProgressTracker {
|
|
|
230
227
|
const statusIcon = (0, _format.getGlyphForStatus)(status, this.runningSprite);
|
|
231
228
|
let suffix = '';
|
|
232
229
|
if (id === 'upload') {
|
|
233
|
-
if (status ===
|
|
230
|
+
if (status === StepStatus.RUNNING && percentage) {
|
|
234
231
|
suffix = percentage;
|
|
235
232
|
}
|
|
236
233
|
} else if (progress) {
|
|
@@ -42,11 +42,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
42
42
|
// Need to use CommonJS imports here as the `fetch-retry` typedefs are messed up and throwing TypeJS errors when using `import`
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
44
44
|
const fetchWithRetry =
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-var-requires
|
|
46
46
|
require('fetch-retry')(_nodeFetch.default, {
|
|
47
47
|
// Set default retry options
|
|
48
48
|
retries: 3,
|
|
49
|
-
retryDelay:
|
|
49
|
+
retryDelay: attempt => {
|
|
50
50
|
return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
|
|
51
51
|
}
|
|
52
52
|
});
|
|
@@ -213,7 +213,7 @@ async function uploadUsingPutObject({
|
|
|
213
213
|
});
|
|
214
214
|
const response = await fetchWithRetry(presignedRequest.url, {
|
|
215
215
|
...fetchOptions,
|
|
216
|
-
body: fileContent
|
|
216
|
+
body: fileContent ?? (0, _fs.createReadStream)(fileName).pipe(progressPassThrough)
|
|
217
217
|
});
|
|
218
218
|
if (response.status === 200) {
|
|
219
219
|
return 'ok';
|
|
@@ -239,8 +239,9 @@ const promptForUpdate = async (appTypeId, opts, softwareSettings) => {
|
|
|
239
239
|
const version = await _processComponentVersion(softwareSettings, component, opts.version);
|
|
240
240
|
const confirm =
|
|
241
241
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
242
|
-
opts.force || (
|
|
243
|
-
|
|
242
|
+
opts.force || (
|
|
243
|
+
// NOSONAR
|
|
244
|
+
await new _enquirer.Confirm({
|
|
244
245
|
message: `Are you sure you want to upgrade ${COMPONENT_NAMES[component]} to ${version}?`
|
|
245
246
|
}).run().catch(() => {
|
|
246
247
|
throw new _userError.default('Command cancelled by user.');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WORDPRESS_SITE_TYPE_IDS = exports.WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = exports.WORDPRESS_APPLICATION_TYPE_ID = exports.NODEJS_SITE_TYPE_IDS = exports.NODEJS_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_APPLICATION_TYPE_ID = exports.NODEJS_APPLICATION_TYPE_ID = void 0;
|
|
6
|
+
exports.WORDPRESS_SITE_TYPE_IDS = exports.WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = exports.WORDPRESS_APPLICATION_TYPE_ID = exports.NODEJS_SITE_TYPE_IDS = exports.NODEJS_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_APPLICATION_TYPE_ID = exports.NODEJS_APPLICATION_TYPE_ID = exports.DATABASE_APPLICATION_TYPE_IDS = void 0;
|
|
7
7
|
const WORDPRESS_APPLICATION_TYPE_ID = 2;
|
|
8
8
|
exports.WORDPRESS_APPLICATION_TYPE_ID = WORDPRESS_APPLICATION_TYPE_ID;
|
|
9
9
|
const WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = 6;
|
|
@@ -19,4 +19,6 @@ exports.NODEJS_REDIS_APPLICATION_TYPE_ID = NODEJS_REDIS_APPLICATION_TYPE_ID;
|
|
|
19
19
|
const NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = 8;
|
|
20
20
|
exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID;
|
|
21
21
|
const NODEJS_SITE_TYPE_IDS = [NODEJS_APPLICATION_TYPE_ID, NODEJS_MYSQL_APPLICATION_TYPE_ID, NODEJS_REDIS_APPLICATION_TYPE_ID, NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID];
|
|
22
|
-
exports.NODEJS_SITE_TYPE_IDS = NODEJS_SITE_TYPE_IDS;
|
|
22
|
+
exports.NODEJS_SITE_TYPE_IDS = NODEJS_SITE_TYPE_IDS;
|
|
23
|
+
const DATABASE_APPLICATION_TYPE_IDS = [WORDPRESS_APPLICATION_TYPE_ID, WORDPRESS_NON_PROD_APPLICATION_TYPE_ID, NODEJS_MYSQL_APPLICATION_TYPE_ID, NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID];
|
|
24
|
+
exports.DATABASE_APPLICATION_TYPE_IDS = DATABASE_APPLICATION_TYPE_IDS;
|
|
@@ -91,7 +91,7 @@ async function getLandoConfig() {
|
|
|
91
91
|
proxyName: 'vip-dev-env-proxy',
|
|
92
92
|
userConfRoot: landoDir,
|
|
93
93
|
home: fakeHomeDir,
|
|
94
|
-
domain: 'lndo.site',
|
|
94
|
+
domain: 'vipdev.lndo.site',
|
|
95
95
|
version: 'unknown'
|
|
96
96
|
};
|
|
97
97
|
return (0, _bootstrap.buildConfig)(config);
|
|
@@ -101,8 +101,9 @@ async function initLandoApplication(lando, instancePath) {
|
|
|
101
101
|
const app = lando.getApp(instancePath);
|
|
102
102
|
app.events.on('post-init', 1, () => {
|
|
103
103
|
const initOnly = [];
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const services = app.config.services;
|
|
105
|
+
Object.keys(services).forEach(serviceName => {
|
|
106
|
+
if (services[serviceName].initOnly) {
|
|
106
107
|
initOnly.push(serviceName);
|
|
107
108
|
app.config.services[serviceName].scanner = false;
|
|
108
109
|
}
|
|
@@ -8,11 +8,6 @@ exports.getEnvContext = getEnvContext;
|
|
|
8
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
9
|
var _command = require("../../lib/cli/command");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @format
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* External dependencies
|
|
18
13
|
*/
|
|
@@ -23,6 +18,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
18
|
|
|
24
19
|
// Shared debugger.
|
|
25
20
|
const debug = (0, _debug.default)('@automattic/vip:bin:config:envvar');
|
|
21
|
+
|
|
22
|
+
// FIXME: Replace with a proper type
|
|
26
23
|
exports.debug = debug;
|
|
27
24
|
function getEnvContext(app, env) {
|
|
28
25
|
return `@${app.id}.${(0, _command.getEnvIdentifier)(env)}`;
|
package/dist/lib/keychain.js
CHANGED
|
@@ -19,6 +19,7 @@ let exportValue;
|
|
|
19
19
|
const debug = (0, _debug.default)('@automattic/vip:keychain');
|
|
20
20
|
try {
|
|
21
21
|
// Try using Secure keychain ("keytar") first
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
22
23
|
const Secure = require("./keychain/secure");
|
|
23
24
|
exportValue = new Secure();
|
|
24
25
|
} catch (error) {
|
|
@@ -7,11 +7,6 @@ exports.SUPPORTED_MEDIA_FILE_IMPORT_SITE_TYPES = exports.MEDIA_IMPORT_FILE_SIZE_
|
|
|
7
7
|
exports.currentUserCanImportForApp = currentUserCanImportForApp;
|
|
8
8
|
exports.isSupportedApp = void 0;
|
|
9
9
|
var _fileSize = require("../../lib/constants/file-size");
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @format
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
10
|
/**
|
|
16
11
|
* Internal dependencies
|
|
17
12
|
*/
|
|
@@ -7,13 +7,14 @@ exports.MediaImportProgressTracker = void 0;
|
|
|
7
7
|
var _singleLineLog = require("single-line-log");
|
|
8
8
|
var _status = require("../../lib/media-import/status");
|
|
9
9
|
var _format = require("../../lib/cli/format");
|
|
10
|
-
/** @format */
|
|
11
10
|
/**
|
|
12
11
|
* External dependencies
|
|
13
12
|
*/
|
|
13
|
+
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
+
|
|
17
18
|
const PRINT_INTERVAL = process.env.DEBUG ? 5000 : 200; // How often the report is printed. Mainly affects the "spinner" animation.
|
|
18
19
|
|
|
19
20
|
class MediaImportProgressTracker {
|
|
@@ -26,15 +27,20 @@ class MediaImportProgressTracker {
|
|
|
26
27
|
constructor(status) {
|
|
27
28
|
this.runningSprite = new _format.RunningSprite();
|
|
28
29
|
this.hasFailure = false;
|
|
29
|
-
this.status =
|
|
30
|
+
this.status = {
|
|
31
|
+
...status
|
|
32
|
+
};
|
|
30
33
|
this.prefix = '';
|
|
31
34
|
this.suffix = '';
|
|
35
|
+
this.hasPrinted = false;
|
|
32
36
|
}
|
|
33
37
|
setStatus(status) {
|
|
34
38
|
if ('FAILED' === status.status) {
|
|
35
39
|
this.hasFailure = true;
|
|
36
40
|
}
|
|
37
|
-
this.status =
|
|
41
|
+
this.status = {
|
|
42
|
+
...status
|
|
43
|
+
};
|
|
38
44
|
}
|
|
39
45
|
startPrinting(prePrintCallback = () => {}) {
|
|
40
46
|
this.printInterval = setInterval(() => {
|
|
@@ -54,7 +60,7 @@ class MediaImportProgressTracker {
|
|
|
54
60
|
this.hasPrinted = true;
|
|
55
61
|
_singleLineLog.stdout.clear();
|
|
56
62
|
}
|
|
57
|
-
const statusIcon = (0, _status.getGlyphForStatus)(this.status.status, this.runningSprite);
|
|
63
|
+
const statusIcon = (0, _status.getGlyphForStatus)(this.status.status ?? '', this.runningSprite);
|
|
58
64
|
let logs;
|
|
59
65
|
if (this.status.filesProcessed && this.status.filesTotal) {
|
|
60
66
|
const progressPercentage = Math.floor(this.status.filesProcessed / this.status.filesTotal * 100);
|
|
@@ -62,7 +68,7 @@ class MediaImportProgressTracker {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
// Output the logs
|
|
65
|
-
(0, _singleLineLog.stdout)(`${this.prefix || ''}${logs
|
|
71
|
+
(0, _singleLineLog.stdout)(`${this.prefix || ''}${logs ?? ''}${this.suffix || ''}`);
|
|
66
72
|
if (clearAfter) {
|
|
67
73
|
// Break out of the "Single log line" buffer
|
|
68
74
|
_singleLineLog.stdout.clear();
|
|
@@ -6,23 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.getGlyphForStatus = getGlyphForStatus;
|
|
8
8
|
exports.mediaImportCheckStatus = mediaImportCheckStatus;
|
|
9
|
+
var _promises = require("node:fs/promises");
|
|
10
|
+
var _nodePath = require("node:path");
|
|
9
11
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
12
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
11
|
-
var _fs = require("fs");
|
|
12
|
-
var path = _interopRequireWildcard(require("path"));
|
|
13
13
|
var _api = _interopRequireDefault(require("../../lib/api"));
|
|
14
14
|
var _mediaFileImport = require("../../lib/media-import/media-file-import");
|
|
15
|
-
var _progress = require("../../lib/media-import/progress");
|
|
16
15
|
var _format = require("../../lib/cli/format");
|
|
17
|
-
var _format2 = require("../cli/format");
|
|
18
|
-
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); }
|
|
19
|
-
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; }
|
|
20
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @format
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
17
|
/**
|
|
27
18
|
* External dependencies
|
|
28
19
|
*/
|
|
@@ -62,6 +53,7 @@ const IMPORT_MEDIA_PROGRESS_QUERY = (0, _graphqlTag.default)`
|
|
|
62
53
|
}
|
|
63
54
|
`;
|
|
64
55
|
async function getStatus(api, appId, envId) {
|
|
56
|
+
var _response$data$app;
|
|
65
57
|
const response = await api.query({
|
|
66
58
|
query: IMPORT_MEDIA_PROGRESS_QUERY,
|
|
67
59
|
variables: {
|
|
@@ -70,21 +62,15 @@ async function getStatus(api, appId, envId) {
|
|
|
70
62
|
},
|
|
71
63
|
fetchPolicy: 'network-only'
|
|
72
64
|
});
|
|
73
|
-
const
|
|
74
|
-
data: {
|
|
75
|
-
app: {
|
|
76
|
-
environments
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} = response;
|
|
65
|
+
const environments = (_response$data$app = response.data.app) === null || _response$data$app === void 0 ? void 0 : _response$data$app.environments;
|
|
80
66
|
if (!(environments !== null && environments !== void 0 && environments.length)) {
|
|
81
67
|
throw new Error('Unable to determine import status from environment');
|
|
82
68
|
}
|
|
83
69
|
const [environment] = environments;
|
|
84
70
|
const {
|
|
85
71
|
mediaImportStatus
|
|
86
|
-
} = environment;
|
|
87
|
-
return mediaImportStatus;
|
|
72
|
+
} = environment ?? {};
|
|
73
|
+
return mediaImportStatus ?? null;
|
|
88
74
|
}
|
|
89
75
|
function getGlyphForStatus(status, runningSprite) {
|
|
90
76
|
switch (status) {
|
|
@@ -113,10 +99,11 @@ function buildErrorMessage(importFailed) {
|
|
|
113
99
|
if ('FAILED' === importFailed.status) {
|
|
114
100
|
const globalFailureDetails = importFailed.failureDetails;
|
|
115
101
|
if (globalFailureDetails) {
|
|
102
|
+
var _globalFailureDetails;
|
|
116
103
|
message += `${_chalk.default.red('Import failed at status: ')}`;
|
|
117
104
|
message += `${_chalk.default.redBright.bold(globalFailureDetails.previousStatus)}\n`;
|
|
118
105
|
message += _chalk.default.red('Errors:');
|
|
119
|
-
globalFailureDetails.globalErrors.forEach(value => {
|
|
106
|
+
(_globalFailureDetails = globalFailureDetails.globalErrors) === null || _globalFailureDetails === void 0 || _globalFailureDetails.forEach(value => {
|
|
120
107
|
message += `\n\t- ${_chalk.default.redBright.bold(value)}`;
|
|
121
108
|
});
|
|
122
109
|
return message;
|
|
@@ -131,16 +118,17 @@ function buildFileErrors(fileErrors, exportFileErrorsToJson) {
|
|
|
131
118
|
if (exportFileErrorsToJson) {
|
|
132
119
|
const fileErrorsToExport = fileErrors.map(fileError => {
|
|
133
120
|
return {
|
|
134
|
-
fileName: fileError.fileName,
|
|
135
|
-
errors: fileError.errors
|
|
121
|
+
fileName: fileError === null || fileError === void 0 ? void 0 : fileError.fileName,
|
|
122
|
+
errors: fileError === null || fileError === void 0 ? void 0 : fileError.errors
|
|
136
123
|
};
|
|
137
124
|
});
|
|
138
125
|
return (0, _format.formatData)(fileErrorsToExport, 'json');
|
|
139
126
|
}
|
|
140
127
|
let errorString = '';
|
|
141
128
|
for (const fileError of fileErrors) {
|
|
142
|
-
|
|
143
|
-
errorString +=
|
|
129
|
+
var _fileError$errors;
|
|
130
|
+
errorString += `File Name: ${(fileError === null || fileError === void 0 ? void 0 : fileError.fileName) ?? 'N/A'}`;
|
|
131
|
+
errorString += `\n\nErrors:\n\t- ${(fileError === null || fileError === void 0 || (_fileError$errors = fileError.errors) === null || _fileError$errors === void 0 ? void 0 : _fileError$errors.join(', ')) ?? 'unknown error'}\n\n\n\n`;
|
|
144
132
|
}
|
|
145
133
|
return errorString;
|
|
146
134
|
}
|
|
@@ -177,7 +165,7 @@ async function mediaImportCheckStatus({
|
|
|
177
165
|
const suffix = `
|
|
178
166
|
=============================================================
|
|
179
167
|
Status: ${statusMessage}
|
|
180
|
-
App: ${app.name} (${(0, _format.formatEnvironment)(env.type)})
|
|
168
|
+
App: ${app.name ?? 'N/A'} (${(0, _format.formatEnvironment)(env.type ?? 'N/A')})
|
|
181
169
|
=============================================================
|
|
182
170
|
${maybeExitPrompt}
|
|
183
171
|
`;
|
|
@@ -188,13 +176,15 @@ ${maybeExitPrompt}
|
|
|
188
176
|
progressTracker.print();
|
|
189
177
|
};
|
|
190
178
|
progressTracker.startPrinting(setSuffixAndPrint);
|
|
191
|
-
const getResults = () =>
|
|
179
|
+
const getResults = () =>
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
181
|
+
new Promise((resolve, reject) => {
|
|
192
182
|
let startDate = Date.now();
|
|
193
183
|
let pollIntervalDecreasing = false;
|
|
194
184
|
const checkStatus = async pollInterval => {
|
|
195
|
-
let mediaImportStatus;
|
|
185
|
+
let mediaImportStatus = null;
|
|
196
186
|
try {
|
|
197
|
-
mediaImportStatus = await getStatus(api, app.id, env.id);
|
|
187
|
+
mediaImportStatus = await getStatus(api, app.id ?? -1, env.id ?? -1);
|
|
198
188
|
if (!mediaImportStatus) {
|
|
199
189
|
return reject({
|
|
200
190
|
error: 'Requested app/environment is not available for this operation. If you think this is not correct, please contact Support.'
|
|
@@ -202,12 +192,10 @@ ${maybeExitPrompt}
|
|
|
202
192
|
}
|
|
203
193
|
} catch (error) {
|
|
204
194
|
return reject({
|
|
205
|
-
error
|
|
195
|
+
error: error.message
|
|
206
196
|
});
|
|
207
197
|
}
|
|
208
|
-
const
|
|
209
|
-
status
|
|
210
|
-
} = mediaImportStatus;
|
|
198
|
+
const status = mediaImportStatus.status ?? 'unknown';
|
|
211
199
|
const failedMediaImport = 'FAILED' === status;
|
|
212
200
|
if (failedMediaImport) {
|
|
213
201
|
progressTracker.setStatus(mediaImportStatus);
|
|
@@ -244,23 +232,23 @@ ${maybeExitPrompt}
|
|
|
244
232
|
try {
|
|
245
233
|
var _results$failureDetai;
|
|
246
234
|
const results = await getResults();
|
|
247
|
-
overallStatus =
|
|
235
|
+
overallStatus = results.status ?? 'unknown';
|
|
248
236
|
progressTracker.stopPrinting();
|
|
249
237
|
setProgressTrackerSuffix();
|
|
250
238
|
progressTracker.print();
|
|
251
239
|
const fileErrors = (_results$failureDetai = results.failureDetails) === null || _results$failureDetai === void 0 ? void 0 : _results$failureDetai.fileErrors;
|
|
252
240
|
if (!!fileErrors && fileErrors.length > 0) {
|
|
253
241
|
progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${fileErrors.length} file error(s) have been extracted`)}`;
|
|
254
|
-
if (results.filesTotal - results.filesProcessed !== fileErrors.length) {
|
|
242
|
+
if ((results.filesTotal ?? 0) - (results.filesProcessed ?? 0) !== fileErrors.length) {
|
|
255
243
|
progressTracker.suffix += `. ${_chalk.default.italic.yellow('File-errors report size threshold reached.')}`;
|
|
256
244
|
}
|
|
257
245
|
const formattedData = buildFileErrors(fileErrors, exportFileErrorsToJson);
|
|
258
|
-
const errorsFile = `media-import-${app.name}-${Date.now()}${exportFileErrorsToJson ? '.json' : '.txt'}`;
|
|
246
|
+
const errorsFile = `media-import-${app.name ?? ''}-${Date.now()}${exportFileErrorsToJson ? '.json' : '.txt'}`;
|
|
259
247
|
try {
|
|
260
|
-
await
|
|
261
|
-
progressTracker.suffix += `\n\n${_chalk.default.yellow(`All errors have been exported to ${_chalk.default.bold(
|
|
248
|
+
await (0, _promises.writeFile)(errorsFile, formattedData);
|
|
249
|
+
progressTracker.suffix += `\n\n${_chalk.default.yellow(`All errors have been exported to ${_chalk.default.bold((0, _nodePath.resolve)(errorsFile))}`)}\n\n`;
|
|
262
250
|
} catch (writeFileErr) {
|
|
263
|
-
progressTracker.suffix += `\n\n${_chalk.default.red(`Could not export errors to file\n${writeFileErr}`)}\n\n`;
|
|
251
|
+
progressTracker.suffix += `\n\n${_chalk.default.red(`Could not export errors to file\n${writeFileErr.message}`)}\n\n`;
|
|
264
252
|
}
|
|
265
253
|
}
|
|
266
254
|
|
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SYNC_STATUS_NOT_SYNCING = exports.
|
|
6
|
+
exports.SYNC_STATUS_NOT_SYNCING = exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = exports.SQL_IMPORT_FILE_SIZE_LIMIT = void 0;
|
|
7
7
|
exports.currentUserCanImportForApp = currentUserCanImportForApp;
|
|
8
8
|
exports.isSupportedApp = exports.isImportingBlockedBySync = void 0;
|
|
9
9
|
var _fileSize = require("../../lib/constants/file-size");
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @format
|
|
13
|
-
*/
|
|
14
|
-
|
|
10
|
+
var _vipgo = require("../../lib/constants/vipgo");
|
|
15
11
|
/**
|
|
16
12
|
* Internal dependencies
|
|
17
13
|
*/
|
|
@@ -24,17 +20,14 @@ function currentUserCanImportForApp(app) {
|
|
|
24
20
|
// TODO: implement
|
|
25
21
|
return !!app;
|
|
26
22
|
}
|
|
27
|
-
const SUPPORTED_DB_FILE_IMPORT_SITE_TYPES = ['WordPress'];
|
|
28
|
-
exports.SUPPORTED_DB_FILE_IMPORT_SITE_TYPES = SUPPORTED_DB_FILE_IMPORT_SITE_TYPES;
|
|
29
23
|
const isSupportedApp = ({
|
|
30
|
-
|
|
31
|
-
}) =>
|
|
24
|
+
typeId
|
|
25
|
+
}) => _vipgo.DATABASE_APPLICATION_TYPE_IDS.includes(typeId);
|
|
32
26
|
exports.isSupportedApp = isSupportedApp;
|
|
33
27
|
const SYNC_STATUS_NOT_SYNCING = 'not_syncing';
|
|
34
28
|
exports.SYNC_STATUS_NOT_SYNCING = SYNC_STATUS_NOT_SYNCING;
|
|
35
|
-
const isImportingBlockedBySync =
|
|
36
|
-
syncProgress
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}) => status !== SYNC_STATUS_NOT_SYNCING;
|
|
29
|
+
const isImportingBlockedBySync = env => {
|
|
30
|
+
var _env$syncProgress;
|
|
31
|
+
return ((_env$syncProgress = env.syncProgress) === null || _env$syncProgress === void 0 ? void 0 : _env$syncProgress.status) !== SYNC_STATUS_NOT_SYNCING;
|
|
32
|
+
};
|
|
40
33
|
exports.isImportingBlockedBySync = isImportingBlockedBySync;
|