install current symlink automatically from git

This commit is contained in:
Chris Wanstrath 2026-02-02 16:03:32 -08:00
parent 6f03954850
commit 52bfa783e1
12 changed files with 36 additions and 11 deletions

3
.gitignore vendored
View File

@ -33,3 +33,6 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Finder (MacOS) folder config
.DS_Store
# app symlinks (created on boot)
apps/*/current

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260201-000000

1
apps/env/current vendored
View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260130-181927

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1 +0,0 @@
20260130-000000

View File

@ -1,7 +1,7 @@
import type { App as SharedApp, AppState } from '@types'
import type { Subprocess } from 'bun'
import { DEFAULT_EMOJI } from '@types'
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync } from 'fs'
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, symlinkSync, unlinkSync, writeFileSync } from 'fs'
import { join, resolve } from 'path'
import { appLog, hostLog, setApps } from './tui'
@ -84,6 +84,7 @@ export function initApps() {
initPortPool()
setupShutdownHandlers()
rotateLogs()
createAppSymlinks()
discoverApps()
runApps()
}
@ -292,6 +293,37 @@ function allAppDirs() {
.sort()
}
function createAppSymlinks() {
for (const app of readdirSync(APPS_DIR, { withFileTypes: true })) {
if (!app.isDirectory()) continue
const appDir = join(APPS_DIR, app.name)
const currentPath = join(appDir, 'current')
if (existsSync(currentPath)) continue
// Find valid version directories
const versions = readdirSync(appDir, { withFileTypes: true })
.filter(e => {
if (!e.isDirectory()) return false
const pkgPath = join(appDir, e.name, 'package.json')
if (!existsSync(pkgPath)) return false
try {
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
return !!pkg.scripts?.toes
} catch {
return false
}
})
.map(e => e.name)
.sort()
.reverse()
const latest = versions[0]
if (latest) {
symlinkSync(latest, currentPath)
}
}
}
function discoverApps() {
for (const dir of allAppDirs()) {
const { pkg, error } = loadApp(dir)