@standards-kit/conform 0.3.2 → 0.4.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 (38) hide show
  1. package/dist/{chunk-AJIWBLUQ.js → chunk-HLF56NMK.js} +2 -2
  2. package/dist/{chunk-HMNRMNEA.js → chunk-RR4OEIAZ.js} +2 -2
  3. package/dist/{chunk-HMNRMNEA.js.map → chunk-RR4OEIAZ.js.map} +1 -1
  4. package/dist/{chunk-UU6OT5O3.js → chunk-ZKFWS3GU.js} +16 -10
  5. package/dist/chunk-ZKFWS3GU.js.map +1 -0
  6. package/dist/cli.js +53 -21
  7. package/dist/cli.js.map +1 -1
  8. package/dist/code/tools/base.d.ts +4 -2
  9. package/dist/core/schema.d.ts +1 -0
  10. package/dist/{core-SAQ5O5IL.js → core-HQ7WZCSW.js} +3 -3
  11. package/dist/{iam-ZV3RA3JZ.js → iam-363WGRLI.js} +2 -2
  12. package/dist/index.js +44 -12
  13. package/dist/index.js.map +1 -1
  14. package/dist/{infra-OWKYLH3J.js → infra-CHHXGSWU.js} +5 -5
  15. package/dist/mcp/index.d.ts +1 -1
  16. package/dist/{mcp-6PRCC6P6.js → mcp-RPYXEVCR.js} +4 -4
  17. package/dist/process/tools/hooks.d.ts +3 -0
  18. package/dist/{registry-QYUYWBMY.js → registry-7CTKYGKA.js} +3 -3
  19. package/dist/{s3-3DJX6X5S.js → s3-7GRZRXLA.js} +4 -4
  20. package/dist/{s3-6YMTP5VV.js → s3-MFBDXYQ5.js} +4 -4
  21. package/dist/{scan-5QKYVHI6.js → scan-S5VYRCPC.js} +4 -4
  22. package/dist/{standards-EGSQSDOD.js → standards-CASOIZJV.js} +3 -3
  23. package/dist/{sync-QMZDAV44.js → sync-PT6KT46K.js} +3 -3
  24. package/dist/{validate-OGNSVZO5.js → validate-WLVATJEZ.js} +4 -4
  25. package/package.json +1 -1
  26. package/dist/chunk-UU6OT5O3.js.map +0 -1
  27. /package/dist/{chunk-AJIWBLUQ.js.map → chunk-HLF56NMK.js.map} +0 -0
  28. /package/dist/{core-SAQ5O5IL.js.map → core-HQ7WZCSW.js.map} +0 -0
  29. /package/dist/{iam-ZV3RA3JZ.js.map → iam-363WGRLI.js.map} +0 -0
  30. /package/dist/{infra-OWKYLH3J.js.map → infra-CHHXGSWU.js.map} +0 -0
  31. /package/dist/{mcp-6PRCC6P6.js.map → mcp-RPYXEVCR.js.map} +0 -0
  32. /package/dist/{registry-QYUYWBMY.js.map → registry-7CTKYGKA.js.map} +0 -0
  33. /package/dist/{s3-3DJX6X5S.js.map → s3-7GRZRXLA.js.map} +0 -0
  34. /package/dist/{s3-6YMTP5VV.js.map → s3-MFBDXYQ5.js.map} +0 -0
  35. /package/dist/{scan-5QKYVHI6.js.map → scan-S5VYRCPC.js.map} +0 -0
  36. /package/dist/{standards-EGSQSDOD.js.map → standards-CASOIZJV.js.map} +0 -0
  37. /package/dist/{sync-QMZDAV44.js.map → sync-PT6KT46K.js.map} +0 -0
  38. /package/dist/{validate-OGNSVZO5.js.map → validate-WLVATJEZ.js.map} +0 -0
@@ -9,11 +9,13 @@ export declare abstract class BaseToolRunner implements IToolRunner {
9
9
  abstract readonly toolId: string;
10
10
  abstract readonly configFiles: string[];
11
11
  /**
12
- * Check if any of the config files exist
12
+ * Check if any of the config files exist in projectRoot or parent directories.
13
+ * Most tools (ESLint, TSC, etc.) walk up directories to find configs.
13
14
  */
14
15
  protected hasConfig(projectRoot: string): boolean;
15
16
  /**
16
- * Find which config file exists (if any)
17
+ * Find which config file exists, searching projectRoot and parent directories.
18
+ * Returns the path relative to the directory where it was found, or null.
17
19
  */
18
20
  protected findConfig(projectRoot: string): string | null;
19
21
  /**
@@ -154,6 +154,7 @@ export declare const configSchema: z.ZodObject<{
154
154
  require_hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
155
155
  commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
156
156
  protected_branches: z.ZodOptional<z.ZodArray<z.ZodString>>;
157
+ templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
157
158
  }, z.core.$strict>>;
158
159
  ci: z.ZodOptional<z.ZodObject<{
159
160
  enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -15,8 +15,8 @@ import {
15
15
  loadConfig,
16
16
  loadConfigAsync,
17
17
  loadConfigWithOverrides
18
- } from "./chunk-UU6OT5O3.js";
19
- import "./chunk-HMNRMNEA.js";
18
+ } from "./chunk-ZKFWS3GU.js";
19
+ import "./chunk-RR4OEIAZ.js";
20
20
  export {
21
21
  CONFIG_FILE_NAME,
22
22
  CheckResultBuilder,
@@ -33,4 +33,4 @@ export {
33
33
  loadConfigAsync,
34
34
  loadConfigWithOverrides
35
35
  };
36
- //# sourceMappingURL=core-SAQ5O5IL.js.map
36
+ //# sourceMappingURL=core-HQ7WZCSW.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AWS_DEFAULTS
3
- } from "./chunk-HMNRMNEA.js";
3
+ } from "./chunk-RR4OEIAZ.js";
4
4
 
5
5
  // src/infra/checkers/iam.ts
6
6
  import { GetPolicyCommand, GetRoleCommand, IAMClient } from "@aws-sdk/client-iam";
@@ -97,4 +97,4 @@ async function checkPolicy(policyArn) {
97
97
  export {
98
98
  IAMChecker
99
99
  };
100
- //# sourceMappingURL=iam-ZV3RA3JZ.js.map
100
+ //# sourceMappingURL=iam-363WGRLI.js.map
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  getProjectRoot,
27
27
  loadConfig,
28
28
  loadConfigAsync
29
- } from "./chunk-UU6OT5O3.js";
29
+ } from "./chunk-ZKFWS3GU.js";
30
30
  import {
31
31
  AccountIdSchema,
32
32
  AccountKeySchema,
@@ -78,26 +78,34 @@ import {
78
78
  GITHUB_API,
79
79
  STANDARDS_REPO,
80
80
  TIMEOUTS
81
- } from "./chunk-HMNRMNEA.js";
81
+ } from "./chunk-RR4OEIAZ.js";
82
82
 
83
83
  // src/code/tools/base.ts
84
84
  import * as fs from "fs";
85
85
  import * as path from "path";
86
86
  var BaseToolRunner = class {
87
87
  /**
88
- * Check if any of the config files exist
88
+ * Check if any of the config files exist in projectRoot or parent directories.
89
+ * Most tools (ESLint, TSC, etc.) walk up directories to find configs.
89
90
  */
90
91
  hasConfig(projectRoot) {
91
- return this.configFiles.some((config) => fs.existsSync(path.join(projectRoot, config)));
92
+ return this.findConfig(projectRoot) !== null;
92
93
  }
93
94
  /**
94
- * Find which config file exists (if any)
95
+ * Find which config file exists, searching projectRoot and parent directories.
96
+ * Returns the path relative to the directory where it was found, or null.
95
97
  */
96
98
  findConfig(projectRoot) {
97
- for (const config of this.configFiles) {
98
- if (fs.existsSync(path.join(projectRoot, config))) {
99
- return config;
99
+ let dir = path.resolve(projectRoot);
100
+ const root = path.parse(dir).root;
101
+ while (true) {
102
+ for (const config of this.configFiles) {
103
+ if (fs.existsSync(path.join(dir, config))) {
104
+ return dir === path.resolve(projectRoot) ? config : path.join(dir, config);
105
+ }
100
106
  }
107
+ if (dir === root) break;
108
+ dir = path.dirname(dir);
101
109
  }
102
110
  return null;
103
111
  }
@@ -5169,6 +5177,28 @@ var HooksRunner = class extends BaseProcessToolRunner {
5169
5177
  (pattern) => this.fileContains(projectRoot, hookPath, pattern)
5170
5178
  );
5171
5179
  }
5180
+ /** Check that hook files match expected template content */
5181
+ checkHookTemplates(projectRoot) {
5182
+ const templates = this.config.templates ?? {};
5183
+ const violations = [];
5184
+ for (const [hook, expectedContent] of Object.entries(templates)) {
5185
+ const hookPath = `.husky/${hook}`;
5186
+ const actual = this.readFile(projectRoot, hookPath);
5187
+ if (actual === null) {
5188
+ continue;
5189
+ }
5190
+ if (actual.trim() !== expectedContent.trim()) {
5191
+ violations.push({
5192
+ rule: `${this.rule}.${hook}.template`,
5193
+ tool: this.toolId,
5194
+ file: hookPath,
5195
+ message: `Hook '${hook}' does not match expected template`,
5196
+ severity: "error"
5197
+ });
5198
+ }
5199
+ }
5200
+ return violations;
5201
+ }
5172
5202
  /** Check that pre-push hook prevents direct pushes to protected branches */
5173
5203
  checkProtectedBranches(projectRoot) {
5174
5204
  const protectedBranches = this.config.protected_branches ?? [];
@@ -5210,6 +5240,7 @@ var HooksRunner = class extends BaseProcessToolRunner {
5210
5240
  const violations = [
5211
5241
  ...this.checkRequiredHooks(projectRoot),
5212
5242
  ...this.checkHookCommands(projectRoot),
5243
+ ...this.checkHookTemplates(projectRoot),
5213
5244
  ...this.checkProtectedBranches(projectRoot)
5214
5245
  ];
5215
5246
  return this.fromViolations(violations, elapsed());
@@ -5921,7 +5952,8 @@ function createHooksRunner(config) {
5921
5952
  require_husky: hooksConfig.require_husky,
5922
5953
  require_hooks: hooksConfig.require_hooks,
5923
5954
  commands: hooksConfig.commands,
5924
- protected_branches: hooksConfig.protected_branches
5955
+ protected_branches: hooksConfig.protected_branches,
5956
+ templates: hooksConfig.templates
5925
5957
  });
5926
5958
  }
5927
5959
  return runner;
@@ -6663,7 +6695,7 @@ async function scanRepository(repo, config) {
6663
6695
  return aggregateResults(repoInfo, [rulesetsResult, filesResult]);
6664
6696
  }
6665
6697
  async function validateProcess(options) {
6666
- const { loadConfigAsync: loadConfigAsync2 } = await import("./core-SAQ5O5IL.js");
6698
+ const { loadConfigAsync: loadConfigAsync2 } = await import("./core-HQ7WZCSW.js");
6667
6699
  const { config } = await loadConfigAsync2(options.config);
6668
6700
  const result = await scanRepository(options.repo, config);
6669
6701
  const fs22 = await import("fs");
@@ -7636,12 +7668,12 @@ function isSupportedService(service) {
7636
7668
  return SUPPORTED_SERVICES.includes(service);
7637
7669
  }
7638
7670
  var checkerFactories = {
7639
- s3: async () => (await import("./s3-3DJX6X5S.js")).S3Checker,
7671
+ s3: async () => (await import("./s3-MFBDXYQ5.js")).S3Checker,
7640
7672
  lambda: async () => (await import("./lambda-YTJOCYV5.js")).LambdaChecker,
7641
7673
  dynamodb: async () => (await import("./dynamodb-HQH3IMAI.js")).DynamoDBChecker,
7642
7674
  sqs: async () => (await import("./sqs-MHBW6UFC.js")).SQSChecker,
7643
7675
  sns: async () => (await import("./sns-RV64OMK2.js")).SNSChecker,
7644
- iam: async () => (await import("./iam-ZV3RA3JZ.js")).IAMChecker,
7676
+ iam: async () => (await import("./iam-363WGRLI.js")).IAMChecker,
7645
7677
  secretsmanager: async () => (await import("./secretsmanager-FJKTPIXI.js")).SecretsManagerChecker,
7646
7678
  logs: async () => (await import("./cloudwatch-3LTDYG6G.js")).CloudWatchLogsChecker,
7647
7679
  ecs: async () => (await import("./ecs-UHKCH5A7.js")).ECSChecker,