代码拉取完成,页面将自动刷新
同步操作将从 张超杰/f-render 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const semver = require('semver')
const pkg = require('./package.json')
const requiredVersion = pkg.engines.node
checkNodeVersion(requiredVersion, pkg.name)
function checkNodeVersion(wanted, id) {
if (!semver.satisfies(process.version, wanted)) {
console.log(
'\x1B[31m%s\x1B[0m',
'You are using Node ' +
process.version +
', but this version of ' +
id +
' requires Node ' +
wanted +
'.\nPlease upgrade your Node version.'
)
process.exit(1)
}
}
const chalk = require('chalk')
const internalIp = require('internal-ip')
const program = require('commander')
const handler = require('serve-handler')
const http = require('http')
const path = require('path')
const open = require('open')
const updateNotifier = require('update-notifier')
// 检查更新
function updateCheck() {
const notifier = updateNotifier({ pkg })
const message = []
if (notifier.update) {
message.push(
'Update available: ' +
chalk.green.bold(notifier.update.latest) +
chalk.gray(' (current: ' + notifier.update.current + ');')
)
message.push(
'Run ' +
chalk.magenta('npm install -g ' + pkg.name) +
' Or ' +
chalk.magenta('yarn global add ' + pkg.name) +
' to update.'
)
// eslint-disable-next-line no-console
console.log(message.join('\r\n'))
}
}
updateCheck()
const server = http.createServer((request, response) => {
return handler(request, response, {
public: path.resolve(__dirname, './dist')
})
})
program.version(`fgen ${pkg.version}`).usage('<command> [options]')
program.option('-p, --port <port>', 'Port used by the server', 54321)
program.parse(process.argv)
const port = program.port
server.listen(port, async () => {
const localUrl = 'http://localhost:' + port
const networkUrl = await internalIp.v4()
const networkMsg = networkUrl
? chalk.cyan(`http://${networkUrl}:${port}`)
: chalk.gray('unavailable')
console.log()
console.log(` App running at:`)
console.log(` - Local: ${chalk.cyan(localUrl)}`)
console.log(` - Network: ${networkMsg}`)
console.log()
open(localUrl)
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。