@devicecloud.dev/dcd 2.1.0 → 2.2.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.
@@ -47,6 +47,7 @@ export default class Cloud extends Command {
47
47
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
48
48
  orientation: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
49
49
  quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
50
+ retry: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
50
51
  };
51
52
  run(): Promise<void>;
52
53
  }
@@ -55,9 +55,15 @@ class Cloud extends core_1.Command {
55
55
  }
56
56
  await (0, methods_1.versionCheck)(this.config.version);
57
57
  const { args, flags, raw } = await this.parse(Cloud);
58
- const { 'additional-app-binary-ids': nonFlatAdditionalAppBinaryIds, 'additional-app-files': nonFlatAdditionalAppFiles, 'android-api-level': androidApiLevel, 'android-device': androidDevice, apiKey, apiUrl, 'app-binary-id': appBinaryId, 'app-file': appFile, async, 'device-locale': deviceLocale, 'download-artifacts': downloadArtifacts, env, 'exclude-flows': excludeFlows, 'exclude-tags': excludeTags, flows, 'google-play': googlePlay, 'include-tags': includeTags, 'ios-device': iOSDevice, 'ios-version': iOSVersion, 'maestro-version': maestroVersion, name, orientation, quiet, ...rest } = flags;
58
+ const { 'additional-app-binary-ids': nonFlatAdditionalAppBinaryIds, 'additional-app-files': nonFlatAdditionalAppFiles, 'android-api-level': androidApiLevel, 'android-device': androidDevice, apiKey, apiUrl, 'app-binary-id': appBinaryId, 'app-file': appFile, async, 'device-locale': deviceLocale, 'download-artifacts': downloadArtifacts, env, 'exclude-flows': excludeFlows, 'exclude-tags': excludeTags, flows, 'google-play': googlePlay, 'include-tags': includeTags, 'ios-device': iOSDevice, 'ios-version': iOSVersion, 'maestro-version': maestroVersion, name, orientation, quiet, retry, ...rest } = flags;
59
59
  if (!apiKey)
60
60
  throw new Error('You must provide an API key');
61
+ if (retry) {
62
+ if (retry < 0)
63
+ throw new Error('Retry must be a positive number');
64
+ if (retry > 3)
65
+ throw new Error('Retry must be 3 or less');
66
+ }
61
67
  const additionalAppBinaryIds = nonFlatAdditionalAppBinaryIds?.flat();
62
68
  const additionalAppFiles = nonFlatAdditionalAppFiles?.flat();
63
69
  const { firstFile, secondFile } = args;
@@ -186,6 +192,7 @@ class Cloud extends core_1.Command {
186
192
  const config = {
187
193
  allExcludeTags,
188
194
  allIncludeTags,
195
+ autoRetriesRemaining: retry,
189
196
  continueOnFailure,
190
197
  deviceLocale,
191
198
  maestroVersion,
@@ -250,8 +257,8 @@ class Cloud extends core_1.Command {
250
257
  if (!quiet) {
251
258
  core_1.ux.action.status =
252
259
  '\nStatus Test\n─────────── ───────────────';
253
- for (const { status, test_file_name: test } of updatedResults) {
254
- core_1.ux.action.status += `\n${status.padEnd(10, ' ')} ${test}`;
260
+ for (const { retry_of: isRetry, status, test_file_name: test, } of updatedResults) {
261
+ core_1.ux.action.status += `\n${status.padEnd(10, ' ')} ${test} ${isRetry ? '(retry)' : ''}`;
255
262
  }
256
263
  }
257
264
  if (updatedResults.every((result) => !['PENDING', 'RUNNING'].includes(result.status))) {
@@ -259,7 +266,9 @@ class Cloud extends core_1.Command {
259
266
  (0, cli_ux_1.info)('\n');
260
267
  (0, cli_ux_1.table)(updatedResults, {
261
268
  status: { get: (row) => row.status },
262
- test: { get: (row) => row.test_file_name },
269
+ test: {
270
+ get: (row) => `${row.test_file_name} ${row.retry_of ? '(retry)' : ''}`,
271
+ },
263
272
  }, { printLine: this.log.bind(this) });
264
273
  (0, cli_ux_1.info)('\n');
265
274
  (0, cli_ux_1.info)('Run completed, you can access the results at:');
@@ -282,7 +291,11 @@ class Cloud extends core_1.Command {
282
291
  this.warn('Failed to download artifacts');
283
292
  }
284
293
  }
285
- if (updatedResults.some((result) => result.status === 'FAILED')) {
294
+ const resultsWithoutEarlierTries = updatedResults.filter((result) => {
295
+ const beenRetried = updatedResults.find((r) => r.retry_of === result.id);
296
+ return !beenRetried;
297
+ });
298
+ if (resultsWithoutEarlierTries.some((result) => result.status === 'FAILED')) {
286
299
  // eslint-disable-next-line unicorn/no-process-exit
287
300
  process.exit(2);
288
301
  }
@@ -23,6 +23,7 @@ export declare const flags: {
23
23
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
24
24
  orientation: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
25
25
  quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
+ retry: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
26
27
  };
27
28
  export declare const iOSCompatibilityLookup: {
28
29
  [k in EiOSDevices]: string[];
package/dist/constants.js CHANGED
@@ -121,7 +121,7 @@ exports.flags = {
121
121
  }),
122
122
  'maestro-version': core_1.Flags.string({
123
123
  aliases: ['maestroVersion'],
124
- description: '[ALPHA pre-release] - Maestro version to run your flow against',
124
+ description: 'Maestro version to run your flow against',
125
125
  options: [
126
126
  '1.36.0',
127
127
  '1.37.0',
@@ -136,6 +136,7 @@ exports.flags = {
136
136
  '1.37.9',
137
137
  '1.38.1',
138
138
  '1.39.0',
139
+ '1.39.1',
139
140
  ],
140
141
  }),
141
142
  name: core_1.Flags.string({
@@ -150,6 +151,9 @@ exports.flags = {
150
151
  default: false,
151
152
  description: 'Quieter console output that wont provide progress updates',
152
153
  }),
154
+ retry: core_1.Flags.integer({
155
+ description: 'Number of times to retry the run if it fails (same as pressing retry in the UI, this will deduct credits from your account)',
156
+ }),
153
157
  };
154
158
  exports.iOSCompatibilityLookup = {
155
159
  'ipad-pro-6th-gen': ['16', '17', '18'],
@@ -35,25 +35,40 @@ function isFlowFile(filePath) {
35
35
  return filePath.endsWith('.yaml') || filePath.endsWith('.yml');
36
36
  }
37
37
  const readYamlFileAsJson = (filePath) => {
38
- const yamlText = fs.readFileSync(filePath, 'utf8');
39
- return yaml.load(yamlText);
38
+ try {
39
+ const yamlText = fs.readFileSync(filePath, 'utf8');
40
+ return yaml.load(yamlText);
41
+ }
42
+ catch (error) {
43
+ const message = `Error parsing YAML file ${filePath}: ${error}`;
44
+ console.error(message);
45
+ throw new Error(message);
46
+ }
40
47
  };
41
48
  exports.readYamlFileAsJson = readYamlFileAsJson;
42
49
  const readTestYamlFileAsJson = (filePath) => {
43
- const yamlText = fs.readFileSync(filePath, 'utf8');
44
- if (yamlText.includes('\n---\n')) {
45
- const yamlTexts = yamlText.split('\n---\n');
46
- const config = yaml.load(yamlTexts[0]);
47
- const testSteps = yaml.load(yamlTexts[1]);
48
- if (Object.keys(config ?? {}).length > 0) {
49
- return { config, testSteps };
50
+ try {
51
+ const yamlText = fs.readFileSync(filePath, 'utf8');
52
+ const normalizedText = yamlText.replaceAll('\r\n', '\n');
53
+ if (normalizedText.includes('\n---\n')) {
54
+ const yamlTexts = normalizedText.split('\n---\n');
55
+ const config = yaml.load(yamlTexts[0]);
56
+ const testSteps = yaml.load(yamlTexts[1]);
57
+ if (Object.keys(config ?? {}).length > 0) {
58
+ return { config, testSteps };
59
+ }
60
+ }
61
+ const testSteps = yaml.load(yamlText);
62
+ if (Object.keys(testSteps).length > 0) {
63
+ return { config: null, testSteps };
50
64
  }
51
- }
52
- const testSteps = yaml.load(yamlText);
53
- if (Object.keys(testSteps).length > 0) {
54
65
  return { config: null, testSteps };
55
66
  }
56
- return { config: null, testSteps };
67
+ catch (error) {
68
+ const message = `Error parsing YAML file ${filePath}: ${error}`;
69
+ console.error(message);
70
+ throw new Error(message);
71
+ }
57
72
  };
58
73
  exports.readTestYamlFileAsJson = readTestYamlFileAsJson;
59
74
  async function readDirectory(dir, filterFunction) {
@@ -222,7 +222,7 @@
222
222
  "aliases": [
223
223
  "maestroVersion"
224
224
  ],
225
- "description": "[ALPHA pre-release] - Maestro version to run your flow against",
225
+ "description": "Maestro version to run your flow against",
226
226
  "name": "maestro-version",
227
227
  "hasDynamicHelp": false,
228
228
  "multiple": false,
@@ -239,7 +239,8 @@
239
239
  "1.37.8",
240
240
  "1.37.9",
241
241
  "1.38.1",
242
- "1.39.0"
242
+ "1.39.0",
243
+ "1.39.1"
243
244
  ],
244
245
  "type": "option"
245
246
  },
@@ -269,6 +270,13 @@
269
270
  "name": "quiet",
270
271
  "allowNo": false,
271
272
  "type": "boolean"
273
+ },
274
+ "retry": {
275
+ "description": "Number of times to retry the run if it fails (same as pressing retry in the UI, this will deduct credits from your account)",
276
+ "name": "retry",
277
+ "hasDynamicHelp": false,
278
+ "multiple": false,
279
+ "type": "option"
272
280
  }
273
281
  },
274
282
  "hasDynamicHelp": false,
@@ -287,5 +295,5 @@
287
295
  ]
288
296
  }
289
297
  },
290
- "version": "2.1.0"
298
+ "version": "2.2.0"
291
299
  }
package/package.json CHANGED
@@ -80,7 +80,7 @@
80
80
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
81
81
  "version": "oclif readme && git add README.md"
82
82
  },
83
- "version": "2.1.0",
83
+ "version": "2.2.0",
84
84
  "bugs": {
85
85
  "url": "https://discord.gg/gm3mJwcNw8"
86
86
  },