@reallavo/clonecheck 0.1.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.
Files changed (94) hide show
  1. package/.env.example +2 -0
  2. package/.gitattributes +1 -0
  3. package/.github/workflows/ci.yml +24 -0
  4. package/CONTRIBUTING.md +22 -0
  5. package/LICENSE +21 -0
  6. package/README.md +205 -0
  7. package/action/README.md +34 -0
  8. package/action/action.yml +50 -0
  9. package/clonecheck.config.json +5 -0
  10. package/docs/checks.md +44 -0
  11. package/docs/config.md +36 -0
  12. package/docs/scoring.md +20 -0
  13. package/eslint.config.js +29 -0
  14. package/examples/docker-compose-missing-env/.env.example +1 -0
  15. package/examples/docker-compose-missing-env/README.md +5 -0
  16. package/examples/docker-compose-missing-env/docker-compose.yml +12 -0
  17. package/examples/node-basic/.env.example +1 -0
  18. package/examples/node-basic/README.md +8 -0
  19. package/examples/node-basic/package.json +15 -0
  20. package/examples/node-basic/pnpm-lock.yaml +5 -0
  21. package/examples/node-basic/src-index.ts +1 -0
  22. package/examples/node-missing-env/.env.example +1 -0
  23. package/examples/node-missing-env/README.md +8 -0
  24. package/examples/node-missing-env/package.json +11 -0
  25. package/examples/node-missing-env/pnpm-lock.yaml +5 -0
  26. package/examples/node-missing-env/src/app.ts +14 -0
  27. package/examples/python-basic/.env.example +1 -0
  28. package/examples/python-basic/README.md +8 -0
  29. package/examples/python-basic/app.py +6 -0
  30. package/examples/python-basic/requirements.txt +1 -0
  31. package/package.json +40 -0
  32. package/packages/cli/LICENSE +21 -0
  33. package/packages/cli/README.md +15 -0
  34. package/packages/cli/package.json +55 -0
  35. package/packages/cli/src/index.ts +186 -0
  36. package/packages/cli/tsconfig.json +11 -0
  37. package/packages/core/LICENSE +21 -0
  38. package/packages/core/README.md +11 -0
  39. package/packages/core/package.json +51 -0
  40. package/packages/core/src/checks/ciPresence.ts +35 -0
  41. package/packages/core/src/checks/dockerComposeEnv.ts +61 -0
  42. package/packages/core/src/checks/envExample.ts +31 -0
  43. package/packages/core/src/checks/helpers.ts +54 -0
  44. package/packages/core/src/checks/index.ts +24 -0
  45. package/packages/core/src/checks/packageManagerConsistency.ts +65 -0
  46. package/packages/core/src/checks/portDocumentation.ts +62 -0
  47. package/packages/core/src/checks/projectFiles.ts +77 -0
  48. package/packages/core/src/checks/readmeCommands.ts +87 -0
  49. package/packages/core/src/checks/scriptsAvailability.ts +69 -0
  50. package/packages/core/src/config.ts +96 -0
  51. package/packages/core/src/detectors/dockerCompose.ts +62 -0
  52. package/packages/core/src/detectors/env.ts +189 -0
  53. package/packages/core/src/detectors/packageManager.ts +54 -0
  54. package/packages/core/src/detectors/ports.ts +99 -0
  55. package/packages/core/src/detectors/project.ts +50 -0
  56. package/packages/core/src/detectors/readme.ts +131 -0
  57. package/packages/core/src/index.ts +31 -0
  58. package/packages/core/src/reporters/index.ts +3 -0
  59. package/packages/core/src/reporters/json.ts +5 -0
  60. package/packages/core/src/reporters/labels.ts +40 -0
  61. package/packages/core/src/reporters/markdown.ts +63 -0
  62. package/packages/core/src/reporters/text.ts +108 -0
  63. package/packages/core/src/run.ts +111 -0
  64. package/packages/core/src/scoring.ts +60 -0
  65. package/packages/core/src/types.ts +85 -0
  66. package/packages/core/src/utils/files.ts +109 -0
  67. package/packages/core/tests/config.test.ts +53 -0
  68. package/packages/core/tests/detectors.test.ts +127 -0
  69. package/packages/core/tests/fixtures/docker-compose-missing-env/.env.example +1 -0
  70. package/packages/core/tests/fixtures/docker-compose-missing-env/README.md +5 -0
  71. package/packages/core/tests/fixtures/docker-compose-missing-env/docker-compose.yml +6 -0
  72. package/packages/core/tests/fixtures/env-missing/.env.example +1 -0
  73. package/packages/core/tests/fixtures/env-missing/README.md +6 -0
  74. package/packages/core/tests/fixtures/env-missing/package-lock.json +4 -0
  75. package/packages/core/tests/fixtures/env-missing/package.json +8 -0
  76. package/packages/core/tests/fixtures/env-missing/src.py +4 -0
  77. package/packages/core/tests/fixtures/node-pnpm-readme-npm/.env.example +1 -0
  78. package/packages/core/tests/fixtures/node-pnpm-readme-npm/README.md +8 -0
  79. package/packages/core/tests/fixtures/node-pnpm-readme-npm/package.json +8 -0
  80. package/packages/core/tests/fixtures/node-pnpm-readme-npm/pnpm-lock.yaml +1 -0
  81. package/packages/core/tests/fixtures/node-pnpm-readme-npm/src.ts +3 -0
  82. package/packages/core/tests/reporters.test.ts +43 -0
  83. package/packages/core/tests/run.test.ts +37 -0
  84. package/packages/core/tests/scoring.test.ts +33 -0
  85. package/packages/core/tsconfig.json +8 -0
  86. package/packages/npm/LICENSE +21 -0
  87. package/packages/npm/README.md +17 -0
  88. package/packages/npm/package.json +54 -0
  89. package/packages/npm/src/index.ts +2 -0
  90. package/packages/npm/tsconfig.json +12 -0
  91. package/pnpm-workspace.yaml +4 -0
  92. package/prettier.config.js +5 -0
  93. package/scripts/build-package.mjs +30 -0
  94. package/tsconfig.base.json +17 -0
@@ -0,0 +1,60 @@
1
+ import type { ClonecheckCheckResult, ClonecheckIssue, ClonecheckReport, Severity } from "./types.js";
2
+
3
+ const DEFAULT_PENALTIES: Record<Severity, number> = {
4
+ error: 15,
5
+ warning: 7,
6
+ info: 2
7
+ };
8
+
9
+ const STRICT_PENALTIES: Record<Severity, number> = {
10
+ error: 15,
11
+ warning: 10,
12
+ info: 3
13
+ };
14
+
15
+ export function scoreImpactForIssues(issues: ClonecheckIssue[], strict = false): number {
16
+ const penalties = strict ? STRICT_PENALTIES : DEFAULT_PENALTIES;
17
+ return issues.reduce((total, issue) => total + penalties[issue.severity], 0);
18
+ }
19
+
20
+ export function scoreChecks(
21
+ checks: ClonecheckCheckResult[],
22
+ strict = false
23
+ ): { score: number; checks: ClonecheckCheckResult[] } {
24
+ const scoredChecks = checks.map((check) => ({
25
+ ...check,
26
+ scoreImpact: check.status === "skip" ? 0 : scoreImpactForIssues(check.issues, strict)
27
+ }));
28
+ const totalImpact = scoredChecks.reduce((total, check) => total + check.scoreImpact, 0);
29
+ return {
30
+ score: Math.max(0, 100 - totalImpact),
31
+ checks: scoredChecks
32
+ };
33
+ }
34
+
35
+ export function statusFromScore(score: number): ClonecheckReport["status"] {
36
+ if (score >= 90) {
37
+ return "excellent";
38
+ }
39
+ if (score >= 75) {
40
+ return "good";
41
+ }
42
+ if (score >= 50) {
43
+ return "needs-work";
44
+ }
45
+
46
+ return "poor";
47
+ }
48
+
49
+ export function collectSuggestions(checks: ClonecheckCheckResult[]): string[] {
50
+ const suggestions = new Set<string>();
51
+ for (const check of checks) {
52
+ for (const issue of check.issues) {
53
+ if (issue.suggestion) {
54
+ suggestions.add(issue.suggestion);
55
+ }
56
+ }
57
+ }
58
+
59
+ return Array.from(suggestions);
60
+ }
@@ -0,0 +1,85 @@
1
+ export const CLONECHECK_VERSION = "0.1.0";
2
+
3
+ export type Severity = "info" | "warning" | "error";
4
+ export type CheckStatus = "pass" | "warning" | "fail" | "skip";
5
+ export type ProjectType = "node" | "python" | "go" | "rust" | "docker";
6
+ export type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
7
+
8
+ export interface ClonecheckIssue {
9
+ id: string;
10
+ title: string;
11
+ message: string;
12
+ severity: Severity;
13
+ file?: string;
14
+ line?: number;
15
+ suggestion?: string;
16
+ }
17
+
18
+ export interface ClonecheckCheckResult {
19
+ id: string;
20
+ title: string;
21
+ status: CheckStatus;
22
+ issues: ClonecheckIssue[];
23
+ scoreImpact: number;
24
+ }
25
+
26
+ export interface ClonecheckReport {
27
+ repoPath: string;
28
+ projectName: string;
29
+ score: number;
30
+ status: "excellent" | "good" | "needs-work" | "poor";
31
+ checks: ClonecheckCheckResult[];
32
+ suggestions: string[];
33
+ metadata: {
34
+ detectedProjectTypes: string[];
35
+ detectedPackageManager?: string;
36
+ generatedAt: string;
37
+ clonecheckVersion: string;
38
+ };
39
+ }
40
+
41
+ export interface RunClonecheckOptions {
42
+ repoPath: string;
43
+ configPath?: string;
44
+ strict?: boolean;
45
+ }
46
+
47
+ export interface ClonecheckConfig {
48
+ ignore: string[];
49
+ ignoreEnvVars: string[];
50
+ checks: Record<string, boolean>;
51
+ }
52
+
53
+ export interface PackageJson {
54
+ name?: string;
55
+ packageManager?: string;
56
+ scripts?: Record<string, string>;
57
+ dependencies?: Record<string, string>;
58
+ devDependencies?: Record<string, string>;
59
+ }
60
+
61
+ export interface ClonecheckContext {
62
+ repoPath: string;
63
+ files: string[];
64
+ config: ClonecheckConfig;
65
+ packageJson?: unknown;
66
+ readmeText?: string;
67
+ envExampleText?: string;
68
+ envExampleVars: Set<string>;
69
+ detectedProjectTypes: ProjectType[];
70
+ detectedPackageManager?: PackageManager;
71
+ strict: boolean;
72
+ }
73
+
74
+ export interface ClonecheckCheck {
75
+ id: string;
76
+ title: string;
77
+ description: string;
78
+ run(context: ClonecheckContext): Promise<ClonecheckCheckResult>;
79
+ }
80
+
81
+ export const DEFAULT_CONFIG: ClonecheckConfig = {
82
+ ignore: [],
83
+ ignoreEnvVars: [],
84
+ checks: {}
85
+ };
@@ -0,0 +1,109 @@
1
+ import { access, readFile, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import fg from "fast-glob";
4
+
5
+ export const DEFAULT_FILE_IGNORE = [
6
+ "**/node_modules/**",
7
+ "**/.git/**",
8
+ "**/dist/**",
9
+ "**/build/**",
10
+ "**/.next/**",
11
+ "**/coverage/**"
12
+ ];
13
+
14
+ const TEXT_EXTENSIONS = new Set([
15
+ ".cjs",
16
+ ".go",
17
+ ".js",
18
+ ".json",
19
+ ".jsx",
20
+ ".mjs",
21
+ ".md",
22
+ ".py",
23
+ ".rs",
24
+ ".sh",
25
+ ".toml",
26
+ ".ts",
27
+ ".tsx",
28
+ ".txt",
29
+ ".yaml",
30
+ ".yml"
31
+ ]);
32
+
33
+ export function normalizeRelativePath(filePath: string): string {
34
+ return filePath.split(path.sep).join("/");
35
+ }
36
+
37
+ export function absolutePath(repoPath: string, relativePath: string): string {
38
+ return path.join(repoPath, relativePath);
39
+ }
40
+
41
+ export async function pathExists(filePath: string): Promise<boolean> {
42
+ try {
43
+ await access(filePath);
44
+ return true;
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ export async function discoverFiles(repoPath: string, ignore: string[] = []): Promise<string[]> {
51
+ const files = await fg(["**/*"], {
52
+ cwd: repoPath,
53
+ dot: true,
54
+ onlyFiles: true,
55
+ followSymbolicLinks: false,
56
+ unique: true,
57
+ ignore: [...DEFAULT_FILE_IGNORE, ...ignore]
58
+ });
59
+
60
+ return files.map(normalizeRelativePath).sort((a, b) => a.localeCompare(b));
61
+ }
62
+
63
+ export async function readTextFile(repoPath: string, relativePath: string): Promise<string | undefined> {
64
+ const target = absolutePath(repoPath, relativePath);
65
+ try {
66
+ const info = await stat(target);
67
+ if (info.size > 1_000_000) {
68
+ return undefined;
69
+ }
70
+
71
+ return await readFile(target, "utf8");
72
+ } catch {
73
+ return undefined;
74
+ }
75
+ }
76
+
77
+ export function isLikelyTextFile(relativePath: string): boolean {
78
+ const baseName = path.basename(relativePath);
79
+ if (
80
+ baseName === ".env.example" ||
81
+ baseName === ".env.sample" ||
82
+ baseName === ".env.template" ||
83
+ baseName === "example.env"
84
+ ) {
85
+ return true;
86
+ }
87
+
88
+ return TEXT_EXTENSIONS.has(path.extname(relativePath));
89
+ }
90
+
91
+ export function findCaseInsensitive(files: string[], expected: string): string | undefined {
92
+ const expectedLower = expected.toLowerCase();
93
+ return files.find((file) => file.toLowerCase() === expectedLower);
94
+ }
95
+
96
+ export function findAnyCaseInsensitive(files: string[], expected: string[]): string | undefined {
97
+ for (const filename of expected) {
98
+ const match = findCaseInsensitive(files, filename);
99
+ if (match) {
100
+ return match;
101
+ }
102
+ }
103
+
104
+ return undefined;
105
+ }
106
+
107
+ export function lineNumberFromIndex(text: string, index: number): number {
108
+ return text.slice(0, index).split(/\r?\n/).length;
109
+ }
@@ -0,0 +1,53 @@
1
+ import { mkdtemp, writeFile } from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, expect, it } from "vitest";
5
+ import { ClonecheckConfigError, initConfig, loadConfig } from "../src/index.js";
6
+
7
+ describe("config loading", () => {
8
+ it("loads default config when no file exists", async () => {
9
+ const repoPath = await mkdtemp(path.join(os.tmpdir(), "clonecheck-config-"));
10
+ const { config } = await loadConfig(repoPath);
11
+
12
+ expect(config).toEqual({
13
+ ignore: [],
14
+ ignoreEnvVars: [],
15
+ checks: {}
16
+ });
17
+ });
18
+
19
+ it("validates clonecheck config files", async () => {
20
+ const repoPath = await mkdtemp(path.join(os.tmpdir(), "clonecheck-config-"));
21
+ await writeFile(
22
+ path.join(repoPath, "clonecheck.config.json"),
23
+ JSON.stringify({
24
+ ignore: ["examples/**"],
25
+ ignoreEnvVars: ["CUSTOM_IGNORE"],
26
+ checks: { "ci-presence": false }
27
+ }),
28
+ "utf8"
29
+ );
30
+
31
+ const { config } = await loadConfig(repoPath);
32
+
33
+ expect(config.ignore).toEqual(["examples/**"]);
34
+ expect(config.ignoreEnvVars).toEqual(["CUSTOM_IGNORE"]);
35
+ expect(config.checks["ci-presence"]).toBe(false);
36
+ });
37
+
38
+ it("throws a friendly error for invalid config", async () => {
39
+ const repoPath = await mkdtemp(path.join(os.tmpdir(), "clonecheck-config-"));
40
+ await writeFile(path.join(repoPath, "clonecheck.config.json"), JSON.stringify({ ignore: "nope" }), "utf8");
41
+
42
+ await expect(loadConfig(repoPath)).rejects.toBeInstanceOf(ClonecheckConfigError);
43
+ });
44
+
45
+ it("creates a default config without overwriting existing files", async () => {
46
+ const repoPath = await mkdtemp(path.join(os.tmpdir(), "clonecheck-config-"));
47
+ const first = await initConfig(repoPath);
48
+ const second = await initConfig(repoPath);
49
+
50
+ expect(first.created).toBe(true);
51
+ expect(second.created).toBe(false);
52
+ });
53
+ });
@@ -0,0 +1,127 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import path from "node:path";
3
+ import { describe, expect, it } from "vitest";
4
+ import {
5
+ detectPackageManager,
6
+ extractDockerComposeEnvVars,
7
+ extractEnvVarUsages,
8
+ extractReadmeCommands,
9
+ findMissingEnvVars,
10
+ isPackageInstallCommand,
11
+ parseEnvExampleVars
12
+ } from "../src/index.js";
13
+ import { discoverFiles, readTextFile } from "../src/utils/files.js";
14
+
15
+ const fixturesPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "fixtures");
16
+
17
+ describe("package manager detection", () => {
18
+ it("detects pnpm from lockfiles", () => {
19
+ const detection = detectPackageManager(["package.json", "pnpm-lock.yaml"]);
20
+
21
+ expect(detection.manager).toBe("pnpm");
22
+ expect(detection.lockfiles).toEqual(["pnpm-lock.yaml"]);
23
+ });
24
+ });
25
+
26
+ describe("README command extraction", () => {
27
+ it("extracts package manager and docker commands from shell blocks", () => {
28
+ const commands = extractReadmeCommands(`
29
+ # App
30
+
31
+ \`\`\`bash
32
+ pnpm install
33
+ pnpm dev
34
+ pnpm --filter @clonecheck/cli dev -- scan .
35
+ docker compose up
36
+ \`\`\`
37
+ `);
38
+
39
+ expect(commands.map((command) => command.command)).toEqual([
40
+ "pnpm install",
41
+ "pnpm dev",
42
+ "pnpm --filter @clonecheck/cli dev -- scan .",
43
+ "docker compose up"
44
+ ]);
45
+ expect(commands.map((command) => command.kind)).toEqual(["install", "run", "run", "docker"]);
46
+ });
47
+
48
+ it("distinguishes repo installs from package installation examples", () => {
49
+ expect(isPackageInstallCommand("npm install")).toBe(false);
50
+ expect(isPackageInstallCommand("pnpm install --frozen-lockfile")).toBe(false);
51
+ expect(isPackageInstallCommand("npm install --save-dev clonecheck")).toBe(true);
52
+ expect(isPackageInstallCommand("pnpm add -D clonecheck")).toBe(false);
53
+ });
54
+ });
55
+
56
+ describe("environment variable detection", () => {
57
+ it("detects supported JS, Python, Go, and Rust env patterns", () => {
58
+ const usages = extractEnvVarUsages(
59
+ `
60
+ process.env.DATABASE_URL
61
+ process.env["JWT_SECRET"]
62
+ process.env['STRIPE_SECRET_KEY']
63
+ import.meta.env.VITE_API_URL
64
+ os.environ["PYTHON_SECRET"]
65
+ os.getenv("PYTHON_OPTIONAL")
66
+ os.Getenv("GO_SECRET")
67
+ std::env::var("RUST_SECRET")
68
+ `,
69
+ "src/config.ts"
70
+ );
71
+
72
+ expect(usages.map((usage) => usage.name)).toEqual([
73
+ "DATABASE_URL",
74
+ "JWT_SECRET",
75
+ "STRIPE_SECRET_KEY",
76
+ "VITE_API_URL",
77
+ "PYTHON_SECRET",
78
+ "PYTHON_OPTIONAL",
79
+ "GO_SECRET",
80
+ "RUST_SECRET"
81
+ ]);
82
+ });
83
+
84
+ it("compares detected env vars with documented examples", () => {
85
+ const documented = parseEnvExampleVars(`
86
+ DATABASE_URL=
87
+ # Comment
88
+ export VITE_API_URL=
89
+ `);
90
+ const missing = findMissingEnvVars(
91
+ [
92
+ { name: "DATABASE_URL", file: "src/app.ts", line: 1 },
93
+ { name: "JWT_SECRET", file: "src/app.ts", line: 2 },
94
+ { name: "VITE_API_URL", file: "src/app.ts", line: 3 }
95
+ ],
96
+ documented
97
+ );
98
+
99
+ expect(missing).toEqual(["JWT_SECRET"]);
100
+ });
101
+ });
102
+
103
+ describe("Docker Compose env detection", () => {
104
+ it("extracts variable references with and without defaults", () => {
105
+ const refs = extractDockerComposeEnvVars(
106
+ `
107
+ services:
108
+ db:
109
+ environment:
110
+ POSTGRES_PASSWORD: \${POSTGRES_PASSWORD:-postgres}
111
+ DATABASE_URL: \${DATABASE_URL}
112
+ `,
113
+ "docker-compose.yml"
114
+ );
115
+
116
+ expect(refs.map((ref) => ref.name)).toEqual(["POSTGRES_PASSWORD", "DATABASE_URL"]);
117
+ });
118
+
119
+ it("discovers compose fixtures from disk", async () => {
120
+ const repoPath = path.join(fixturesPath, "docker-compose-missing-env");
121
+ const files = await discoverFiles(repoPath);
122
+ const compose = await readTextFile(repoPath, "docker-compose.yml");
123
+
124
+ expect(files).toContain("docker-compose.yml");
125
+ expect(compose).toContain("POSTGRES_PASSWORD");
126
+ });
127
+ });
@@ -0,0 +1,5 @@
1
+ # Compose Fixture
2
+
3
+ ```bash
4
+ docker compose up
5
+ ```
@@ -0,0 +1,6 @@
1
+ services:
2
+ api:
3
+ image: node:20
4
+ environment:
5
+ DATABASE_URL: ${DATABASE_URL}
6
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
@@ -0,0 +1 @@
1
+ DATABASE_URL=
@@ -0,0 +1,6 @@
1
+ # Env Missing
2
+
3
+ ```bash
4
+ npm install
5
+ npm run dev
6
+ ```
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "env-missing",
3
+ "lockfileVersion": 3
4
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "env-missing",
3
+ "private": true,
4
+ "scripts": {
5
+ "dev": "node src/app.js",
6
+ "test": "node --test"
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ import os
2
+
3
+ database_url = os.environ["DATABASE_URL"]
4
+ jwt_secret = os.getenv("JWT_SECRET")
@@ -0,0 +1,8 @@
1
+ # Fixture
2
+
3
+ ```bash
4
+ npm install
5
+ npm run dev
6
+ ```
7
+
8
+ Open http://localhost:3000.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "node-pnpm-readme-npm",
3
+ "private": true,
4
+ "scripts": {
5
+ "dev": "vite --port 5173",
6
+ "test": "vitest run"
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ lockfileVersion: '9.0'
@@ -0,0 +1,3 @@
1
+ const url = process.env.DATABASE_URL;
2
+ const secret = process.env.JWT_SECRET;
3
+ const port = 5173;
@@ -0,0 +1,43 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { formatMarkdownReport, type ClonecheckReport } from "../src/index.js";
3
+
4
+ describe("markdown reporter", () => {
5
+ it("renders a GitHub-friendly report", () => {
6
+ const report: ClonecheckReport = {
7
+ repoPath: "/tmp/app",
8
+ projectName: "app",
9
+ score: 72,
10
+ status: "needs-work",
11
+ checks: [
12
+ {
13
+ id: "env-example",
14
+ title: "Environment example",
15
+ status: "warning",
16
+ issues: [
17
+ {
18
+ id: "env-example.JWT_SECRET",
19
+ title: "Environment variable is undocumented",
20
+ message: "Environment variable JWT_SECRET is used but missing from .env.example.",
21
+ severity: "warning",
22
+ suggestion: "Add JWT_SECRET= to .env.example."
23
+ }
24
+ ],
25
+ scoreImpact: 7
26
+ }
27
+ ],
28
+ suggestions: ["Add JWT_SECRET= to .env.example."],
29
+ metadata: {
30
+ detectedProjectTypes: ["node"],
31
+ detectedPackageManager: "pnpm",
32
+ generatedAt: "2026-07-08T00:00:00.000Z",
33
+ clonecheckVersion: "0.1.0"
34
+ }
35
+ };
36
+
37
+ const markdown = formatMarkdownReport(report);
38
+
39
+ expect(markdown).toContain("# Clonecheck Report");
40
+ expect(markdown).toContain("| env-example |");
41
+ expect(markdown).toContain("## Suggestions");
42
+ });
43
+ });
@@ -0,0 +1,37 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import path from "node:path";
3
+ import { describe, expect, it } from "vitest";
4
+ import { formatJsonReport, runClonecheck } from "../src/index.js";
5
+
6
+ const fixturesPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "fixtures");
7
+
8
+ describe("runClonecheck", () => {
9
+ it("reports package-manager and port mismatches", async () => {
10
+ const report = await runClonecheck({
11
+ repoPath: path.join(fixturesPath, "node-pnpm-readme-npm")
12
+ });
13
+
14
+ expect(report.metadata.detectedPackageManager).toBe("pnpm");
15
+ expect(report.checks.find((check) => check.id === "readme-commands")?.status).toBe("warning");
16
+ expect(report.checks.find((check) => check.id === "port-documentation")?.status).toBe("warning");
17
+ });
18
+
19
+ it("reports missing env example variables", async () => {
20
+ const report = await runClonecheck({
21
+ repoPath: path.join(fixturesPath, "env-missing")
22
+ });
23
+
24
+ const envCheck = report.checks.find((check) => check.id === "env-example");
25
+ expect(envCheck?.issues.map((issue) => issue.id)).toContain("env-example.JWT_SECRET");
26
+ });
27
+
28
+ it("emits valid JSON", async () => {
29
+ const report = await runClonecheck({
30
+ repoPath: path.join(fixturesPath, "env-missing")
31
+ });
32
+
33
+ expect(JSON.parse(formatJsonReport(report))).toMatchObject({
34
+ projectName: "env-missing"
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,33 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { scoreImpactForIssues, statusFromScore } from "../src/index.js";
3
+
4
+ describe("scoring", () => {
5
+ it("scores normal mode severities", () => {
6
+ expect(
7
+ scoreImpactForIssues([
8
+ { id: "a", title: "A", message: "A", severity: "error" },
9
+ { id: "b", title: "B", message: "B", severity: "warning" },
10
+ { id: "c", title: "C", message: "C", severity: "info" }
11
+ ])
12
+ ).toBe(24);
13
+ });
14
+
15
+ it("scores strict mode severities", () => {
16
+ expect(
17
+ scoreImpactForIssues(
18
+ [
19
+ { id: "a", title: "A", message: "A", severity: "warning" },
20
+ { id: "b", title: "B", message: "B", severity: "info" }
21
+ ],
22
+ true
23
+ )
24
+ ).toBe(13);
25
+ });
26
+
27
+ it("maps scores to statuses", () => {
28
+ expect(statusFromScore(95)).toBe("excellent");
29
+ expect(statusFromScore(80)).toBe("good");
30
+ expect(statusFromScore(60)).toBe("needs-work");
31
+ expect(statusFromScore(40)).toBe("poor");
32
+ });
33
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "outDir": "dist"
6
+ },
7
+ "include": ["src/**/*.ts", "tests/**/*.ts"]
8
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 clonecheck contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ # clonecheck
2
+
3
+ Know if your repo is actually cloneable.
4
+
5
+ Run without installing:
6
+
7
+ ```bash
8
+ npx clonecheck scan
9
+ ```
10
+
11
+ Install locally:
12
+
13
+ ```bash
14
+ npm install --save-dev clonecheck
15
+ ```
16
+
17
+ Full documentation: https://github.com/reallav0/clonecheck