Merge branch 'worktree/pr343-retarget-latest-master' into worktree/pr344-retarget-stack
This commit is contained in:
36
scripts/cordis-config-files.spec.ts
Normal file
36
scripts/cordis-config-files.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
||||||
|
import { tmpdir } from 'node:os'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
import { afterEach, describe, expect, it } from 'vitest'
|
||||||
|
import { cordisConfigFiles } from './cordis-config-files.ts'
|
||||||
|
|
||||||
|
const roots: string[] = []
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('cordisConfigFiles', () => {
|
||||||
|
it('finds Loader YAML without treating translation records as configs', () => {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), 'dsh-cordis-config-files-'))
|
||||||
|
roots.push(root)
|
||||||
|
for (const directory of ['.claude', 'docs', 'examples', 'node_modules/pkg', 'vendor/pkg']) {
|
||||||
|
mkdirSync(join(root, directory), { recursive: true })
|
||||||
|
}
|
||||||
|
for (const file of [
|
||||||
|
'.claude/hidden.cordis.yml',
|
||||||
|
'docs/cordis-primer.i18n.yaml',
|
||||||
|
'examples/agent.cordis.yaml',
|
||||||
|
'examples/headless.cordis.yml',
|
||||||
|
'node_modules/pkg/hidden.cordis.yml',
|
||||||
|
'vendor/pkg/hidden.cordis.yml',
|
||||||
|
]) {
|
||||||
|
writeFileSync(join(root, file), '[]\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(cordisConfigFiles(root)).toEqual([
|
||||||
|
'examples/agent.cordis.yaml',
|
||||||
|
'examples/headless.cordis.yml',
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
18
scripts/cordis-config-files.ts
Normal file
18
scripts/cordis-config-files.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/** Cordis Loader configuration file discovery. */
|
||||||
|
|
||||||
|
import { globSync } from 'node:fs'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return repository-relative Cordis Loader YAML paths under `root`.
|
||||||
|
*
|
||||||
|
* Translation consistency records are YAML sidecars, never Loader inputs.
|
||||||
|
*
|
||||||
|
* @param root Repository root to scan.
|
||||||
|
* @returns Sorted repository-relative Loader configuration paths.
|
||||||
|
*/
|
||||||
|
export function cordisConfigFiles(root: string): string[] {
|
||||||
|
return globSync(['**/*cordis*.yml', '**/*cordis*.yaml'], {
|
||||||
|
cwd: root,
|
||||||
|
exclude: ['.claude/**', 'node_modules/**', 'vendor/**', '**/*.i18n.yaml'],
|
||||||
|
}).sort()
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import { globSync, readFileSync } from 'node:fs'
|
|||||||
import { dirname, relative, resolve } from 'node:path'
|
import { dirname, relative, resolve } from 'node:path'
|
||||||
import * as yaml from 'js-yaml'
|
import * as yaml from 'js-yaml'
|
||||||
import ts from 'typescript'
|
import ts from 'typescript'
|
||||||
|
import { cordisConfigFiles } from './cordis-config-files.ts'
|
||||||
|
|
||||||
interface JsExpr {
|
interface JsExpr {
|
||||||
__jsExpr: string
|
__jsExpr: string
|
||||||
@@ -39,10 +40,7 @@ const jsExprType = new yaml.Type('tag:yaml.org,2002:js', {
|
|||||||
})
|
})
|
||||||
const schema = yaml.JSON_SCHEMA.extend(jsExprType)
|
const schema = yaml.JSON_SCHEMA.extend(jsExprType)
|
||||||
|
|
||||||
const files = globSync(['**/*cordis*.yml', '**/*cordis*.yaml'], {
|
const files = cordisConfigFiles(root)
|
||||||
cwd: root,
|
|
||||||
exclude: ['.claude/**', 'node_modules/**', 'vendor/**'],
|
|
||||||
}).sort()
|
|
||||||
const errors: string[] = []
|
const errors: string[] = []
|
||||||
const examplePluginReferences: PluginReference[] = []
|
const examplePluginReferences: PluginReference[] = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user