@automattic/vip 2.14.0 → 2.17.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 +582 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +0 -549
- package/assets/dev-env.lando.template.yml.ejs +10 -14
- package/dist/bin/vip-config-software-get.js +90 -0
- package/dist/bin/vip-config-software-update.js +147 -0
- package/dist/bin/vip-config-software.js +27 -0
- package/dist/bin/vip-config.js +1 -1
- package/dist/bin/vip-dev-env-create.js +11 -9
- package/dist/bin/vip-dev-env-import-sql.js +1 -1
- package/dist/bin/vip-dev-env-info.js +0 -3
- package/dist/bin/vip-dev-env-start.js +3 -2
- package/dist/bin/vip-dev-env-update.js +2 -2
- package/dist/bin/vip-import-sql.js +6 -4
- package/dist/lib/analytics/clients/pendo.js +2 -5
- package/dist/lib/api/app.js +9 -3
- package/dist/lib/api/http.js +71 -0
- package/dist/lib/api.js +4 -24
- package/dist/lib/app.js +36 -0
- package/dist/lib/cli/command.js +9 -2
- package/dist/lib/config/software.js +345 -0
- package/dist/lib/constants/dev-environment.js +7 -8
- package/dist/lib/constants/vipgo.js +22 -0
- package/dist/lib/dev-environment/dev-environment-cli.js +109 -43
- package/dist/lib/dev-environment/dev-environment-core.js +25 -3
- package/dist/lib/dev-environment/dev-environment-lando.js +5 -4
- package/dist/lib/site-import/db-file-import.js +1 -1
- package/dist/lib/user-error.js +14 -0
- package/dist/lib/validations/is-multisite-domain-mapped.js +161 -0
- package/dist/lib/validations/line-by-line.js +3 -2
- package/dist/lib/validations/site-type.js +27 -1
- package/dist/lib/validations/utils.js +45 -0
- package/npm-shrinkwrap.json +134 -35
- package/package.json +5 -2
|
@@ -0,0 +1,90 @@
|
|
|
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 _tracker = require("../lib/tracker");
|
|
18
|
+
|
|
19
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
20
|
+
|
|
21
|
+
var _format = require("../lib/cli/format");
|
|
22
|
+
|
|
23
|
+
var _software = require("../lib/config/software");
|
|
24
|
+
|
|
25
|
+
var _userError = _interopRequireDefault(require("../lib/user-error"));
|
|
26
|
+
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
+
|
|
29
|
+
// Command examples
|
|
30
|
+
const examples = [{
|
|
31
|
+
usage: 'vip config software get wordpress --format json',
|
|
32
|
+
description: 'Read current software settings for WordPress in JSON format'
|
|
33
|
+
}, {
|
|
34
|
+
usage: 'vip config software get',
|
|
35
|
+
description: 'Read current software settings for all components'
|
|
36
|
+
}];
|
|
37
|
+
(0, _command.default)({
|
|
38
|
+
appContext: true,
|
|
39
|
+
appQuery: _software.appQuery,
|
|
40
|
+
appQueryFragments: _software.appQueryFragments,
|
|
41
|
+
envContext: true,
|
|
42
|
+
wildcardCommand: true,
|
|
43
|
+
format: true,
|
|
44
|
+
usage: 'vip config software get <wordpress|php|nodejs|muplugins>'
|
|
45
|
+
}).examples(examples).argv(process.argv, async (arg, opt) => {
|
|
46
|
+
var _opt$env;
|
|
47
|
+
|
|
48
|
+
const trackingInfo = {
|
|
49
|
+
environment_id: (_opt$env = opt.env) === null || _opt$env === void 0 ? void 0 : _opt$env.id,
|
|
50
|
+
args: JSON.stringify(arg)
|
|
51
|
+
};
|
|
52
|
+
await (0, _tracker.trackEvent)('config_software_get_execute', trackingInfo);
|
|
53
|
+
const {
|
|
54
|
+
softwareSettings
|
|
55
|
+
} = opt.env;
|
|
56
|
+
|
|
57
|
+
if (softwareSettings === null) {
|
|
58
|
+
throw new _userError.default('Software settings are not supported for this environment.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let chosenSettings = [];
|
|
62
|
+
|
|
63
|
+
if (arg.length > 0) {
|
|
64
|
+
const component = arg[0];
|
|
65
|
+
|
|
66
|
+
if (!softwareSettings[component]) {
|
|
67
|
+
throw new _userError.default(`Software settings for ${component} are not supported for this environment.`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
chosenSettings = [softwareSettings[component]];
|
|
71
|
+
} else {
|
|
72
|
+
chosenSettings = [softwareSettings.wordpress, softwareSettings.php, softwareSettings.muplugins, softwareSettings.nodejs];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const preFormatted = chosenSettings.filter(softwareSetting => !!softwareSetting).map(softwareSetting => {
|
|
76
|
+
let version = softwareSetting.current.version;
|
|
77
|
+
|
|
78
|
+
if (softwareSetting.slug === 'wordpress' && !softwareSetting.pinned) {
|
|
79
|
+
version += ' (managed updates)';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
name: softwareSetting.name,
|
|
84
|
+
slug: softwareSetting.slug,
|
|
85
|
+
version
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
console.log((0, _format.formatData)(preFormatted, opt.format));
|
|
89
|
+
await (0, _tracker.trackEvent)('config_software_get_success', trackingInfo);
|
|
90
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
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 _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
|
+
|
|
19
|
+
var _software = require("../lib/config/software");
|
|
20
|
+
|
|
21
|
+
var _progress = require("../lib/cli/progress");
|
|
22
|
+
|
|
23
|
+
var _userError = _interopRequireDefault(require("../lib/user-error"));
|
|
24
|
+
|
|
25
|
+
var _tracker = require("../lib/tracker");
|
|
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:config-software');
|
|
33
|
+
const UPDATE_SOFTWARE_PROGRESS_STEPS = [{
|
|
34
|
+
id: 'trigger',
|
|
35
|
+
name: 'Trigger software update'
|
|
36
|
+
}, {
|
|
37
|
+
id: 'process',
|
|
38
|
+
name: 'Process software update'
|
|
39
|
+
}];
|
|
40
|
+
const cmd = (0, _command.default)({
|
|
41
|
+
appContext: true,
|
|
42
|
+
appQuery: _software.appQuery,
|
|
43
|
+
appQueryFragments: _software.appQueryFragments,
|
|
44
|
+
envContext: true,
|
|
45
|
+
wildcardCommand: true,
|
|
46
|
+
usage: 'vip config software update <wordpress|php|nodejs|muplugins> <version>'
|
|
47
|
+
}).examples([{
|
|
48
|
+
usage: 'vip config software update wordpress 6.0',
|
|
49
|
+
description: 'Update WordPress to 6.0.x'
|
|
50
|
+
}, {
|
|
51
|
+
usage: 'vip config software update nodejs 16',
|
|
52
|
+
description: 'Update Node.js to v16'
|
|
53
|
+
}]);
|
|
54
|
+
cmd.option('force', 'Auto-confirm update');
|
|
55
|
+
cmd.argv(process.argv, async (arg, opt) => {
|
|
56
|
+
const {
|
|
57
|
+
app,
|
|
58
|
+
env
|
|
59
|
+
} = opt;
|
|
60
|
+
const {
|
|
61
|
+
softwareSettings
|
|
62
|
+
} = env;
|
|
63
|
+
const baseTrackingInfo = {
|
|
64
|
+
environment_id: env === null || env === void 0 ? void 0 : env.id,
|
|
65
|
+
args: JSON.stringify(arg)
|
|
66
|
+
};
|
|
67
|
+
await (0, _tracker.trackEvent)('config_software_update_execute', baseTrackingInfo);
|
|
68
|
+
let updateData = {};
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
if (softwareSettings === null) {
|
|
72
|
+
throw new _userError.default('Software settings are not supported for this environment.');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const updateOptions = {
|
|
76
|
+
force: !!opt.force
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (arg.length > 0) {
|
|
80
|
+
updateOptions.component = arg[0];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (arg.length > 1) {
|
|
84
|
+
updateOptions.version = arg[1];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
updateData = await (0, _software.promptForUpdate)(app.typeId, updateOptions, softwareSettings);
|
|
88
|
+
const hasProcessJob = updateData.component !== 'nodejs';
|
|
89
|
+
const steps = hasProcessJob ? UPDATE_SOFTWARE_PROGRESS_STEPS : [UPDATE_SOFTWARE_PROGRESS_STEPS[0]];
|
|
90
|
+
const progressTracker = new _progress.ProgressTracker(steps);
|
|
91
|
+
progressTracker.startPrinting();
|
|
92
|
+
progressTracker.stepRunning('trigger');
|
|
93
|
+
const triggerResult = await (0, _software.triggerUpdate)({
|
|
94
|
+
appId: app.id,
|
|
95
|
+
envId: env.id,
|
|
96
|
+
...updateData
|
|
97
|
+
});
|
|
98
|
+
debug('Triggered update with result', triggerResult);
|
|
99
|
+
progressTracker.stepSuccess('trigger');
|
|
100
|
+
|
|
101
|
+
if (hasProcessJob) {
|
|
102
|
+
const {
|
|
103
|
+
ok,
|
|
104
|
+
errorMessage
|
|
105
|
+
} = await (0, _software.getUpdateResult)(app.id, env.id);
|
|
106
|
+
|
|
107
|
+
if (ok) {
|
|
108
|
+
progressTracker.stepSuccess('process');
|
|
109
|
+
} else {
|
|
110
|
+
progressTracker.stepFailed('process');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
progressTracker.print();
|
|
114
|
+
progressTracker.stopPrinting();
|
|
115
|
+
|
|
116
|
+
if (ok) {
|
|
117
|
+
console.log(_chalk.default.green('✓') + ' Software update complete');
|
|
118
|
+
} else {
|
|
119
|
+
throw Error(errorMessage);
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
progressTracker.print();
|
|
123
|
+
progressTracker.stopPrinting();
|
|
124
|
+
const deploymentsLink = `https://dashboard.wpvip.com/apps/${app.id}/${env.uniqueLabel}/deploys`;
|
|
125
|
+
const message = ` A new build of the application code has been initiated and will be deployed using Node.js v${updateData.version} when the build is successful\n` + `View the deployments page in VIP Dashboard for progress updates. - ${deploymentsLink}`;
|
|
126
|
+
console.log(_chalk.default.green('✓') + message);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
await (0, _tracker.trackEvent)('config_software_update_success', { ...baseTrackingInfo,
|
|
130
|
+
...updateData
|
|
131
|
+
});
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (error instanceof _userError.default) {
|
|
134
|
+
await (0, _tracker.trackEvent)('config_software_update_success', { ...baseTrackingInfo,
|
|
135
|
+
...updateData,
|
|
136
|
+
user_error: error === null || error === void 0 ? void 0 : error.message
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
await (0, _tracker.trackEvent)('config_software_update_error', { ...baseTrackingInfo,
|
|
140
|
+
...updateData,
|
|
141
|
+
error: error === null || error === void 0 ? void 0 : error.message
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
usage: 'vip config software <action>'
|
|
24
|
+
}).command('get', 'Read current software settings').command('update', 'Update software settings').examples([{
|
|
25
|
+
usage: 'vip config software update <wordpress|php|nodejs|muplugins> <version>',
|
|
26
|
+
description: 'Update <component> to <version>'
|
|
27
|
+
}]).argv(process.argv);
|
package/dist/bin/vip-config.js
CHANGED
|
@@ -15,6 +15,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
|
|
16
16
|
(0, _command.default)({
|
|
17
17
|
requiredArgs: 2
|
|
18
|
-
}).command('envvar', 'Manage environment variables for an application environment').argv(process.argv, async () => {
|
|
18
|
+
}).command('envvar', 'Manage environment variables for an application environment').command('software', 'Software management').argv(process.argv, async () => {
|
|
19
19
|
process.exit(0);
|
|
20
20
|
});
|
|
@@ -49,26 +49,28 @@ const examples = [{
|
|
|
49
49
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --slug=test`,
|
|
50
50
|
description: 'Assigning unique slugs to environments allows multiple environments to be created.'
|
|
51
51
|
}, {
|
|
52
|
-
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite --wordpress="5.8" --
|
|
53
|
-
description: 'Creates a local multisite dev environment using WP 5.8 and
|
|
52
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} create --multisite --wordpress="5.8" --app-code="~/git/my_code"`,
|
|
53
|
+
description: 'Creates a local multisite dev environment using WP 5.8 and application code is expected to be in "~/git/my_code"'
|
|
54
54
|
}];
|
|
55
|
-
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,
|
|
56
|
-
var _value$toLowerCase;
|
|
57
|
-
|
|
58
|
-
return 'false' !== (value === null || value === void 0 ? void 0 : (_value$toLowerCase = value.toLowerCase) === null || _value$toLowerCase === void 0 ? void 0 : _value$toLowerCase.call(value));
|
|
59
|
-
});
|
|
55
|
+
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.processBooleanOption);
|
|
60
56
|
(0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
|
|
61
57
|
cmd.examples(examples);
|
|
62
58
|
cmd.argv(process.argv, async (arg, opt) => {
|
|
63
59
|
await (0, _devEnvironmentCli.validateDependencies)();
|
|
64
|
-
const
|
|
60
|
+
const environmentNameOptions = {
|
|
61
|
+
slug: opt.slug,
|
|
62
|
+
app: opt.app,
|
|
63
|
+
env: opt.env,
|
|
64
|
+
allowAppEnv: true
|
|
65
|
+
};
|
|
66
|
+
const slug = (0, _devEnvironmentCli.getEnvironmentName)(environmentNameOptions);
|
|
65
67
|
debug('Args: ', arg, 'Options: ', opt);
|
|
66
68
|
const trackingInfo = {
|
|
67
69
|
slug
|
|
68
70
|
};
|
|
69
71
|
await (0, _tracker.trackEvent)('dev_env_create_command_execute', trackingInfo);
|
|
70
72
|
|
|
71
|
-
const startCommand = _chalk.default.bold((0, _devEnvironmentCli.getEnvironmentStartCommand)(
|
|
73
|
+
const startCommand = _chalk.default.bold((0, _devEnvironmentCli.getEnvironmentStartCommand)(slug));
|
|
72
74
|
|
|
73
75
|
const environmentAlreadyExists = (0, _devEnvironmentCore.doesEnvironmentExist)(slug);
|
|
74
76
|
|
|
@@ -44,7 +44,7 @@ const examples = [{
|
|
|
44
44
|
}];
|
|
45
45
|
(0, _command.default)({
|
|
46
46
|
requiredArgs: 1
|
|
47
|
-
}).option('slug', 'Custom name of the dev environment').option('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) => {
|
|
47
|
+
}).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) => {
|
|
48
48
|
await (0, _devEnvironmentCli.validateDependencies)();
|
|
49
49
|
const [fileName] = unmatchedArgs;
|
|
50
50
|
const {
|
|
@@ -31,9 +31,6 @@ const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
|
31
31
|
const examples = [{
|
|
32
32
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} info --all`,
|
|
33
33
|
description: 'Return information about all local dev environments'
|
|
34
|
-
}, {
|
|
35
|
-
usage: `vip @123 ${_devEnvironment.DEV_ENVIRONMENT_SUBCOMMAND} info`,
|
|
36
|
-
description: 'Return information about dev environment for site 123'
|
|
37
34
|
}, {
|
|
38
35
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} info --slug=my_site`,
|
|
39
36
|
description: 'Return information about a local dev environment named "my_site"'
|
|
@@ -38,7 +38,7 @@ const examples = [{
|
|
|
38
38
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start`,
|
|
39
39
|
description: 'Starts a local dev environment'
|
|
40
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) => {
|
|
41
|
+
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip propting for wordpress update if non latest').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
42
42
|
await (0, _devEnvironmentCli.validateDependencies)();
|
|
43
43
|
const startProcessing = new Date();
|
|
44
44
|
const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
@@ -46,7 +46,8 @@ const examples = [{
|
|
|
46
46
|
await (0, _tracker.trackEvent)('dev_env_start_command_execute', trackingInfo);
|
|
47
47
|
debug('Args: ', arg, 'Options: ', opt);
|
|
48
48
|
const options = {
|
|
49
|
-
skipRebuild: !!opt.skipRebuild
|
|
49
|
+
skipRebuild: !!opt.skipRebuild,
|
|
50
|
+
skipWpVersionsCheck: !!opt.skipWpVersionsCheck
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
try {
|
|
@@ -59,16 +59,16 @@ cmd.argv(process.argv, async (arg, opt) => {
|
|
|
59
59
|
...opt
|
|
60
60
|
};
|
|
61
61
|
const defaultOptions = {
|
|
62
|
-
|
|
62
|
+
appCode: currentInstanceData.appCode.dir || currentInstanceData.appCode.tag || 'latest',
|
|
63
63
|
muPlugins: currentInstanceData.muPlugins.dir || currentInstanceData.muPlugins.tag || 'latest',
|
|
64
64
|
wordpress: currentInstanceData.wordpress.tag,
|
|
65
|
+
elasticsearchEnabled: currentInstanceData.elasticsearchEnabled,
|
|
65
66
|
elasticsearch: currentInstanceData.elasticsearch,
|
|
66
67
|
php: currentInstanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS.default,
|
|
67
68
|
mariadb: currentInstanceData.mariadb,
|
|
68
69
|
statsd: currentInstanceData.statsd,
|
|
69
70
|
phpmyadmin: currentInstanceData.phpmyadmin,
|
|
70
71
|
xdebug: currentInstanceData.xdebug,
|
|
71
|
-
enterpriseSearchEnabled: currentInstanceData.enterpriseSearchEnabled,
|
|
72
72
|
mediaRedirectDomain: currentInstanceData.mediaRedirectDomain,
|
|
73
73
|
multisite: false,
|
|
74
74
|
title: ''
|
|
@@ -249,7 +249,8 @@ async function validateAndGetTableNames({
|
|
|
249
249
|
skipValidate,
|
|
250
250
|
appId,
|
|
251
251
|
envId,
|
|
252
|
-
fileNameToUpload
|
|
252
|
+
fileNameToUpload,
|
|
253
|
+
searchReplace
|
|
253
254
|
}) {
|
|
254
255
|
const validations = [_sql.staticSqlValidations, _siteType.siteTypeValidations];
|
|
255
256
|
|
|
@@ -259,10 +260,10 @@ async function validateAndGetTableNames({
|
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
try {
|
|
262
|
-
await (0, _lineByLine.fileLineValidations)(appId, envId, fileNameToUpload, validations);
|
|
263
|
+
await (0, _lineByLine.fileLineValidations)(appId, envId, fileNameToUpload, validations, searchReplace);
|
|
263
264
|
} catch (validateErr) {
|
|
264
265
|
console.log('');
|
|
265
|
-
exit.withError(`${validateErr.message}
|
|
266
|
+
exit.withError(`${validateErr.message}\n
|
|
266
267
|
If you are confident the file does not contain unsupported statements, you can retry the command with the ${_chalk.default.yellow('--skip-validate')} option.
|
|
267
268
|
`);
|
|
268
269
|
} // this can only be called after static validation of the SQL file
|
|
@@ -407,7 +408,8 @@ const displayPlaybook = ({
|
|
|
407
408
|
skipValidate,
|
|
408
409
|
appId,
|
|
409
410
|
envId,
|
|
410
|
-
fileNameToUpload
|
|
411
|
+
fileNameToUpload,
|
|
412
|
+
searchReplace
|
|
411
413
|
}); // display playbook of what will happen during execution
|
|
412
414
|
|
|
413
415
|
displayPlaybook({
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _http = _interopRequireDefault(require("../../api/http"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
@@ -75,10 +75,7 @@ class Pendo {
|
|
|
75
75
|
visitorId: `${this.context.userId}`
|
|
76
76
|
};
|
|
77
77
|
debug('send()', body);
|
|
78
|
-
const {
|
|
79
|
-
apiFetch
|
|
80
|
-
} = await (0, _api.default)();
|
|
81
|
-
const response = await apiFetch(Pendo.ENDPOINT, {
|
|
78
|
+
const response = await (0, _http.default)(Pendo.ENDPOINT, {
|
|
82
79
|
method: 'POST',
|
|
83
80
|
body
|
|
84
81
|
});
|
package/dist/lib/api/app.js
CHANGED
|
@@ -18,11 +18,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
/**
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
|
-
async function _default(app, fields) {
|
|
21
|
+
async function _default(app, fields, fragments) {
|
|
22
22
|
if (!fields) {
|
|
23
23
|
fields = 'id,name';
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
if (!fragments) {
|
|
27
|
+
fragments = '';
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
const api = await (0, _api.default)();
|
|
27
31
|
|
|
28
32
|
if (isNaN(app)) {
|
|
@@ -36,7 +40,8 @@ async function _default(app, fields) {
|
|
|
36
40
|
${fields}
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
|
-
}
|
|
43
|
+
}
|
|
44
|
+
${fragments || ''}`,
|
|
40
45
|
variables: {
|
|
41
46
|
name: app
|
|
42
47
|
}
|
|
@@ -56,7 +61,8 @@ async function _default(app, fields) {
|
|
|
56
61
|
app( id: $id ){
|
|
57
62
|
${fields}
|
|
58
63
|
}
|
|
59
|
-
}
|
|
64
|
+
}
|
|
65
|
+
${fragments || ''}`,
|
|
60
66
|
variables: {
|
|
61
67
|
id: app
|
|
62
68
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
9
|
+
|
|
10
|
+
var _token = _interopRequireDefault(require("../token"));
|
|
11
|
+
|
|
12
|
+
var _env = _interopRequireDefault(require("../env"));
|
|
13
|
+
|
|
14
|
+
var _proxyAgent = require("../http/proxy-agent");
|
|
15
|
+
|
|
16
|
+
var _api = require("../api");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* External dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
const debug = require('debug')('@automattic/vip:http');
|
|
28
|
+
/**
|
|
29
|
+
* Call the Public API with an arbitrary path (e.g. to connect to REST endpoints).
|
|
30
|
+
* This will include the token in an Authorization header so requests are "logged-in."
|
|
31
|
+
*
|
|
32
|
+
* This is simply a wrapper around node-fetch
|
|
33
|
+
*
|
|
34
|
+
* @param {string} path API path to pass to `fetch` -- will be prefixed by the API_HOST
|
|
35
|
+
* @param {object} options options to pass to `fetch`
|
|
36
|
+
* @returns {Promise} Return value of the `fetch` call
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var _default = async (path, options = {}) => {
|
|
41
|
+
let url = path; // For convenience, we support just passing in the path to this function...
|
|
42
|
+
// but some things (Apollo) always pass the full url
|
|
43
|
+
|
|
44
|
+
if (!path.startsWith(_api.API_HOST)) {
|
|
45
|
+
url = `${_api.API_HOST}${path}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const authToken = await _token.default.get();
|
|
49
|
+
const headers = {
|
|
50
|
+
'User-Agent': _env.default.userAgent,
|
|
51
|
+
Authorization: authToken ? `Bearer ${authToken.raw}` : null
|
|
52
|
+
};
|
|
53
|
+
const proxyAgent = (0, _proxyAgent.createProxyAgent)(url);
|
|
54
|
+
debug('running fetch', url);
|
|
55
|
+
return (0, _nodeFetch.default)(url, { ...options,
|
|
56
|
+
...{
|
|
57
|
+
agent: proxyAgent,
|
|
58
|
+
headers: { ...headers,
|
|
59
|
+
...{
|
|
60
|
+
'Content-Type': 'application/json'
|
|
61
|
+
},
|
|
62
|
+
...options.headers
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
...{
|
|
66
|
+
body: typeof options.body === 'object' ? JSON.stringify(options.body) : options.body
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.default = _default;
|
package/dist/lib/api.js
CHANGED
|
@@ -97,10 +97,13 @@ async function API({
|
|
|
97
97
|
return forward(operation);
|
|
98
98
|
});
|
|
99
99
|
const proxyAgent = (0, _proxyAgent.createProxyAgent)(API_URL);
|
|
100
|
+
|
|
101
|
+
const http = require("./api/http").default;
|
|
102
|
+
|
|
100
103
|
const httpLink = new _core.HttpLink({
|
|
101
104
|
uri: API_URL,
|
|
102
105
|
headers,
|
|
103
|
-
fetch:
|
|
106
|
+
fetch: http,
|
|
104
107
|
fetchOptions: {
|
|
105
108
|
agent: proxyAgent
|
|
106
109
|
}
|
|
@@ -109,28 +112,5 @@ async function API({
|
|
|
109
112
|
link: _core2.ApolloLink.from([withToken, errorLink, authLink, httpLink]),
|
|
110
113
|
cache: new _core.InMemoryCache()
|
|
111
114
|
});
|
|
112
|
-
/**
|
|
113
|
-
* Call the Public API with an arbitrary path (e.g. to connect to REST endpoints).
|
|
114
|
-
* This will include the token in an Authorization header so requests are "logged-in."
|
|
115
|
-
* @param {string} path API path to pass to `fetch` -- will be prefixed by the API_HOST
|
|
116
|
-
* @param {object} options options to pass to `fetch`
|
|
117
|
-
* @returns {Promise} Return value of the `fetch` call
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
apiClient.apiFetch = (path, options = {}) => (0, _nodeFetch.default)(`${API_HOST}${path}`, { ...options,
|
|
121
|
-
...{
|
|
122
|
-
agent: proxyAgent,
|
|
123
|
-
headers: { ...headers,
|
|
124
|
-
...{
|
|
125
|
-
'Content-Type': 'application/json'
|
|
126
|
-
},
|
|
127
|
-
...options.headers
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
...{
|
|
131
|
-
body: typeof options.body === 'object' ? JSON.stringify(options.body) : options.body
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
115
|
return apiClient;
|
|
136
116
|
}
|
package/dist/lib/app.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isAppWordPress = isAppWordPress;
|
|
7
|
+
exports.isAppNodejs = isAppNodejs;
|
|
8
|
+
|
|
9
|
+
var _vipgo = require("./constants/vipgo");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* External dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Is this a WordPress application?
|
|
21
|
+
* @param {int} appTypeId application type ID
|
|
22
|
+
* @constructor
|
|
23
|
+
*/
|
|
24
|
+
function isAppWordPress(appTypeId) {
|
|
25
|
+
return _vipgo.WORDPRESS_SITE_TYPE_IDS.includes(appTypeId);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Is this a Nodejs application?
|
|
29
|
+
* @param {int} appTypeId application type ID
|
|
30
|
+
* @constructor
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function isAppNodejs(appTypeId) {
|
|
35
|
+
return _vipgo.NODEJS_SITE_TYPE_IDS.includes(appTypeId);
|
|
36
|
+
}
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -39,6 +39,8 @@ var exit = _interopRequireWildcard(require("./exit"));
|
|
|
39
39
|
|
|
40
40
|
var _debug = _interopRequireDefault(require("debug"));
|
|
41
41
|
|
|
42
|
+
var _userError = _interopRequireDefault(require("../user-error"));
|
|
43
|
+
|
|
42
44
|
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); }
|
|
43
45
|
|
|
44
46
|
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; }
|
|
@@ -56,6 +58,10 @@ function uncaughtError(err) {
|
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
if (err instanceof _userError.default) {
|
|
62
|
+
exit.withError(err.message);
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
console.log(_chalk.default.red('✕'), 'Please contact VIP Support with the following information:');
|
|
60
66
|
console.log(_chalk.default.dim(err.stack));
|
|
61
67
|
exit.withError('Unexpected error');
|
|
@@ -189,7 +195,8 @@ _args.default.argv = async function (argv, cb) {
|
|
|
189
195
|
${_opts.appQuery}
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
|
-
}
|
|
198
|
+
}
|
|
199
|
+
${_opts.appQueryFragments || ''}`,
|
|
193
200
|
variables: {
|
|
194
201
|
first: 100,
|
|
195
202
|
after: null // TODO make dynamic?
|
|
@@ -251,7 +258,7 @@ _args.default.argv = async function (argv, cb) {
|
|
|
251
258
|
let appLookup;
|
|
252
259
|
|
|
253
260
|
try {
|
|
254
|
-
appLookup = await (0, _app.default)(options.app, _opts.appQuery);
|
|
261
|
+
appLookup = await (0, _app.default)(options.app, _opts.appQuery, _opts.appQueryFragments);
|
|
255
262
|
} catch (err) {
|
|
256
263
|
await (0, _tracker.trackEvent)('command_appcontext_param_error', {
|
|
257
264
|
error: 'App lookup failed'
|