@arkstack/console 0.15.0 → 0.15.2

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.
Files changed (2) hide show
  1. package/dist/index.js +58 -14
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as ArkstackConsoleApp } from "./app-DnaQWE9q.js";
3
3
  import { n as BaseTCConfig, r as TSConfig, t as BuildInterfaces } from "./BuildInterfaces-CPmSl41C.js";
4
+ import { createRequire } from "node:module";
4
5
  import { Publisher, abort, abortIf, assertFound, config, discoverCommands, env, importFile, initializeGlobalContext, loadPrototypes, outputDir, rebuildOutput } from "@arkstack/common";
5
6
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
6
7
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -48,26 +49,32 @@ var BuildCommand = class extends Command {
48
49
 
49
50
  //#endregion
50
51
  //#region dist/commands/DevCommand.js
51
- var DevCommand = class extends Command {
52
+ var DevCommand = class DevCommand extends Command {
52
53
  signature = `dev
53
- {--t|tunnel : tunnel the dev server through Ngrok}
54
+ {--t|tunnel : Tunnel the dev server through Ngrok}
55
+ {--host : Expose the dev server on the local network}
56
+ {--s|secure : Serve the dev server over HTTPS with a self-signed certificate}
54
57
  `;
55
58
  description = "Run the development server";
56
59
  async handle() {
57
- const tunnel = this.option?.("tunnel");
60
+ const vars = DevCommand.devServerEnv(this.options());
61
+ const rootDir = Arkstack.rootDir();
62
+ const bin = DevCommand.resolveTsdownBin(rootDir);
63
+ const [command, args] = bin ? [process.execPath, [
64
+ bin,
65
+ "--log-level",
66
+ "silent"
67
+ ]] : [process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
68
+ "exec",
69
+ "tsdown",
70
+ "--log-level",
71
+ "silent"
72
+ ]];
58
73
  await new Promise((resolve, reject) => {
59
- const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
60
- "exec",
61
- "tsdown",
62
- "--log-level",
63
- "silent"
64
- ], {
65
- cwd: Arkstack.rootDir(),
74
+ const child = spawn(command, args, {
75
+ cwd: rootDir,
66
76
  stdio: "inherit",
67
- env: Object.assign(process.env, {
68
- NODE_ENV: "development",
69
- TUNNEL: tunnel ? "true" : void 0
70
- })
77
+ env: Object.assign(process.env, vars)
71
78
  });
72
79
  child.on("error", (error) => {
73
80
  reject(error);
@@ -81,6 +88,43 @@ var DevCommand = class extends Command {
81
88
  });
82
89
  });
83
90
  }
91
+ /**
92
+ * Resolve the absolute path to tsdown's executable so it can be run directly
93
+ * with `node`, skipping the `pnpm exec` wrapper process. Returns `undefined`
94
+ * when tsdown cannot be resolved from the app root, letting the caller fall
95
+ * back to `pnpm exec`.
96
+ *
97
+ * @param rootDir The application root to resolve tsdown from.
98
+ */
99
+ static resolveTsdownBin(rootDir) {
100
+ try {
101
+ const pkgPath = createRequire(join(rootDir, "noop.js")).resolve("tsdown/package.json");
102
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
103
+ const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.tsdown;
104
+ return bin ? join(dirname(pkgPath), bin) : void 0;
105
+ } catch {
106
+ return;
107
+ }
108
+ }
109
+ /**
110
+ * Map `dev` command flags to the environment variables the running server reads.
111
+ *
112
+ * The dev server binds `127.0.0.1` by default so it is local-only; `--host`
113
+ * switches it to `0.0.0.0` to expose it on the local network. `--secure` flags
114
+ * the driver to serve HTTPS, and `--tunnel` enables the Ngrok tunnel.
115
+ *
116
+ * @param options
117
+ * @returns
118
+ */
119
+ static devServerEnv(options) {
120
+ const vars = {
121
+ NODE_ENV: "development",
122
+ APP_HOST: options.host ? "0.0.0.0" : "127.0.0.1"
123
+ };
124
+ if (options.tunnel) vars.TUNNEL = "true";
125
+ if (options.secure) vars.APP_SECURE = "true";
126
+ return vars;
127
+ }
84
128
  };
85
129
 
86
130
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/console",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "description": "Console module for Arkstack, providing the command-line runtime and console integration layer.",
6
6
  "homepage": "https://arkstack.toneflix.net/guide/cli",
@@ -51,8 +51,8 @@
51
51
  "chalk": "^5.6.2",
52
52
  "resora": "^1.3.27",
53
53
  "ts-morph": "^28.0.0",
54
- "@arkstack/common": "^0.15.0",
55
- "@arkstack/contract": "^0.15.0"
54
+ "@arkstack/common": "^0.15.2",
55
+ "@arkstack/contract": "^0.15.2"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsdown",