feat: 在服務端重新編譯前端
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"server": "deno task build && deno run --allow-read --allow-write --allow-env --allow-net --allow-sys ./server/main.ts",
|
"server": "deno task build && deno run --allow-read --allow-write --allow-env --allow-net --allow-sys --allow-run=deno ./server/main.ts",
|
||||||
"debug": "deno task build && deno run --watch --allow-read --allow-write --allow-env --allow-net --allow-sys ./server/main.ts",
|
"debug": "deno task build && deno run --watch --allow-read --allow-write --allow-env --allow-net --allow-sys --allow-run=deno ./server/main.ts",
|
||||||
"build": "cd ./client && deno task build"
|
"build": "cd ./client && deno task build"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import https from 'node:https'
|
|||||||
import readline from 'node:readline'
|
import readline from 'node:readline'
|
||||||
import process from "node:process"
|
import process from "node:process"
|
||||||
import chalk from "chalk"
|
import chalk from "chalk"
|
||||||
|
import child_process from "node:child_process"
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
@@ -20,12 +21,12 @@ app.use((req, res, next) => {
|
|||||||
app.use('/', express.static(config.data_path + '/page_compiled'))
|
app.use('/', express.static(config.data_path + '/page_compiled'))
|
||||||
|
|
||||||
const httpServer: HttpServerLike = (
|
const httpServer: HttpServerLike = (
|
||||||
((config.server.use == 'http') && http.createServer(app)) ||
|
((config.server.use == 'http') && http.createServer(app)) ||
|
||||||
((config.server.use == 'https') && https.createServer(config.server.https, app)) ||
|
((config.server.use == 'https') && https.createServer(config.server.https, app)) ||
|
||||||
http.createServer(app)
|
http.createServer(app)
|
||||||
)
|
)
|
||||||
const io = new SocketIo.Server(httpServer, {
|
const io = new SocketIo.Server(httpServer, {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ApiManager.initServer(httpServer, io)
|
ApiManager.initServer(httpServer, io)
|
||||||
@@ -33,13 +34,24 @@ ApiManager.initEvents()
|
|||||||
ApiManager.initAllApis()
|
ApiManager.initAllApis()
|
||||||
|
|
||||||
httpServer.listen(config.server.listen)
|
httpServer.listen(config.server.listen)
|
||||||
console.log(chalk.yellow("===== TheWhiteSilk Server ====="))
|
|
||||||
console.log(chalk.green("API & Web 服務已經開始運作"))
|
console.log(chalk.green("API & Web 服務已經開始運作"))
|
||||||
|
function help() {
|
||||||
|
console.log(chalk.yellow("===== TheWhiteSilk Server ====="))
|
||||||
|
console.log(chalk.yellow("b - 重新編譯前端"))
|
||||||
|
}
|
||||||
|
help()
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout
|
||||||
})
|
})
|
||||||
rl.on('line', async (text) => {
|
rl.on('line', (text) => {
|
||||||
|
if (text == 'b') {
|
||||||
|
console.log(chalk.green("重新編譯..."))
|
||||||
|
child_process.spawnSync("deno", ["task", "build"], {
|
||||||
|
stdio: [process.stdin, process.stdout, process.stderr]
|
||||||
|
})
|
||||||
|
console.log(chalk.green("✓ 編譯完畢"))
|
||||||
|
help()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user