@orkestrel/scaffold 0.0.20 → 0.0.21

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.
@@ -18,6 +18,7 @@ export const CENTRAL_SOURCE_FILES: readonly string[] = Object.freeze([
18
18
  'middlewares.ts',
19
19
  'parsers.ts',
20
20
  'relations.ts',
21
+ 'routes.ts',
21
22
  'schemas.ts',
22
23
  'seeders.ts',
23
24
  'shapers.ts',
@@ -39,6 +40,7 @@ export const FUNCTION_SOURCE_FILES: readonly string[] = Object.freeze([
39
40
  'middlewares.ts',
40
41
  'parsers.ts',
41
42
  'relations.ts',
43
+ 'routes.ts',
42
44
  'schemas.ts',
43
45
  'seeders.ts',
44
46
  'shapers.ts',
@@ -51,6 +53,7 @@ export const DATA_SOURCE_FILES: readonly string[] = Object.freeze([
51
53
  'constants.ts',
52
54
  'contracts.ts',
53
55
  'relations.ts',
56
+ 'routes.ts',
54
57
  'schemas.ts',
55
58
  'shapers.ts',
56
59
  'templates.ts',
@@ -90,6 +93,22 @@ export const WORKER_SCOPE_VALUE_GLOBALS: readonly string[] = Object.freeze([
90
93
  'removeEventListener',
91
94
  ])
92
95
 
96
+ /** Source extensions inspected by the repository coding-law sweep. */
97
+ export const CODING_SOURCE_EXTENSIONS: readonly string[] = Object.freeze([
98
+ 'cjs',
99
+ 'cts',
100
+ 'js',
101
+ 'jsx',
102
+ 'mjs',
103
+ 'mts',
104
+ 'ts',
105
+ 'tsx',
106
+ 'vue',
107
+ ])
108
+
109
+ /** Production-source glob derived from the complete inspected extension vocabulary. */
110
+ export const CODING_SOURCE_GLOB = `{app,src}/**/*.{${CODING_SOURCE_EXTENSIONS.join(',')}}`
111
+
93
112
  /** Virtual source text used while binding one policy-inspected module. */
94
113
  export const POLICY_SOURCE_TEXTS: Map<string, string> = new Map()
95
114
 
@@ -109,6 +128,17 @@ export function normalizePolicyPath(path: string): string {
109
128
  return path.replaceAll('\\', '/').replace(/\/+/gu, '/')
110
129
  }
111
130
 
131
+ /** Whether a path belongs to the production-source coding-law corpus. */
132
+ export function isCodingSourcePath(path: string): boolean {
133
+ const normalized = normalizePolicyPath(path)
134
+ const extension = normalized.split('.').pop()
135
+ return (
136
+ (normalized.startsWith('app/') || normalized.startsWith('src/')) &&
137
+ extension !== undefined &&
138
+ CODING_SOURCE_EXTENSIONS.includes(extension)
139
+ )
140
+ }
141
+
112
142
  /** Whether a declaration carries an explicit export modifier. */
113
143
  export function hasExportModifier(node: ts.Node): boolean {
114
144
  return (
@@ -416,6 +446,22 @@ export function inspectVueCodingLaw(
416
446
  return violations
417
447
  }
418
448
 
449
+ /** Inspect one production source through the shared coding-law route. */
450
+ export function inspectCodingSource(
451
+ path: string,
452
+ content: string,
453
+ vueScripts?: VueScriptExtractorInterface,
454
+ ): readonly string[] {
455
+ const normalizedPath = normalizePolicyPath(path)
456
+ if (!normalizedPath.endsWith('.vue')) return inspectCodingLaw(normalizedPath, content)
457
+ const violations: string[] = []
458
+ if (!normalizedPath.startsWith('app/browser/')) {
459
+ violations.push(`${normalizedPath} Vue components belong in app/browser`)
460
+ }
461
+ violations.push(...inspectVueCodingLaw(normalizedPath, vueScripts?.(normalizedPath, content)))
462
+ return violations
463
+ }
464
+
419
465
  /** Add syntax-wide coding-law violations while traversing one source tree. */
420
466
  export function inspectCodingNode(
421
467
  path: string,
@@ -627,25 +673,17 @@ export function inspectCodingLaw(path: string, content: string): readonly string
627
673
  return violations
628
674
  }
629
675
 
630
- /** Inspect every production TypeScript module under one workspace. */
676
+ /** Inspect every production source under one workspace. */
631
677
  export function inspectCodingWorkspace(
632
678
  root: string,
633
679
  vueScripts?: VueScriptExtractorInterface,
634
680
  ): readonly string[] {
635
681
  const violations: string[] = []
636
- for (const path of globSync('{app,src}/**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx,vue}', {
682
+ for (const path of globSync(CODING_SOURCE_GLOB, {
637
683
  cwd: root,
638
684
  })) {
639
685
  const content = readFileSync(join(root, path), 'utf8')
640
- const normalizedPath = normalizePolicyPath(path)
641
- if (path.endsWith('.vue') && !normalizedPath.startsWith('app/browser/')) {
642
- violations.push(`${normalizedPath} Vue components belong in app/browser`)
643
- }
644
- violations.push(
645
- ...(path.endsWith('.vue')
646
- ? inspectVueCodingLaw(normalizedPath, vueScripts?.(normalizedPath, content))
647
- : inspectCodingLaw(normalizedPath, content)),
648
- )
686
+ violations.push(...inspectCodingSource(path, content, vueScripts))
649
687
  }
650
688
  return violations
651
689
  }