@haowjy/remote-workspace 0.1.0 → 0.1.1
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/launcher.js +35 -21
- package/package.json +1 -1
package/dist/launcher.js
CHANGED
|
@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
const currentFilePath = fileURLToPath(import.meta.url);
|
|
7
7
|
const currentDirectoryPath = path.dirname(currentFilePath);
|
|
8
8
|
const appDir = path.resolve(currentDirectoryPath, "..");
|
|
9
|
+
const builtServerPath = path.resolve(currentDirectoryPath, "server.js");
|
|
9
10
|
function printUsage() {
|
|
10
11
|
console.log(`Usage: pnpm dev -- [options]
|
|
11
12
|
|
|
@@ -249,23 +250,26 @@ function runSync(commandName, args) {
|
|
|
249
250
|
}
|
|
250
251
|
function main() {
|
|
251
252
|
const args = parseArgs(process.argv.slice(2));
|
|
252
|
-
|
|
253
|
-
fail("pnpm is required but not installed.");
|
|
254
|
-
}
|
|
253
|
+
const runBuiltServer = existsSync(builtServerPath);
|
|
255
254
|
if (args.serveEnabled) {
|
|
256
255
|
if (!hasCommand("tailscale")) {
|
|
257
|
-
fail("tailscale is not installed, but serve mode is enabled.\nUse local-only mode
|
|
256
|
+
fail("tailscale is not installed, but serve mode is enabled.\nUse local-only mode with --no-serve (or --password <pwd>).\nOr install Tailscale, run 'tailscale up', then restart with --serve.");
|
|
258
257
|
}
|
|
259
258
|
runSyncOrFail("tailscale", ["status"], "tailscale is installed but not connected.\nRun 'tailscale up' and retry --serve, or use local-only mode with --no-serve.");
|
|
260
259
|
}
|
|
261
|
-
if (!
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
260
|
+
if (!runBuiltServer) {
|
|
261
|
+
if (!hasCommand("pnpm")) {
|
|
262
|
+
fail("pnpm is required but not installed.");
|
|
263
|
+
}
|
|
264
|
+
if (!existsSync(path.join(appDir, "package.json"))) {
|
|
265
|
+
fail(`remote-workspace app not found at: ${appDir}`);
|
|
266
|
+
}
|
|
267
|
+
if (args.forceInstall) {
|
|
268
|
+
runSyncOrFail("pnpm", ["--dir", appDir, "install"], "Dependency install failed.");
|
|
269
|
+
}
|
|
270
|
+
else if (!args.skipInstall && !existsSync(path.join(appDir, "node_modules"))) {
|
|
271
|
+
runSyncOrFail("pnpm", ["--dir", appDir, "install"], "Dependency install failed.");
|
|
272
|
+
}
|
|
269
273
|
}
|
|
270
274
|
if (args.serveEnabled) {
|
|
271
275
|
console.log(`Configuring tailscale serve (https:443 -> 127.0.0.1:${args.port})`);
|
|
@@ -288,15 +292,25 @@ function main() {
|
|
|
288
292
|
console.log("Auth: Basic Auth enabled");
|
|
289
293
|
}
|
|
290
294
|
console.log("");
|
|
291
|
-
const child =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
const child = runBuiltServer
|
|
296
|
+
? spawn("node", [builtServerPath], {
|
|
297
|
+
stdio: "inherit",
|
|
298
|
+
env: {
|
|
299
|
+
...process.env,
|
|
300
|
+
REPO_ROOT: args.repoRoot,
|
|
301
|
+
REMOTE_WS_PORT: String(args.port),
|
|
302
|
+
REMOTE_WS_PASSWORD: args.workspacePassword,
|
|
303
|
+
},
|
|
304
|
+
})
|
|
305
|
+
: spawn("pnpm", ["--dir", appDir, "dev:server"], {
|
|
306
|
+
stdio: "inherit",
|
|
307
|
+
env: {
|
|
308
|
+
...process.env,
|
|
309
|
+
REPO_ROOT: args.repoRoot,
|
|
310
|
+
REMOTE_WS_PORT: String(args.port),
|
|
311
|
+
REMOTE_WS_PASSWORD: args.workspacePassword,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
300
314
|
child.on("exit", (code, signal) => {
|
|
301
315
|
if (signal) {
|
|
302
316
|
process.kill(process.pid, signal);
|