Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include commit hash in APP_VERSION constant #10

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
}
],
"scripts": {
"start": "bun index.ts",
"dev": "bun --watch index.ts",
"lint": "bunx tsc --noEmit --skipLibCheck --pretty",
"test": "bun test --coverage",
"build": "bun build --compile ./index.ts --outfile antelope-token-api"
"start": "export APP_VERSION=$(git rev-parse --short HEAD) && bun index.ts",
"dev": "export APP_VERSION=$(git rev-parse --short HEAD) && bun --watch index.ts",
"lint": "export APP_VERSION=$(git rev-parse --short HEAD) && bunx tsc --noEmit --skipLibCheck --pretty",
"test": "export APP_VERSION=$(git rev-parse --short HEAD) && bun test --coverage",
"build": "export APP_VERSION=$(git rev-parse --short HEAD) && bun build --compile ./index.ts --outfile antelope-token-api"
},
"dependencies": {
"@clickhouse/client-web": "latest",
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export const DEFAULT_MAX_LIMIT = 10000;
export const DEFAULT_VERBOSE = false;
export const DEFAULT_SORT_BY = "DESC";
export const APP_NAME = pkg.name;
export const APP_VERSION = `${pkg.version}+${process.env.APP_VERSION || "unknown"}`;

// parse command line options
const opts = program
.name(pkg.name)
.version(pkg.version)
.version(APP_VERSION)
.description(pkg.description)
.showHelpAfterError()
.addOption(new Option("-p, --port <number>", "HTTP port on which to attach the API").env("PORT").default(DEFAULT_PORT))
Expand Down
4 changes: 2 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Logger, type ILogObj } from "tslog";
import { name } from "../package.json" assert { type: "json" };
import { APP_NAME, APP_VERSION } from "./config.js";

class TsLogger extends Logger<ILogObj> {
constructor() {
super();
this.settings.minLevel = 5;
this.settings.name = name;
this.settings.name = `${APP_NAME}:${APP_VERSION}`;
}

public enable(type: "pretty" | "json" = "pretty") {
Expand Down
Loading