| 12345678910111213141516171819202122232425 |
- import { readFileSync } from 'node:fs'
- import { fileURLToPath } from 'node:url'
- import { dirname, resolve } from 'node:path'
- import { JSDOM, VirtualConsole } from 'jsdom'
- const HERE = dirname(fileURLToPath(import.meta.url))
- const portal = resolve(HERE, '../../../release/web/portal')
- const shell = readFileSync(portal + '/shell.html', 'utf8')
- const ids = Array.from(shell.matchAll(/<!--@TEMPLATE:([^>]+?)-->/g)).map((m) => m[1])
- let s = shell
- for (const id of ids) {
- const body = readFileSync(portal + '/templates/' + id + '.html', 'utf8')
- s = s.replace('<!--@TEMPLATE:' + id + '-->', '<template id="' + id + '">' + body + '</template>')
- }
- const gs = readFileSync(portal + '/governance_sources.json', 'utf8')
- s = s.replace('<!--@GOVERNANCE_SOURCES-->', gs.replace(/</g, '\\u003c'))
- const dom = new JSDOM(s, { virtualConsole: new VirtualConsole() })
- const d = dom.window.document
- const bodyText = (d.body ? d.body.textContent : '').replace(/\s+/g, ' ')
- console.log('IDS ' + ids.length)
- console.log('LEFT_MARKERS ' + (s.match(/<!--@TEMPLATE:/g) || []).length)
- console.log('TPL_ELEMENTS ' + d.querySelectorAll('template[id]').length)
- console.log('TITLE ' + d.title)
- console.log('BODY_HAS_MARKUP_TEXT ' + /utf-8|<!DOCTYPE|:root\{/.test(bodyText))
- console.log('BODY_TEXT_HEAD ' + bodyText.slice(0, 160))
|