roast-my-codebase 1.3.6 → 1.3.7
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/index.js +20 -53
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10709,64 +10709,36 @@ function filterFindingsByChangedLines(findings, changedRanges) {
|
|
|
10709
10709
|
// src/ci/index.ts
|
|
10710
10710
|
import fs38 from "fs";
|
|
10711
10711
|
import path24 from "path";
|
|
10712
|
-
function
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
const installCmd = packageManager === "yarn" ? "yarn install --frozen-lockfile" : packageManager === "pnpm" ? "pnpm install --frozen-lockfile" : "npm ci";
|
|
10720
|
-
const scanCmd = [
|
|
10721
|
-
"npx roast-my-codebase --json",
|
|
10722
|
-
`--threshold ${threshold}`,
|
|
10723
|
-
prComment ? "--pr-comment" : "",
|
|
10724
|
-
sarif ? "--sarif-file" : ""
|
|
10725
|
-
].filter(Boolean).join(" ");
|
|
10726
|
-
const permissionsLines = [" contents: read"];
|
|
10727
|
-
if (prComment) permissionsLines.push(" pull-requests: write");
|
|
10728
|
-
if (sarif) permissionsLines.push(" security-events: write");
|
|
10729
|
-
const permissionsBlock = permissionsLines.join("\n");
|
|
10730
|
-
const sarifStep = sarif ? `
|
|
10731
|
-
- name: Upload SARIF to GitHub Code Scanning
|
|
10732
|
-
uses: github/codeql-action/upload-sarif@v4
|
|
10733
|
-
if: always()
|
|
10734
|
-
with:
|
|
10735
|
-
sarif_file: .roast-results.sarif` : "";
|
|
10712
|
+
function generateCIWorkflow(config = {}) {
|
|
10713
|
+
const { threshold, aiRoasts } = config;
|
|
10714
|
+
const failBelow = threshold !== void 0 ? `
|
|
10715
|
+
fail-below: "${threshold}"` : "";
|
|
10716
|
+
const aiBlock = aiRoasts ? `
|
|
10717
|
+
ai-roasts: "true"
|
|
10718
|
+
anthropic-api-key: \${{ secrets.ANTHROPIC_API_KEY }}` : "";
|
|
10736
10719
|
return `name: Roast My Codebase
|
|
10737
10720
|
|
|
10738
10721
|
on:
|
|
10739
|
-
push:
|
|
10740
|
-
branches: [main, master]
|
|
10741
10722
|
pull_request:
|
|
10742
|
-
|
|
10723
|
+
types: [opened, synchronize, reopened]
|
|
10724
|
+
|
|
10725
|
+
permissions:
|
|
10726
|
+
pull-requests: write
|
|
10743
10727
|
|
|
10744
10728
|
jobs:
|
|
10745
10729
|
roast:
|
|
10746
|
-
name: Roast Codebase
|
|
10747
10730
|
runs-on: ubuntu-latest
|
|
10748
|
-
permissions:
|
|
10749
|
-
${permissionsBlock}
|
|
10750
|
-
|
|
10751
10731
|
steps:
|
|
10752
10732
|
- uses: actions/checkout@v4
|
|
10753
|
-
|
|
10754
|
-
- name: Setup Node.js
|
|
10755
|
-
uses: actions/setup-node@v4
|
|
10756
10733
|
with:
|
|
10757
|
-
|
|
10758
|
-
cache: '${packageManager}'
|
|
10759
|
-
|
|
10760
|
-
- name: Install dependencies
|
|
10761
|
-
run: ${installCmd}
|
|
10734
|
+
fetch-depth: 0
|
|
10762
10735
|
|
|
10763
|
-
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}${sarifStep}
|
|
10736
|
+
- uses: rahuldk1105/roast-my-codebase@v1
|
|
10737
|
+
with:
|
|
10738
|
+
github-token: \${{ secrets.GITHUB_TOKEN }}${failBelow}${aiBlock}
|
|
10767
10739
|
`;
|
|
10768
10740
|
}
|
|
10769
|
-
function writeCIWorkflow(rootDir, config) {
|
|
10741
|
+
function writeCIWorkflow(rootDir, config = {}) {
|
|
10770
10742
|
const workflowsDir = path24.join(rootDir, ".github", "workflows");
|
|
10771
10743
|
const filePath = path24.join(workflowsDir, "roast.yml");
|
|
10772
10744
|
const displayPath = filePath.split(path24.sep).join("/");
|
|
@@ -10776,8 +10748,7 @@ function writeCIWorkflow(rootDir, config) {
|
|
|
10776
10748
|
if (!fs38.existsSync(workflowsDir)) {
|
|
10777
10749
|
fs38.mkdirSync(workflowsDir, { recursive: true });
|
|
10778
10750
|
}
|
|
10779
|
-
|
|
10780
|
-
fs38.writeFileSync(filePath, yaml, "utf-8");
|
|
10751
|
+
fs38.writeFileSync(filePath, generateCIWorkflow(config), "utf-8");
|
|
10781
10752
|
return { path: displayPath, alreadyExists: false };
|
|
10782
10753
|
}
|
|
10783
10754
|
|
|
@@ -13063,13 +13034,9 @@ function createCli() {
|
|
|
13063
13034
|
process.exit(0);
|
|
13064
13035
|
}
|
|
13065
13036
|
if (options.initCi) {
|
|
13066
|
-
const pm = detectPackageManager(rootDir);
|
|
13067
13037
|
const ciConfig = {
|
|
13068
|
-
threshold: options.threshold
|
|
13069
|
-
|
|
13070
|
-
sarif: true,
|
|
13071
|
-
nodeVersion: "20.x",
|
|
13072
|
-
packageManager: pm
|
|
13038
|
+
threshold: options.threshold,
|
|
13039
|
+
aiRoasts: options.aiRoasts
|
|
13073
13040
|
};
|
|
13074
13041
|
const result = writeCIWorkflow(rootDir, ciConfig);
|
|
13075
13042
|
if (result.alreadyExists) {
|
|
@@ -13081,7 +13048,7 @@ function createCli() {
|
|
|
13081
13048
|
console.log(chalk12.green(`
|
|
13082
13049
|
\u2713 Created ${result.path}
|
|
13083
13050
|
`));
|
|
13084
|
-
console.log(chalk12.dim("
|
|
13051
|
+
console.log(chalk12.dim(" Uses rahuldk1105/roast-my-codebase@v1 \u2014 no extra secrets needed.\n"));
|
|
13085
13052
|
console.log(chalk12.dim(" Commit and push to activate.\n"));
|
|
13086
13053
|
}
|
|
13087
13054
|
process.exit(0);
|
package/package.json
CHANGED