install current symlink automatically from git
This commit is contained in:
parent
6f03954850
commit
52bfa783e1
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -33,3 +33,6 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||||
|
|
||||||
# Finder (MacOS) folder config
|
# Finder (MacOS) folder config
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# app symlinks (created on boot)
|
||||||
|
apps/*/current
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260201-000000
|
|
||||||
1
apps/env/current
vendored
1
apps/env/current
vendored
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-181927
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
20260130-000000
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { App as SharedApp, AppState } from '@types'
|
import type { App as SharedApp, AppState } from '@types'
|
||||||
import type { Subprocess } from 'bun'
|
import type { Subprocess } from 'bun'
|
||||||
import { DEFAULT_EMOJI } from '@types'
|
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 { join, resolve } from 'path'
|
||||||
import { appLog, hostLog, setApps } from './tui'
|
import { appLog, hostLog, setApps } from './tui'
|
||||||
|
|
||||||
|
|
@ -84,6 +84,7 @@ export function initApps() {
|
||||||
initPortPool()
|
initPortPool()
|
||||||
setupShutdownHandlers()
|
setupShutdownHandlers()
|
||||||
rotateLogs()
|
rotateLogs()
|
||||||
|
createAppSymlinks()
|
||||||
discoverApps()
|
discoverApps()
|
||||||
runApps()
|
runApps()
|
||||||
}
|
}
|
||||||
|
|
@ -292,6 +293,37 @@ function allAppDirs() {
|
||||||
.sort()
|
.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() {
|
function discoverApps() {
|
||||||
for (const dir of allAppDirs()) {
|
for (const dir of allAppDirs()) {
|
||||||
const { pkg, error } = loadApp(dir)
|
const { pkg, error } = loadApp(dir)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user