Skip to content

Commit

Permalink
docs(changeset): feat: vinxi start command (just works with node targ…
Browse files Browse the repository at this point in the history
…et right now)
  • Loading branch information
nksaraf committed Dec 2, 2023
1 parent 5aa23ef commit e7313f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-lemons-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vinxi": patch
---

feat: vinxi start command (just works with node target right now)
45 changes: 38 additions & 7 deletions packages/vinxi/bin/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#!/usr/bin/env node
import chokidar from "chokidar";
import { defineCommand, runMain } from "citty";
import fs from "fs";
// import mri from "mri";
import { fileURLToPath } from "url";

import { exec } from "node:child_process";

import { loadApp } from "../lib/load-app.js";
import { log } from "../lib/logger.js";

const packageJson = JSON.parse(
fs.readFileSync(
fileURLToPath(new URL("../package.json", import.meta.url)),
Expand Down Expand Up @@ -64,6 +57,9 @@ const command = defineCommand({
},
},
async run({ args }) {
const chokidar = await import("chokidar");
const { loadApp } = await import("../lib/load-app.js");
const { log } = await import("../lib/logger.js");
const configFile = args.config;
globalThis.MANIFEST = {};
const app = await loadApp(configFile, args);
Expand Down Expand Up @@ -153,12 +149,47 @@ const command = defineCommand({
async run({ args }) {
const configFile = args.config;
globalThis.MANIFEST = {};
const { loadApp } = await import("../lib/load-app.js");
const app = await loadApp(configFile, args);
process.env.NODE_ENV = "production";
const { createBuild } = await import("../lib/build.js");
await createBuild(app, { preset: args.preset });
},
},
start: {
meta: {
name: "start",
version: packageJson.version,
description: "Start your built Vinxi app",
},
args: {
config: {
type: "string",
description: "Path to config file (default: app.config.js)",
},
stack: {
type: "string",
description: "Stacks",
},
preset: {
type: "string",
description: "Server preset (default: node-server)",
},
port: {
type: "number",
description: "Port to listen on (default: 3000)",
},
host: {
type: "boolean",
description: "Expose to host (default: false)",
},
},
async run({ args }) {
process.env.PORT ??= args.port ?? 3000;
process.env.HOST ??= args.host;
await import(process.cwd() + "/.output/server/index.mjs");
},
},
}),
});

Expand Down

0 comments on commit e7313f4

Please sign in to comment.