Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!--Do not remove or modify this section -->-->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
Expand Down
43 changes: 43 additions & 0 deletions checks/codechecks.ts
Original file line number Diff line number Diff line change
@@ -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);
}
3 changes: 3 additions & 0 deletions codechecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,18 @@
],
"dependencies": {
"typecov": "^0.2.1"
}
},
"description": "<p align=\"center\">\r <a href=\"https://codechecks.io\"><img src=\"./images/codechecks.png\" width=\"600\" alt=\"codechecks.io\"></a>\r <h1 align=\"center\">Code Checks</h1>\r <p align=\"center\">\r Open source platform for code review automation ✅\r </p>\r <p align=\"center\">\r <a href=\"https://circleci.com/gh/codechecks/monorepo\"><img alt=\"Build Status\" src=\"https://circleci.com/gh/codechecks/monorepo/tree/master.svg?style=svg\"></a>\r <a href=\"/package.json\"><img alt=\"Software License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"></a>\r <img src=\"https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square\" alt=\"All Contributors\">\r <a href=\"https://codechecks.io\"><img src=\"https://raw.githubusercontent.com/codechecks/docs/master/images/badges/badge-default.svg?sanitize=true\" alt=\"codechecks.io\"></a>\r </p>\r </p>",
"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"
}