@naturalcycles/nodejs-lib 13.40.0 → 13.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,9 @@ export interface GenerateBuildInfoOptions {
4
4
  * If set - this timestamp will be used, instead of "current time".
5
5
  */
6
6
  overrideTimestamp?: UnixTimestamp;
7
+ /**
8
+ * Defaults to currently checked out git branch.
9
+ */
10
+ overrideBranchName?: string;
7
11
  }
8
12
  export declare function generateBuildInfo(opt?: GenerateBuildInfoOptions): BuildInfo;
@@ -8,7 +8,7 @@ function generateBuildInfo(opt = {}) {
8
8
  const now = js_lib_1.localTime.orNow(opt.overrideTimestamp);
9
9
  const ts = now.unix;
10
10
  const rev = git2_1.git2.getCurrentCommitSha();
11
- const branchName = git2_1.git2.getCurrentBranchName();
11
+ const branchName = opt.overrideBranchName || git2_1.git2.getCurrentBranchName();
12
12
  const repoName = git2_1.git2.getCurrentRepoName();
13
13
  const tsCommit = git2_1.git2.getCurrentCommitTimestamp();
14
14
  const ver = [now.toStringCompact(), repoName, branchName, rev].join('_');
@@ -1,4 +1,4 @@
1
- import { BaseDBEntity, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib';
1
+ import { BaseDBEntity, IANATimezone, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib';
2
2
  import { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi';
3
3
  import { NumberSchema } from './number.extensions';
4
4
  import { StringSchema } from './string.extensions';
@@ -92,7 +92,7 @@ export declare const SEM_VER_REGEX: RegExp;
92
92
  export declare const semVerSchema: StringSchema<string>;
93
93
  export declare const userAgentSchema: StringSchema<string>;
94
94
  export declare const utcOffsetSchema: NumberSchema<number>;
95
- export declare const ianaTimezoneSchema: StringSchema<string>;
95
+ export declare const ianaTimezoneSchema: StringSchema<IANATimezone>;
96
96
  export declare const ipAddressSchema: StringSchema<string>;
97
97
  export declare const baseDBEntitySchema: ObjectSchema<BaseDBEntity>;
98
98
  export declare const macAddressSchema: StringSchema<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.40.0",
3
+ "version": "13.41.1",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
@@ -13,6 +13,11 @@ export interface GenerateBuildInfoOptions {
13
13
  * If set - this timestamp will be used, instead of "current time".
14
14
  */
15
15
  overrideTimestamp?: UnixTimestamp
16
+
17
+ /**
18
+ * Defaults to currently checked out git branch.
19
+ */
20
+ overrideBranchName?: string
16
21
  }
17
22
 
18
23
  export function generateBuildInfo(opt: GenerateBuildInfoOptions = {}): BuildInfo {
@@ -20,7 +25,7 @@ export function generateBuildInfo(opt: GenerateBuildInfoOptions = {}): BuildInfo
20
25
  const ts = now.unix
21
26
 
22
27
  const rev = git2.getCurrentCommitSha()
23
- const branchName = git2.getCurrentBranchName()
28
+ const branchName = opt.overrideBranchName || git2.getCurrentBranchName()
24
29
  const repoName = git2.getCurrentRepoName()
25
30
  const tsCommit = git2.getCurrentCommitTimestamp()
26
31
 
@@ -4,6 +4,7 @@ import {
4
4
  _stringEnumKeys,
5
5
  _stringEnumValues,
6
6
  BaseDBEntity,
7
+ IANATimezone,
7
8
  IsoDateTime,
8
9
  NumberEnum,
9
10
  StringEnum,
@@ -177,7 +178,7 @@ export const ianaTimezoneSchema = stringSchema
177
178
  .valid(...Intl.supportedValuesOf('timeZone'), 'UTC')
178
179
  .messages({
179
180
  'any.only': `must be a valid IANA timezone string`,
180
- })
181
+ }) as StringSchema<IANATimezone>
181
182
 
182
183
  export const ipAddressSchema = stringSchema.ip()
183
184