Compare commits
No commits in common. "6afefcec5b504778f96f7f44c7ba424e0323d8b9" and "c10ebe3c98837bb7e1821b52bac9eaec5243b1be" have entirely different histories.
6afefcec5b
...
c10ebe3c98
|
|
@ -37,10 +37,18 @@ async function waitForState(name: string, target: string, timeout: number): Prom
|
||||||
export async function configShow() {
|
export async function configShow() {
|
||||||
console.log(`Host: ${color.bold(HOST)}`)
|
console.log(`Host: ${color.bold(HOST)}`)
|
||||||
|
|
||||||
const syncState = readSyncState(process.cwd())
|
const source = process.env.TOES_URL ? 'TOES_URL' : process.env.DEV ? 'DEV' : '(default)'
|
||||||
if (syncState) {
|
console.log(`Source: ${color.gray(source)}`)
|
||||||
console.log(`Version: ${color.bold(syncState.version)}`)
|
|
||||||
|
if (process.env.TOES_URL) {
|
||||||
|
console.log(` TOES_URL=${process.env.TOES_URL}`)
|
||||||
}
|
}
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log(` DEV=${process.env.DEV}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const syncState = readSyncState(process.cwd())
|
||||||
|
console.log(`Version: ${syncState ? color.bold(syncState.version) : color.gray('(not deployed)')}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function infoApp(arg?: string) {
|
export async function infoApp(arg?: string) {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync,
|
||||||
import { dirname, join } from 'path'
|
import { dirname, join } from 'path'
|
||||||
import { Hype } from '@because/hype'
|
import { Hype } from '@because/hype'
|
||||||
|
|
||||||
const MAX_VERSIONS = 5
|
|
||||||
|
|
||||||
interface FileChangeEvent {
|
interface FileChangeEvent {
|
||||||
hash?: string
|
hash?: string
|
||||||
path: string
|
path: string
|
||||||
|
|
@ -296,7 +294,7 @@ router.post('/apps/:app/activate', async c => {
|
||||||
// Atomic rename over old symlink/directory
|
// Atomic rename over old symlink/directory
|
||||||
renameSync(tempLink, currentLink)
|
renameSync(tempLink, currentLink)
|
||||||
|
|
||||||
// Clean up old versions
|
// Clean up old versions (keep 5 most recent)
|
||||||
try {
|
try {
|
||||||
const entries = readdirSync(appDir, { withFileTypes: true })
|
const entries = readdirSync(appDir, { withFileTypes: true })
|
||||||
|
|
||||||
|
|
@ -307,24 +305,13 @@ router.post('/apps/:app/activate', async c => {
|
||||||
.sort()
|
.sort()
|
||||||
.reverse() // Newest first
|
.reverse() // Newest first
|
||||||
|
|
||||||
// Keep most recent, delete the rest
|
// Keep 5 most recent, delete the rest
|
||||||
const toDelete = versionDirs.slice(MAX_VERSIONS)
|
const toDelete = versionDirs.slice(5)
|
||||||
for (const dir of toDelete) {
|
for (const dir of toDelete) {
|
||||||
const dirPath = join(appDir, dir)
|
const dirPath = join(appDir, dir)
|
||||||
rmSync(dirPath, { recursive: true, force: true })
|
rmSync(dirPath, { recursive: true, force: true })
|
||||||
console.log(`Cleaned up old version: ${dir}`)
|
console.log(`Cleaned up old version: ${dir}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete node_modules from old kept versions (not the active one)
|
|
||||||
const toKeep = versionDirs.slice(0, MAX_VERSIONS)
|
|
||||||
for (const dir of toKeep) {
|
|
||||||
if (dir === version) continue
|
|
||||||
const nm = join(appDir, dir, 'node_modules')
|
|
||||||
if (existsSync(nm)) {
|
|
||||||
rmSync(nm, { recursive: true, force: true })
|
|
||||||
console.log(`Removed node_modules from old version: ${dir}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Log but don't fail activation if cleanup fails
|
// Log but don't fail activation if cleanup fails
|
||||||
console.error(`Failed to clean up old versions: ${e}`)
|
console.error(`Failed to clean up old versions: ${e}`)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user