@eserstack/codebase 0.0.0-bootstrap.0 → 5.0.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/README.md +302 -0
- package/dist/changelog-gen.d.ts +105 -0
- package/dist/changelog-gen.js +498 -0
- package/dist/changelog-text.d.ts +39 -0
- package/dist/changelog-text.js +82 -0
- package/dist/cli-support.d.ts +140 -0
- package/dist/cli-support.js +244 -0
- package/dist/cli-system/app-opts.d.ts +15 -0
- package/dist/cli-system/app-opts.js +13 -0
- package/dist/cli-system/app.d.ts +29 -0
- package/dist/cli-system/app.js +12 -0
- package/dist/cli-system/handlers/completions-setup.d.ts +14 -0
- package/dist/cli-system/handlers/completions-setup.js +139 -0
- package/dist/cli-system/handlers/completions.d.ts +3 -0
- package/dist/cli-system/handlers/completions.js +79 -0
- package/dist/cli-system/handlers/doctor.d.ts +8 -0
- package/dist/cli-system/handlers/doctor.js +146 -0
- package/dist/cli-system/handlers/info.d.ts +3 -0
- package/dist/cli-system/handlers/info.js +69 -0
- package/dist/cli-system/handlers/install.d.ts +8 -0
- package/dist/cli-system/handlers/install.js +137 -0
- package/dist/cli-system/handlers/mod.d.ts +12 -0
- package/dist/cli-system/handlers/mod.js +13 -0
- package/dist/cli-system/handlers/uninstall.d.ts +3 -0
- package/dist/cli-system/handlers/uninstall.js +60 -0
- package/dist/cli-system/handlers/update.d.ts +76 -0
- package/dist/cli-system/handlers/update.js +310 -0
- package/dist/cli-system/handlers/version-check.d.ts +16 -0
- package/dist/cli-system/handlers/version-check.js +176 -0
- package/dist/cli-system/handlers/version.d.ts +3 -0
- package/dist/cli-system/handlers/version.js +45 -0
- package/dist/cli-system/mod.d.ts +19 -0
- package/dist/cli-system/mod.js +52 -0
- package/dist/commitmsg.d.ts +28 -0
- package/dist/commitmsg.js +232 -0
- package/dist/directive-analysis.d.ts +75 -0
- package/dist/directive-analysis.js +223 -0
- package/dist/ffi-client.d.ts +11 -0
- package/dist/ffi-client.js +12 -0
- package/dist/file-tool.d.ts +96 -0
- package/dist/file-tool.js +274 -0
- package/dist/file-tools-shared.d.ts +81 -0
- package/dist/file-tools-shared.js +276 -0
- package/dist/gh-contributors.d.ts +89 -0
- package/dist/gh-contributors.js +205 -0
- package/dist/gh.d.ts +3 -0
- package/dist/gh.js +64 -0
- package/dist/git-listing.d.ts +27 -0
- package/dist/git-listing.js +69 -0
- package/dist/git.d.ts +172 -0
- package/dist/git.js +277 -0
- package/dist/install.d.ts +34 -0
- package/dist/install.js +421 -0
- package/dist/main.d.ts +22 -0
- package/dist/main.js +14 -0
- package/dist/mod.d.ts +25 -0
- package/dist/mod.js +8 -0
- package/dist/module.d.ts +10 -0
- package/dist/module.js +221 -0
- package/dist/native-functions.d.ts +1088 -0
- package/dist/native-functions.js +2 -0
- package/dist/npm-externals.d.ts +27 -0
- package/dist/npm-externals.js +34 -0
- package/dist/npm-workspace-specifiers.d.ts +6 -0
- package/dist/npm-workspace-specifiers.js +45 -0
- package/dist/package/loader.d.ts +34 -0
- package/dist/package/loader.js +203 -0
- package/dist/package/mod.d.ts +36 -0
- package/dist/package/mod.js +5 -0
- package/dist/package/types.d.ts +142 -0
- package/dist/package/types.js +32 -0
- package/dist/package/workspace.d.ts +33 -0
- package/dist/package/workspace.js +158 -0
- package/dist/package/writer.d.ts +52 -0
- package/dist/package/writer.js +278 -0
- package/dist/package.json +275 -0
- package/dist/release-notes.d.ts +90 -0
- package/dist/release-notes.js +236 -0
- package/dist/release-tag.d.ts +46 -0
- package/dist/release-tag.js +95 -0
- package/dist/release.d.ts +145 -0
- package/dist/release.js +584 -0
- package/dist/source-mask.d.ts +3 -0
- package/dist/source-mask.js +185 -0
- package/dist/validate-bom.d.ts +5 -0
- package/dist/validate-bom.js +43 -0
- package/dist/validate-case-conflict.d.ts +5 -0
- package/dist/validate-case-conflict.js +43 -0
- package/dist/validate-circular-deps.d.ts +11 -0
- package/dist/validate-circular-deps.js +53 -0
- package/dist/validate-code-conventions.d.ts +22 -0
- package/dist/validate-code-conventions.js +166 -0
- package/dist/validate-commit-msg.d.ts +50 -0
- package/dist/validate-commit-msg.js +182 -0
- package/dist/validate-docs.d.ts +20 -0
- package/dist/validate-docs.js +78 -0
- package/dist/validate-eof.d.ts +5 -0
- package/dist/validate-eof.js +61 -0
- package/dist/validate-error-coverage.d.ts +28 -0
- package/dist/validate-error-coverage.js +93 -0
- package/dist/validate-export-names.d.ts +17 -0
- package/dist/validate-export-names.js +56 -0
- package/dist/validate-filenames.d.ts +5 -0
- package/dist/validate-filenames.js +151 -0
- package/dist/validate-json.d.ts +5 -0
- package/dist/validate-json.js +71 -0
- package/dist/validate-large-files.d.ts +5 -0
- package/dist/validate-large-files.js +41 -0
- package/dist/validate-laroux-boundaries.d.ts +19 -0
- package/dist/validate-laroux-boundaries.js +59 -0
- package/dist/validate-licenses.d.ts +5 -0
- package/dist/validate-licenses.js +137 -0
- package/dist/validate-line-endings.d.ts +5 -0
- package/dist/validate-line-endings.js +47 -0
- package/dist/validate-merge-conflict.d.ts +5 -0
- package/dist/validate-merge-conflict.js +46 -0
- package/dist/validate-mod-exports.d.ts +16 -0
- package/dist/validate-mod-exports.js +56 -0
- package/dist/validate-naming-and-todos.d.ts +5 -0
- package/dist/validate-naming-and-todos.js +70 -0
- package/dist/validate-runtime-js-apis.d.ts +5 -0
- package/dist/validate-runtime-js-apis.js +78 -0
- package/dist/validate-secrets.d.ts +5 -0
- package/dist/validate-secrets.js +82 -0
- package/dist/validate-self-imports.d.ts +5 -0
- package/dist/validate-self-imports.js +78 -0
- package/dist/validate-server-loc.d.ts +32 -0
- package/dist/validate-server-loc.js +94 -0
- package/dist/validate-shebangs.d.ts +5 -0
- package/dist/validate-shebangs.js +33 -0
- package/dist/validate-stream.d.ts +25 -0
- package/dist/validate-stream.js +62 -0
- package/dist/validate-submodules.d.ts +5 -0
- package/dist/validate-submodules.js +43 -0
- package/dist/validate-symlinks.d.ts +5 -0
- package/dist/validate-symlinks.js +46 -0
- package/dist/validate-toml.d.ts +5 -0
- package/dist/validate-toml.js +40 -0
- package/dist/validate-trailing-whitespace.d.ts +5 -0
- package/dist/validate-trailing-whitespace.js +49 -0
- package/dist/validate-yaml.d.ts +5 -0
- package/dist/validate-yaml.js +40 -0
- package/dist/validation/config.d.ts +17 -0
- package/dist/validation/config.js +30 -0
- package/dist/validation/mod.d.ts +71 -0
- package/dist/validation/mod.js +479 -0
- package/dist/validation/registry.d.ts +57 -0
- package/dist/validation/registry.js +256 -0
- package/dist/validation/types.d.ts +101 -0
- package/dist/validation/types.js +2 -0
- package/dist/validation/validators/circular-deps.d.ts +7 -0
- package/dist/validation/validators/circular-deps.js +31 -0
- package/dist/validation/validators/docs.d.ts +7 -0
- package/dist/validation/validators/docs.js +38 -0
- package/dist/validation/validators/error-coverage.d.ts +2 -0
- package/dist/validation/validators/error-coverage.js +46 -0
- package/dist/validation/validators/export-names.d.ts +7 -0
- package/dist/validation/validators/export-names.js +31 -0
- package/dist/validation/validators/laroux-boundaries.d.ts +2 -0
- package/dist/validation/validators/laroux-boundaries.js +29 -0
- package/dist/validation/validators/mod-exports.d.ts +7 -0
- package/dist/validation/validators/mod-exports.js +32 -0
- package/dist/validation/validators/mod.d.ts +11 -0
- package/dist/validation/validators/mod.js +12 -0
- package/dist/validation/validators/server-loc.d.ts +2 -0
- package/dist/validation/validators/server-loc.js +48 -0
- package/dist/versions.d.ts +166 -0
- package/dist/versions.js +349 -0
- package/dist/violation-baseline.d.ts +58 -0
- package/dist/violation-baseline.js +144 -0
- package/dist/walk-stream.d.ts +24 -0
- package/dist/walk-stream.js +55 -0
- package/dist/workspace-discovery.d.ts +60 -0
- package/dist/workspace-discovery.js +130 -0
- package/package.json +225 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
import * as ffiClient from "../ffi-client.js";
|
|
3
|
+
// Hand-written validators
|
|
4
|
+
import * as circularDeps from "./validators/circular-deps.js";
|
|
5
|
+
import * as larouxBoundaries from "./validators/laroux-boundaries.js";
|
|
6
|
+
import * as modExports from "./validators/mod-exports.js";
|
|
7
|
+
import * as exportNames from "./validators/export-names.js";
|
|
8
|
+
import * as docs from "./validators/docs.js";
|
|
9
|
+
import * as serverLoc from "./validators/server-loc.js";
|
|
10
|
+
import * as errorCoverage from "./validators/error-coverage.js";
|
|
11
|
+
// File tools (factory-generated — import tool objects for full adapter access)
|
|
12
|
+
import * as validateEof from "../validate-eof.js";
|
|
13
|
+
import * as validateTrailingWhitespace from "../validate-trailing-whitespace.js";
|
|
14
|
+
import * as validateBom from "../validate-bom.js";
|
|
15
|
+
import * as validateLineEndings from "../validate-line-endings.js";
|
|
16
|
+
import * as validateLargeFiles from "../validate-large-files.js";
|
|
17
|
+
import * as validateCaseConflict from "../validate-case-conflict.js";
|
|
18
|
+
import * as validateMergeConflict from "../validate-merge-conflict.js";
|
|
19
|
+
import * as validateJson from "../validate-json.js";
|
|
20
|
+
import * as validateToml from "../validate-toml.js";
|
|
21
|
+
import * as validateYaml from "../validate-yaml.js";
|
|
22
|
+
import * as validateSymlinks from "../validate-symlinks.js";
|
|
23
|
+
import * as validateShebangs from "../validate-shebangs.js";
|
|
24
|
+
import * as validateSecrets from "../validate-secrets.js";
|
|
25
|
+
import * as validateFilenames from "../validate-filenames.js";
|
|
26
|
+
import * as validateSubmodules from "../validate-submodules.js";
|
|
27
|
+
import * as validateLicenses from "../validate-licenses.js";
|
|
28
|
+
import * as validateRuntimeJsApis from "../validate-runtime-js-apis.js";
|
|
29
|
+
import * as validateSelfImports from "../validate-self-imports.js";
|
|
30
|
+
import * as validateCodeConventions from "../validate-code-conventions.js";
|
|
31
|
+
import * as validateNamingAndTodos from "../validate-naming-and-todos.js";
|
|
32
|
+
// Standalone scripts (not file tools)
|
|
33
|
+
import * as validateCommitMsg from "../validate-commit-msg.js";
|
|
34
|
+
const state = {
|
|
35
|
+
validators: new Map(),
|
|
36
|
+
initialized: false,
|
|
37
|
+
};
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// Built-in registration
|
|
40
|
+
// =============================================================================
|
|
41
|
+
const initializeBuiltinValidators = () => {
|
|
42
|
+
// Hand-written validators
|
|
43
|
+
registerValidator(circularDeps.circularDepsValidator);
|
|
44
|
+
registerValidator(larouxBoundaries.larouxBoundariesValidator);
|
|
45
|
+
registerValidator(modExports.modExportsValidator);
|
|
46
|
+
registerValidator(exportNames.exportNamesValidator);
|
|
47
|
+
registerValidator(docs.docsValidator);
|
|
48
|
+
registerValidator(serverLoc.serverLocValidator);
|
|
49
|
+
registerValidator(errorCoverage.errorCoverageValidator);
|
|
50
|
+
// File tool validators
|
|
51
|
+
registerValidator(validateEof.validator);
|
|
52
|
+
registerValidator(validateTrailingWhitespace.validator);
|
|
53
|
+
registerValidator(validateBom.validator);
|
|
54
|
+
registerValidator(validateLineEndings.validator);
|
|
55
|
+
registerValidator(validateLargeFiles.validator);
|
|
56
|
+
registerValidator(validateCaseConflict.validator);
|
|
57
|
+
registerValidator(validateMergeConflict.validator);
|
|
58
|
+
registerValidator(validateJson.validator);
|
|
59
|
+
registerValidator(validateToml.validator);
|
|
60
|
+
registerValidator(validateYaml.validator);
|
|
61
|
+
registerValidator(validateSymlinks.validator);
|
|
62
|
+
registerValidator(validateShebangs.validator);
|
|
63
|
+
registerValidator(validateSecrets.validator);
|
|
64
|
+
registerValidator(validateFilenames.validator);
|
|
65
|
+
registerValidator(validateSubmodules.validator);
|
|
66
|
+
registerValidator(validateLicenses.validator);
|
|
67
|
+
registerValidator(validateRuntimeJsApis.validator);
|
|
68
|
+
registerValidator(validateSelfImports.validator);
|
|
69
|
+
registerValidator(validateCodeConventions.validator);
|
|
70
|
+
registerValidator(validateNamingAndTodos.validator);
|
|
71
|
+
};
|
|
72
|
+
const ensureInitialized = () => {
|
|
73
|
+
if (state.initialized) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
state.initialized = true;
|
|
77
|
+
initializeBuiltinValidators();
|
|
78
|
+
};
|
|
79
|
+
// =============================================================================
|
|
80
|
+
// Public API
|
|
81
|
+
// =============================================================================
|
|
82
|
+
/**
|
|
83
|
+
* Register a validator in the registry.
|
|
84
|
+
*/
|
|
85
|
+
export const registerValidator = (validator) => {
|
|
86
|
+
state.validators.set(validator.name, validator);
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Get a validator by name.
|
|
90
|
+
*/
|
|
91
|
+
export const getValidator = (name) => {
|
|
92
|
+
ensureInitialized();
|
|
93
|
+
return state.validators.get(name) ?? null;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Get all registered validators.
|
|
97
|
+
*/
|
|
98
|
+
export const getValidators = () => {
|
|
99
|
+
ensureInitialized();
|
|
100
|
+
return [...state.validators.values()];
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Get all validator names.
|
|
104
|
+
*/
|
|
105
|
+
export const getValidatorNames = () => {
|
|
106
|
+
ensureInitialized();
|
|
107
|
+
return [...state.validators.keys()];
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Adapt a FileTool to a WorkflowCompatibleTool.
|
|
111
|
+
* Uses `tool.run()` which preserves mutation data.
|
|
112
|
+
*/
|
|
113
|
+
const adaptFileTool = (fileTool) => ({
|
|
114
|
+
name: fileTool.config.name,
|
|
115
|
+
description: fileTool.config.description,
|
|
116
|
+
run: async (options) => {
|
|
117
|
+
const result = await fileTool.run(options);
|
|
118
|
+
return {
|
|
119
|
+
name: result.name,
|
|
120
|
+
passed: result.issues.length === 0,
|
|
121
|
+
issues: result.issues.map((i) => ({
|
|
122
|
+
path: i.path,
|
|
123
|
+
line: i.line,
|
|
124
|
+
message: i.message,
|
|
125
|
+
fixed: i.fixed,
|
|
126
|
+
})),
|
|
127
|
+
mutations: result.mutations.map((m) => ({
|
|
128
|
+
path: m.path,
|
|
129
|
+
oldContent: m.oldContent,
|
|
130
|
+
newContent: m.newContent,
|
|
131
|
+
})),
|
|
132
|
+
stats: {
|
|
133
|
+
filesChecked: result.filesChecked,
|
|
134
|
+
issuesFound: result.issues.length,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* Adapt a Validator to a WorkflowCompatibleTool.
|
|
141
|
+
* Validators don't produce mutations.
|
|
142
|
+
*/
|
|
143
|
+
const adaptValidator = (v) => ({
|
|
144
|
+
name: v.name,
|
|
145
|
+
description: v.description,
|
|
146
|
+
run: async (options) => {
|
|
147
|
+
const result = await v.validate({
|
|
148
|
+
root: options["root"] ?? ".",
|
|
149
|
+
options,
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
name: result.name,
|
|
153
|
+
passed: result.passed,
|
|
154
|
+
issues: result.issues.map((i) => ({
|
|
155
|
+
path: i.file,
|
|
156
|
+
line: i.line,
|
|
157
|
+
message: i.message,
|
|
158
|
+
})),
|
|
159
|
+
mutations: [],
|
|
160
|
+
stats: result.stats,
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* Get all codebase tools adapted for the workflow engine.
|
|
166
|
+
*
|
|
167
|
+
* Returns duck-typed objects structurally compatible with
|
|
168
|
+
* `WorkflowTool` from `@eserstack/workflows`.
|
|
169
|
+
*/
|
|
170
|
+
export const getWorkflowTools = () => {
|
|
171
|
+
const tools = [];
|
|
172
|
+
// File tools (have full mutation support)
|
|
173
|
+
const fileTools = [
|
|
174
|
+
validateEof.tool,
|
|
175
|
+
validateTrailingWhitespace.tool,
|
|
176
|
+
validateBom.tool,
|
|
177
|
+
validateLineEndings.tool,
|
|
178
|
+
validateLargeFiles.tool,
|
|
179
|
+
validateCaseConflict.tool,
|
|
180
|
+
validateMergeConflict.tool,
|
|
181
|
+
validateJson.tool,
|
|
182
|
+
validateToml.tool,
|
|
183
|
+
validateYaml.tool,
|
|
184
|
+
validateSymlinks.tool,
|
|
185
|
+
validateShebangs.tool,
|
|
186
|
+
validateSecrets.tool,
|
|
187
|
+
validateFilenames.tool,
|
|
188
|
+
validateSubmodules.tool,
|
|
189
|
+
validateLicenses.tool,
|
|
190
|
+
validateRuntimeJsApis.tool,
|
|
191
|
+
validateSelfImports.tool,
|
|
192
|
+
validateCodeConventions.tool,
|
|
193
|
+
validateNamingAndTodos.tool,
|
|
194
|
+
];
|
|
195
|
+
for (const ft of fileTools) {
|
|
196
|
+
tools.push(adaptFileTool(ft));
|
|
197
|
+
}
|
|
198
|
+
// Hand-written validators (no mutations)
|
|
199
|
+
const validators = [
|
|
200
|
+
circularDeps.circularDepsValidator,
|
|
201
|
+
larouxBoundaries.larouxBoundariesValidator,
|
|
202
|
+
modExports.modExportsValidator,
|
|
203
|
+
exportNames.exportNamesValidator,
|
|
204
|
+
docs.docsValidator,
|
|
205
|
+
serverLoc.serverLocValidator,
|
|
206
|
+
errorCoverage.errorCoverageValidator,
|
|
207
|
+
];
|
|
208
|
+
for (const v of validators) {
|
|
209
|
+
tools.push(adaptValidator(v));
|
|
210
|
+
}
|
|
211
|
+
// validate-commit-msg (standalone script, needs special adapter)
|
|
212
|
+
tools.push({
|
|
213
|
+
name: "validate-commit-msg",
|
|
214
|
+
description: "Validate conventional commit format",
|
|
215
|
+
run: async (options) => {
|
|
216
|
+
const commitMsgFile = options["commitMsgFile"] ??
|
|
217
|
+
options["_args"]?.[0] ??
|
|
218
|
+
".git/COMMIT_EDITMSG";
|
|
219
|
+
const { runtime } = await import("@eserstack/standards/cross-runtime");
|
|
220
|
+
let message;
|
|
221
|
+
try {
|
|
222
|
+
message = await runtime.fs.readTextFile(commitMsgFile);
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return {
|
|
226
|
+
name: "validate-commit-msg",
|
|
227
|
+
passed: false,
|
|
228
|
+
issues: [
|
|
229
|
+
{
|
|
230
|
+
message: `cannot read commit message file: ${commitMsgFile}`,
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
mutations: [],
|
|
234
|
+
stats: {},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
// Load the bridge before the synchronous check so the native validator
|
|
238
|
+
// runs.
|
|
239
|
+
await ffiClient.ensureLib();
|
|
240
|
+
const result = validateCommitMsg.validateCommitMsg(message, {
|
|
241
|
+
allowAsterisk: options["allowAsterisk"],
|
|
242
|
+
allowMultipleScopes: options["allowMultipleScopes"],
|
|
243
|
+
forceScope: options["forceScope"],
|
|
244
|
+
types: options["types"],
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
name: "validate-commit-msg",
|
|
248
|
+
passed: result.valid,
|
|
249
|
+
issues: result.issues.map((msg) => ({ message: msg })),
|
|
250
|
+
mutations: [],
|
|
251
|
+
stats: {},
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
return tools;
|
|
256
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the validation plugin system
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Supported stack identifiers */
|
|
7
|
+
export type StackId = "javascript" | "golang" | "css" | "rust" | "python";
|
|
8
|
+
/** Issue severity level */
|
|
9
|
+
export type IssueSeverity = "error" | "warning";
|
|
10
|
+
/**
|
|
11
|
+
* A single validation issue
|
|
12
|
+
*/
|
|
13
|
+
export type ValidatorIssue = {
|
|
14
|
+
/** Issue severity */
|
|
15
|
+
readonly severity: IssueSeverity;
|
|
16
|
+
/** Issue message */
|
|
17
|
+
readonly message: string;
|
|
18
|
+
/** File path (if applicable) */
|
|
19
|
+
readonly file?: string;
|
|
20
|
+
/** Line number (if applicable) */
|
|
21
|
+
readonly line?: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Options passed to a validator
|
|
25
|
+
*/
|
|
26
|
+
export type ValidatorOptions = {
|
|
27
|
+
/** Root directory to validate */
|
|
28
|
+
readonly root: string;
|
|
29
|
+
/** Validator-specific options */
|
|
30
|
+
readonly options?: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Result from running a validator
|
|
34
|
+
*/
|
|
35
|
+
export type ValidatorResult = {
|
|
36
|
+
/** Validator name */
|
|
37
|
+
readonly name: string;
|
|
38
|
+
/** Whether validation passed */
|
|
39
|
+
readonly passed: boolean;
|
|
40
|
+
/** Issues found */
|
|
41
|
+
readonly issues: readonly ValidatorIssue[];
|
|
42
|
+
/** Statistics (e.g., filesChecked, packagesChecked) */
|
|
43
|
+
readonly stats: Readonly<Record<string, number>>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Validator interface - all validators implement this
|
|
47
|
+
*/
|
|
48
|
+
export type Validator = {
|
|
49
|
+
/** Unique validator name */
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/** Human-readable description */
|
|
52
|
+
readonly description: string;
|
|
53
|
+
/** Required stacks (empty = runs for all stacks) */
|
|
54
|
+
readonly requiredStacks: readonly StackId[];
|
|
55
|
+
/** Run the validation */
|
|
56
|
+
readonly validate: (options: ValidatorOptions) => Promise<ValidatorResult>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Project configuration from .eser/manifest.yml
|
|
60
|
+
*/
|
|
61
|
+
export type ProjectConfig = {
|
|
62
|
+
/** Template name (for scaffolded projects) */
|
|
63
|
+
readonly name?: string;
|
|
64
|
+
/** Tech stacks used in this project */
|
|
65
|
+
readonly stack?: readonly StackId[];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Information about a skipped validator
|
|
69
|
+
*/
|
|
70
|
+
export type SkippedValidator = {
|
|
71
|
+
/** Validator name */
|
|
72
|
+
readonly name: string;
|
|
73
|
+
/** Reason for skipping */
|
|
74
|
+
readonly reason: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Options for the validate function
|
|
78
|
+
*/
|
|
79
|
+
export type ValidateOptions = {
|
|
80
|
+
/** Root directory to validate */
|
|
81
|
+
readonly root?: string;
|
|
82
|
+
/** Run only these validators */
|
|
83
|
+
readonly only?: readonly string[];
|
|
84
|
+
/** Skip these validators */
|
|
85
|
+
readonly skip?: readonly string[];
|
|
86
|
+
/** Enable auto-fix where supported */
|
|
87
|
+
readonly fix?: boolean;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Result of running all applicable validators
|
|
91
|
+
*/
|
|
92
|
+
export type ValidateResult = {
|
|
93
|
+
/** Overall success (all validators passed) */
|
|
94
|
+
readonly passed: boolean;
|
|
95
|
+
/** Validators that were run */
|
|
96
|
+
readonly results: readonly ValidatorResult[];
|
|
97
|
+
/** Validators skipped due to stack mismatch */
|
|
98
|
+
readonly skipped: readonly SkippedValidator[];
|
|
99
|
+
/** Validators explicitly disabled via config or flags */
|
|
100
|
+
readonly disabled: readonly string[];
|
|
101
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Circular dependency validator
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as validateCircularDeps from "../../validate-circular-deps.js";
|
|
8
|
+
/**
|
|
9
|
+
* Validator for detecting circular dependencies between packages
|
|
10
|
+
*
|
|
11
|
+
* This validator runs for all stacks (language-agnostic).
|
|
12
|
+
*/
|
|
13
|
+
export const circularDepsValidator = {
|
|
14
|
+
name: "validate-circular-deps",
|
|
15
|
+
description: "Detect circular package dependencies",
|
|
16
|
+
requiredStacks: [], // Runs for all stacks
|
|
17
|
+
validate: async (options) => {
|
|
18
|
+
const result = await validateCircularDeps.checkCircularDeps({
|
|
19
|
+
root: options.root,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
name: "validate-circular-deps",
|
|
23
|
+
passed: !result.hasCycles,
|
|
24
|
+
issues: result.cycles.map((cycle) => ({
|
|
25
|
+
severity: "error",
|
|
26
|
+
message: `Circular dependency: ${cycle.join(" → ")}`,
|
|
27
|
+
})),
|
|
28
|
+
stats: { packagesChecked: result.packagesChecked },
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Documentation validator
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as validateDocs from "../../validate-docs.js";
|
|
8
|
+
/**
|
|
9
|
+
* Validator for checking JSDoc documentation
|
|
10
|
+
*
|
|
11
|
+
* This validator requires the 'javascript' stack (TypeScript specific).
|
|
12
|
+
*/
|
|
13
|
+
export const docsValidator = {
|
|
14
|
+
name: "validate-docs",
|
|
15
|
+
description: "Validate JSDoc documentation",
|
|
16
|
+
requiredStacks: ["javascript"],
|
|
17
|
+
validate: async (options) => {
|
|
18
|
+
const requireExamples = options.options?.["requireExamples"];
|
|
19
|
+
const result = await validateDocs.checkDocs({
|
|
20
|
+
root: options.root,
|
|
21
|
+
requireExamples,
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
name: "validate-docs",
|
|
25
|
+
passed: result.isValid,
|
|
26
|
+
issues: result.issues.map((issue) => ({
|
|
27
|
+
severity: "error",
|
|
28
|
+
message: `${issue.symbol}: ${issue.issue}`,
|
|
29
|
+
file: issue.file,
|
|
30
|
+
line: issue.line,
|
|
31
|
+
})),
|
|
32
|
+
stats: {
|
|
33
|
+
filesChecked: result.filesChecked,
|
|
34
|
+
symbolsChecked: result.symbolsChecked,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Error struct field-coverage validator
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as validateErrorCoverage from "../../validate-error-coverage.js";
|
|
8
|
+
export const errorCoverageValidator = {
|
|
9
|
+
name: "validate-error-coverage",
|
|
10
|
+
description: "Verify error-struct entries have non-empty required fields",
|
|
11
|
+
requiredStacks: ["golang"],
|
|
12
|
+
validate: async (options) => {
|
|
13
|
+
const file = options.options?.["file"];
|
|
14
|
+
if (file === undefined || file === "") {
|
|
15
|
+
return {
|
|
16
|
+
name: "validate-error-coverage",
|
|
17
|
+
passed: false,
|
|
18
|
+
issues: [
|
|
19
|
+
{
|
|
20
|
+
severity: "error",
|
|
21
|
+
message: "validate-error-coverage requires a `file` parameter",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
stats: { checked: 0, violations: 0 },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const errorObjects = options.options?.["errorObjects"];
|
|
28
|
+
const requiredFields = options.options?.["requiredFields"];
|
|
29
|
+
const result = await validateErrorCoverage.checkErrorCoverage({
|
|
30
|
+
root: options.root,
|
|
31
|
+
file,
|
|
32
|
+
errorObjects,
|
|
33
|
+
requiredFields,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
name: "validate-error-coverage",
|
|
37
|
+
passed: result.passed,
|
|
38
|
+
issues: result.violations.map((v) => ({
|
|
39
|
+
severity: "error",
|
|
40
|
+
file,
|
|
41
|
+
message: `${v.name}: missing [${v.missing.join(", ")}]`,
|
|
42
|
+
})),
|
|
43
|
+
stats: { checked: result.checked, violations: result.violations.length },
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Export naming convention validator
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as validateExportNames from "../../validate-export-names.js";
|
|
8
|
+
/**
|
|
9
|
+
* Validator for checking export naming conventions
|
|
10
|
+
*
|
|
11
|
+
* This validator requires the 'javascript' stack.
|
|
12
|
+
*/
|
|
13
|
+
export const exportNamesValidator = {
|
|
14
|
+
name: "validate-export-names",
|
|
15
|
+
description: "Validate export naming conventions",
|
|
16
|
+
requiredStacks: ["javascript"],
|
|
17
|
+
validate: async (options) => {
|
|
18
|
+
const result = await validateExportNames.checkExportNames({
|
|
19
|
+
root: options.root,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
name: "validate-export-names",
|
|
23
|
+
passed: result.isValid,
|
|
24
|
+
issues: result.violations.map((violation) => ({
|
|
25
|
+
severity: "error",
|
|
26
|
+
message: `${violation.packageName}: "${violation.exportPath}" should be "${violation.suggestion}"`,
|
|
27
|
+
})),
|
|
28
|
+
stats: { packagesChecked: result.packagesChecked },
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Laroux package boundary validator
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as validateLarouxBoundaries from "../../validate-laroux-boundaries.js";
|
|
8
|
+
const stringList = (value) => Array.isArray(value)
|
|
9
|
+
? value.filter((entry) => typeof entry === "string")
|
|
10
|
+
: [];
|
|
11
|
+
export const larouxBoundariesValidator = {
|
|
12
|
+
name: "validate-laroux-boundaries",
|
|
13
|
+
description: "Enforce the laroux package boundaries and the allowlist of deprecated-package importers",
|
|
14
|
+
requiredStacks: [],
|
|
15
|
+
validate: async (options) => {
|
|
16
|
+
const allowlist = options.options?.["allowlist"];
|
|
17
|
+
const result = await validateLarouxBoundaries.checkLarouxBoundaries({
|
|
18
|
+
root: options.root,
|
|
19
|
+
allowlist: typeof allowlist === "string" ? allowlist : undefined,
|
|
20
|
+
exclude: stringList(options.options?.["exclude"]),
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
name: "validate-laroux-boundaries",
|
|
24
|
+
passed: result.issues.length === 0,
|
|
25
|
+
issues: result.issues,
|
|
26
|
+
stats: { filesChecked: result.filesChecked },
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Module reachability validator
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as validateModExports from "../../validate-mod-exports.js";
|
|
8
|
+
/**
|
|
9
|
+
* Validator that reports the modules no package entry point reaches
|
|
10
|
+
*
|
|
11
|
+
* This validator requires the 'javascript' stack.
|
|
12
|
+
*/
|
|
13
|
+
export const modExportsValidator = {
|
|
14
|
+
name: "validate-mod-exports",
|
|
15
|
+
description: "Detect modules no package entry point reaches",
|
|
16
|
+
requiredStacks: ["javascript"],
|
|
17
|
+
validate: async (options) => {
|
|
18
|
+
const result = await validateModExports.checkModExports({
|
|
19
|
+
root: options.root,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
name: "validate-mod-exports",
|
|
23
|
+
passed: result.isComplete,
|
|
24
|
+
issues: result.missingExports.map((missing) => ({
|
|
25
|
+
severity: "error",
|
|
26
|
+
message: `${missing.packageName}: ${missing.file} is not reached from mod.ts, the exports or another entry point; export it or remove it`,
|
|
27
|
+
file: missing.file,
|
|
28
|
+
})),
|
|
29
|
+
stats: { packagesChecked: result.packagesChecked },
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in validators
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
export { circularDepsValidator } from "./circular-deps.ts";
|
|
7
|
+
export { modExportsValidator } from "./mod-exports.ts";
|
|
8
|
+
export { exportNamesValidator } from "./export-names.ts";
|
|
9
|
+
export { docsValidator } from "./docs.ts";
|
|
10
|
+
export { serverLocValidator } from "./server-loc.ts";
|
|
11
|
+
export { errorCoverageValidator } from "./error-coverage.ts";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* Built-in validators
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { circularDepsValidator } from "./circular-deps.js";
|
|
8
|
+
export { modExportsValidator } from "./mod-exports.js";
|
|
9
|
+
export { exportNamesValidator } from "./export-names.js";
|
|
10
|
+
export { docsValidator } from "./docs.js";
|
|
11
|
+
export { serverLocValidator } from "./server-loc.js";
|
|
12
|
+
export { errorCoverageValidator } from "./error-coverage.js";
|