Skip to content

Commit

Permalink
feat(api): generate better version names in the API config
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed May 20, 2021
1 parent ac28224 commit 38907eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/api/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ export function pickAccept(accept: string | undefined): ContentType {

return "text/html";
}

export function generateReleaseName(pkg: {name: string; version: string}): string {
const slashIndex = pkg.name.lastIndexOf("/");
const sanitizedName = slashIndex === -1 ? pkg.name : pkg.name.slice(slashIndex + 1);
return `${sanitizedName}@${pkg.version}`;
}
4 changes: 2 additions & 2 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {readFileSync} from "fs";
import {Buffer} from "buffer";
import {booleanize} from "../api/util";
import {LogLevel} from "../service/logger/i-logger-service";
import {parseLogLevel} from "../api/util/util";
import {generateReleaseName, parseLogLevel} from "../api/util/util";
import pkg from "../../package.json";

export interface Config {
Expand All @@ -22,7 +22,7 @@ export interface Config {
}

export const config: Config = {
version: `${pkg.name}@${pkg.version}:${Date.now()}`.replace(/\//g, "_"),
version: generateReleaseName(pkg),
sentryDsn: environment.SENTRY_DSN,
environment: environment.NODE_ENV,
production: environment.NODE_ENV != null && environment.NODE_ENV.toLowerCase() === "production",
Expand Down

0 comments on commit 38907eb

Please sign in to comment.