@automattic/vip 2.16.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.17.0 (06 Sep 2022)
4
+ - #1093 [dev-env] use latest proxy image
5
+ - #1091 Extract http helper into standalone function
6
+ - #1090 Add tracking to software update
7
+ - #1083 Software Management: Update
8
+ - #1089 [dev-env] Fix wording in wizard
9
+
3
10
  ### 2.16.0 (29 Aug 2022)
4
11
 
5
12
  - #1086 Add tracking to config software get
package/CONTRIBUTING.md CHANGED
@@ -85,7 +85,7 @@ Prepare the release by making sure that:
85
85
 
86
86
  ```
87
87
  export LAST_RELEASE_DATE=2021-08-25T13:40:00+02
88
- gh pr list --search "is:merged sort:updated-desc closed:>$LAST_RELEASE_DATE" | sed -e 's/\s*\S\+\s*\S\+\s*$//' -e 's/^/- #/'
88
+ gh pr list --search "is:merged sort:updated-desc closed:>$LAST_RELEASE_DATE" | sed -e 's/\s\+\S\+\tMERGED.*$//' -e 's/^/- #/'
89
89
  ```
90
90
 
91
91
  Then, let's publish:
@@ -22,7 +22,7 @@ var _format = require("../lib/cli/format");
22
22
 
23
23
  var _software = require("../lib/config/software");
24
24
 
25
- var _userError = _interopRequireDefault(require("../lib/cli/userError"));
25
+ var _userError = _interopRequireDefault(require("../lib/user-error"));
26
26
 
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
28
 
@@ -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
+ });
@@ -19,5 +19,9 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
 
21
21
  (0, _command.default)({
22
- requiredArgs: 1
23
- }).command('get', 'Read current software settings').argv(process.argv);
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);
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _api = _interopRequireDefault(require("../../api"));
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
  });
@@ -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: _nodeFetch.default,
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
  }
@@ -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
+ }
@@ -39,7 +39,7 @@ var exit = _interopRequireWildcard(require("./exit"));
39
39
 
40
40
  var _debug = _interopRequireDefault(require("debug"));
41
41
 
42
- var _userError = _interopRequireDefault(require("./userError"));
42
+ var _userError = _interopRequireDefault(require("../user-error"));
43
43
 
44
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); }
45
45
 
@@ -3,17 +3,43 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.appQueryFragments = exports.appQuery = void 0;
6
+ exports.getUpdateResult = exports.triggerUpdate = exports.promptForUpdate = exports.appQueryFragments = exports.appQuery = void 0;
7
+
8
+ var _enquirer = require("enquirer");
9
+
10
+ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
11
+
12
+ var _debug = _interopRequireDefault(require("debug"));
13
+
14
+ var _app = require("../app");
15
+
16
+ var _api = _interopRequireDefault(require("../api"));
17
+
18
+ var _userError = _interopRequireDefault(require("../user-error"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ /**
23
+ * External dependencies
24
+ */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+ const UPDATE_PROGRESS_POLL_INTERVAL = 5;
30
+ const debug = (0, _debug.default)('@automattic/vip:bin:config-software');
7
31
  const appQuery = `
8
32
  id,
9
33
  name,
10
34
  type,
35
+ typeId,
11
36
  organization { id, name },
12
37
  environments{
13
38
  appId
14
39
  id
15
40
  name
16
41
  type
42
+ uniqueLabel
17
43
  softwareSettings {
18
44
  php {
19
45
  ...Software
@@ -54,4 +80,266 @@ const appQueryFragments = `fragment Software on AppEnvironmentSoftwareSettingsSo
54
80
  }
55
81
  }
56
82
  `;
57
- exports.appQueryFragments = appQueryFragments;
83
+ exports.appQueryFragments = appQueryFragments;
84
+ const updateSoftwareMutation = (0, _graphqlTag.default)`
85
+ mutation UpdateSoftwareSettings(
86
+ $appId: Int!
87
+ $envId: Int!
88
+ $component: String!
89
+ $version: String!
90
+ ) {
91
+ updateSoftwareSettings(
92
+ input: {
93
+ appId: $appId
94
+ environmentId: $envId
95
+ softwareName: $component
96
+ softwareVersion: $version
97
+ }
98
+ ) {
99
+ php {
100
+ ...Software
101
+ }
102
+ wordpress {
103
+ ...Software
104
+ }
105
+ muplugins {
106
+ ...Software
107
+ }
108
+ nodejs {
109
+ ...Software
110
+ }
111
+ }
112
+ }
113
+ ${appQueryFragments}
114
+ `;
115
+ const updateJobQuery = (0, _graphqlTag.default)`
116
+ query UpdateJob($appId: Int!, $envId: Int!) {
117
+ app(id: $appId ) {
118
+ environments(id: $envId) {
119
+ jobs (types:["upgrade_php", "upgrade_wordpress", "upgrade_muplugins", "upgrade_nodejs"]) {
120
+ type
121
+ completedAt
122
+ createdAt
123
+ inProgressLock
124
+ progress {
125
+ status
126
+ steps {
127
+ step
128
+ name
129
+ status
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }`;
136
+ const COMPONENT_NAMES = {
137
+ wordpress: 'WordPress',
138
+ php: 'PHP',
139
+ muplugins: 'MU Plugins',
140
+ nodejs: 'Node.js'
141
+ };
142
+ const MANAGED_OPTION_KEY = 'managed_latest';
143
+
144
+ const _optionsForVersion = softwareSettings => {
145
+ const {
146
+ options,
147
+ current,
148
+ pinned,
149
+ slug
150
+ } = softwareSettings;
151
+ const versionChoices = {
152
+ managed: [],
153
+ supported: [],
154
+ test: [],
155
+ deprecated: []
156
+ };
157
+
158
+ for (const option of options) {
159
+ if (option.deprecated) {
160
+ versionChoices.deprecated.push({
161
+ message: `${option.version} (deprecated)`,
162
+ value: option.version
163
+ });
164
+ } else if (option.unstable) {
165
+ versionChoices.test.push({
166
+ message: `${option.version} (test)`,
167
+ value: option.version
168
+ });
169
+ } else {
170
+ versionChoices.supported.push({
171
+ message: option.version,
172
+ value: option.version
173
+ });
174
+ }
175
+ }
176
+
177
+ if (slug === 'wordpress') {
178
+ versionChoices.managed.push({
179
+ message: 'Managed updates',
180
+ value: MANAGED_OPTION_KEY
181
+ });
182
+ }
183
+
184
+ const allOptions = [...versionChoices.managed, ...versionChoices.supported, ...versionChoices.test, ...versionChoices.deprecated];
185
+ return allOptions.map(option => {
186
+ const isActivePinned = option.value === MANAGED_OPTION_KEY && !pinned;
187
+ const isActiveVersion = option.value === current.version && pinned;
188
+
189
+ if (isActivePinned || isActiveVersion) {
190
+ return {
191
+ message: `Active: ${option.message}`,
192
+ value: option.value,
193
+ disabled: true
194
+ };
195
+ }
196
+
197
+ return option;
198
+ });
199
+ };
200
+
201
+ const _processComponent = async (appTypeId, userProvidedComponent) => {
202
+ const validComponents = [];
203
+
204
+ if ((0, _app.isAppWordPress)(appTypeId)) {
205
+ validComponents.push('wordpress', 'php', 'muplugins');
206
+ } else if ((0, _app.isAppNodejs)(appTypeId)) {
207
+ validComponents.push('nodejs');
208
+ }
209
+
210
+ if (userProvidedComponent) {
211
+ if (!validComponents.includes(userProvidedComponent)) {
212
+ throw new _userError.default(`Component ${userProvidedComponent} is not supported. Use one of: ${validComponents.join(',')}`);
213
+ }
214
+
215
+ return userProvidedComponent;
216
+ }
217
+
218
+ if (validComponents.length === 0) {
219
+ throw new _userError.default('No components are supported for this application');
220
+ }
221
+
222
+ if (validComponents.length === 1) {
223
+ return validComponents[0];
224
+ }
225
+
226
+ const choices = validComponents.map(item => ({
227
+ message: COMPONENT_NAMES[item],
228
+ value: item
229
+ }));
230
+ const select = new _enquirer.Select({
231
+ message: 'Component to update',
232
+ choices
233
+ });
234
+ return await select.run();
235
+ };
236
+
237
+ const _processComponentVersion = async (softwareSettings, component, userProvidedVersion) => {
238
+ const versionChoices = _optionsForVersion(softwareSettings[component]);
239
+
240
+ if (userProvidedVersion) {
241
+ const validValues = versionChoices.map(item => item.value);
242
+
243
+ if (!validValues.includes(userProvidedVersion)) {
244
+ throw new _userError.default(`Version ${userProvidedVersion} is not supported for ${COMPONENT_NAMES[component]}. Use one of: ${validValues.join(',')}`);
245
+ }
246
+
247
+ return userProvidedVersion;
248
+ }
249
+
250
+ const versionSelect = new _enquirer.Select({
251
+ message: `Version for ${COMPONENT_NAMES[component]} to upgrade to`,
252
+ choices: versionChoices
253
+ });
254
+ return await versionSelect.run();
255
+ };
256
+
257
+ const promptForUpdate = async (appTypeId, opts, softwareSettings) => {
258
+ const component = await _processComponent(appTypeId, opts.component);
259
+ const version = await _processComponentVersion(softwareSettings, component, opts.version);
260
+ const confirm = opts.force || (await new _enquirer.Confirm({
261
+ message: `Are you sure you want to upgrade ${COMPONENT_NAMES[component]} to ${version}?`
262
+ }).run());
263
+
264
+ if (confirm) {
265
+ return {
266
+ component,
267
+ version
268
+ };
269
+ }
270
+
271
+ throw new _userError.default('Update canceled');
272
+ };
273
+
274
+ exports.promptForUpdate = promptForUpdate;
275
+
276
+ const triggerUpdate = async variables => {
277
+ debug('Triggering update', variables);
278
+ const api = await (0, _api.default)();
279
+ return await api.mutate({
280
+ mutation: updateSoftwareMutation,
281
+ variables
282
+ });
283
+ };
284
+
285
+ exports.triggerUpdate = triggerUpdate;
286
+
287
+ const _getLatestJob = async (appId, envId) => {
288
+ var _result$data, _result$data$app;
289
+
290
+ const api = await (0, _api.default)();
291
+ const result = await api.query({
292
+ query: updateJobQuery,
293
+ variables: {
294
+ appId,
295
+ envId
296
+ },
297
+ fetchPolicy: 'network-only'
298
+ });
299
+ const jobs = (result === null || result === void 0 ? void 0 : (_result$data = result.data) === null || _result$data === void 0 ? void 0 : (_result$data$app = _result$data.app) === null || _result$data$app === void 0 ? void 0 : _result$data$app.environments[0].jobs) || [];
300
+
301
+ if (jobs.length) {
302
+ return jobs.reduce((prev, current) => prev.createdAt > current.createdAt ? prev : current);
303
+ }
304
+
305
+ return null;
306
+ };
307
+
308
+ const _getCompletedJob = async (appId, envId) => {
309
+ const latestJob = await _getLatestJob(appId, envId);
310
+ debug('Latest job result:', latestJob);
311
+
312
+ if (!latestJob || !latestJob.inProgressLock) {
313
+ return latestJob;
314
+ }
315
+
316
+ debug(`Sleep for ${UPDATE_PROGRESS_POLL_INTERVAL} seconds`);
317
+ await new Promise(resolve => setTimeout(resolve, UPDATE_PROGRESS_POLL_INTERVAL * 1000));
318
+ return _getCompletedJob(appId, envId);
319
+ };
320
+
321
+ const getUpdateResult = async (appId, envId) => {
322
+ var _completedJob$progres, _completedJob$progres2, _completedJob$progres3;
323
+
324
+ debug('Getting update result', {
325
+ appId,
326
+ envId
327
+ });
328
+ const completedJob = await _getCompletedJob(appId, envId);
329
+ const success = !completedJob || (completedJob === null || completedJob === void 0 ? void 0 : (_completedJob$progres = completedJob.progress) === null || _completedJob$progres === void 0 ? void 0 : _completedJob$progres.status) === 'success';
330
+
331
+ if (success) {
332
+ return {
333
+ ok: true
334
+ };
335
+ }
336
+
337
+ const failedStep = completedJob === null || completedJob === void 0 ? void 0 : (_completedJob$progres2 = completedJob.progress) === null || _completedJob$progres2 === void 0 ? void 0 : (_completedJob$progres3 = _completedJob$progres2.steps) === null || _completedJob$progres3 === void 0 ? void 0 : _completedJob$progres3.find(step => step.status === 'failed');
338
+ const error = failedStep ? `Failed during step: ${failedStep.name}` : 'Software update failed';
339
+ return {
340
+ ok: false,
341
+ errorMessage: error
342
+ };
343
+ };
344
+
345
+ exports.getUpdateResult = getUpdateResult;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NODEJS_SITE_TYPE_IDS = exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_REDIS_APPLICATION_TYPE_ID = exports.NODEJS_MYSQL_APPLICATION_TYPE_ID = exports.NODEJS_APPLICATION_TYPE_ID = exports.WORDPRESS_SITE_TYPE_IDS = exports.WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = exports.WORDPRESS_APPLICATION_TYPE_ID = void 0;
7
+ const WORDPRESS_APPLICATION_TYPE_ID = 2;
8
+ exports.WORDPRESS_APPLICATION_TYPE_ID = WORDPRESS_APPLICATION_TYPE_ID;
9
+ const WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = 6;
10
+ exports.WORDPRESS_NON_PROD_APPLICATION_TYPE_ID = WORDPRESS_NON_PROD_APPLICATION_TYPE_ID;
11
+ const WORDPRESS_SITE_TYPE_IDS = [WORDPRESS_APPLICATION_TYPE_ID, WORDPRESS_NON_PROD_APPLICATION_TYPE_ID];
12
+ exports.WORDPRESS_SITE_TYPE_IDS = WORDPRESS_SITE_TYPE_IDS;
13
+ const NODEJS_APPLICATION_TYPE_ID = 3;
14
+ exports.NODEJS_APPLICATION_TYPE_ID = NODEJS_APPLICATION_TYPE_ID;
15
+ const NODEJS_MYSQL_APPLICATION_TYPE_ID = 5;
16
+ exports.NODEJS_MYSQL_APPLICATION_TYPE_ID = NODEJS_MYSQL_APPLICATION_TYPE_ID;
17
+ const NODEJS_REDIS_APPLICATION_TYPE_ID = 7;
18
+ exports.NODEJS_REDIS_APPLICATION_TYPE_ID = NODEJS_REDIS_APPLICATION_TYPE_ID;
19
+ const NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = 8;
20
+ exports.NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID = NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID;
21
+ const NODEJS_SITE_TYPE_IDS = [NODEJS_APPLICATION_TYPE_ID, NODEJS_MYSQL_APPLICATION_TYPE_ID, NODEJS_REDIS_APPLICATION_TYPE_ID, NODEJS_MYSQL_REDIS_APPLICATION_TYPE_ID];
22
+ exports.NODEJS_SITE_TYPE_IDS = NODEJS_SITE_TYPE_IDS;
@@ -45,7 +45,7 @@ var _devEnvironmentCore = require("./dev-environment-core");
45
45
 
46
46
  var _devEnvironmentLando = require("./dev-environment-lando");
47
47
 
48
- var _userError = _interopRequireDefault(require("../cli/userError"));
48
+ var _userError = _interopRequireDefault(require("../user-error"));
49
49
 
50
50
  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); }
51
51
 
@@ -421,21 +421,26 @@ const componentDisplayNames = {
421
421
  muPlugins: 'vip-go-mu-plugins',
422
422
  appCode: 'application code'
423
423
  };
424
+ const componentDemoyNames = {
425
+ muPlugins: 'vip-go-mu-plugins',
426
+ appCode: 'vip-go-skeleton'
427
+ };
424
428
 
425
429
  async function promptForComponent(component, allowLocal, defaultObject) {
426
430
  debug(`Prompting for ${component} with default:`, defaultObject);
427
431
  const componentDisplayName = componentDisplayNames[component] || component;
432
+ const componentDemoName = componentDemoyNames[component] || component;
428
433
  const modChoices = [];
429
434
 
430
435
  if (allowLocal) {
431
436
  modChoices.push({
432
- message: `local folder - where you already have ${componentDisplayName} code`,
437
+ message: `Custom - Path to a locally cloned ${componentDisplayName} directory`,
433
438
  value: 'local'
434
439
  });
435
440
  }
436
441
 
437
442
  modChoices.push({
438
- message: 'demo image - that gets automatically fetched',
443
+ message: `Demo - Automatically fetched ${componentDemoName}`,
439
444
  value: 'image'
440
445
  });
441
446
  let initialMode = 'image';
File without changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -5501,6 +5501,12 @@
5501
5501
  "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz",
5502
5502
  "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw=="
5503
5503
  },
5504
+ "colors": {
5505
+ "version": "1.4.0",
5506
+ "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
5507
+ "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
5508
+ "optional": true
5509
+ },
5504
5510
  "is-fullwidth-code-point": {
5505
5511
  "version": "2.0.0",
5506
5512
  "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
@@ -5642,10 +5648,9 @@
5642
5648
  "dev": true
5643
5649
  },
5644
5650
  "colors": {
5645
- "version": "1.4.0",
5646
- "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
5647
- "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
5648
- "optional": true
5651
+ "version": "1.0.3",
5652
+ "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
5653
+ "integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw=="
5649
5654
  },
5650
5655
  "combined-stream": {
5651
5656
  "version": "1.0.8",
@@ -5898,9 +5903,9 @@
5898
5903
  }
5899
5904
  },
5900
5905
  "dayjs": {
5901
- "version": "1.11.4",
5902
- "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.4.tgz",
5903
- "integrity": "sha512-Zj/lPM5hOvQ1Bf7uAvewDaUcsJoI6JmNqmHhHl3nyumwe0XHwt8sWdOVAPACJzCebL8gQCi+K49w7iKWnGwX9g=="
5906
+ "version": "1.11.5",
5907
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz",
5908
+ "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA=="
5904
5909
  },
5905
5910
  "debug": {
5906
5911
  "version": "4.3.3",
@@ -10104,8 +10109,8 @@
10104
10109
  "dev": true
10105
10110
  },
10106
10111
  "lando": {
10107
- "version": "git+https://github.com/Automattic/lando-cli.git#db79d2c19e110b3dea32120c56eea7a3df100ad3",
10108
- "from": "git+https://github.com/Automattic/lando-cli.git#v3.5.2-patch2022_08_11",
10112
+ "version": "git+https://github.com/Automattic/lando-cli.git#93b9137e2570025b771fc734fd92e694755917a1",
10113
+ "from": "git+https://github.com/Automattic/lando-cli.git#v3.5.2-patch2022_09_05",
10109
10114
  "requires": {
10110
10115
  "@lando/platformsh": "^0.6.0",
10111
10116
  "axios": "0.21.4",
@@ -10164,11 +10169,6 @@
10164
10169
  "wrap-ansi": "^2.0.0"
10165
10170
  }
10166
10171
  },
10167
- "colors": {
10168
- "version": "1.0.3",
10169
- "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
10170
- "integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw=="
10171
- },
10172
10172
  "find-up": {
10173
10173
  "version": "3.0.0",
10174
10174
  "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
@@ -11865,9 +11865,9 @@
11865
11865
  }
11866
11866
  },
11867
11867
  "platformsh-client": {
11868
- "version": "0.1.205",
11869
- "resolved": "https://registry.npmjs.org/platformsh-client/-/platformsh-client-0.1.205.tgz",
11870
- "integrity": "sha512-VxJ6aWQzujv+nhwBsbC7OMWq+yHRHi0m3Z1yQA5mqVAplHHM6PgRrsEmUa+balCXhKksj8Y+YPYCB7epJ7Y0lw==",
11868
+ "version": "0.1.207",
11869
+ "resolved": "https://registry.npmjs.org/platformsh-client/-/platformsh-client-0.1.207.tgz",
11870
+ "integrity": "sha512-Ox32Rpjbiqgap9ilR231eQNCb4BtObeCCbwTlc8o1/3FZqK1R4CfP6E5jVDXpQ3UzyhKMgFT40w7UGo43OaM/g==",
11871
11871
  "requires": {
11872
11872
  "atob": "^2.1.2",
11873
11873
  "basename": "^0.1.2",
@@ -14460,11 +14460,6 @@
14460
14460
  "version": "1.0.0",
14461
14461
  "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz",
14462
14462
  "integrity": "sha512-5mO7DX4CbJzp9zjaFXusQQ4tzKJARjNB1Ih1pVBi8wkbmXy/xzIDgEMXxWePLzt2OdFwaxfneIlT1nCiXubrPQ=="
14463
- },
14464
- "colors": {
14465
- "version": "1.0.3",
14466
- "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
14467
- "integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw=="
14468
14463
  }
14469
14464
  }
14470
14465
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -18,6 +18,7 @@
18
18
  "vip-config-envvar-set": "dist/bin/vip-config-envvar-set.js",
19
19
  "vip-config-software": "dist/bin/vip-config-software.js",
20
20
  "vip-config-software-get": "dist/bin/vip-config-software-get.js",
21
+ "vip-config-software-update": "dist/bin/vip-config-software-update.js",
21
22
  "vip-dev-env": "dist/bin/vip-dev-env.js",
22
23
  "vip-dev-env-create": "dist/bin/vip-dev-env-create.js",
23
24
  "vip-dev-env-update": "dist/bin/vip-dev-env-update.js",
@@ -126,7 +127,7 @@
126
127
  "ini": "2.0.0",
127
128
  "json2csv": "5.0.6",
128
129
  "jwt-decode": "2.2.0",
129
- "lando": "git+https://github.com/Automattic/lando-cli.git#v3.5.2-patch2022_08_11",
130
+ "lando": "git+https://github.com/Automattic/lando-cli.git#v3.5.2-patch2022_09_05",
130
131
  "node-fetch": "^2.6.1",
131
132
  "opn": "5.5.0",
132
133
  "proxy-from-env": "^1.1.0",