forked from defunkt/toes
Merge branch 'cli-version'
This commit is contained in:
commit
c2264c42fc
|
|
@ -9,6 +9,7 @@ import { join } from 'path'
|
||||||
|
|
||||||
const DIST_DIR = join(import.meta.dir, '..', 'dist')
|
const DIST_DIR = join(import.meta.dir, '..', 'dist')
|
||||||
const ENTRY_POINT = join(import.meta.dir, '..', 'src', 'cli', 'index.ts')
|
const ENTRY_POINT = join(import.meta.dir, '..', 'src', 'cli', 'index.ts')
|
||||||
|
const GIT_SHA = Bun.spawnSync(['git', 'rev-parse', '--short', 'HEAD']).stdout.toString().trim() || 'unknown'
|
||||||
|
|
||||||
interface BuildTarget {
|
interface BuildTarget {
|
||||||
arch: string
|
arch: string
|
||||||
|
|
@ -40,6 +41,7 @@ async function buildCurrent() {
|
||||||
'bun',
|
'bun',
|
||||||
'--minify',
|
'--minify',
|
||||||
'--sourcemap=external',
|
'--sourcemap=external',
|
||||||
|
`--define=__GIT_SHA__="${GIT_SHA}"`,
|
||||||
'--outfile',
|
'--outfile',
|
||||||
output,
|
output,
|
||||||
], {
|
], {
|
||||||
|
|
@ -73,6 +75,7 @@ async function buildTarget(target: BuildTarget) {
|
||||||
`bun-${target.os}-${target.arch}`,
|
`bun-${target.os}-${target.arch}`,
|
||||||
'--minify',
|
'--minify',
|
||||||
'--sourcemap=external',
|
'--sourcemap=external',
|
||||||
|
`--define=__GIT_SHA__="${GIT_SHA}"`,
|
||||||
'--outfile',
|
'--outfile',
|
||||||
output,
|
output,
|
||||||
], {
|
], {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { program } from 'commander'
|
||||||
import color from 'kleur'
|
import color from 'kleur'
|
||||||
|
|
||||||
import pkg from '../../package.json'
|
import pkg from '../../package.json'
|
||||||
|
import { SHA } from './version'
|
||||||
import {
|
import {
|
||||||
cronList,
|
cronList,
|
||||||
cronLog,
|
cronLog,
|
||||||
|
|
@ -29,7 +30,7 @@ import {
|
||||||
|
|
||||||
program
|
program
|
||||||
.name('toes')
|
.name('toes')
|
||||||
.version(`v${pkg.version}`, '-v, --version')
|
.version(`v${pkg.version}-${SHA}`, '-v, --version')
|
||||||
.addHelpText('beforeAll', (ctx) => {
|
.addHelpText('beforeAll', (ctx) => {
|
||||||
if (ctx.command === program) {
|
if (ctx.command === program) {
|
||||||
return color.bold().cyan('🐾 Toes') + color.gray(' - personal web appliance\n')
|
return color.bold().cyan('🐾 Toes') + color.gray(' - personal web appliance\n')
|
||||||
|
|
|
||||||
3
src/cli/version.ts
Normal file
3
src/cli/version.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
declare var __GIT_SHA__: string
|
||||||
|
|
||||||
|
export const SHA: string = typeof __GIT_SHA__ !== 'undefined' ? __GIT_SHA__ : 'dev'
|
||||||
Loading…
Reference in New Issue
Block a user