mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-10 10:25:36 +08:00
Add deps-map component and related command
This commit is contained in:
23
docs/.vitepress/deps-map.data.js
Normal file
23
docs/.vitepress/deps-map.data.js
Normal 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 }
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user