@arkstack/console 0.17.17 → 0.17.19
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/index.js +35 -19
- package/dist/prepare.js +2 -0
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Arkstack } from "@arkstack/contract";
|
|
|
11
11
|
import { MakeResource, applyRuntimeConfig, getDefaultConfig } from "resora";
|
|
12
12
|
import { Command, Kernel } from "@h3ravel/musket";
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
|
+
import ngrok from "@ngrok/ngrok";
|
|
14
15
|
import { randomBytes } from "node:crypto";
|
|
15
16
|
import { resolve as resolve$1 } from "path";
|
|
16
17
|
import { writeFile } from "fs/promises";
|
|
@@ -61,6 +62,16 @@ var DevCommand = class DevCommand extends Command {
|
|
|
61
62
|
const vars = DevCommand.devServerEnv(this.options());
|
|
62
63
|
const rootDir = Arkstack.rootDir();
|
|
63
64
|
const bin = DevCommand.resolveTsdownBin(rootDir);
|
|
65
|
+
let tunnel;
|
|
66
|
+
if (this.option?.("tunnel")) {
|
|
67
|
+
tunnel = await ngrok.forward({
|
|
68
|
+
addr: Number(env("APP_PORT", env("PORT", 3e3))),
|
|
69
|
+
authtoken: env("NGROK_AUTHTOKEN"),
|
|
70
|
+
domain: env("NGROK_DOMAIN")
|
|
71
|
+
});
|
|
72
|
+
const url = tunnel.url();
|
|
73
|
+
if (url) vars.TUNNEL_URL = url;
|
|
74
|
+
}
|
|
64
75
|
const [command, args] = bin ? [process.execPath, [
|
|
65
76
|
bin,
|
|
66
77
|
"--log-level",
|
|
@@ -71,23 +82,27 @@ var DevCommand = class DevCommand extends Command {
|
|
|
71
82
|
"--log-level",
|
|
72
83
|
"silent"
|
|
73
84
|
]];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
try {
|
|
86
|
+
await new Promise((resolve, reject) => {
|
|
87
|
+
const child = spawn(command, args, {
|
|
88
|
+
cwd: rootDir,
|
|
89
|
+
stdio: "inherit",
|
|
90
|
+
env: Object.assign({}, process.env, vars)
|
|
91
|
+
});
|
|
92
|
+
child.on("error", (error) => {
|
|
93
|
+
reject(error);
|
|
94
|
+
});
|
|
95
|
+
child.on("exit", (code) => {
|
|
96
|
+
if (code === 0 || code === null) {
|
|
97
|
+
resolve();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
reject(/* @__PURE__ */ new Error(`tsdown exited with code ${code}`));
|
|
101
|
+
});
|
|
89
102
|
});
|
|
90
|
-
}
|
|
103
|
+
} finally {
|
|
104
|
+
await tunnel?.close();
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
/**
|
|
93
108
|
* Resolve the absolute path to tsdown's executable so it can be run directly
|
|
@@ -112,7 +127,8 @@ var DevCommand = class DevCommand extends Command {
|
|
|
112
127
|
*
|
|
113
128
|
* The dev server binds `127.0.0.1` by default so it is local-only; `--host`
|
|
114
129
|
* switches it to `0.0.0.0` to expose it on the local network. `--secure` flags
|
|
115
|
-
* the driver to serve HTTPS
|
|
130
|
+
* the driver to serve HTTPS. The command itself owns the Ngrok tunnel so
|
|
131
|
+
* watcher-driven application restarts cannot replace its public URL.
|
|
116
132
|
*
|
|
117
133
|
* @param options
|
|
118
134
|
* @returns
|
|
@@ -120,9 +136,9 @@ var DevCommand = class DevCommand extends Command {
|
|
|
120
136
|
static devServerEnv(options) {
|
|
121
137
|
const vars = {
|
|
122
138
|
NODE_ENV: "development",
|
|
123
|
-
APP_HOST: options.host ? "0.0.0.0" : "127.0.0.1"
|
|
139
|
+
APP_HOST: options.host ? "0.0.0.0" : "127.0.0.1",
|
|
140
|
+
ARKSTACK_ENV_RELOAD: "true"
|
|
124
141
|
};
|
|
125
|
-
if (options.tunnel) vars.TUNNEL = "true";
|
|
126
142
|
if (options.secure) vars.APP_SECURE = "true";
|
|
127
143
|
return vars;
|
|
128
144
|
}
|
package/dist/prepare.js
CHANGED
|
@@ -73,6 +73,8 @@ var ArkormArtifacts = class ArkormArtifacts {
|
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region dist/prepare.js
|
|
76
|
+
if (!globalThis.env) globalThis.env = (await import("@arkstack/common")).env;
|
|
77
|
+
if (!globalThis.config) globalThis.config = (await import("@arkstack/common")).config;
|
|
76
78
|
if (!existsSync(path.join(Arkstack.rootDir(), ".arkstack/build"))) mkdirSync(path.join(Arkstack.rootDir(), ".arkstack/build"), { recursive: true });
|
|
77
79
|
if (!process.env.NODE_CI) {
|
|
78
80
|
BuildInterfaces.configs();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/console",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.19",
|
|
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",
|
|
@@ -42,16 +42,17 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"arkormx": "^2.12.8",
|
|
44
44
|
"clear-router": "^2.9.3",
|
|
45
|
-
"@arkstack/database": "^0.17.
|
|
45
|
+
"@arkstack/database": "^0.17.19"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
+
"@ngrok/ngrok": "^1.7.0",
|
|
48
49
|
"@h3ravel/musket": "^2.2.13",
|
|
49
50
|
"@h3ravel/support": "^2.2.7",
|
|
50
51
|
"chalk": "^5.6.2",
|
|
51
52
|
"resora": "^1.3.34",
|
|
52
53
|
"ts-morph": "^28.0.0",
|
|
53
|
-
"@arkstack/common": "^0.17.
|
|
54
|
-
"@arkstack/contract": "^0.17.
|
|
54
|
+
"@arkstack/common": "^0.17.19",
|
|
55
|
+
"@arkstack/contract": "^0.17.19"
|
|
55
56
|
},
|
|
56
57
|
"peerDependenciesMeta": {
|
|
57
58
|
"@arkstack/database": {
|