Files

25 lines
1.3 KiB
JavaScript

// The core team's persona files, as strings the package ships.
//
// @hanzo/personas publishes each member as markdown (team/<id>.md), and the app
// used to inline them through a webpack asset rule — a rule every host would
// have to repeat to mount the rooms. Read here instead, from the pinned
// package, and written to src/team.gen.ts, so a persona changes when the pin
// moves and no host configures anything.
import { readFileSync, writeFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const require = createRequire(import.meta.url)
const root = dirname(require.resolve('@hanzo/personas/team.js'))
const IDS = ['dev', 'des', 'vi', 'feynman', 'einstein', 'nora', 'maya', 'leo']
const { version } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
const body = IDS.map((id) => ` ${id}: ${JSON.stringify(readFileSync(join(root, 'team', `${id}.md`), 'utf8'))},`).join('\n')
const out = join(dirname(fileURLToPath(import.meta.url)), '..', 'src', 'team.gen.ts')
writeFileSync(
out,
`// Generated by scripts/team.mjs from @hanzo/personas ${version}. Do not edit.\n` +
`export const FILES = {\n${body}\n} as const\n`,
)
console.log(`team: ${IDS.length} members from @hanzo/personas ${version}`)