diff --git a/README.md b/README.md index 71acfc4..01fe181 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Note: Currently we are in the process of open sourcing whole platform. Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): +--> diff --git a/checks/codechecks.ts b/checks/codechecks.ts new file mode 100644 index 0000000..5223013 --- /dev/null +++ b/checks/codechecks.ts @@ -0,0 +1,43 @@ +import { codechecks } from "@codechecks/client"; +import { execSync } from "child_process"; +import * as fs from "fs"; + +export default async () => { + // Build your project first + execSync("npm run build"); + + // Get the build size (example: dist folder) + const buildSize = getFolderSize("./dist"); + + // Save current build size as an artifact + await codechecks.saveValue("build-size", { size: buildSize }); + + // Compare with baseline (from the main branch) + const baseline = await codechecks.getValue<{ size: number }>("build-size"); + + if (baseline) { + const diff = buildSize - baseline.size; + const sign = diff >= 0 ? "+" : "-"; + + await codechecks.success({ + name: "Build Size Check", + shortDescription: `Build size: ${buildSize} bytes (${sign}${Math.abs(diff)} bytes)`, + longDescription: `## Build Size Report\n| | Size |\n|---|---|\n| Current | ${buildSize} bytes |\n| Baseline | ${baseline.size} bytes |\n| Diff | ${sign}${Math.abs(diff)} bytes |`, + }); + } else { + await codechecks.success({ + name: "Build Size Check", + shortDescription: `Build size: ${buildSize} bytes (no baseline yet)`, + longDescription: `## Build Size Report\nFirst run — baseline saved.`, + }); + } +}; + +function getFolderSize(folderPath: string): number { + // Simple size calculation — customize as needed + const files = fs.readdirSync(folderPath); + return files.reduce((total, file) => { + const stats = fs.statSync(`${folderPath}/${file}`); + return total + stats.size; + }, 0); +} \ No newline at end of file diff --git a/codechecks.yml b/codechecks.yml index 17e5b74..b269b67 100644 --- a/codechecks.yml +++ b/codechecks.yml @@ -5,3 +5,6 @@ checks: options: - name: node-gyp reason: "No native modules, please! They make installation for users much harder" + + - name: build-size-check + preset: ./checks/codechecks.ts \ No newline at end of file diff --git a/package.json b/package.json index 24c6679..f7f2a68 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,18 @@ ], "dependencies": { "typecov": "^0.2.1" - } + }, + "description": "

\r \"codechecks.io\"\r

Code Checks

\r

\r Open source platform for code review automation ✅\r

\r

\r \"Build\r \"Software\r \"All\r \"codechecks.io\"\r

\r

", + "main": "jest.config.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dariusmark-tech/monorepo.git" + }, + "keywords": [], + "author": "", + "type": "commonjs", + "bugs": { + "url": "https://github.com/dariusmark-tech/monorepo/issues" + }, + "homepage": "https://github.com/dariusmark-tech/monorepo#readme" }