@automattic/vip 2.30.0-dev1 → 2.30.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 +10 -0
- package/assets/dev-env.lando.template.yml.ejs +7 -2
- package/dist/bin/vip-dev-env-create.js +4 -1
- package/dist/bin/vip-import-validate-sql.js +2 -2
- package/dist/bin/vip-wp.js +7 -5
- package/dist/bin/vip.js +9 -6
- package/dist/lib/api/feature-flags.js +2 -1
- package/dist/lib/api.js +2 -2
- package/dist/lib/app.js +2 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +47 -3
- package/dist/lib/dev-environment/dev-environment-lando.js +2 -2
- package/dist/lib/keychain/insecure.js +25 -26
- package/dist/lib/keychain/secure.js +5 -2
- package/dist/lib/keychain.js +11 -18
- package/dist/lib/media-import/status.js +2 -2
- package/dist/lib/site-import/status.js +4 -3
- package/dist/lib/token.js +17 -6
- package/dist/lib/tracker.js +3 -4
- package/dist/lib/validations/sql.js +3 -3
- package/noImplictAnyImportBypass.d.ts +6 -0
- package/npm-shrinkwrap.json +914 -137
- package/package.json +27 -5
- package/tsconfig.json +35 -0
- package/dist/lib/keychain/browser.js +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 2.30.0
|
|
4
|
+
|
|
5
|
+
- #1264 feature(dev-env): Add dev-env-sync-sql command
|
|
6
|
+
- #1376 refactor: Convert keychain to TypeScript
|
|
7
|
+
- #1370 fix: Fix issues found by SonarCloud
|
|
8
|
+
- #1374 Add TypeScript support
|
|
9
|
+
- #1334 Dev-env: Allow --multisite to accept boolean, subdirectory, or subdomain values
|
|
10
|
+
- #1375 fix(api): Set non-zero exit code on error
|
|
11
|
+
- #1373 Reverting accidental push to vip-cli
|
|
12
|
+
|
|
3
13
|
### 2.29.1
|
|
4
14
|
|
|
5
15
|
- #1372 fix(export): Make vip-export-sql.js executable
|
|
@@ -74,8 +74,13 @@ services:
|
|
|
74
74
|
run_as_root:
|
|
75
75
|
- chown www-data:www-data /wp/wp-content/mu-plugins /wp/config /wp/log /wp/wp-content/uploads /wp
|
|
76
76
|
run:
|
|
77
|
-
-
|
|
78
|
-
|
|
77
|
+
- >
|
|
78
|
+
sh /dev-tools/setup.sh
|
|
79
|
+
--host database
|
|
80
|
+
--user root
|
|
81
|
+
--domain "http://<%= siteSlug %>.vipdev.lndo.site/"
|
|
82
|
+
--title "<%= wpTitle %>"
|
|
83
|
+
<% if ( multisite ) { %>--ms-domain "<%= siteSlug %>.vipdev.lndo.site" <% if ( multisite === true || multisite === 'subdomain' ) { %>--subdomain <% } %> <% } %>
|
|
79
84
|
database:
|
|
80
85
|
type: compose
|
|
81
86
|
services:
|
|
@@ -42,8 +42,11 @@ const examples = [{
|
|
|
42
42
|
}, {
|
|
43
43
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite --wordpress="5.8" --app-code="~/git/my_code"`,
|
|
44
44
|
description: 'Creates a local multisite dev environment using WP 5.8 and application code is expected to be in "~/git/my_code"'
|
|
45
|
+
}, {
|
|
46
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite=subdirectory --wordpress="5.8" --app-code="~/git/my_code"`,
|
|
47
|
+
description: 'Creates a local multisite dev environment with a subdirectory URL structure using WP 5.8 and application code is expected to be in "~/git/my_code"'
|
|
45
48
|
}];
|
|
46
|
-
const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site').option('multisite', 'Enable multisite install', undefined, _devEnvironmentCli.
|
|
49
|
+
const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment').option('title', 'Title for the WordPress site').option('multisite', 'Enable multisite install', undefined, _devEnvironmentCli.processStringOrBooleanOption);
|
|
47
50
|
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
48
51
|
cmd.examples(examples);
|
|
49
52
|
cmd.argv(process.argv, async (arg, opt) => {
|
|
@@ -17,8 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
requiredArgs: 1
|
|
18
18
|
}).example('vip import validate-sql <file>', 'Run the import validation against file').argv(process.argv, async arg => {
|
|
19
19
|
const filename = arg[0];
|
|
20
|
-
if (!
|
|
20
|
+
if (!filename) {
|
|
21
21
|
exit.withError('You must pass in a filename');
|
|
22
22
|
}
|
|
23
|
-
(0, _sql.validate)(filename);
|
|
23
|
+
await (0, _sql.validate)(filename);
|
|
24
24
|
});
|
package/dist/bin/vip-wp.js
CHANGED
|
@@ -207,7 +207,7 @@ const bindReconnectEvents = ({
|
|
|
207
207
|
stdin: currentJob.stdinStream,
|
|
208
208
|
stdout: currentJob.stdoutStream
|
|
209
209
|
});
|
|
210
|
-
(0, _tracker.trackEvent)('wpcli_command_reconnect', commonTrackingParams);
|
|
210
|
+
(0, _tracker.trackEvent)('wpcli_command_reconnect', commonTrackingParams).catch(() => {});
|
|
211
211
|
currentJob = await launchCommandAndGetStreams({
|
|
212
212
|
socket: currentJob.socket,
|
|
213
213
|
guid: cliCommand.guid,
|
|
@@ -319,7 +319,7 @@ const bindReconnectEvents = ({
|
|
|
319
319
|
};
|
|
320
320
|
/* eslint-enable camelcase */
|
|
321
321
|
|
|
322
|
-
(0, _tracker.trackEvent)('wpcli_command_execute', commonTrackingParams);
|
|
322
|
+
(0, _tracker.trackEvent)('wpcli_command_execute', commonTrackingParams).catch(() => {});
|
|
323
323
|
if (isSubShell) {
|
|
324
324
|
// Reset the cursor (can get messed up with enquirer)
|
|
325
325
|
process.stdout.write('\u001b[?25h');
|
|
@@ -330,7 +330,7 @@ const bindReconnectEvents = ({
|
|
|
330
330
|
value: `wp ${cmd}`
|
|
331
331
|
}], `Are you sure you want to run this command on ${(0, _format.formatEnvironment)(envName)} for site ${appName}?`));
|
|
332
332
|
if (!yes) {
|
|
333
|
-
(0, _tracker.trackEvent)('wpcli_confirm_cancel', commonTrackingParams);
|
|
333
|
+
(0, _tracker.trackEvent)('wpcli_confirm_cancel', commonTrackingParams).catch(() => {});
|
|
334
334
|
console.log('Command cancelled');
|
|
335
335
|
process.exit();
|
|
336
336
|
}
|
|
@@ -458,12 +458,14 @@ const bindReconnectEvents = ({
|
|
|
458
458
|
process.stdin.on('data', data => {
|
|
459
459
|
// only run this in interactive mode for prompts from WP commands
|
|
460
460
|
if (commandRunning && 0 === Buffer.compare(data, Buffer.from('\r'))) {
|
|
461
|
-
|
|
461
|
+
var _currentJob;
|
|
462
|
+
if ((_currentJob = currentJob) !== null && _currentJob !== void 0 && _currentJob.stdinStream) {
|
|
462
463
|
currentJob.stdinStream.write('\n');
|
|
463
464
|
}
|
|
464
465
|
}
|
|
465
466
|
});
|
|
466
467
|
subShellRl.on('SIGINT', async () => {
|
|
468
|
+
var _currentJob2;
|
|
467
469
|
// if we have a 2nd SIGINT, exit immediately
|
|
468
470
|
if (countSIGINT >= 1) {
|
|
469
471
|
process.exit();
|
|
@@ -472,7 +474,7 @@ const bindReconnectEvents = ({
|
|
|
472
474
|
|
|
473
475
|
// write out CTRL-C/SIGINT
|
|
474
476
|
process.stdin.write(cancelCommandChar);
|
|
475
|
-
if (currentJob &&
|
|
477
|
+
if ((_currentJob2 = currentJob) !== null && _currentJob2 !== void 0 && _currentJob2.stdoutStream) {
|
|
476
478
|
currentJob.stdoutStream.end();
|
|
477
479
|
}
|
|
478
480
|
await (0, _tracker.trackEvent)('wpcli_cancel_command', commonTrackingParams);
|
package/dist/bin/vip.js
CHANGED
|
@@ -10,7 +10,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
10
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
11
|
var _config = _interopRequireDefault(require("../lib/cli/config"));
|
|
12
12
|
var _command = _interopRequireWildcard(require("../lib/cli/command"));
|
|
13
|
-
var
|
|
13
|
+
var _token2 = _interopRequireDefault(require("../lib/token"));
|
|
14
14
|
var _tracker = require("../lib/tracker");
|
|
15
15
|
var _logout = _interopRequireDefault(require("../lib/logout"));
|
|
16
16
|
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); }
|
|
@@ -39,14 +39,15 @@ function doesArgvHaveAtLeastOneParam(argv, params) {
|
|
|
39
39
|
return argv.some(arg => params.includes(arg));
|
|
40
40
|
}
|
|
41
41
|
const rootCmd = async function () {
|
|
42
|
-
|
|
42
|
+
var _token;
|
|
43
|
+
let token = await _token2.default.get();
|
|
43
44
|
const isHelpCommand = doesArgvHaveAtLeastOneParam(process.argv, ['help', '-h', '--help']);
|
|
44
45
|
const isVersionCommand = doesArgvHaveAtLeastOneParam(process.argv, ['-v', '--version']);
|
|
45
46
|
const isLogoutCommand = doesArgvHaveAtLeastOneParam(process.argv, ['logout']);
|
|
46
47
|
const isLoginCommand = doesArgvHaveAtLeastOneParam(process.argv, ['login']);
|
|
47
48
|
const isDevEnvCommandWithoutEnv = doesArgvHaveAtLeastOneParam(process.argv, ['dev-env']) && !(0, _command.containsAppEnvArgument)(process.argv);
|
|
48
49
|
debug('Argv:', process.argv);
|
|
49
|
-
if (!isLoginCommand && (isLogoutCommand || isHelpCommand || isVersionCommand || isDevEnvCommandWithoutEnv || token &&
|
|
50
|
+
if (!isLoginCommand && (isLogoutCommand || isHelpCommand || isVersionCommand || isDevEnvCommandWithoutEnv || (_token = token) !== null && _token !== void 0 && _token.valid())) {
|
|
50
51
|
await runCmd();
|
|
51
52
|
} else {
|
|
52
53
|
console.log();
|
|
@@ -82,7 +83,7 @@ const rootCmd = async function () {
|
|
|
82
83
|
message: 'Access Token:'
|
|
83
84
|
});
|
|
84
85
|
try {
|
|
85
|
-
token = new
|
|
86
|
+
token = new _token2.default(tokenInput);
|
|
86
87
|
} catch (err) {
|
|
87
88
|
console.log('The token provided is malformed. Please check the token and try again.');
|
|
88
89
|
await (0, _tracker.trackEvent)('login_command_token_submit_error', {
|
|
@@ -105,7 +106,7 @@ const rootCmd = async function () {
|
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
108
|
try {
|
|
108
|
-
await
|
|
109
|
+
await _token2.default.set(token.raw);
|
|
109
110
|
} catch (err) {
|
|
110
111
|
await (0, _tracker.trackEvent)('login_command_token_submit_error', {
|
|
111
112
|
error: err.message
|
|
@@ -123,4 +124,6 @@ const rootCmd = async function () {
|
|
|
123
124
|
await runCmd();
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
|
-
|
|
127
|
+
|
|
128
|
+
// We may end up having an unhandled rejection here :-(
|
|
129
|
+
void rootCmd();
|
|
@@ -14,7 +14,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
let api;
|
|
17
|
-
|
|
17
|
+
// If Token.get() fails, we may have an unhandled rejection
|
|
18
|
+
void (0, _api.default)().then(client => {
|
|
18
19
|
api = client;
|
|
19
20
|
});
|
|
20
21
|
const isVipQuery = (0, _graphqlTag.default)`
|
package/dist/lib/api.js
CHANGED
|
@@ -57,14 +57,14 @@ async function API({
|
|
|
57
57
|
}) => {
|
|
58
58
|
if (networkError && networkError.statusCode === 401) {
|
|
59
59
|
console.error(_chalk.default.red('Unauthorized:'), 'You are unauthorized to perform this request, please logout with `vip logout` then try again.');
|
|
60
|
-
process.exit();
|
|
60
|
+
process.exit(1);
|
|
61
61
|
}
|
|
62
62
|
if (graphQLErrors && graphQLErrors.length && globalGraphQLErrorHandlingEnabled) {
|
|
63
63
|
graphQLErrors.forEach(error => {
|
|
64
64
|
console.error(_chalk.default.red('Error:'), error.message);
|
|
65
65
|
});
|
|
66
66
|
if (exitOnError) {
|
|
67
|
-
process.exit();
|
|
67
|
+
process.exit(1);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
});
|
package/dist/lib/app.js
CHANGED
|
@@ -16,10 +16,12 @@ exports.postStart = postStart;
|
|
|
16
16
|
exports.printTable = printTable;
|
|
17
17
|
exports.processBooleanOption = processBooleanOption;
|
|
18
18
|
exports.processComponentOptionInput = processComponentOptionInput;
|
|
19
|
+
exports.processStringOrBooleanOption = processStringOrBooleanOption;
|
|
19
20
|
exports.processVersionOption = processVersionOption;
|
|
20
21
|
exports.promptForArguments = promptForArguments;
|
|
21
22
|
exports.promptForBoolean = promptForBoolean;
|
|
22
23
|
exports.promptForComponent = promptForComponent;
|
|
24
|
+
exports.promptForMultisite = promptForMultisite;
|
|
23
25
|
exports.promptForPhpVersion = promptForPhpVersion;
|
|
24
26
|
exports.promptForText = promptForText;
|
|
25
27
|
exports.resolvePath = resolvePath;
|
|
@@ -270,6 +272,7 @@ function getOptionsFromAppInfo(appInfo) {
|
|
|
270
272
|
*/
|
|
271
273
|
// eslint-disable-next-line complexity
|
|
272
274
|
async function promptForArguments(preselectedOptions, defaultOptions, suppressPrompts = false) {
|
|
275
|
+
var _preselectedOptions$m;
|
|
273
276
|
debug('Provided preselected', preselectedOptions, 'and default', defaultOptions);
|
|
274
277
|
if (suppressPrompts) {
|
|
275
278
|
preselectedOptions = {
|
|
@@ -280,14 +283,12 @@ async function promptForArguments(preselectedOptions, defaultOptions, suppressPr
|
|
|
280
283
|
console.log(_devEnvironment.DEV_ENVIRONMENT_PROMPT_INTRO);
|
|
281
284
|
}
|
|
282
285
|
let multisiteText = 'Multisite';
|
|
283
|
-
let multisiteDefault = _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.multisite;
|
|
284
286
|
if (defaultOptions.title) {
|
|
285
287
|
multisiteText += ` (${defaultOptions.title} ${defaultOptions.multisite ? 'IS' : 'is NOT'} multisite)`;
|
|
286
|
-
multisiteDefault = defaultOptions.multisite;
|
|
287
288
|
}
|
|
288
289
|
const instanceData = {
|
|
289
290
|
wpTitle: preselectedOptions.title || (await promptForText('WordPress site title', defaultOptions.title || _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.title)),
|
|
290
|
-
multisite: preselectedOptions.multisite !==
|
|
291
|
+
multisite: resolveMultisite((_preselectedOptions$m = preselectedOptions.multisite) !== null && _preselectedOptions$m !== void 0 ? _preselectedOptions$m : await promptForMultisite(multisiteText, defaultOptions.multisite || _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.multisite)),
|
|
291
292
|
elasticsearch: false,
|
|
292
293
|
php: preselectedOptions.php ? resolvePhpVersion(preselectedOptions.php) : await promptForPhpVersion(resolvePhpVersion(defaultOptions.php || _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.phpVersion)),
|
|
293
294
|
mariadb: preselectedOptions.mariadb || defaultOptions.mariadb,
|
|
@@ -450,6 +451,31 @@ async function promptForText(message, initial) {
|
|
|
450
451
|
}
|
|
451
452
|
return (((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.input) || '').trim();
|
|
452
453
|
}
|
|
454
|
+
async function promptForMultisite(message, initial) {
|
|
455
|
+
var _result3;
|
|
456
|
+
let result = {
|
|
457
|
+
input: initial
|
|
458
|
+
};
|
|
459
|
+
if (isStdinTTY) {
|
|
460
|
+
result = await (0, _enquirer.prompt)({
|
|
461
|
+
type: 'input',
|
|
462
|
+
name: 'input',
|
|
463
|
+
message,
|
|
464
|
+
initial
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
let input = (((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.input) || initial.toString()).trim();
|
|
468
|
+
const multisiteOptions = ['subdomain', 'subdirectory'];
|
|
469
|
+
const allowedOptions = [...FALSE_OPTIONS, ...TRUE_OPTIONS, ...multisiteOptions, 'none'];
|
|
470
|
+
if (!allowedOptions.includes(input) && isStdinTTY) {
|
|
471
|
+
const select = new _enquirer.Select({
|
|
472
|
+
message: `Please choose a valid option for multisite:`,
|
|
473
|
+
choices: [...multisiteOptions, 'false']
|
|
474
|
+
});
|
|
475
|
+
input = await select.run();
|
|
476
|
+
}
|
|
477
|
+
return processStringOrBooleanOption(input);
|
|
478
|
+
}
|
|
453
479
|
function promptForBoolean(message, initial) {
|
|
454
480
|
if (isStdinTTY) {
|
|
455
481
|
const confirm = new _enquirer.Confirm({
|
|
@@ -460,6 +486,13 @@ function promptForBoolean(message, initial) {
|
|
|
460
486
|
}
|
|
461
487
|
return Promise.resolve(initial);
|
|
462
488
|
}
|
|
489
|
+
function resolveMultisite(value) {
|
|
490
|
+
const allowedValues = ['subdomain', 'subdirectory'];
|
|
491
|
+
if (typeof value === 'string' && !allowedValues.includes(value)) {
|
|
492
|
+
return _devEnvironment.DEV_ENVIRONMENT_DEFAULTS.multisite;
|
|
493
|
+
}
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
463
496
|
function resolvePhpVersion(version) {
|
|
464
497
|
debug(`Resolving PHP version %j`, version);
|
|
465
498
|
if (version.startsWith('image:')) {
|
|
@@ -583,6 +616,17 @@ function processBooleanOption(value) {
|
|
|
583
616
|
}
|
|
584
617
|
return !FALSE_OPTIONS.includes((_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
585
618
|
}
|
|
619
|
+
const TRUE_OPTIONS = ['true', 'yes', 'y', '1'];
|
|
620
|
+
function processStringOrBooleanOption(value) {
|
|
621
|
+
var _value$toLowerCase2, _value$toLowerCase3;
|
|
622
|
+
if (!value || FALSE_OPTIONS.includes((_value$toLowerCase2 = value.toLowerCase) === null || _value$toLowerCase2 === void 0 ? void 0 : _value$toLowerCase2.call(value))) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
if (TRUE_OPTIONS.includes((_value$toLowerCase3 = value.toLowerCase) === null || _value$toLowerCase3 === void 0 ? void 0 : _value$toLowerCase3.call(value))) {
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
return value;
|
|
629
|
+
}
|
|
586
630
|
function processVersionOption(value) {
|
|
587
631
|
if (!isNaN(value) && value % 1 === 0) {
|
|
588
632
|
// If it's an Integer passed in, let's ensure that it has a decimal in it to match the version tags e.g. 6 => 6.0
|
|
@@ -179,7 +179,7 @@ async function bootstrapLando() {
|
|
|
179
179
|
}
|
|
180
180
|
if (pull || !instanceData.pullAfter) {
|
|
181
181
|
instanceData.pullAfter = Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
182
|
-
(0, _devEnvironmentCore.writeEnvironmentData)(data.name, instanceData);
|
|
182
|
+
await (0, _devEnvironmentCore.writeEnvironmentData)(data.name, instanceData);
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
await lando.bootstrap();
|
|
@@ -245,7 +245,7 @@ async function getBridgeNetwork(lando) {
|
|
|
245
245
|
}
|
|
246
246
|
async function cleanUpLandoProxy(lando) {
|
|
247
247
|
const network = await getBridgeNetwork(lando);
|
|
248
|
-
if (network && network.Containers && !Object.keys(network.Containers).length) {
|
|
248
|
+
if (network !== null && network !== void 0 && network.Containers && !Object.keys(network.Containers).length) {
|
|
249
249
|
const proxy = lando.engine.docker.getContainer(lando.config.proxyContainer);
|
|
250
250
|
try {
|
|
251
251
|
await proxy.remove({
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _configstore = _interopRequireDefault(require("configstore"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
9
|
/**
|
|
8
10
|
* External dependencies
|
|
9
11
|
*/
|
|
10
|
-
const Configstore = require('configstore');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
@@ -16,38 +17,36 @@ const Configstore = require('configstore');
|
|
|
16
17
|
class Insecure {
|
|
17
18
|
constructor(file) {
|
|
18
19
|
this.file = file;
|
|
19
|
-
this.configstore = new
|
|
20
|
+
this.configstore = new _configstore.default(this.file);
|
|
20
21
|
}
|
|
21
22
|
getPassword(service) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} catch (err) {
|
|
27
|
-
return reject(err);
|
|
23
|
+
try {
|
|
24
|
+
const value = this.configstore.get(service);
|
|
25
|
+
if (null === value || undefined === value) {
|
|
26
|
+
return Promise.resolve(null);
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
30
|
+
return Promise.resolve(value.toString()); // NOSONAR
|
|
31
|
+
} catch (err) {
|
|
32
|
+
return Promise.reject(err);
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
setPassword(service, password) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
resolve(true);
|
|
40
|
-
});
|
|
36
|
+
try {
|
|
37
|
+
this.configstore.set(service, password);
|
|
38
|
+
return Promise.resolve(true);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return Promise.reject(err);
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
deletePassword(service) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
resolve(true);
|
|
50
|
-
});
|
|
44
|
+
try {
|
|
45
|
+
this.configstore.delete(service);
|
|
46
|
+
return Promise.resolve(true);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return Promise.reject(err);
|
|
49
|
+
}
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
exports.default = Insecure;
|
|
@@ -9,15 +9,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
9
9
|
/**
|
|
10
10
|
* External dependencies
|
|
11
11
|
*/
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
16
|
+
|
|
15
17
|
class Secure {
|
|
16
18
|
getPassword(service) {
|
|
17
19
|
return _keytar.default.getPassword(service, service);
|
|
18
20
|
}
|
|
19
|
-
setPassword(service, password) {
|
|
20
|
-
|
|
21
|
+
async setPassword(service, password) {
|
|
22
|
+
await _keytar.default.setPassword(service, service, password);
|
|
23
|
+
return true;
|
|
21
24
|
}
|
|
22
25
|
deletePassword(service) {
|
|
23
26
|
return _keytar.default.deletePassword(service, service);
|
package/dist/lib/keychain.js
CHANGED
|
@@ -4,35 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
7
8
|
var _insecure = _interopRequireDefault(require("./keychain/insecure"));
|
|
8
|
-
var _browser = _interopRequireDefault(require("./keychain/browser"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
/* global window */
|
|
11
10
|
/**
|
|
12
11
|
* External dependencies
|
|
13
12
|
*/
|
|
14
|
-
const debug = require('debug')('@automattic/vip:keychain');
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Internal dependencies
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
|
-
let exportValue
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
let exportValue;
|
|
19
|
+
const debug = (0, _debug.default)('@automattic/vip:keychain');
|
|
20
|
+
try {
|
|
21
|
+
// Try using Secure keychain ("keytar") first
|
|
22
|
+
const Secure = require("./keychain/secure");
|
|
23
|
+
exportValue = new Secure();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
debug('Cannot use Secure keychain; falling back to Insecure keychain (Details: %o)', error);
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const Secure = require("./keychain/secure");
|
|
27
|
-
exportValue = new Secure();
|
|
28
|
-
} catch (error) {
|
|
29
|
-
debug('Cannot use Secure keychain; falling back to Insecure keychain (Details: %o)', error);
|
|
30
|
-
|
|
31
|
-
// Fallback to Insecure keychain if we can't
|
|
32
|
-
exportValue = new _insecure.default('vip-go-cli');
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
exportValue = new _browser.default();
|
|
27
|
+
// Fallback to Insecure keychain if we can't
|
|
28
|
+
exportValue = new _insecure.default('vip-go-cli');
|
|
36
29
|
}
|
|
37
30
|
var _default = exportValue;
|
|
38
31
|
exports.default = _default;
|
|
@@ -234,12 +234,12 @@ ${maybeExitPrompt}
|
|
|
234
234
|
startDate = Date.now();
|
|
235
235
|
}
|
|
236
236
|
setTimeout(() => {
|
|
237
|
-
checkStatus(pollInterval);
|
|
237
|
+
void checkStatus(pollInterval);
|
|
238
238
|
}, pollInterval);
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
// Kick off the check
|
|
242
|
-
checkStatus(IMPORT_MEDIA_PROGRESS_POLL_INTERVAL);
|
|
242
|
+
void checkStatus(IMPORT_MEDIA_PROGRESS_POLL_INTERVAL);
|
|
243
243
|
});
|
|
244
244
|
try {
|
|
245
245
|
var _results$failureDetai;
|
|
@@ -246,8 +246,9 @@ ${maybeExitPrompt}
|
|
|
246
246
|
|
|
247
247
|
// if the progress meta isn't filled out yet, wait until it is.
|
|
248
248
|
if (!statusSteps) {
|
|
249
|
-
return setTimeout(checkStatus, IMPORT_SQL_PROGRESS_POLL_INTERVAL);
|
|
249
|
+
return setTimeout(checkStatus, IMPORT_SQL_PROGRESS_POLL_INTERVAL); // NOSONAR
|
|
250
250
|
}
|
|
251
|
+
|
|
251
252
|
jobSteps = statusSteps.map(step => {
|
|
252
253
|
return {
|
|
253
254
|
id: step.name,
|
|
@@ -348,11 +349,11 @@ ${maybeExitPrompt}
|
|
|
348
349
|
return resolve(importJob);
|
|
349
350
|
}
|
|
350
351
|
overallStatus = 'running';
|
|
351
|
-
setTimeout(checkStatus, IMPORT_SQL_PROGRESS_POLL_INTERVAL);
|
|
352
|
+
setTimeout(checkStatus, IMPORT_SQL_PROGRESS_POLL_INTERVAL); // NOSONAR
|
|
352
353
|
};
|
|
353
354
|
|
|
354
355
|
// Kick off the check
|
|
355
|
-
checkStatus();
|
|
356
|
+
void checkStatus();
|
|
356
357
|
});
|
|
357
358
|
try {
|
|
358
359
|
const results = await getResults();
|
package/dist/lib/token.js
CHANGED
|
@@ -12,9 +12,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
/**
|
|
13
13
|
* External dependencies
|
|
14
14
|
*/
|
|
15
|
+
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
19
|
+
|
|
18
20
|
// Config
|
|
19
21
|
const SERVICE = 'vip-go-cli';
|
|
20
22
|
exports.SERVICE = SERVICE;
|
|
@@ -28,9 +30,9 @@ class Token {
|
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
32
|
const decodedToken = (0, _jwtDecode.default)(token);
|
|
31
|
-
this.
|
|
33
|
+
this._raw = token;
|
|
32
34
|
if (decodedToken.id) {
|
|
33
|
-
this.
|
|
35
|
+
this._id = decodedToken.id;
|
|
34
36
|
}
|
|
35
37
|
if (decodedToken.iat) {
|
|
36
38
|
this.iat = new Date(decodedToken.iat * 1000);
|
|
@@ -40,7 +42,7 @@ class Token {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
valid() {
|
|
43
|
-
if (!this.
|
|
45
|
+
if (!this._id) {
|
|
44
46
|
return false;
|
|
45
47
|
}
|
|
46
48
|
if (!this.iat) {
|
|
@@ -59,6 +61,14 @@ class Token {
|
|
|
59
61
|
const now = new Date();
|
|
60
62
|
return now > this.exp;
|
|
61
63
|
}
|
|
64
|
+
get id() {
|
|
65
|
+
var _this$_id;
|
|
66
|
+
return (_this$_id = this._id) !== null && _this$_id !== void 0 ? _this$_id : NaN;
|
|
67
|
+
}
|
|
68
|
+
get raw() {
|
|
69
|
+
var _this$_raw;
|
|
70
|
+
return (_this$_raw = this._raw) !== null && _this$_raw !== void 0 ? _this$_raw : '';
|
|
71
|
+
}
|
|
62
72
|
static async uuid() {
|
|
63
73
|
const service = Token.getServiceName('-uuid');
|
|
64
74
|
let _uuid = await _keychain.default.getPassword(service);
|
|
@@ -72,16 +82,17 @@ class Token {
|
|
|
72
82
|
const service = Token.getServiceName('-uuid');
|
|
73
83
|
await _keychain.default.setPassword(service, _uuid);
|
|
74
84
|
}
|
|
75
|
-
static
|
|
85
|
+
static set(token) {
|
|
76
86
|
const service = Token.getServiceName();
|
|
77
87
|
return _keychain.default.setPassword(service, token);
|
|
78
88
|
}
|
|
79
89
|
static async get() {
|
|
90
|
+
var _await$keychain$getPa;
|
|
80
91
|
const service = Token.getServiceName();
|
|
81
|
-
const token = await _keychain.default.getPassword(service);
|
|
92
|
+
const token = (_await$keychain$getPa = await _keychain.default.getPassword(service)) !== null && _await$keychain$getPa !== void 0 ? _await$keychain$getPa : '';
|
|
82
93
|
return new Token(token);
|
|
83
94
|
}
|
|
84
|
-
static
|
|
95
|
+
static purge() {
|
|
85
96
|
const service = Token.getServiceName();
|
|
86
97
|
return _keychain.default.deletePassword(service);
|
|
87
98
|
}
|
package/dist/lib/tracker.js
CHANGED
|
@@ -37,10 +37,9 @@ async function init() {
|
|
|
37
37
|
userId: uuid
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
return new _index.default({
|
|
41
41
|
clients
|
|
42
42
|
});
|
|
43
|
-
return analytics;
|
|
44
43
|
}
|
|
45
44
|
async function getInstance() {
|
|
46
45
|
if (analytics) {
|
|
@@ -64,9 +63,9 @@ async function aliasUser(vipUserId) {
|
|
|
64
63
|
await trackEvent('_alias_user', {
|
|
65
64
|
ui: vipUserId,
|
|
66
65
|
_ut: _config.default.tracksUserType,
|
|
67
|
-
anonid: _token.default.uuid()
|
|
66
|
+
anonid: await _token.default.uuid()
|
|
68
67
|
});
|
|
69
|
-
_token.default.setUuid(vipUserId);
|
|
68
|
+
await _token.default.setUuid(vipUserId);
|
|
70
69
|
}
|
|
71
70
|
} catch (err) {
|
|
72
71
|
debug('aliasUser() failed', err);
|
|
@@ -125,11 +125,11 @@ function checkTablePrefixes(results, errors, infos) {
|
|
|
125
125
|
const wpMultisiteTables = [];
|
|
126
126
|
results.forEach(result => {
|
|
127
127
|
const tableName = result.text || '';
|
|
128
|
-
if (
|
|
128
|
+
if (RegExp(/^wp_(\d+_)/).exec(tableName)) {
|
|
129
129
|
wpMultisiteTables.push(tableName);
|
|
130
|
-
} else if (tableName.
|
|
130
|
+
} else if (tableName.startsWith('wp_')) {
|
|
131
131
|
wpTables.push(tableName);
|
|
132
|
-
} else
|
|
132
|
+
} else {
|
|
133
133
|
notWPTables.push(tableName);
|
|
134
134
|
}
|
|
135
135
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This file allows us to bypass the noImplicitAny rule for importing modules
|
|
2
|
+
// noImplicitAny is too good of a rule to fully disable, so we provide this file to ensure that we can still import modules without types.
|
|
3
|
+
// as that seems to have been a big pain point for everyone.
|
|
4
|
+
// reference: https://www.typescriptlang.org/docs/handbook/modules.html#shorthand-ambient-modules
|
|
5
|
+
|
|
6
|
+
declare module '*';
|