@xcelera/cli 1.3.0 → 1.4.1
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 +35 -12
- package/dist/action.js.map +1 -1
- package/dist/cli.js +34 -5
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
package/dist/action.js
CHANGED
|
@@ -31282,15 +31282,30 @@ async function requestAudit(url, token, github) {
|
|
|
31282
31282
|
})
|
|
31283
31283
|
});
|
|
31284
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 errorResponse;
|
|
31289
|
+
}
|
|
31290
|
+
// handle unexpected errors
|
|
31285
31291
|
const errorText = await response.text();
|
|
31286
|
-
throw new Error(`
|
|
31292
|
+
throw new Error(`Operation failed: ${response.status} ${response.statusText} - ${errorText}`);
|
|
31287
31293
|
}
|
|
31288
|
-
const data = await response.json();
|
|
31289
|
-
return
|
|
31294
|
+
const { data } = (await response.json());
|
|
31295
|
+
return {
|
|
31296
|
+
success: true,
|
|
31297
|
+
data
|
|
31298
|
+
};
|
|
31290
31299
|
}
|
|
31291
31300
|
catch (error) {
|
|
31292
31301
|
if (isNetworkError(error)) {
|
|
31293
|
-
|
|
31302
|
+
return {
|
|
31303
|
+
success: false,
|
|
31304
|
+
error: {
|
|
31305
|
+
message: 'Network error',
|
|
31306
|
+
details: error.message
|
|
31307
|
+
}
|
|
31308
|
+
};
|
|
31294
31309
|
}
|
|
31295
31310
|
throw error;
|
|
31296
31311
|
}
|
|
@@ -31307,23 +31322,31 @@ async function run() {
|
|
|
31307
31322
|
try {
|
|
31308
31323
|
const url = coreExports.getInput('url', { required: true });
|
|
31309
31324
|
const token = coreExports.getInput('token', { required: true });
|
|
31310
|
-
coreExports.debug(`Auditing URL: ${url}`);
|
|
31311
|
-
coreExports.debug('Calling Xcelera audit API...');
|
|
31312
31325
|
const githubContext = {
|
|
31313
31326
|
owner: githubExports.context.repo.owner,
|
|
31314
31327
|
repo: githubExports.context.repo.repo,
|
|
31315
31328
|
sha: githubExports.context.sha
|
|
31316
31329
|
};
|
|
31330
|
+
coreExports.debug(`Calling xcelera audit API with URL: ${url}`);
|
|
31317
31331
|
const response = await requestAudit(url, token, githubContext);
|
|
31318
|
-
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
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!');
|
|
31324
31346
|
}
|
|
31325
31347
|
catch (error) {
|
|
31326
31348
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
31349
|
+
coreExports.error(`❌ ${errorMessage}`);
|
|
31327
31350
|
coreExports.setFailed(errorMessage);
|
|
31328
31351
|
coreExports.setOutput('status', 'failed');
|
|
31329
31352
|
}
|