@automattic/vip 3.23.0 → 3.23.2

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.
@@ -63,7 +63,11 @@ async function deleteEnvVarCommand(arg, opt) {
63
63
  (0, _input.cancel)();
64
64
  }
65
65
  }
66
- await (0, _api.deleteEnvVar)(opt.app.id, opt.env.id, name).catch(async err => {
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
- console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
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
- await (0, _api.setEnvVar)(opt.app.id, opt.env.id, name, value).catch(async err => {
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 (!opt.skipConfirmation) {
95
- console.log(_chalk.default.bgYellow(_chalk.default.bold('Important:')), 'Updates to environment variables will not be available until the application’s next deploy.');
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)({
@@ -42,14 +42,6 @@ const appQuery = `
42
42
  primaryDomain { name }
43
43
  uniqueLabel
44
44
  isMultisite
45
- wpSitesSDS(first:500) {
46
- total
47
- nodes {
48
- id
49
- blogId
50
- homeUrl
51
- }
52
- }
53
45
  }
54
46
  `;
55
47
  (0, _command.default)({
@@ -188,11 +188,11 @@ class DevEnvSyncSQLCommand {
188
188
  await (0, _promises.pipeline)(streams);
189
189
  _fs.default.renameSync(outputFile, this.sqlFile);
190
190
  }
191
- async getSiteUrlsFromSDS() {
192
- if (this.env.isMultisite && (!this.env.wpSitesSDS?.nodes || !this.env.wpSitesSDS?.total || this.env.wpSitesSDS.nodes.length < this.env.wpSitesSDS.total)) {
191
+ getSiteUrlsFromSDS() {
192
+ if (this.env.isMultisite) {
193
193
  return this.fetchAllSites(Number(this.app.id), Number(this.env.id));
194
194
  }
195
- return this.env.wpSitesSDS?.nodes?.filter(node => Boolean(node)) ?? [];
195
+ return Promise.resolve([]);
196
196
  }
197
197
  fetchSitesPage(api, appId, environmentId, after) {
198
198
  return api.query({
@@ -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($appId: Int!, $envId: Int!, $name: String!) {
9
+ mutation DeleteEnvironmentVariable(
10
+ $appId: Int!
11
+ $envId: Int!
12
+ $name: String!
13
+ $reloadManifest: Boolean!
14
+ ) {
10
15
  deleteEnvironmentVariable(
11
- input: { applicationId: $appId, environmentId: $envId, name: $name, value: "" }
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($appId: Int!, $envId: Int!, $name: String!, $value: String!) {
9
+ mutation AddEnvironmentVariable(
10
+ $appId: Int!
11
+ $envId: Int!
12
+ $name: String!
13
+ $value: String!
14
+ $reloadManifest: Boolean!
15
+ ) {
10
16
  addEnvironmentVariable(
11
- input: { applicationId: $appId, environmentId: $envId, name: $name, value: $value }
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,
@@ -23,6 +23,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
23
23
  const appQuery = exports.appQuery = `
24
24
  id
25
25
  name
26
+ typeId
26
27
  environments {
27
28
  id
28
29
  appId
@@ -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
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "3.23.0",
3
+ "version": "3.23.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "3.23.0",
9
+ "version": "3.23.2",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
@@ -13386,13 +13386,13 @@
13386
13386
  }
13387
13387
  },
13388
13388
  "node_modules/socket.io-client": {
13389
- "version": "4.8.1",
13390
- "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.8.1.tgz",
13391
- "integrity": "sha512-hJVXfu3E28NmzGk8o1sHhN3om52tRvwYeidbj7xKy2eIIse5IoKX3USlS6Tqt3BHAtflLIkCQBkzVrEEfWUyYQ==",
13389
+ "version": "4.8.3",
13390
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.8.3.tgz",
13391
+ "integrity": "sha512-uP0bpjWrjQmUt5DTHq9RuoCBdFJF10cdX9X+a368j/Ft0wmaVgxlrjvK3kjvgCODOMMOz9lcaRzxmso0bTWZ/g==",
13392
13392
  "license": "MIT",
13393
13393
  "dependencies": {
13394
13394
  "@socket.io/component-emitter": "~3.1.0",
13395
- "debug": "~4.3.2",
13395
+ "debug": "~4.4.1",
13396
13396
  "engine.io-client": "~6.6.1",
13397
13397
  "socket.io-parser": "~4.2.4"
13398
13398
  },
@@ -13400,23 +13400,6 @@
13400
13400
  "node": ">=10.0.0"
13401
13401
  }
13402
13402
  },
13403
- "node_modules/socket.io-client/node_modules/debug": {
13404
- "version": "4.3.7",
13405
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
13406
- "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
13407
- "license": "MIT",
13408
- "dependencies": {
13409
- "ms": "^2.1.3"
13410
- },
13411
- "engines": {
13412
- "node": ">=6.0"
13413
- },
13414
- "peerDependenciesMeta": {
13415
- "supports-color": {
13416
- "optional": true
13417
- }
13418
- }
13419
- },
13420
13403
  "node_modules/socket.io-parser": {
13421
13404
  "version": "4.2.4",
13422
13405
  "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "3.23.0",
3
+ "version": "3.23.2",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {