eser 0.8.4 → 0.8.5
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/eser.js +8381 -0
- package/package.json +2 -10
- package/bin.js +0 -6
- package/commands/codebase/mod.js +0 -346
- package/main.js +0 -48
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eser",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"exports": "./main.js",
|
|
6
5
|
"bin": {
|
|
7
|
-
"eser": "./
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@eser/codebase": "npm:@jsr/eser__codebase@^0.8.4",
|
|
11
|
-
"@eser/standards": "npm:@jsr/eser__standards@^0.8.4",
|
|
12
|
-
"@std/cli": "npm:@jsr/std__cli@^1.0.25",
|
|
13
|
-
"@std/fmt": "npm:@jsr/std__fmt@^1.0.8",
|
|
14
|
-
"@std/path": "npm:@jsr/std__path@^1.1.4"
|
|
6
|
+
"eser": "./eser.js"
|
|
15
7
|
}
|
|
16
8
|
}
|
package/bin.js
DELETED
package/commands/codebase/mod.js
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import * as cliParseArgs from "@std/cli/parse-args";
|
|
2
|
-
import * as fmtColors from "@std/fmt/colors";
|
|
3
|
-
import * as standardsRuntime from "@eser/standards/runtime";
|
|
4
|
-
import * as checkCircularDeps from "@eser/codebase/check-circular-deps";
|
|
5
|
-
import * as checkModExports from "@eser/codebase/check-mod-exports";
|
|
6
|
-
import * as checkExportNames from "@eser/codebase/check-export-names";
|
|
7
|
-
import * as checkDocs from "@eser/codebase/check-docs";
|
|
8
|
-
import * as checkLicenses from "@eser/codebase/check-licenses";
|
|
9
|
-
import * as checkPackageConfigs from "@eser/codebase/check-package-configs";
|
|
10
|
-
import * as versions from "@eser/codebase/versions";
|
|
11
|
-
const showSubcommandHelp = (name, def) => {
|
|
12
|
-
console.log(`eser codebase ${name} - ${def.description}
|
|
13
|
-
`);
|
|
14
|
-
console.log(`Usage: ${def.usage}
|
|
15
|
-
`);
|
|
16
|
-
if (def.options.length > 0) {
|
|
17
|
-
console.log("Options:");
|
|
18
|
-
for (const opt of def.options) {
|
|
19
|
-
console.log(` ${opt.flag.padEnd(20)} ${opt.description}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const subcommands = {
|
|
24
|
-
"check-circular-deps": {
|
|
25
|
-
description: "Detect circular package dependencies",
|
|
26
|
-
usage: "eser codebase check-circular-deps [options]",
|
|
27
|
-
options: [
|
|
28
|
-
{
|
|
29
|
-
flag: "--root <path>",
|
|
30
|
-
description: "Root directory (default: current)"
|
|
31
|
-
},
|
|
32
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
33
|
-
],
|
|
34
|
-
handler: async (_args, flags) => {
|
|
35
|
-
const root = flags["root"];
|
|
36
|
-
console.log("Checking for circular dependencies...\n");
|
|
37
|
-
const result = await checkCircularDeps.checkCircularDeps({ root });
|
|
38
|
-
console.log(`Checked ${result.packagesChecked} packages.`);
|
|
39
|
-
if (result.hasCycles) {
|
|
40
|
-
console.log(
|
|
41
|
-
fmtColors.red(
|
|
42
|
-
`
|
|
43
|
-
Found ${result.cycles.length} circular dependencies:
|
|
44
|
-
`
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
for (const cycle of result.cycles) {
|
|
48
|
-
console.log(fmtColors.yellow(` ${cycle.join(" \u2192 ")}`));
|
|
49
|
-
}
|
|
50
|
-
standardsRuntime.runtime.process.exit(1);
|
|
51
|
-
} else {
|
|
52
|
-
console.log(fmtColors.green("\nNo circular dependencies found."));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"check-mod-exports": {
|
|
57
|
-
description: "Validate mod.ts exports all public files",
|
|
58
|
-
usage: "eser codebase check-mod-exports [options]",
|
|
59
|
-
options: [
|
|
60
|
-
{
|
|
61
|
-
flag: "--root <path>",
|
|
62
|
-
description: "Root directory (default: current)"
|
|
63
|
-
},
|
|
64
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
65
|
-
],
|
|
66
|
-
handler: async (_args, flags) => {
|
|
67
|
-
const root = flags["root"];
|
|
68
|
-
console.log("Checking mod.ts exports...\n");
|
|
69
|
-
const result = await checkModExports.checkModExports({ root });
|
|
70
|
-
console.log(`Checked ${result.packagesChecked} packages.`);
|
|
71
|
-
if (!result.isComplete) {
|
|
72
|
-
console.log(
|
|
73
|
-
fmtColors.red(
|
|
74
|
-
`
|
|
75
|
-
Found ${result.missingExports.length} missing exports:
|
|
76
|
-
`
|
|
77
|
-
)
|
|
78
|
-
);
|
|
79
|
-
for (const missing of result.missingExports) {
|
|
80
|
-
console.log(
|
|
81
|
-
fmtColors.yellow(` ${missing.packageName}: ${missing.file}`)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
standardsRuntime.runtime.process.exit(1);
|
|
85
|
-
} else {
|
|
86
|
-
console.log(fmtColors.green("\nAll mod.ts exports are complete."));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
"check-export-names": {
|
|
91
|
-
description: "Validate export naming conventions",
|
|
92
|
-
usage: "eser codebase check-export-names [options]",
|
|
93
|
-
options: [
|
|
94
|
-
{
|
|
95
|
-
flag: "--root <path>",
|
|
96
|
-
description: "Root directory (default: current)"
|
|
97
|
-
},
|
|
98
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
99
|
-
],
|
|
100
|
-
handler: async (_args, flags) => {
|
|
101
|
-
const root = flags["root"];
|
|
102
|
-
console.log("Checking export naming conventions...\n");
|
|
103
|
-
const result = await checkExportNames.checkExportNames({ root });
|
|
104
|
-
console.log(`Checked ${result.packagesChecked} packages.`);
|
|
105
|
-
if (!result.isValid) {
|
|
106
|
-
console.log(
|
|
107
|
-
fmtColors.red(
|
|
108
|
-
`
|
|
109
|
-
Found ${result.violations.length} naming violations:
|
|
110
|
-
`
|
|
111
|
-
)
|
|
112
|
-
);
|
|
113
|
-
for (const violation of result.violations) {
|
|
114
|
-
console.log(fmtColors.yellow(` ${violation.packageName}:`));
|
|
115
|
-
console.log(` Export: ${violation.exportPath}`);
|
|
116
|
-
console.log(` Suggestion: ${violation.suggestion}`);
|
|
117
|
-
}
|
|
118
|
-
standardsRuntime.runtime.process.exit(1);
|
|
119
|
-
} else {
|
|
120
|
-
console.log(fmtColors.green("\nAll export names follow conventions."));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
"check-docs": {
|
|
125
|
-
description: "Validate JSDoc documentation",
|
|
126
|
-
usage: "eser codebase check-docs [options]",
|
|
127
|
-
options: [
|
|
128
|
-
{
|
|
129
|
-
flag: "--root <path>",
|
|
130
|
-
description: "Root directory (default: current)"
|
|
131
|
-
},
|
|
132
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
133
|
-
],
|
|
134
|
-
handler: async (_args, flags) => {
|
|
135
|
-
const root = flags["root"];
|
|
136
|
-
console.log("Checking documentation...\n");
|
|
137
|
-
const result = await checkDocs.checkDocs({ root });
|
|
138
|
-
console.log(
|
|
139
|
-
`Checked ${result.filesChecked} files, ${result.symbolsChecked} symbols.`
|
|
140
|
-
);
|
|
141
|
-
if (!result.isValid) {
|
|
142
|
-
console.log(
|
|
143
|
-
fmtColors.red(
|
|
144
|
-
`
|
|
145
|
-
Found ${result.issues.length} documentation issues:
|
|
146
|
-
`
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
const byFile = /* @__PURE__ */ new Map();
|
|
150
|
-
for (const issue of result.issues) {
|
|
151
|
-
const existing = byFile.get(issue.file) ?? [];
|
|
152
|
-
existing.push(issue);
|
|
153
|
-
byFile.set(issue.file, existing);
|
|
154
|
-
}
|
|
155
|
-
for (const [file, fileIssues] of byFile) {
|
|
156
|
-
console.log(fmtColors.yellow(`
|
|
157
|
-
${file}:`));
|
|
158
|
-
for (const issue of fileIssues) {
|
|
159
|
-
const lineInfo = issue.line !== void 0 ? `:${issue.line}` : "";
|
|
160
|
-
console.log(` ${issue.symbol}${lineInfo}: ${issue.issue}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
standardsRuntime.runtime.process.exit(1);
|
|
164
|
-
} else {
|
|
165
|
-
console.log(fmtColors.green("\nAll documentation is valid."));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
"check-licenses": {
|
|
170
|
-
description: "Validate license headers in source files",
|
|
171
|
-
usage: "eser codebase check-licenses [options]",
|
|
172
|
-
options: [
|
|
173
|
-
{ flag: "--fix", description: "Auto-fix missing or incorrect headers" },
|
|
174
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
175
|
-
],
|
|
176
|
-
handler: async (_args, flags) => {
|
|
177
|
-
const fix = flags["fix"];
|
|
178
|
-
console.log("Validating license headers...\n");
|
|
179
|
-
const result = await checkLicenses.validateLicenses({ fix });
|
|
180
|
-
if (result.issues.length === 0) {
|
|
181
|
-
console.log(
|
|
182
|
-
`Checked ${result.checked} files. All licenses are valid.`
|
|
183
|
-
);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (fix) {
|
|
187
|
-
for (const issue of result.issues) {
|
|
188
|
-
if (issue.fixed) {
|
|
189
|
-
console.log(`Fixed ${issue.issue} header: ${issue.path}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
console.log(`Fixed ${result.fixedCount} files.`);
|
|
193
|
-
} else {
|
|
194
|
-
for (const issue of result.issues) {
|
|
195
|
-
console.error(
|
|
196
|
-
fmtColors.red(
|
|
197
|
-
`${issue.issue === "missing" ? "Missing" : "Incorrect"} copyright header: ${issue.path}`
|
|
198
|
-
)
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
console.log(
|
|
202
|
-
fmtColors.yellow(
|
|
203
|
-
`
|
|
204
|
-
Copyright header should be "// Copyright YYYY-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license."`
|
|
205
|
-
)
|
|
206
|
-
);
|
|
207
|
-
standardsRuntime.runtime.process.exit(1);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
"check-package-configs": {
|
|
212
|
-
description: "Validate deno.json and package.json consistency",
|
|
213
|
-
usage: "eser codebase check-package-configs [options]",
|
|
214
|
-
options: [
|
|
215
|
-
{
|
|
216
|
-
flag: "--root <path>",
|
|
217
|
-
description: "Root directory (default: current)"
|
|
218
|
-
},
|
|
219
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
220
|
-
],
|
|
221
|
-
handler: async (_args, flags) => {
|
|
222
|
-
const root = flags["root"];
|
|
223
|
-
console.log("Checking package config consistency...\n");
|
|
224
|
-
const result = await checkPackageConfigs.checkPackageConfigs({ root });
|
|
225
|
-
console.log(`Checked ${result.packagesChecked} packages.`);
|
|
226
|
-
if (!result.isConsistent) {
|
|
227
|
-
console.log(
|
|
228
|
-
fmtColors.red(
|
|
229
|
-
`
|
|
230
|
-
Found ${result.inconsistencies.length} inconsistencies:
|
|
231
|
-
`
|
|
232
|
-
)
|
|
233
|
-
);
|
|
234
|
-
const byPackage = /* @__PURE__ */ new Map();
|
|
235
|
-
for (const inc of result.inconsistencies) {
|
|
236
|
-
const existing = byPackage.get(inc.packageName) ?? [];
|
|
237
|
-
existing.push(inc);
|
|
238
|
-
byPackage.set(inc.packageName, existing);
|
|
239
|
-
}
|
|
240
|
-
for (const [pkgName, inconsistencies] of byPackage) {
|
|
241
|
-
console.log(fmtColors.yellow(`${pkgName}:`));
|
|
242
|
-
for (const inc of inconsistencies) {
|
|
243
|
-
console.log(fmtColors.red(` \u26A0 ${inc.field} mismatch:`));
|
|
244
|
-
console.log(` deno.json: ${JSON.stringify(inc.denoValue)}`);
|
|
245
|
-
console.log(
|
|
246
|
-
` package.json: ${JSON.stringify(inc.packageValue)}`
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
standardsRuntime.runtime.process.exit(1);
|
|
251
|
-
} else {
|
|
252
|
-
console.log(fmtColors.green("\nAll package configs are consistent."));
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
versions: {
|
|
257
|
-
description: "Manage workspace package versions",
|
|
258
|
-
usage: "eser codebase versions [command] [options]",
|
|
259
|
-
options: [
|
|
260
|
-
{ flag: "sync", description: "Sync all packages to root version" },
|
|
261
|
-
{ flag: "patch", description: "Bump patch version (0.0.x)" },
|
|
262
|
-
{ flag: "minor", description: "Bump minor version (0.x.0)" },
|
|
263
|
-
{ flag: "major", description: "Bump major version (x.0.0)" },
|
|
264
|
-
{ flag: "--dry-run", description: "Preview changes without applying" },
|
|
265
|
-
{ flag: "-h, --help", description: "Show this help message" }
|
|
266
|
-
],
|
|
267
|
-
handler: async (args, flags) => {
|
|
268
|
-
const command = args[0];
|
|
269
|
-
const dryRun = flags["dry-run"];
|
|
270
|
-
if (command === void 0) {
|
|
271
|
-
const result2 = await versions.showVersions();
|
|
272
|
-
console.table(result2.packages);
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const validCommands = ["sync", "patch", "minor", "major"];
|
|
276
|
-
if (!validCommands.includes(command)) {
|
|
277
|
-
console.error(fmtColors.red(`Invalid command: ${command}`));
|
|
278
|
-
console.error(
|
|
279
|
-
"Usage: eser codebase versions [sync|patch|minor|major] [--dry-run]"
|
|
280
|
-
);
|
|
281
|
-
standardsRuntime.runtime.process.exit(1);
|
|
282
|
-
}
|
|
283
|
-
if (command === "sync") {
|
|
284
|
-
console.log("Syncing all versions...");
|
|
285
|
-
} else {
|
|
286
|
-
console.log(`Bumping all versions (${command})...`);
|
|
287
|
-
}
|
|
288
|
-
const result = await versions.versions(command, { dryRun });
|
|
289
|
-
console.log(`Target version: ${result.targetVersion}`);
|
|
290
|
-
console.table(result.updates);
|
|
291
|
-
if (result.dryRun) {
|
|
292
|
-
console.log(
|
|
293
|
-
fmtColors.cyan(
|
|
294
|
-
`Dry run - ${result.changedCount} packages would be modified.`
|
|
295
|
-
)
|
|
296
|
-
);
|
|
297
|
-
} else {
|
|
298
|
-
console.log(`Done. Updated ${result.changedCount} packages.`);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
const showHelp = () => {
|
|
304
|
-
console.log("eser codebase - Codebase validation tools\n");
|
|
305
|
-
console.log("Usage: eser codebase <subcommand> [options]\n");
|
|
306
|
-
console.log("Subcommands:");
|
|
307
|
-
console.log(" check-circular-deps Detect circular package dependencies");
|
|
308
|
-
console.log(" check-mod-exports Validate mod.ts exports all files");
|
|
309
|
-
console.log(" check-export-names Validate export naming conventions");
|
|
310
|
-
console.log(" check-docs Validate JSDoc documentation");
|
|
311
|
-
console.log(" check-licenses Validate license headers");
|
|
312
|
-
console.log(
|
|
313
|
-
" check-package-configs Validate deno.json/package.json consistency"
|
|
314
|
-
);
|
|
315
|
-
console.log(" versions Manage workspace versions");
|
|
316
|
-
console.log(
|
|
317
|
-
"\nRun 'eser codebase <subcommand> --help' for subcommand options."
|
|
318
|
-
);
|
|
319
|
-
};
|
|
320
|
-
const codebaseCommand = async (rawArgs, _parentFlags) => {
|
|
321
|
-
const parsed = cliParseArgs.parseArgs(rawArgs, {
|
|
322
|
-
boolean: ["help", "dry-run", "fix"],
|
|
323
|
-
string: ["root"],
|
|
324
|
-
alias: { h: "help" }
|
|
325
|
-
});
|
|
326
|
-
const subcommand = parsed._[0];
|
|
327
|
-
if (subcommand === void 0) {
|
|
328
|
-
showHelp();
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const def = subcommands[subcommand];
|
|
332
|
-
if (def === void 0) {
|
|
333
|
-
console.error(fmtColors.red(`Unknown subcommand: ${subcommand}`));
|
|
334
|
-
console.log("");
|
|
335
|
-
showHelp();
|
|
336
|
-
standardsRuntime.runtime.process.exit(1);
|
|
337
|
-
}
|
|
338
|
-
if (parsed.help) {
|
|
339
|
-
showSubcommandHelp(subcommand, def);
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
await def.handler(parsed._.slice(1), parsed);
|
|
343
|
-
};
|
|
344
|
-
export {
|
|
345
|
-
codebaseCommand
|
|
346
|
-
};
|
package/main.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as cliParseArgs from "@std/cli/parse-args";
|
|
2
|
-
import * as standardsRuntime from "@eser/standards/runtime";
|
|
3
|
-
import { codebaseCommand } from "./commands/codebase/mod.js";
|
|
4
|
-
import config from "./package.json" with { type: "json" };
|
|
5
|
-
const commands = {
|
|
6
|
-
codebase: codebaseCommand
|
|
7
|
-
};
|
|
8
|
-
const showHelp = () => {
|
|
9
|
-
console.log("eser - Eser Ozvataf's command-line tooling to access things\n");
|
|
10
|
-
console.log("Usage: eser <command> [subcommand] [options]\n");
|
|
11
|
-
console.log("Commands:");
|
|
12
|
-
console.log(" codebase Codebase validation and management tools");
|
|
13
|
-
console.log("\nOptions:");
|
|
14
|
-
console.log(" -h, --help Show this help message");
|
|
15
|
-
console.log(" -v, --version Show version number");
|
|
16
|
-
console.log("\nRun 'eser <command> --help' for command-specific help.");
|
|
17
|
-
};
|
|
18
|
-
const main = async () => {
|
|
19
|
-
const args = cliParseArgs.parseArgs(standardsRuntime.runtime.process.args, {
|
|
20
|
-
boolean: ["help", "version"],
|
|
21
|
-
alias: { h: "help", v: "version" },
|
|
22
|
-
stopEarly: true
|
|
23
|
-
// Stop parsing at first non-option to pass rest to subcommand
|
|
24
|
-
});
|
|
25
|
-
if (args.version) {
|
|
26
|
-
console.log(`eser ${config.version}`);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const command = args._[0];
|
|
30
|
-
if (command === void 0) {
|
|
31
|
-
showHelp();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const handler = commands[command];
|
|
35
|
-
if (handler === void 0) {
|
|
36
|
-
console.error(`Unknown command: ${command}`);
|
|
37
|
-
console.log("");
|
|
38
|
-
showHelp();
|
|
39
|
-
standardsRuntime.runtime.process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
await handler(args._.slice(1), args);
|
|
42
|
-
};
|
|
43
|
-
if (import.meta.main) {
|
|
44
|
-
await main();
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
main
|
|
48
|
-
};
|