@sujithx1/optimizeguard 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/st.md +0 -93
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sujithx1/optimizeguard",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
 
6
6
  "bin": {
package/st.md DELETED
@@ -1,93 +0,0 @@
1
- // OptimizeGuard v1 - High Performance Code Quality Gate SDK
2
- // Bun / Node compatible
3
-
4
- // package.json
5
- /*
6
- {
7
- "name": "optimizeguard",
8
- "version": "1.0.0",
9
- "type": "module",
10
- "bin": { "optimizeguard": "dist/cli.js" },
11
- "scripts": {
12
- "build": "bun build src/cli.ts --outdir dist",
13
- "dev": "bun src/cli.ts"
14
- },
15
- "dependencies": {
16
- "@typescript-eslint/parser": "^7.0.0",
17
- "esbuild": "^0.20.0",
18
- "glob": "^10.3.10"
19
- }
20
- }
21
- */
22
-
23
- // src/cli.ts
24
- #!/usr/bin/env bun
25
- import { runOptimizeGuard } from "./engine.js";
26
-
27
- const result = await runOptimizeGuard();
28
- if (!result.ok) process.ex it(1);
29
-
30
- // src/engine.ts
31
- import { scanProject } from "./scanner.js";
32
- import { runRules } from "./rules/index.js";
33
- import { report } from "./reporter.js";
34
-
35
- export async function runOptimizeGuard() {
36
- console.log("⚡ OptimizeGuard v1 running...\n");
37
- const files = await scanProject();
38
- const issues = await runRules(files);
39
- report(issues);
40
- return { ok: issues.length === 0 };
41
- }
42
-
43
- // src/scanner.ts
44
- import glob from "glob";
45
- export async function scanProject() {
46
- return glob.sync("**/*.{ts,js}", { ignore: ["node_modules/**", "dist/**"] });
47
- }
48
-
49
- // src/rules/index.ts
50
- import { perfRules } from "./performance.js";
51
- import { securityRules } from "./security.js";
52
-
53
- export async function runRules(files: string[]) {
54
- const all = [...perfRules, ...securityRules];
55
- const issues = [] as any[];
56
- for (const file of files) for (const r of all) issues.push(...(await r.check(file)));
57
- return issues;
58
- }
59
-
60
- // src/rules/performance.ts
61
- import fs from "fs";
62
- export const perfRules = [
63
- {
64
- name: "await-in-loop",
65
- async check(file: string) {
66
- const c = fs.readFileSync(file, "utf8");
67
- return /for\s*\(.*\)\s*{[\s\S]*await/.test(c)
68
- ? [{ type: "PERF", file, msg: "await inside loop" }]
69
- : [];
70
- },
71
- },
72
- ];
73
-
74
- // src/rules/security.ts
75
- import fs from "fs";
76
- export const securityRules = [
77
- {
78
- name: "hardcoded-secret",
79
- async check(file: string) {
80
- const c = fs.readFileSync(file, "utf8");
81
- return /(API_KEY|SECRET|TOKEN)\s*=\s*['\"]/i.test(c)
82
- ? [{ type: "SEC", file, msg: "Hardcoded secret detected" }]
83
- : [];
84
- },
85
- },
86
- ];
87
-
88
- // src/reporter.ts
89
- export function report(issues: any[]) {
90
- if (!issues.length) return console.log("✅ Code is optimized and safe!\n");
91
- for (const i of issues) console.log(`❌ [${i.type}] ${i.msg} → ${i.file}`);
92
- console.log(`\nScore: ${100 - issues.length * 5} / 100`);
93
- }