diff --git a/src/cli/index.ts b/src/cli/index.ts index 004744b..cc9e873 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -276,18 +276,20 @@ async function getApp(name: string) { console.log(color.green(`āœ“ Downloaded ${name}`)) } -function isApp(): boolean { +function getAppPackage(): { name?: string; scripts?: { toes?: string } } | null { try { - const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8')) - return !!pkg?.scripts?.toes - } catch (e) { - return false + return JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8')) + } catch { + return null } } +const isApp = () => !!getAppPackage()?.scripts?.toes + function resolveAppName(name?: string): string | undefined { if (name) return name - if (isApp()) return basename(process.cwd()) + const pkg = getAppPackage() + if (pkg?.scripts?.toes) return pkg.name || basename(process.cwd()) console.error('No app specified and current directory is not a toes app') return undefined } @@ -648,6 +650,22 @@ async function rmApp(arg?: string) { program .name('toes') .version('0.0.1', '-v, --version') + .addHelpText('beforeAll', (ctx) => { + if (ctx.command === program) { + return color.bold().cyan('\n🐾 Toes') + color.gray(' - personal web appliance\n') + } + return '' + }) + .configureOutput({ + writeOut: (str) => { + const colored = str + .replace(/^(Usage:)/gm, color.yellow('$1')) + .replace(/^(Commands:)/gm, color.yellow('$1')) + .replace(/^(Options:)/gm, color.yellow('$1')) + .replace(/^(Arguments:)/gm, color.yellow('$1')) + process.stdout.write(colored) + }, + }) program .command('info') diff --git a/src/client/index.tsx b/src/client/index.tsx index 2454785..a52f6db 100644 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -605,7 +605,7 @@ const AppDetail = ({ app }: { app: App }) => ( {app.name} - + {/* */}