@xcelera/cli 1.4.0 → 1.5.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/dist/action.js CHANGED
@@ -31285,20 +31285,13 @@ async function requestAudit(url, token, github) {
31285
31285
  // handle expected errors
31286
31286
  if (response.headers.get('content-type')?.includes('application/json')) {
31287
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
- };
31288
+ return errorResponse;
31296
31289
  }
31297
31290
  // handle unexpected errors
31298
31291
  const errorText = await response.text();
31299
31292
  throw new Error(`Operation failed: ${response.status} ${response.statusText} - ${errorText}`);
31300
31293
  }
31301
- const data = (await response.json());
31294
+ const { data } = (await response.json());
31302
31295
  return {
31303
31296
  success: true,
31304
31297
  data
@@ -31329,23 +31322,31 @@ async function run() {
31329
31322
  try {
31330
31323
  const url = coreExports.getInput('url', { required: true });
31331
31324
  const token = coreExports.getInput('token', { required: true });
31332
- coreExports.debug(`Auditing URL: ${url}`);
31333
- coreExports.debug('Calling Xcelera audit API...');
31334
31325
  const githubContext = {
31335
31326
  owner: githubExports.context.repo.owner,
31336
31327
  repo: githubExports.context.repo.repo,
31337
31328
  sha: githubExports.context.sha
31338
31329
  };
31330
+ coreExports.debug(`Calling xcelera audit API with URL: ${url}`);
31339
31331
  const response = await requestAudit(url, token, githubContext);
31340
- // Set outputs
31341
- coreExports.setOutput('auditId', response.auditId);
31342
- coreExports.setOutput('status', response.status);
31343
- coreExports.info(`✅ Audit scheduled successfully!`);
31344
- coreExports.info(`Audit ID: ${response.auditId}`);
31345
- coreExports.info(`Status: ${response.status}`);
31332
+ if (!response.success) {
31333
+ const { message, details } = response.error;
31334
+ coreExports.setFailed('❌ Failed to schedule audit');
31335
+ coreExports.error(message);
31336
+ if (details) {
31337
+ coreExports.error(` ${details}`);
31338
+ }
31339
+ coreExports.setOutput('status', 'failed');
31340
+ return;
31341
+ }
31342
+ const { auditId, status } = response.data;
31343
+ coreExports.setOutput('auditId', auditId);
31344
+ coreExports.setOutput('status', status);
31345
+ coreExports.info('✅ Audit scheduled successfully!');
31346
31346
  }
31347
31347
  catch (error) {
31348
31348
  const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
31349
+ coreExports.error(`❌ ${errorMessage}`);
31349
31350
  coreExports.setFailed(errorMessage);
31350
31351
  coreExports.setOutput('status', 'failed');
31351
31352
  }