@take-out/scripts 0.0.46 → 0.0.47
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 +2 -2
- package/src/release.ts +2 -2
- package/src/dev-tunnel-if-exist.ts +0 -166
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@take-out/scripts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/run.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@take-out/helpers": "0.0.
|
|
27
|
+
"@take-out/helpers": "0.0.47",
|
|
28
28
|
"glob": "^11.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/release.ts
CHANGED
|
@@ -322,8 +322,8 @@ async function updateDownstreamRepos() {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
// run upgrade
|
|
325
|
-
console.info(` Running upgrade
|
|
326
|
-
await run(`bun
|
|
325
|
+
console.info(` Running upgrade takeout...`)
|
|
326
|
+
await run(`bun up takeout`, { cwd: repoPath })
|
|
327
327
|
|
|
328
328
|
// run check:all
|
|
329
329
|
console.info(` Running check:all...`)
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { spawn } from 'node:child_process'
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
-
import { homedir } from 'node:os'
|
|
6
|
-
import { join } from 'node:path'
|
|
7
|
-
|
|
8
|
-
const TUNNEL_CONFIG_DIR = join(homedir(), '.onechat-tunnel')
|
|
9
|
-
const TUNNEL_ID_FILE = join(TUNNEL_CONFIG_DIR, 'tunnel-id.txt')
|
|
10
|
-
const TUNNEL_CONFIG_FILE = join(TUNNEL_CONFIG_DIR, 'config.yml')
|
|
11
|
-
|
|
12
|
-
// check internet connectivity first
|
|
13
|
-
async function checkInternetConnection(): Promise<boolean> {
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
// try to ping cloudflare dns
|
|
16
|
-
const pingProcess = spawn('ping', ['-c', '1', '-W', '2', '1.1.1.1'], {
|
|
17
|
-
stdio: 'pipe',
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
pingProcess.on('error', () => {
|
|
21
|
-
resolve(false)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
pingProcess.on('exit', (code) => {
|
|
25
|
-
resolve(code === 0)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// check connectivity before proceeding
|
|
31
|
-
const isOnline = await checkInternetConnection()
|
|
32
|
-
if (!isOnline) {
|
|
33
|
-
console.info('📵 Offline - skipping tunnel setup')
|
|
34
|
-
// Keep process alive for watch mode
|
|
35
|
-
await new Promise(() => {})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ensure config dir exists
|
|
39
|
-
if (!existsSync(TUNNEL_CONFIG_DIR)) {
|
|
40
|
-
mkdirSync(TUNNEL_CONFIG_DIR, { recursive: true })
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// check if cloudflared is authenticated
|
|
44
|
-
const certPath = join(homedir(), '.cloudflared', 'cert.pem')
|
|
45
|
-
const hasCloudflaredAuth = existsSync(certPath)
|
|
46
|
-
|
|
47
|
-
if (!hasCloudflaredAuth) {
|
|
48
|
-
console.info('☁️ Tunnel not set up. Run "bun dev:tunnel" to enable.')
|
|
49
|
-
// Keep process alive for watch mode
|
|
50
|
-
await new Promise(() => {})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// check if we have a tunnel id
|
|
54
|
-
const hasTunnelId = existsSync(TUNNEL_ID_FILE)
|
|
55
|
-
if (!hasTunnelId) {
|
|
56
|
-
console.info('☁️ No tunnel created. Run "bun dev:tunnel" once to set up.')
|
|
57
|
-
// Keep process alive for watch mode
|
|
58
|
-
await new Promise(() => {})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// check if cloudflared is installed
|
|
62
|
-
const checkProcess = spawn('which', ['cloudflared'], {
|
|
63
|
-
shell: true,
|
|
64
|
-
stdio: 'pipe',
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
checkProcess.on('error', () => {
|
|
68
|
-
console.warn('⚠️ cloudflared not found - skipping tunnel setup')
|
|
69
|
-
// Keep process alive for watch mode
|
|
70
|
-
new Promise(() => {})
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
checkProcess.on('exit', async (code) => {
|
|
74
|
-
if (code === 0) {
|
|
75
|
-
const tunnelId = readFileSync(TUNNEL_ID_FILE, 'utf-8').trim()
|
|
76
|
-
const tunnelName = 'onechat-dev-n8' // your tunnel name
|
|
77
|
-
console.info(`🚇 Starting tunnel ${tunnelId}...`)
|
|
78
|
-
|
|
79
|
-
// The stable URL format for your domain
|
|
80
|
-
const tunnelDomain = `${tunnelName}.start.chat`
|
|
81
|
-
|
|
82
|
-
// Create config file with ingress rules
|
|
83
|
-
const tunnelConfig = `
|
|
84
|
-
tunnel: ${tunnelId}
|
|
85
|
-
credentials-file: ${join(homedir(), '.cloudflared', `${tunnelId}.json`)}
|
|
86
|
-
|
|
87
|
-
ingress:
|
|
88
|
-
- hostname: ${tunnelDomain}
|
|
89
|
-
service: http://localhost:8081
|
|
90
|
-
- service: http_status:404
|
|
91
|
-
`
|
|
92
|
-
writeFileSync(TUNNEL_CONFIG_FILE, tunnelConfig)
|
|
93
|
-
|
|
94
|
-
// Set up DNS route if needed (this is idempotent, safe to run multiple times)
|
|
95
|
-
const routeProcess = spawn(
|
|
96
|
-
'cloudflared',
|
|
97
|
-
['tunnel', 'route', 'dns', tunnelId, tunnelDomain],
|
|
98
|
-
{
|
|
99
|
-
stdio: 'pipe',
|
|
100
|
-
shell: true,
|
|
101
|
-
}
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
await new Promise((resolve) => {
|
|
105
|
-
routeProcess.on('exit', resolve)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
const tunnelUrl = `https://${tunnelDomain}`
|
|
109
|
-
const tunnelUrlFile = join(TUNNEL_CONFIG_DIR, 'tunnel-url.txt')
|
|
110
|
-
writeFileSync(tunnelUrlFile, tunnelUrl)
|
|
111
|
-
console.info(`🌐 Tunnel URL: ${tunnelUrl}`)
|
|
112
|
-
|
|
113
|
-
// Run tunnel with config file
|
|
114
|
-
const tunnelProcess = spawn(
|
|
115
|
-
'cloudflared',
|
|
116
|
-
['tunnel', '--config', TUNNEL_CONFIG_FILE, 'run'],
|
|
117
|
-
{
|
|
118
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
119
|
-
shell: true,
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
// Track if we've shown the connection message
|
|
124
|
-
let hasShownConnected = false
|
|
125
|
-
|
|
126
|
-
// Process stdout to filter logs
|
|
127
|
-
tunnelProcess.stdout?.on('data', (data) => {
|
|
128
|
-
const output = data.toString()
|
|
129
|
-
|
|
130
|
-
// Only show first successful connection
|
|
131
|
-
if (!hasShownConnected && output.includes('Registered tunnel connection')) {
|
|
132
|
-
console.info('✅ Tunnel connected')
|
|
133
|
-
hasShownConnected = true
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
// Process stderr (where cloudflared logs go)
|
|
138
|
-
tunnelProcess.stderr?.on('data', (data) => {
|
|
139
|
-
const output = data.toString()
|
|
140
|
-
|
|
141
|
-
// Only show first successful connection
|
|
142
|
-
if (!hasShownConnected && output.includes('Registered tunnel connection')) {
|
|
143
|
-
console.info('✅ Tunnel connected')
|
|
144
|
-
hasShownConnected = true
|
|
145
|
-
}
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
// handle process termination
|
|
149
|
-
process.on('SIGINT', () => {
|
|
150
|
-
tunnelProcess.kill()
|
|
151
|
-
process.exit(0)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
tunnelProcess.on('exit', (code) => {
|
|
155
|
-
if (code !== 0) {
|
|
156
|
-
console.warn(`⚠️ Tunnel process exited with code ${code}`)
|
|
157
|
-
}
|
|
158
|
-
// Keep process alive for watch mode
|
|
159
|
-
new Promise(() => {})
|
|
160
|
-
})
|
|
161
|
-
} else {
|
|
162
|
-
console.warn('⚠️ cloudflared not found - skipping tunnel setup')
|
|
163
|
-
// Keep process alive for watch mode
|
|
164
|
-
await new Promise(() => {})
|
|
165
|
-
}
|
|
166
|
-
})
|