mirror of
https://github.com/iflytek/skillhub.git
synced 2026-08-28 11:25:00 +00:00
- Add integration tests for doctor, install, list, publish, remove, whoami commands - Expand fake-registry with resolve/delete state capture for real assertions - Fix update command: use correct package name @astron-team/skillhub from constants - Refactor runUpdateCommand to accept string[] instead of fragile string splitting - Add dependency injection to updateCommand for testable unit tests without global mocks - Replace package.json import with codegen (scripts/generate-pkg-info.ts) to avoid leaking devDependencies into the build artifact - Fix startNetworkFailureServer TOCTOU race by keeping listener alive - Add TODO markers for known help command bugs (--json not forwarded, unknown topic crash) - Extend update integration test timeout for real npm registry checks
29 lines
990 B
TypeScript
29 lines
990 B
TypeScript
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
import { dirname, resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
interface PackageJson {
|
|
name: string
|
|
version: string
|
|
}
|
|
|
|
const scriptDir = dirname(fileURLToPath(import.meta.url))
|
|
const cliRoot = resolve(scriptDir, '..')
|
|
const pkgPath = resolve(cliRoot, 'package.json')
|
|
const outPath = resolve(cliRoot, 'src/generated/pkg-info.ts')
|
|
|
|
const pkg = JSON.parse(await readFile(pkgPath, 'utf8')) as PackageJson
|
|
|
|
if (typeof pkg.name !== 'string' || typeof pkg.version !== 'string') {
|
|
throw new Error(`package.json at ${pkgPath} is missing name or version`)
|
|
}
|
|
|
|
const contents =
|
|
'// Generated by scripts/generate-pkg-info.ts - do not edit by hand.\n' +
|
|
`export const PKG_NAME = ${JSON.stringify(pkg.name)}\n` +
|
|
`export const PKG_VERSION = ${JSON.stringify(pkg.version)}\n`
|
|
|
|
await mkdir(dirname(outPath), { recursive: true })
|
|
await writeFile(outPath, contents, 'utf8')
|
|
|
|
console.log(`generated ${outPath}`)
|