优化
This commit is contained in:
@@ -6,6 +6,8 @@ import { fileURLToPath } from 'node:url'
|
||||
|
||||
const repositoryRoot = path.resolve(fileURLToPath(new URL('..', import.meta.url)))
|
||||
const scriptsReadme = path.join(repositoryRoot, 'scripts', 'README.md')
|
||||
const adminModulesReadme = path.join(repositoryRoot, 'scripts', 'admin-test-env-modules', 'README.md')
|
||||
const adminAcceptanceEntry = path.join(repositoryRoot, 'scripts', 'admin-test-env-acceptance.mjs')
|
||||
const excludedDirectoryNames = new Set([
|
||||
'.git', '.logs', 'dist', 'node_modules', 'output', 'outputs', 'reports', 'target', 'uni_modules',
|
||||
])
|
||||
@@ -79,3 +81,19 @@ test('README explains internal modules and test scripts are not standalone entri
|
||||
assert.match(readme, /admin-test-env-modules\/\*\.mjs.*逐模块说明/)
|
||||
assert.match(readme, /warehouse\/scripts\/warehouse-public-master-data-contract\.test\.mjs/)
|
||||
})
|
||||
|
||||
test('all Admin acceptance modules are documented in the module index', async () => {
|
||||
const [entrySource, readme] = await Promise.all([
|
||||
readFile(adminAcceptanceEntry, 'utf8'),
|
||||
readFile(adminModulesReadme, 'utf8'),
|
||||
])
|
||||
const registeredModules = []
|
||||
for (const list of entrySource.matchAll(/const (?:CONFIGURED|OPTIONAL)_MODULES = \[([\s\S]*?)\]/g)) {
|
||||
for (const moduleName of list[1].matchAll(/'([^']+)'/g)) registeredModules.push(moduleName[1])
|
||||
}
|
||||
|
||||
assert.notEqual(registeredModules.length, 0, '未从 Admin 全量入口读取到模块注册表')
|
||||
const undocumented = [...new Set(registeredModules)]
|
||||
.filter((moduleName) => !readme.includes(`\`${moduleName}.mjs\``))
|
||||
assert.deepEqual(undocumented, [], `以下 Admin 验收模块未登记用途与边界:\n${undocumented.join('\n')}`)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user