UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

65 lines (54 loc) 1.18 kB
import { localTime } from '../datetime/localTime.js' import type { UnixTimestamp } from '../types.js' export interface BuildInfo { /** * Unix timestamp of when the build was made. */ ts: UnixTimestamp /** * Unix timestamp of commit ("committer date", not "author date") */ tsCommit: UnixTimestamp repoName: string branchName: string /** * GIT sha revision (first 7 characters) */ rev: string /** * "Version string" in the following format: * yyyyMMdd_HHmm_$repoName_$branch_$rev * * E.g: * 20190419_1728_myrepo_master_21aecf5 */ ver: string /** * Build during development. */ dev?: boolean /** * Build "environment". * Normally taken from process.env.APP_ENV * Can be undefined. */ env?: string } export function generateBuildInfoDev(): BuildInfo { const now = localTime.now() const ts = now.unix const rev = 'devRev' const branchName = 'devBranch' const repoName = 'devRepo' const tsCommit = now.unix const ver = [now.toStringCompact(), repoName, branchName, rev].join('_') return { ts, tsCommit, repoName, branchName, rev, ver, env: 'dev', } }