clonecheck-monorepo 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.
- package/.env.example +2 -0
- package/.gitattributes +1 -0
- package/.github/workflows/ci.yml +24 -0
- package/CONTRIBUTING.md +22 -0
- package/LICENSE +21 -0
- package/README.md +205 -0
- package/action/README.md +34 -0
- package/action/action.yml +50 -0
- package/clonecheck.config.json +5 -0
- package/docs/checks.md +44 -0
- package/docs/config.md +36 -0
- package/docs/scoring.md +20 -0
- package/eslint.config.js +29 -0
- package/examples/docker-compose-missing-env/.env.example +1 -0
- package/examples/docker-compose-missing-env/README.md +5 -0
- package/examples/docker-compose-missing-env/docker-compose.yml +12 -0
- package/examples/node-basic/.env.example +1 -0
- package/examples/node-basic/README.md +8 -0
- package/examples/node-basic/package.json +15 -0
- package/examples/node-basic/pnpm-lock.yaml +5 -0
- package/examples/node-basic/src-index.ts +1 -0
- package/examples/node-missing-env/.env.example +1 -0
- package/examples/node-missing-env/README.md +8 -0
- package/examples/node-missing-env/package.json +11 -0
- package/examples/node-missing-env/pnpm-lock.yaml +5 -0
- package/examples/node-missing-env/src/app.ts +14 -0
- package/examples/python-basic/.env.example +1 -0
- package/examples/python-basic/README.md +8 -0
- package/examples/python-basic/app.py +6 -0
- package/examples/python-basic/requirements.txt +1 -0
- package/package.json +40 -0
- package/packages/cli/LICENSE +21 -0
- package/packages/cli/README.md +15 -0
- package/packages/cli/package.json +55 -0
- package/packages/cli/src/index.ts +186 -0
- package/packages/cli/tsconfig.json +11 -0
- package/packages/core/LICENSE +21 -0
- package/packages/core/README.md +11 -0
- package/packages/core/package.json +51 -0
- package/packages/core/src/checks/ciPresence.ts +35 -0
- package/packages/core/src/checks/dockerComposeEnv.ts +61 -0
- package/packages/core/src/checks/envExample.ts +31 -0
- package/packages/core/src/checks/helpers.ts +54 -0
- package/packages/core/src/checks/index.ts +24 -0
- package/packages/core/src/checks/packageManagerConsistency.ts +65 -0
- package/packages/core/src/checks/portDocumentation.ts +62 -0
- package/packages/core/src/checks/projectFiles.ts +77 -0
- package/packages/core/src/checks/readmeCommands.ts +87 -0
- package/packages/core/src/checks/scriptsAvailability.ts +69 -0
- package/packages/core/src/config.ts +96 -0
- package/packages/core/src/detectors/dockerCompose.ts +62 -0
- package/packages/core/src/detectors/env.ts +189 -0
- package/packages/core/src/detectors/packageManager.ts +54 -0
- package/packages/core/src/detectors/ports.ts +99 -0
- package/packages/core/src/detectors/project.ts +50 -0
- package/packages/core/src/detectors/readme.ts +131 -0
- package/packages/core/src/index.ts +31 -0
- package/packages/core/src/reporters/index.ts +3 -0
- package/packages/core/src/reporters/json.ts +5 -0
- package/packages/core/src/reporters/labels.ts +40 -0
- package/packages/core/src/reporters/markdown.ts +63 -0
- package/packages/core/src/reporters/text.ts +108 -0
- package/packages/core/src/run.ts +111 -0
- package/packages/core/src/scoring.ts +60 -0
- package/packages/core/src/types.ts +85 -0
- package/packages/core/src/utils/files.ts +109 -0
- package/packages/core/tests/config.test.ts +53 -0
- package/packages/core/tests/detectors.test.ts +127 -0
- package/packages/core/tests/fixtures/docker-compose-missing-env/.env.example +1 -0
- package/packages/core/tests/fixtures/docker-compose-missing-env/README.md +5 -0
- package/packages/core/tests/fixtures/docker-compose-missing-env/docker-compose.yml +6 -0
- package/packages/core/tests/fixtures/env-missing/.env.example +1 -0
- package/packages/core/tests/fixtures/env-missing/README.md +6 -0
- package/packages/core/tests/fixtures/env-missing/package-lock.json +4 -0
- package/packages/core/tests/fixtures/env-missing/package.json +8 -0
- package/packages/core/tests/fixtures/env-missing/src.py +4 -0
- package/packages/core/tests/fixtures/node-pnpm-readme-npm/.env.example +1 -0
- package/packages/core/tests/fixtures/node-pnpm-readme-npm/README.md +8 -0
- package/packages/core/tests/fixtures/node-pnpm-readme-npm/package.json +8 -0
- package/packages/core/tests/fixtures/node-pnpm-readme-npm/pnpm-lock.yaml +1 -0
- package/packages/core/tests/fixtures/node-pnpm-readme-npm/src.ts +3 -0
- package/packages/core/tests/reporters.test.ts +43 -0
- package/packages/core/tests/run.test.ts +37 -0
- package/packages/core/tests/scoring.test.ts +33 -0
- package/packages/core/tsconfig.json +8 -0
- package/packages/npm/LICENSE +21 -0
- package/packages/npm/README.md +17 -0
- package/packages/npm/package.json +54 -0
- package/packages/npm/src/index.ts +2 -0
- package/packages/npm/tsconfig.json +12 -0
- package/pnpm-workspace.yaml +4 -0
- package/prettier.config.js +5 -0
- package/scripts/build-package.mjs +30 -0
- package/tsconfig.base.json +17 -0
|
@@ -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,15 @@
|
|
|
1
|
+
# @clonecheck/cli
|
|
2
|
+
|
|
3
|
+
CLI package for clonecheck.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @clonecheck/cli scan
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Most users should install or run the unscoped `clonecheck` package:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx clonecheck scan
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Full documentation: https://github.com/reallav0/clonecheck
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clonecheck/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for clonecheck.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/reallav0/clonecheck.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/reallav0/clonecheck/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/reallav0/clonecheck#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"clonecheck",
|
|
17
|
+
"cli",
|
|
18
|
+
"developer-experience",
|
|
19
|
+
"repository",
|
|
20
|
+
"readme"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"bin": {
|
|
34
|
+
"clonecheck": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node ../../scripts/build-package.mjs .",
|
|
43
|
+
"dev": "tsx src/index.ts",
|
|
44
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
45
|
+
"scan": "tsx src/index.ts scan",
|
|
46
|
+
"test": "vitest run --passWithNoTests",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"prepack": "pnpm build"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@clonecheck/core": "workspace:*",
|
|
52
|
+
"commander": "^12.1.0",
|
|
53
|
+
"picocolors": "^1.1.1"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import pc from "picocolors";
|
|
6
|
+
import {
|
|
7
|
+
CLONECHECK_VERSION,
|
|
8
|
+
ClonecheckConfigError,
|
|
9
|
+
createClonecheckContext,
|
|
10
|
+
formatJsonReport,
|
|
11
|
+
formatMarkdownReport,
|
|
12
|
+
formatTextReport,
|
|
13
|
+
generateEnvExample,
|
|
14
|
+
initConfig,
|
|
15
|
+
runClonecheck
|
|
16
|
+
} from "@clonecheck/core";
|
|
17
|
+
|
|
18
|
+
type OutputFormat = "text" | "json" | "markdown";
|
|
19
|
+
|
|
20
|
+
interface ScanOptions {
|
|
21
|
+
format: OutputFormat;
|
|
22
|
+
output?: string;
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
config?: string;
|
|
25
|
+
color?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface GenerateEnvOptions {
|
|
29
|
+
write?: boolean;
|
|
30
|
+
config?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface InitOptions {
|
|
34
|
+
force?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function shouldShowDebug(): boolean {
|
|
38
|
+
const value = process.env.DEBUG;
|
|
39
|
+
if (!value) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return value === "*" || value.split(",").map((entry) => entry.trim()).includes("clonecheck");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function handleError(error: unknown): void {
|
|
47
|
+
if (shouldShowDebug()) {
|
|
48
|
+
console.error(error);
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (error instanceof ClonecheckConfigError) {
|
|
54
|
+
console.error(pc.red(error.message));
|
|
55
|
+
} else if (error instanceof Error) {
|
|
56
|
+
console.error(pc.red(error.message));
|
|
57
|
+
} else {
|
|
58
|
+
console.error(pc.red(String(error)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function normalizeFormat(format: string): OutputFormat {
|
|
65
|
+
if (format === "text" || format === "json" || format === "markdown") {
|
|
66
|
+
return format;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
throw new Error(`Unsupported format "${format}". Use text, json, or markdown.`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function resolveUserPath(inputPath: string): string {
|
|
73
|
+
if (path.isAbsolute(inputPath)) {
|
|
74
|
+
return inputPath;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return path.resolve(process.env.INIT_CWD ?? process.cwd(), inputPath);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function writeOutput(outputPath: string, content: string): Promise<void> {
|
|
81
|
+
const resolved = resolveUserPath(outputPath);
|
|
82
|
+
await mkdir(path.dirname(resolved), { recursive: true });
|
|
83
|
+
await writeFile(resolved, content, "utf8");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function runScan(repoPath: string, options: ScanOptions): Promise<void> {
|
|
87
|
+
const format = normalizeFormat(options.format);
|
|
88
|
+
const report = await runClonecheck({
|
|
89
|
+
repoPath: resolveUserPath(repoPath),
|
|
90
|
+
configPath: options.config,
|
|
91
|
+
strict: Boolean(options.strict)
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const output =
|
|
95
|
+
format === "json"
|
|
96
|
+
? formatJsonReport(report)
|
|
97
|
+
: format === "markdown"
|
|
98
|
+
? formatMarkdownReport(report)
|
|
99
|
+
: formatTextReport(report, { color: options.color });
|
|
100
|
+
|
|
101
|
+
if (options.output) {
|
|
102
|
+
await writeOutput(options.output, output);
|
|
103
|
+
} else {
|
|
104
|
+
process.stdout.write(output);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (options.strict && report.score < 75) {
|
|
108
|
+
process.exitCode = 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function runGenerateEnvExample(repoPath: string, options: GenerateEnvOptions): Promise<void> {
|
|
113
|
+
const { context } = await createClonecheckContext({
|
|
114
|
+
repoPath: resolveUserPath(repoPath),
|
|
115
|
+
configPath: options.config
|
|
116
|
+
});
|
|
117
|
+
const result = await generateEnvExample({
|
|
118
|
+
repoPath: context.repoPath,
|
|
119
|
+
files: context.files,
|
|
120
|
+
config: context.config,
|
|
121
|
+
write: Boolean(options.write)
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
if (options.write) {
|
|
125
|
+
const writtenPath = result.writtenPath ?? path.join(context.repoPath, ".env.example");
|
|
126
|
+
console.log(
|
|
127
|
+
`Updated ${writtenPath} with ${result.missingVars.length} missing environment variable${result.missingVars.length === 1 ? "" : "s"}.`
|
|
128
|
+
);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
process.stdout.write(result.content);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function runInit(repoPath: string, options: InitOptions): Promise<void> {
|
|
136
|
+
const result = await initConfig(resolveUserPath(repoPath), Boolean(options.force));
|
|
137
|
+
if (!result.created) {
|
|
138
|
+
console.error(`Config already exists at ${result.path}. Use --force to overwrite it.`);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
console.log(`Created ${result.path}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const program = new Command();
|
|
147
|
+
|
|
148
|
+
program
|
|
149
|
+
.name("clonecheck")
|
|
150
|
+
.description("Know if your repo is actually cloneable.")
|
|
151
|
+
.version(CLONECHECK_VERSION)
|
|
152
|
+
.showHelpAfterError();
|
|
153
|
+
|
|
154
|
+
program
|
|
155
|
+
.command("scan")
|
|
156
|
+
.description("Scan a repository for cloneability and contributor-readiness issues.")
|
|
157
|
+
.argument("[repoPath]", "repository path", ".")
|
|
158
|
+
.option("--format <format>", "output format: text, json, or markdown", "text")
|
|
159
|
+
.option("--output <file>", "write the report to a file")
|
|
160
|
+
.option("--strict", "exit with code 1 when score is below 75")
|
|
161
|
+
.option("--config <file>", "path to a clonecheck config file")
|
|
162
|
+
.option("--no-color", "disable terminal colors")
|
|
163
|
+
.action((repoPath: string, options: ScanOptions) => {
|
|
164
|
+
return runScan(repoPath, options).catch(handleError);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
program
|
|
168
|
+
.command("generate-env-example")
|
|
169
|
+
.description("Print or update a suggested .env.example based on environment variables used in code.")
|
|
170
|
+
.argument("[repoPath]", "repository path", ".")
|
|
171
|
+
.option("--write", "create or append missing variables to .env.example")
|
|
172
|
+
.option("--config <file>", "path to a clonecheck config file")
|
|
173
|
+
.action((repoPath: string, options: GenerateEnvOptions) => {
|
|
174
|
+
return runGenerateEnvExample(repoPath, options).catch(handleError);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
program
|
|
178
|
+
.command("init")
|
|
179
|
+
.description("Create a clonecheck.config.json file.")
|
|
180
|
+
.argument("[repoPath]", "repository path", ".")
|
|
181
|
+
.option("--force", "overwrite an existing config file")
|
|
182
|
+
.action((repoPath: string, options: InitOptions) => {
|
|
183
|
+
return runInit(repoPath, options).catch(handleError);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
program.parseAsync(process.argv).catch(handleError);
|
|
@@ -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,11 @@
|
|
|
1
|
+
# @clonecheck/core
|
|
2
|
+
|
|
3
|
+
Core TypeScript API for clonecheck.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { runClonecheck } from "@clonecheck/core";
|
|
7
|
+
|
|
8
|
+
const report = await runClonecheck({ repoPath: process.cwd() });
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Full documentation: https://github.com/reallav0/clonecheck
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clonecheck/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core repository usability scanner for clonecheck.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/reallav0/clonecheck.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/reallav0/clonecheck/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/reallav0/clonecheck#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"clonecheck",
|
|
17
|
+
"developer-experience",
|
|
18
|
+
"repository",
|
|
19
|
+
"readme",
|
|
20
|
+
"static-analysis"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"registry": "https://registry.npmjs.org/"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "node ../../scripts/build-package.mjs .",
|
|
40
|
+
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"prepack": "pnpm build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"fast-glob": "^3.3.3",
|
|
47
|
+
"js-yaml": "^4.1.0",
|
|
48
|
+
"picocolors": "^1.1.1",
|
|
49
|
+
"zod": "^3.24.1"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ClonecheckCheck } from "../types.js";
|
|
2
|
+
import { createIssue, createResult } from "./helpers.js";
|
|
3
|
+
|
|
4
|
+
export const ciPresenceCheck: ClonecheckCheck = {
|
|
5
|
+
id: "ci-presence",
|
|
6
|
+
title: "CI presence",
|
|
7
|
+
description: "Checks whether the repository has at least one GitHub Actions workflow.",
|
|
8
|
+
async run(context) {
|
|
9
|
+
const workflows = context.files.filter(
|
|
10
|
+
(file) =>
|
|
11
|
+
file.startsWith(".github/workflows/") && (file.endsWith(".yml") || file.endsWith(".yaml"))
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
if (workflows.length > 0) {
|
|
15
|
+
return createResult({
|
|
16
|
+
id: this.id,
|
|
17
|
+
title: this.title
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return createResult({
|
|
22
|
+
id: this.id,
|
|
23
|
+
title: this.title,
|
|
24
|
+
issues: [
|
|
25
|
+
createIssue({
|
|
26
|
+
id: "ci-presence.missing",
|
|
27
|
+
title: "CI workflow is missing",
|
|
28
|
+
message: "Repository does not include a GitHub Actions workflow in .github/workflows.",
|
|
29
|
+
severity: "warning",
|
|
30
|
+
suggestion: "Add a CI workflow that installs dependencies, runs tests, and builds the project."
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ClonecheckCheck } from "../types.js";
|
|
2
|
+
import { DEFAULT_IGNORE_ENV_VARS } from "../detectors/env.js";
|
|
3
|
+
import { COMPOSE_FILES, detectDockerComposeEnvVars } from "../detectors/dockerCompose.js";
|
|
4
|
+
import { createIssue, createResult } from "./helpers.js";
|
|
5
|
+
|
|
6
|
+
export const dockerComposeEnvCheck: ClonecheckCheck = {
|
|
7
|
+
id: "docker-compose-env",
|
|
8
|
+
title: "Docker Compose environment",
|
|
9
|
+
description: "Checks whether Docker Compose variable references are documented in env examples.",
|
|
10
|
+
async run(context) {
|
|
11
|
+
const hasCompose = context.files.some((file) => COMPOSE_FILES.includes(file));
|
|
12
|
+
if (!hasCompose) {
|
|
13
|
+
return createResult({
|
|
14
|
+
id: this.id,
|
|
15
|
+
title: this.title,
|
|
16
|
+
status: "skip"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ignored = new Set([...DEFAULT_IGNORE_ENV_VARS, ...context.config.ignoreEnvVars]);
|
|
21
|
+
const scan = await detectDockerComposeEnvVars(context.repoPath, context.files);
|
|
22
|
+
const issues = scan.parseErrors.map((error) =>
|
|
23
|
+
createIssue({
|
|
24
|
+
id: `docker-compose-env.parse.${error.file}`,
|
|
25
|
+
title: "Docker Compose file could not be parsed",
|
|
26
|
+
message: `${error.file} could not be parsed as YAML: ${error.message}`,
|
|
27
|
+
severity: "warning",
|
|
28
|
+
file: error.file,
|
|
29
|
+
suggestion: "Fix the Docker Compose YAML syntax."
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const uniqueMissing = Array.from(
|
|
34
|
+
new Set(
|
|
35
|
+
scan.refs
|
|
36
|
+
.map((ref) => ref.name)
|
|
37
|
+
.filter((name) => !ignored.has(name) && !context.envExampleVars.has(name))
|
|
38
|
+
)
|
|
39
|
+
).sort((a, b) => a.localeCompare(b));
|
|
40
|
+
|
|
41
|
+
for (const name of uniqueMissing) {
|
|
42
|
+
const ref = scan.refs.find((entry) => entry.name === name);
|
|
43
|
+
issues.push(
|
|
44
|
+
createIssue({
|
|
45
|
+
id: `docker-compose-env.${name}`,
|
|
46
|
+
title: "Docker Compose variable is undocumented",
|
|
47
|
+
message: `Docker Compose references ${name}, but it is not documented in an env example file.`,
|
|
48
|
+
severity: "warning",
|
|
49
|
+
file: ref?.file,
|
|
50
|
+
suggestion: `Add ${name}= to .env.example.`
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return createResult({
|
|
56
|
+
id: this.id,
|
|
57
|
+
title: this.title,
|
|
58
|
+
issues
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ClonecheckCheck } from "../types.js";
|
|
2
|
+
import { detectEnvVarUsages, findMissingEnvVars } from "../detectors/env.js";
|
|
3
|
+
import { createIssue, createResult } from "./helpers.js";
|
|
4
|
+
|
|
5
|
+
export const envExampleCheck: ClonecheckCheck = {
|
|
6
|
+
id: "env-example",
|
|
7
|
+
title: "Environment example",
|
|
8
|
+
description: "Checks whether environment variables used in code are documented in an example env file.",
|
|
9
|
+
async run(context) {
|
|
10
|
+
const usages = await detectEnvVarUsages(context.repoPath, context.files, context.config);
|
|
11
|
+
const missing = findMissingEnvVars(usages, context.envExampleVars);
|
|
12
|
+
const issues = missing.map((name) => {
|
|
13
|
+
const firstUsage = usages.find((usage) => usage.name === name);
|
|
14
|
+
return createIssue({
|
|
15
|
+
id: `env-example.${name}`,
|
|
16
|
+
title: "Environment variable is undocumented",
|
|
17
|
+
message: `Environment variable ${name} is used but missing from .env.example or another env template.`,
|
|
18
|
+
severity: "warning",
|
|
19
|
+
file: firstUsage?.file,
|
|
20
|
+
line: firstUsage?.line,
|
|
21
|
+
suggestion: `Add ${name}= to .env.example.`
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return createResult({
|
|
26
|
+
id: this.id,
|
|
27
|
+
title: this.title,
|
|
28
|
+
issues
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CheckStatus,
|
|
3
|
+
ClonecheckCheckResult,
|
|
4
|
+
ClonecheckIssue,
|
|
5
|
+
PackageJson,
|
|
6
|
+
Severity
|
|
7
|
+
} from "../types.js";
|
|
8
|
+
|
|
9
|
+
export function statusFromIssues(issues: ClonecheckIssue[]): CheckStatus {
|
|
10
|
+
if (issues.some((issue) => issue.severity === "error")) {
|
|
11
|
+
return "fail";
|
|
12
|
+
}
|
|
13
|
+
if (issues.some((issue) => issue.severity === "warning")) {
|
|
14
|
+
return "warning";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return "pass";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createIssue(input: {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
message: string;
|
|
24
|
+
severity: Severity;
|
|
25
|
+
file?: string;
|
|
26
|
+
line?: number;
|
|
27
|
+
suggestion?: string;
|
|
28
|
+
}): ClonecheckIssue {
|
|
29
|
+
return input;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createResult(input: {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
issues?: ClonecheckIssue[];
|
|
36
|
+
status?: CheckStatus;
|
|
37
|
+
}): ClonecheckCheckResult {
|
|
38
|
+
const issues = input.issues ?? [];
|
|
39
|
+
return {
|
|
40
|
+
id: input.id,
|
|
41
|
+
title: input.title,
|
|
42
|
+
status: input.status ?? statusFromIssues(issues),
|
|
43
|
+
issues,
|
|
44
|
+
scoreImpact: 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function asPackageJson(value: unknown): PackageJson | undefined {
|
|
49
|
+
if (!value || typeof value !== "object") {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return value as PackageJson;
|
|
54
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ClonecheckCheck } from "../types.js";
|
|
2
|
+
import { ciPresenceCheck } from "./ciPresence.js";
|
|
3
|
+
import { dockerComposeEnvCheck } from "./dockerComposeEnv.js";
|
|
4
|
+
import { envExampleCheck } from "./envExample.js";
|
|
5
|
+
import { packageManagerConsistencyCheck } from "./packageManagerConsistency.js";
|
|
6
|
+
import { portDocumentationCheck } from "./portDocumentation.js";
|
|
7
|
+
import { projectFilesCheck } from "./projectFiles.js";
|
|
8
|
+
import { readmeCommandsCheck } from "./readmeCommands.js";
|
|
9
|
+
import { scriptsAvailabilityCheck } from "./scriptsAvailability.js";
|
|
10
|
+
|
|
11
|
+
export const checks: ClonecheckCheck[] = [
|
|
12
|
+
packageManagerConsistencyCheck,
|
|
13
|
+
scriptsAvailabilityCheck,
|
|
14
|
+
envExampleCheck,
|
|
15
|
+
readmeCommandsCheck,
|
|
16
|
+
portDocumentationCheck,
|
|
17
|
+
dockerComposeEnvCheck,
|
|
18
|
+
projectFilesCheck,
|
|
19
|
+
ciPresenceCheck
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export function getChecks(): ClonecheckCheck[] {
|
|
23
|
+
return checks;
|
|
24
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ClonecheckCheck } from "../types.js";
|
|
2
|
+
import { detectPackageManager } from "../detectors/packageManager.js";
|
|
3
|
+
import { extractReadmeCommands, isPackageInstallCommand } from "../detectors/readme.js";
|
|
4
|
+
import { createIssue, createResult, asPackageJson } from "./helpers.js";
|
|
5
|
+
|
|
6
|
+
export const packageManagerConsistencyCheck: ClonecheckCheck = {
|
|
7
|
+
id: "package-manager-consistency",
|
|
8
|
+
title: "Package manager consistency",
|
|
9
|
+
description: "Checks whether README package-manager commands match the detected lockfile.",
|
|
10
|
+
async run(context) {
|
|
11
|
+
const detection = detectPackageManager(context.files, asPackageJson(context.packageJson));
|
|
12
|
+
const issues = [];
|
|
13
|
+
|
|
14
|
+
if (!detection.manager) {
|
|
15
|
+
return createResult({
|
|
16
|
+
id: this.id,
|
|
17
|
+
title: this.title,
|
|
18
|
+
status: "skip"
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (detection.managers.length > 1) {
|
|
23
|
+
issues.push(
|
|
24
|
+
createIssue({
|
|
25
|
+
id: "package-manager-consistency.multiple-lockfiles",
|
|
26
|
+
title: "Multiple package managers detected",
|
|
27
|
+
message: `Multiple package-manager lockfiles were found: ${detection.lockfiles.join(", ")}.`,
|
|
28
|
+
severity: "warning",
|
|
29
|
+
suggestion: "Keep only the lockfile for the package manager contributors should use."
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const commands = context.readmeText ? extractReadmeCommands(context.readmeText) : [];
|
|
35
|
+
const mismatches = commands.filter(
|
|
36
|
+
(command) =>
|
|
37
|
+
command.packageManager &&
|
|
38
|
+
command.packageManager !== detection.manager &&
|
|
39
|
+
!(command.kind === "install" && isPackageInstallCommand(command.command))
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const seen = new Set<string>();
|
|
43
|
+
for (const mismatch of mismatches) {
|
|
44
|
+
if (!mismatch.packageManager || seen.has(mismatch.packageManager)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
seen.add(mismatch.packageManager);
|
|
48
|
+
issues.push(
|
|
49
|
+
createIssue({
|
|
50
|
+
id: `package-manager-consistency.${mismatch.packageManager}`,
|
|
51
|
+
title: "README uses a different package manager",
|
|
52
|
+
message: `README uses ${mismatch.packageManager} commands, but the repository appears to use ${detection.manager}.`,
|
|
53
|
+
severity: "warning",
|
|
54
|
+
suggestion: `Replace ${mismatch.packageManager} commands in README with ${detection.manager} equivalents.`
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return createResult({
|
|
60
|
+
id: this.id,
|
|
61
|
+
title: this.title,
|
|
62
|
+
issues
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|