@automattic/vip 2.33.0 → 2.34.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,34 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.34.0
4
+
5
+ - #1503 chore(dev-deps): update nock to 13.3.3
6
+ - #1502 chore(dev-deps): update flow-bin to 0.216.1
7
+ - #1501 chore(deps): update jest-related packages
8
+ - #1500 chore(dev-deps): update babel-related packages
9
+ - #1498 ci: run tests and checks in parallel
10
+ - #1462 Fixed Slowlogs local unit test
11
+ - #1488 fix: do not abort if a temporary directory cannot be removed on exit
12
+ - #1495 refactor: convert `media-import` to TypeScript
13
+ - #1492 refactor: convert `site-import` directory to TypeScript
14
+
15
+ ### 2.33.0
16
+
17
+ - #1475 Updating CONTRIBUTING.md with new publishing procedure
18
+ - #1477 Fetch environment name from server to fix environment selector label
19
+ - #1479 chore(dev-deps): update jest-related packages to 29.6.2
20
+ - #1480 chore(deps): update node-fetch to 2.6.12
21
+ - #1481 chore(deps): update socket.io-client to 4.7.2
22
+ - #1482 chore(deps): update enquirer to 2.4.1
23
+ - #1478 Fix False UP status for multisite dev-envs
24
+ - #1483 Disable Windows patch
25
+ - #1458 Add warning confirmation when there's not enough space on disk. by
26
+ - #1487 fix(dev-env): display ports exposed by services
27
+ - #1490 fix: CLI not respecting proxy settings when creating local dev environment by
28
+ - #1491 chore(dev-deps): update eslint from 8.43.0 to 8.47.0
29
+ - #1486 chore(dev-deps): update babel-related packages
30
+ - #1484 feat(backup): Add vip backup db command
31
+
3
32
  ### 2.32.4
4
33
 
5
34
  - #1470 Rename prepare-release.yml to npm-prepare-release.yml
@@ -7,11 +7,6 @@ exports.SUPPORTED_MEDIA_FILE_IMPORT_SITE_TYPES = exports.MEDIA_IMPORT_FILE_SIZE_
7
7
  exports.currentUserCanImportForApp = currentUserCanImportForApp;
8
8
  exports.isSupportedApp = void 0;
9
9
  var _fileSize = require("../../lib/constants/file-size");
10
- /**
11
- *
12
- * @format
13
- */
14
-
15
10
  /**
16
11
  * Internal dependencies
17
12
  */
@@ -7,13 +7,14 @@ exports.MediaImportProgressTracker = void 0;
7
7
  var _singleLineLog = require("single-line-log");
8
8
  var _status = require("../../lib/media-import/status");
9
9
  var _format = require("../../lib/cli/format");
10
- /** @format */
11
10
  /**
12
11
  * External dependencies
13
12
  */
13
+
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
+
17
18
  const PRINT_INTERVAL = process.env.DEBUG ? 5000 : 200; // How often the report is printed. Mainly affects the "spinner" animation.
18
19
 
19
20
  class MediaImportProgressTracker {
@@ -26,15 +27,20 @@ class MediaImportProgressTracker {
26
27
  constructor(status) {
27
28
  this.runningSprite = new _format.RunningSprite();
28
29
  this.hasFailure = false;
29
- this.status = Object.assign({}, status);
30
+ this.status = {
31
+ ...status
32
+ };
30
33
  this.prefix = '';
31
34
  this.suffix = '';
35
+ this.hasPrinted = false;
32
36
  }
33
37
  setStatus(status) {
34
38
  if ('FAILED' === status.status) {
35
39
  this.hasFailure = true;
36
40
  }
37
- this.status = Object.assign({}, status);
41
+ this.status = {
42
+ ...status
43
+ };
38
44
  }
39
45
  startPrinting(prePrintCallback = () => {}) {
40
46
  this.printInterval = setInterval(() => {
@@ -54,7 +60,7 @@ class MediaImportProgressTracker {
54
60
  this.hasPrinted = true;
55
61
  _singleLineLog.stdout.clear();
56
62
  }
57
- const statusIcon = (0, _status.getGlyphForStatus)(this.status.status, this.runningSprite);
63
+ const statusIcon = (0, _status.getGlyphForStatus)(this.status.status ?? '', this.runningSprite);
58
64
  let logs;
59
65
  if (this.status.filesProcessed && this.status.filesTotal) {
60
66
  const progressPercentage = Math.floor(this.status.filesProcessed / this.status.filesTotal * 100);
@@ -62,7 +68,7 @@ class MediaImportProgressTracker {
62
68
  }
63
69
 
64
70
  // Output the logs
65
- (0, _singleLineLog.stdout)(`${this.prefix || ''}${logs || ''}${this.suffix || ''}`);
71
+ (0, _singleLineLog.stdout)(`${this.prefix || ''}${logs ?? ''}${this.suffix || ''}`);
66
72
  if (clearAfter) {
67
73
  // Break out of the "Single log line" buffer
68
74
  _singleLineLog.stdout.clear();
@@ -6,23 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  exports.getGlyphForStatus = getGlyphForStatus;
8
8
  exports.mediaImportCheckStatus = mediaImportCheckStatus;
9
+ var _promises = require("node:fs/promises");
10
+ var _nodePath = require("node:path");
9
11
  var _chalk = _interopRequireDefault(require("chalk"));
10
12
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
11
- var _fs = require("fs");
12
- var path = _interopRequireWildcard(require("path"));
13
13
  var _api = _interopRequireDefault(require("../../lib/api"));
14
14
  var _mediaFileImport = require("../../lib/media-import/media-file-import");
15
- var _progress = require("../../lib/media-import/progress");
16
15
  var _format = require("../../lib/cli/format");
17
- var _format2 = require("../cli/format");
18
- 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); }
19
- 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; }
20
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
- /**
22
- *
23
- * @format
24
- */
25
-
26
17
  /**
27
18
  * External dependencies
28
19
  */
@@ -62,6 +53,7 @@ const IMPORT_MEDIA_PROGRESS_QUERY = (0, _graphqlTag.default)`
62
53
  }
63
54
  `;
64
55
  async function getStatus(api, appId, envId) {
56
+ var _response$data$app;
65
57
  const response = await api.query({
66
58
  query: IMPORT_MEDIA_PROGRESS_QUERY,
67
59
  variables: {
@@ -70,21 +62,15 @@ async function getStatus(api, appId, envId) {
70
62
  },
71
63
  fetchPolicy: 'network-only'
72
64
  });
73
- const {
74
- data: {
75
- app: {
76
- environments
77
- }
78
- }
79
- } = response;
65
+ const environments = (_response$data$app = response.data.app) === null || _response$data$app === void 0 ? void 0 : _response$data$app.environments;
80
66
  if (!(environments !== null && environments !== void 0 && environments.length)) {
81
67
  throw new Error('Unable to determine import status from environment');
82
68
  }
83
69
  const [environment] = environments;
84
70
  const {
85
71
  mediaImportStatus
86
- } = environment;
87
- return mediaImportStatus;
72
+ } = environment ?? {};
73
+ return mediaImportStatus ?? null;
88
74
  }
89
75
  function getGlyphForStatus(status, runningSprite) {
90
76
  switch (status) {
@@ -113,10 +99,11 @@ function buildErrorMessage(importFailed) {
113
99
  if ('FAILED' === importFailed.status) {
114
100
  const globalFailureDetails = importFailed.failureDetails;
115
101
  if (globalFailureDetails) {
102
+ var _globalFailureDetails;
116
103
  message += `${_chalk.default.red('Import failed at status: ')}`;
117
104
  message += `${_chalk.default.redBright.bold(globalFailureDetails.previousStatus)}\n`;
118
105
  message += _chalk.default.red('Errors:');
119
- globalFailureDetails.globalErrors.forEach(value => {
106
+ (_globalFailureDetails = globalFailureDetails.globalErrors) === null || _globalFailureDetails === void 0 || _globalFailureDetails.forEach(value => {
120
107
  message += `\n\t- ${_chalk.default.redBright.bold(value)}`;
121
108
  });
122
109
  return message;
@@ -131,16 +118,17 @@ function buildFileErrors(fileErrors, exportFileErrorsToJson) {
131
118
  if (exportFileErrorsToJson) {
132
119
  const fileErrorsToExport = fileErrors.map(fileError => {
133
120
  return {
134
- fileName: fileError.fileName,
135
- errors: fileError.errors
121
+ fileName: fileError === null || fileError === void 0 ? void 0 : fileError.fileName,
122
+ errors: fileError === null || fileError === void 0 ? void 0 : fileError.errors
136
123
  };
137
124
  });
138
125
  return (0, _format.formatData)(fileErrorsToExport, 'json');
139
126
  }
140
127
  let errorString = '';
141
128
  for (const fileError of fileErrors) {
142
- errorString += `File Name: ${fileError.fileName}`;
143
- errorString += `\n\nErrors:\n\t- ${fileError.errors}\n\n\n\n`;
129
+ var _fileError$errors;
130
+ errorString += `File Name: ${(fileError === null || fileError === void 0 ? void 0 : fileError.fileName) ?? 'N/A'}`;
131
+ errorString += `\n\nErrors:\n\t- ${(fileError === null || fileError === void 0 || (_fileError$errors = fileError.errors) === null || _fileError$errors === void 0 ? void 0 : _fileError$errors.join(', ')) ?? 'unknown error'}\n\n\n\n`;
144
132
  }
145
133
  return errorString;
146
134
  }
@@ -177,7 +165,7 @@ async function mediaImportCheckStatus({
177
165
  const suffix = `
178
166
  =============================================================
179
167
  Status: ${statusMessage}
180
- App: ${app.name} (${(0, _format.formatEnvironment)(env.type)})
168
+ App: ${app.name ?? 'N/A'} (${(0, _format.formatEnvironment)(env.type ?? 'N/A')})
181
169
  =============================================================
182
170
  ${maybeExitPrompt}
183
171
  `;
@@ -188,13 +176,15 @@ ${maybeExitPrompt}
188
176
  progressTracker.print();
189
177
  };
190
178
  progressTracker.startPrinting(setSuffixAndPrint);
191
- const getResults = () => new Promise((resolve, reject) => {
179
+ const getResults = () =>
180
+ // eslint-disable-next-line @typescript-eslint/no-shadow
181
+ new Promise((resolve, reject) => {
192
182
  let startDate = Date.now();
193
183
  let pollIntervalDecreasing = false;
194
184
  const checkStatus = async pollInterval => {
195
- let mediaImportStatus;
185
+ let mediaImportStatus = null;
196
186
  try {
197
- mediaImportStatus = await getStatus(api, app.id, env.id);
187
+ mediaImportStatus = await getStatus(api, app.id ?? -1, env.id ?? -1);
198
188
  if (!mediaImportStatus) {
199
189
  return reject({
200
190
  error: 'Requested app/environment is not available for this operation. If you think this is not correct, please contact Support.'
@@ -202,12 +192,10 @@ ${maybeExitPrompt}
202
192
  }
203
193
  } catch (error) {
204
194
  return reject({
205
- error
195
+ error: error.message
206
196
  });
207
197
  }
208
- const {
209
- status
210
- } = mediaImportStatus;
198
+ const status = mediaImportStatus.status ?? 'unknown';
211
199
  const failedMediaImport = 'FAILED' === status;
212
200
  if (failedMediaImport) {
213
201
  progressTracker.setStatus(mediaImportStatus);
@@ -244,23 +232,23 @@ ${maybeExitPrompt}
244
232
  try {
245
233
  var _results$failureDetai;
246
234
  const results = await getResults();
247
- overallStatus = (results === null || results === void 0 ? void 0 : results.status) || 'unknown';
235
+ overallStatus = results.status ?? 'unknown';
248
236
  progressTracker.stopPrinting();
249
237
  setProgressTrackerSuffix();
250
238
  progressTracker.print();
251
239
  const fileErrors = (_results$failureDetai = results.failureDetails) === null || _results$failureDetai === void 0 ? void 0 : _results$failureDetai.fileErrors;
252
240
  if (!!fileErrors && fileErrors.length > 0) {
253
241
  progressTracker.suffix += `${_chalk.default.yellow(`⚠️ ${fileErrors.length} file error(s) have been extracted`)}`;
254
- if (results.filesTotal - results.filesProcessed !== fileErrors.length) {
242
+ if ((results.filesTotal ?? 0) - (results.filesProcessed ?? 0) !== fileErrors.length) {
255
243
  progressTracker.suffix += `. ${_chalk.default.italic.yellow('File-errors report size threshold reached.')}`;
256
244
  }
257
245
  const formattedData = buildFileErrors(fileErrors, exportFileErrorsToJson);
258
- const errorsFile = `media-import-${app.name}-${Date.now()}${exportFileErrorsToJson ? '.json' : '.txt'}`;
246
+ const errorsFile = `media-import-${app.name ?? ''}-${Date.now()}${exportFileErrorsToJson ? '.json' : '.txt'}`;
259
247
  try {
260
- await _fs.promises.writeFile(errorsFile, formattedData);
261
- progressTracker.suffix += `\n\n${_chalk.default.yellow(`All errors have been exported to ${_chalk.default.bold(path.resolve(errorsFile))}`)}\n\n`;
248
+ await (0, _promises.writeFile)(errorsFile, formattedData);
249
+ progressTracker.suffix += `\n\n${_chalk.default.yellow(`All errors have been exported to ${_chalk.default.bold((0, _nodePath.resolve)(errorsFile))}`)}\n\n`;
262
250
  } catch (writeFileErr) {
263
- progressTracker.suffix += `\n\n${_chalk.default.red(`Could not export errors to file\n${writeFileErr}`)}\n\n`;
251
+ progressTracker.suffix += `\n\n${_chalk.default.red(`Could not export errors to file\n${writeFileErr.message}`)}\n\n`;
264
252
  }
265
253
  }
266
254
 
@@ -7,11 +7,6 @@ exports.SYNC_STATUS_NOT_SYNCING = exports.SUPPORTED_DB_FILE_IMPORT_SITE_TYPES =
7
7
  exports.currentUserCanImportForApp = currentUserCanImportForApp;
8
8
  exports.isSupportedApp = exports.isImportingBlockedBySync = void 0;
9
9
  var _fileSize = require("../../lib/constants/file-size");
10
- /**
11
- *
12
- * @format
13
- */
14
-
15
10
  /**
16
11
  * Internal dependencies
17
12
  */
@@ -32,9 +27,8 @@ const isSupportedApp = ({
32
27
  exports.isSupportedApp = isSupportedApp;
33
28
  const SYNC_STATUS_NOT_SYNCING = 'not_syncing';
34
29
  exports.SYNC_STATUS_NOT_SYNCING = SYNC_STATUS_NOT_SYNCING;
35
- const isImportingBlockedBySync = ({
36
- syncProgress: {
37
- status
38
- }
39
- }) => status !== SYNC_STATUS_NOT_SYNCING;
30
+ const isImportingBlockedBySync = env => {
31
+ var _env$syncProgress;
32
+ return ((_env$syncProgress = env.syncProgress) === null || _env$syncProgress === void 0 ? void 0 : _env$syncProgress.status) !== SYNC_STATUS_NOT_SYNCING;
33
+ };
40
34
  exports.isImportingBlockedBySync = isImportingBlockedBySync;
@@ -10,17 +10,12 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
10
10
  var _debug = _interopRequireDefault(require("debug"));
11
11
  var _api = _interopRequireDefault(require("../../lib/api"));
12
12
  var _dbFileImport = require("../../lib/site-import/db-file-import");
13
- var _progress = require("../../lib/cli/progress");
14
13
  var exit = _interopRequireWildcard(require("../../lib/cli/exit"));
15
14
  var _format = require("../../lib/cli/format");
16
15
  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); }
17
16
  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; }
18
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
- /**
20
- *
21
- * @format
22
- */
23
-
18
+ /* eslint-disable complexity */
24
19
  /**
25
20
  * External dependencies
26
21
  */
@@ -72,6 +67,7 @@ const IMPORT_SQL_PROGRESS_QUERY = (0, _graphqlTag.default)`
72
67
  }
73
68
  `;
74
69
  async function getStatus(api, appId, envId) {
70
+ var _response$data$app;
75
71
  const response = await api.query({
76
72
  query: IMPORT_SQL_PROGRESS_QUERY,
77
73
  variables: {
@@ -80,17 +76,11 @@ async function getStatus(api, appId, envId) {
80
76
  },
81
77
  fetchPolicy: 'network-only'
82
78
  });
83
- const {
84
- data: {
85
- app: {
86
- environments
87
- }
88
- }
89
- } = response;
90
- if (!(environments !== null && environments !== void 0 && environments.length)) {
79
+ const environments = ((_response$data$app = response.data.app) === null || _response$data$app === void 0 ? void 0 : _response$data$app.environments) ?? [];
80
+ if (!environments.length) {
91
81
  throw new Error('Unable to determine import status from environment');
92
82
  }
93
- const [environment] = environments;
83
+ const environment = environments[0] ?? {};
94
84
  const {
95
85
  importStatus,
96
86
  jobs,
@@ -99,7 +89,7 @@ async function getStatus(api, appId, envId) {
99
89
  if (!environment.isK8sResident && !(jobs !== null && jobs !== void 0 && jobs.length)) {
100
90
  return {};
101
91
  }
102
- const [importJob] = jobs;
92
+ const [importJob] = jobs ?? [];
103
93
  return {
104
94
  importStatus,
105
95
  importJob,
@@ -178,6 +168,7 @@ async function importSqlCheckStatus({
178
168
  let completedAt;
179
169
  let overallStatus = 'Checking...';
180
170
  const setProgressTrackerSuffix = () => {
171
+ var _env$primaryDomain;
181
172
  const sprite = (0, _format.getGlyphForStatus)(overallStatus, progressTracker.runningSprite);
182
173
  const formattedCreatedAt = createdAt ? `${new Date(createdAt).toLocaleString()} (${createdAt})` : 'TBD';
183
174
  const formattedCompletedAt = createdAt && completedAt ? `${new Date(completedAt).toLocaleString()} (${completedAt})` : 'TBD';
@@ -185,7 +176,7 @@ async function importSqlCheckStatus({
185
176
  let statusMessage;
186
177
  switch (overallStatus) {
187
178
  case 'success':
188
- statusMessage = `Success ${sprite} imported data should be visible on your site ${env.primaryDomain.name}.`;
179
+ statusMessage = `Success ${sprite} imported data should be visible on your site ${((_env$primaryDomain = env.primaryDomain) === null || _env$primaryDomain === void 0 ? void 0 : _env$primaryDomain.name) ?? 'N/A'}.`;
189
180
  break;
190
181
  case 'running':
191
182
  if (progressTracker.allStepsSucceeded()) {
@@ -205,7 +196,7 @@ SQL Import Completed: ${formattedCompletedAt}`;
205
196
  const suffix = `
206
197
  =============================================================
207
198
  Status: ${statusMessage}
208
- Site: ${app.name} (${(0, _format.formatEnvironment)(env.type)})${maybeTimestamps}
199
+ Site: ${app.name ?? 'N/A'} (${(0, _format.formatEnvironment)(env.type ?? 'N/A')})${maybeTimestamps}
209
200
  =============================================================
210
201
  ${maybeExitPrompt}
211
202
  `;
@@ -221,7 +212,7 @@ ${maybeExitPrompt}
221
212
  var _importJob$progress, _importJob$progress2;
222
213
  let status;
223
214
  try {
224
- status = await getStatus(api, app.id, env.id);
215
+ status = await getStatus(api, app.id ?? -1, env.id ?? -1);
225
216
  } catch (error) {
226
217
  return reject({
227
218
  error
@@ -246,13 +237,15 @@ ${maybeExitPrompt}
246
237
 
247
238
  // if the progress meta isn't filled out yet, wait until it is.
248
239
  if (!statusSteps) {
249
- return setTimeout(checkStatus, IMPORT_SQL_PROGRESS_POLL_INTERVAL); // NOSONAR
240
+ return setTimeout(() => {
241
+ void checkStatus();
242
+ }, IMPORT_SQL_PROGRESS_POLL_INTERVAL);
250
243
  }
251
-
252
244
  jobSteps = statusSteps.map(step => {
245
+ var _step$name;
253
246
  return {
254
247
  id: step.name,
255
- name: (0, _format.capitalize)(step.name.replace(/_/g, ' ')),
248
+ name: (0, _format.capitalize)((_step$name = step.name) === null || _step$name === void 0 ? void 0 : _step$name.replace(/_/g, ' ')),
256
249
  status: step.result
257
250
  };
258
251
  });
@@ -267,7 +260,8 @@ ${maybeExitPrompt}
267
260
  result
268
261
  }) => result === 'success')) {
269
262
  jobStatus = 'success';
270
- importJob.completedAt = new Date(Math.max(...statusSteps.map(step => step.finished_at), 0) * 1000).toUTCString();
263
+ const timestamps = statusSteps.map(step => step.finished_at).filter(Boolean);
264
+ importJob.completedAt = new Date(Math.max(...timestamps, 0) * 1000).toUTCString();
271
265
  }
272
266
  if (importStatus !== null && importStatus !== void 0 && (_importStatus$progres2 = importStatus.progress) !== null && _importStatus$progres2 !== void 0 && _importStatus$progres2.started_at) {
273
267
  importJob.createdAt = new Date(importStatus.progress.started_at * 1000).toUTCString();
@@ -288,7 +282,7 @@ ${maybeExitPrompt}
288
282
  dbOperationInProgress,
289
283
  importInProgress,
290
284
  progress: importStepProgress
291
- } = importStatus;
285
+ } = importStatus ?? {};
292
286
  debug({
293
287
  jobStatus,
294
288
  completedAt,
@@ -299,14 +293,15 @@ ${maybeExitPrompt}
299
293
  });
300
294
  let jobCreationTime;
301
295
  try {
302
- jobCreationTime = new Date(createdAt).getTime();
296
+ jobCreationTime = new Date(createdAt ?? '').getTime();
303
297
  } catch (err) {
304
298
  debug('Unable to parse createdAt to a Date');
305
299
  }
306
300
  let failedImportStep;
307
- if (jobCreationTime && (importStepProgress === null || importStepProgress === void 0 ? void 0 : importStepProgress.started_at) * 1000 >= jobCreationTime) {
301
+ if (jobCreationTime && ((importStepProgress === null || importStepProgress === void 0 ? void 0 : importStepProgress.started_at) ?? 0) * 1000 >= jobCreationTime) {
302
+ var _importStepProgress$s;
308
303
  // The contents of the `import_progress` meta are pertinent to the most recent import job
309
- failedImportStep = importStepProgress.steps.find(step => (step === null || step === void 0 ? void 0 : step.result) === 'failed' && 1000 * (step === null || step === void 0 ? void 0 : step.started_at) > new Date(createdAt).getTime());
304
+ failedImportStep = importStepProgress === null || importStepProgress === void 0 || (_importStepProgress$s = importStepProgress.steps) === null || _importStepProgress$s === void 0 ? void 0 : _importStepProgress$s.find(step => (step === null || step === void 0 ? void 0 : step.result) === 'failed' && 1000 * (step.started_at ?? 0) > new Date(createdAt ?? '').getTime());
310
305
  }
311
306
  if (!jobSteps.length) {
312
307
  return reject({
@@ -317,9 +312,7 @@ ${maybeExitPrompt}
317
312
  if (failedImportStep) {
318
313
  // The server marks the step as a success as per the host action, demote it to 'failed'
319
314
  const _jobSteps = [...jobSteps];
320
- const failedJobStepIndex = _jobSteps.findIndex(({
321
- id
322
- }) => id === 'import');
315
+ const failedJobStepIndex = _jobSteps.findIndex(step => (step === null || step === void 0 ? void 0 : step.id) === 'import');
323
316
  _jobSteps[failedJobStepIndex] = {
324
317
  ..._jobSteps[failedJobStepIndex],
325
318
  status: 'failed'
@@ -332,7 +325,6 @@ ${maybeExitPrompt}
332
325
  commandOutput: failedImportStep.output,
333
326
  error: 'Import step failed',
334
327
  stepName: failedImportStep.name,
335
- errorText: failedImportStep.error,
336
328
  launched
337
329
  });
338
330
  }
@@ -349,7 +341,9 @@ ${maybeExitPrompt}
349
341
  return resolve(importJob);
350
342
  }
351
343
  overallStatus = 'running';
352
- setTimeout(checkStatus, IMPORT_SQL_PROGRESS_POLL_INTERVAL); // NOSONAR
344
+ setTimeout(() => {
345
+ void checkStatus();
346
+ }, IMPORT_SQL_PROGRESS_POLL_INTERVAL);
353
347
  };
354
348
 
355
349
  // Kick off the check
@@ -361,7 +355,7 @@ ${maybeExitPrompt}
361
355
  overallStatus = results;
362
356
  } else {
363
357
  var _results$progress;
364
- overallStatus = (results === null || results === void 0 || (_results$progress = results.progress) === null || _results$progress === void 0 ? void 0 : _results$progress.status) || 'unknown';
358
+ overallStatus = ((_results$progress = results.progress) === null || _results$progress === void 0 ? void 0 : _results$progress.status) ?? 'unknown';
365
359
  // This shouldn't be 'unknown'...what should we do here?
366
360
  }
367
361
 
package/dist/lib/utils.js CHANGED
@@ -56,11 +56,16 @@ function makeTempDir(prefix = 'vip-cli') {
56
56
  const tempDir = _fs.default.mkdtempSync(_path.default.join(_os.default.tmpdir(), `${prefix}-`));
57
57
  debug(`Created a directory to hold temporary files: ${tempDir}`);
58
58
  process.on('exit', () => {
59
- _fs.default.rmSync(tempDir, {
60
- recursive: true,
61
- force: true
62
- });
63
- debug(`Removed temporary directory: ${tempDir}`);
59
+ try {
60
+ _fs.default.rmSync(tempDir, {
61
+ recursive: true,
62
+ force: true,
63
+ maxRetries: 10
64
+ });
65
+ debug(`Removed temporary directory: ${tempDir}`);
66
+ } catch (err) {
67
+ console.warn(`Failed to remove temporary directory ${tempDir} (${err.message})`);
68
+ }
64
69
  });
65
70
  return tempDir;
66
71
  }