@automattic/vip 2.12.0 → 2.14.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/README.md +27 -3
- package/dist/bin/vip-cache-purge-url.js +93 -0
- package/{package/dist/bin/vip-config.js → dist/bin/vip-cache.js} +6 -3
- package/dist/bin/vip-dev-env-exec.js +9 -2
- package/dist/bin/vip-dev-env-import-sql.js +8 -1
- package/dist/bin/vip-dev-env-start.js +2 -1
- package/dist/bin/vip-dev-env-update.js +1 -0
- package/dist/bin/vip.js +1 -1
- package/dist/lib/api/cache-purge.js +76 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +2 -2
- package/dist/lib/dev-environment/dev-environment-core.js +3 -3
- package/dist/lib/dev-environment/dev-environment-lando.js +38 -7
- package/dist/lib/envvar/read-file.js +2 -18
- package/{package/dist/lib/envvar → dist/lib}/read-file.js +3 -6
- package/dist/lib/validations/sql.js +175 -53
- package/npm-shrinkwrap.json +82 -82
- package/package.json +5 -3
- package/.circleci/config.yml +0 -67
- package/package/dist/bin/vip-app-list.js +0 -73
- package/package/dist/bin/vip-app.js +0 -76
- package/package/dist/bin/vip-config-envvar-delete.js +0 -97
- package/package/dist/bin/vip-config-envvar-get-all.js +0 -94
- package/package/dist/bin/vip-config-envvar-get.js +0 -79
- package/package/dist/bin/vip-config-envvar-list.js +0 -91
- package/package/dist/bin/vip-config-envvar-set.js +0 -123
- package/package/dist/bin/vip-config-envvar.js +0 -23
- package/package/dist/bin/vip-dev-env-create.js +0 -105
- package/package/dist/bin/vip-dev-env-destroy.js +0 -56
- package/package/dist/bin/vip-dev-env-exec.js +0 -67
- package/package/dist/bin/vip-dev-env-import-media.js +0 -51
- package/package/dist/bin/vip-dev-env-import-sql.js +0 -83
- package/package/dist/bin/vip-dev-env-import.js +0 -32
- package/package/dist/bin/vip-dev-env-info.js +0 -61
- package/package/dist/bin/vip-dev-env-list.js +0 -46
- package/package/dist/bin/vip-dev-env-start.js +0 -77
- package/package/dist/bin/vip-dev-env-stop.js +0 -52
- package/package/dist/bin/vip-dev-env-update.js +0 -89
- package/package/dist/bin/vip-dev-env.js +0 -23
- package/package/dist/bin/vip-import-media-abort.js +0 -132
- package/package/dist/bin/vip-import-media-status.js +0 -84
- package/package/dist/bin/vip-import-media.js +0 -168
- package/package/dist/bin/vip-import-sql-status.js +0 -83
- package/package/dist/bin/vip-import-sql.js +0 -580
- package/package/dist/bin/vip-import-validate-files.js +0 -191
- package/package/dist/bin/vip-import-validate-sql.js +0 -34
- package/package/dist/bin/vip-import.js +0 -20
- package/package/dist/bin/vip-logs.js +0 -232
- package/package/dist/bin/vip-search-replace.js +0 -71
- package/package/dist/bin/vip-sync.js +0 -191
- package/package/dist/bin/vip-whoami.js +0 -67
- package/package/dist/bin/vip-wp.js +0 -555
- package/package/dist/bin/vip.js +0 -149
- package/package/dist/lib/analytics/clients/client.js +0 -1
- package/package/dist/lib/analytics/clients/pendo.js +0 -92
- package/package/dist/lib/analytics/clients/stub.js +0 -19
- package/package/dist/lib/analytics/clients/tracks.js +0 -128
- package/package/dist/lib/analytics/index.js +0 -45
- package/package/dist/lib/api/app.js +0 -70
- package/package/dist/lib/api/feature-flags.js +0 -39
- package/package/dist/lib/api/user.js +0 -58
- package/package/dist/lib/api.js +0 -136
- package/package/dist/lib/app-logs/app-logs.js +0 -70
- package/package/dist/lib/cli/apiConfig.js +0 -90
- package/package/dist/lib/cli/command.js +0 -606
- package/package/dist/lib/cli/envAlias.js +0 -60
- package/package/dist/lib/cli/exit.js +0 -33
- package/package/dist/lib/cli/format.js +0 -213
- package/package/dist/lib/cli/pager.js +0 -52
- package/package/dist/lib/cli/progress.js +0 -208
- package/package/dist/lib/cli/prompt.js +0 -37
- package/package/dist/lib/cli/repo.js +0 -77
- package/package/dist/lib/client-file-uploader.js +0 -602
- package/package/dist/lib/constants/dev-environment.js +0 -42
- package/package/dist/lib/constants/file-size.js +0 -14
- package/package/dist/lib/dev-environment/dev-environment-cli.js +0 -508
- package/package/dist/lib/dev-environment/dev-environment-core.js +0 -620
- package/package/dist/lib/dev-environment/dev-environment-lando.js +0 -330
- package/package/dist/lib/dev-environment/types.js +0 -1
- package/package/dist/lib/env.js +0 -36
- package/package/dist/lib/envvar/api-delete.js +0 -56
- package/package/dist/lib/envvar/api-get-all.js +0 -59
- package/package/dist/lib/envvar/api-get.js +0 -24
- package/package/dist/lib/envvar/api-list.js +0 -60
- package/package/dist/lib/envvar/api-set.js +0 -58
- package/package/dist/lib/envvar/api.js +0 -104
- package/package/dist/lib/envvar/input.js +0 -55
- package/package/dist/lib/envvar/logging.js +0 -33
- package/package/dist/lib/http/socks-proxy-agent.js +0 -25
- package/package/dist/lib/keychain/browser.js +0 -35
- package/package/dist/lib/keychain/insecure.js +0 -63
- package/package/dist/lib/keychain/keychain.js +0 -1
- package/package/dist/lib/keychain/secure.js +0 -36
- package/package/dist/lib/keychain.js +0 -36
- package/package/dist/lib/media-import/media-file-import.js +0 -34
- package/package/dist/lib/media-import/progress.js +0 -86
- package/package/dist/lib/media-import/status.js +0 -335
- package/package/dist/lib/rollbar.js +0 -35
- package/package/dist/lib/search-and-replace.js +0 -203
- package/package/dist/lib/site-import/db-file-import.js +0 -46
- package/package/dist/lib/site-import/status.js +0 -444
- package/package/dist/lib/token.js +0 -132
- package/package/dist/lib/tracker.js +0 -96
- package/package/dist/lib/validations/is-multi-site-sql-dump.js +0 -59
- package/package/dist/lib/validations/is-multi-site.js +0 -99
- package/package/dist/lib/validations/line-by-line.js +0 -92
- package/package/dist/lib/validations/site-type.js +0 -66
- package/package/dist/lib/validations/sql.js +0 -371
- package/package/dist/lib/vip-import-validate-files.js +0 -548
- package/package/vip.iml +0 -11
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
14
|
-
|
|
15
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
16
|
-
|
|
17
|
-
var _child_process = require("child_process");
|
|
18
|
-
|
|
19
|
-
var _tracker = require("../lib/tracker");
|
|
20
|
-
|
|
21
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
24
|
-
|
|
25
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
-
|
|
27
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
28
|
-
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Internal dependencies
|
|
33
|
-
*/
|
|
34
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment'); // PowerShell command for Windows Docker patch
|
|
35
|
-
|
|
36
|
-
const dockerWindowsPathCmd = 'wsl -d docker-desktop bash -c "sysctl -w vm.max_map_count=262144"';
|
|
37
|
-
const examples = [{
|
|
38
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start`,
|
|
39
|
-
description: 'Starts a local dev environment'
|
|
40
|
-
}];
|
|
41
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
42
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
43
|
-
const startProcessing = new Date();
|
|
44
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
45
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
46
|
-
await (0, _tracker.trackEvent)('dev_env_start_command_execute', trackingInfo);
|
|
47
|
-
debug('Args: ', arg, 'Options: ', opt);
|
|
48
|
-
const options = {
|
|
49
|
-
skipRebuild: !!opt.skipRebuild
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
if (process.platform === 'win32') {
|
|
54
|
-
debug('Windows platform detected. Applying Docker patch...');
|
|
55
|
-
(0, _child_process.exec)(dockerWindowsPathCmd, {
|
|
56
|
-
shell: 'powershell.exe'
|
|
57
|
-
}, (error, stdout) => {
|
|
58
|
-
if (error != null) {
|
|
59
|
-
debug(error);
|
|
60
|
-
console.log(`${_chalk.default.red('✕')} There was an error while applying the Windows Docker patch.`);
|
|
61
|
-
} else {
|
|
62
|
-
debug(stdout);
|
|
63
|
-
console.log(`${_chalk.default.green('✓')} Docker patch for Windows applied.`);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
await (0, _devEnvironmentCore.startEnvironment)(slug, options);
|
|
69
|
-
const processingTime = new Date() - startProcessing;
|
|
70
|
-
const successTrackingInfo = { ...trackingInfo,
|
|
71
|
-
processing_time: processingTime
|
|
72
|
-
};
|
|
73
|
-
await (0, _tracker.trackEvent)('dev_env_start_command_success', successTrackingInfo);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_start_command_error', trackingInfo);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
22
|
-
|
|
23
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
24
|
-
|
|
25
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
33
|
-
const examples = [{
|
|
34
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} stop`,
|
|
35
|
-
description: 'Stops a local dev environment'
|
|
36
|
-
}];
|
|
37
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
38
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
39
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
40
|
-
debug('Args: ', arg, 'Options: ', opt);
|
|
41
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
42
|
-
await (0, _tracker.trackEvent)('dev_env_stop_command_execute', trackingInfo);
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
await (0, _devEnvironmentCore.stopEnvironment)(slug);
|
|
46
|
-
const message = _chalk.default.green('✓') + ' environment stopped.\n';
|
|
47
|
-
console.log(message);
|
|
48
|
-
await (0, _tracker.trackEvent)('dev_env_stop_command_success', trackingInfo);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_stop_command_error', trackingInfo);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
|
-
var _tracker = require("../lib/tracker");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
22
|
-
|
|
23
|
-
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
24
|
-
|
|
25
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
33
|
-
const examples = [{
|
|
34
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} update`,
|
|
35
|
-
description: 'Retriggers setup wizard in order to change environment configuration'
|
|
36
|
-
}];
|
|
37
|
-
const cmd = (0, _command.default)().option('slug', 'Custom name of the dev environment');
|
|
38
|
-
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
39
|
-
cmd.examples(examples);
|
|
40
|
-
cmd.argv(process.argv, async (arg, opt) => {
|
|
41
|
-
await (0, _devEnvironmentCli.validateDependencies)();
|
|
42
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
43
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
44
|
-
await (0, _tracker.trackEvent)('dev_env_update_command_execute', trackingInfo);
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
48
|
-
|
|
49
|
-
if (!environmentAlreadyExists) {
|
|
50
|
-
throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const currentInstanceData = (0, _devEnvironmentCore.readEnvironmentData)(slug);
|
|
54
|
-
debug('Read instance data', currentInstanceData);
|
|
55
|
-
const preselectedOptions = {
|
|
56
|
-
// Title and multisite can't be changed during update
|
|
57
|
-
title: currentInstanceData.wpTitle,
|
|
58
|
-
multisite: currentInstanceData.multisite,
|
|
59
|
-
...opt
|
|
60
|
-
};
|
|
61
|
-
const defaultOptions = {
|
|
62
|
-
clientCode: currentInstanceData.clientCode.dir || currentInstanceData.clientCode.tag || 'latest',
|
|
63
|
-
muPlugins: currentInstanceData.muPlugins.dir || currentInstanceData.muPlugins.tag || 'latest',
|
|
64
|
-
wordpress: currentInstanceData.wordpress.tag,
|
|
65
|
-
elasticsearch: currentInstanceData.elasticsearch,
|
|
66
|
-
php: currentInstanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS.default,
|
|
67
|
-
mariadb: currentInstanceData.mariadb,
|
|
68
|
-
statsd: currentInstanceData.statsd,
|
|
69
|
-
phpmyadmin: currentInstanceData.phpmyadmin,
|
|
70
|
-
xdebug: currentInstanceData.xdebug,
|
|
71
|
-
mediaRedirectDomain: currentInstanceData.mediaRedirectDomain,
|
|
72
|
-
multisite: false,
|
|
73
|
-
title: ''
|
|
74
|
-
};
|
|
75
|
-
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(preselectedOptions, defaultOptions);
|
|
76
|
-
instanceData.siteSlug = slug;
|
|
77
|
-
await (0, _devEnvironmentCore.updateEnvironment)(instanceData);
|
|
78
|
-
const message = '\n' + _chalk.default.green('✓') + ' environment updated. Restart environment for changes to take an affect.';
|
|
79
|
-
console.log(message);
|
|
80
|
-
await (0, _tracker.trackEvent)('dev_env_update_command_success', trackingInfo);
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if ('ENOENT' === error.code) {
|
|
83
|
-
const message = 'Environment was created before update was supported.\n\nTo update environment please destroy it and create a new one.';
|
|
84
|
-
(0, _devEnvironmentCli.handleCLIException)(new Error(message), 'dev_env_update_command_error', trackingInfo);
|
|
85
|
-
} else {
|
|
86
|
-
(0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_update_command_error', trackingInfo);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
(0, _command.default)({
|
|
22
|
-
requiredArgs: 1
|
|
23
|
-
}).command('create', 'Create a new local dev environment').command('update', 'Update an already created local dev environment').command('start', 'Start a local dev environment').command('stop', 'Stop a local dev environment').command('destroy', 'Remove containers, networks, volumes and configuration files of a local dev environment').command('info', 'Provides basic info about one or multiple local dev environments').command('list', 'Provides basic info about all local dev environments').command('exec', 'Execute an operation on a dev environment').command('import', 'Import data into a local WordPress environment').argv(process.argv);
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
14
|
-
|
|
15
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
|
-
var _mediaFileImport = require("../lib/media-import/media-file-import");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _api = _interopRequireDefault(require("../lib/api"));
|
|
22
|
-
|
|
23
|
-
var exit = _interopRequireWildcard(require("../lib/cli/exit"));
|
|
24
|
-
|
|
25
|
-
var _tracker = require("../lib/tracker");
|
|
26
|
-
|
|
27
|
-
var _progress = require("../lib/media-import/progress");
|
|
28
|
-
|
|
29
|
-
var _status = require("../lib/media-import/status");
|
|
30
|
-
|
|
31
|
-
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); }
|
|
32
|
-
|
|
33
|
-
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; }
|
|
34
|
-
|
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Internal dependencies
|
|
39
|
-
*/
|
|
40
|
-
// eslint-disable-next-line no-duplicate-imports
|
|
41
|
-
const appQuery = `
|
|
42
|
-
id,
|
|
43
|
-
name,
|
|
44
|
-
type,
|
|
45
|
-
environments{
|
|
46
|
-
id
|
|
47
|
-
appId
|
|
48
|
-
type
|
|
49
|
-
primaryDomain {
|
|
50
|
-
id
|
|
51
|
-
name
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
const ABORT_IMPORT_MUTATION = (0, _graphqlTag.default)`
|
|
56
|
-
mutation AbortMediaImport( $input: AppEnvironmentAbortMediaImportInput ) {
|
|
57
|
-
abortMediaImport( input: $input ) {
|
|
58
|
-
applicationId
|
|
59
|
-
environmentId
|
|
60
|
-
mediaImportStatusChange {
|
|
61
|
-
importId
|
|
62
|
-
siteId
|
|
63
|
-
statusFrom
|
|
64
|
-
statusTo
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
(0, _command.default)({
|
|
70
|
-
appContext: true,
|
|
71
|
-
appQuery,
|
|
72
|
-
envContext: true,
|
|
73
|
-
requiredArgs: 0,
|
|
74
|
-
requireConfirm: `
|
|
75
|
-
${_chalk.default.red.bold('By running this command, the Media Import running on your App will stop and can\'t be resumed.')}
|
|
76
|
-
${_chalk.default.red.bold('Are you sure you want to abort this Media Import?')}
|
|
77
|
-
`
|
|
78
|
-
}).argv(process.argv, async (arg, {
|
|
79
|
-
app,
|
|
80
|
-
env
|
|
81
|
-
}) => {
|
|
82
|
-
const {
|
|
83
|
-
id: envId,
|
|
84
|
-
appId
|
|
85
|
-
} = env;
|
|
86
|
-
|
|
87
|
-
const track = _tracker.trackEventWithEnv.bind(null, appId, envId);
|
|
88
|
-
|
|
89
|
-
if (!(0, _mediaFileImport.isSupportedApp)(app)) {
|
|
90
|
-
await track('import_media_command_error', {
|
|
91
|
-
errorType: 'unsupported-app'
|
|
92
|
-
});
|
|
93
|
-
exit.withError('The type of application you specified does not currently support Media imports.');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const api = await (0, _api.default)();
|
|
97
|
-
await track('import_media_abort_execute');
|
|
98
|
-
const progressTracker = new _progress.MediaImportProgressTracker([]);
|
|
99
|
-
progressTracker.prefix = `
|
|
100
|
-
=============================================================
|
|
101
|
-
Aborting the Media Import running on your App
|
|
102
|
-
`;
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
await api.mutate({
|
|
106
|
-
mutation: ABORT_IMPORT_MUTATION,
|
|
107
|
-
variables: {
|
|
108
|
-
input: {
|
|
109
|
-
applicationId: app.id,
|
|
110
|
-
environmentId: env.id
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
await (0, _status.mediaImportCheckStatus)({
|
|
115
|
-
app,
|
|
116
|
-
env,
|
|
117
|
-
progressTracker
|
|
118
|
-
});
|
|
119
|
-
} catch (error) {
|
|
120
|
-
if (error.graphQLErrors) {
|
|
121
|
-
for (const err of error.graphQLErrors) {
|
|
122
|
-
console.log(_chalk.default.red('Error:'), err.message);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
await track('import_media_abort_execute_error', {
|
|
129
|
-
error: `Error: ${error.message}`
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _tracker = require("../lib/tracker");
|
|
14
|
-
|
|
15
|
-
var exit = _interopRequireWildcard(require("../lib/cli/exit"));
|
|
16
|
-
|
|
17
|
-
var _mediaFileImport = require("../lib/media-import/media-file-import");
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _progress = require("../lib/media-import/progress");
|
|
22
|
-
|
|
23
|
-
var _status = require("../lib/media-import/status");
|
|
24
|
-
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
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); }
|
|
28
|
-
|
|
29
|
-
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; }
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Internal dependencies
|
|
33
|
-
*/
|
|
34
|
-
const appQuery = `
|
|
35
|
-
id,
|
|
36
|
-
name,
|
|
37
|
-
type,
|
|
38
|
-
environments{
|
|
39
|
-
id
|
|
40
|
-
appId
|
|
41
|
-
type
|
|
42
|
-
primaryDomain {
|
|
43
|
-
id
|
|
44
|
-
name
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
(0, _command.default)({
|
|
49
|
-
appContext: true,
|
|
50
|
-
appQuery,
|
|
51
|
-
envContext: true,
|
|
52
|
-
requiredArgs: 0
|
|
53
|
-
}).option('exportFileErrorsToJson', 'Export any file errors encountered to a JSON file instead of a plain text file', false).argv(process.argv, async (arg, {
|
|
54
|
-
app,
|
|
55
|
-
env,
|
|
56
|
-
exportFileErrorsToJson
|
|
57
|
-
}) => {
|
|
58
|
-
const {
|
|
59
|
-
id: envId,
|
|
60
|
-
appId
|
|
61
|
-
} = env;
|
|
62
|
-
|
|
63
|
-
const track = _tracker.trackEventWithEnv.bind(null, appId, envId);
|
|
64
|
-
|
|
65
|
-
if (!(0, _mediaFileImport.isSupportedApp)(app)) {
|
|
66
|
-
await track('import_media_command_error', {
|
|
67
|
-
errorType: 'unsupported-app'
|
|
68
|
-
});
|
|
69
|
-
exit.withError('The type of application you specified does not currently support this feature');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
await track('import_media_check_status_command_execute');
|
|
73
|
-
const progressTracker = new _progress.MediaImportProgressTracker([]);
|
|
74
|
-
progressTracker.prefix = `
|
|
75
|
-
=============================================================
|
|
76
|
-
Checking the Media import status for your environment...
|
|
77
|
-
`;
|
|
78
|
-
await (0, _status.mediaImportCheckStatus)({
|
|
79
|
-
app,
|
|
80
|
-
env,
|
|
81
|
-
progressTracker,
|
|
82
|
-
exportFileErrorsToJson
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
14
|
-
|
|
15
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
16
|
-
|
|
17
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
|
-
|
|
19
|
-
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
-
|
|
21
|
-
var _api = _interopRequireDefault(require("../lib/api"));
|
|
22
|
-
|
|
23
|
-
var _tracker = require("../lib/tracker");
|
|
24
|
-
|
|
25
|
-
var _format = require("../lib/cli/format");
|
|
26
|
-
|
|
27
|
-
var _progress = require("../lib/media-import/progress");
|
|
28
|
-
|
|
29
|
-
var _status = require("../lib/media-import/status");
|
|
30
|
-
|
|
31
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Internal dependencies
|
|
35
|
-
*/
|
|
36
|
-
// eslint-disable-next-line no-duplicate-imports
|
|
37
|
-
const appQuery = `
|
|
38
|
-
id,
|
|
39
|
-
name,
|
|
40
|
-
type,
|
|
41
|
-
organization { id, name },
|
|
42
|
-
environments{
|
|
43
|
-
id
|
|
44
|
-
appId
|
|
45
|
-
type
|
|
46
|
-
name
|
|
47
|
-
primaryDomain { name }
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
const START_IMPORT_MUTATION = (0, _graphqlTag.default)`
|
|
51
|
-
mutation StartMediaImport( $input: AppEnvironmentStartMediaImportInput ) {
|
|
52
|
-
startMediaImport( input: $input ) {
|
|
53
|
-
applicationId
|
|
54
|
-
environmentId
|
|
55
|
-
mediaImportStatus {
|
|
56
|
-
importId
|
|
57
|
-
siteId
|
|
58
|
-
status
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
const debug = (0, _debug.default)('vip:vip-import-media'); // Command examples for the `vip import media` help prompt
|
|
64
|
-
|
|
65
|
-
const examples = [{
|
|
66
|
-
usage: 'vip import media @mysite.production https://<path_to_publicly_accessible_archive>',
|
|
67
|
-
description: 'Start a media import with the contents of the archive file in the URL'
|
|
68
|
-
}, // `media status` subcommand
|
|
69
|
-
{
|
|
70
|
-
usage: 'vip import media status @mysite.production',
|
|
71
|
-
description: 'Check the status of the most recent import. If an import is running, this will poll until it is complete.'
|
|
72
|
-
}, // `media abort` subcommand
|
|
73
|
-
{
|
|
74
|
-
usage: 'vip import media abort @mysite.production',
|
|
75
|
-
description: 'Abort an ongoing import'
|
|
76
|
-
}];
|
|
77
|
-
|
|
78
|
-
function isSupportedUrl(urlToTest) {
|
|
79
|
-
let url;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
url = new URL(urlToTest);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
(0, _command.default)({
|
|
91
|
-
appContext: true,
|
|
92
|
-
appQuery,
|
|
93
|
-
envContext: true,
|
|
94
|
-
module: 'import-media',
|
|
95
|
-
requiredArgs: 1,
|
|
96
|
-
requireConfirm: `
|
|
97
|
-
${_chalk.default.red.bold('NOTE: If the provided archive\'s directory structure contains an `uploads/` directory,')}
|
|
98
|
-
${_chalk.default.red.bold('only the files present inside that directory will be imported and the rest will be ignored.')}
|
|
99
|
-
${_chalk.default.red.bold('If no `uploads/` directory is found, all files will be imported, as is.')}
|
|
100
|
-
|
|
101
|
-
Are you sure you want to import the contents of the url?
|
|
102
|
-
`
|
|
103
|
-
}).command('status', 'Check the status of the latest Media Import').command('abort', 'Abort the Media Import running for your App').option('exportFileErrorsToJson', 'Export any file errors encountered to a JSON file instead of a plain text file', false).option('overwriteExistingFiles', 'Overwrite any existing files', false).option('importIntermediateImages', 'Import intermediate image files', false).examples(examples).argv(process.argv, async (args, opts) => {
|
|
104
|
-
const {
|
|
105
|
-
app,
|
|
106
|
-
env,
|
|
107
|
-
exportFileErrorsToJson,
|
|
108
|
-
overwriteExistingFiles,
|
|
109
|
-
importIntermediateImages
|
|
110
|
-
} = opts;
|
|
111
|
-
const [url] = args;
|
|
112
|
-
|
|
113
|
-
if (!isSupportedUrl(url)) {
|
|
114
|
-
console.log(_chalk.default.red(`
|
|
115
|
-
Error:
|
|
116
|
-
Invalid URL provided: ${url}
|
|
117
|
-
Please make sure that it is a publicly accessible web URL containing an archive of the media files to import`));
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const track = _tracker.trackEventWithEnv.bind(null, app.id, env.id);
|
|
122
|
-
|
|
123
|
-
const api = await (0, _api.default)();
|
|
124
|
-
debug('Options: ', opts);
|
|
125
|
-
debug('Args:', args);
|
|
126
|
-
await track('import_media_start_execute');
|
|
127
|
-
const progressTracker = new _progress.MediaImportProgressTracker([]);
|
|
128
|
-
progressTracker.prefix = `
|
|
129
|
-
=============================================================
|
|
130
|
-
Importing Media into your App...
|
|
131
|
-
`;
|
|
132
|
-
console.log();
|
|
133
|
-
console.log(`Importing archive from: ${url}`);
|
|
134
|
-
console.log(`to: ${env.primaryDomain.name} (${(0, _format.formatEnvironment)(env.type)})`);
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
await api.mutate({
|
|
138
|
-
mutation: START_IMPORT_MUTATION,
|
|
139
|
-
variables: {
|
|
140
|
-
input: {
|
|
141
|
-
applicationId: app.id,
|
|
142
|
-
environmentId: env.id,
|
|
143
|
-
archiveUrl: url,
|
|
144
|
-
overwriteExistingFiles,
|
|
145
|
-
importIntermediateImages
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
await (0, _status.mediaImportCheckStatus)({
|
|
150
|
-
app,
|
|
151
|
-
env,
|
|
152
|
-
progressTracker,
|
|
153
|
-
exportFileErrorsToJson
|
|
154
|
-
});
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (error.graphQLErrors) {
|
|
157
|
-
for (const err of error.graphQLErrors) {
|
|
158
|
-
console.log(_chalk.default.red('Error:'), err.message);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
await track('import_media_start_execute_error', {
|
|
165
|
-
error: `Error: ${error.message}`
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
});
|