fix(ci): ignore translation records in Cordis config scan
The Loader verifier matched docs/cordis-primer.i18n.yaml solely because its basename contained cordis. Centralize file discovery, exclude i18n sidecars, and cover Loader YAML plus excluded trees with a regression test.
This commit is contained in:
@@ -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',
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -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 * as yaml from 'js-yaml'
|
||||
import ts from 'typescript'
|
||||
import { cordisConfigFiles } from './cordis-config-files.ts'
|
||||
|
||||
interface JsExpr {
|
||||
__jsExpr: string
|
||||
@@ -39,10 +40,7 @@ const jsExprType = new yaml.Type('tag:yaml.org,2002:js', {
|
||||
})
|
||||
const schema = yaml.JSON_SCHEMA.extend(jsExprType)
|
||||
|
||||
const files = globSync(['**/*cordis*.yml', '**/*cordis*.yaml'], {
|
||||
cwd: root,
|
||||
exclude: ['.claude/**', 'node_modules/**', 'vendor/**'],
|
||||
}).sort()
|
||||
const files = cordisConfigFiles(root)
|
||||
const errors: string[] = []
|
||||
const examplePluginReferences: PluginReference[] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user