@automattic/vip 2.25.0 → 2.26.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 +34 -6
- package/assets/dev-env.lando.template.yml.ejs +7 -3
- package/automattic-vip-2.26.0.tgz +0 -0
- package/dist/bin/vip-config-software-get.js +1 -1
- package/dist/bin/vip-dev-env-import-sql.js +1 -1
- package/dist/bin/vip-dev-env-start.js +1 -1
- package/dist/bin/vip-import-media-abort.js +2 -2
- package/dist/bin/vip-import-sql.js +4 -4
- 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/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 +14 -16
- package/dist/lib/config/software.js +0 -2
- package/dist/lib/dev-environment/dev-environment-cli.js +11 -5
- package/dist/lib/dev-environment/dev-environment-core.js +44 -19
- package/dist/lib/dev-environment/dev-environment-lando.js +76 -33
- 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 +11 -9
- package/dist/lib/site-import/db-file-import.js +1 -1
- package/dist/lib/site-import/status.js +6 -5
- package/dist/lib/sql-export.js +360 -0
- package/dist/lib/tracker.js +2 -2
- package/dist/lib/utils.js +28 -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 +21091 -4237
- package/package.json +9 -15
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
|
@@ -30,8 +30,8 @@ var _crypto = require("crypto");
|
|
|
30
30
|
var _stream = require("stream");
|
|
31
31
|
var _xml2js = require("xml2js");
|
|
32
32
|
var _debug = _interopRequireDefault(require("debug"));
|
|
33
|
-
var _http = _interopRequireDefault(require("
|
|
34
|
-
var _fileSize = require("
|
|
33
|
+
var _http = _interopRequireDefault(require("../lib/api/http"));
|
|
34
|
+
var _fileSize = require("../lib/constants/file-size");
|
|
35
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
36
|
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
37
|
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; }
|
|
@@ -79,22 +79,20 @@ exports.getFileMD5Hash = getFileMD5Hash;
|
|
|
79
79
|
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}`)));
|
|
80
80
|
exports.gzipFile = gzipFile;
|
|
81
81
|
async function getFileMeta(fileName) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// TODO Validate File basename... encodeURIComponent, maybe...?
|
|
82
|
+
const fileSize = await getFileSize(fileName);
|
|
83
|
+
const basename = _path.default.basename(fileName);
|
|
84
|
+
// TODO Validate File basename... encodeURIComponent, maybe...?
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
const mimeType = await detectCompressedMimeType(fileName);
|
|
87
|
+
// TODO Only allow a subset of Mime Types...?
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
89
|
+
const isCompressed = ['application/zip', 'application/gzip'].includes(mimeType);
|
|
90
|
+
return {
|
|
91
|
+
basename,
|
|
92
|
+
fileName,
|
|
93
|
+
fileSize,
|
|
94
|
+
isCompressed
|
|
95
|
+
};
|
|
98
96
|
}
|
|
99
97
|
async function uploadImportSqlFileToS3({
|
|
100
98
|
app,
|
|
@@ -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 = `
|
|
@@ -30,7 +30,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
30
30
|
var _path = _interopRequireDefault(require("path"));
|
|
31
31
|
var _os = _interopRequireDefault(require("os"));
|
|
32
32
|
var _dns = _interopRequireDefault(require("dns"));
|
|
33
|
-
var _progress = require("
|
|
33
|
+
var _progress = require("../../lib/cli/progress");
|
|
34
34
|
var _tracker = require("../tracker");
|
|
35
35
|
var _devEnvironment = require("../constants/dev-environment");
|
|
36
36
|
var _devEnvironmentCore = require("./dev-environment-core");
|
|
@@ -222,7 +222,7 @@ function processComponentOptionInput(passedParam, allowLocal) {
|
|
|
222
222
|
// cast to string
|
|
223
223
|
const param = passedParam + '';
|
|
224
224
|
// This is a bit of a naive check
|
|
225
|
-
if (allowLocal && /[
|
|
225
|
+
if (allowLocal && /[\\/]/.test(param)) {
|
|
226
226
|
return {
|
|
227
227
|
mode: 'local',
|
|
228
228
|
dir: param
|
|
@@ -246,11 +246,13 @@ function getOptionsFromAppInfo(appInfo) {
|
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
248
|
* Prompt for arguments
|
|
249
|
+
*
|
|
249
250
|
* @param {InstanceOptions} preselectedOptions - options to be used without prompt
|
|
250
|
-
* @param {InstanceOptions} defaultOptions
|
|
251
|
-
* @param {boolean}
|
|
252
|
-
* @
|
|
251
|
+
* @param {InstanceOptions} defaultOptions - options to be used as default values for prompt
|
|
252
|
+
* @param {boolean} suppressPrompts - supress prompts and use default values where needed
|
|
253
|
+
* @return {any} instance data
|
|
253
254
|
*/
|
|
255
|
+
// eslint-disable-next-line complexity
|
|
254
256
|
async function promptForArguments(preselectedOptions, defaultOptions, suppressPrompts = false) {
|
|
255
257
|
debug('Provided preselected', preselectedOptions, 'and default', defaultOptions);
|
|
256
258
|
if (suppressPrompts) {
|
|
@@ -307,6 +309,8 @@ async function promptForArguments(preselectedOptions, defaultOptions, suppressPr
|
|
|
307
309
|
var _preselectedOptions$c, _defaultOptions$compo;
|
|
308
310
|
const option = ((_preselectedOptions$c = preselectedOptions[component]) !== null && _preselectedOptions$c !== void 0 ? _preselectedOptions$c : '').toString();
|
|
309
311
|
const defaultValue = ((_defaultOptions$compo = defaultOptions[component]) !== null && _defaultOptions$compo !== void 0 ? _defaultOptions$compo : '').toString();
|
|
312
|
+
|
|
313
|
+
// eslint-disable-next-line no-await-in-loop
|
|
310
314
|
const result = await processComponent(component, option, defaultValue);
|
|
311
315
|
if (null === result) {
|
|
312
316
|
throw new Error('processComponent() returned null');
|
|
@@ -324,6 +328,7 @@ async function promptForArguments(preselectedOptions, defaultOptions, suppressPr
|
|
|
324
328
|
if (service in preselectedOptions) {
|
|
325
329
|
instanceData[service] = preselectedOptions[service];
|
|
326
330
|
} else {
|
|
331
|
+
// eslint-disable-next-line no-await-in-loop
|
|
327
332
|
instanceData[service] = await promptForBoolean(`Enable ${promptLabels[service] || service}`, defaultOptions[service]);
|
|
328
333
|
}
|
|
329
334
|
}
|
|
@@ -355,6 +360,7 @@ async function processComponent(component, preselectedValue, defaultValue) {
|
|
|
355
360
|
break;
|
|
356
361
|
} else if (isStdinTTY) {
|
|
357
362
|
console.log(_chalk.default.yellow('Warning:'), message);
|
|
363
|
+
// eslint-disable-next-line no-await-in-loop
|
|
358
364
|
result = await promptForComponent(component, allowLocal, defaultObject);
|
|
359
365
|
} else {
|
|
360
366
|
throw new Error(message);
|