@automattic/vip 2.31.1-dev4 → 2.31.1-dev5

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.
@@ -80,7 +80,7 @@ async function getBackupJob(appId, envId) {
80
80
  }
81
81
  } = response;
82
82
  const job = environments[0].jobs[0];
83
- return job;
83
+ return job || null;
84
84
  }
85
85
  async function createBackupJob(appId, envId) {
86
86
  // Disable global error handling so that we can handle errors ourselves
@@ -138,11 +138,11 @@ class BackupDBCommand {
138
138
  this.progressTracker.stopPrinting();
139
139
  }
140
140
  async loadBackupJob() {
141
- var _this$job$metadata$fi, _this$job$metadata$fi2, _this$job$progress;
141
+ var _this$job, _this$job$metadata$fi, _this$job2, _this$job2$progress, _this$job3;
142
142
  this.job = await getBackupJob(this.app.id, this.env.id);
143
- this.backupName = (_this$job$metadata$fi = (_this$job$metadata$fi2 = this.job.metadata.find(meta => meta.name === 'backupName')) === null || _this$job$metadata$fi2 === void 0 ? void 0 : _this$job$metadata$fi2.value) !== null && _this$job$metadata$fi !== void 0 ? _this$job$metadata$fi : 'Unknown';
144
- this.jobStatus = (_this$job$progress = this.job.progress) === null || _this$job$progress === void 0 ? void 0 : _this$job$progress.status;
145
- if (this.job.completedAt) {
143
+ this.backupName = ((_this$job = this.job) === null || _this$job === void 0 ? void 0 : (_this$job$metadata$fi = _this$job.metadata.find(meta => meta.name === 'backupName')) === null || _this$job$metadata$fi === void 0 ? void 0 : _this$job$metadata$fi.value) || 'Unknown';
144
+ this.jobStatus = (_this$job2 = this.job) === null || _this$job2 === void 0 ? void 0 : (_this$job2$progress = _this$job2.progress) === null || _this$job2$progress === void 0 ? void 0 : _this$job2$progress.status;
145
+ if ((_this$job3 = this.job) !== null && _this$job3 !== void 0 && _this$job3.completedAt) {
146
146
  this.jobAge = (new Date().getTime() - new Date(this.job.completedAt).getTime()) / 1000 / 60;
147
147
  } else {
148
148
  this.jobAge = undefined;
@@ -150,14 +150,14 @@ class BackupDBCommand {
150
150
  return this.job;
151
151
  }
152
152
  async run(silent = false) {
153
- var _this$job;
153
+ var _this$job4;
154
154
  this.silent = silent;
155
155
  let noticeMessage = `\n${_chalk.default.yellow('NOTICE: ')}`;
156
156
  noticeMessage += 'If a recent database backup does not exist, a new one will be generated for this environment. ';
157
157
  noticeMessage += 'Learn more about this: https://docs.wpvip.com/technical-references/vip-dashboard/backups/#2-download-a-full-database-backup \n';
158
158
  this.log(noticeMessage);
159
159
  await this.loadBackupJob();
160
- if ((_this$job = this.job) !== null && _this$job !== void 0 && _this$job.inProgressLock) {
160
+ if ((_this$job4 = this.job) !== null && _this$job4 !== void 0 && _this$job4.inProgressLock) {
161
161
  this.log('Database backup already in progress...');
162
162
  } else {
163
163
  try {
@@ -165,15 +165,16 @@ class BackupDBCommand {
165
165
  this.progressTracker.stepRunning(this.steps.PREPARE);
166
166
  this.progressTracker.startPrinting();
167
167
  await createBackupJob(this.app.id, this.env.id);
168
- } catch (stepErr) {
169
- const err = stepErr;
168
+ } catch (e) {
169
+ var _err$message;
170
+ const err = e;
170
171
  this.progressTracker.stepFailed(this.steps.PREPARE);
171
172
  this.stopProgressTracker();
172
- if (err.message.includes('Database backups limit reached')) {
173
+ if ((_err$message = err.message) !== null && _err$message !== void 0 && _err$message.includes('Database backups limit reached')) {
173
174
  await this.track('error', {
174
175
  error_type: 'rate_limit_exceeded',
175
- error_message: `Couldn't create a new database backup job: ${err.message}`,
176
- stack: err.stack
176
+ error_message: `Couldn't create a new database backup job: ${err === null || err === void 0 ? void 0 : err.message}`,
177
+ stack: err === null || err === void 0 ? void 0 : err.stack
177
178
  });
178
179
  let errMessage = err.message.replace('Database backups limit reached', 'A new database backup was not generated because a recently generated backup already exists.');
179
180
  errMessage = errMessage.replace('Retry after', '\nIf you would like to run the same command, you can retry on or after:');
@@ -183,26 +184,26 @@ class BackupDBCommand {
183
184
  }
184
185
  await this.track('error', {
185
186
  error_type: 'db_backup_job_creation_failed',
186
- error_message: `Database Backup job creation failed: ${err.message}`,
187
- stack: err.stack
187
+ error_message: `Database Backup job creation failed: ${err === null || err === void 0 ? void 0 : err.message}`,
188
+ stack: err === null || err === void 0 ? void 0 : err.stack
188
189
  });
189
- exit.withError(`Couldn't create a new database backup job: ${err.message}`);
190
+ exit.withError(`Couldn't create a new database backup job: ${err === null || err === void 0 ? void 0 : err.message}`);
190
191
  }
191
192
  }
192
193
  this.progressTracker.stepSuccess(this.steps.PREPARE);
193
194
  this.progressTracker.stepRunning(this.steps.GENERATE);
194
195
  try {
195
196
  await (0, _utils.pollUntil)(this.loadBackupJob.bind(this), DB_BACKUP_PROGRESS_POLL_INTERVAL, this.isDone.bind(this));
196
- } catch (pollErr) {
197
- const err = pollErr;
197
+ } catch (e) {
198
+ const err = e;
198
199
  this.progressTracker.stepFailed(this.steps.GENERATE);
199
200
  this.stopProgressTracker();
200
201
  await this.track('error', {
201
202
  error_type: 'db_backup_job_failed',
202
- error_message: `Database Backup job failed: ${err.message}`,
203
- stack: err.stack
203
+ error_message: `Database Backup job failed: ${err === null || err === void 0 ? void 0 : err.message}`,
204
+ stack: err === null || err === void 0 ? void 0 : err.stack
204
205
  });
205
- exit.withError(`Failed to create new database backup: ${err.message}`);
206
+ exit.withError(`Failed to create new database backup: ${err === null || err === void 0 ? void 0 : err.message}`);
206
207
  }
207
208
  this.progressTracker.stepSuccess(this.steps.GENERATE);
208
209
  this.stopProgressTracker();
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.31.1-dev4",
3
+ "version": "2.31.1-dev5",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "2.31.1-dev4",
9
+ "version": "2.31.1-dev5",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.31.1-dev4",
3
+ "version": "2.31.1-dev5",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {