dump-config-check.mjs 1.0 KB

123456789101112131415161718192021
  1. import assert from 'node:assert/strict'
  2. import fs from 'node:fs'
  3. import path from 'node:path'
  4. import { fileURLToPath } from 'node:url'
  5. import { parse } from 'yaml'
  6. import { thinScripts } from './artifact-contract.mjs'
  7. const root = fileURLToPath(new URL('../', import.meta.url))
  8. const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
  9. assert.deepEqual(parse(fs.readFileSync(path.join(root, 'cordis.patch.yml'), 'utf8')), [
  10. { insert: [{ id: 'webnovel', name: manifest.name }] },
  11. ])
  12. assert.equal(manifest.dsh.bundle.patch, './cordis.patch.yml')
  13. const lib = fs.readFileSync(path.join(root, 'lib/index.js'), 'utf8')
  14. for (const [relative, name] of thinScripts) {
  15. const text = fs.readFileSync(path.join(root, relative), 'utf8')
  16. assert.ok(text.includes('lib/index.js'), relative)
  17. assert.ok(!/from\s*["']@webnovel\//.test(text), relative)
  18. assert.ok(lib.includes(name), `${name} missing from built library`)
  19. }
  20. console.log(`[bundle] config and ${thinScripts.length} installed script entrypoints: ok`)