代码拉取完成,页面将自动刷新
// local-registry related utils
import { fileURLToPath } from 'node:url'
import { runServer, parseConfigFile } from 'verdaccio'
const START_VERDACCIO_TIMEOUT_IN_SECONDS = 60
// use an unconventional port to avoid conflicts with other local registries
const LOCAL_REGISTRY_PORT = 6173
export const REGISTRY_ADDRESS = `http://localhost:${LOCAL_REGISTRY_PORT}/`
export async function startRegistry() {
// It's not ideal to repeat this config option here,
// luckily, `self_path` would no longer be required in verdaccio 6
const cache = fileURLToPath(new URL('./.verdaccio-cache', import.meta.url))
const config = {
...parseConfigFile(
fileURLToPath(new URL('./verdaccio.yaml', import.meta.url)),
),
self_path: cache,
}
return new Promise((resolve, reject) => {
// A promise can only be fulfilled/rejected once, so we can use this as a shortcut of `Promise.race`
setTimeout(() => {
reject(
new Error(
`Verdaccio did not start in ${START_VERDACCIO_TIMEOUT_IN_SECONDS} seconds`,
),
)
}, START_VERDACCIO_TIMEOUT_IN_SECONDS * 1000)
runServer(config).then((app) => {
app.listen(LOCAL_REGISTRY_PORT, () => {
console.log(`Verdaccio started on port ${LOCAL_REGISTRY_PORT}`)
resolve(app)
})
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
// Use once() so that receiving double signals exit the app.
process.once(signal, () => {
console.log('Received shutdown signal - closing server...')
app.close(() => {
console.log('Server closed')
process.exit(0)
})
})
}
})
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。