@codefast/cli 0.13.0 → 0.15.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 (72) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +124 -40
  3. package/dist/arrange/simplify/variant-classname-probe.js +2 -11
  4. package/dist/audit/command.js +57 -16
  5. package/dist/audit/comments/domain/comment-content.d.ts +12 -0
  6. package/dist/audit/comments/domain/comment-content.js +17 -4
  7. package/dist/audit/comments/domain/comment-dividers.js +8 -1
  8. package/dist/audit/display-names/domain/display-names.js +4 -3
  9. package/dist/audit/domain/types.d.ts +119 -24
  10. package/dist/audit/engines/cli-result.d.ts +13 -0
  11. package/dist/audit/engines/cli-result.js +22 -0
  12. package/dist/audit/engines/cli-schema.d.ts +18 -0
  13. package/dist/audit/{constants → engines}/cli-schema.js +3 -3
  14. package/dist/audit/engines/domain/node-floor.d.ts +34 -0
  15. package/dist/audit/engines/domain/node-floor.js +40 -0
  16. package/dist/audit/engines/domain/range-gaps.d.ts +21 -0
  17. package/dist/audit/engines/domain/range-gaps.js +136 -0
  18. package/dist/audit/engines/output.d.ts +7 -0
  19. package/dist/audit/engines/output.js +40 -0
  20. package/dist/audit/engines/prepare.d.ts +16 -0
  21. package/dist/audit/engines/prepare.js +12 -0
  22. package/dist/audit/engines/run.d.ts +18 -0
  23. package/dist/audit/engines/run.js +225 -0
  24. package/dist/audit/layers/cli-result.d.ts +13 -0
  25. package/dist/audit/{constants → layers}/cli-result.js +6 -6
  26. package/dist/audit/layers/cli-schema.d.ts +29 -0
  27. package/dist/audit/layers/cli-schema.js +17 -0
  28. package/dist/audit/layers/domain/layering.d.ts +46 -0
  29. package/dist/audit/layers/domain/layering.js +191 -0
  30. package/dist/audit/layers/output.d.ts +7 -0
  31. package/dist/audit/layers/output.js +21 -0
  32. package/dist/audit/layers/prepare.d.ts +25 -0
  33. package/dist/audit/layers/prepare.js +66 -0
  34. package/dist/audit/layers/run.d.ts +19 -0
  35. package/dist/audit/layers/run.js +62 -0
  36. package/dist/audit/prepare.d.ts +13 -1
  37. package/dist/audit/prepare.js +16 -1
  38. package/dist/audit/props/cli-result.d.ts +13 -0
  39. package/dist/audit/props/cli-result.js +22 -0
  40. package/dist/audit/props/cli-schema.d.ts +18 -0
  41. package/dist/audit/props/cli-schema.js +12 -0
  42. package/dist/audit/props/domain/props-intersection.d.ts +56 -0
  43. package/dist/audit/props/domain/props-intersection.js +189 -0
  44. package/dist/audit/props/output.d.ts +7 -0
  45. package/dist/audit/{constants → props}/output.js +5 -5
  46. package/dist/audit/props/prepare.d.ts +13 -0
  47. package/dist/audit/props/prepare.js +9 -0
  48. package/dist/audit/props/run.d.ts +17 -0
  49. package/dist/audit/props/run.js +57 -0
  50. package/dist/audit/props/type-probe.d.ts +23 -0
  51. package/dist/audit/props/type-probe.js +85 -0
  52. package/dist/core/config/schema.d.ts +13 -4
  53. package/dist/core/config/schema.js +14 -1
  54. package/dist/core/type-server.d.ts +21 -0
  55. package/dist/core/type-server.js +32 -0
  56. package/dist/tag/cli-result.d.ts +3 -0
  57. package/dist/tag/cli-result.js +8 -2
  58. package/dist/tag/domain/types.d.ts +15 -0
  59. package/dist/tag/output.js +13 -6
  60. package/dist/tag/run.js +2 -0
  61. package/dist/tag/writer/since-writer.d.ts +5 -0
  62. package/dist/tag/writer/since-writer.js +41 -9
  63. package/package.json +6 -5
  64. package/dist/audit/constants/cli-result.d.ts +0 -13
  65. package/dist/audit/constants/cli-schema.d.ts +0 -18
  66. package/dist/audit/constants/domain/constants.d.ts +0 -8
  67. package/dist/audit/constants/domain/constants.js +0 -66
  68. package/dist/audit/constants/output.d.ts +0 -7
  69. package/dist/audit/constants/prepare.d.ts +0 -16
  70. package/dist/audit/constants/prepare.js +0 -37
  71. package/dist/audit/constants/run.d.ts +0 -14
  72. package/dist/audit/constants/run.js +0 -64
@@ -1,14 +0,0 @@
1
- import type { ConstantAuditResult } from "#audit/domain/types";
2
- import { AppError } from "#core/errors";
3
- import type { Filesystem } from "#core/filesystem/filesystem";
4
- import type { Result } from "#core/result";
5
- /**
6
- * Scans a target path's library sources for numeric constants that name none of the three kinds.
7
- *
8
- * @since 0.11.0
9
- */
10
- export declare function runConstantAudit(fs: Filesystem, args: {
11
- readonly rootDir: string;
12
- readonly targetPath: string;
13
- readonly allowlist: ReadonlyArray<string>;
14
- }): Result<ConstantAuditResult, AppError>;
@@ -1,64 +0,0 @@
1
- import path from "node:path";
2
- import { auditNumericConstants } from "#audit/constants/domain/constants";
3
- import { AppError, messageFrom } from "#core/errors";
4
- import { err, ok } from "#core/result";
5
- import { walkTsxFiles } from "#core/workspace/typescript-walk";
6
- /**
7
- * Trees the convention does not reach: a test fixes a value to observe it, a benchmark sizes a
8
- * workload, and an app or example is a consumer, not the library.
9
- */
10
- const SKIPPED_SEGMENTS = new Set([
11
- "tests",
12
- "benchmarks",
13
- "apps",
14
- "examples",
15
- "node_modules",
16
- "dist",
17
- ]);
18
- /**
19
- * Scans a target path's library sources for numeric constants that name none of the three kinds.
20
- *
21
- * @since 0.11.0
22
- */
23
- export function runConstantAudit(fs, args) {
24
- try {
25
- const allowlist = new Set(args.allowlist);
26
- const { rootDir, targetPath } = args;
27
- const filesToScan = collectScanPaths(fs, rootDir, targetPath);
28
- const files = [];
29
- let violationCount = 0;
30
- let allowlistedCount = 0;
31
- for (const absolutePath of filesToScan) {
32
- const relativePath = toPosixPath(path.relative(rootDir, absolutePath));
33
- const content = fs.readFileSync(absolutePath, "utf8");
34
- const remaining = auditNumericConstants(content).filter(({ raw }) => {
35
- const name = raw.split(" ")[0];
36
- const isAllowed = allowlist.has(name) || allowlist.has(`${relativePath}:${name}`);
37
- if (isAllowed) {
38
- allowlistedCount++;
39
- }
40
- return !isAllowed;
41
- });
42
- if (remaining.length === 0) {
43
- continue;
44
- }
45
- violationCount += remaining.length;
46
- files.push({ relativePath, violations: remaining });
47
- }
48
- return ok({ files, violationCount, allowlistedCount, scannedFileCount: filesToScan.length });
49
- }
50
- catch (error) {
51
- return err(new AppError("INFRA_FAILURE", messageFrom(error), error));
52
- }
53
- }
54
- /** The `.ts` files under a `src` directory of a library package, below the target. */
55
- function collectScanPaths(fs, rootDir, targetPath) {
56
- const candidates = fs.statSync(targetPath).isDirectory() ? walkTsxFiles(targetPath, fs) : [targetPath];
57
- return candidates.filter((absolutePath) => {
58
- const segments = toPosixPath(path.relative(rootDir, absolutePath)).split("/");
59
- return segments.includes("src") && !segments.some((segment) => SKIPPED_SEGMENTS.has(segment));
60
- });
61
- }
62
- function toPosixPath(filePath) {
63
- return filePath.split(path.sep).join("/");
64
- }