@zeroexcore/tuna 0.1.2 → 0.1.4
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/package.json +11 -10
- package/src/commands/run.ts +5 -6
- package/src/lib/service.ts +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeroexcore/tuna",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Cloudflare Tunnel Wrapper for Development Servers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,15 @@
|
|
|
18
18
|
"bin": {
|
|
19
19
|
"tuna": "./src/index.ts"
|
|
20
20
|
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "tsx watch src/index.ts",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"test:ui": "vitest --ui",
|
|
27
|
+
"lint": "eslint src",
|
|
28
|
+
"prepublishOnly": "pnpm typecheck && pnpm test"
|
|
29
|
+
},
|
|
21
30
|
"keywords": [
|
|
22
31
|
"cloudflare",
|
|
23
32
|
"tunnel",
|
|
@@ -48,13 +57,5 @@
|
|
|
48
57
|
"js-yaml": "^4.1.1",
|
|
49
58
|
"keytar": "^7.9.0",
|
|
50
59
|
"ora": "^9.1.0"
|
|
51
|
-
},
|
|
52
|
-
"scripts": {
|
|
53
|
-
"dev": "tsx watch src/index.ts",
|
|
54
|
-
"typecheck": "tsc --noEmit",
|
|
55
|
-
"test": "vitest run",
|
|
56
|
-
"test:watch": "vitest",
|
|
57
|
-
"test:ui": "vitest --ui",
|
|
58
|
-
"lint": "eslint src"
|
|
59
60
|
}
|
|
60
|
-
}
|
|
61
|
+
}
|
package/src/commands/run.ts
CHANGED
|
@@ -9,11 +9,7 @@ import { randomBytes } from 'crypto';
|
|
|
9
9
|
import { readConfig, generateTunnelName } from '../lib/config.ts';
|
|
10
10
|
import { getCredentials, getRootDomain } from '../lib/credentials.ts';
|
|
11
11
|
import { CloudflareAPI } from '../lib/api.ts';
|
|
12
|
-
import {
|
|
13
|
-
isInstalled,
|
|
14
|
-
download,
|
|
15
|
-
ensureDirectories,
|
|
16
|
-
} from '../lib/cloudflared.ts';
|
|
12
|
+
import { isInstalled, download, ensureDirectories } from '../lib/cloudflared.ts';
|
|
17
13
|
import {
|
|
18
14
|
generateIngressConfig,
|
|
19
15
|
writeIngressConfig,
|
|
@@ -116,7 +112,9 @@ export async function runCommand(args: string[]): Promise<void> {
|
|
|
116
112
|
// Check if we have local credentials
|
|
117
113
|
if (!tunnelCredentialsExist(tunnel.id)) {
|
|
118
114
|
spinner.fail('Tunnel exists but local credentials missing');
|
|
119
|
-
console.error(
|
|
115
|
+
console.error(
|
|
116
|
+
chalk.red('\nThe tunnel exists on Cloudflare but local credentials are missing.')
|
|
117
|
+
);
|
|
120
118
|
console.log(chalk.yellow('Options:'));
|
|
121
119
|
console.log(chalk.yellow(' 1. Delete the tunnel and let tuna recreate it:'));
|
|
122
120
|
console.log(chalk.cyan(` tuna --delete ${tunnelName}`));
|
|
@@ -153,6 +151,7 @@ export async function runCommand(args: string[]): Promise<void> {
|
|
|
153
151
|
spinner.succeed('Service restarted');
|
|
154
152
|
}
|
|
155
153
|
} catch (error) {
|
|
154
|
+
console.log(error);
|
|
156
155
|
spinner.fail('Failed to start service');
|
|
157
156
|
console.error(chalk.red(`\nError: ${(error as Error).message}`));
|
|
158
157
|
process.exit(1);
|
package/src/lib/service.ts
CHANGED
|
@@ -269,7 +269,9 @@ export async function startService(): Promise<void> {
|
|
|
269
269
|
throw new Error('Service not installed. Run tuna first to set up the tunnel.');
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
// Use launchctl load which loads and starts the service (since RunAtLoad is true)
|
|
273
|
+
// This works whether the service is already loaded or not
|
|
274
|
+
await execa('launchctl', ['load', PLIST_PATH]);
|
|
273
275
|
}
|
|
274
276
|
|
|
275
277
|
/**
|
|
@@ -285,9 +287,11 @@ export async function stopService(): Promise<void> {
|
|
|
285
287
|
}
|
|
286
288
|
|
|
287
289
|
try {
|
|
288
|
-
|
|
290
|
+
// Use launchctl unload to stop and unregister the service
|
|
291
|
+
// This works whether the service is running or not
|
|
292
|
+
await execa('launchctl', ['unload', PLIST_PATH]);
|
|
289
293
|
} catch {
|
|
290
|
-
// Ignore errors if service wasn't
|
|
294
|
+
// Ignore errors if service wasn't loaded
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
297
|
|