Add deps-map component and related command

This commit is contained in:
crazywhalecc
2026-04-20 11:30:40 +08:00
parent 05900c2d6c
commit c39155898a
11 changed files with 1466 additions and 96 deletions

View File

@@ -0,0 +1,23 @@
import { readFileSync, existsSync } from 'node:fs'
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const DATA_PATH = resolve(__dirname, 'deps-data.json')
export default {
watch: [DATA_PATH],
load() {
if (!existsSync(DATA_PATH)) {
console.warn(
'[deps-map.data.js] deps-data.json not found. ' +
'Run `bin/spc dev:gen-deps-data` to generate it.'
)
return { packages: {}, missing: true }
}
const raw = JSON.parse(readFileSync(DATA_PATH, 'utf-8'))
return { packages: raw.packages ?? {}, missing: false }
},
}