@take-out/scripts 0.0.45 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@take-out/scripts",
3
- "version": "0.0.45",
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.45",
27
+ "@take-out/helpers": "0.0.47",
28
28
  "glob": "^11.0.0"
29
29
  },
30
30
  "devDependencies": {
package/src/release.ts CHANGED
@@ -279,12 +279,70 @@ async function main() {
279
279
  }
280
280
 
281
281
  console.info(`āœ… Done\n`)
282
+
283
+ // update downstream repos if they exist
284
+ if (!canary) {
285
+ await updateDownstreamRepos()
286
+ }
282
287
  } catch (err) {
283
288
  console.info('\nError:\n', err)
284
289
  process.exit(1)
285
290
  }
286
291
  }
287
292
 
293
+ async function updateDownstreamRepos() {
294
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ''
295
+ const downstreamRepos = [join(homeDir, 'takeout-free'), join(homeDir, 'takeout-static')]
296
+
297
+ for (const repoPath of downstreamRepos) {
298
+ if (!(await fs.pathExists(repoPath))) {
299
+ continue
300
+ }
301
+
302
+ console.info(`\nšŸ“¦ Found downstream repo: ${repoPath}`)
303
+
304
+ try {
305
+ // check for uncommitted changes
306
+ const statusOut = await run(`git status --porcelain`, {
307
+ cwd: repoPath,
308
+ silent: true,
309
+ })
310
+ if (statusOut.stdout.trim()) {
311
+ console.warn(` āš ļø Skipping ${repoPath}: has uncommitted changes`)
312
+ continue
313
+ }
314
+
315
+ // pull latest
316
+ console.info(` Pulling latest...`)
317
+ try {
318
+ await run(`git pull --rebase origin HEAD`, { cwd: repoPath, silent: true })
319
+ } catch (err) {
320
+ console.warn(` āš ļø Skipping ${repoPath}: failed to pull from origin`)
321
+ continue
322
+ }
323
+
324
+ // run upgrade
325
+ console.info(` Running upgrade takeout...`)
326
+ await run(`bun up takeout`, { cwd: repoPath })
327
+
328
+ // run check:all
329
+ console.info(` Running check:all...`)
330
+ try {
331
+ await run(`bun check:all`, { cwd: repoPath })
332
+ console.info(` āœ… ${repoPath} upgraded successfully`)
333
+ } catch (err) {
334
+ console.warn(
335
+ ` āš ļø ${repoPath}: check:all failed after upgrade, please review manually`
336
+ )
337
+ // reset the changes since check failed
338
+ await run(`git checkout .`, { cwd: repoPath, silent: true })
339
+ }
340
+ } catch (err) {
341
+ console.warn(` āš ļø Error updating ${repoPath}:`, err)
342
+ }
343
+ }
344
+ }
345
+
288
346
  async function getWorkspacePackages() {
289
347
  // read workspaces from root package.json
290
348
  const rootPackageJson = await fs.readJSON(join(process.cwd(), 'package.json'))
@@ -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
- })