@automattic/vip 2.25.1 → 2.26.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.
- package/CHANGELOG.md +27 -7
- package/assets/dev-env.lando.template.yml.ejs +18 -4
- package/automattic-vip-2.26.1.tgz +0 -0
- package/dist/bin/vip-config-software-get.js +1 -1
- package/dist/bin/vip-dev-env-create.js +2 -1
- package/dist/bin/vip-dev-env-import-sql.js +8 -67
- package/dist/bin/vip-dev-env-info.js +2 -1
- package/dist/bin/vip-dev-env-start.js +1 -1
- package/dist/bin/vip-dev-env-update.js +3 -3
- package/dist/bin/vip-import-media-abort.js +2 -2
- package/dist/bin/vip-import-sql.js +7 -7
- package/dist/bin/vip-import-validate-files.js +2 -4
- package/dist/bin/vip-logs.js +10 -1
- package/dist/bin/vip-sync.js +1 -1
- package/dist/bin/vip-validate-preflight.js +2 -2
- package/dist/bin/vip-wp.js +4 -4
- package/dist/commands/dev-env-import-sql.js +94 -0
- package/dist/commands/dev-env-sync-sql.js +184 -0
- package/dist/commands/export-sql.js +360 -0
- package/dist/lib/analytics/clients/pendo.js +1 -1
- package/dist/lib/analytics/clients/stub.js +1 -2
- package/dist/lib/analytics/index.js +0 -2
- package/dist/lib/api/app.js +1 -1
- package/dist/lib/api/cache-purge.js +1 -1
- package/dist/lib/api/feature-flags.js +1 -1
- package/dist/lib/api/http.js +7 -7
- package/dist/lib/api/user.js +1 -1
- package/dist/lib/api.js +1 -1
- package/dist/lib/app-logs/app-logs.js +1 -1
- package/dist/lib/app.js +6 -6
- package/dist/lib/cli/apiConfig.js +21 -28
- package/dist/lib/cli/command.js +91 -81
- package/dist/lib/cli/envAlias.js +15 -10
- package/dist/lib/cli/exit.js +1 -1
- package/dist/lib/cli/format.js +22 -7
- package/dist/lib/cli/progress.js +1 -2
- package/dist/lib/cli/prompt.js +1 -3
- package/dist/lib/cli/repo.js +0 -1
- package/dist/lib/client-file-uploader.js +32 -19
- package/dist/lib/config/software.js +0 -2
- package/dist/lib/constants/dev-environment.js +0 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +32 -17
- package/dist/lib/dev-environment/dev-environment-core.js +57 -22
- package/dist/lib/dev-environment/dev-environment-lando.js +124 -40
- package/dist/lib/envvar/api-delete.js +1 -1
- package/dist/lib/envvar/api-get-all.js +1 -1
- package/dist/lib/envvar/api-get.js +1 -1
- package/dist/lib/envvar/api-list.js +1 -1
- package/dist/lib/envvar/api-set.js +1 -1
- package/dist/lib/envvar/api.js +1 -1
- package/dist/lib/envvar/logging.js +1 -1
- package/dist/lib/envvar/read-file.js +1 -1
- package/dist/lib/http/proxy-agent.js +5 -6
- package/dist/lib/keychain/secure.js +0 -6
- package/dist/lib/keychain.js +6 -1
- package/dist/lib/logout.js +3 -3
- package/dist/lib/media-import/media-file-import.js +1 -1
- package/dist/lib/media-import/progress.js +2 -2
- package/dist/lib/media-import/status.js +6 -5
- package/dist/lib/read-file.js +1 -1
- package/dist/lib/rollbar.js +1 -1
- package/dist/lib/search-and-replace.js +13 -16
- package/dist/lib/site-import/db-file-import.js +1 -1
- package/dist/lib/site-import/status.js +6 -5
- package/dist/lib/tracker.js +2 -2
- package/dist/lib/utils.js +69 -0
- package/dist/lib/validations/is-multi-site-sql-dump.js +3 -40
- package/dist/lib/validations/is-multi-site.js +4 -5
- package/dist/lib/validations/is-multisite-domain-mapped.js +15 -18
- package/dist/lib/validations/line-by-line.js +4 -14
- package/dist/lib/validations/site-type.js +5 -5
- package/dist/lib/validations/sql.js +16 -16
- package/dist/lib/validations/utils.js +2 -2
- package/dist/lib/vip-import-validate-files.js +44 -44
- package/npm-shrinkwrap.json +20971 -4078
- package/package.json +10 -16
package/dist/lib/app.js
CHANGED
|
@@ -9,15 +9,14 @@ var _vipgo = require("./constants/vipgo");
|
|
|
9
9
|
/**
|
|
10
10
|
* External dependencies
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* Is this a WordPress application?
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
17
|
+
*
|
|
18
|
+
* @param {number} appTypeId application type ID
|
|
19
|
+
* @return {boolean} Whether this a WordPress application
|
|
21
20
|
*/
|
|
22
21
|
function isAppWordPress(appTypeId) {
|
|
23
22
|
return _vipgo.WORDPRESS_SITE_TYPE_IDS.includes(appTypeId);
|
|
@@ -25,8 +24,9 @@ function isAppWordPress(appTypeId) {
|
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Is this a Nodejs application?
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
27
|
+
*
|
|
28
|
+
* @param {number} appTypeId application type ID
|
|
29
|
+
* @return {boolean} Whether this a Node.js application
|
|
30
30
|
*/
|
|
31
31
|
function isAppNodejs(appTypeId) {
|
|
32
32
|
return _vipgo.NODEJS_SITE_TYPE_IDS.includes(appTypeId);
|
|
@@ -6,26 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.checkFeatureEnabled = checkFeatureEnabled;
|
|
7
7
|
exports.checkIfUserIsVip = checkIfUserIsVip;
|
|
8
8
|
exports.exitWhenFeatureDisabled = exitWhenFeatureDisabled;
|
|
9
|
-
var _tracker = require("
|
|
9
|
+
var _tracker = require("../../lib/tracker");
|
|
10
10
|
var exit = _interopRequireWildcard(require("./exit"));
|
|
11
|
-
var featureFlags = _interopRequireWildcard(require("
|
|
12
|
-
var _token = _interopRequireDefault(require("
|
|
11
|
+
var featureFlags = _interopRequireWildcard(require("../../lib/api/feature-flags"));
|
|
12
|
+
var _token = _interopRequireDefault(require("../../lib/token"));
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
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); }
|
|
15
15
|
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; }
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
* @format
|
|
19
|
-
*/
|
|
20
|
-
|
|
16
|
+
// @format
|
|
21
17
|
/**
|
|
22
18
|
* External dependencies
|
|
23
19
|
*/
|
|
24
|
-
|
|
25
20
|
/**
|
|
26
21
|
* Internal dependencies
|
|
27
22
|
*/
|
|
28
|
-
|
|
29
23
|
async function checkFeatureEnabled(featureName, exitOnFalse = false) {
|
|
30
24
|
// TODO: eventually let's look at more feature flags coming from the public api,
|
|
31
25
|
// for now, let's see if the user of the CLI is VIP
|
|
@@ -33,25 +27,24 @@ async function checkFeatureEnabled(featureName, exitOnFalse = false) {
|
|
|
33
27
|
featureName,
|
|
34
28
|
exitOnFalse
|
|
35
29
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
} catch (err) {
|
|
46
|
-
const message = err.toString();
|
|
47
|
-
await (0, _tracker.trackEvent)('checkFeatureEnabled_fetch_error', {
|
|
48
|
-
featureName,
|
|
49
|
-
exitOnFalse,
|
|
50
|
-
error: message
|
|
51
|
-
});
|
|
52
|
-
exit.withError('Failed to determine if feature is enabled' + message);
|
|
30
|
+
let isVIP;
|
|
31
|
+
try {
|
|
32
|
+
var _res$data, _res$data$me;
|
|
33
|
+
const res = await featureFlags.get();
|
|
34
|
+
if ((res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$me = _res$data.me) === null || _res$data$me === void 0 ? void 0 : _res$data$me.isVIP) !== undefined) {
|
|
35
|
+
isVIP = res.data.me.isVIP;
|
|
36
|
+
} else {
|
|
37
|
+
isVIP = false;
|
|
53
38
|
}
|
|
54
|
-
})
|
|
39
|
+
} catch (err) {
|
|
40
|
+
const message = err.toString();
|
|
41
|
+
await (0, _tracker.trackEvent)('checkFeatureEnabled_fetch_error', {
|
|
42
|
+
featureName,
|
|
43
|
+
exitOnFalse,
|
|
44
|
+
error: message
|
|
45
|
+
});
|
|
46
|
+
exit.withError('Failed to determine if feature is enabled' + message);
|
|
47
|
+
}
|
|
55
48
|
if (exitOnFalse === true && isVIP === false) {
|
|
56
49
|
exit.withError('The feature you are attempting to use is not currently enabled.');
|
|
57
50
|
}
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -12,11 +12,11 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
12
12
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
13
13
|
var _updateNotifier = _interopRequireDefault(require("update-notifier"));
|
|
14
14
|
var _prompt = require("./prompt");
|
|
15
|
-
var _api = _interopRequireDefault(require("
|
|
16
|
-
var _app = _interopRequireDefault(require("
|
|
15
|
+
var _api = _interopRequireDefault(require("../../lib/api"));
|
|
16
|
+
var _app = _interopRequireDefault(require("../../lib/api/app"));
|
|
17
17
|
var _format = require("./format");
|
|
18
18
|
var _package = _interopRequireDefault(require("../../../package.json"));
|
|
19
|
-
var _tracker = require("
|
|
19
|
+
var _tracker = require("../../lib/tracker");
|
|
20
20
|
var _envAlias = require("./envAlias");
|
|
21
21
|
var _rollbar = require("../rollbar");
|
|
22
22
|
var exit = _interopRequireWildcard(require("./exit"));
|
|
@@ -28,7 +28,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
28
28
|
/**
|
|
29
29
|
* External dependencies
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Internal dependencies
|
|
33
|
+
*/
|
|
32
34
|
function uncaughtError(err) {
|
|
33
35
|
// Error raised when trying to write to an already closed stream
|
|
34
36
|
if (err.code === 'EPIPE') {
|
|
@@ -45,6 +47,8 @@ process.on('uncaughtException', uncaughtError);
|
|
|
45
47
|
process.on('unhandledRejection', uncaughtError);
|
|
46
48
|
let _opts = {};
|
|
47
49
|
let alreadyConfirmedDebugAttachment = false;
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line complexity
|
|
48
52
|
_args.default.argv = async function (argv, cb) {
|
|
49
53
|
if (process.execArgv.includes('--inspect') && !alreadyConfirmedDebugAttachment) {
|
|
50
54
|
await (0, _enquirer.prompt)({
|
|
@@ -321,106 +325,112 @@ _args.default.argv = async function (argv, cb) {
|
|
|
321
325
|
}
|
|
322
326
|
switch (_opts.module) {
|
|
323
327
|
case 'import-sql':
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
328
|
+
{
|
|
329
|
+
const site = options.env;
|
|
330
|
+
if (site && site.primaryDomain) {
|
|
331
|
+
const primaryDomainName = site.primaryDomain.name;
|
|
332
|
+
info.push({
|
|
333
|
+
key: 'Primary Domain Name',
|
|
334
|
+
value: primaryDomainName
|
|
335
|
+
});
|
|
336
|
+
}
|
|
332
337
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
338
|
+
// Site launched details
|
|
339
|
+
const haveLaunchedField = Object.prototype.hasOwnProperty.call(site, 'launched');
|
|
340
|
+
if (haveLaunchedField) {
|
|
341
|
+
const launched = site.launched ? '✅ Yes' : `${_chalk.default.red('x')} No`;
|
|
342
|
+
info.push({
|
|
343
|
+
key: 'Launched?',
|
|
344
|
+
value: `${_chalk.default.cyan(launched)}`
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
if (this.sub) {
|
|
348
|
+
info.push({
|
|
349
|
+
key: 'SQL File',
|
|
350
|
+
value: `${_chalk.default.blueBright(this.sub)}`
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
options.skipValidate = Object.prototype.hasOwnProperty.call(options, 'skipValidate') && !!options.skipValidate && !['false', 'no'].includes(options.skipValidate);
|
|
354
|
+
if (options.skipValidate) {
|
|
355
|
+
info.push({
|
|
356
|
+
key: 'Pre-Upload Validations',
|
|
357
|
+
value: _chalk.default.red('SKIPPED!')
|
|
358
|
+
});
|
|
359
|
+
}
|
|
353
360
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
361
|
+
// Show S-R params if the `search-replace` flag is set
|
|
362
|
+
const searchReplace = options.searchReplace;
|
|
363
|
+
const assignSRValues = (from, to) => {
|
|
364
|
+
const pairs = {
|
|
365
|
+
From: `${from}`,
|
|
366
|
+
To: `${to}`
|
|
367
|
+
};
|
|
368
|
+
return pairs;
|
|
360
369
|
};
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (searchReplace) {
|
|
364
|
-
const searchReplaceValues = (0, _format.formatSearchReplaceValues)(searchReplace, assignSRValues);
|
|
370
|
+
if (searchReplace) {
|
|
371
|
+
const searchReplaceValues = (0, _format.formatSearchReplaceValues)(searchReplace, assignSRValues);
|
|
365
372
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
373
|
+
// Format data into a user-friendly table
|
|
374
|
+
info.push({
|
|
375
|
+
key: 'Replacements',
|
|
376
|
+
value: '\n' + (0, _format.formatData)(searchReplaceValues, 'table')
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
break;
|
|
371
380
|
}
|
|
372
|
-
break;
|
|
373
381
|
case 'sync':
|
|
374
|
-
|
|
375
|
-
backup,
|
|
376
|
-
canSync,
|
|
377
|
-
errors
|
|
378
|
-
} = options.env.syncPreview;
|
|
379
|
-
if (!canSync) {
|
|
380
|
-
// User can not sync due to some error(s)
|
|
381
|
-
// Shows the first error in the array
|
|
382
|
-
exit.withError(`Could not sync to this environment: ${errors[0].message}`);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// remove __typename from replacements.
|
|
386
|
-
// can not be deleted afterwards if deconstructed
|
|
387
|
-
const replacements = options.env.syncPreview.replacements.map(rep => {
|
|
382
|
+
{
|
|
388
383
|
const {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
to
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
384
|
+
backup,
|
|
385
|
+
canSync,
|
|
386
|
+
errors
|
|
387
|
+
} = options.env.syncPreview;
|
|
388
|
+
if (!canSync) {
|
|
389
|
+
// User can not sync due to some error(s)
|
|
390
|
+
// Shows the first error in the array
|
|
391
|
+
exit.withError(`Could not sync to this environment: ${errors[0].message}`);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// remove __typename from replacements.
|
|
395
|
+
// can not be deleted afterwards if deconstructed
|
|
396
|
+
const replacements = options.env.syncPreview.replacements.map(rep => {
|
|
397
|
+
const {
|
|
398
|
+
from,
|
|
399
|
+
to
|
|
400
|
+
} = rep;
|
|
401
|
+
return {
|
|
402
|
+
from,
|
|
403
|
+
to
|
|
404
|
+
};
|
|
405
|
+
});
|
|
406
|
+
if (backup) {
|
|
407
|
+
info.push({
|
|
408
|
+
key: 'From backup',
|
|
409
|
+
value: new Date(backup.createdAt).toUTCString()
|
|
410
|
+
});
|
|
411
|
+
}
|
|
398
412
|
info.push({
|
|
399
|
-
key: '
|
|
400
|
-
value:
|
|
413
|
+
key: 'Replacements',
|
|
414
|
+
value: '\n' + (0, _format.formatData)(replacements, 'table')
|
|
401
415
|
});
|
|
416
|
+
break;
|
|
402
417
|
}
|
|
403
|
-
info.push({
|
|
404
|
-
key: 'Replacements',
|
|
405
|
-
value: '\n' + (0, _format.formatData)(replacements, 'table')
|
|
406
|
-
});
|
|
407
|
-
break;
|
|
408
418
|
case 'import-media':
|
|
409
419
|
info.push({
|
|
410
420
|
key: 'Archive URL',
|
|
411
421
|
value: _chalk.default.blue.underline(this.sub)
|
|
412
422
|
});
|
|
413
|
-
options.overwriteExistingFiles =
|
|
423
|
+
options.overwriteExistingFiles = Object.prototype.hasOwnProperty.call(options, 'overwriteExistingFiles') && !!options.overwriteExistingFiles && !['false', 'no'].includes(options.overwriteExistingFiles);
|
|
414
424
|
info.push({
|
|
415
425
|
key: 'Overwrite any existing files',
|
|
416
426
|
value: options.overwriteExistingFiles ? '✅ Yes' : `${_chalk.default.red('x')} No`
|
|
417
427
|
});
|
|
418
|
-
options.importIntermediateImages =
|
|
428
|
+
options.importIntermediateImages = Object.prototype.hasOwnProperty.call(options, 'importIntermediateImages') && !!options.importIntermediateImages && !['false', 'no'].includes(options.importIntermediateImages);
|
|
419
429
|
info.push({
|
|
420
430
|
key: 'Import intermediate image files',
|
|
421
431
|
value: options.importIntermediateImages ? '✅ Yes' : `${_chalk.default.red('x')} No`
|
|
422
432
|
});
|
|
423
|
-
options.exportFileErrorsToJson =
|
|
433
|
+
options.exportFileErrorsToJson = Object.prototype.hasOwnProperty.call(options, 'exportFileErrorsToJson') && !!options.exportFileErrorsToJson && !['false', 'no'].includes(options.exportFileErrorsToJson);
|
|
424
434
|
info.push({
|
|
425
435
|
key: 'Export any file errors encountered to a JSON file instead of a plain text file',
|
|
426
436
|
value: options.exportFileErrorsToJson ? '✅ Yes' : `${_chalk.default.red('x')} No`
|
package/dist/lib/cli/envAlias.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
return /^@[A-Za-z0-9
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!
|
|
6
|
+
function isAlias(alias) {
|
|
7
|
+
return /^@[A-Za-z0-9.-]+$/.test(alias);
|
|
8
|
+
}
|
|
9
|
+
function parseEnvAlias(alias) {
|
|
10
|
+
if (!isAlias(alias)) {
|
|
11
11
|
throw new Error('Invalid environment alias. Aliases are in the format of @app-name or @app-name.environment-name');
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ exports.parseEnvAlias = function (alias) {
|
|
|
17
17
|
// in JS, .split() with a limit discards the extra ones, so can't use it
|
|
18
18
|
// Also convert to lowercase because mixed case environment names would cause problems
|
|
19
19
|
const [app, ...rest] = stripped.split('.');
|
|
20
|
-
let env
|
|
20
|
+
let env;
|
|
21
21
|
|
|
22
22
|
// Rejoin the env on '.' (if present), to handle instance names (env.instance-01)
|
|
23
23
|
if (rest && rest.length) {
|
|
@@ -27,8 +27,8 @@ exports.parseEnvAlias = function (alias) {
|
|
|
27
27
|
app,
|
|
28
28
|
env
|
|
29
29
|
};
|
|
30
|
-
}
|
|
31
|
-
|
|
30
|
+
}
|
|
31
|
+
function parseEnvAliasFromArgv(processArgv) {
|
|
32
32
|
// Clone to not affect original arvg
|
|
33
33
|
const argv = processArgv.slice(0);
|
|
34
34
|
|
|
@@ -39,7 +39,7 @@ exports.parseEnvAliasFromArgv = function (processArgv) {
|
|
|
39
39
|
if (dashDashIndex > -1) {
|
|
40
40
|
argsBeforeDashDash = argv.slice(0, dashDashIndex);
|
|
41
41
|
}
|
|
42
|
-
const alias = argsBeforeDashDash.find(arg =>
|
|
42
|
+
const alias = argsBeforeDashDash.find(arg => isAlias(arg));
|
|
43
43
|
if (!alias) {
|
|
44
44
|
return {
|
|
45
45
|
argv
|
|
@@ -47,7 +47,7 @@ exports.parseEnvAliasFromArgv = function (processArgv) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// If we did have an alias, split it up into app/env
|
|
50
|
-
const parsedAlias = exports.parseEnvAlias(alias);
|
|
50
|
+
const parsedAlias = module.exports.parseEnvAlias(alias);
|
|
51
51
|
|
|
52
52
|
// Splice out the alias
|
|
53
53
|
argv.splice(argv.indexOf(alias), 1);
|
|
@@ -55,4 +55,9 @@ exports.parseEnvAliasFromArgv = function (processArgv) {
|
|
|
55
55
|
argv,
|
|
56
56
|
...parsedAlias
|
|
57
57
|
};
|
|
58
|
+
}
|
|
59
|
+
module.exports = {
|
|
60
|
+
isAlias,
|
|
61
|
+
parseEnvAlias,
|
|
62
|
+
parseEnvAliasFromArgv
|
|
58
63
|
};
|
package/dist/lib/cli/exit.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.withError = withError;
|
|
7
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
var _env = _interopRequireDefault(require("
|
|
8
|
+
var _env = _interopRequireDefault(require("../../lib/env"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
/**
|
|
11
11
|
*
|
package/dist/lib/cli/format.js
CHANGED
|
@@ -9,6 +9,8 @@ exports.formatData = formatData;
|
|
|
9
9
|
exports.formatEnvironment = formatEnvironment;
|
|
10
10
|
exports.formatSearchReplaceValues = void 0;
|
|
11
11
|
exports.getGlyphForStatus = getGlyphForStatus;
|
|
12
|
+
exports.isJson = isJson;
|
|
13
|
+
exports.isJsonObject = isJsonObject;
|
|
12
14
|
exports.keyValue = keyValue;
|
|
13
15
|
exports.requoteArgs = requoteArgs;
|
|
14
16
|
exports.table = table;
|
|
@@ -18,22 +20,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
20
|
/**
|
|
19
21
|
* External dependencies
|
|
20
22
|
*/
|
|
21
|
-
function formatData(data, format
|
|
23
|
+
function formatData(data, format) {
|
|
22
24
|
if (!data || !data.length) {
|
|
23
25
|
return '';
|
|
24
26
|
}
|
|
25
27
|
switch (format) {
|
|
26
28
|
case 'ids':
|
|
27
|
-
return ids(data
|
|
29
|
+
return ids(data);
|
|
28
30
|
case 'json':
|
|
29
31
|
return JSON.stringify(data, null, '\t');
|
|
30
32
|
case 'csv':
|
|
31
|
-
return csv(data
|
|
33
|
+
return csv(data);
|
|
32
34
|
case 'keyValue':
|
|
33
|
-
return keyValue(data
|
|
35
|
+
return keyValue(data);
|
|
34
36
|
case 'table':
|
|
35
37
|
default:
|
|
36
|
-
return table(data
|
|
38
|
+
return table(data);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
function formatEnvironment(environment) {
|
|
@@ -85,7 +87,9 @@ function formatFields(fields) {
|
|
|
85
87
|
function keyValue(values) {
|
|
86
88
|
const lines = [];
|
|
87
89
|
const pairs = values.length > 0;
|
|
88
|
-
|
|
90
|
+
if (pairs) {
|
|
91
|
+
lines.push('===================================');
|
|
92
|
+
}
|
|
89
93
|
for (const {
|
|
90
94
|
key,
|
|
91
95
|
value
|
|
@@ -106,12 +110,23 @@ function requoteArgs(args) {
|
|
|
106
110
|
if (arg.includes('--') && arg.includes('=') && arg.includes(' ')) {
|
|
107
111
|
return arg.replace(/^--(.*)=(.*)$/, '--$1="$2"');
|
|
108
112
|
}
|
|
109
|
-
if (arg.includes(' ')) {
|
|
113
|
+
if (arg.includes(' ') && !isJsonObject(arg)) {
|
|
110
114
|
return `"${arg}"`;
|
|
111
115
|
}
|
|
112
116
|
return arg;
|
|
113
117
|
});
|
|
114
118
|
}
|
|
119
|
+
function isJsonObject(str) {
|
|
120
|
+
return typeof str === 'string' && str.trim().startsWith('{') && isJson(str);
|
|
121
|
+
}
|
|
122
|
+
function isJson(str) {
|
|
123
|
+
try {
|
|
124
|
+
JSON.parse(str);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
115
130
|
function capitalize(str) {
|
|
116
131
|
if (typeof str !== 'string' || !str.length) {
|
|
117
132
|
return '';
|
package/dist/lib/cli/progress.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ProgressTracker = void 0;
|
|
7
7
|
var _singleLineLog = require("single-line-log");
|
|
8
|
-
var _format = require("
|
|
8
|
+
var _format = require("../../lib/cli/format");
|
|
9
9
|
/** @format */
|
|
10
10
|
/**
|
|
11
11
|
* External dependencies
|
|
@@ -105,7 +105,6 @@ class ProgressTracker {
|
|
|
105
105
|
const nextStep = this.getNextStep();
|
|
106
106
|
if (nextStep) {
|
|
107
107
|
this.stepRunning(nextStep.id);
|
|
108
|
-
return;
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
allStepsSucceeded() {
|
package/dist/lib/cli/prompt.js
CHANGED
|
@@ -12,15 +12,13 @@ var _format = require("./format");
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
/* eslint-disable no-duplicate-imports */
|
|
16
|
-
/* eslint-enable no-duplicate-imports */
|
|
17
15
|
async function confirm(values, message, skipPrompt = false) {
|
|
18
16
|
console.log((0, _format.keyValue)(values));
|
|
19
17
|
if (!skipPrompt) {
|
|
20
18
|
const answer = await (0, _enquirer.prompt)({
|
|
21
19
|
type: 'confirm',
|
|
22
20
|
name: 'confirm',
|
|
23
|
-
message
|
|
21
|
+
message,
|
|
24
22
|
default: false
|
|
25
23
|
});
|
|
26
24
|
return answer.confirm;
|
package/dist/lib/cli/repo.js
CHANGED
|
@@ -15,6 +15,7 @@ exports.getPartBoundaries = getPartBoundaries;
|
|
|
15
15
|
exports.getSignedUploadRequestData = getSignedUploadRequestData;
|
|
16
16
|
exports.gzipFile = exports.getWorkingTempDir = void 0;
|
|
17
17
|
exports.isFile = isFile;
|
|
18
|
+
exports.unzipFile = void 0;
|
|
18
19
|
exports.uploadImportSqlFileToS3 = uploadImportSqlFileToS3;
|
|
19
20
|
exports.uploadPart = uploadPart;
|
|
20
21
|
exports.uploadParts = uploadParts;
|
|
@@ -27,11 +28,11 @@ var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
|
27
28
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
28
29
|
var _zlib = require("zlib");
|
|
29
30
|
var _crypto = require("crypto");
|
|
30
|
-
var
|
|
31
|
+
var _promises = require("node:stream/promises");
|
|
31
32
|
var _xml2js = require("xml2js");
|
|
32
33
|
var _debug = _interopRequireDefault(require("debug"));
|
|
33
|
-
var _http = _interopRequireDefault(require("
|
|
34
|
-
var _fileSize = require("
|
|
34
|
+
var _http = _interopRequireDefault(require("../lib/api/http"));
|
|
35
|
+
var _fileSize = require("../lib/constants/file-size");
|
|
35
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
37
|
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); }
|
|
37
38
|
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; }
|
|
@@ -77,24 +78,36 @@ const getFileMD5Hash = async fileName => new Promise((resolve, reject) => _fs.de
|
|
|
77
78
|
}).on('error', error => reject(`could not generate file hash: ${error}`)));
|
|
78
79
|
exports.getFileMD5Hash = getFileMD5Hash;
|
|
79
80
|
const gzipFile = async (uncompressedFileName, compressedFileName) => new Promise((resolve, reject) => _fs.default.createReadStream(uncompressedFileName).pipe((0, _zlib.createGzip)()).pipe(_fs.default.createWriteStream(compressedFileName)).on('finish', resolve).on('error', error => reject(`could not compress file: ${error}`)));
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Extract a .gz file and save it to a specified location
|
|
84
|
+
*
|
|
85
|
+
* @param {string} inputFilename The file to unzip
|
|
86
|
+
* @param {string} outputFilename The file where the unzipped data will be written
|
|
87
|
+
* @return {Promise} A promise that resolves when the file is unzipped
|
|
88
|
+
*/
|
|
80
89
|
exports.gzipFile = gzipFile;
|
|
90
|
+
const unzipFile = async (inputFilename, outputFilename) => {
|
|
91
|
+
const source = _fs.default.createReadStream(inputFilename);
|
|
92
|
+
const destination = _fs.default.createWriteStream(outputFilename);
|
|
93
|
+
await (0, _promises.pipeline)(source, (0, _zlib.createGunzip)(), destination);
|
|
94
|
+
};
|
|
95
|
+
exports.unzipFile = unzipFile;
|
|
81
96
|
async function getFileMeta(fileName) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// TODO Validate File basename... encodeURIComponent, maybe...?
|
|
97
|
+
const fileSize = await getFileSize(fileName);
|
|
98
|
+
const basename = _path.default.basename(fileName);
|
|
99
|
+
// TODO Validate File basename... encodeURIComponent, maybe...?
|
|
86
100
|
|
|
87
|
-
|
|
88
|
-
|
|
101
|
+
const mimeType = await detectCompressedMimeType(fileName);
|
|
102
|
+
// TODO Only allow a subset of Mime Types...?
|
|
89
103
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
104
|
+
const isCompressed = ['application/zip', 'application/gzip'].includes(mimeType);
|
|
105
|
+
return {
|
|
106
|
+
basename,
|
|
107
|
+
fileName,
|
|
108
|
+
fileSize,
|
|
109
|
+
isCompressed
|
|
110
|
+
};
|
|
98
111
|
}
|
|
99
112
|
async function uploadImportSqlFileToS3({
|
|
100
113
|
app,
|
|
@@ -173,7 +186,7 @@ async function uploadUsingPutObject({
|
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
let readBytes = 0;
|
|
176
|
-
const progressPassThrough = new
|
|
189
|
+
const progressPassThrough = new _promises.PassThrough();
|
|
177
190
|
progressPassThrough.on('data', data => {
|
|
178
191
|
readBytes += data.length;
|
|
179
192
|
const percentage = Math.floor(100 * readBytes / fileSize) + '%';
|
|
@@ -396,7 +409,7 @@ async function uploadParts({
|
|
|
396
409
|
index,
|
|
397
410
|
partSize
|
|
398
411
|
} = part;
|
|
399
|
-
const progressPassThrough = new
|
|
412
|
+
const progressPassThrough = new _promises.PassThrough();
|
|
400
413
|
let partBytesRead = 0;
|
|
401
414
|
progressPassThrough.on('data', data => {
|
|
402
415
|
totalBytesRead += data.length;
|
|
@@ -14,11 +14,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
/**
|
|
15
15
|
* External dependencies
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
18
|
* Internal dependencies
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
20
|
const UPDATE_PROGRESS_POLL_INTERVAL = 5;
|
|
23
21
|
const debug = (0, _debug.default)('@automattic/vip:bin:config-software');
|
|
24
22
|
const appQuery = `
|
|
@@ -11,7 +11,6 @@ exports.DEV_ENVIRONMENT_FULL_COMMAND = DEV_ENVIRONMENT_FULL_COMMAND;
|
|
|
11
11
|
const DEV_ENVIRONMENT_DEFAULTS = {
|
|
12
12
|
title: 'VIP Dev',
|
|
13
13
|
multisite: false,
|
|
14
|
-
mariadbVersion: '10.3',
|
|
15
14
|
phpVersion: '8.0'
|
|
16
15
|
};
|
|
17
16
|
exports.DEV_ENVIRONMENT_DEFAULTS = DEV_ENVIRONMENT_DEFAULTS;
|