@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/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### 2.26.0
|
|
4
|
+
|
|
5
|
+
- #1237 Skip requoting if the arg is a valid JSON Object
|
|
6
|
+
- #1258 fix(dev-env): Get more verbose logs from Lando in debug mode
|
|
7
|
+
- #1249 refactor(dev-env): Do not use Lando's memcached plugin
|
|
8
|
+
- #1266 fix(dev-env): Fix incorrect working directory when vip dev-env exec is run from a 8 level deep directory
|
|
9
|
+
- #1263 Dev-env: Do not prompt to update WP version if trunk is used
|
|
10
|
+
- #1244 chore(deps): Pin @apollo/client to 3.3.6
|
|
11
|
+
- #1261 fix(dev-env): Gracefully handle failures to fetch WP versions
|
|
12
|
+
- #1257 fix(dev-env): Fix "This app was built on a different version of Lando" warning
|
|
13
|
+
- #1260 Config Software: fix small typo in "include" usage
|
|
14
|
+
- #1250 feat(dev-env): Implement upgrade path for changes affecting .lando.yml
|
|
15
|
+
- #1259 Add notifications commands to package.json
|
|
16
|
+
- #1228 fix(dev-env): Do not use a temporary directory for Lando
|
|
17
|
+
- #1251 Fix lint errors fix/lint-errors
|
|
18
|
+
- #1247 Add library to facilitate SQL backup export
|
|
19
|
+
- #1246 fix(dev-env): ElasticSearch => Elasticsearch
|
|
20
|
+
- #1243 fix: Fix peer dependencies and code style issues
|
|
21
|
+
- #1242 chore: Set minimum Node.js version to 16
|
|
22
|
+
|
|
23
|
+
### 2.25.1
|
|
4
24
|
|
|
5
25
|
- #1239 Downgrade Apollo client to 3.3.6
|
|
6
26
|
|
|
7
|
-
|
|
27
|
+
### 2.25.0
|
|
8
28
|
|
|
9
29
|
- #1233 Update @automattic/vip-go-preflight-checks to 2.0.16
|
|
10
30
|
- #1232 fix(dev-env): Make environment existence check more robust
|
|
@@ -39,15 +59,15 @@
|
|
|
39
59
|
- #1196 fix(dev-env): Fix ambiguous short option for MailHog/MariaDB
|
|
40
60
|
- #1195 fix(dev-env): increase max number of event listeners for AsyncEvents
|
|
41
61
|
|
|
42
|
-
|
|
62
|
+
### 2.24.2 (22 Dec 2022)
|
|
43
63
|
|
|
44
64
|
- #1219 fix(dev-env): Fix search/replace on SQL file import
|
|
45
65
|
|
|
46
|
-
|
|
66
|
+
### 2.24.1 (10 Dec 2022)
|
|
47
67
|
|
|
48
68
|
- #1193 Fix regression in vip dev-env import sql related to the fact we don't mount User's home dir anymore
|
|
49
69
|
|
|
50
|
-
|
|
70
|
+
### 2.24.0 (06 Dec 2022)
|
|
51
71
|
|
|
52
72
|
- #1139 fix(dev-env): Fall back to copy when rename fails due to EXDEV
|
|
53
73
|
- #1170 [dev-env] Substitute the check for forward slash to with a cross-platform regex when processing component argument value
|
|
@@ -65,14 +85,14 @@
|
|
|
65
85
|
- #1188 fix: Make bin files executables
|
|
66
86
|
- #1189 refactor(dev-env): Bootstrap Lando only once
|
|
67
87
|
|
|
68
|
-
|
|
88
|
+
### 2.23.0 (11 Nov 2022)
|
|
69
89
|
|
|
70
90
|
- #1169 Preflight Validation: Change return code on error
|
|
71
91
|
- #1095 Harmonia Pre Deploy Validation: Add `validate` command
|
|
72
92
|
- #1156 Validate env before resolving path
|
|
73
93
|
- #1167 dev-env: Fix bug in getVersionList() when path doesn't exist
|
|
74
94
|
|
|
75
|
-
|
|
95
|
+
### 2.22.0 (2 Nov 2022)
|
|
76
96
|
|
|
77
97
|
#1165 Add caching type policy for `WPSite` data
|
|
78
98
|
#1164 Fix regExp to categorize multisite tables during SQL Imports
|
|
@@ -59,28 +59,42 @@ services:
|
|
|
59
59
|
volume:
|
|
60
60
|
nocopy: true
|
|
61
61
|
<% wpVolumes() %>
|
|
62
|
+
run_as_root:
|
|
63
|
+
- chown www-data:www-data /wp/wp-content/mu-plugins /wp/config /wp/log /wp/wp-content/uploads /wp
|
|
62
64
|
run:
|
|
63
65
|
- sh /dev-tools/setup.sh database root "http://<%= siteSlug %>.vipdev.lndo.site/" "<%= wpTitle %>" <% if ( multisite ) { %> <%= siteSlug %>.vipdev.lndo.site <% } %>
|
|
64
66
|
|
|
65
67
|
database:
|
|
66
68
|
type: compose
|
|
67
69
|
services:
|
|
70
|
+
<% if ( mariadb ) { %>
|
|
68
71
|
image: mariadb:<%= mariadb %>
|
|
69
72
|
command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION --max_allowed_packet=67M
|
|
73
|
+
<% } else { %>
|
|
74
|
+
image: mysql:8
|
|
75
|
+
command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION --max_allowed_packet=67M --default-authentication-plugin=mysql_native_password
|
|
76
|
+
<% } %>
|
|
70
77
|
ports:
|
|
71
78
|
- ":3306"
|
|
72
79
|
environment:
|
|
73
|
-
|
|
80
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
|
|
81
|
+
MYSQL_USER: wordpress
|
|
82
|
+
MYSQL_PASSWORD: wordpress
|
|
83
|
+
MYSQL_DATABASE: wordpress
|
|
74
84
|
volumes:
|
|
75
85
|
- database_data:/var/lib/mysql
|
|
76
86
|
volumes:
|
|
77
87
|
database_data:
|
|
78
88
|
|
|
79
89
|
memcached:
|
|
80
|
-
type:
|
|
81
|
-
|
|
90
|
+
type: compose
|
|
91
|
+
services:
|
|
82
92
|
image: memcached:1.6-alpine3.16
|
|
83
|
-
command:
|
|
93
|
+
command: memcached -m 64
|
|
94
|
+
environment:
|
|
95
|
+
LANDO_NO_USER_PERMS: 1
|
|
96
|
+
LANDO_NO_SCRIPTS: 1
|
|
97
|
+
LANDO_NEEDS_EXEC: 1
|
|
84
98
|
|
|
85
99
|
<% if ( phpmyadmin ) { %>
|
|
86
100
|
phpmyadmin:
|
|
Binary file
|
|
@@ -37,7 +37,7 @@ const VALID_INCLUDES = ['available_versions'];
|
|
|
37
37
|
wildcardCommand: true,
|
|
38
38
|
format: true,
|
|
39
39
|
usage: 'vip @mysite.develop config software get <wordpress|php|nodejs|muplugins>'
|
|
40
|
-
}).option('include', `Extra information to be included.
|
|
40
|
+
}).option('include', `Extra information to be included. Valid values: ${VALID_INCLUDES.join(',')}`).examples(examples).argv(process.argv, async (arg, opt) => {
|
|
41
41
|
var _opt$env;
|
|
42
42
|
const trackingInfo = {
|
|
43
43
|
environment_id: (_opt$env = opt.env) === null || _opt$env === void 0 ? void 0 : _opt$env.id,
|
|
@@ -87,7 +87,8 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
87
87
|
try {
|
|
88
88
|
await (0, _devEnvironmentCore.createEnvironment)(instanceData);
|
|
89
89
|
await (0, _devEnvironmentCore.printEnvironmentInfo)(lando, slug, {
|
|
90
|
-
extended: false
|
|
90
|
+
extended: false,
|
|
91
|
+
suppressWarnings: true
|
|
91
92
|
});
|
|
92
93
|
const message = '\n' + _chalk.default.green('✓') + ` environment created.\n\nTo start it please run:\n\n${startCommand}\n`;
|
|
93
94
|
console.log(message);
|
|
@@ -8,22 +8,18 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* External dependencies
|
|
10
10
|
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
11
15
|
"use strict";
|
|
12
16
|
|
|
13
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
14
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
17
|
var _tracker = require("../lib/tracker");
|
|
16
18
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
17
19
|
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
18
|
-
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
19
20
|
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
20
|
-
var
|
|
21
|
-
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
22
|
-
var _userError = _interopRequireDefault(require("../lib/user-error"));
|
|
21
|
+
var _devEnvImportSql = require("../commands/dev-env-import-sql");
|
|
23
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
23
|
const examples = [{
|
|
28
24
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} import sql some-wp-db-file.sql`,
|
|
29
25
|
description: 'Import the contents of a WordPress database from an SQL file'
|
|
@@ -41,65 +37,10 @@ const examples = [{
|
|
|
41
37
|
requiredArgs: 1
|
|
42
38
|
}).option('slug', 'Custom name of the dev environment').option(['r', 'search-replace'], 'Perform Search and Replace on the specified SQL file').option('in-place', 'Search and Replace explicitly on the given input file').option('skip-validate', 'Do not perform file validation.').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
|
|
43
39
|
const [fileName] = unmatchedArgs;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
inPlace
|
|
47
|
-
} = opt;
|
|
48
|
-
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
49
|
-
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
50
|
-
await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
|
|
51
|
-
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
52
|
-
await (0, _tracker.trackEvent)('dev_env_import_sql_command_execute', trackingInfo);
|
|
40
|
+
const cmd = new _devEnvImportSql.DevEnvImportSQLCommand(fileName, opt);
|
|
41
|
+
const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(cmd.slug);
|
|
53
42
|
try {
|
|
54
|
-
|
|
55
|
-
if (!opt.skipValidate) {
|
|
56
|
-
if (!(0, _devEnvironmentLando.isEnvUp)(lando, (0, _devEnvironmentCore.getEnvironmentPath)(slug))) {
|
|
57
|
-
throw new _userError.default('Environment needs to be started first');
|
|
58
|
-
}
|
|
59
|
-
const expectedDomain = `${slug}.vipdev.lndo.site`;
|
|
60
|
-
await (0, _sql.validate)(resolvedPath, {
|
|
61
|
-
isImport: false,
|
|
62
|
-
skipChecks: [],
|
|
63
|
-
extraCheckParams: {
|
|
64
|
-
siteHomeUrlLando: expectedDomain
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
const fd = await _fs.default.promises.open(resolvedPath, 'r');
|
|
69
|
-
const importArg = ['db', '--disable-auto-rehash'];
|
|
70
|
-
const origIsTTY = process.stdin.isTTY;
|
|
71
|
-
try {
|
|
72
|
-
/**
|
|
73
|
-
* When stdin is a TTY, Lando passes the `--tty` flag to Docker.
|
|
74
|
-
* This breaks our code when we pass the stream as stdin to Docker.
|
|
75
|
-
* exec() then fails with "the input device is not a TTY".
|
|
76
|
-
*
|
|
77
|
-
* Therefore, for the things to work, we have to pretend that stdin is not a TTY :-)
|
|
78
|
-
*/
|
|
79
|
-
process.stdin.isTTY = false;
|
|
80
|
-
await (0, _devEnvironmentCore.exec)(lando, slug, importArg, {
|
|
81
|
-
stdio: [fd, 'pipe', 'pipe']
|
|
82
|
-
});
|
|
83
|
-
console.log(`${_chalk.default.green.bold('Success:')} Database imported.`);
|
|
84
|
-
} finally {
|
|
85
|
-
process.stdin.isTTY = origIsTTY;
|
|
86
|
-
}
|
|
87
|
-
if (searchReplace && searchReplace.length && !inPlace) {
|
|
88
|
-
_fs.default.unlinkSync(resolvedPath);
|
|
89
|
-
}
|
|
90
|
-
const cacheArg = ['wp', 'cache', 'flush'];
|
|
91
|
-
await (0, _devEnvironmentCore.exec)(lando, slug, cacheArg);
|
|
92
|
-
try {
|
|
93
|
-
await (0, _devEnvironmentCore.exec)(lando, slug, ['wp', 'cli', 'has-command', 'vip-search']);
|
|
94
|
-
const doIndex = await (0, _devEnvironmentCli.promptForBoolean)('Do you want to index data in ElasticSearch (used by enterprise search)?', true);
|
|
95
|
-
if (doIndex) {
|
|
96
|
-
await (0, _devEnvironmentCore.exec)(lando, slug, ['wp', 'vip-search', 'index', '--setup', '--network-wide', '--skip-confirm']);
|
|
97
|
-
}
|
|
98
|
-
} catch (err) {
|
|
99
|
-
// Exception means they don't have vip-search enabled.
|
|
100
|
-
}
|
|
101
|
-
const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'];
|
|
102
|
-
await (0, _devEnvironmentCore.exec)(lando, slug, addUserArg);
|
|
43
|
+
await cmd.run();
|
|
103
44
|
await (0, _tracker.trackEvent)('dev_env_import_sql_command_success', trackingInfo);
|
|
104
45
|
} catch (error) {
|
|
105
46
|
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_sql_command_error', trackingInfo);
|
|
@@ -40,7 +40,8 @@ const examples = [{
|
|
|
40
40
|
debug('Args: ', arg, 'Options: ', opt);
|
|
41
41
|
try {
|
|
42
42
|
const options = {
|
|
43
|
-
extended: !!opt.extended
|
|
43
|
+
extended: !!opt.extended,
|
|
44
|
+
suppressWarnings: true
|
|
44
45
|
};
|
|
45
46
|
if (opt.all) {
|
|
46
47
|
await (0, _devEnvironmentCore.printAllEnvironmentsInfo)(lando, options);
|
|
@@ -49,7 +49,7 @@ const examples = [{
|
|
|
49
49
|
(0, _child_process.exec)(dockerWindowsPathCmd, {
|
|
50
50
|
shell: 'powershell.exe'
|
|
51
51
|
}, (error, stdout) => {
|
|
52
|
-
if (error
|
|
52
|
+
if (error) {
|
|
53
53
|
debug(error);
|
|
54
54
|
console.log(`${_chalk.default.red('✕')} There was an error while applying the Windows Docker patch.`);
|
|
55
55
|
} else {
|
|
@@ -52,7 +52,7 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
52
52
|
const defaultOptions = {
|
|
53
53
|
appCode: currentInstanceData.appCode.dir || currentInstanceData.appCode.tag || 'latest',
|
|
54
54
|
muPlugins: currentInstanceData.muPlugins.dir || currentInstanceData.muPlugins.tag || 'latest',
|
|
55
|
-
wordpress: currentInstanceData.wordpress.tag,
|
|
55
|
+
wordpress: currentInstanceData.wordpress.tag || 'trunk',
|
|
56
56
|
elasticsearch: currentInstanceData.elasticsearch,
|
|
57
57
|
php: currentInstanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS.default,
|
|
58
58
|
mariadb: currentInstanceData.mariadb,
|
|
@@ -66,8 +66,8 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
66
66
|
const providedOptions = Object.keys(opt).filter(option => option.length > 1) // Filter out single letter aliases
|
|
67
67
|
.filter(option => !['debug', 'help', 'slug'].includes(option)); // Filter out options that are not related to instance configuration
|
|
68
68
|
|
|
69
|
-
const
|
|
70
|
-
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(preselectedOptions, defaultOptions,
|
|
69
|
+
const suppressPrompts = providedOptions.length > 0;
|
|
70
|
+
const instanceData = await (0, _devEnvironmentCli.promptForArguments)(preselectedOptions, defaultOptions, suppressPrompts);
|
|
71
71
|
instanceData.siteSlug = slug;
|
|
72
72
|
await (0, _devEnvironmentCore.updateEnvironment)(instanceData);
|
|
73
73
|
const message = '\n' + _chalk.default.green('✓') + ' environment updated. Restart environment for changes to take an affect.';
|
|
@@ -23,8 +23,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
23
|
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; }
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
/**
|
|
26
|
-
* Internal dependencies
|
|
27
|
-
*/
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
28
|
// eslint-disable-next-line no-duplicate-imports
|
|
29
29
|
const appQuery = `
|
|
30
30
|
id,
|
|
@@ -233,7 +233,7 @@ If you are confident the file does not contain unsupported statements, you can r
|
|
|
233
233
|
return (0, _sql.getTableNames)();
|
|
234
234
|
}
|
|
235
235
|
function validateFilename(filename) {
|
|
236
|
-
const re = /^[a-z0-9
|
|
236
|
+
const re = /^[a-z0-9\-_.]+$/i;
|
|
237
237
|
|
|
238
238
|
// Exits if filename contains anything outside a-z A-Z - _ .
|
|
239
239
|
if (!re.test(filename)) {
|
|
@@ -305,7 +305,7 @@ const displayPlaybook = ({
|
|
|
305
305
|
console.log(_chalk.default.yellowBright('You are updating tables in a launched multi site installation. Sites in the same network may have their performance impacted by this operation.'));
|
|
306
306
|
}
|
|
307
307
|
console.log(_chalk.default.yellow('The following sites will be affected by the import:'));
|
|
308
|
-
multiSiteBreakdown.
|
|
308
|
+
multiSiteBreakdown.forEach(siteObject => {
|
|
309
309
|
console.log();
|
|
310
310
|
console.log(_chalk.default.blueBright(`Blog with ID ${siteObject.id} and URL ${siteObject.url} will import the following tables:`));
|
|
311
311
|
console.log((0, _cliColumns.default)(siteObject.tables));
|
|
@@ -353,10 +353,10 @@ const displayPlaybook = ({
|
|
|
353
353
|
const domain = env !== null && env !== void 0 && (_env$primaryDomain = env.primaryDomain) !== null && _env$primaryDomain !== void 0 && _env$primaryDomain.name ? env.primaryDomain.name : `#${env.id}`;
|
|
354
354
|
const formattedEnvironment = (0, _format.formatEnvironment)(opts.env.type);
|
|
355
355
|
const launched = opts.env.launched;
|
|
356
|
-
let fileNameToUpload = fileName;
|
|
357
356
|
|
|
358
|
-
//
|
|
359
|
-
validateFilename(
|
|
357
|
+
// Extract base file name and exit if it contains unsafe character
|
|
358
|
+
validateFilename(fileMeta.basename);
|
|
359
|
+
let fileNameToUpload = fileName;
|
|
360
360
|
|
|
361
361
|
// SQL file validations
|
|
362
362
|
const tableNames = await validateAndGetTableNames({
|
|
@@ -464,8 +464,8 @@ Processing the SQL import for your environment...
|
|
|
464
464
|
startImportVariables.input = {
|
|
465
465
|
id: app.id,
|
|
466
466
|
environmentId: env.id,
|
|
467
|
-
basename
|
|
468
|
-
md5
|
|
467
|
+
basename,
|
|
468
|
+
md5,
|
|
469
469
|
searchReplace: []
|
|
470
470
|
};
|
|
471
471
|
if (searchReplace) {
|
|
@@ -8,7 +8,6 @@ var _url = _interopRequireDefault(require("url"));
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
-
var _util = require("util");
|
|
12
11
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
13
12
|
var _vipImportValidateFiles = require("../lib/vip-import-validate-files");
|
|
14
13
|
var _tracker = require("../lib/tracker");
|
|
@@ -16,8 +15,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
|
-
// Promisify to use async/await
|
|
20
|
-
const stat = (0, _util.promisify)(_fs.default.stat);
|
|
21
18
|
(0, _command.default)({
|
|
22
19
|
requiredArgs: 1,
|
|
23
20
|
format: true
|
|
@@ -79,7 +76,8 @@ const stat = (0, _util.promisify)(_fs.default.stat);
|
|
|
79
76
|
// Iterate through each file to isolate the extension name
|
|
80
77
|
for (const file of files) {
|
|
81
78
|
// Check if file is a directory
|
|
82
|
-
|
|
79
|
+
// eslint-disable-next-line no-await-in-loop
|
|
80
|
+
const stats = await _fs.default.promises.stat(file);
|
|
83
81
|
const isFolder = stats.isDirectory();
|
|
84
82
|
const extension = _path.default.extname(file); // Extract the extension of the file
|
|
85
83
|
const ext = extension.substr(1); // We only want the ext name minus the period (e.g- .jpg -> jpg)
|
package/dist/bin/vip-logs.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.followLogs = followLogs;
|
|
|
12
12
|
exports.getLogs = getLogs;
|
|
13
13
|
exports.validateInputs = validateInputs;
|
|
14
14
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
|
+
var _promises = require("timers/promises");
|
|
15
16
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
16
17
|
var _rollbar = require("../lib/rollbar");
|
|
17
18
|
var _tracker = require("../lib/tracker");
|
|
@@ -68,6 +69,8 @@ async function followLogs(opt) {
|
|
|
68
69
|
|
|
69
70
|
// Set an initial default delay
|
|
70
71
|
let delay = DEFAULT_POLLING_DELAY_IN_SECONDS;
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line no-constant-condition
|
|
71
74
|
while (true) {
|
|
72
75
|
const limit = isFirstRequest ? opt.limit : LIMIT_MAX;
|
|
73
76
|
requestNumber++;
|
|
@@ -77,12 +80,16 @@ async function followLogs(opt) {
|
|
|
77
80
|
let logs;
|
|
78
81
|
try {
|
|
79
82
|
var _logs;
|
|
83
|
+
// eslint-disable-next-line no-await-in-loop
|
|
80
84
|
logs = await logsLib.getRecentLogs(opt.app.id, opt.env.id, opt.type, limit, after);
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line no-await-in-loop
|
|
81
87
|
await (0, _tracker.trackEvent)('logs_command_follow_success', {
|
|
82
88
|
...trackingParams,
|
|
83
89
|
total: (_logs = logs) === null || _logs === void 0 ? void 0 : _logs.nodes.length
|
|
84
90
|
});
|
|
85
91
|
} catch (error) {
|
|
92
|
+
// eslint-disable-next-line no-await-in-loop
|
|
86
93
|
await (0, _tracker.trackEvent)('logs_command_follow_error', {
|
|
87
94
|
...trackingParams,
|
|
88
95
|
error: error.message
|
|
@@ -110,7 +117,9 @@ async function followLogs(opt) {
|
|
|
110
117
|
// Keep a sane lower limit of MIN_POLLING_DELAY_IN_SECONDS just in case something goes wrong in the server-side
|
|
111
118
|
delay = Math.max(((_logs4 = logs) === null || _logs4 === void 0 ? void 0 : _logs4.pollingDelaySeconds) || DEFAULT_POLLING_DELAY_IN_SECONDS, MIN_POLLING_DELAY_IN_SECONDS);
|
|
112
119
|
}
|
|
113
|
-
|
|
120
|
+
|
|
121
|
+
// eslint-disable-next-line no-await-in-loop
|
|
122
|
+
await (0, _promises.setTimeout)(delay * 1000);
|
|
114
123
|
}
|
|
115
124
|
}
|
|
116
125
|
function getBaseTrackingParams(opt) {
|
package/dist/bin/vip-sync.js
CHANGED
|
@@ -426,8 +426,8 @@ async function validateArgs(opt) {
|
|
|
426
426
|
/**
|
|
427
427
|
* Remove sensitive information from the tracked events and snake_case the keys.
|
|
428
428
|
*
|
|
429
|
-
* @param {
|
|
430
|
-
* @
|
|
429
|
+
* @param {Object} args The arguments passed to the command.
|
|
430
|
+
* @return {Object} Copy of the arguments without sensitive information.
|
|
431
431
|
*/
|
|
432
432
|
function sanitizeArgsForTracking(args) {
|
|
433
433
|
const protectedKeys = ['npmToken', 'nodeBuildDockerEnv'];
|
package/dist/bin/vip-wp.js
CHANGED
|
@@ -136,7 +136,7 @@ const cancelCommand = async guid => {
|
|
|
136
136
|
`,
|
|
137
137
|
variables: {
|
|
138
138
|
input: {
|
|
139
|
-
guid
|
|
139
|
+
guid
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
});
|
|
@@ -220,7 +220,7 @@ const bindReconnectEvents = ({
|
|
|
220
220
|
currentJob = await launchCommandAndGetStreams({
|
|
221
221
|
socket: currentJob.socket,
|
|
222
222
|
guid: cliCommand.guid,
|
|
223
|
-
inputToken
|
|
223
|
+
inputToken,
|
|
224
224
|
offset: currentOffset
|
|
225
225
|
});
|
|
226
226
|
|
|
@@ -362,7 +362,7 @@ const bindReconnectEvents = ({
|
|
|
362
362
|
const promptIdentifier = `${appName}.${(0, _command.getEnvIdentifier)(opts.env)}`;
|
|
363
363
|
let countSIGINT = 0;
|
|
364
364
|
const mutableStdout = new _stream.Writable({
|
|
365
|
-
write
|
|
365
|
+
write(chunk, encoding, callback) {
|
|
366
366
|
if (!this.muted) {
|
|
367
367
|
process.stdout.write(chunk, encoding);
|
|
368
368
|
}
|
|
@@ -462,7 +462,7 @@ const bindReconnectEvents = ({
|
|
|
462
462
|
currentJob = await launchCommandAndGetStreams({
|
|
463
463
|
socket,
|
|
464
464
|
guid: cliCommand.guid,
|
|
465
|
-
inputToken
|
|
465
|
+
inputToken
|
|
466
466
|
});
|
|
467
467
|
pipeStreamsToProcess({
|
|
468
468
|
stdin: currentJob.stdinStream,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DevEnvImportSQLCommand = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
10
|
+
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
11
|
+
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
12
|
+
var _userError = _interopRequireDefault(require("../lib/user-error"));
|
|
13
|
+
var _sql = require("../lib/validations/sql");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @format
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* External dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
class DevEnvImportSQLCommand {
|
|
29
|
+
constructor(fileName, options) {
|
|
30
|
+
this.fileName = fileName;
|
|
31
|
+
this.options = options;
|
|
32
|
+
this.slug = (0, _devEnvironmentCli.getEnvironmentName)(options);
|
|
33
|
+
}
|
|
34
|
+
async run(silent = false) {
|
|
35
|
+
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
36
|
+
await (0, _devEnvironmentCli.validateDependencies)(lando, this.slug, silent);
|
|
37
|
+
const {
|
|
38
|
+
searchReplace,
|
|
39
|
+
inPlace
|
|
40
|
+
} = this.options;
|
|
41
|
+
const resolvedPath = await (0, _devEnvironmentCore.resolveImportPath)(this.slug, this.fileName, searchReplace, inPlace);
|
|
42
|
+
if (!this.options.skipValidate) {
|
|
43
|
+
if (!(await (0, _devEnvironmentLando.isEnvUp)(lando, (0, _devEnvironmentCore.getEnvironmentPath)(this.slug)))) {
|
|
44
|
+
throw new _userError.default('Environment needs to be started first');
|
|
45
|
+
}
|
|
46
|
+
const expectedDomain = `${this.slug}.vipdev.lndo.site`;
|
|
47
|
+
await (0, _sql.validate)(resolvedPath, {
|
|
48
|
+
isImport: false,
|
|
49
|
+
skipChecks: [],
|
|
50
|
+
extraCheckParams: {
|
|
51
|
+
siteHomeUrlLando: expectedDomain
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const fd = await _fs.default.promises.open(resolvedPath, 'r');
|
|
56
|
+
const importArg = ['db', '--disable-auto-rehash'];
|
|
57
|
+
const origIsTTY = process.stdin.isTTY;
|
|
58
|
+
try {
|
|
59
|
+
/**
|
|
60
|
+
* When stdin is a TTY, Lando passes the `--tty` flag to Docker.
|
|
61
|
+
* This breaks our code when we pass the stream as stdin to Docker.
|
|
62
|
+
* exec() then fails with "the input device is not a TTY".
|
|
63
|
+
*
|
|
64
|
+
* Therefore, for the things to work, we have to pretend that stdin is not a TTY :-)
|
|
65
|
+
*/
|
|
66
|
+
process.stdin.isTTY = false;
|
|
67
|
+
await (0, _devEnvironmentCore.exec)(lando, this.slug, importArg, {
|
|
68
|
+
stdio: [fd, 'pipe', 'pipe']
|
|
69
|
+
});
|
|
70
|
+
if (!silent) {
|
|
71
|
+
console.log(`${_chalk.default.green.bold('Success:')} Database imported.`);
|
|
72
|
+
}
|
|
73
|
+
} finally {
|
|
74
|
+
process.stdin.isTTY = origIsTTY;
|
|
75
|
+
}
|
|
76
|
+
if (searchReplace && searchReplace.length && !inPlace) {
|
|
77
|
+
_fs.default.unlinkSync(resolvedPath);
|
|
78
|
+
}
|
|
79
|
+
const cacheArg = ['wp', 'cache', 'flush'];
|
|
80
|
+
await (0, _devEnvironmentCore.exec)(lando, this.slug, cacheArg);
|
|
81
|
+
try {
|
|
82
|
+
await (0, _devEnvironmentCore.exec)(lando, this.slug, ['wp', 'cli', 'has-command', 'vip-search']);
|
|
83
|
+
const doIndex = await (0, _devEnvironmentCli.promptForBoolean)('Do you want to index data in Elasticsearch (used by Enterprise Search)?', true);
|
|
84
|
+
if (doIndex) {
|
|
85
|
+
await (0, _devEnvironmentCore.exec)(lando, this.slug, ['wp', 'vip-search', 'index', '--setup', '--network-wide', '--skip-confirm']);
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
// Exception means they don't have vip-search enabled.
|
|
89
|
+
}
|
|
90
|
+
const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password'];
|
|
91
|
+
await (0, _devEnvironmentCore.exec)(lando, this.slug, addUserArg);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.DevEnvImportSQLCommand = DevEnvImportSQLCommand;
|