@xcelera/cli 1.2.2 → 1.4.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.
Files changed (48) hide show
  1. package/dist/action.js +81 -18
  2. package/dist/action.js.map +1 -1
  3. package/dist/cli.js +94 -19
  4. package/dist/cli.js.map +1 -0
  5. package/package.json +10 -3
  6. package/.commitlintrc.json +0 -3
  7. package/.devcontainer/devcontainer.json +0 -41
  8. package/.env.example +0 -61
  9. package/.gitattributes +0 -3
  10. package/.github/dependabot.yml +0 -30
  11. package/.github/workflows/check-dist.yml +0 -72
  12. package/.github/workflows/ci.yml +0 -70
  13. package/.github/workflows/codeql-analysis.yml +0 -48
  14. package/.github/workflows/licensed.yml +0 -74
  15. package/.github/workflows/linter.yml +0 -53
  16. package/.github/workflows/release.yml +0 -56
  17. package/.licensed.yml +0 -18
  18. package/.licenses/npm/@actions/core.dep.yml +0 -20
  19. package/.licenses/npm/@actions/exec.dep.yml +0 -20
  20. package/.licenses/npm/@actions/http-client.dep.yml +0 -32
  21. package/.licenses/npm/@actions/io.dep.yml +0 -20
  22. package/.licenses/npm/@fastify/busboy.dep.yml +0 -30
  23. package/.licenses/npm/tunnel.dep.yml +0 -35
  24. package/.licenses/npm/undici.dep.yml +0 -34
  25. package/.markdown-lint.yml +0 -24
  26. package/.node-version +0 -1
  27. package/.nvmrc +0 -1
  28. package/.prettierignore +0 -5
  29. package/.prettierrc.yml +0 -16
  30. package/.vscode/launch.json +0 -15
  31. package/.yaml-lint.yml +0 -14
  32. package/CODEOWNERS +0 -7
  33. package/action.yml +0 -29
  34. package/badges/coverage.svg +0 -1
  35. package/eslint.config.mjs +0 -81
  36. package/jest.config.js +0 -40
  37. package/release.config.mjs +0 -12
  38. package/rollup.config.ts +0 -30
  39. package/script/release +0 -133
  40. package/src/action.ts +0 -35
  41. package/src/api.ts +0 -46
  42. package/src/cli.ts +0 -79
  43. package/src/git.ts +0 -66
  44. package/src/types/git.ts +0 -5
  45. package/src/types/parse-github-url.d.ts +0 -12
  46. package/tsconfig.base.json +0 -23
  47. package/tsconfig.eslint.json +0 -18
  48. package/tsconfig.json +0 -11
package/dist/action.js CHANGED
@@ -31233,29 +31233,92 @@ function requireGithub () {
31233
31233
 
31234
31234
  var githubExports = requireGithub();
31235
31235
 
31236
+ const objectToString = Object.prototype.toString;
31237
+
31238
+ const isError = value => objectToString.call(value) === '[object Error]';
31239
+
31240
+ const errorMessages = new Set([
31241
+ 'network error', // Chrome
31242
+ 'Failed to fetch', // Chrome
31243
+ 'NetworkError when attempting to fetch resource.', // Firefox
31244
+ 'The Internet connection appears to be offline.', // Safari 16
31245
+ 'Load failed', // Safari 17+
31246
+ 'Network request failed', // `cross-fetch`
31247
+ 'fetch failed', // Undici (Node.js)
31248
+ 'terminated', // Undici (Node.js)
31249
+ ]);
31250
+
31251
+ function isNetworkError(error) {
31252
+ const isValid = error
31253
+ && isError(error)
31254
+ && error.name === 'TypeError'
31255
+ && typeof error.message === 'string';
31256
+
31257
+ if (!isValid) {
31258
+ return false;
31259
+ }
31260
+
31261
+ // We do an extra check for Safari 17+ as it has a very generic error message.
31262
+ // Network errors in Safari have no stack.
31263
+ if (error.message === 'Load failed') {
31264
+ return error.stack === undefined;
31265
+ }
31266
+
31267
+ return errorMessages.has(error.message);
31268
+ }
31269
+
31236
31270
  async function requestAudit(url, token, github) {
31237
31271
  const apiUrl = `${getApiBaseUrl()}/api/v1/audit`;
31238
- const response = await fetch(apiUrl, {
31239
- method: 'POST',
31240
- headers: {
31241
- 'Content-Type': 'application/json',
31242
- Authorization: `Bearer ${token}`
31243
- },
31244
- body: JSON.stringify({
31245
- url,
31246
- github
31247
- })
31248
- });
31249
- if (!response.ok) {
31250
- const errorText = await response.text();
31251
- throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
31272
+ try {
31273
+ const response = await fetch(apiUrl, {
31274
+ method: 'POST',
31275
+ headers: {
31276
+ 'Content-Type': 'application/json',
31277
+ Authorization: `Bearer ${token}`
31278
+ },
31279
+ body: JSON.stringify({
31280
+ url,
31281
+ github
31282
+ })
31283
+ });
31284
+ if (!response.ok) {
31285
+ // handle expected errors
31286
+ if (response.headers.get('content-type')?.includes('application/json')) {
31287
+ const errorResponse = (await response.json());
31288
+ return {
31289
+ success: false,
31290
+ error: {
31291
+ code: response.status,
31292
+ message: errorResponse.error,
31293
+ details: errorResponse.details
31294
+ }
31295
+ };
31296
+ }
31297
+ // handle unexpected errors
31298
+ const errorText = await response.text();
31299
+ throw new Error(`Operation failed: ${response.status} ${response.statusText} - ${errorText}`);
31300
+ }
31301
+ const data = (await response.json());
31302
+ return {
31303
+ success: true,
31304
+ data
31305
+ };
31306
+ }
31307
+ catch (error) {
31308
+ if (isNetworkError(error)) {
31309
+ return {
31310
+ success: false,
31311
+ error: {
31312
+ message: 'Network error',
31313
+ details: error.message
31314
+ }
31315
+ };
31316
+ }
31317
+ throw error;
31252
31318
  }
31253
- const data = await response.json();
31254
- return data;
31255
31319
  }
31256
31320
  function getApiBaseUrl() {
31257
- if (process.env.NODE_ENV === 'development' ||
31258
- process.env.GITHUB_ACTIONS !== 'true') {
31321
+ if (process.env.NODE_ENV === 'development') {
31259
31322
  return 'http://localhost:3000';
31260
31323
  }
31261
31324
  return 'https://xcelera.dev';