manage-apps/cli/build.mjs
Claude Code cc7b27e7eb chore(cli): 🔧 Update CLI build configuration to reflect new package name "manage-apps"
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-04-08 16:22:42 -07:00

44 lines
1.6 KiB
JavaScript

import esbuild from 'esbuild'
import { chmodSync, copyFileSync, mkdirSync, existsSync, cpSync } from 'fs'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { homedir } from 'os'
import { execFileSync } from 'child_process'
const dir = dirname(fileURLToPath(import.meta.url))
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
target: 'node20',
format: 'cjs',
outfile: 'dist/manage-apps.js',
banner: { js: '#!/usr/bin/env node' },
alias: { '@shared': resolve(dir, '../shared') },
nodePaths: [resolve(dir, 'node_modules')],
})
chmodSync('dist/manage-apps.js', 0o755)
const manDest = resolve(homedir(), '.local/share/man/man1')
mkdirSync(manDest, { recursive: true })
copyFileSync(resolve(dir, 'man/manage-apps.1'), resolve(manDest, 'manage-apps.1'))
// Build dashboard if it exists and has node_modules
const dashboardDir = resolve(dir, '../dashboard')
const dashboardDist = resolve(dashboardDir, 'dist')
const cliDashboardDist = resolve(dir, 'dist/dashboard')
if (existsSync(resolve(dashboardDir, 'node_modules'))) {
try {
execFileSync('/bin/sh', ['-c', 'node_modules/.bin/vite build'], { cwd: dashboardDir, stdio: 'pipe' })
mkdirSync(cliDashboardDist, { recursive: true })
cpSync(dashboardDist, cliDashboardDist, { recursive: true })
process.stdout.write('Dashboard built and copied to cli/dist/dashboard/\n')
} catch (e) {
process.stderr.write(`Dashboard build failed: ${e instanceof Error ? e.message : e}\n`)
}
} else if (existsSync(dashboardDir)) {
process.stdout.write('Dashboard: run pnpm install in dashboard/ to enable dashboard builds\n')
}