@automattic/vip 3.23.1 → 3.23.3
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/dist/bin/vip-config-envvar-delete.js +7 -3
- package/dist/bin/vip-config-envvar-set.js +9 -3
- package/dist/bin/vip-import-media.js +9 -1
- package/dist/lib/cli/command.js +33 -24
- package/dist/lib/constants/dev-environment.js +0 -4
- package/dist/lib/envvar/api-delete.js +16 -4
- package/dist/lib/envvar/api-set.js +17 -4
- package/dist/lib/envvar/api.js +1 -0
- package/dist/lib/envvar/input.js +23 -0
- package/npm-shrinkwrap.json +429 -317
- package/package.json +8 -8
|
@@ -63,7 +63,11 @@ async function deleteEnvVarCommand(arg, opt) {
|
|
|
63
63
|
(0, _input.cancel)();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
let reloadManifest = false;
|
|
67
|
+
if (!opt.skipConfirmation) {
|
|
68
|
+
reloadManifest = await (0, _input.promptForReloadManifest)(opt.app.typeId);
|
|
69
|
+
}
|
|
70
|
+
await (0, _api.deleteEnvVar)(opt.app.id, opt.env.id, name, reloadManifest).catch(async err => {
|
|
67
71
|
await (0, _tracker.trackEvent)('envvar_delete_mutation_error', {
|
|
68
72
|
...trackingParams,
|
|
69
73
|
error: err.message
|
|
@@ -72,8 +76,8 @@ async function deleteEnvVarCommand(arg, opt) {
|
|
|
72
76
|
});
|
|
73
77
|
await (0, _tracker.trackEvent)('envvar_delete_command_success', trackingParams);
|
|
74
78
|
console.log(_chalk.default.green(`Successfully deleted environment variable ${JSON.stringify(name)}`));
|
|
75
|
-
if (!opt.skipConfirmation) {
|
|
76
|
-
|
|
79
|
+
if (!opt.skipConfirmation && !reloadManifest) {
|
|
80
|
+
(0, _input.showDeployWarning)();
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
(0, _command.default)({
|
|
@@ -82,7 +82,11 @@ async function setEnvVarCommand(arg, opt) {
|
|
|
82
82
|
(0, _input.cancel)();
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
let reloadManifest = false;
|
|
86
|
+
if (!opt.skipConfirmation) {
|
|
87
|
+
reloadManifest = await (0, _input.promptForReloadManifest)(opt.app.typeId);
|
|
88
|
+
}
|
|
89
|
+
await (0, _api.setEnvVar)(opt.app.id, opt.env.id, name, value, reloadManifest).catch(async err => {
|
|
86
90
|
await (0, _tracker.trackEvent)('envvar_set_mutation_error', {
|
|
87
91
|
...trackingParams,
|
|
88
92
|
error: err.message
|
|
@@ -91,8 +95,10 @@ async function setEnvVarCommand(arg, opt) {
|
|
|
91
95
|
});
|
|
92
96
|
await (0, _tracker.trackEvent)('envvar_set_command_success', trackingParams);
|
|
93
97
|
console.log(_chalk.default.green(`Successfully set environment variable ${JSON.stringify(name)}`));
|
|
94
|
-
if (
|
|
95
|
-
console.log(_chalk.default.
|
|
98
|
+
if (reloadManifest) {
|
|
99
|
+
console.log(_chalk.default.yellow('Environment variable is active and available.'));
|
|
100
|
+
} else if (!opt.skipConfirmation) {
|
|
101
|
+
(0, _input.showDeployWarning)();
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
(0, _command.default)({
|
|
@@ -131,6 +131,7 @@ Are you sure you want to import the contents of the URL?
|
|
|
131
131
|
sourceIsLocal = true;
|
|
132
132
|
const fileMeta = await (0, _clientFileUploader.getFileMeta)(fileNameOrURL);
|
|
133
133
|
fileMeta.fileName = fileNameOrURL;
|
|
134
|
+
let lastProgress = '';
|
|
134
135
|
const {
|
|
135
136
|
fileMeta: {
|
|
136
137
|
basename
|
|
@@ -141,8 +142,15 @@ Are you sure you want to import the contents of the URL?
|
|
|
141
142
|
app,
|
|
142
143
|
env,
|
|
143
144
|
fileMeta,
|
|
144
|
-
progressCallback: percentage =>
|
|
145
|
+
progressCallback: percentage => {
|
|
146
|
+
if (percentage === lastProgress) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
lastProgress = percentage;
|
|
150
|
+
process.stdout.write(`\rUpload progress: ${percentage} `);
|
|
151
|
+
}
|
|
145
152
|
});
|
|
153
|
+
process.stdout.write('\n');
|
|
146
154
|
|
|
147
155
|
// small debug info to keep variables used
|
|
148
156
|
debug('Uploaded file basename:', basename);
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -440,30 +440,39 @@ _args.default.argv = async function (argv, cb) {
|
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
case 'import-media':
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
443
|
+
{
|
|
444
|
+
const isUrl = this.sub && (String(this.sub).startsWith('http://') || String(this.sub).startsWith('https://'));
|
|
445
|
+
const archiveLabel = isUrl ? 'Archive URL' : 'Archive Path';
|
|
446
|
+
info.push({
|
|
447
|
+
key: archiveLabel,
|
|
448
|
+
value: _chalk.default.blue.underline(this.sub)
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// Update confirmation message if it's a local path
|
|
452
|
+
if (!isUrl && 'string' === typeof _opts.requireConfirm) {
|
|
453
|
+
message = message.replaceAll('the URL', 'the path');
|
|
454
|
+
}
|
|
455
|
+
options.overwriteExistingFiles = Object.hasOwn(options, 'overwriteExistingFiles') && Boolean(options.overwriteExistingFiles) && !['false', 'no'].includes(options.overwriteExistingFiles);
|
|
456
|
+
info.push({
|
|
457
|
+
key: 'Overwrite any existing files',
|
|
458
|
+
value: options.overwriteExistingFiles ? '✅ Yes' : `${_chalk.default.red('x')} No`
|
|
459
|
+
});
|
|
460
|
+
options.importIntermediateImages = Object.hasOwn(options, 'importIntermediateImages') && Boolean(options.importIntermediateImages) && !['false', 'no'].includes(options.importIntermediateImages);
|
|
461
|
+
info.push({
|
|
462
|
+
key: 'Import intermediate image files',
|
|
463
|
+
value: options.importIntermediateImages ? '✅ Yes' : `${_chalk.default.red('x')} No`
|
|
464
|
+
});
|
|
465
|
+
options.exportFileErrorsToJson = Object.hasOwn(options, 'exportFileErrorsToJson') && Boolean(options.exportFileErrorsToJson) && !['false', 'no'].includes(options.exportFileErrorsToJson);
|
|
466
|
+
info.push({
|
|
467
|
+
key: 'Export any file errors encountered to a JSON file instead of a plain text file.',
|
|
468
|
+
value: options.exportFileErrorsToJson ? '✅ Yes' : `${_chalk.default.red('x')} No`
|
|
469
|
+
});
|
|
470
|
+
info.push({
|
|
471
|
+
key: 'Download file-error logs?',
|
|
472
|
+
value: options.saveErrorLog
|
|
473
|
+
});
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
467
476
|
default:
|
|
468
477
|
}
|
|
469
478
|
const skipPrompt = _opts.skipConfirmPrompt || false;
|
|
@@ -18,10 +18,6 @@ const DEV_ENVIRONMENT_PHP_VERSIONS = exports.DEV_ENVIRONMENT_PHP_VERSIONS = {
|
|
|
18
18
|
image: 'ghcr.io/automattic/vip-container-images/php-fpm:8.2',
|
|
19
19
|
label: '8.2 (recommended)'
|
|
20
20
|
},
|
|
21
|
-
8.1: {
|
|
22
|
-
image: 'ghcr.io/automattic/vip-container-images/php-fpm:8.1',
|
|
23
|
-
label: '8.1'
|
|
24
|
-
},
|
|
25
21
|
8.3: {
|
|
26
22
|
image: 'ghcr.io/automattic/vip-container-images/php-fpm:8.3',
|
|
27
23
|
label: '8.3'
|
|
@@ -6,9 +6,20 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
|
6
6
|
var _api = _interopRequireDefault(require("../../lib/api"));
|
|
7
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
const mutation = (0, _graphqlTag.default)`
|
|
9
|
-
mutation DeleteEnvironmentVariable(
|
|
9
|
+
mutation DeleteEnvironmentVariable(
|
|
10
|
+
$appId: Int!
|
|
11
|
+
$envId: Int!
|
|
12
|
+
$name: String!
|
|
13
|
+
$reloadManifest: Boolean!
|
|
14
|
+
) {
|
|
10
15
|
deleteEnvironmentVariable(
|
|
11
|
-
input: {
|
|
16
|
+
input: {
|
|
17
|
+
applicationId: $appId
|
|
18
|
+
environmentId: $envId
|
|
19
|
+
name: $name
|
|
20
|
+
value: ""
|
|
21
|
+
reloadManifest: $reloadManifest
|
|
22
|
+
}
|
|
12
23
|
) {
|
|
13
24
|
environmentVariables {
|
|
14
25
|
total
|
|
@@ -19,12 +30,13 @@ const mutation = (0, _graphqlTag.default)`
|
|
|
19
30
|
}
|
|
20
31
|
}
|
|
21
32
|
`;
|
|
22
|
-
async function deleteEnvVar(appId, envId, name) {
|
|
33
|
+
async function deleteEnvVar(appId, envId, name, reloadManifest = false) {
|
|
23
34
|
const api = (0, _api.default)();
|
|
24
35
|
const variables = {
|
|
25
36
|
appId,
|
|
26
37
|
envId,
|
|
27
|
-
name
|
|
38
|
+
name,
|
|
39
|
+
reloadManifest
|
|
28
40
|
};
|
|
29
41
|
return api.mutate({
|
|
30
42
|
mutation,
|
|
@@ -6,9 +6,21 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
|
6
6
|
var _api = _interopRequireDefault(require("../../lib/api"));
|
|
7
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
const mutation = (0, _graphqlTag.default)`
|
|
9
|
-
mutation AddEnvironmentVariable(
|
|
9
|
+
mutation AddEnvironmentVariable(
|
|
10
|
+
$appId: Int!
|
|
11
|
+
$envId: Int!
|
|
12
|
+
$name: String!
|
|
13
|
+
$value: String!
|
|
14
|
+
$reloadManifest: Boolean!
|
|
15
|
+
) {
|
|
10
16
|
addEnvironmentVariable(
|
|
11
|
-
input: {
|
|
17
|
+
input: {
|
|
18
|
+
applicationId: $appId
|
|
19
|
+
environmentId: $envId
|
|
20
|
+
name: $name
|
|
21
|
+
value: $value
|
|
22
|
+
reloadManifest: $reloadManifest
|
|
23
|
+
}
|
|
12
24
|
) {
|
|
13
25
|
environmentVariables {
|
|
14
26
|
total
|
|
@@ -19,13 +31,14 @@ const mutation = (0, _graphqlTag.default)`
|
|
|
19
31
|
}
|
|
20
32
|
}
|
|
21
33
|
`;
|
|
22
|
-
async function setEnvVar(appId, envId, name, value) {
|
|
34
|
+
async function setEnvVar(appId, envId, name, value, reloadManifest = false) {
|
|
23
35
|
const api = (0, _api.default)();
|
|
24
36
|
const variables = {
|
|
25
37
|
appId,
|
|
26
38
|
envId,
|
|
27
39
|
name,
|
|
28
|
-
value
|
|
40
|
+
value,
|
|
41
|
+
reloadManifest
|
|
29
42
|
};
|
|
30
43
|
return api.mutate({
|
|
31
44
|
mutation,
|
package/dist/lib/envvar/api.js
CHANGED
package/dist/lib/envvar/input.js
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.cancel = cancel;
|
|
5
5
|
exports.confirm = confirm;
|
|
6
|
+
exports.promptForReloadManifest = promptForReloadManifest;
|
|
6
7
|
exports.promptForValue = promptForValue;
|
|
8
|
+
exports.showDeployWarning = showDeployWarning;
|
|
7
9
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
10
|
var _enquirer = require("enquirer");
|
|
11
|
+
var _app = require("../app");
|
|
9
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
13
|
function cancel() {
|
|
11
14
|
console.log(_chalk.default.yellow('Command cancelled by user.'));
|
|
@@ -31,4 +34,24 @@ async function promptForValue(message, mustMatch) {
|
|
|
31
34
|
}
|
|
32
35
|
});
|
|
33
36
|
return str?.trim() ?? '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Prompts the user to confirm whether to apply the environment variable update now.
|
|
41
|
+
*
|
|
42
|
+
* @param {number} appTypeId - The application type ID
|
|
43
|
+
* @return {Promise<boolean>} Whether to reload the manifest
|
|
44
|
+
*/
|
|
45
|
+
async function promptForReloadManifest(appTypeId) {
|
|
46
|
+
if ((0, _app.isAppNodejs)(appTypeId)) {
|
|
47
|
+
console.log(_chalk.default.yellow(`⚠️ Note: ${_chalk.default.bold('Only applies to runtime variable changes.')} Build-time environment variable changes won't take effect until your next deploy.`));
|
|
48
|
+
}
|
|
49
|
+
return await confirm('Apply this environment variable update now?');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Shows a warning message that the environment variable update won't be available until the next deploy.
|
|
54
|
+
*/
|
|
55
|
+
function showDeployWarning() {
|
|
56
|
+
console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'This environment variable update will not be available until the next code deploy is made to this environment.');
|
|
34
57
|
}
|