color
This commit is contained in:
parent
aa5b536942
commit
07300eb96f
|
|
@ -276,18 +276,20 @@ async function getApp(name: string) {
|
||||||
console.log(color.green(`✓ Downloaded ${name}`))
|
console.log(color.green(`✓ Downloaded ${name}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
function isApp(): boolean {
|
function getAppPackage(): { name?: string; scripts?: { toes?: string } } | null {
|
||||||
try {
|
try {
|
||||||
const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8'))
|
return JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8'))
|
||||||
return !!pkg?.scripts?.toes
|
} catch {
|
||||||
} catch (e) {
|
return null
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isApp = () => !!getAppPackage()?.scripts?.toes
|
||||||
|
|
||||||
function resolveAppName(name?: string): string | undefined {
|
function resolveAppName(name?: string): string | undefined {
|
||||||
if (name) return name
|
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')
|
console.error('No app specified and current directory is not a toes app')
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
@ -648,6 +650,22 @@ async function rmApp(arg?: string) {
|
||||||
program
|
program
|
||||||
.name('toes')
|
.name('toes')
|
||||||
.version('0.0.1', '-v, --version')
|
.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
|
program
|
||||||
.command('info')
|
.command('info')
|
||||||
|
|
|
||||||
|
|
@ -605,7 +605,7 @@ const AppDetail = ({ app }: { app: App }) => (
|
||||||
{app.name}
|
{app.name}
|
||||||
</MainTitle>
|
</MainTitle>
|
||||||
<HeaderActions>
|
<HeaderActions>
|
||||||
<Button>Settings</Button>
|
{/* <Button>Settings</Button> */}
|
||||||
<Button variant="danger" onClick={() => openDeleteAppModal(app)}>Delete</Button>
|
<Button variant="danger" onClick={() => openDeleteAppModal(app)}>Delete</Button>
|
||||||
</HeaderActions>
|
</HeaderActions>
|
||||||
</MainHeader>
|
</MainHeader>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user