@shivaedev/quality 0.57.0 → 0.58.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 (229) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +11 -4
  3. package/dist/adapters/ImportAnalysisFailure.d.ts +10 -0
  4. package/dist/adapters/ImportAnalysisFailure.d.ts.map +1 -0
  5. package/dist/adapters/ImportAnalysisFailure.js +4 -0
  6. package/dist/adapters/ImportAnalysisFailure.js.map +1 -0
  7. package/dist/adapters/ImportCompiler.d.ts +2 -13
  8. package/dist/adapters/ImportCompiler.d.ts.map +1 -1
  9. package/dist/adapters/ImportCompiler.js +7 -13
  10. package/dist/adapters/ImportCompiler.js.map +1 -1
  11. package/dist/adapters/executable.d.ts +3 -0
  12. package/dist/adapters/executable.d.ts.map +1 -0
  13. package/dist/adapters/executable.js +14 -0
  14. package/dist/adapters/executable.js.map +1 -0
  15. package/dist/adapters/imports/analysisFailure.d.ts +3 -0
  16. package/dist/adapters/imports/analysisFailure.d.ts.map +1 -0
  17. package/dist/adapters/imports/analysisFailure.js +5 -0
  18. package/dist/adapters/imports/analysisFailure.js.map +1 -0
  19. package/dist/adapters/imports/analyzeDepartures.d.ts +5 -0
  20. package/dist/adapters/imports/analyzeDepartures.d.ts.map +1 -0
  21. package/dist/adapters/imports/analyzeDepartures.js +5 -0
  22. package/dist/adapters/imports/analyzeDepartures.js.map +1 -0
  23. package/dist/adapters/imports/analyzeGraph.d.ts +4 -0
  24. package/dist/adapters/imports/analyzeGraph.d.ts.map +1 -0
  25. package/dist/adapters/imports/analyzeGraph.js +6 -0
  26. package/dist/adapters/imports/analyzeGraph.js.map +1 -0
  27. package/dist/adapters/imports/checkBrowser.d.ts +4 -0
  28. package/dist/adapters/imports/checkBrowser.d.ts.map +1 -0
  29. package/dist/adapters/imports/checkBrowser.js +4 -0
  30. package/dist/adapters/imports/checkBrowser.js.map +1 -0
  31. package/dist/adapters/indirectServiceReferences.d.ts +3 -0
  32. package/dist/adapters/indirectServiceReferences.d.ts.map +1 -0
  33. package/dist/adapters/indirectServiceReferences.js +19 -0
  34. package/dist/adapters/indirectServiceReferences.js.map +1 -0
  35. package/dist/adapters/knip/entryPointFindings.d.ts +1 -1
  36. package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
  37. package/dist/adapters/nativeTransactionFindings.d.ts +4 -0
  38. package/dist/adapters/nativeTransactionFindings.d.ts.map +1 -0
  39. package/dist/adapters/nativeTransactionFindings.js +98 -0
  40. package/dist/adapters/nativeTransactionFindings.js.map +1 -0
  41. package/dist/adapters/outsideImportFindings.d.ts +1 -1
  42. package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
  43. package/dist/adapters/queueReadoutFindings.d.ts +1 -1
  44. package/dist/adapters/queueReadoutFindings.d.ts.map +1 -1
  45. package/dist/adapters/serviceAssemblyImports.d.ts +10 -0
  46. package/dist/adapters/serviceAssemblyImports.d.ts.map +1 -0
  47. package/dist/adapters/serviceAssemblyImports.js +71 -0
  48. package/dist/adapters/serviceAssemblyImports.js.map +1 -0
  49. package/dist/adapters/serviceAssemblySyntax.d.ts +10 -0
  50. package/dist/adapters/serviceAssemblySyntax.d.ts.map +1 -0
  51. package/dist/adapters/serviceAssemblySyntax.js +105 -0
  52. package/dist/adapters/serviceAssemblySyntax.js.map +1 -0
  53. package/dist/adapters/serviceDefinitionProblems.d.ts +7 -0
  54. package/dist/adapters/serviceDefinitionProblems.d.ts.map +1 -0
  55. package/dist/adapters/serviceDefinitionProblems.js +43 -0
  56. package/dist/adapters/serviceDefinitionProblems.js.map +1 -0
  57. package/dist/adapters/serviceIdFindings.d.ts.map +1 -1
  58. package/dist/adapters/serviceIdFindings.js +12 -7
  59. package/dist/adapters/serviceIdFindings.js.map +1 -1
  60. package/dist/adapters/transactionChanges.d.ts +3 -0
  61. package/dist/adapters/transactionChanges.d.ts.map +1 -0
  62. package/dist/adapters/transactionChanges.js +81 -0
  63. package/dist/adapters/transactionChanges.js.map +1 -0
  64. package/dist/baseline/cleanupMergeFiles.d.ts.map +1 -1
  65. package/dist/baseline/cleanupMergeFiles.js +3 -2
  66. package/dist/baseline/cleanupMergeFiles.js.map +1 -1
  67. package/dist/baseline/shards.d.ts.map +1 -1
  68. package/dist/baseline/shards.js +4 -2
  69. package/dist/baseline/shards.js.map +1 -1
  70. package/dist/biome/recommendedRules.d.ts.map +1 -1
  71. package/dist/biome/recommendedRules.js +3 -2
  72. package/dist/biome/recommendedRules.js.map +1 -1
  73. package/dist/biome/report.d.ts.map +1 -1
  74. package/dist/biome/report.js +3 -2
  75. package/dist/biome/report.js.map +1 -1
  76. package/dist/cli/baseline.d.ts.map +1 -1
  77. package/dist/cli/baseline.js +3 -2
  78. package/dist/cli/baseline.js.map +1 -1
  79. package/dist/cli/fix.d.ts.map +1 -1
  80. package/dist/cli/fix.js +3 -2
  81. package/dist/cli/fix.js.map +1 -1
  82. package/dist/cli/fixRule.d.ts.map +1 -1
  83. package/dist/cli/fixRule.js +3 -2
  84. package/dist/cli/fixRule.js.map +1 -1
  85. package/dist/cli/lint.d.ts.map +1 -1
  86. package/dist/cli/lint.js +2 -2
  87. package/dist/cli/lint.js.map +1 -1
  88. package/dist/cli/migrateBaseline.d.ts.map +1 -1
  89. package/dist/cli/migrateBaseline.js +3 -2
  90. package/dist/cli/migrateBaseline.js.map +1 -1
  91. package/dist/cli/migrateExceptions.d.ts.map +1 -1
  92. package/dist/cli/migrateExceptions.js +3 -2
  93. package/dist/cli/migrateExceptions.js.map +1 -1
  94. package/dist/config/load.d.ts.map +1 -1
  95. package/dist/config/load.js +3 -2
  96. package/dist/config/load.js.map +1 -1
  97. package/dist/engine/session.d.ts.map +1 -1
  98. package/dist/engine/session.js +3 -2
  99. package/dist/engine/session.js.map +1 -1
  100. package/dist/hooks/install.d.ts.map +1 -1
  101. package/dist/hooks/install.js +4 -2
  102. package/dist/hooks/install.js.map +1 -1
  103. package/dist/hooks/location.d.ts.map +1 -1
  104. package/dist/hooks/location.js +3 -2
  105. package/dist/hooks/location.js.map +1 -1
  106. package/dist/hooks/preCommit.d.ts.map +1 -1
  107. package/dist/hooks/preCommit.js +3 -2
  108. package/dist/hooks/preCommit.js.map +1 -1
  109. package/dist/hooks/setup.d.ts.map +1 -1
  110. package/dist/hooks/setup.js +3 -2
  111. package/dist/hooks/setup.js.map +1 -1
  112. package/dist/hooks/status.d.ts.map +1 -1
  113. package/dist/hooks/status.js +5 -15
  114. package/dist/hooks/status.js.map +1 -1
  115. package/dist/hooks/uninstall.d.ts.map +1 -1
  116. package/dist/hooks/uninstall.js +3 -2
  117. package/dist/hooks/uninstall.js.map +1 -1
  118. package/dist/imports/departures.d.ts +1 -1
  119. package/dist/imports/departures.d.ts.map +1 -1
  120. package/dist/imports/fences/check.d.ts +1 -1
  121. package/dist/imports/fences/check.d.ts.map +1 -1
  122. package/dist/imports/graph.d.ts +1 -1
  123. package/dist/imports/graph.d.ts.map +1 -1
  124. package/dist/inventory/filesystem.d.ts.map +1 -1
  125. package/dist/inventory/filesystem.js +3 -2
  126. package/dist/inventory/filesystem.js.map +1 -1
  127. package/dist/inventory/shadcnFolders.d.ts.map +1 -1
  128. package/dist/inventory/shadcnFolders.js +4 -2
  129. package/dist/inventory/shadcnFolders.js.map +1 -1
  130. package/dist/inventory/trackedPaths.d.ts.map +1 -1
  131. package/dist/inventory/trackedPaths.js +4 -2
  132. package/dist/inventory/trackedPaths.js.map +1 -1
  133. package/dist/rules/builtIn.d.ts +1 -1
  134. package/dist/rules/builtIn.d.ts.map +1 -1
  135. package/dist/rules/builtIn.js +4 -0
  136. package/dist/rules/builtIn.js.map +1 -1
  137. package/dist/rules/effect/serviceCatalog.d.ts +1 -1
  138. package/dist/rules/effect/serviceCatalog.d.ts.map +1 -1
  139. package/dist/rules/effect/serviceCatalog.js +4 -2
  140. package/dist/rules/effect/serviceCatalog.js.map +1 -1
  141. package/dist/rules/effect/serviceDefinitionAssembly.d.ts +2 -0
  142. package/dist/rules/effect/serviceDefinitionAssembly.d.ts.map +1 -0
  143. package/dist/rules/effect/serviceDefinitionAssembly.js +43 -0
  144. package/dist/rules/effect/serviceDefinitionAssembly.js.map +1 -0
  145. package/dist/rules/effect/serviceIds.js +1 -1
  146. package/dist/rules/effect/serviceIds.js.map +1 -1
  147. package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
  148. package/dist/rules/effect/serviceParameters.js +12 -6
  149. package/dist/rules/effect/serviceParameters.js.map +1 -1
  150. package/dist/rules/effect/sqlTransact.d.ts +2 -0
  151. package/dist/rules/effect/sqlTransact.d.ts.map +1 -0
  152. package/dist/rules/effect/sqlTransact.js +9 -0
  153. package/dist/rules/effect/sqlTransact.js.map +1 -0
  154. package/dist/rules/imports/manifest.d.ts.map +1 -1
  155. package/dist/rules/imports/manifest.js +9 -6
  156. package/dist/rules/imports/manifest.js.map +1 -1
  157. package/dist/rules/stories/sources.d.ts +1 -1
  158. package/dist/rules/stories/sources.d.ts.map +1 -1
  159. package/dist/rules/suppressions/noIgnoreDeprecations.d.ts.map +1 -1
  160. package/dist/rules/suppressions/noIgnoreDeprecations.js +3 -2
  161. package/dist/rules/suppressions/noIgnoreDeprecations.js.map +1 -1
  162. package/dist/testing/adapters/assertThat.d.ts +5 -0
  163. package/dist/testing/adapters/assertThat.d.ts.map +1 -0
  164. package/dist/testing/adapters/assertThat.js +9 -0
  165. package/dist/testing/adapters/assertThat.js.map +1 -0
  166. package/dist/testing/adapters/cli.d.ts +2 -2
  167. package/dist/testing/adapters/cli.d.ts.map +1 -1
  168. package/dist/testing/adapters/cli.js +11 -14
  169. package/dist/testing/adapters/cli.js.map +1 -1
  170. package/dist/testing/adapters/git.d.ts +10 -0
  171. package/dist/testing/adapters/git.d.ts.map +1 -1
  172. package/dist/testing/adapters/git.js +6 -2
  173. package/dist/testing/adapters/git.js.map +1 -1
  174. package/dist/testing/adapters/hookRepository.d.ts.map +1 -1
  175. package/dist/testing/adapters/hookRepository.js +6 -2
  176. package/dist/testing/adapters/hookRepository.js.map +1 -1
  177. package/dist/testing/ruleStory.d.ts.map +1 -1
  178. package/dist/testing/ruleStory.js +1 -2
  179. package/dist/testing/ruleStory.js.map +1 -1
  180. package/package.json +6 -5
  181. package/src/adapters/ImportAnalysisFailure.ts +6 -0
  182. package/src/adapters/ImportCompiler.ts +7 -20
  183. package/src/adapters/executable.ts +14 -0
  184. package/src/adapters/imports/analysisFailure.ts +5 -0
  185. package/src/adapters/imports/analyzeDepartures.ts +9 -0
  186. package/src/adapters/imports/analyzeGraph.ts +9 -0
  187. package/src/adapters/imports/checkBrowser.ts +5 -0
  188. package/src/adapters/indirectServiceReferences.ts +25 -0
  189. package/src/adapters/nativeTransactionFindings.ts +108 -0
  190. package/src/adapters/outsideImportFindings.ts +1 -1
  191. package/src/adapters/serviceAssemblyImports.ts +93 -0
  192. package/src/adapters/serviceAssemblySyntax.ts +129 -0
  193. package/src/adapters/serviceDefinitionProblems.ts +63 -0
  194. package/src/adapters/serviceIdFindings.ts +16 -13
  195. package/src/adapters/transactionChanges.ts +85 -0
  196. package/src/baseline/cleanupMergeFiles.ts +4 -2
  197. package/src/baseline/shards.ts +6 -2
  198. package/src/biome/recommendedRules.ts +4 -2
  199. package/src/biome/report.ts +4 -2
  200. package/src/cli/baseline.ts +4 -2
  201. package/src/cli/fix.ts +4 -2
  202. package/src/cli/fixRule.ts +4 -2
  203. package/src/cli/lint.ts +3 -2
  204. package/src/cli/migrateBaseline.ts +4 -2
  205. package/src/cli/migrateExceptions.ts +4 -2
  206. package/src/config/load.ts +4 -2
  207. package/src/engine/session.ts +4 -2
  208. package/src/hooks/install.ts +6 -2
  209. package/src/hooks/location.ts +4 -2
  210. package/src/hooks/preCommit.ts +4 -2
  211. package/src/hooks/setup.ts +4 -2
  212. package/src/hooks/status.ts +7 -15
  213. package/src/hooks/uninstall.ts +4 -2
  214. package/src/inventory/filesystem.ts +4 -2
  215. package/src/inventory/shadcnFolders.ts +6 -2
  216. package/src/inventory/trackedPaths.ts +6 -2
  217. package/src/rules/builtIn.ts +4 -0
  218. package/src/rules/effect/serviceCatalog.ts +4 -2
  219. package/src/rules/effect/serviceDefinitionAssembly.ts +46 -0
  220. package/src/rules/effect/serviceIds.ts +1 -1
  221. package/src/rules/effect/serviceParameters.ts +12 -6
  222. package/src/rules/effect/sqlTransact.ts +10 -0
  223. package/src/rules/imports/manifest.ts +14 -8
  224. package/src/rules/suppressions/noIgnoreDeprecations.ts +4 -2
  225. package/src/testing/adapters/assertThat.ts +12 -0
  226. package/src/testing/adapters/cli.ts +22 -14
  227. package/src/testing/adapters/git.ts +7 -2
  228. package/src/testing/adapters/hookRepository.ts +6 -2
  229. package/src/testing/ruleStory.ts +1 -2
@@ -0,0 +1,129 @@
1
+ import ts from "typescript";
2
+
3
+ export function unwrapExpression(expression: ts.Expression): ts.Expression {
4
+ if (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isSatisfiesExpression(expression)) {
5
+ return unwrapExpression(expression.expression);
6
+ }
7
+ return expression;
8
+ }
9
+
10
+ export function directServiceDefinitions(source: ts.SourceFile, names: ReadonlySet<string>): readonly ts.CallExpression[] {
11
+ const found: ts.CallExpression[] = [];
12
+ for (const statement of source.statements) {
13
+ if (!ts.isVariableStatement(statement)) {
14
+ continue;
15
+ }
16
+ for (const declaration of statement.declarationList.declarations) {
17
+ if (declaration.initializer === undefined) {
18
+ continue;
19
+ }
20
+ const value = unwrapExpression(declaration.initializer);
21
+ if (!ts.isCallExpression(value)) {
22
+ continue;
23
+ }
24
+ const called = unwrapExpression(value.expression);
25
+ if (ts.isIdentifier(called) && names.has(called.text)) {
26
+ found.push(value);
27
+ }
28
+ }
29
+ }
30
+ return found;
31
+ }
32
+
33
+ const CONFIG_MEMBERS = new Set(["id", "initialize", "methods", "requires"]);
34
+
35
+ export function invalidServiceMembers(config: ts.ObjectLiteralExpression): readonly ts.ObjectLiteralElementLike[] {
36
+ return config.properties.filter(
37
+ (member) =>
38
+ !(
39
+ (ts.isPropertyAssignment(member) || ts.isShorthandPropertyAssignment(member))
40
+ && ts.isIdentifier(member.name)
41
+ && CONFIG_MEMBERS.has(member.name.text)
42
+ ),
43
+ );
44
+ }
45
+
46
+ export function serviceProperty(object: ts.ObjectLiteralExpression, name: string): ts.Expression | undefined {
47
+ const member = object.properties.find(
48
+ (candidate) =>
49
+ (ts.isPropertyAssignment(candidate) || ts.isShorthandPropertyAssignment(candidate))
50
+ && ts.isIdentifier(candidate.name)
51
+ && candidate.name.text === name,
52
+ );
53
+ if (member !== undefined && ts.isPropertyAssignment(member)) {
54
+ return member.initializer;
55
+ }
56
+ return member !== undefined && ts.isShorthandPropertyAssignment(member) ? member.name : undefined;
57
+ }
58
+
59
+ export function returnedServiceMethods(value: ts.Expression): ts.ObjectLiteralExpression | undefined {
60
+ if (!ts.isArrowFunction(value)) {
61
+ return;
62
+ }
63
+ if (!ts.isBlock(value.body)) {
64
+ const body = unwrapExpression(value.body);
65
+ return ts.isObjectLiteralExpression(body) ? body : undefined;
66
+ }
67
+ if (value.body.statements.length !== 1) {
68
+ return;
69
+ }
70
+ const [statement] = value.body.statements;
71
+ if (statement === undefined || !ts.isReturnStatement(statement) || statement.expression === undefined) {
72
+ return;
73
+ }
74
+ const result = unwrapExpression(statement.expression);
75
+ return ts.isObjectLiteralExpression(result) ? result : undefined;
76
+ }
77
+
78
+ export function isEffectVoid(value: ts.Expression, effects: ReadonlySet<string>): boolean {
79
+ return (
80
+ ts.isPropertyAccessExpression(value) && ts.isIdentifier(value.expression) && effects.has(value.expression.text) && value.name.text === "void"
81
+ );
82
+ }
83
+
84
+ export function isOperationReference(member: ts.ObjectLiteralElementLike, imports: ReadonlySet<string>, generics: ReadonlySet<string>): boolean {
85
+ if (ts.isShorthandPropertyAssignment(member)) {
86
+ return imports.has(member.name.text);
87
+ }
88
+ if (!ts.isPropertyAssignment(member) || ts.isComputedPropertyName(member.name)) {
89
+ return false;
90
+ }
91
+ const value = unwrapExpression(member.initializer);
92
+ if (ts.isIdentifier(value)) {
93
+ return imports.has(value.text);
94
+ }
95
+ if (ts.isCallExpression(value) && ts.isIdentifier(value.expression) && generics.has(value.expression.text)) {
96
+ const method = value.arguments[0];
97
+ return method !== undefined && isOperationValue(unwrapExpression(method), imports);
98
+ }
99
+ return isOperationValue(value, imports);
100
+ }
101
+
102
+ function isOperationValue(value: ts.Expression, imports: ReadonlySet<string>): boolean {
103
+ return (
104
+ (ts.isIdentifier(value) && imports.has(value.text))
105
+ || (ts.isCallExpression(value)
106
+ && ts.isIdentifier(unwrapExpression(value.expression))
107
+ && imports.has(unwrapExpression(value.expression).getText()))
108
+ );
109
+ }
110
+
111
+ function isFunctionBody(node: ts.Node): node is ts.FunctionLikeDeclaration {
112
+ return (
113
+ (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node))
114
+ && node.body !== undefined
115
+ );
116
+ }
117
+
118
+ export function implementationBodies(source: ts.SourceFile, allowed: ReadonlySet<ts.Node>): readonly ts.Node[] {
119
+ const found: ts.Node[] = [];
120
+ function visit(node: ts.Node): void {
121
+ if (isFunctionBody(node) && !allowed.has(node)) {
122
+ found.push(node);
123
+ return;
124
+ }
125
+ ts.forEachChild(node, visit);
126
+ }
127
+ visit(source);
128
+ return found;
129
+ }
@@ -0,0 +1,63 @@
1
+ import ts from "typescript";
2
+ import {
3
+ invalidServiceMembers,
4
+ isEffectVoid,
5
+ isOperationReference,
6
+ returnedServiceMethods,
7
+ serviceProperty,
8
+ unwrapExpression,
9
+ } from "#adapters/serviceAssemblySyntax.ts";
10
+
11
+ export interface ServiceAssemblyProblem {
12
+ readonly message: string;
13
+ readonly node: ts.Node;
14
+ }
15
+
16
+ export function serviceDefinitionProblems(
17
+ definition: ts.CallExpression,
18
+ effects: ReadonlySet<string>,
19
+ imports: ReadonlySet<string>,
20
+ allowedBodies: Set<ts.Node>,
21
+ generics: ReadonlySet<string>,
22
+ ): readonly ServiceAssemblyProblem[] {
23
+ const config = definition.arguments[0];
24
+ if (config === undefined || !ts.isObjectLiteralExpression(config)) {
25
+ return [{ message: "Inline the service inventory.", node: definition }];
26
+ }
27
+ const found: ServiceAssemblyProblem[] = invalidServiceMembers(config).map((node) => ({
28
+ message: "List id, initialize, methods, and requires directly; computed members and spreads cannot hide the service inventory.",
29
+ node,
30
+ }));
31
+ const initialize = serviceProperty(config, "initialize");
32
+ if (
33
+ initialize !== undefined
34
+ && !(ts.isIdentifier(unwrapExpression(initialize)) && imports.has(unwrapExpression(initialize).getText()))
35
+ && !isEffectVoid(unwrapExpression(initialize), effects)
36
+ ) {
37
+ found.push({
38
+ message: "Reference a named initializer export or use Effect.void.",
39
+ node: initialize,
40
+ });
41
+ }
42
+ const methodsValue = serviceProperty(config, "methods");
43
+ const methods = methodsValue && returnedServiceMethods(methodsValue);
44
+ if (methodsValue !== undefined && methods === undefined) {
45
+ found.push({
46
+ message: "Keep methods as a direct operation inventory.",
47
+ node: methodsValue,
48
+ });
49
+ return found;
50
+ }
51
+ if (methodsValue !== undefined) {
52
+ allowedBodies.add(methodsValue);
53
+ }
54
+ for (const operation of methods?.properties ?? []) {
55
+ if (!isOperationReference(operation, imports, generics)) {
56
+ found.push({
57
+ message: "Reference a named operation export or call its named state factory.",
58
+ node: operation,
59
+ });
60
+ }
61
+ }
62
+ return found;
63
+ }
@@ -1,6 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { Effect } from "effect";
3
3
  import ts from "typescript";
4
+ import { packageOf, type WorkspacePackage, workspacePackages } from "#imports/workspace.ts";
4
5
  import type { Finding, RuleInputs } from "#rule.ts";
5
6
  import { boundaryReference } from "#rules/effect/boundaryReference.ts";
6
7
 
@@ -64,17 +65,19 @@ function checkPackage(inputs: RuleInputs, prefix: string): readonly Finding[] {
64
65
  });
65
66
  }
66
67
 
67
- export const serviceIdFindings = Effect.fn("ServiceIds.serviceIdFindings")((inputs: RuleInputs) =>
68
- Effect.sync(() => {
69
- const groups = new Map<string, RuleInputs["sources"][number][]>();
70
- for (const source of inputs.sources) {
71
- const name = /^packages\/(?<name>[^/]+)\/.+\.[cm]?[jt]sx?$/u.exec(source.path)?.groups?.name;
72
- if (name !== undefined) {
73
- const files = groups.get(name) ?? [];
74
- files.push(source);
75
- groups.set(name, files);
76
- }
68
+ export const serviceIdFindings = Effect.fn("ServiceIds.serviceIdFindings")(function* (inputs: RuleInputs) {
69
+ const packages = yield* Effect.promise(() => workspacePackages(inputs));
70
+ const groups = new Map<WorkspacePackage, RuleInputs["sources"][number][]>();
71
+ for (const source of inputs.sources) {
72
+ if (!source.path.startsWith("packages/")) {
73
+ continue;
74
+ }
75
+ const owner = packageOf(packages, source.path);
76
+ if (owner !== undefined) {
77
+ const files = groups.get(owner) ?? [];
78
+ files.push(source);
79
+ groups.set(owner, files);
77
80
  }
78
- return [...groups].flatMap(([name, sources]) => checkPackage({ ...inputs, sources }, `@shivaedev/${name}/`));
79
- }),
80
- );
81
+ }
82
+ return [...groups].flatMap(([owner, sources]) => checkPackage({ ...inputs, sources }, `${owner.name}/`));
83
+ });
@@ -0,0 +1,85 @@
1
+ import ts from "typescript";
2
+ import { memberName, unwrapped } from "#rules/stories/syntax.ts";
3
+
4
+ const WRITES = new Set([
5
+ "insert",
6
+ "insertVoid",
7
+ "insertOrIgnore",
8
+ "insertMany",
9
+ "insertManyOrIgnore",
10
+ "insertFromSelect",
11
+ "insertFromSelectOrIgnore",
12
+ "update",
13
+ "updateVoid",
14
+ "upsert",
15
+ "upsertMany",
16
+ "delete",
17
+ "deleteBatched",
18
+ ]);
19
+
20
+ function sqlModule(path: string): boolean {
21
+ return /\/(?:@shivaedev\/)?sql\/(?:src|dist)\//u.test(path.replaceAll("\\", "/"));
22
+ }
23
+
24
+ export function transactionChanges(checker: ts.TypeChecker, body: ts.Expression): boolean {
25
+ const seen = new Set<ts.Node>();
26
+ function repositoryWrite(expression: ts.Expression, name: string | undefined): boolean {
27
+ if (!WRITES.has(name ?? "")) {
28
+ return false;
29
+ }
30
+ const purge = checker.getTypeAtLocation(expression).getProperty("deleteBatched");
31
+ return purge?.declarations?.some((declaration) => sqlModule(declaration.getSourceFile().fileName)) ?? false;
32
+ }
33
+ function bindingWrite(declaration: ts.BindingElement): boolean {
34
+ if (!ts.isVariableDeclaration(declaration.parent.parent)) {
35
+ return false;
36
+ }
37
+ const value = declaration.parent.parent.initializer;
38
+ const property = declaration.propertyName ?? declaration.name;
39
+ return value !== undefined && repositoryWrite(value, ts.isIdentifier(property) ? property.text : undefined);
40
+ }
41
+ function declarationChanges(declaration: ts.Declaration, name: string): boolean {
42
+ const source = declaration.getSourceFile();
43
+ if (sqlModule(source.fileName)) {
44
+ return ["transact", "invalidateOnCommit"].includes(name) && /\/transact\.(?:d\.)?ts$/u.test(source.fileName);
45
+ }
46
+ if (source.isDeclarationFile || source.fileName.includes("/node_modules/")) {
47
+ return false;
48
+ }
49
+ if (ts.isVariableDeclaration(declaration)) {
50
+ return declaration.initializer !== undefined && visit(declaration.initializer);
51
+ }
52
+ if (ts.isFunctionDeclaration(declaration)) {
53
+ return declaration.body !== undefined && visit(declaration.body);
54
+ }
55
+ if (ts.isBindingElement(declaration)) {
56
+ return bindingWrite(declaration);
57
+ }
58
+ return false;
59
+ }
60
+ function reference(node: ts.Identifier): boolean {
61
+ const symbol = checker.getSymbolAtLocation(node);
62
+ if (symbol === undefined) {
63
+ return false;
64
+ }
65
+ const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
66
+ return target.declarations?.some((declaration) => declarationChanges(declaration, target.name)) ?? false;
67
+ }
68
+ function visit(node: ts.Node): boolean {
69
+ if (seen.has(node) || ts.isTypeNode(node)) {
70
+ return false;
71
+ }
72
+ seen.add(node);
73
+ if (ts.isIdentifier(node) && reference(node)) {
74
+ return true;
75
+ }
76
+ if (
77
+ (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node))
78
+ && repositoryWrite(unwrapped(node.expression), memberName(node))
79
+ ) {
80
+ return true;
81
+ }
82
+ return ts.forEachChild(node, (child) => visit(child) || undefined) ?? false;
83
+ }
84
+ return visit(body);
85
+ }
@@ -1,5 +1,5 @@
1
- import { resolve } from "node:path";
2
- import { Clock, Effect, FileSystem, Option } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Clock, Effect, FileSystem, Option, Path } from "effect";
3
3
  import { SetupFailure } from "#failure.ts";
4
4
  import { gitOrFail } from "#git/command.ts";
5
5
 
@@ -7,6 +7,8 @@ const STALE_AFTER_MS = 5 * 60_000;
7
7
 
8
8
  export const cleanupMergeFiles = Effect.fn("Baseline.cleanupMergeFiles")(
9
9
  function* (cwd: string, inputs: readonly string[]) {
10
+ const { resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
11
+
10
12
  const fs = yield* FileSystem.FileSystem;
11
13
  const root = (yield* gitOrFail(cwd, ["rev-parse", "--show-toplevel"])).trim();
12
14
  const active = new Set(inputs.map((path) => resolve(cwd, path)));
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, FileSystem, Path } from "effect";
3
3
  import type { BaselineEntry } from "#baseline/format.ts";
4
4
  import { rewriteBaseline } from "#baseline/rewrite.ts";
5
5
  import type { ResolvedConfig } from "#config/load.ts";
@@ -19,6 +19,8 @@ export function shardOf(file: string, rootFile: string): string {
19
19
  }
20
20
 
21
21
  export const shardPaths = Effect.fn("Baseline.shardPaths")(function* (config: ResolvedConfig) {
22
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
23
+
22
24
  const fs = yield* FileSystem.FileSystem;
23
25
  const folder = join(config.root, "packages");
24
26
  const names = yield* orWhenAbsent(folder, fs.readDirectory(folder), []);
@@ -33,6 +35,8 @@ export const shardPaths = Effect.fn("Baseline.shardPaths")(function* (config: Re
33
35
 
34
36
  export const saveShards = Effect.fn("Baseline.saveShards")(
35
37
  function* (config: ResolvedConfig, before: ReadonlyMap<string, Shard>, entries: readonly BaselineEntry[]) {
38
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
39
+
36
40
  const fs = yield* FileSystem.FileSystem;
37
41
  const grouped = new Map<string, BaselineEntry[]>();
38
42
  for (const entry of entries) {
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, FileSystem, Path } from "effect";
3
3
  import { runBiome } from "#adapters/biome/run.ts";
4
4
 
5
5
  const RECOMMENDED_ONLY = '{ "linter": { "rules": { "preset": "recommended" } } }\n';
@@ -9,6 +9,8 @@ const ENABLED_RULE = /^ {4}(?<rule>[a-z0-9]+\/\w+)$/gimu;
9
9
  export const recommendedRules = Effect.fn("Biome.recommendedRules")(function* () {
10
10
  return yield* Effect.scoped(
11
11
  Effect.gen(function* () {
12
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
13
+
12
14
  const fs = yield* FileSystem.FileSystem;
13
15
  const directory = yield* fs.makeTempDirectoryScoped({ prefix: "quality-biome-recommended-" });
14
16
  yield* fs.writeFileString(join(directory, "biome.json"), RECOMMENDED_ONLY);
@@ -1,5 +1,5 @@
1
- import { relative, sep } from "node:path";
2
- import { Effect, Schema } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, Path, Schema } from "effect";
3
3
  import { type BiomeRun, runBiome } from "#adapters/biome/run.ts";
4
4
  import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
5
5
  import { SetupFailure } from "#failure.ts";
@@ -65,6 +65,8 @@ export const biomeReport = Effect.fn("Biome.biomeReport")(function* (
65
65
  exceptions: readonly ExceptionDeclaration[] = [],
66
66
  files: readonly string[] = ["."],
67
67
  ) {
68
+ const { relative, sep } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
69
+
68
70
  const [report, tracked] = yield* Effect.all([reportFor(root, args, files, exceptions), ignoredTrackedPaths(root)], {
69
71
  concurrency: "unbounded",
70
72
  });
@@ -1,5 +1,5 @@
1
- import { relative, resolve } from "node:path";
2
- import { Console, Effect, type FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, type FileSystem, Path } from "effect";
3
3
  import type { BaselineEntry } from "#baseline/format.ts";
4
4
  import { saveShards } from "#baseline/shards.ts";
5
5
  import { adopt, type Pruned, prune, type Scope } from "#baseline/update.ts";
@@ -26,6 +26,8 @@ export const writeBaseline = Effect.fn("Cli.writeBaseline")(function* (
26
26
  files: readonly string[],
27
27
  firstAdoption = false,
28
28
  ): Effect.fn.Return<void, SetupFailure, RuleServices> {
29
+ const { relative, resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
30
+
29
31
  const session = yield* openSession(cwd, config);
30
32
  const existing = session.baseline.files.size === 0 ? undefined : session.baseline.entries;
31
33
  if (firstAdoption && (rules.length === 0 || rules.some((rule) => registrable(session.config, rule)))) {
package/src/cli/fix.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { relative } from "node:path";
2
- import { Console, Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, FileSystem, Path } from "effect";
3
3
  import { biomeReport } from "#biome/report.ts";
4
4
  import { changedRanges } from "#cli/changedRanges.ts";
5
5
  import { loadConfig } from "#config/load.ts";
@@ -19,6 +19,8 @@ function isBinary(bytes: Uint8Array): boolean {
19
19
 
20
20
  export function snapshotOf(root: string): Effect.Effect<ReadonlyMap<string, string>, SetupFailure, RuleServices> {
21
21
  return Effect.gen(function* () {
22
+ const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
23
+
22
24
  const fs = yield* FileSystem.FileSystem;
23
25
  const decoder = new TextDecoder();
24
26
  const paths = yield* walk(root);
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Console, Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, FileSystem, Path } from "effect";
3
3
  import { fixJsxConditionals } from "#adapters/fixJsxConditionals.ts";
4
4
  import { loadConfig } from "#config/load.ts";
5
5
  import { scan } from "#engine/session.ts";
@@ -16,6 +16,8 @@ export const fixRule = Effect.fn("Cli.fixRule")(function* (
16
16
  configPath: string | undefined,
17
17
  rules: readonly string[],
18
18
  ): Effect.fn.Return<void, SetupFailure | GateFailed, RuleServices> {
19
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
20
+
19
21
  const config = yield* loadConfig(cwd, configPath);
20
22
  for (const rule of rules) {
21
23
  if (rule !== "react/jsx-conditionals") {
package/src/cli/lint.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { relative } from "node:path";
2
1
  import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
3
2
  import * as NodePath from "@effect/platform-node/NodePath";
4
- import { Console, Effect } from "effect";
3
+ import { Console, Effect, Path } from "effect";
5
4
  import { withHeavyLock } from "@shivaedev/heavy-lock/withHeavyLock.ts";
6
5
  import { looseStagedEntries } from "#baseline/looseStagedEntries.ts";
7
6
  import { evaluate, passes } from "#engine/evaluate.ts";
@@ -13,6 +12,8 @@ import type { RuleServices } from "#rule.ts";
13
12
 
14
13
  export const lint = Effect.fn("Cli.lint")(
15
14
  function* (cwd: string, config: string | undefined, staged = false): Effect.fn.Return<void, SetupFailure | GateFailed, RuleServices> {
15
+ const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
16
+
16
17
  const session = yield* openSession(cwd, config);
17
18
  const evaluated = evaluate(session.violations, session.registry, session.baseline.entries, session.config);
18
19
  const loose = staged ? yield* looseStagedEntries(session) : [];
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Console, Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, FileSystem, Path } from "effect";
3
3
  import { decodeBaseline } from "#baseline/format.ts";
4
4
  import { convertLegacy, decodeLegacyBaseline, LEGACY_BASELINE } from "#baseline/legacy.ts";
5
5
  import { saveShards, shardPaths } from "#baseline/shards.ts";
@@ -16,6 +16,8 @@ export const migrateBaseline = Effect.fn("Cli.migrateBaseline")(function* (
16
16
  configPath: string | undefined,
17
17
  from: string | undefined,
18
18
  ): Effect.fn.Return<void, SetupFailure, RuleServices> {
19
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
20
+
19
21
  const config = yield* loadConfig(cwd, configPath);
20
22
  const source = from ?? LEGACY_BASELINE;
21
23
  const paths = yield* shardPaths(config).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Console, Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, FileSystem, Path } from "effect";
3
3
  import { loadConfig } from "#config/load.ts";
4
4
  import { validOrFail } from "#decoded.ts";
5
5
  import { readInput } from "#engine/baselineFile.ts";
@@ -38,6 +38,8 @@ export const migrateExceptions = Effect.fnUntraced(function* (
38
38
  configPath: string | undefined,
39
39
  from: string | undefined,
40
40
  ): Effect.fn.Return<void, SetupFailure, FileSystem.FileSystem> {
41
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
42
+
41
43
  const config = yield* loadConfig(cwd, configPath);
42
44
  const registryPath = from ?? config.registry;
43
45
  const raw = yield* readInput(config.root, registryPath);
@@ -1,5 +1,5 @@
1
- import { dirname } from "node:path";
2
- import { Effect, type FileSystem, Schema } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, type FileSystem, Path, Schema } from "effect";
3
3
  import { readConfig } from "#adapters/readConfig.ts";
4
4
  import { validOrFail } from "#decoded.ts";
5
5
  import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
@@ -46,6 +46,8 @@ export const loadConfig = Effect.fn("Config.loadConfig")(function* (
46
46
  cwd: string,
47
47
  path: string | undefined,
48
48
  ): Effect.fn.Return<ResolvedConfig, SetupFailure, FileSystem.FileSystem> {
49
+ const { dirname } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
50
+
49
51
  const { file, loaded } = yield* readConfig(cwd, path);
50
52
  const config = yield* validOrFail(file, yield* Effect.promise(() => decodeConfig(loaded)));
51
53
  const rules = yield* validOrFail(file, yield* resolveRules(config));
@@ -1,5 +1,5 @@
1
- import { relative } from "node:path";
2
- import { Effect, type Scope } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, Path, type Scope } from "effect";
3
3
  import { setManifestFiles } from "#adapters/manifestInventory.ts";
4
4
  import { manifestReader } from "#adapters/manifestReader.ts";
5
5
  import { loadConfig, type ResolvedConfig } from "#config/load.ts";
@@ -31,6 +31,8 @@ function setup<TValue, TRequirements>(effect: Effect.Effect<TValue, Error, TRequ
31
31
  export const scan = Effect.fn("Engine.scan")(function* (
32
32
  config: ResolvedConfig,
33
33
  ): Effect.fn.Return<Pick<Session, "inventory" | "staleRegistry" | "violations">, SetupFailure, RuleServices | Scope.Scope> {
34
+ const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
35
+
34
36
  const inventory = yield* setup(collectInventory(config.root, config));
35
37
  const readText = yield* manifestReader(config.root);
36
38
  setManifestFiles(readText, inventory.manifestFiles);
@@ -1,5 +1,5 @@
1
- import { basename, dirname, join, relative } from "node:path";
2
- import { Console, Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, FileSystem, Path } from "effect";
3
3
  import { CONFIG_FILE } from "#config/constants.ts";
4
4
  import { loadConfig } from "#config/load.ts";
5
5
  import { SetupFailure } from "#failure.ts";
@@ -28,6 +28,8 @@ const realPath = Effect.fnUntraced(function* (path: string) {
28
28
  });
29
29
 
30
30
  const write = Effect.fnUntraced(function* (file: string, text: string) {
31
+ const { dirname } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
32
+
31
33
  const fs = yield* FileSystem.FileSystem;
32
34
  yield* fs.makeDirectory(dirname(file), { recursive: true }).pipe(
33
35
  Effect.andThen(fs.writeFileString(file, text)),
@@ -37,6 +39,8 @@ const write = Effect.fnUntraced(function* (file: string, text: string) {
37
39
  });
38
40
 
39
41
  export const installHook = Effect.fn("Hooks.installHook")(function* (install: HookInstall) {
42
+ const { basename, dirname, join, relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
43
+
40
44
  const config = yield* loadConfig(install.cwd, install.config);
41
45
  const location = yield* hookLocation(config.root);
42
46
  const root = yield* realPath(config.root);
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Effect } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, Path } from "effect";
3
3
  import { SetupFailure } from "#failure.ts";
4
4
  import { run } from "#git/command.ts";
5
5
 
@@ -11,6 +11,8 @@ export interface HookLocation {
11
11
 
12
12
  // Hooks live in the common git directory, which every worktree of the repository shares.
13
13
  export const hookLocation = Effect.fn("Hooks.hookLocation")(function* (cwd: string) {
14
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
15
+
14
16
  const paths = yield* run(cwd, ["rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir"]);
15
17
  const [toplevel, common] = paths.stdout.trim().split("\n");
16
18
  if (paths.code !== 0 || toplevel === undefined || common === undefined) {
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
- import { Console, Effect } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, Path } from "effect";
3
3
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
4
  import { readPackageManifest } from "#adapters/manifestInventory.ts";
5
5
  import { manifestReader } from "#adapters/manifestReader.ts";
@@ -11,6 +11,8 @@ const COMMIT_AGAIN =
11
11
  "help: fix what the output above reports, then commit again; `quality hooks pre-commit` repeats these checks without committing.";
12
12
 
13
13
  const commitScripts = Effect.fnUntraced(function* (root: string) {
14
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
15
+
14
16
  const file = join(root, "package.json");
15
17
  const readText = yield* manifestReader(root);
16
18
  const manifest = yield* Effect.tryPromise({
@@ -1,8 +1,10 @@
1
- import { join } from "node:path";
2
- import { Effect, FileSystem } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Effect, FileSystem, Path } from "effect";
3
3
  import { type HookInstall, installHook } from "./install.ts";
4
4
 
5
5
  export const setupHook = Effect.fn("Hooks.setupHook")(function* (options: Omit<HookInstall, "force">) {
6
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
7
+
6
8
  const fs = yield* FileSystem.FileSystem;
7
9
  if (yield* fs.exists(join(options.cwd, ".git"))) {
8
10
  yield* installHook({ ...options, force: false });
@@ -1,7 +1,6 @@
1
- import { constants } from "node:fs";
2
- import { access, realpath } from "node:fs/promises";
3
- import { dirname, resolve } from "node:path";
4
- import { Console, Effect } from "effect";
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, Path } from "effect";
3
+ import { executable } from "#adapters/executable.ts";
5
4
  import { GateFailed, SetupFailure } from "#failure.ts";
6
5
  import { gitOrFail } from "#git/command.ts";
7
6
  import { readOptionalText } from "#inventory/filesystem.ts";
@@ -9,18 +8,9 @@ import { forwardingPath, globalHooksPath } from "./forwarding.ts";
9
8
  import { type HookLocation, hookLocation } from "./location.ts";
10
9
  import { isHookShim } from "./shim.ts";
11
10
 
12
- function executable(file: string) {
13
- return Effect.promise(async () => {
14
- try {
15
- await access(file, constants.X_OK);
16
- return await realpath(file);
17
- } catch {
18
- return undefined;
19
- }
20
- });
21
- }
22
-
23
11
  export const globalHookStatus = Effect.fn("Hooks.globalHookStatus")(function* (location: HookLocation) {
12
+ const { resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
13
+
24
14
  const path = yield* globalHooksPath(location.toplevel);
25
15
  const hook = resolve(location.toplevel, path, "pre-commit");
26
16
  const target = path === "" ? undefined : yield* executable(hook);
@@ -33,6 +23,8 @@ export const globalHookStatus = Effect.fn("Hooks.globalHookStatus")(function* (l
33
23
  });
34
24
 
35
25
  export const hookStatus = Effect.fn("Hooks.hookStatus")(function* (cwd: string) {
26
+ const { dirname, resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
27
+
36
28
  const location = yield* hookLocation(cwd);
37
29
  const path = (yield* gitOrFail(cwd, ["rev-parse", "--path-format=absolute", "--git-path", "hooks/pre-commit"])).trim();
38
30
  const text = yield* readOptionalText(path).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));