vibelet 0.0.5 → 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/bin/vibelet.mjs +23 -8
- package/dist/index.cjs +42 -42
- package/package.json +1 -1
package/bin/vibelet.mjs
CHANGED
|
@@ -138,6 +138,8 @@ function createDarwinBackend() {
|
|
|
138
138
|
|
|
139
139
|
const envVars = { VIBE_PORT: String(port) };
|
|
140
140
|
if (process.env.VIBELET_RELAY_URL) envVars.VIBELET_RELAY_URL = process.env.VIBELET_RELAY_URL;
|
|
141
|
+
if (process.env.VIBELET_CANONICAL_HOST) envVars.VIBELET_CANONICAL_HOST = process.env.VIBELET_CANONICAL_HOST;
|
|
142
|
+
if (process.env.VIBELET_FALLBACK_HOSTS) envVars.VIBELET_FALLBACK_HOSTS = process.env.VIBELET_FALLBACK_HOSTS;
|
|
141
143
|
const envSection = Object.keys(envVars).length > 0
|
|
142
144
|
? ` <key>EnvironmentVariables</key>
|
|
143
145
|
<dict>
|
|
@@ -246,7 +248,7 @@ Restart=always
|
|
|
246
248
|
RestartSec=3
|
|
247
249
|
StandardOutput=append:${stdoutLogPath}
|
|
248
250
|
StandardError=append:${stderrLogPath}
|
|
249
|
-
Environment=VIBE_PORT=${port}${process.env.VIBELET_RELAY_URL ? `\nEnvironment=VIBELET_RELAY_URL=${process.env.VIBELET_RELAY_URL}` : ''}
|
|
251
|
+
Environment=VIBE_PORT=${port}${process.env.VIBELET_RELAY_URL ? `\nEnvironment=VIBELET_RELAY_URL=${process.env.VIBELET_RELAY_URL}` : ''}${process.env.VIBELET_CANONICAL_HOST ? `\nEnvironment=VIBELET_CANONICAL_HOST=${process.env.VIBELET_CANONICAL_HOST}` : ''}${process.env.VIBELET_FALLBACK_HOSTS ? `\nEnvironment=VIBELET_FALLBACK_HOSTS=${process.env.VIBELET_FALLBACK_HOSTS}` : ''}
|
|
250
252
|
|
|
251
253
|
[Install]
|
|
252
254
|
WantedBy=default.target
|
|
@@ -498,6 +500,8 @@ function printHelp() {
|
|
|
498
500
|
process.stdout.write(` npx ${packageJson.name} Install/start the daemon and print a pairing QR code\n`);
|
|
499
501
|
process.stdout.write(` npx ${packageJson.name} start Same as above\n`);
|
|
500
502
|
process.stdout.write(` npx ${packageJson.name} --relay <url> Use a tunnel URL for remote access\n`);
|
|
503
|
+
process.stdout.write(` npx ${packageJson.name} --host <ip> Set the primary host/IP address\n`);
|
|
504
|
+
process.stdout.write(` npx ${packageJson.name} --fallback-hosts <ips> Comma-separated fallback IPs\n`);
|
|
501
505
|
process.stdout.write(` npx ${packageJson.name} stop Stop the daemon\n`);
|
|
502
506
|
process.stdout.write(` npx ${packageJson.name} restart Restart the daemon\n`);
|
|
503
507
|
process.stdout.write(` npx ${packageJson.name} status Show service and daemon status\n`);
|
|
@@ -511,16 +515,19 @@ function printHelp() {
|
|
|
511
515
|
process.stdout.write(` vibelet\n`);
|
|
512
516
|
}
|
|
513
517
|
|
|
514
|
-
function
|
|
515
|
-
const idx = process.argv.indexOf(
|
|
518
|
+
function parseNamedArg(name, errorHint) {
|
|
519
|
+
const idx = process.argv.indexOf(`--${name}`);
|
|
516
520
|
if (idx === -1) return null;
|
|
517
|
-
const
|
|
518
|
-
if (!
|
|
519
|
-
fail(
|
|
521
|
+
const value = process.argv[idx + 1];
|
|
522
|
+
if (!value || value.startsWith('-')) {
|
|
523
|
+
fail(`--${name} requires an argument${errorHint ? ` (e.g. --${name} ${errorHint})` : ''}`);
|
|
520
524
|
}
|
|
521
|
-
// Remove --relay and URL from argv so they don't interfere with command parsing
|
|
522
525
|
process.argv.splice(idx, 2);
|
|
523
|
-
return
|
|
526
|
+
return value;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function parseRelayArg() {
|
|
530
|
+
return parseNamedArg('relay', 'https://abc.trycloudflare.com');
|
|
524
531
|
}
|
|
525
532
|
|
|
526
533
|
function loadRelayConfig() {
|
|
@@ -543,6 +550,8 @@ function clearRelayConfig() {
|
|
|
543
550
|
|
|
544
551
|
async function main() {
|
|
545
552
|
const relayArg = parseRelayArg();
|
|
553
|
+
const hostArg = parseNamedArg('host', '100.x.x.x');
|
|
554
|
+
const fallbackHostsArg = parseNamedArg('fallback-hosts', '100.x.x.x,192.168.1.x');
|
|
546
555
|
// --relay "" clears saved relay; --relay <url> saves it; omitted uses saved value
|
|
547
556
|
if (relayArg !== null) {
|
|
548
557
|
if (relayArg) {
|
|
@@ -555,6 +564,12 @@ async function main() {
|
|
|
555
564
|
if (relayUrl) {
|
|
556
565
|
process.env.VIBELET_RELAY_URL = relayUrl;
|
|
557
566
|
}
|
|
567
|
+
if (hostArg) {
|
|
568
|
+
process.env.VIBELET_CANONICAL_HOST = hostArg;
|
|
569
|
+
}
|
|
570
|
+
if (fallbackHostsArg) {
|
|
571
|
+
process.env.VIBELET_FALLBACK_HOSTS = fallbackHostsArg;
|
|
572
|
+
}
|
|
558
573
|
const backend = resolveBackend();
|
|
559
574
|
const command = process.argv[2] ?? 'default';
|
|
560
575
|
|