@xcelera/cli 2.1.2 → 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.
- package/dist/action.js +95 -33
- package/dist/action.js.map +1 -1
- package/dist/cli.js +101 -47
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/action.js
CHANGED
|
@@ -36566,62 +36566,124 @@ async function inferBuildContext() {
|
|
|
36566
36566
|
branch: ('prBranch' in ciEnv && ciEnv.prBranch ? ciEnv.prBranch : ciEnv.branch) ??
|
|
36567
36567
|
undefined
|
|
36568
36568
|
};
|
|
36569
|
-
|
|
36569
|
+
return {
|
|
36570
36570
|
service: ciEnv.isCi ? ciEnv.service : 'unknown',
|
|
36571
36571
|
prNumber: 'pr' in ciEnv ? ciEnv.pr : undefined,
|
|
36572
36572
|
buildNumber: 'build' in ciEnv ? ciEnv.build : undefined,
|
|
36573
36573
|
buildUrl: 'buildUrl' in ciEnv ? ciEnv.buildUrl : undefined,
|
|
36574
36574
|
git: gitContext
|
|
36575
36575
|
};
|
|
36576
|
-
console.log('🔍 Inferred build context:');
|
|
36577
|
-
if (buildContext.service) {
|
|
36578
|
-
console.log(` • service: ${buildContext.service}`);
|
|
36579
|
-
}
|
|
36580
|
-
console.log(` • repository: ${gitContext.owner}/${gitContext.repo}`);
|
|
36581
|
-
console.log(` • branch: ${gitContext.branch}`);
|
|
36582
|
-
console.log(` • commit: ${gitContext.commit.hash}`);
|
|
36583
|
-
console.log('');
|
|
36584
|
-
return buildContext;
|
|
36585
36576
|
}
|
|
36586
36577
|
|
|
36587
|
-
|
|
36588
|
-
|
|
36578
|
+
async function runAuditCommand(url, token) {
|
|
36579
|
+
const output = [];
|
|
36580
|
+
const errors = [];
|
|
36589
36581
|
try {
|
|
36590
|
-
const url = coreExports.getInput('url', { required: true });
|
|
36591
|
-
const token = coreExports.getInput('token', { required: true });
|
|
36592
36582
|
const buildContext = await inferBuildContext();
|
|
36593
|
-
|
|
36583
|
+
output.push(...formatBuildContext(buildContext));
|
|
36594
36584
|
const response = await requestAudit(url, token, buildContext);
|
|
36595
36585
|
if (!response.success) {
|
|
36596
36586
|
const { message, details } = response.error;
|
|
36597
|
-
|
|
36598
|
-
|
|
36587
|
+
errors.push('❌ Unable to schedule audit :(');
|
|
36588
|
+
errors.push(` ↳ ${message}`);
|
|
36599
36589
|
if (details) {
|
|
36600
|
-
|
|
36590
|
+
errors.push(` ↳ ${details}`);
|
|
36601
36591
|
}
|
|
36602
|
-
|
|
36603
|
-
return;
|
|
36592
|
+
return { exitCode: 1, output, errors };
|
|
36604
36593
|
}
|
|
36605
36594
|
const { auditId, status, integrations } = response.data;
|
|
36606
|
-
|
|
36607
|
-
|
|
36608
|
-
|
|
36609
|
-
|
|
36610
|
-
|
|
36611
|
-
|
|
36612
|
-
|
|
36613
|
-
coreExports.warning('The xcelera.dev Github app is installed, but it does not have repository access.');
|
|
36595
|
+
output.push('✅ Audit scheduled successfully!');
|
|
36596
|
+
if (process.env.DEBUG) {
|
|
36597
|
+
output.push('');
|
|
36598
|
+
output.push(`Audit ID: ${auditId}`);
|
|
36599
|
+
output.push(`Status: ${status}`);
|
|
36600
|
+
if (Object.keys(integrations).length === 0) {
|
|
36601
|
+
output.push('No integrations detected');
|
|
36614
36602
|
}
|
|
36615
|
-
coreExports.debug(` ↳ installation ID: ${integrations.github.installationId}`);
|
|
36616
|
-
coreExports.debug(` ↳ check run ID: ${integrations.github.checkRunId}`);
|
|
36617
|
-
coreExports.debug(` ↳ installation has repo access: ${integrations.github.hasRepoAccess}`);
|
|
36618
36603
|
}
|
|
36604
|
+
if (integrations?.github) {
|
|
36605
|
+
const githubOutput = formatGitHubIntegrationStatus(integrations.github);
|
|
36606
|
+
output.push(...githubOutput.output);
|
|
36607
|
+
errors.push(...githubOutput.errors);
|
|
36608
|
+
}
|
|
36609
|
+
return { exitCode: 0, output, errors };
|
|
36619
36610
|
}
|
|
36620
36611
|
catch (error) {
|
|
36621
36612
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
36622
|
-
|
|
36623
|
-
|
|
36613
|
+
errors.push(`❌ ${errorMessage}`);
|
|
36614
|
+
return { exitCode: 1, output, errors };
|
|
36615
|
+
}
|
|
36616
|
+
}
|
|
36617
|
+
function formatBuildContext(context) {
|
|
36618
|
+
const logs = [];
|
|
36619
|
+
logs.push('🔍 Inferred build context:');
|
|
36620
|
+
if (context.service) {
|
|
36621
|
+
logs.push(` • service: ${context.service}`);
|
|
36622
|
+
}
|
|
36623
|
+
if (context.git) {
|
|
36624
|
+
logs.push(` • repository: ${context.git.owner}/${context.git.repo}`);
|
|
36625
|
+
logs.push(` • branch: ${context.git.branch}`);
|
|
36626
|
+
logs.push(` • commit: ${context.git.commit.hash}`);
|
|
36627
|
+
}
|
|
36628
|
+
logs.push('');
|
|
36629
|
+
return logs;
|
|
36630
|
+
}
|
|
36631
|
+
function formatGitHubIntegrationStatus(context) {
|
|
36632
|
+
const output = [];
|
|
36633
|
+
const errors = [];
|
|
36634
|
+
output.push('');
|
|
36635
|
+
switch (context.status) {
|
|
36636
|
+
case 'success': {
|
|
36637
|
+
output.push('✅ GitHub integration detected!');
|
|
36638
|
+
if (process.env.DEBUG) {
|
|
36639
|
+
output.push(` ↳ installation ID: ${context.installationId}`);
|
|
36640
|
+
output.push(` ↳ check run ID: ${context.checkRunId}`);
|
|
36641
|
+
}
|
|
36642
|
+
break;
|
|
36643
|
+
}
|
|
36644
|
+
case 'skipped': {
|
|
36645
|
+
if (process.env.DEBUG) {
|
|
36646
|
+
const reasonMessage = context.reason === 'no_git_context'
|
|
36647
|
+
? 'no git context detected; skipping GitHub integration.'
|
|
36648
|
+
: 'GitHub app not installed; skipping GitHub integration.';
|
|
36649
|
+
output.push(`↳ GitHub integration skipped: ${reasonMessage}`);
|
|
36650
|
+
}
|
|
36651
|
+
break;
|
|
36652
|
+
}
|
|
36653
|
+
case 'misconfigured': {
|
|
36654
|
+
errors.push('⚠️ GitHub integration is misconfigured.');
|
|
36655
|
+
if (context.reason === 'no_repo_access') {
|
|
36656
|
+
errors.push('The xcelera.dev GitHub app is installed, but it does not have access to this repository.');
|
|
36657
|
+
errors.push('Please update the GitHub app installation and grant access to this repository.');
|
|
36658
|
+
}
|
|
36659
|
+
if (process.env.DEBUG) {
|
|
36660
|
+
errors.push(` ↳ installation ID: ${context.installationId}`);
|
|
36661
|
+
}
|
|
36662
|
+
break;
|
|
36663
|
+
}
|
|
36664
|
+
case 'error': {
|
|
36665
|
+
errors.push('⚠️ Something went wrong with the GitHub integration.');
|
|
36666
|
+
errors.push('Your audit was scheduled successfully, but we could not create or update the GitHub check run.');
|
|
36667
|
+
break;
|
|
36668
|
+
}
|
|
36669
|
+
}
|
|
36670
|
+
return { output, errors };
|
|
36671
|
+
}
|
|
36672
|
+
|
|
36673
|
+
/* istanbul ignore file */
|
|
36674
|
+
run();
|
|
36675
|
+
async function run() {
|
|
36676
|
+
const url = coreExports.getInput('url', { required: true });
|
|
36677
|
+
const token = coreExports.getInput('token', { required: true });
|
|
36678
|
+
const result = await runAuditCommand(url, token);
|
|
36679
|
+
result.output.forEach((line) => coreExports.info(line));
|
|
36680
|
+
result.errors.forEach((line) => coreExports.error(line));
|
|
36681
|
+
if (result.exitCode !== 0) {
|
|
36682
|
+
coreExports.setFailed('Audit command failed');
|
|
36624
36683
|
coreExports.setOutput('status', 'failed');
|
|
36625
36684
|
}
|
|
36685
|
+
else {
|
|
36686
|
+
coreExports.setOutput('status', 'success');
|
|
36687
|
+
}
|
|
36626
36688
|
}
|
|
36627
36689
|
//# sourceMappingURL=action.js.map
|