@automattic/vip 2.27.0-dev5 → 2.27.0-dev6

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.
Binary file
@@ -17,5 +17,5 @@
17
17
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
  (0, _command.default)({
20
- requiredArgs: 2
20
+ requiredArgs: 1
21
21
  }).command('purge-url', 'Purge page cache').argv(process.argv);
@@ -17,5 +17,5 @@
17
17
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
  (0, _command.default)({
20
- requiredArgs: 1
20
+ requiredArgs: 0
21
21
  }).command('delete', 'Permanently delete an environment variable').command('get', 'Get the value of an environment variable').command('get-all', 'Get the values of all environment variable').command('list', 'List the names of all environment variables').command('set', 'Add or update an environment variable').argv(process.argv);
@@ -13,7 +13,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
13
13
  var _tracker = require("../lib/tracker");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  (0, _command.default)({
16
- requiredArgs: 1
16
+ requiredArgs: 0
17
17
  }).command('preflight', 'Runs preflight tests to validate if your application is ready to be deployed').argv(process.argv, async () => {
18
18
  await (0, _tracker.trackEvent)('vip_validate_command_execute');
19
19
  });
@@ -8,7 +8,7 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
  var _https = _interopRequireDefault(require("https"));
10
10
  var _path = _interopRequireDefault(require("path"));
11
- var _api = _interopRequireDefault(require("../lib/api"));
11
+ var _api = _interopRequireWildcard(require("../lib/api"));
12
12
  var _format = require("../lib/cli/format");
13
13
  var _progress = require("../lib/cli/progress");
14
14
  var exit = _interopRequireWildcard(require("../lib/cli/exit"));
@@ -162,8 +162,10 @@ async function generateDownloadLink(appId, envId, backupId) {
162
162
  * @throws {Error} Throws an error if the job creation fails
163
163
  */
164
164
  async function createExportJob(appId, envId, backupId) {
165
+ // Disable global error handling so that we can handle errors ourselves
166
+ (0, _api.disableGlobalGraphQLErrorHandling)();
165
167
  const api = await (0, _api.default)();
166
- const response = await api.mutate({
168
+ await api.mutate({
167
169
  mutation: CREATE_EXPORT_JOB_MUTATION,
168
170
  variables: {
169
171
  input: {
@@ -173,16 +175,9 @@ async function createExportJob(appId, envId, backupId) {
173
175
  }
174
176
  }
175
177
  });
176
- const {
177
- data: {
178
- startDBBackupCopy: {
179
- success
180
- }
181
- }
182
- } = response;
183
- if (!success) {
184
- throw new Error();
185
- }
178
+
179
+ // Re-enable global error handling
180
+ (0, _api.enableGlobalGraphQLErrorHandling)();
186
181
  }
187
182
 
188
183
  /**
@@ -195,6 +190,7 @@ class ExportSQLCommand {
195
190
  DOWNLOAD_LINK: 'downloadLink',
196
191
  DOWNLOAD: 'download'
197
192
  };
193
+
198
194
  /**
199
195
  * Creates an instance of SQLExportCommand
200
196
  *
@@ -231,7 +227,6 @@ class ExportSQLCommand {
231
227
  latestBackup,
232
228
  jobs
233
229
  } = await fetchLatestBackupAndJobStatus(this.app.id, this.env.id);
234
- this.runningJobs = jobs.filter(job => job.progress.status === 'running');
235
230
 
236
231
  // Find the job that generates the export for the latest backup
237
232
  return jobs.find(job => {
@@ -316,10 +311,8 @@ class ExportSQLCommand {
316
311
  async run() {
317
312
  console.log(`Fetching the latest backup for ${this.app.name}`);
318
313
  const {
319
- latestBackup,
320
- jobs
314
+ latestBackup
321
315
  } = await fetchLatestBackupAndJobStatus(this.app.id, this.env.id);
322
- this.runningJobs = jobs.filter(job => job.progress.status === 'running');
323
316
  if (!latestBackup) {
324
317
  exit.withError(`No backup found for site ${this.app.name}`);
325
318
  } else {
@@ -327,13 +320,15 @@ class ExportSQLCommand {
327
320
  }
328
321
  if (await this.getExportJob()) {
329
322
  console.log(`Attaching to an existing export for the backup with timestamp ${latestBackup.createdAt}`);
330
- } else if (this.runningJobs.length > 0) {
331
- exit.withError('There is an export job already running for this site: ' + `https://dashboard.wpvip.com/apps/${this.app.id}/${this.env.uniqueLabel}/data/database/backups\n` + 'Currently, we allow only one export job per site. Please try again later.');
332
323
  } else {
333
324
  console.log(`Creating a new export for the backup with timestamp ${latestBackup.createdAt}`);
334
325
  try {
335
326
  await createExportJob(this.app.id, this.env.id, latestBackup.id);
336
327
  } catch (err) {
328
+ // Todo: match error code instead of message substring
329
+ if (err !== null && err !== void 0 && err.message.includes('Backup Copy already in progress')) {
330
+ exit.withError('There is an export job already running for this site: ' + `https://dashboard.wpvip.com/apps/${this.app.id}/${this.env.uniqueLabel}/data/database/backups\n` + 'Currently, we allow only one export job per site. Please try again later.');
331
+ }
337
332
  exit.withError(`Error creating export job: ${err === null || err === void 0 ? void 0 : err.message}`);
338
333
  }
339
334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.27.0-dev5",
3
+ "version": "2.27.0-dev6",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {
Binary file