@venizia/dev-configs 0.5.0-1 → 0.5.0-10

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 (177) hide show
  1. package/README.md +18 -13
  2. package/dist/checks/purity/manifest.js +11 -3
  3. package/dist/checks/purity/manifest.js.map +1 -1
  4. package/dist/checks/purity/probe.js +19 -2
  5. package/dist/checks/purity/probe.js.map +1 -1
  6. package/dist/checks/split-report.js +2 -1
  7. package/dist/checks/split-report.js.map +1 -1
  8. package/dist/checks/test-controls.d.ts +9 -1
  9. package/dist/checks/test-controls.js +9 -3
  10. package/dist/checks/test-controls.js.map +1 -1
  11. package/dist/checks/test-dead-code.d.ts +9 -1
  12. package/dist/checks/test-dead-code.js +13 -2
  13. package/dist/checks/test-dead-code.js.map +1 -1
  14. package/dist/checks/test-mutate.d.ts +9 -1
  15. package/dist/checks/test-mutate.js +12 -6
  16. package/dist/checks/test-mutate.js.map +1 -1
  17. package/dist/cli/check.js +42 -38
  18. package/dist/cli/check.js.map +1 -1
  19. package/dist/cli/clean.js +3 -2
  20. package/dist/cli/clean.js.map +1 -1
  21. package/dist/cli/codemod/any-aliases.d.ts +1 -1
  22. package/dist/cli/codemod/any-aliases.js +14 -13
  23. package/dist/cli/codemod/any-aliases.js.map +1 -1
  24. package/dist/cli/codemod/async-style.d.ts +1 -1
  25. package/dist/cli/codemod/async-style.js +18 -17
  26. package/dist/cli/codemod/async-style.js.map +1 -1
  27. package/dist/cli/codemod/binding-keys.d.ts +32 -1
  28. package/dist/cli/codemod/binding-keys.js +238 -58
  29. package/dist/cli/codemod/binding-keys.js.map +1 -1
  30. package/dist/cli/codemod/class-renames.d.ts +39 -0
  31. package/dist/cli/codemod/class-renames.js +297 -0
  32. package/dist/cli/codemod/class-renames.js.map +1 -0
  33. package/dist/cli/codemod/connector-imports.d.ts +1 -1
  34. package/dist/cli/codemod/connector-imports.js +13 -12
  35. package/dist/cli/codemod/connector-imports.js.map +1 -1
  36. package/dist/cli/codemod/const-class-sets.d.ts +55 -0
  37. package/dist/cli/codemod/const-class-sets.js +219 -0
  38. package/dist/cli/codemod/const-class-sets.js.map +1 -0
  39. package/dist/cli/codemod/const-classes.d.ts +21 -3
  40. package/dist/cli/codemod/const-classes.js +151 -36
  41. package/dist/cli/codemod/const-classes.js.map +1 -1
  42. package/dist/cli/codemod/drop-redundant-casts.d.ts +6 -1
  43. package/dist/cli/codemod/drop-redundant-casts.js +27 -19
  44. package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
  45. package/dist/cli/codemod/env-get.d.ts +3 -3
  46. package/dist/cli/codemod/env-get.js +19 -18
  47. package/dist/cli/codemod/env-get.js.map +1 -1
  48. package/dist/cli/codemod/files.d.ts +4 -2
  49. package/dist/cli/codemod/files.js +7 -8
  50. package/dist/cli/codemod/files.js.map +1 -1
  51. package/dist/cli/codemod/function-to-arrow.d.ts +76 -0
  52. package/dist/cli/codemod/function-to-arrow.js +357 -0
  53. package/dist/cli/codemod/function-to-arrow.js.map +1 -0
  54. package/dist/cli/codemod/index.js +25 -4
  55. package/dist/cli/codemod/index.js.map +1 -1
  56. package/dist/cli/codemod/namespace-functions/index.d.ts +1 -1
  57. package/dist/cli/codemod/namespace-functions/index.js +14 -13
  58. package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
  59. package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js +3 -3
  60. package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js.map +1 -1
  61. package/dist/cli/codemod/namespace-functions/mappings/helpers.js +1 -1
  62. package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
  63. package/dist/cli/codemod/typed-route-context.d.ts +58 -0
  64. package/dist/cli/codemod/typed-route-context.js +918 -0
  65. package/dist/cli/codemod/typed-route-context.js.map +1 -0
  66. package/dist/cli/index.js +5 -4
  67. package/dist/cli/index.js.map +1 -1
  68. package/dist/common/cli-output.d.ts +16 -0
  69. package/dist/common/cli-output.js +49 -0
  70. package/dist/common/cli-output.js.map +1 -0
  71. package/dist/compilers/bun.js +1 -1
  72. package/dist/compilers/bun.js.map +1 -1
  73. package/dist/linters/eslint.js +1 -1
  74. package/dist/linters/eslint.js.map +1 -1
  75. package/dist/linters/house/browser-api-patterns.d.ts +43 -0
  76. package/dist/linters/house/browser-api-patterns.js +87 -0
  77. package/dist/linters/house/browser-api-patterns.js.map +1 -0
  78. package/dist/linters/house/common.d.ts +17 -2
  79. package/dist/linters/house/common.js +18 -2
  80. package/dist/linters/house/common.js.map +1 -1
  81. package/dist/linters/house/configs.js +25 -0
  82. package/dist/linters/house/configs.js.map +1 -1
  83. package/dist/linters/house/const-class-values.rule.d.ts +2 -2
  84. package/dist/linters/house/const-class-values.rule.js +14 -5
  85. package/dist/linters/house/const-class-values.rule.js.map +1 -1
  86. package/dist/linters/house/effect-cleanup-consistency.rule.d.ts +2 -2
  87. package/dist/linters/house/effect-cleanup-consistency.rule.js +1 -1
  88. package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
  89. package/dist/linters/house/framework-api-patterns.d.ts +54 -0
  90. package/dist/linters/house/framework-api-patterns.js +62 -0
  91. package/dist/linters/house/framework-api-patterns.js.map +1 -0
  92. package/dist/linters/house/framework-exports.d.ts +62 -0
  93. package/dist/linters/house/framework-exports.js +325 -0
  94. package/dist/linters/house/framework-exports.js.map +1 -0
  95. package/dist/linters/house/import-support.d.ts +56 -0
  96. package/dist/linters/house/import-support.js +179 -0
  97. package/dist/linters/house/import-support.js.map +1 -0
  98. package/dist/linters/house/index.d.ts +12 -0
  99. package/dist/linters/house/index.js +15 -1
  100. package/dist/linters/house/index.js.map +1 -1
  101. package/dist/linters/house/max-params-own.rule.d.ts +2 -2
  102. package/dist/linters/house/max-params-own.rule.js +1 -1
  103. package/dist/linters/house/max-params-own.rule.js.map +1 -1
  104. package/dist/linters/house/no-async-hook-callback.rule.d.ts +2 -2
  105. package/dist/linters/house/no-async-hook-callback.rule.js +1 -1
  106. package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
  107. package/dist/linters/house/no-await-new-chain.rule.d.ts +2 -2
  108. package/dist/linters/house/no-await-new-chain.rule.js +1 -1
  109. package/dist/linters/house/no-await-new-chain.rule.js.map +1 -1
  110. package/dist/linters/house/no-await-promise-chain.rule.d.ts +2 -2
  111. package/dist/linters/house/no-await-promise-chain.rule.js +5 -5
  112. package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
  113. package/dist/linters/house/no-inline-await.rule.d.ts +2 -2
  114. package/dist/linters/house/no-inline-await.rule.js +1 -1
  115. package/dist/linters/house/no-inline-await.rule.js.map +1 -1
  116. package/dist/linters/house/no-leaked-render.rule.d.ts +2 -2
  117. package/dist/linters/house/no-leaked-render.rule.js +1 -1
  118. package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
  119. package/dist/linters/house/no-new-error.rule.d.ts +2 -2
  120. package/dist/linters/house/no-new-error.rule.js +2 -2
  121. package/dist/linters/house/no-new-error.rule.js.map +1 -1
  122. package/dist/linters/house/no-parent-import.rule.d.ts +45 -0
  123. package/dist/linters/house/no-parent-import.rule.js +176 -0
  124. package/dist/linters/house/no-parent-import.rule.js.map +1 -0
  125. package/dist/linters/house/no-return-await.rule.d.ts +2 -2
  126. package/dist/linters/house/no-return-await.rule.js +1 -1
  127. package/dist/linters/house/no-return-await.rule.js.map +1 -1
  128. package/dist/linters/house/no-shadow-framework-type.rule.d.ts +24 -0
  129. package/dist/linters/house/no-shadow-framework-type.rule.js +100 -0
  130. package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -0
  131. package/dist/linters/house/no-silent-catch.rule.d.ts +2 -2
  132. package/dist/linters/house/no-silent-catch.rule.js +3 -3
  133. package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
  134. package/dist/linters/house/no-unbraced-case.rule.d.ts +2 -2
  135. package/dist/linters/house/no-unbraced-case.rule.js +1 -1
  136. package/dist/linters/house/no-unbraced-case.rule.js.map +1 -1
  137. package/dist/linters/house/plugin.d.ts +1 -1
  138. package/dist/linters/house/plugin.js +18 -2
  139. package/dist/linters/house/plugin.js.map +1 -1
  140. package/dist/linters/house/prefer-framework-api.rule.d.ts +83 -0
  141. package/dist/linters/house/prefer-framework-api.rule.js +562 -0
  142. package/dist/linters/house/prefer-framework-api.rule.js.map +1 -0
  143. package/dist/linters/house/prefer-http-method.rule.d.ts +22 -0
  144. package/dist/linters/house/prefer-http-method.rule.js +182 -0
  145. package/dist/linters/house/prefer-http-method.rule.js.map +1 -0
  146. package/dist/linters/house/prefer-promise-sleep.rule.d.ts +26 -0
  147. package/dist/linters/house/prefer-promise-sleep.rule.js +155 -0
  148. package/dist/linters/house/prefer-promise-sleep.rule.js.map +1 -0
  149. package/dist/linters/house/prefer-tnullable.rule.d.ts +25 -0
  150. package/dist/linters/house/prefer-tnullable.rule.js +124 -0
  151. package/dist/linters/house/prefer-tnullable.rule.js.map +1 -0
  152. package/dist/linters/house/typed-route-context.rule.d.ts +19 -0
  153. package/dist/linters/house/typed-route-context.rule.js +334 -0
  154. package/dist/linters/house/typed-route-context.rule.js.map +1 -0
  155. package/dist/linters/house/zod-schema-convention.rule.d.ts +82 -0
  156. package/dist/linters/house/zod-schema-convention.rule.js +477 -0
  157. package/dist/linters/house/zod-schema-convention.rule.js.map +1 -0
  158. package/dist/linters/oxlint.js +11 -1
  159. package/dist/linters/oxlint.js.map +1 -1
  160. package/dist/linters/react-eslint.js.map +1 -1
  161. package/dist/linters/rules/naming-convention.rule.d.ts +4 -1
  162. package/dist/linters/rules/naming-convention.rule.js +30 -1
  163. package/dist/linters/rules/naming-convention.rule.js.map +1 -1
  164. package/dist/linters/rules/no-restricted-properties.rule.js +1 -1
  165. package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
  166. package/dist/testing/index.d.ts +2 -2
  167. package/dist/testing/index.js +2 -2
  168. package/dist/testing/index.js.map +1 -1
  169. package/dist/testing/{rejection.helper.d.ts → rejection.utility.d.ts} +4 -4
  170. package/dist/testing/{rejection.helper.js → rejection.utility.js} +7 -7
  171. package/dist/testing/rejection.utility.js.map +1 -0
  172. package/dist/testing/{spawn.helper.d.ts → spawn.utility.d.ts} +2 -2
  173. package/dist/testing/{spawn.helper.js → spawn.utility.js} +6 -6
  174. package/dist/testing/spawn.utility.js.map +1 -0
  175. package/package.json +7 -7
  176. package/dist/testing/rejection.helper.js.map +0 -1
  177. package/dist/testing/spawn.helper.js.map +0 -1
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeadTestCodeCheck = void 0;
3
+ exports.DeadTestCodeCheck = exports.DeadTestCodeCandidateTypes = void 0;
4
4
  const node_child_process_1 = require("node:child_process");
5
5
  const node_path_1 = require("node:path");
6
+ /** Why a support file is a candidate for deletion. */
7
+ class DeadTestCodeCandidateTypes {
8
+ static { this.UNREFERENCED = 'unreferenced'; }
9
+ static { this.FOLDER_REFERENCED = 'folder-referenced'; }
10
+ }
11
+ exports.DeadTestCodeCandidateTypes = DeadTestCodeCandidateTypes;
6
12
  const SUPPORT_EXTENSION = /\.(?:[cm]?[jt]sx?|json|sql|txt)$/;
7
13
  const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
8
14
  const git = (opts) => {
@@ -44,7 +50,12 @@ class DeadTestCodeCheck {
44
50
  }
45
51
  const folder = (0, node_path_1.dirname)(underTests);
46
52
  const folderReferenced = folder !== '.' && referencedElsewhere({ root: opts.root, needle: folder, self: file });
47
- candidates.push({ file, kind: folderReferenced ? 'folder-referenced' : 'unreferenced' });
53
+ candidates.push({
54
+ file,
55
+ type: folderReferenced
56
+ ? DeadTestCodeCandidateTypes.FOLDER_REFERENCED
57
+ : DeadTestCodeCandidateTypes.UNREFERENCED,
58
+ });
48
59
  }
49
60
  return candidates;
50
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"test-dead-code.js","sourceRoot":"","sources":["../../src/checks/test-dead-code.ts"],"names":[],"mappings":";;;AAAA,2DAA+C;AAC/C,yC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,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;YAEnE,IACE,uBAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAC9D,mBAAmB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAC9E,CAAC;gBACD,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,UAAU,CAAC,CAAC;YACnC,MAAM,gBAAgB,GACpB,MAAM,KAAK,GAAG,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAEzF,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAjCD,8CAiCC","sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { dirname } from 'node:path';\n\n/**\n * Support files of the tests (fixtures, helpers, probes) that no other file refers to. The second\n * step of the trim-tests method. The output is CANDIDATES: a fixture can be loaded by a path built at\n * run time or by scanning a folder, so a candidate is deleted only after the package suite is green\n * without it.\n */\nexport interface IDeadTestCodeCandidate {\n file: string;\n /**\n * `unreferenced`: neither its name nor its path under `__tests__` appears in another file, nor does\n * its folder. `folder-referenced`: only its folder path does, so a scan of that folder may load it.\n */\n kind: 'unreferenced' | 'folder-referenced';\n}\n\nconst SUPPORT_EXTENSION = /\\.(?:[cm]?[jt]sx?|json|sql|txt)$/;\nconst TEST_FILE = /\\.(?:test|spec)\\.[cm]?[jt]sx?$/;\n\nconst git = (opts: { root: string; args: string[] }): { status: number; stdout: string } => {\n const result = spawnSync('git', opts.args, {\n cwd: opts.root,\n encoding: 'utf8',\n maxBuffer: 256 * 1024 * 1024,\n });\n\n return { status: result.status ?? 1, stdout: result.stdout ?? '' };\n};\n\n/** Files other than `self` whose text contains `needle` (a fixed string). */\nconst referencedElsewhere = (opts: { root: string; needle: string; self: string }): boolean => {\n const result = git({ root: opts.root, args: ['grep', '-l', '-I', '-F', '-e', opts.needle] });\n\n return result.stdout.split('\\n').some((line) => line !== '' && line !== opts.self);\n};\n\nconst escapeForRegex = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** Files other than `self` that mention the name of the file as a path segment or an import. */\nconst nameReferencedElsewhere = (opts: { root: string; stem: string; self: string }): boolean => {\n const pattern = `[/'\"\\`]${escapeForRegex(opts.stem)}(\\\\.|'|\"|\\`|$)`;\n const result = git({ root: opts.root, args: ['grep', '-l', '-I', '-E', '-e', pattern] });\n\n return result.stdout.split('\\n').some((line) => line !== '' && line !== opts.self);\n};\n\n/** Finds support files under `__tests__` (fixtures, helpers) that no tracked file refers to, using `git grep` in the given repository. */\nexport class DeadTestCodeCheck {\n static find(opts: { root: string }): IDeadTestCodeCandidate[] {\n const tracked = git({ root: opts.root, args: ['ls-files'] }).stdout.split('\\n');\n const support = tracked.filter(\n (file) =>\n file.includes('/__tests__/') &&\n SUPPORT_EXTENSION.test(file) &&\n !TEST_FILE.test(file) &&\n !file.endsWith('.d.ts'),\n );\n const candidates: IDeadTestCodeCandidate[] = [];\n\n for (const file of support) {\n const underTests = file.slice(file.indexOf('/__tests__/') + '/__tests__/'.length);\n const stem = underTests.split('/').pop()!.replace(SUPPORT_EXTENSION, '');\n const withoutExtension = underTests.replace(SUPPORT_EXTENSION, '');\n\n if (\n nameReferencedElsewhere({ root: opts.root, stem, self: file }) ||\n referencedElsewhere({ root: opts.root, needle: withoutExtension, self: file })\n ) {\n continue;\n }\n\n const folder = dirname(underTests);\n const folderReferenced =\n folder !== '.' && referencedElsewhere({ root: opts.root, needle: folder, self: file });\n\n candidates.push({ file, kind: folderReferenced ? 'folder-referenced' : 'unreferenced' });\n }\n\n return candidates;\n }\n}\n"]}
1
+ {"version":3,"file":"test-dead-code.js","sourceRoot":"","sources":["../../src/checks/test-dead-code.ts"],"names":[],"mappings":";;;AAAA,2DAA+C;AAC/C,yCAAoC;AAIpC,sDAAsD;AACtD,MAAa,0BAA0B;aACrB,iBAAY,GAAG,cAAc,CAAC;aAC9B,sBAAiB,GAAG,mBAAmB,CAAC;;AAF1D,gEAGC;AAoBD,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;AAC7D,MAAM,SAAS,GAAG,gCAAgC,CAAC;AAEnD,MAAM,GAAG,GAAG,CAAC,IAAsC,EAAsC,EAAE;IACzF,MAAM,MAAM,GAAG,IAAA,8BAAS,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE;QACzC,GAAG,EAAE,IAAI,CAAC,IAAI;QACd,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;KAC7B,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;AACrE,CAAC,CAAC;AAEF,6EAA6E;AAC7E,MAAM,mBAAmB,GAAG,CAAC,IAAoD,EAAW,EAAE;IAC5F,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAE7F,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE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M,UAAU,GAA6B,EAAE,CAAC;QAEhD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;YAClF,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;YACzE,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;YAEnE,IACE,uBAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAC9D,mBAAmB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAC9E,CAAC;gBACD,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,UAAU,CAAC,CAAC;YACnC,MAAM,gBAAgB,GACpB,MAAM,KAAK,GAAG,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAEzF,UAAU,CAAC,IAAI,CAAC;gBACd,IAAI;gBACJ,IAAI,EAAE,gBAAgB;oBACpB,CAAC,CAAC,0BAA0B,CAAC,iBAAiB;oBAC9C,CAAC,CAAC,0BAA0B,CAAC,YAAY;aAC5C,CAAC,CAAC;QACL,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAtCD,8CAsCC","sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { dirname } from 'node:path';\n\nimport type { TConstValue } from '../linters/rules/common';\n\n/** Why a support file is a candidate for deletion. */\nexport class DeadTestCodeCandidateTypes {\n static readonly UNREFERENCED = 'unreferenced';\n static readonly FOLDER_REFERENCED = 'folder-referenced';\n}\n\n/** One of `DeadTestCodeCandidateTypes`. */\nexport type TDeadTestCodeCandidateType = TConstValue<typeof DeadTestCodeCandidateTypes>;\n\n/**\n * Support files of the tests (fixtures, helpers, probes) that no other file refers to. The second\n * step of the trim-tests method. The output is CANDIDATES: a fixture can be loaded by a path built at\n * run time or by scanning a folder, so a candidate is deleted only after the package suite is green\n * without it.\n */\nexport interface IDeadTestCodeCandidate {\n file: string;\n /**\n * `unreferenced`: neither its name nor its path under `__tests__` appears in another file, nor does\n * its folder. `folder-referenced`: only its folder path does, so a scan of that folder may load it.\n */\n type: TDeadTestCodeCandidateType;\n}\n\nconst SUPPORT_EXTENSION = /\\.(?:[cm]?[jt]sx?|json|sql|txt)$/;\nconst TEST_FILE = /\\.(?:test|spec)\\.[cm]?[jt]sx?$/;\n\nconst git = (opts: { root: string; args: string[] }): { status: number; stdout: string } => {\n const result = spawnSync('git', opts.args, {\n cwd: opts.root,\n encoding: 'utf8',\n maxBuffer: 256 * 1024 * 1024,\n });\n\n return { status: result.status ?? 1, stdout: result.stdout ?? '' };\n};\n\n/** Files other than `self` whose text contains `needle` (a fixed string). */\nconst referencedElsewhere = (opts: { root: string; needle: string; self: string }): boolean => {\n const result = git({ root: opts.root, args: ['grep', '-l', '-I', '-F', '-e', opts.needle] });\n\n return result.stdout.split('\\n').some((line) => line !== '' && line !== opts.self);\n};\n\nconst escapeForRegex = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** Files other than `self` that mention the name of the file as a path segment or an import. */\nconst nameReferencedElsewhere = (opts: { root: string; stem: string; self: string }): boolean => {\n const pattern = `[/'\"\\`]${escapeForRegex(opts.stem)}(\\\\.|'|\"|\\`|$)`;\n const result = git({ root: opts.root, args: ['grep', '-l', '-I', '-E', '-e', pattern] });\n\n return result.stdout.split('\\n').some((line) => line !== '' && line !== opts.self);\n};\n\n/** Finds support files under `__tests__` (fixtures, helpers) that no tracked file refers to, using `git grep` in the given repository. */\nexport class DeadTestCodeCheck {\n static find(opts: { root: string }): IDeadTestCodeCandidate[] {\n const tracked = git({ root: opts.root, args: ['ls-files'] }).stdout.split('\\n');\n const support = tracked.filter(\n (file) =>\n file.includes('/__tests__/') &&\n SUPPORT_EXTENSION.test(file) &&\n !TEST_FILE.test(file) &&\n !file.endsWith('.d.ts'),\n );\n const candidates: IDeadTestCodeCandidate[] = [];\n\n for (const file of support) {\n const underTests = file.slice(file.indexOf('/__tests__/') + '/__tests__/'.length);\n const stem = underTests.split('/').pop()!.replace(SUPPORT_EXTENSION, '');\n const withoutExtension = underTests.replace(SUPPORT_EXTENSION, '');\n\n if (\n nameReferencedElsewhere({ root: opts.root, stem, self: file }) ||\n referencedElsewhere({ root: opts.root, needle: withoutExtension, self: file })\n ) {\n continue;\n }\n\n const folder = dirname(underTests);\n const folderReferenced =\n folder !== '.' && referencedElsewhere({ root: opts.root, needle: folder, self: file });\n\n candidates.push({\n file,\n type: folderReferenced\n ? DeadTestCodeCandidateTypes.FOLDER_REFERENCED\n : DeadTestCodeCandidateTypes.UNREFERENCED,\n });\n }\n\n return candidates;\n }\n}\n"]}
@@ -1,3 +1,11 @@
1
+ import type { TConstValue } from '../linters/rules/common';
2
+ /** What a ledger line expects of the candidate test under the mutant. */
3
+ export declare class CandidateExpectations {
4
+ static readonly RED = "red";
5
+ static readonly VACUOUS = "vacuous";
6
+ }
7
+ /** One of `CandidateExpectations`. */
8
+ export type TCandidateExpectation = TConstValue<typeof CandidateExpectations>;
1
9
  /**
2
10
  * Replays the mutation proof of the trim-tests method. A ledger line says: "this test (the
3
11
  * candidate) is redundant because that test (the survivor) already catches the same break". The
@@ -42,7 +50,7 @@ export interface ILedgerLine {
42
50
  *
43
51
  * @default 'red'
44
52
  */
45
- expectCandidate?: 'red' | 'vacuous';
53
+ expectCandidate?: TCandidateExpectation;
46
54
  secondMutant?: IMutant | IMutant[];
47
55
  }
48
56
  /** The mutation ledger: every line to replay. */
@@ -1,12 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestMutateCheck = void 0;
3
+ exports.TestMutateCheck = exports.CandidateExpectations = void 0;
4
4
  const node_child_process_1 = require("node:child_process");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const node_path_1 = require("node:path");
7
+ /** What a ledger line expects of the candidate test under the mutant. */
8
+ class CandidateExpectations {
9
+ static { this.RED = 'red'; }
10
+ static { this.VACUOUS = 'vacuous'; }
11
+ }
12
+ exports.CandidateExpectations = CandidateExpectations;
7
13
  const TEST_TIMEOUT_MILLISECONDS = 300_000;
8
14
  /** The one place this tool builds an `Error`: `getError` would make dev-configs depend on inversion, which depends on dev-configs. */
9
- // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle
15
+ // eslint-disable-next-line @venizia/no-new-error -- getError would be a dev-configs -> inversion cycle
10
16
  const replayError = (message) => new Error(message);
11
17
  /** The nearest folder at or above the test file that holds a `package.json`: where `bun test` runs. */
12
18
  const packageDirectoryOf = (opts) => {
@@ -26,7 +32,7 @@ const packageDirectoryOf = (opts) => {
26
32
  const runIsRed = (opts) => {
27
33
  const directory = packageDirectoryOf({ root: opts.root, file: opts.file });
28
34
  const target = (0, node_path_1.join)(opts.root, opts.file).slice(directory.length + 1);
29
- const args = ['test', target, ...(opts.name ? ['-t', opts.name] : [])];
35
+ const args = ['test', target, '--max-concurrency=6', ...(opts.name ? ['-t', opts.name] : [])];
30
36
  const result = (0, node_child_process_1.spawnSync)('bun', args, {
31
37
  cwd: directory,
32
38
  encoding: 'utf8',
@@ -114,18 +120,18 @@ class TestMutateCheck {
114
120
  }),
115
121
  });
116
122
  const result = { id: line.id, survivorRed, candidateRed, ok: true };
117
- const expectation = line.expectCandidate ?? 'red';
123
+ const expectation = line.expectCandidate ?? CandidateExpectations.RED;
118
124
  if (!survivorRed) {
119
125
  result.ok = false;
120
126
  result.problem =
121
127
  'the survivor stayed green under the mutant: it does not cover the behaviour';
122
128
  }
123
- else if (expectation === 'red' && !candidateRed) {
129
+ else if (expectation === CandidateExpectations.RED && !candidateRed) {
124
130
  result.ok = false;
125
131
  result.problem =
126
132
  'the candidate stayed green under the mutant: record it as vacuous with a second mutant, or pick a mutant it checks';
127
133
  }
128
- else if (expectation === 'vacuous') {
134
+ else if (expectation === CandidateExpectations.VACUOUS) {
129
135
  if (!line.secondMutant) {
130
136
  result.ok = false;
131
137
  result.problem = 'a vacuous line needs a secondMutant';
@@ -1 +1 @@
1
- {"version":3,"file":"test-mutate.js","sourceRoot":"","sources":["../../src/checks/test-mutate.ts"],"names":[],"mappings":";;;AAAA,2DAA+C;AAC/C,qCAAqF;AACrF,yCAAmD;AAmEnD,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAE1C,sIAAsI;AACtI,sGAAsG;AACtG,MAAM,WAAW,GAAG,CAAC,OAAe,EAAS,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnE,uGAAuG;AACvG,MAAM,kBAAkB,GAAG,CAAC,IAAoC,EAAU,EAAE;IAC1E,IAAI,OAAO,GAAG,IAAA,mBAAO,EAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAElD,SAAS,CAAC;QACR,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;YAC9C,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,OAAO,CAAC,CAAC;QAEhC,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QAED,OA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,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,qBAAqB,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CACvH,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAzED,0CAyEC","sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\n/**\n * Replays the mutation proof of the trim-tests method. A ledger line says: \"this test (the\n * candidate) is redundant because that test (the survivor) already catches the same break\". The\n * replay applies the break (the mutant) to a file, runs the survivor and the candidate, and puts the\n * file back. The survivor must go red. The candidate must go red too, unless the line says it is\n * vacuous and a second mutant leaves it green as well.\n *\n * The mutant edits the file the test really loads: the package's own `src` for a test that imports\n * through the `@/` alias, or the `dist` of the dependency for a test that reaches another package\n * through its `exports`. A rebuild is never needed.\n */\nexport interface IMutant {\n /** Repository-relative file to edit (a `src` file, or a `dist` file of a dependency). */\n file: string;\n /** Text that must occur exactly once in the file. */\n find: string;\n replace: string;\n}\n\n/** One ledger line: a candidate test that the survivor test makes redundant, or one that proves nothing (`vacuous`). */\nexport interface ILedgerLine {\n id: string;\n /** Repository-relative test file that is deleted. */\n candidate: string;\n /**\n * Run only the cases whose name matches (`bun test -t`).\n *\n * @default the whole file\n */\n candidateName?: string;\n /** Repository-relative test file that stays. */\n survivor: string;\n survivorName?: string;\n /**\n * The break. An array applies every edit together: a survivor in the package that owns the code\n * loads its `src`, a candidate in another package loads that package's `dist`, so one break is two edits.\n */\n mutant: IMutant | IMutant[];\n /** The source line the mutant stands for, `path:line`; recorded, not used by the replay. */\n srcLine?: string;\n /**\n * `red`: the candidate must fail. `vacuous`: it must stay green under `mutant` AND `secondMutant`.\n *\n * @default 'red'\n */\n expectCandidate?: 'red' | 'vacuous';\n secondMutant?: IMutant | IMutant[];\n}\n\n/** The mutation ledger: every line to replay. */\nexport interface ILedger {\n mutants: ILedgerLine[];\n}\n\n/** Result of replaying one ledger line; `ok` is false when the claim does not hold, with the reason in `problem`. */\nexport interface ILedgerResult {\n id: string;\n survivorRed: boolean;\n candidateRed: boolean;\n /** Only for a `vacuous` line: whether the candidate also stayed green under the second mutant. */\n candidateGreenUnderSecond?: boolean;\n ok: boolean;\n problem?: string;\n}\n\nconst TEST_TIMEOUT_MILLISECONDS = 300_000;\n\n/** The one place this tool builds an `Error`: `getError` would make dev-configs depend on inversion, which depends on dev-configs. */\n// eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\nconst replayError = (message: string): Error => new Error(message);\n\n/** The nearest folder at or above the test file that holds a `package.json`: where `bun test` runs. */\nconst packageDirectoryOf = (opts: { root: string; file: string }): string => {\n let current = dirname(join(opts.root, opts.file));\n\n for (;;) {\n if (existsSync(join(current, 'package.json'))) {\n return current;\n }\n\n const parent = dirname(current);\n\n if (parent === current || parent.length < opts.root.length) {\n return opts.root;\n }\n\n current = parent;\n }\n};\n\n/** Runs one test file (or the cases matching `name`) and reports whether it failed. */\nconst runIsRed = (opts: { root: string; file: string; name?: string }): boolean => {\n const directory = packageDirectoryOf({ root: opts.root, file: opts.file });\n const target = join(opts.root, opts.file).slice(directory.length + 1);\n const args = ['test', target, ...(opts.name ? ['-t', opts.name] : [])];\n const result = spawnSync('bun', args, {\n cwd: directory,\n encoding: 'utf8',\n timeout: TEST_TIMEOUT_MILLISECONDS,\n killSignal: 'SIGKILL',\n env: { ...process.env, NODE_ENV: 'test' },\n });\n\n if (result.error) {\n throw replayError(`[test-mutate] could not run bun test ${target}: ${result.error.message}`);\n }\n\n // A name filter that matches nothing runs no case and exits 0: that would read as \"green\" and could\n // hide a typo as a vacuous test, so a run that executed nothing is an unusable ledger line.\n const output = `${result.stdout ?? ''}${result.stderr ?? ''}`;\n const passed = Number(/^\\s*(\\d+) pass/m.exec(output)?.[1] ?? 0);\n const failed = Number(/^\\s*(\\d+) fail/m.exec(output)?.[1] ?? 0);\n\n if (passed + failed === 0) {\n throw replayError(\n `[test-mutate] bun test ${target}${opts.name ? ` -t ${opts.name}` : ''} ran no case | check the file and the name`,\n );\n }\n\n return result.status !== 0 || failed > 0;\n};\n\n/** Applies `mutant`, runs `action`, and puts the file back byte for byte, verified byte for byte. */\nconst withMutant = <T>(opts: {\n root: string;\n mutant: IMutant;\n scratch: string;\n id: string;\n action: () => T;\n}): T => {\n const path = join(opts.root, opts.mutant.file);\n const original = readFileSync(path);\n const text = original.toString('utf8');\n const occurrences = text.split(opts.mutant.find).length - 1;\n\n if (occurrences !== 1) {\n throw replayError(\n `[test-mutate][${opts.id}] \\`find\\` occurs ${occurrences} times in ${opts.mutant.file}, it must occur exactly once`,\n );\n }\n\n mkdirSync(opts.scratch, { recursive: true });\n const backup = join(opts.scratch, `test-mutate-${opts.id.replace(/[^\\w.-]/g, '_')}.orig`);\n\n if (existsSync(backup)) {\n throw replayError(\n `[test-mutate][${opts.id}] a backup from an interrupted run exists: ${backup} | restore ${opts.mutant.file} from it, then delete it`,\n );\n }\n\n writeFileSync(backup, original);\n\n let outcome: { value: T } | { error: unknown };\n\n try {\n writeFileSync(\n path,\n text.replace(opts.mutant.find, () => opts.mutant.replace),\n );\n outcome = { value: opts.action() };\n } catch (error) {\n outcome = { error };\n }\n\n // Restored whatever the action did, and checked, before its result or error is passed on.\n writeFileSync(path, original);\n\n if (!readFileSync(path).equals(original)) {\n throw replayError(\n `[test-mutate][${opts.id}] ${opts.mutant.file} was not restored | the backup is ${backup}`,\n );\n }\n\n rmSync(backup, { force: true });\n\n if ('error' in outcome) {\n throw outcome.error;\n }\n\n return outcome.value;\n};\n\n/** Applies every edit of `mutant`, runs `action`, and puts each file back byte for byte, verified byte for byte. */\nconst withMutants = <T>(opts: {\n root: string;\n mutant: IMutant | IMutant[];\n scratch: string;\n id: string;\n action: () => T;\n}): T => {\n const edits = Array.isArray(opts.mutant) ? opts.mutant : [opts.mutant];\n\n const apply = (index: number): T =>\n index === edits.length\n ? opts.action()\n : withMutant({\n root: opts.root,\n mutant: edits[index],\n scratch: opts.scratch,\n id: `${opts.id}-${index}`,\n action: () => apply(index + 1),\n });\n\n return apply(0);\n};\n\n/** Replays the mutation ledger of the trim-tests method: applies each break, runs the survivor and candidate tests, and restores the file. */\nexport class TestMutateCheck {\n /** Replays every line; never throws for a green survivor (that is a result), only for an unusable ledger. */\n static replayLedger(opts: { root: string; ledger: ILedger; scratch?: string }): ILedgerResult[] {\n const root = resolve(opts.root);\n const scratch = opts.scratch ?? join(root, '.agents/local/tmp');\n const results: ILedgerResult[] = [];\n\n for (const line of opts.ledger.mutants) {\n const { survivorRed, candidateRed } = withMutants({\n root,\n mutant: line.mutant,\n scratch,\n id: line.id,\n action: () => ({\n survivorRed: runIsRed({ root, file: line.survivor, name: line.survivorName }),\n candidateRed: runIsRed({ root, file: line.candidate, name: line.candidateName }),\n }),\n });\n const result: ILedgerResult = { id: line.id, survivorRed, candidateRed, ok: true };\n const expectation = line.expectCandidate ?? 'red';\n\n if (!survivorRed) {\n result.ok = false;\n result.problem =\n 'the survivor stayed green under the mutant: it does not cover the behaviour';\n } else if (expectation === 'red' && !candidateRed) {\n result.ok = false;\n result.problem =\n 'the candidate stayed green under the mutant: record it as vacuous with a second mutant, or pick a mutant it checks';\n } else if (expectation === 'vacuous') {\n if (!line.secondMutant) {\n result.ok = false;\n result.problem = 'a vacuous line needs a secondMutant';\n } else if (candidateRed) {\n result.ok = false;\n result.problem = 'the candidate went red under the mutant: it is not vacuous';\n } else {\n const greenUnderSecond = !withMutants({\n root,\n mutant: line.secondMutant,\n scratch,\n id: `${line.id}-second`,\n action: () => runIsRed({ root, file: line.candidate, name: line.candidateName }),\n });\n result.candidateGreenUnderSecond = greenUnderSecond;\n\n if (!greenUnderSecond) {\n result.ok = false;\n result.problem = 'the candidate went red under the second mutant: it is not vacuous';\n }\n }\n }\n\n results.push(result);\n }\n\n return results;\n }\n\n /** The report lines of a replay, one per ledger line and a closing tally. */\n static formatLedgerResults(opts: { results: ILedgerResult[] }): string[] {\n const { results } = opts;\n const lines = results.map(\n (result) =>\n `${result.ok ? 'ok ' : 'FAIL'} ${result.id}: survivor ${result.survivorRed ? 'red' : 'GREEN'}, candidate ${result.candidateRed ? 'red' : 'green'}${result.problem ? ` | ${result.problem}` : ''}`,\n );\n const failed = results.filter((result) => !result.ok).length;\n lines.push(\n `\\n[test-mutate] ${results.length - failed}/${results.length} ledger lines hold${failed ? `, ${failed} do not` : ''}.`,\n );\n\n return lines;\n }\n}\n"]}
1
+ {"version":3,"file":"test-mutate.js","sourceRoot":"","sources":["../../src/checks/test-mutate.ts"],"names":[],"mappings":";;;AAAA,2DAA+C;AAC/C,qCAAqF;AACrF,yCAAmD;AAInD,yEAAyE;AACzE,MAAa,qBAAqB;aAChB,QAAG,GAAG,KAAK,CAAC;aACZ,YAAO,GAAG,SAAS,CAAC;;AAFtC,sDAGC;AAsED,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAE1C,sIAAsI;AACtI,uGAAuG;AACvG,MAAM,WAAW,GAAG,CAAC,OAAe,EAAS,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnE,uGAAuG;AACvG,MAAM,kBAAkB,GAAG,CAAC,IAAoC,EAAU,EAAE;IAC1E,IAAI,OAAO,GAAG,IAAA,mBAAO,EAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAElD,SAAS,CAAC;QACR,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;YAC9C,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,OAAO,CAAC,CAAC;QAEhC,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3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M,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;QAC7D,KAAK,CAAC,IAAI,CACR,mBAAmB,OAAO,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,qBAAqB,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CACvH,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAzED,0CAyEC","sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\nimport type { TConstValue } from '../linters/rules/common';\n\n/** What a ledger line expects of the candidate test under the mutant. */\nexport class CandidateExpectations {\n static readonly RED = 'red';\n static readonly VACUOUS = 'vacuous';\n}\n\n/** One of `CandidateExpectations`. */\nexport type TCandidateExpectation = TConstValue<typeof CandidateExpectations>;\n\n/**\n * Replays the mutation proof of the trim-tests method. A ledger line says: \"this test (the\n * candidate) is redundant because that test (the survivor) already catches the same break\". The\n * replay applies the break (the mutant) to a file, runs the survivor and the candidate, and puts the\n * file back. The survivor must go red. The candidate must go red too, unless the line says it is\n * vacuous and a second mutant leaves it green as well.\n *\n * The mutant edits the file the test really loads: the package's own `src` for a test that imports\n * through the `@/` alias, or the `dist` of the dependency for a test that reaches another package\n * through its `exports`. A rebuild is never needed.\n */\nexport interface IMutant {\n /** Repository-relative file to edit (a `src` file, or a `dist` file of a dependency). */\n file: string;\n /** Text that must occur exactly once in the file. */\n find: string;\n replace: string;\n}\n\n/** One ledger line: a candidate test that the survivor test makes redundant, or one that proves nothing (`vacuous`). */\nexport interface ILedgerLine {\n id: string;\n /** Repository-relative test file that is deleted. */\n candidate: string;\n /**\n * Run only the cases whose name matches (`bun test -t`).\n *\n * @default the whole file\n */\n candidateName?: string;\n /** Repository-relative test file that stays. */\n survivor: string;\n survivorName?: string;\n /**\n * The break. An array applies every edit together: a survivor in the package that owns the code\n * loads its `src`, a candidate in another package loads that package's `dist`, so one break is two edits.\n */\n mutant: IMutant | IMutant[];\n /** The source line the mutant stands for, `path:line`; recorded, not used by the replay. */\n srcLine?: string;\n /**\n * `red`: the candidate must fail. `vacuous`: it must stay green under `mutant` AND `secondMutant`.\n *\n * @default 'red'\n */\n expectCandidate?: TCandidateExpectation;\n secondMutant?: IMutant | IMutant[];\n}\n\n/** The mutation ledger: every line to replay. */\nexport interface ILedger {\n mutants: ILedgerLine[];\n}\n\n/** Result of replaying one ledger line; `ok` is false when the claim does not hold, with the reason in `problem`. */\nexport interface ILedgerResult {\n id: string;\n survivorRed: boolean;\n candidateRed: boolean;\n /** Only for a `vacuous` line: whether the candidate also stayed green under the second mutant. */\n candidateGreenUnderSecond?: boolean;\n ok: boolean;\n problem?: string;\n}\n\nconst TEST_TIMEOUT_MILLISECONDS = 300_000;\n\n/** The one place this tool builds an `Error`: `getError` would make dev-configs depend on inversion, which depends on dev-configs. */\n// eslint-disable-next-line @venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\nconst replayError = (message: string): Error => new Error(message);\n\n/** The nearest folder at or above the test file that holds a `package.json`: where `bun test` runs. */\nconst packageDirectoryOf = (opts: { root: string; file: string }): string => {\n let current = dirname(join(opts.root, opts.file));\n\n for (;;) {\n if (existsSync(join(current, 'package.json'))) {\n return current;\n }\n\n const parent = dirname(current);\n\n if (parent === current || parent.length < opts.root.length) {\n return opts.root;\n }\n\n current = parent;\n }\n};\n\n/** Runs one test file (or the cases matching `name`) and reports whether it failed. */\nconst runIsRed = (opts: { root: string; file: string; name?: string }): boolean => {\n const directory = packageDirectoryOf({ root: opts.root, file: opts.file });\n const target = join(opts.root, opts.file).slice(directory.length + 1);\n const args = ['test', target, '--max-concurrency=6', ...(opts.name ? ['-t', opts.name] : [])];\n const result = spawnSync('bun', args, {\n cwd: directory,\n encoding: 'utf8',\n timeout: TEST_TIMEOUT_MILLISECONDS,\n killSignal: 'SIGKILL',\n env: { ...process.env, NODE_ENV: 'test' },\n });\n\n if (result.error) {\n throw replayError(`[test-mutate] could not run bun test ${target}: ${result.error.message}`);\n }\n\n // A name filter that matches nothing runs no case and exits 0: that would read as \"green\" and could\n // hide a typo as a vacuous test, so a run that executed nothing is an unusable ledger line.\n const output = `${result.stdout ?? ''}${result.stderr ?? ''}`;\n const passed = Number(/^\\s*(\\d+) pass/m.exec(output)?.[1] ?? 0);\n const failed = Number(/^\\s*(\\d+) fail/m.exec(output)?.[1] ?? 0);\n\n if (passed + failed === 0) {\n throw replayError(\n `[test-mutate] bun test ${target}${opts.name ? ` -t ${opts.name}` : ''} ran no case | check the file and the name`,\n );\n }\n\n return result.status !== 0 || failed > 0;\n};\n\n/** Applies `mutant`, runs `action`, and puts the file back byte for byte, verified byte for byte. */\nconst withMutant = <T>(opts: {\n root: string;\n mutant: IMutant;\n scratch: string;\n id: string;\n action: () => T;\n}): T => {\n const path = join(opts.root, opts.mutant.file);\n const original = readFileSync(path);\n const text = original.toString('utf8');\n const occurrences = text.split(opts.mutant.find).length - 1;\n\n if (occurrences !== 1) {\n throw replayError(\n `[test-mutate][${opts.id}] \\`find\\` occurs ${occurrences} times in ${opts.mutant.file}, it must occur exactly once`,\n );\n }\n\n mkdirSync(opts.scratch, { recursive: true });\n const backup = join(opts.scratch, `test-mutate-${opts.id.replace(/[^\\w.-]/g, '_')}.orig`);\n\n if (existsSync(backup)) {\n throw replayError(\n `[test-mutate][${opts.id}] a backup from an interrupted run exists: ${backup} | restore ${opts.mutant.file} from it, then delete it`,\n );\n }\n\n writeFileSync(backup, original);\n\n let outcome: { value: T } | { error: unknown };\n\n try {\n writeFileSync(\n path,\n text.replace(opts.mutant.find, () => opts.mutant.replace),\n );\n outcome = { value: opts.action() };\n } catch (error) {\n outcome = { error };\n }\n\n // Restored whatever the action did, and checked, before its result or error is passed on.\n writeFileSync(path, original);\n\n if (!readFileSync(path).equals(original)) {\n throw replayError(\n `[test-mutate][${opts.id}] ${opts.mutant.file} was not restored | the backup is ${backup}`,\n );\n }\n\n rmSync(backup, { force: true });\n\n if ('error' in outcome) {\n throw outcome.error;\n }\n\n return outcome.value;\n};\n\n/** Applies every edit of `mutant`, runs `action`, and puts each file back byte for byte, verified byte for byte. */\nconst withMutants = <T>(opts: {\n root: string;\n mutant: IMutant | IMutant[];\n scratch: string;\n id: string;\n action: () => T;\n}): T => {\n const edits = Array.isArray(opts.mutant) ? opts.mutant : [opts.mutant];\n\n const apply = (index: number): T =>\n index === edits.length\n ? opts.action()\n : withMutant({\n root: opts.root,\n mutant: edits[index],\n scratch: opts.scratch,\n id: `${opts.id}-${index}`,\n action: () => apply(index + 1),\n });\n\n return apply(0);\n};\n\n/** Replays the mutation ledger of the trim-tests method: applies each break, runs the survivor and candidate tests, and restores the file. */\nexport class TestMutateCheck {\n /** Replays every line; never throws for a green survivor (that is a result), only for an unusable ledger. */\n static replayLedger(opts: { root: string; ledger: ILedger; scratch?: string }): ILedgerResult[] {\n const root = resolve(opts.root);\n const scratch = opts.scratch ?? join(root, '.agents/local/tmp');\n const results: ILedgerResult[] = [];\n\n for (const line of opts.ledger.mutants) {\n const { survivorRed, candidateRed } = withMutants({\n root,\n mutant: line.mutant,\n scratch,\n id: line.id,\n action: () => ({\n survivorRed: runIsRed({ root, file: line.survivor, name: line.survivorName }),\n candidateRed: runIsRed({ root, file: line.candidate, name: line.candidateName }),\n }),\n });\n const result: ILedgerResult = { id: line.id, survivorRed, candidateRed, ok: true };\n const expectation = line.expectCandidate ?? CandidateExpectations.RED;\n\n if (!survivorRed) {\n result.ok = false;\n result.problem =\n 'the survivor stayed green under the mutant: it does not cover the behaviour';\n } else if (expectation === CandidateExpectations.RED && !candidateRed) {\n result.ok = false;\n result.problem =\n 'the candidate stayed green under the mutant: record it as vacuous with a second mutant, or pick a mutant it checks';\n } else if (expectation === CandidateExpectations.VACUOUS) {\n if (!line.secondMutant) {\n result.ok = false;\n result.problem = 'a vacuous line needs a secondMutant';\n } else if (candidateRed) {\n result.ok = false;\n result.problem = 'the candidate went red under the mutant: it is not vacuous';\n } else {\n const greenUnderSecond = !withMutants({\n root,\n mutant: line.secondMutant,\n scratch,\n id: `${line.id}-second`,\n action: () => runIsRed({ root, file: line.candidate, name: line.candidateName }),\n });\n result.candidateGreenUnderSecond = greenUnderSecond;\n\n if (!greenUnderSecond) {\n result.ok = false;\n result.problem = 'the candidate went red under the second mutant: it is not vacuous';\n }\n }\n }\n\n results.push(result);\n }\n\n return results;\n }\n\n /** The report lines of a replay, one per ledger line and a closing tally. */\n static formatLedgerResults(opts: { results: ILedgerResult[] }): string[] {\n const { results } = opts;\n const lines = results.map(\n (result) =>\n `${result.ok ? 'ok ' : 'FAIL'} ${result.id}: survivor ${result.survivorRed ? 'red' : 'GREEN'}, candidate ${result.candidateRed ? 'red' : 'green'}${result.problem ? ` | ${result.problem}` : ''}`,\n );\n const failed = results.filter((result) => !result.ok).length;\n lines.push(\n `\\n[test-mutate] ${results.length - failed}/${results.length} ledger lines hold${failed ? `, ${failed} do not` : ''}.`,\n );\n\n return lines;\n }\n}\n"]}
package/dist/cli/check.js CHANGED
@@ -11,6 +11,7 @@ const test_controls_1 = require("../checks/test-controls");
11
11
  const test_dead_code_1 = require("../checks/test-dead-code");
12
12
  const test_mutate_1 = require("../checks/test-mutate");
13
13
  const test_weight_1 = require("../checks/test-weight");
14
+ const cli_output_1 = require("../common/cli-output");
14
15
  const USAGE = `Usage: devz check <name> [options]
15
16
 
16
17
  Checks:
@@ -32,7 +33,7 @@ purity
32
33
 
33
34
  test-weight, test-dead-code, test-mutate, test-controls: the tools of the trim-tests method, see
34
35
  .agents/knowledge/process/trimming-tests.md in the IGNIS repository. Produce the JUnit files with
35
- bun test ./src --parallel --reporter=junit --reporter-outfile=<file>.
36
+ bun test ./src --parallel=6 --max-concurrency=6 --reporter=junit --reporter-outfile=<file>.
36
37
 
37
38
  module-cycles
38
39
  <dir>, or --dist <dir> the built folder (dist/esm); exits 1 when more cycles than --max, 2 on a usage error
@@ -105,7 +106,7 @@ class CheckCommand {
105
106
  static runTestWeight(opts) {
106
107
  const parsed = parseRepeatable({ args: opts.args, repeatable: [], single: ['top'] });
107
108
  if (typeof parsed === 'string' || parsed.positionals.length === 0) {
108
- console.error(`devz check test-weight: ${typeof parsed === 'string' ? parsed : 'give at least one JUnit file'}\n${USAGE}`);
109
+ cli_output_1.CliOutput.error(`devz check test-weight: ${typeof parsed === 'string' ? parsed : 'give at least one JUnit file'}\n${USAGE}`);
109
110
  return USAGE_ERROR_CODE;
110
111
  }
111
112
  const reports = parsed.positionals.map((file) => {
@@ -117,7 +118,7 @@ class CheckCommand {
117
118
  });
118
119
  const missing = parsed.positionals.filter((file) => !(0, node_fs_1.existsSync)((0, node_path_1.resolve)(opts.root, file)));
119
120
  if (missing.length > 0) {
120
- console.error(`devz check test-weight: not found: ${missing.join(', ')}`);
121
+ cli_output_1.CliOutput.error(`devz check test-weight: not found: ${missing.join(', ')}`);
121
122
  return USAGE_ERROR_CODE;
122
123
  }
123
124
  const top = parsed.values.top?.[0] === undefined ? undefined : Number(parsed.values.top[0]);
@@ -125,79 +126,82 @@ class CheckCommand {
125
126
  report: test_weight_1.TestWeightCheck.analyseJunit({ reports }),
126
127
  top,
127
128
  })) {
128
- console.log(line);
129
+ cli_output_1.CliOutput.log(line);
129
130
  }
130
131
  return 0;
131
132
  }
132
133
  static runTestDeadCode(opts) {
133
134
  if (opts.args.length > 0) {
134
- console.error(`devz check test-dead-code: unexpected argument "${opts.args[0]}"\n${USAGE}`);
135
+ cli_output_1.CliOutput.error(`devz check test-dead-code: unexpected argument "${opts.args[0]}"\n${USAGE}`);
135
136
  return USAGE_ERROR_CODE;
136
137
  }
137
138
  const candidates = test_dead_code_1.DeadTestCodeCheck.find({ root: opts.root });
138
- for (const kind of ['unreferenced', 'folder-referenced']) {
139
- const own = candidates.filter((candidate) => candidate.kind === kind);
140
- console.log(`${kind}: ${own.length}`);
139
+ for (const type of [
140
+ test_dead_code_1.DeadTestCodeCandidateTypes.UNREFERENCED,
141
+ test_dead_code_1.DeadTestCodeCandidateTypes.FOLDER_REFERENCED,
142
+ ]) {
143
+ const own = candidates.filter((candidate) => candidate.type === type);
144
+ cli_output_1.CliOutput.log(`${type}: ${own.length}`);
141
145
  for (const candidate of own) {
142
- console.log(` ${candidate.file}`);
146
+ cli_output_1.CliOutput.log(` ${candidate.file}`);
143
147
  }
144
148
  }
145
- console.log('\nThese are candidates: delete one, run the package suite, and keep it if anything fails or loads it by a built path.');
149
+ cli_output_1.CliOutput.log('\nThese are candidates: delete one, run the package suite, and keep it if anything fails or loads it by a built path.');
146
150
  return 0;
147
151
  }
148
152
  static runTestMutate(opts) {
149
153
  const [file, ...extra] = opts.args;
150
154
  if (file === undefined || extra.length > 0) {
151
- console.error(`devz check test-mutate: give one ledger file\n${USAGE}`);
155
+ cli_output_1.CliOutput.error(`devz check test-mutate: give one ledger file\n${USAGE}`);
152
156
  return USAGE_ERROR_CODE;
153
157
  }
154
158
  const path = (0, node_path_1.resolve)(opts.root, file);
155
159
  if (!(0, node_fs_1.existsSync)(path)) {
156
- console.error(`devz check test-mutate: ledger not found: ${file}`);
160
+ cli_output_1.CliOutput.error(`devz check test-mutate: ledger not found: ${file}`);
157
161
  return USAGE_ERROR_CODE;
158
162
  }
159
163
  const ledger = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
160
164
  if (!Array.isArray(ledger.mutants)) {
161
- console.error(`devz check test-mutate: ${file} has no "mutants" array`);
165
+ cli_output_1.CliOutput.error(`devz check test-mutate: ${file} has no "mutants" array`);
162
166
  return USAGE_ERROR_CODE;
163
167
  }
164
168
  const results = test_mutate_1.TestMutateCheck.replayLedger({ root: opts.root, ledger });
165
169
  for (const line of test_mutate_1.TestMutateCheck.formatLedgerResults({ results })) {
166
- console.log(line);
170
+ cli_output_1.CliOutput.log(line);
167
171
  }
168
172
  return results.every((result) => result.ok) ? 0 : 1;
169
173
  }
170
174
  static async runTestControls(opts) {
171
175
  const [file, ...extra] = opts.args;
172
176
  if (file === undefined || extra.length > 0) {
173
- console.error(`devz check test-controls: give one registry file\n${USAGE}`);
177
+ cli_output_1.CliOutput.error(`devz check test-controls: give one registry file\n${USAGE}`);
174
178
  return USAGE_ERROR_CODE;
175
179
  }
176
180
  const path = (0, node_path_1.resolve)(opts.root, file);
177
181
  if (!(0, node_fs_1.existsSync)(path)) {
178
- console.error(`devz check test-controls: registry not found: ${file}`);
182
+ cli_output_1.CliOutput.error(`devz check test-controls: registry not found: ${file}`);
179
183
  return USAGE_ERROR_CODE;
180
184
  }
181
185
  const registry = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
182
186
  if (!Array.isArray(registry.controls)) {
183
- console.error(`devz check test-controls: ${file} has no "controls" array`);
187
+ cli_output_1.CliOutput.error(`devz check test-controls: ${file} has no "controls" array`);
184
188
  return USAGE_ERROR_CODE;
185
189
  }
186
190
  const report = await test_controls_1.TestControlsCheck.run({ root: opts.root, controls: registry.controls });
187
191
  if (report.problems.length === 0) {
188
- console.log(`test-controls: OK - ${report.checked} registered controls found`);
192
+ cli_output_1.CliOutput.log(`test-controls: OK - ${report.checked} registered controls found`);
189
193
  return 0;
190
194
  }
191
- console.error(`test-controls: ${report.problems.length} of ${report.checked} registered controls are gone:`);
195
+ cli_output_1.CliOutput.error(`test-controls: ${report.problems.length} of ${report.checked} registered controls are gone:`);
192
196
  for (const problem of report.problems) {
193
- console.error(` [${problem.entry.gate}] ${problem.message}`);
197
+ cli_output_1.CliOutput.error(` [${problem.entry.gate}] ${problem.message}`);
194
198
  }
195
199
  return 1;
196
200
  }
197
201
  static runSplitReport(opts) {
198
202
  const parsed = parseRepeatable({ args: opts.args, repeatable: [], single: ['dist'] });
199
203
  if (typeof parsed === 'string') {
200
- console.error(`devz check split-report: ${parsed}\n${USAGE}`);
204
+ cli_output_1.CliOutput.error(`devz check split-report: ${parsed}\n${USAGE}`);
201
205
  return USAGE_ERROR_CODE;
202
206
  }
203
207
  const targets = parsed.positionals.length
@@ -215,7 +219,7 @@ class CheckCommand {
215
219
  single: ['preset-prefix'],
216
220
  });
217
221
  if (typeof parsed === 'string' || parsed.positionals.length > 0) {
218
- console.error(`devz check catalog: ${typeof parsed === 'string' ? parsed : `unexpected argument "${parsed.positionals[0]}"`}\n${USAGE}`);
222
+ cli_output_1.CliOutput.error(`devz check catalog: ${typeof parsed === 'string' ? parsed : `unexpected argument "${parsed.positionals[0]}"`}\n${USAGE}`);
219
223
  return USAGE_ERROR_CODE;
220
224
  }
221
225
  const report = await catalog_1.CatalogCheck.find({
@@ -225,16 +229,16 @@ class CheckCommand {
225
229
  presetPrefix: parsed.values['preset-prefix']?.[0],
226
230
  });
227
231
  if (report.noCatalog) {
228
- console.error('check-catalog: no `workspaces.catalog` in the root package.json');
232
+ cli_output_1.CliOutput.error('check-catalog: no `workspaces.catalog` in the root package.json');
229
233
  return 1;
230
234
  }
231
235
  if (report.problems.length === 0) {
232
- console.log(`check-catalog: OK - ${report.entries} entries, ${report.referenced} referenced`);
236
+ cli_output_1.CliOutput.log(`check-catalog: OK - ${report.entries} entries, ${report.referenced} referenced`);
233
237
  return 0;
234
238
  }
235
- console.error(`check-catalog: ${report.problems.length} problem(s):`);
239
+ cli_output_1.CliOutput.error(`check-catalog: ${report.problems.length} problem(s):`);
236
240
  for (const problem of report.problems) {
237
- console.error(` ${problem.file}: ${problem.message}`);
241
+ cli_output_1.CliOutput.error(` ${problem.file}: ${problem.message}`);
238
242
  }
239
243
  return 1;
240
244
  }
@@ -242,14 +246,14 @@ class CheckCommand {
242
246
  const { root, args = [] } = opts;
243
247
  const [name, ...rest] = args;
244
248
  if (name === undefined || name === '--help' || name === '-h') {
245
- console.log(USAGE);
249
+ cli_output_1.CliOutput.log(USAGE);
246
250
  return name === undefined ? USAGE_ERROR_CODE : 0;
247
251
  }
248
252
  if (name === 'module-cycles') {
249
253
  return module_cycles_1.ModuleCyclesCheck.run({
250
254
  args: rest,
251
- print: (line) => console.log(line),
252
- printError: (line) => console.error(line),
255
+ print: (line) => cli_output_1.CliOutput.log(line),
256
+ printError: (line) => cli_output_1.CliOutput.error(line),
253
257
  });
254
258
  }
255
259
  if (name === 'split-report') {
@@ -271,32 +275,32 @@ class CheckCommand {
271
275
  return CheckCommand.runTestControls({ root, args: rest });
272
276
  }
273
277
  if (name !== 'purity') {
274
- console.error(`devz check: unknown check "${name}"\n${USAGE}`);
278
+ cli_output_1.CliOutput.error(`devz check: unknown check "${name}"\n${USAGE}`);
275
279
  return USAGE_ERROR_CODE;
276
280
  }
277
281
  if (rest.includes('--help') || rest.includes('-h')) {
278
- console.log(USAGE);
282
+ cli_output_1.CliOutput.log(USAGE);
279
283
  return 0;
280
284
  }
281
285
  const parsed = parsePurityArguments(rest);
282
286
  if (typeof parsed === 'string') {
283
- console.error(`devz check purity: ${parsed}\n${USAGE}`);
287
+ cli_output_1.CliOutput.error(`devz check purity: ${parsed}\n${USAGE}`);
284
288
  return USAGE_ERROR_CODE;
285
289
  }
286
290
  if (parsed.claimsFile === undefined) {
287
- console.error(`devz check purity: --claims <file> is required\n${USAGE}`);
291
+ cli_output_1.CliOutput.error(`devz check purity: --claims <file> is required\n${USAGE}`);
288
292
  return USAGE_ERROR_CODE;
289
293
  }
290
294
  const claimsPath = (0, node_path_1.isAbsolute)(parsed.claimsFile)
291
295
  ? parsed.claimsFile
292
296
  : (0, node_path_1.resolve)(root, parsed.claimsFile);
293
297
  if (!(0, node_fs_1.existsSync)(claimsPath)) {
294
- console.error(`devz check purity: claims file not found: ${parsed.claimsFile}`);
298
+ cli_output_1.CliOutput.error(`devz check purity: claims file not found: ${parsed.claimsFile}`);
295
299
  return USAGE_ERROR_CODE;
296
300
  }
297
301
  const claimsModule = await import(claimsPath);
298
302
  if (!Array.isArray(claimsModule.PURITY_CLAIMS)) {
299
- console.error(`devz check purity: ${parsed.claimsFile} does not export PURITY_CLAIMS`);
303
+ cli_output_1.CliOutput.error(`devz check purity: ${parsed.claimsFile} does not export PURITY_CLAIMS`);
300
304
  return USAGE_ERROR_CODE;
301
305
  }
302
306
  const lines = [];
@@ -306,14 +310,14 @@ class CheckCommand {
306
310
  options: claimsModule.PURITY_OPTIONS,
307
311
  filter: parsed.filter,
308
312
  claimsFile: (0, node_path_1.relative)(root, claimsPath),
309
- print: (line) => (parsed.json ? lines.push(line) : console.log(line)),
310
- printError: (line) => console.error(line),
313
+ print: (line) => (parsed.json ? lines.push(line) : cli_output_1.CliOutput.log(line)),
314
+ printError: (line) => cli_output_1.CliOutput.error(line),
311
315
  });
312
316
  if (report === undefined) {
313
317
  return 1;
314
318
  }
315
319
  if (parsed.json) {
316
- console.log(JSON.stringify(report, null, 2));
320
+ cli_output_1.CliOutput.log(JSON.stringify(report, null, 2));
317
321
  }
318
322
  return report.failed > 0 ? 1 : 0;
319
323
  }
@@ -1 +1 @@
1
- {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/cli/check.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAoE;AACpE,+CAAiD;AACjD,2DAA4D;AAC5D,8CAAmD;AACnD,yDAAqD;AACrD,2DAA4D;AAE5D,6DAA6D;AAC7D,uDAAwD;AAExD,uDAAwD;AAGxD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAmC+B,CAAC;AAE9C,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAa3B,MAAM,oBAAoB,GAAG,CAAC,IAAc,EAA6B,EAAE;IACzE,MAAM,MAAM,GAAqB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAEjD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;YACnB,SAA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AC;QAE7D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/C,OAAO,CAAC,KAAK,CAAC,sBAAsB,MAAM,CAAC,UAAU,gCAAgC,CAAC,CAAC;YAEvF,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,iBAAW,CAAC,GAAG,CAAC;YACnC,IAAI;YACJ,MAAM,EAAE,YAAY,CAAC,aAAa;YAClC,OAAO,EAAE,YAAY,CAAC,cAAc;YACpC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,IAAA,oBAAQ,EAAC,IAAI,EAAE,UAAU,CAAC;YACtC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrE,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;SAC1C,CAAC,CAAC;QAEH,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;CACF;AAzTD,oCAyTC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { basename, isAbsolute, relative, resolve } from 'node:path';\nimport { CatalogCheck } from '../checks/catalog';\nimport { ModuleCyclesCheck } from '../checks/module-cycles';\nimport { PurityCheck } from '../checks/purity/run';\nimport { SplitReport } from '../checks/split-report';\nimport { TestControlsCheck } from '../checks/test-controls';\nimport type { IControlEntry } from '../checks/test-controls';\nimport { DeadTestCodeCheck } from '../checks/test-dead-code';\nimport { TestMutateCheck } from '../checks/test-mutate';\nimport type { ILedger } from '../checks/test-mutate';\nimport { TestWeightCheck } from '../checks/test-weight';\nimport type { IPurityClaim, IPurityOptions } from '../checks/purity/manifest';\n\nconst USAGE = `Usage: devz check <name> [options]\n\nChecks:\n purity [package] --claims <file> [--json] probe every entry claimed browser-pure (needs a build)\n module-cycles <dir> [--max <n>] list the import cycles of a built ESM folder\n split-report [--dist <dir>] [folder...] report hub files, stray types, missing barrels, long files, cycles (never a gate)\n catalog [--glob <pattern>]... [--pinned <file>]... [--preset-prefix <prefix>]\n guard dependency ranges against the root workspaces.catalog\n test-weight [--top <n>] <junit.xml>... per-file time, cases, assertions, duplicates and skips from bun's JUnit report\n test-dead-code list support files under __tests__ that no other file refers to (candidates)\n test-mutate <ledger.json> replay a mutation ledger: the survivor must go red under each mutant\n test-controls <registry.json> fail when a registered positive-control test is gone\n\npurity\n --claims <file> a module that exports PURITY_CLAIMS (the claims) and, optionally, PURITY_OPTIONS\n [package] probe only the rows of this package; a token that matches nothing fails\n --json print the verdict as JSON (no paths of this machine, no timing) instead of the report\n\n\ntest-weight, test-dead-code, test-mutate, test-controls: the tools of the trim-tests method, see\n .agents/knowledge/process/trimming-tests.md in the IGNIS repository. Produce the JUnit files with\n bun test ./src --parallel --reporter=junit --reporter-outfile=<file>.\n\nmodule-cycles\n <dir>, or --dist <dir> the built folder (dist/esm); exits 1 when more cycles than --max, 2 on a usage error\n\nsplit-report\n --dist <dir> the built ESM folder inside a package: dist/esm, or dist where one build is published (default dist)\n [folder...] package folders to report; none scans every packages/* and examples/* that has a src/\n\ncatalog\n --glob <pattern> a manifest glob beside packages/*/package.json (repeatable)\n --pinned <file> a manifest outside the workspace: its catalogued ranges must equal the catalog's (repeatable)\n --preset-prefix <p> files under this prefix are presets: catalog: is allowed in their peerDependencies\n\n --help print this text and exit`;\n\n/** A usage error: nothing was probed. */\nconst USAGE_ERROR_CODE = 2;\n\ninterface IClaimsModule {\n PURITY_CLAIMS?: IPurityClaim[];\n PURITY_OPTIONS?: IPurityOptions;\n}\n\ninterface IPurityArguments {\n claimsFile?: string;\n filter?: string;\n json: boolean;\n}\n\nconst parsePurityArguments = (args: string[]): IPurityArguments | string => {\n const parsed: IPurityArguments = { json: false };\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n\n if (arg === '--json') {\n parsed.json = true;\n continue;\n }\n\n if (arg === '--claims') {\n const value = args[index + 1];\n\n if (value === undefined || value.startsWith('--')) {\n return '--claims needs a file';\n }\n\n parsed.claimsFile = value;\n index += 1;\n continue;\n }\n\n if (arg.startsWith('--')) {\n return `unknown option \"${arg}\"`;\n }\n\n if (parsed.filter !== undefined) {\n return `unexpected argument \"${arg}\"`;\n }\n\n parsed.filter = arg;\n }\n\n return parsed;\n};\n\n/** Splits repeatable `--name value` options and positionals; `undefined` for an option that lacks its value. */\nconst parseRepeatable = (opts: {\n args: string[];\n repeatable: string[];\n single: string[];\n}): { positionals: string[]; values: Record<string, string[]> } | string => {\n const { args, repeatable, single } = opts;\n const values: Record<string, string[]> = {};\n const positionals: string[] = [];\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n\n if (arg.startsWith('--')) {\n const name = arg.slice(2);\n\n if (!repeatable.includes(name) && !single.includes(name)) {\n return `unknown option \"${arg}\"`;\n }\n\n const value = args[index + 1];\n\n if (value === undefined || value.startsWith('--')) {\n return `${arg} needs a value`;\n }\n\n values[name] = [...(values[name] ?? []), value];\n index += 1;\n continue;\n }\n\n positionals.push(arg);\n }\n\n return { positionals, values };\n};\n\n/** `devz check <name>`: runs one of the shared repository gates in the current folder. */\nexport class CheckCommand {\n private static runTestWeight(opts: { root: string; args: string[] }): number {\n const parsed = parseRepeatable({ args: opts.args, repeatable: [], single: ['top'] });\n\n if (typeof parsed === 'string' || parsed.positionals.length === 0) {\n console.error(\n `devz check test-weight: ${typeof parsed === 'string' ? parsed : 'give at least one JUnit file'}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const reports = parsed.positionals.map((file) => {\n const path = resolve(opts.root, file);\n\n return {\n label: basename(file).replace(/\\.xml$/, ''),\n xml: existsSync(path) ? readFileSync(path, 'utf8') : '',\n };\n });\n const missing = parsed.positionals.filter((file) => !existsSync(resolve(opts.root, file)));\n\n if (missing.length > 0) {\n console.error(`devz check test-weight: not found: ${missing.join(', ')}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const top = parsed.values.top?.[0] === undefined ? undefined : Number(parsed.values.top[0]);\n\n for (const line of TestWeightCheck.formatReport({\n report: TestWeightCheck.analyseJunit({ reports }),\n top,\n })) {\n console.log(line);\n }\n\n return 0;\n }\n\n private static runTestDeadCode(opts: { root: string; args: string[] }): number {\n if (opts.args.length > 0) {\n console.error(`devz check test-dead-code: unexpected argument \"${opts.args[0]}\"\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const candidates = DeadTestCodeCheck.find({ root: opts.root });\n\n for (const kind of ['unreferenced', 'folder-referenced'] as const) {\n const own = candidates.filter((candidate) => candidate.kind === kind);\n console.log(`${kind}: ${own.length}`);\n\n for (const candidate of own) {\n console.log(` ${candidate.file}`);\n }\n }\n\n console.log(\n '\\nThese are candidates: delete one, run the package suite, and keep it if anything fails or loads it by a built path.',\n );\n\n return 0;\n }\n\n private static runTestMutate(opts: { root: string; args: string[] }): number {\n const [file, ...extra] = opts.args;\n\n if (file === undefined || extra.length > 0) {\n console.error(`devz check test-mutate: give one ledger file\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const path = resolve(opts.root, file);\n\n if (!existsSync(path)) {\n console.error(`devz check test-mutate: ledger not found: ${file}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const ledger: ILedger = JSON.parse(readFileSync(path, 'utf8'));\n\n if (!Array.isArray(ledger.mutants)) {\n console.error(`devz check test-mutate: ${file} has no \"mutants\" array`);\n\n return USAGE_ERROR_CODE;\n }\n\n const results = TestMutateCheck.replayLedger({ root: opts.root, ledger });\n\n for (const line of TestMutateCheck.formatLedgerResults({ results })) {\n console.log(line);\n }\n\n return results.every((result) => result.ok) ? 0 : 1;\n }\n\n private static async runTestControls(opts: { root: string; args: string[] }): Promise<number> {\n const [file, ...extra] = opts.args;\n\n if (file === undefined || extra.length > 0) {\n console.error(`devz check test-controls: give one registry file\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const path = resolve(opts.root, file);\n\n if (!existsSync(path)) {\n console.error(`devz check test-controls: registry not found: ${file}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const registry: { controls?: IControlEntry[] } = JSON.parse(readFileSync(path, 'utf8'));\n\n if (!Array.isArray(registry.controls)) {\n console.error(`devz check test-controls: ${file} has no \"controls\" array`);\n\n return USAGE_ERROR_CODE;\n }\n\n const report = await TestControlsCheck.run({ root: opts.root, controls: registry.controls });\n\n if (report.problems.length === 0) {\n console.log(`test-controls: OK - ${report.checked} registered controls found`);\n\n return 0;\n }\n\n console.error(\n `test-controls: ${report.problems.length} of ${report.checked} registered controls are gone:`,\n );\n\n for (const problem of report.problems) {\n console.error(` [${problem.entry.gate}] ${problem.message}`);\n }\n\n return 1;\n }\n\n private static runSplitReport(opts: { root: string; args: string[] }): number {\n const parsed = parseRepeatable({ args: opts.args, repeatable: [], single: ['dist'] });\n\n if (typeof parsed === 'string') {\n console.error(`devz check split-report: ${parsed}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const targets = parsed.positionals.length\n ? parsed.positionals.map((target) => resolve(opts.root, target))\n : SplitReport.defaultTargets({ root: opts.root });\n\n for (const packageDir of targets) {\n SplitReport.run({ packageDir, distDir: parsed.values.dist?.[0] });\n }\n\n return 0;\n }\n\n private static async runCatalog(opts: { root: string; args: string[] }): Promise<number> {\n const parsed = parseRepeatable({\n args: opts.args,\n repeatable: ['glob', 'pinned'],\n single: ['preset-prefix'],\n });\n\n if (typeof parsed === 'string' || parsed.positionals.length > 0) {\n console.error(\n `devz check catalog: ${typeof parsed === 'string' ? parsed : `unexpected argument \"${parsed.positionals[0]}\"`}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const report = await CatalogCheck.find({\n root: opts.root,\n globs: parsed.values.glob,\n pinned: parsed.values.pinned,\n presetPrefix: parsed.values['preset-prefix']?.[0],\n });\n\n if (report.noCatalog) {\n console.error('check-catalog: no `workspaces.catalog` in the root package.json');\n\n return 1;\n }\n\n if (report.problems.length === 0) {\n console.log(`check-catalog: OK - ${report.entries} entries, ${report.referenced} referenced`);\n\n return 0;\n }\n\n console.error(`check-catalog: ${report.problems.length} problem(s):`);\n\n for (const problem of report.problems) {\n console.error(` ${problem.file}: ${problem.message}`);\n }\n\n return 1;\n }\n\n static async run(opts: { root: string; args?: string[] }): Promise<number> {\n const { root, args = [] } = opts;\n const [name, ...rest] = args;\n\n if (name === undefined || name === '--help' || name === '-h') {\n console.log(USAGE);\n\n return name === undefined ? USAGE_ERROR_CODE : 0;\n }\n\n if (name === 'module-cycles') {\n return ModuleCyclesCheck.run({\n args: rest,\n print: (line) => console.log(line),\n printError: (line) => console.error(line),\n });\n }\n\n if (name === 'split-report') {\n return CheckCommand.runSplitReport({ root, args: rest });\n }\n\n if (name === 'catalog') {\n return CheckCommand.runCatalog({ root, args: rest });\n }\n\n if (name === 'test-weight') {\n return CheckCommand.runTestWeight({ root, args: rest });\n }\n\n if (name === 'test-dead-code') {\n return CheckCommand.runTestDeadCode({ root, args: rest });\n }\n\n if (name === 'test-mutate') {\n return CheckCommand.runTestMutate({ root, args: rest });\n }\n\n if (name === 'test-controls') {\n return CheckCommand.runTestControls({ root, args: rest });\n }\n\n if (name !== 'purity') {\n console.error(`devz check: unknown check \"${name}\"\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n if (rest.includes('--help') || rest.includes('-h')) {\n console.log(USAGE);\n\n return 0;\n }\n\n const parsed = parsePurityArguments(rest);\n\n if (typeof parsed === 'string') {\n console.error(`devz check purity: ${parsed}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n if (parsed.claimsFile === undefined) {\n console.error(`devz check purity: --claims <file> is required\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const claimsPath = isAbsolute(parsed.claimsFile)\n ? parsed.claimsFile\n : resolve(root, parsed.claimsFile);\n\n if (!existsSync(claimsPath)) {\n console.error(`devz check purity: claims file not found: ${parsed.claimsFile}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const claimsModule: IClaimsModule = await import(claimsPath);\n\n if (!Array.isArray(claimsModule.PURITY_CLAIMS)) {\n console.error(`devz check purity: ${parsed.claimsFile} does not export PURITY_CLAIMS`);\n\n return USAGE_ERROR_CODE;\n }\n\n const lines: string[] = [];\n const report = await PurityCheck.run({\n root,\n claims: claimsModule.PURITY_CLAIMS,\n options: claimsModule.PURITY_OPTIONS,\n filter: parsed.filter,\n claimsFile: relative(root, claimsPath),\n print: (line) => (parsed.json ? lines.push(line) : console.log(line)),\n printError: (line) => console.error(line),\n });\n\n if (report === undefined) {\n return 1;\n }\n\n if (parsed.json) {\n console.log(JSON.stringify(report, null, 2));\n }\n\n return report.failed > 0 ? 1 : 0;\n }\n}\n"]}
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/cli/check.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAoE;AACpE,+CAAiD;AACjD,2DAA4D;AAC5D,8CAAmD;AACnD,yDAAqD;AACrD,2DAA4D;AAE5D,6DAAyF;AACzF,uDAAwD;AAExD,uDAAwD;AAExD,qDAAiD;AAEjD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAmC+B,CAAC;AAE9C,yCAAyC;AACzC,MA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C;QAEH,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,sBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;CACF;AA9TD,oCA8TC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { basename, isAbsolute, relative, resolve } from 'node:path';\nimport { CatalogCheck } from '../checks/catalog';\nimport { ModuleCyclesCheck } from '../checks/module-cycles';\nimport { PurityCheck } from '../checks/purity/run';\nimport { SplitReport } from '../checks/split-report';\nimport { TestControlsCheck } from '../checks/test-controls';\nimport type { IControlEntry } from '../checks/test-controls';\nimport { DeadTestCodeCandidateTypes, DeadTestCodeCheck } from '../checks/test-dead-code';\nimport { TestMutateCheck } from '../checks/test-mutate';\nimport type { ILedger } from '../checks/test-mutate';\nimport { TestWeightCheck } from '../checks/test-weight';\nimport type { IPurityClaim, IPurityOptions } from '../checks/purity/manifest';\nimport { CliOutput } from '../common/cli-output';\n\nconst USAGE = `Usage: devz check <name> [options]\n\nChecks:\n purity [package] --claims <file> [--json] probe every entry claimed browser-pure (needs a build)\n module-cycles <dir> [--max <n>] list the import cycles of a built ESM folder\n split-report [--dist <dir>] [folder...] report hub files, stray types, missing barrels, long files, cycles (never a gate)\n catalog [--glob <pattern>]... [--pinned <file>]... [--preset-prefix <prefix>]\n guard dependency ranges against the root workspaces.catalog\n test-weight [--top <n>] <junit.xml>... per-file time, cases, assertions, duplicates and skips from bun's JUnit report\n test-dead-code list support files under __tests__ that no other file refers to (candidates)\n test-mutate <ledger.json> replay a mutation ledger: the survivor must go red under each mutant\n test-controls <registry.json> fail when a registered positive-control test is gone\n\npurity\n --claims <file> a module that exports PURITY_CLAIMS (the claims) and, optionally, PURITY_OPTIONS\n [package] probe only the rows of this package; a token that matches nothing fails\n --json print the verdict as JSON (no paths of this machine, no timing) instead of the report\n\n\ntest-weight, test-dead-code, test-mutate, test-controls: the tools of the trim-tests method, see\n .agents/knowledge/process/trimming-tests.md in the IGNIS repository. Produce the JUnit files with\n bun test ./src --parallel=6 --max-concurrency=6 --reporter=junit --reporter-outfile=<file>.\n\nmodule-cycles\n <dir>, or --dist <dir> the built folder (dist/esm); exits 1 when more cycles than --max, 2 on a usage error\n\nsplit-report\n --dist <dir> the built ESM folder inside a package: dist/esm, or dist where one build is published (default dist)\n [folder...] package folders to report; none scans every packages/* and examples/* that has a src/\n\ncatalog\n --glob <pattern> a manifest glob beside packages/*/package.json (repeatable)\n --pinned <file> a manifest outside the workspace: its catalogued ranges must equal the catalog's (repeatable)\n --preset-prefix <p> files under this prefix are presets: catalog: is allowed in their peerDependencies\n\n --help print this text and exit`;\n\n/** A usage error: nothing was probed. */\nconst USAGE_ERROR_CODE = 2;\n\ninterface IClaimsModule {\n PURITY_CLAIMS?: IPurityClaim[];\n PURITY_OPTIONS?: IPurityOptions;\n}\n\ninterface IPurityArguments {\n claimsFile?: string;\n filter?: string;\n json: boolean;\n}\n\nconst parsePurityArguments = (args: string[]): IPurityArguments | string => {\n const parsed: IPurityArguments = { json: false };\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n\n if (arg === '--json') {\n parsed.json = true;\n continue;\n }\n\n if (arg === '--claims') {\n const value = args[index + 1];\n\n if (value === undefined || value.startsWith('--')) {\n return '--claims needs a file';\n }\n\n parsed.claimsFile = value;\n index += 1;\n continue;\n }\n\n if (arg.startsWith('--')) {\n return `unknown option \"${arg}\"`;\n }\n\n if (parsed.filter !== undefined) {\n return `unexpected argument \"${arg}\"`;\n }\n\n parsed.filter = arg;\n }\n\n return parsed;\n};\n\n/** Splits repeatable `--name value` options and positionals; `undefined` for an option that lacks its value. */\nconst parseRepeatable = (opts: {\n args: string[];\n repeatable: string[];\n single: string[];\n}): { positionals: string[]; values: Record<string, string[]> } | string => {\n const { args, repeatable, single } = opts;\n const values: Record<string, string[]> = {};\n const positionals: string[] = [];\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n\n if (arg.startsWith('--')) {\n const name = arg.slice(2);\n\n if (!repeatable.includes(name) && !single.includes(name)) {\n return `unknown option \"${arg}\"`;\n }\n\n const value = args[index + 1];\n\n if (value === undefined || value.startsWith('--')) {\n return `${arg} needs a value`;\n }\n\n values[name] = [...(values[name] ?? []), value];\n index += 1;\n continue;\n }\n\n positionals.push(arg);\n }\n\n return { positionals, values };\n};\n\n/** `devz check <name>`: runs one of the shared repository gates in the current folder. */\nexport class CheckCommand {\n private static runTestWeight(opts: { root: string; args: string[] }): number {\n const parsed = parseRepeatable({ args: opts.args, repeatable: [], single: ['top'] });\n\n if (typeof parsed === 'string' || parsed.positionals.length === 0) {\n CliOutput.error(\n `devz check test-weight: ${typeof parsed === 'string' ? parsed : 'give at least one JUnit file'}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const reports = parsed.positionals.map((file) => {\n const path = resolve(opts.root, file);\n\n return {\n label: basename(file).replace(/\\.xml$/, ''),\n xml: existsSync(path) ? readFileSync(path, 'utf8') : '',\n };\n });\n const missing = parsed.positionals.filter((file) => !existsSync(resolve(opts.root, file)));\n\n if (missing.length > 0) {\n CliOutput.error(`devz check test-weight: not found: ${missing.join(', ')}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const top = parsed.values.top?.[0] === undefined ? undefined : Number(parsed.values.top[0]);\n\n for (const line of TestWeightCheck.formatReport({\n report: TestWeightCheck.analyseJunit({ reports }),\n top,\n })) {\n CliOutput.log(line);\n }\n\n return 0;\n }\n\n private static runTestDeadCode(opts: { root: string; args: string[] }): number {\n if (opts.args.length > 0) {\n CliOutput.error(`devz check test-dead-code: unexpected argument \"${opts.args[0]}\"\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const candidates = DeadTestCodeCheck.find({ root: opts.root });\n\n for (const type of [\n DeadTestCodeCandidateTypes.UNREFERENCED,\n DeadTestCodeCandidateTypes.FOLDER_REFERENCED,\n ]) {\n const own = candidates.filter((candidate) => candidate.type === type);\n CliOutput.log(`${type}: ${own.length}`);\n\n for (const candidate of own) {\n CliOutput.log(` ${candidate.file}`);\n }\n }\n\n CliOutput.log(\n '\\nThese are candidates: delete one, run the package suite, and keep it if anything fails or loads it by a built path.',\n );\n\n return 0;\n }\n\n private static runTestMutate(opts: { root: string; args: string[] }): number {\n const [file, ...extra] = opts.args;\n\n if (file === undefined || extra.length > 0) {\n CliOutput.error(`devz check test-mutate: give one ledger file\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const path = resolve(opts.root, file);\n\n if (!existsSync(path)) {\n CliOutput.error(`devz check test-mutate: ledger not found: ${file}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const ledger: ILedger = JSON.parse(readFileSync(path, 'utf8'));\n\n if (!Array.isArray(ledger.mutants)) {\n CliOutput.error(`devz check test-mutate: ${file} has no \"mutants\" array`);\n\n return USAGE_ERROR_CODE;\n }\n\n const results = TestMutateCheck.replayLedger({ root: opts.root, ledger });\n\n for (const line of TestMutateCheck.formatLedgerResults({ results })) {\n CliOutput.log(line);\n }\n\n return results.every((result) => result.ok) ? 0 : 1;\n }\n\n private static async runTestControls(opts: { root: string; args: string[] }): Promise<number> {\n const [file, ...extra] = opts.args;\n\n if (file === undefined || extra.length > 0) {\n CliOutput.error(`devz check test-controls: give one registry file\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const path = resolve(opts.root, file);\n\n if (!existsSync(path)) {\n CliOutput.error(`devz check test-controls: registry not found: ${file}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const registry: { controls?: IControlEntry[] } = JSON.parse(readFileSync(path, 'utf8'));\n\n if (!Array.isArray(registry.controls)) {\n CliOutput.error(`devz check test-controls: ${file} has no \"controls\" array`);\n\n return USAGE_ERROR_CODE;\n }\n\n const report = await TestControlsCheck.run({ root: opts.root, controls: registry.controls });\n\n if (report.problems.length === 0) {\n CliOutput.log(`test-controls: OK - ${report.checked} registered controls found`);\n\n return 0;\n }\n\n CliOutput.error(\n `test-controls: ${report.problems.length} of ${report.checked} registered controls are gone:`,\n );\n\n for (const problem of report.problems) {\n CliOutput.error(` [${problem.entry.gate}] ${problem.message}`);\n }\n\n return 1;\n }\n\n private static runSplitReport(opts: { root: string; args: string[] }): number {\n const parsed = parseRepeatable({ args: opts.args, repeatable: [], single: ['dist'] });\n\n if (typeof parsed === 'string') {\n CliOutput.error(`devz check split-report: ${parsed}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const targets = parsed.positionals.length\n ? parsed.positionals.map((target) => resolve(opts.root, target))\n : SplitReport.defaultTargets({ root: opts.root });\n\n for (const packageDir of targets) {\n SplitReport.run({ packageDir, distDir: parsed.values.dist?.[0] });\n }\n\n return 0;\n }\n\n private static async runCatalog(opts: { root: string; args: string[] }): Promise<number> {\n const parsed = parseRepeatable({\n args: opts.args,\n repeatable: ['glob', 'pinned'],\n single: ['preset-prefix'],\n });\n\n if (typeof parsed === 'string' || parsed.positionals.length > 0) {\n CliOutput.error(\n `devz check catalog: ${typeof parsed === 'string' ? parsed : `unexpected argument \"${parsed.positionals[0]}\"`}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const report = await CatalogCheck.find({\n root: opts.root,\n globs: parsed.values.glob,\n pinned: parsed.values.pinned,\n presetPrefix: parsed.values['preset-prefix']?.[0],\n });\n\n if (report.noCatalog) {\n CliOutput.error('check-catalog: no `workspaces.catalog` in the root package.json');\n\n return 1;\n }\n\n if (report.problems.length === 0) {\n CliOutput.log(\n `check-catalog: OK - ${report.entries} entries, ${report.referenced} referenced`,\n );\n\n return 0;\n }\n\n CliOutput.error(`check-catalog: ${report.problems.length} problem(s):`);\n\n for (const problem of report.problems) {\n CliOutput.error(` ${problem.file}: ${problem.message}`);\n }\n\n return 1;\n }\n\n static async run(opts: { root: string; args?: string[] }): Promise<number> {\n const { root, args = [] } = opts;\n const [name, ...rest] = args;\n\n if (name === undefined || name === '--help' || name === '-h') {\n CliOutput.log(USAGE);\n\n return name === undefined ? USAGE_ERROR_CODE : 0;\n }\n\n if (name === 'module-cycles') {\n return ModuleCyclesCheck.run({\n args: rest,\n print: (line) => CliOutput.log(line),\n printError: (line) => CliOutput.error(line),\n });\n }\n\n if (name === 'split-report') {\n return CheckCommand.runSplitReport({ root, args: rest });\n }\n\n if (name === 'catalog') {\n return CheckCommand.runCatalog({ root, args: rest });\n }\n\n if (name === 'test-weight') {\n return CheckCommand.runTestWeight({ root, args: rest });\n }\n\n if (name === 'test-dead-code') {\n return CheckCommand.runTestDeadCode({ root, args: rest });\n }\n\n if (name === 'test-mutate') {\n return CheckCommand.runTestMutate({ root, args: rest });\n }\n\n if (name === 'test-controls') {\n return CheckCommand.runTestControls({ root, args: rest });\n }\n\n if (name !== 'purity') {\n CliOutput.error(`devz check: unknown check \"${name}\"\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n if (rest.includes('--help') || rest.includes('-h')) {\n CliOutput.log(USAGE);\n\n return 0;\n }\n\n const parsed = parsePurityArguments(rest);\n\n if (typeof parsed === 'string') {\n CliOutput.error(`devz check purity: ${parsed}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n if (parsed.claimsFile === undefined) {\n CliOutput.error(`devz check purity: --claims <file> is required\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const claimsPath = isAbsolute(parsed.claimsFile)\n ? parsed.claimsFile\n : resolve(root, parsed.claimsFile);\n\n if (!existsSync(claimsPath)) {\n CliOutput.error(`devz check purity: claims file not found: ${parsed.claimsFile}`);\n\n return USAGE_ERROR_CODE;\n }\n\n const claimsModule: IClaimsModule = await import(claimsPath);\n\n if (!Array.isArray(claimsModule.PURITY_CLAIMS)) {\n CliOutput.error(`devz check purity: ${parsed.claimsFile} does not export PURITY_CLAIMS`);\n\n return USAGE_ERROR_CODE;\n }\n\n const lines: string[] = [];\n const report = await PurityCheck.run({\n root,\n claims: claimsModule.PURITY_CLAIMS,\n options: claimsModule.PURITY_OPTIONS,\n filter: parsed.filter,\n claimsFile: relative(root, claimsPath),\n print: (line) => (parsed.json ? lines.push(line) : CliOutput.log(line)),\n printError: (line) => CliOutput.error(line),\n });\n\n if (report === undefined) {\n return 1;\n }\n\n if (parsed.json) {\n CliOutput.log(JSON.stringify(report, null, 2));\n }\n\n return report.failed > 0 ? 1 : 0;\n }\n}\n"]}