vite-elysia-forge 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import {spawnSync}from'child_process';import {existsSync,mkdirSync,writeFileSync,unlinkSync}from'fs';import {resolve,relative,sep}from'path';async function
|
|
2
|
+
import {spawnSync}from'child_process';import {existsSync,mkdirSync,writeFileSync,unlinkSync,rmSync}from'fs';import {resolve,relative,sep}from'path';async function b(o="src/server/api.ts"){let c=resolve(process.cwd(),o);existsSync(c)||(console.error(`\u274C API entry file "${o}" not found.`),console.error(' By default, vite-elysia-forge looks for "src/server/api.ts".'),console.error(" If your API is located elsewhere, please specify the path:"),console.error(" $ vite-elysia-forge build <path-to-your-api-file>"),process.exit(1));let t=spawnSync("bun",["x","vite","build"],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}});t.status!==0&&(console.error("\u274C Vite build failed"),process.exit(t.status||1));let e=resolve(process.cwd(),".output");existsSync(e)||mkdirSync(e,{recursive:true});let s=resolve(e,".temp-prod.ts"),r=relative(e,c);r=r.split(sep).join("/"),r.startsWith(".")||(r="./"+r);let a=`
|
|
3
3
|
import { startServer } from "vite-elysia-forge/production";
|
|
4
|
-
import { api } from "${
|
|
4
|
+
import { api } from "${r}";
|
|
5
5
|
|
|
6
6
|
startServer({
|
|
7
7
|
api,
|
|
8
8
|
port: process.env.PORT ? parseInt(process.env.PORT) : 3000,
|
|
9
9
|
distDir: "dist",
|
|
10
10
|
});
|
|
11
|
-
`;writeFileSync(s,a);try{let i=await Bun.build({entrypoints:[s],outdir:"dist",target:"bun",minify:!0,naming:"server.js"});if(!i.success){console.error("\u274C Server build failed");for(let
|
|
11
|
+
`;writeFileSync(s,a);try{let i=await Bun.build({entrypoints:[s],outdir:"dist",target:"bun",minify:!0,naming:"server.js"});if(!i.success){console.error("\u274C Server build failed");for(let u of i.logs)console.error(u);process.exit(1);}}catch(i){console.error("\u274C Failed to build server. Ensure you are running this command with Bun."),console.error(i),process.exit(1);}finally{existsSync(s)&&unlinkSync(s),existsSync(e)&&rmSync(e,{recursive:true,force:true});}}if(import.meta.main){let o=process.argv.slice(2);if(o[0]==="build"){let t=o[1];b(t);}else console.log("Usage: vite-elysia-forge build [api-entry]"),console.log(" api-entry: Path to your API entry file (default: src/server/api.ts)");}export{b as build};
|