63 lines
4.7 KiB
JavaScript
63 lines
4.7 KiB
JavaScript
// Verifies the independent dsh-brain Mnemon fork snapshot and the active
|
|
// provider-SDK adapter. Runs without installing the upstream package.
|
|
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
const root = process.cwd()
|
|
const vendor = join(root, 'vendor', 'dsh-mnemon')
|
|
const results = []
|
|
function check(name, ok, detail = '') {
|
|
results.push({ name, ok })
|
|
console.log((ok ? 'PASS ' : 'FAIL ') + name + (detail ? ' :: ' + detail : ''))
|
|
}
|
|
function json(path) { return JSON.parse(readFileSync(path, 'utf8')) }
|
|
|
|
check('vendor fork directory exists', existsSync(vendor))
|
|
const pkg = json(join(vendor, 'package.json'))
|
|
check('fork package has its own name', pkg.name === 'dsh-brain-mnemon', pkg.name)
|
|
check('fork package has a fork version', pkg.version === '0.5.54-dsh.1', pkg.version)
|
|
check('fork package is private', pkg.private === true)
|
|
check('fork records the upstream revision', pkg.dshBrainFork?.upstreamRevision === '8b650ab5ef33522e03887b250b13336593daa26f')
|
|
check('fork keeps the upstream repository URL', String(pkg.repository?.url || '').includes('omdsh-dev/dsh-mnemon'))
|
|
check('fork keeps MIT license metadata', pkg.license === 'MIT')
|
|
check('fork license file keeps the upstream notice', existsSync(join(vendor, 'LICENSE')) && readFileSync(join(vendor, 'LICENSE'), 'utf8').includes('MIT License') && readFileSync(join(vendor, 'LICENSE'), 'utf8').includes('dsh-external contributors'))
|
|
check('fork has a provenance notice', existsSync(join(vendor, 'FORK_NOTICE.md')) && readFileSync(join(vendor, 'FORK_NOTICE.md'), 'utf8').includes('8b650ab5ef33522e03887b250b13336593daa26f'))
|
|
check('fork keeps the full runtime layout', ['src/core', 'src/host', 'src/client', 'src/sdk', 'plugins'].every((path) => existsSync(join(vendor, path))))
|
|
const pluginRoot = join(vendor, 'plugins')
|
|
const pluginDirs = readdirSync(pluginRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name)
|
|
check('every plugin directory is renamed', pluginDirs.length === 18 && pluginDirs.every((name) => name.startsWith('dsh-brain-mnemon-')))
|
|
const pluginPackages = pluginDirs.map((name) => json(join(pluginRoot, name, 'package.json')))
|
|
check('every plugin package is renamed', pluginPackages.every((entry) => entry.name.startsWith('dsh-brain-mnemon-')))
|
|
check('fork keeps all upstream plugins', pluginDirs.some((name) => name.endsWith('source-memory-spaces')) && pluginDirs.some((name) => name.endsWith('provider-mnemon-native')) && pluginDirs.filter((name) => name.includes('strategy-')).length === 5)
|
|
const patch = readFileSync(join(vendor, 'cordis.patch.yml'), 'utf8')
|
|
check('bundle entry name is renamed', patch.includes('name: dsh-brain-mnemon/bundle'))
|
|
check('bundle entry id is renamed', patch.includes('id: dsh-brain-mnemon-bundle'))
|
|
check('core entry id is renamed', patch.includes('id: dsh-brain-mnemon') && !patch.includes('id: mnemon\n'))
|
|
const dependencies = pkg.dependencies || {}
|
|
check('fork dependencies point at renamed workspace packages', Object.keys(dependencies).filter((name) => name.includes('mnemon')).every((name) => name.startsWith('dsh-brain-mnemon-')))
|
|
|
|
const activeFork = join(root, 'src', 'mnemon', 'fork')
|
|
const files = ['contracts.ts', 'provider-sdk.ts', 'providers/adapter.ts', 'providers/definitions.ts', 'providers/http.ts', 'providers/process.ts', 'LICENSE', 'README.md']
|
|
check('active provider SDK fork is complete', files.every((file) => existsSync(join(activeFork, file))))
|
|
for (const file of ['index.ts', 'descriptor.ts', 'driver.ts']) {
|
|
const source = readFileSync(join(root, 'src', 'mnemon', file), 'utf8')
|
|
check('src/mnemon/' + file + ' uses the local fork', source.includes('./fork/provider-sdk') && !source.includes('dsh-mnemon-source-memory-spaces'))
|
|
}
|
|
const sourceFiles = readdirSync(join(root, 'src'), { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile() && /\.[cm]?[jt]sx?$/.test(entry.name))
|
|
const packageRefs = sourceFiles.filter((entry) => {
|
|
const path = join(entry.parentPath || entry.path || '', entry.name)
|
|
return /(?:from\s*|import\s*\()['"]dsh-mnemon-source-memory-spaces/.test(readFileSync(path, 'utf8'))
|
|
})
|
|
check('no source imports the upstream memory-spaces package', packageRefs.length === 0)
|
|
const rootPkg = json(join(root, 'package.json'))
|
|
const rootDeps = { ...(rootPkg.dependencies || {}), ...(rootPkg.devDependencies || {}), ...(rootPkg.peerDependencies || {}) }
|
|
check('dsh-brain package has no upstream Mnemon dependency', !Object.keys(rootDeps).some((name) => name.startsWith('dsh-mnemon')))
|
|
|
|
const failed = results.filter((result) => !result.ok)
|
|
console.log('')
|
|
if (failed.length) {
|
|
console.log('FAILED ' + failed.length + '/' + results.length + ': ' + failed.map((result) => result.name).join(', '))
|
|
process.exit(1)
|
|
}
|
|
console.log('ALL ' + results.length + ' CHECKS PASSED')
|