@hg-ts/execution-mode 0.0.15
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.
- package/.eslintcache +1 -0
- package/.eslintrc.json +3 -0
- package/README.md +1 -0
- package/dist/execution-mode.d.ts +28 -0
- package/dist/execution-mode.d.ts.map +1 -0
- package/dist/execution-mode.js +69 -0
- package/dist/execution-mode.js.map +1 -0
- package/dist/execution.mode.d.ts +28 -0
- package/dist/execution.mode.d.ts.map +1 -0
- package/dist/execution.mode.js +69 -0
- package/dist/execution.mode.js.map +1 -0
- package/dist/hg.execution-mode.d.ts +5 -0
- package/dist/hg.execution-mode.d.ts.map +1 -0
- package/dist/hg.execution-mode.js +11 -0
- package/dist/hg.execution-mode.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mock.execution-mode.d.ts +5 -0
- package/dist/mock.execution-mode.d.ts.map +1 -0
- package/dist/mock.execution-mode.js +11 -0
- package/dist/mock.execution-mode.js.map +1 -0
- package/dist-esm/execution-mode.d.ts +28 -0
- package/dist-esm/execution-mode.d.ts.map +1 -0
- package/dist-esm/execution-mode.js +65 -0
- package/dist-esm/execution-mode.js.map +1 -0
- package/dist-esm/execution.mode.d.ts +28 -0
- package/dist-esm/execution.mode.d.ts.map +1 -0
- package/dist-esm/execution.mode.js +65 -0
- package/dist-esm/execution.mode.js.map +1 -0
- package/dist-esm/hg.execution-mode.d.ts +5 -0
- package/dist-esm/hg.execution-mode.d.ts.map +1 -0
- package/dist-esm/hg.execution-mode.js +7 -0
- package/dist-esm/hg.execution-mode.js.map +1 -0
- package/dist-esm/index.d.ts +5 -0
- package/dist-esm/index.d.ts.map +1 -0
- package/dist-esm/index.js +5 -0
- package/dist-esm/index.js.map +1 -0
- package/dist-esm/mock.execution-mode.d.ts +5 -0
- package/dist-esm/mock.execution-mode.d.ts.map +1 -0
- package/dist-esm/mock.execution-mode.js +7 -0
- package/dist-esm/mock.execution-mode.js.map +1 -0
- package/package.json +35 -0
- package/src/execution-mode.ts +78 -0
- package/src/hg.execution-mode.ts +10 -0
- package/src/index.ts +5 -0
- package/src/mock.execution-mode.ts +11 -0
- package/tsconfig.esm.json +9 -0
- package/tsconfig.json +10 -0
package/.eslintcache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/Volumes/Work/ts/hg/framework/packages/execution-mode/src/index.ts":"1","/Volumes/Work/ts/hg/framework/packages/execution-mode/src/execution-mode.ts":"2","/Volumes/Work/ts/hg/framework/packages/execution-mode/src/hg.execution-mode.ts":"3","/Volumes/Work/ts/hg/framework/packages/execution-mode/src/mock.execution-mode.ts":"4"},{"size":134,"mtime":1665300013476,"results":"5","hashOfConfig":"6"},{"size":1723,"mtime":1664749374276,"results":"7","hashOfConfig":"6"},{"size":202,"mtime":1664686076507,"results":"8","hashOfConfig":"6"},{"size":284,"mtime":1664749380282,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","suppressedMessages":"12","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"165ymhh",{"filePath":"13","messages":"14","suppressedMessages":"15","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","suppressedMessages":"18","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","suppressedMessages":"21","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Volumes/Work/ts/hg/framework/packages/execution-mode/src/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/execution-mode/src/execution-mode.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/execution-mode/src/hg.execution-mode.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/execution-mode/src/mock.execution-mode.ts",[],[]]
|
package/.eslintrc.json
ADDED
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @hg/exception
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum ExecutionModeVariants {
|
|
2
|
+
DEBUG = "debug",
|
|
3
|
+
DEV = "dev",
|
|
4
|
+
TEST = "test",
|
|
5
|
+
QA = "qa",
|
|
6
|
+
DEMO = "demo",
|
|
7
|
+
PROD = "prod"
|
|
8
|
+
}
|
|
9
|
+
export declare class ExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> {
|
|
10
|
+
private value;
|
|
11
|
+
private readonly projectName;
|
|
12
|
+
private readonly defaultValue;
|
|
13
|
+
constructor(projectName: string, defaultValue: ValueType);
|
|
14
|
+
isDebug(): boolean;
|
|
15
|
+
isDev(): boolean;
|
|
16
|
+
isTest(): boolean;
|
|
17
|
+
isQa(): boolean;
|
|
18
|
+
isDemo(): boolean;
|
|
19
|
+
isProd(): boolean;
|
|
20
|
+
getValue(): ValueType;
|
|
21
|
+
isValueIn(variants: ValueType[]): boolean;
|
|
22
|
+
is(expected: ValueType): boolean;
|
|
23
|
+
protected getEnvName(): string;
|
|
24
|
+
protected isValueValid(value?: string): value is ValueType;
|
|
25
|
+
protected getRawValue(): string | undefined;
|
|
26
|
+
private initValue;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=execution-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-mode.d.ts","sourceRoot":"","sources":["../src/execution-mode.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB;IAChC,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,EAAE,OAAO;IACT,IAAI,SAAS;IACb,IAAI,SAAS;CACb;AAED,qBAAa,aAAa,CAAC,SAAS,SAAS,qBAAqB,GAAG,qBAAqB;IACzF,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;gBAEtB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS;IAMxD,OAAO,IAAI,OAAO;IAIlB,KAAK,IAAI,OAAO;IAIhB,MAAM,IAAI,OAAO;IAIjB,IAAI,IAAI,OAAO;IAIf,MAAM,IAAI,OAAO;IAIjB,MAAM,IAAI,OAAO;IAIjB,QAAQ,IAAI,SAAS;IAIrB,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO;IAIzC,EAAE,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO;IAIvC,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS;IAI1D,SAAS,CAAC,WAAW,IAAI,MAAM,GAAG,SAAS;IAI3C,OAAO,CAAC,SAAS;CASjB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionMode = exports.ExecutionModeVariants = void 0;
|
|
4
|
+
var ExecutionModeVariants;
|
|
5
|
+
(function (ExecutionModeVariants) {
|
|
6
|
+
ExecutionModeVariants["DEBUG"] = "debug";
|
|
7
|
+
ExecutionModeVariants["DEV"] = "dev";
|
|
8
|
+
ExecutionModeVariants["TEST"] = "test";
|
|
9
|
+
ExecutionModeVariants["QA"] = "qa";
|
|
10
|
+
ExecutionModeVariants["DEMO"] = "demo";
|
|
11
|
+
ExecutionModeVariants["PROD"] = "prod";
|
|
12
|
+
})(ExecutionModeVariants = exports.ExecutionModeVariants || (exports.ExecutionModeVariants = {}));
|
|
13
|
+
class ExecutionMode {
|
|
14
|
+
value;
|
|
15
|
+
projectName;
|
|
16
|
+
defaultValue;
|
|
17
|
+
constructor(projectName, defaultValue) {
|
|
18
|
+
this.projectName = projectName.toUpperCase();
|
|
19
|
+
this.defaultValue = defaultValue;
|
|
20
|
+
this.initValue();
|
|
21
|
+
}
|
|
22
|
+
isDebug() {
|
|
23
|
+
return this.value === ExecutionModeVariants.DEBUG;
|
|
24
|
+
}
|
|
25
|
+
isDev() {
|
|
26
|
+
return this.value === ExecutionModeVariants.DEV;
|
|
27
|
+
}
|
|
28
|
+
isTest() {
|
|
29
|
+
return this.value === ExecutionModeVariants.TEST;
|
|
30
|
+
}
|
|
31
|
+
isQa() {
|
|
32
|
+
return this.value === ExecutionModeVariants.QA;
|
|
33
|
+
}
|
|
34
|
+
isDemo() {
|
|
35
|
+
return this.value === ExecutionModeVariants.DEMO;
|
|
36
|
+
}
|
|
37
|
+
isProd() {
|
|
38
|
+
return this.value === ExecutionModeVariants.PROD;
|
|
39
|
+
}
|
|
40
|
+
getValue() {
|
|
41
|
+
return this.value;
|
|
42
|
+
}
|
|
43
|
+
isValueIn(variants) {
|
|
44
|
+
return variants.includes(this.value);
|
|
45
|
+
}
|
|
46
|
+
is(expected) {
|
|
47
|
+
return expected === this.value;
|
|
48
|
+
}
|
|
49
|
+
getEnvName() {
|
|
50
|
+
return `${this.projectName}_ENV`;
|
|
51
|
+
}
|
|
52
|
+
isValueValid(value) {
|
|
53
|
+
return Object.keys(ExecutionModeVariants).includes(value);
|
|
54
|
+
}
|
|
55
|
+
getRawValue() {
|
|
56
|
+
return process.env[this.getEnvName()];
|
|
57
|
+
}
|
|
58
|
+
initValue() {
|
|
59
|
+
const value = this.getRawValue();
|
|
60
|
+
if (this.isValueValid(value)) {
|
|
61
|
+
this.value = value;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.value = this.defaultValue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.ExecutionMode = ExecutionMode;
|
|
69
|
+
//# sourceMappingURL=execution-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-mode.js","sourceRoot":"","sources":["../src/execution-mode.ts"],"names":[],"mappings":";;;A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AAC;IAES,UAAU;QACnB,OAAO,GAAG,IAAI,CAAC,WAAW,MAAM,CAAC;IAClC,CAAC;IAES,YAAY,CAAC,KAAc;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,KAAY,CAAC,CAAC;IAClE,CAAC;IAES,WAAW;QACpB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACvC,CAAC;IAEO,SAAS;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACnB;aAAM;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;SAC/B;IACF,CAAC;CACD;AApED,sCAoEC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum ExecutionModeVariants {
|
|
2
|
+
DEBUG = "debug",
|
|
3
|
+
DEV = "dev",
|
|
4
|
+
TEST = "test",
|
|
5
|
+
QA = "qa",
|
|
6
|
+
DEMO = "demo",
|
|
7
|
+
PROD = "prod"
|
|
8
|
+
}
|
|
9
|
+
export declare class ExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> {
|
|
10
|
+
private value;
|
|
11
|
+
private readonly projectName;
|
|
12
|
+
private readonly defaultValue;
|
|
13
|
+
constructor(projectName: string, defaultValue: ValueType);
|
|
14
|
+
isDebug(): boolean;
|
|
15
|
+
isDev(): boolean;
|
|
16
|
+
isTest(): boolean;
|
|
17
|
+
isQa(): boolean;
|
|
18
|
+
isDemo(): boolean;
|
|
19
|
+
isProd(): boolean;
|
|
20
|
+
getValue(): ValueType;
|
|
21
|
+
isValueIn(variants: ValueType[]): boolean;
|
|
22
|
+
is(expected: ValueType): boolean;
|
|
23
|
+
protected getEnvName(): string;
|
|
24
|
+
protected isValueValid(value?: string): value is ValueType;
|
|
25
|
+
private initValue;
|
|
26
|
+
private getRawValue;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=execution.mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.mode.d.ts","sourceRoot":"","sources":["../src/execution.mode.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB;IAChC,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,EAAE,OAAO;IACT,IAAI,SAAS;IACb,IAAI,SAAS;CACb;AAED,qBAAa,aAAa,CAAC,SAAS,SAAS,qBAAqB,GAAG,qBAAqB;IACzF,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;gBAEtB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS;IAMxD,OAAO,IAAI,OAAO;IAIlB,KAAK,IAAI,OAAO;IAIhB,MAAM,IAAI,OAAO;IAIjB,IAAI,IAAI,OAAO;IAIf,MAAM,IAAI,OAAO;IAIjB,MAAM,IAAI,OAAO;IAIjB,QAAQ,IAAI,SAAS;IAIrB,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO;IAIzC,EAAE,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO;IAIvC,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS;IAI1D,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,WAAW;CAGnB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionMode = exports.ExecutionModeVariants = void 0;
|
|
4
|
+
var ExecutionModeVariants;
|
|
5
|
+
(function (ExecutionModeVariants) {
|
|
6
|
+
ExecutionModeVariants["DEBUG"] = "debug";
|
|
7
|
+
ExecutionModeVariants["DEV"] = "dev";
|
|
8
|
+
ExecutionModeVariants["TEST"] = "test";
|
|
9
|
+
ExecutionModeVariants["QA"] = "qa";
|
|
10
|
+
ExecutionModeVariants["DEMO"] = "demo";
|
|
11
|
+
ExecutionModeVariants["PROD"] = "prod";
|
|
12
|
+
})(ExecutionModeVariants = exports.ExecutionModeVariants || (exports.ExecutionModeVariants = {}));
|
|
13
|
+
class ExecutionMode {
|
|
14
|
+
value;
|
|
15
|
+
projectName;
|
|
16
|
+
defaultValue;
|
|
17
|
+
constructor(projectName, defaultValue) {
|
|
18
|
+
this.projectName = projectName.toUpperCase();
|
|
19
|
+
this.defaultValue = defaultValue;
|
|
20
|
+
this.initValue();
|
|
21
|
+
}
|
|
22
|
+
isDebug() {
|
|
23
|
+
return this.value === ExecutionModeVariants.DEBUG;
|
|
24
|
+
}
|
|
25
|
+
isDev() {
|
|
26
|
+
return this.value === ExecutionModeVariants.DEV;
|
|
27
|
+
}
|
|
28
|
+
isTest() {
|
|
29
|
+
return this.value === ExecutionModeVariants.TEST;
|
|
30
|
+
}
|
|
31
|
+
isQa() {
|
|
32
|
+
return this.value === ExecutionModeVariants.QA;
|
|
33
|
+
}
|
|
34
|
+
isDemo() {
|
|
35
|
+
return this.value === ExecutionModeVariants.DEMO;
|
|
36
|
+
}
|
|
37
|
+
isProd() {
|
|
38
|
+
return this.value === ExecutionModeVariants.PROD;
|
|
39
|
+
}
|
|
40
|
+
getValue() {
|
|
41
|
+
return this.value;
|
|
42
|
+
}
|
|
43
|
+
isValueIn(variants) {
|
|
44
|
+
return variants.includes(this.value);
|
|
45
|
+
}
|
|
46
|
+
is(expected) {
|
|
47
|
+
return expected === this.value;
|
|
48
|
+
}
|
|
49
|
+
getEnvName() {
|
|
50
|
+
return `ENV_${this.projectName}`;
|
|
51
|
+
}
|
|
52
|
+
isValueValid(value) {
|
|
53
|
+
return Object.keys(ExecutionModeVariants).includes(value);
|
|
54
|
+
}
|
|
55
|
+
initValue() {
|
|
56
|
+
const value = this.getRawValue();
|
|
57
|
+
if (this.isValueValid(value)) {
|
|
58
|
+
this.value = value;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.value = this.defaultValue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
getRawValue() {
|
|
65
|
+
return process.env[this.getEnvName()];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.ExecutionMode = ExecutionMode;
|
|
69
|
+
//# sourceMappingURL=execution.mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.mode.js","sourceRoot":"","sources":["../src/execution.mode.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAChC,wCAAe,CAAA;IACf,oCAAW,CAAA;IACX,sCAAa,CAAA;IACb,kCAAS,CAAA;IACT,sCAAa,CAAA;IACb,sCAAa,CAAA;AACd,CAAC,EAPW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAOhC;AAED,MAAa,aAAa;IACjB,KAAK,CAAY;IACR,WAAW,CAAS;IACpB,YAAY,CAAY;IAEzC,YAAmB,WAAmB,EAAE,YAAuB;QAC9D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,KAAK,CAAC;IACnD,CAAC;IAEM,KAAK;QACX,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,GAAG,CAAC;IACjD,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,IAAI,CAAC;IAClD,CAAC;IAEM,IAAI;QACV,OAAO,IAAI,CAAC,KAAK,KA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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HgExecutionMode = void 0;
|
|
4
|
+
const execution_mode_1 = require("./execution-mode");
|
|
5
|
+
class HgExecutionMode extends execution_mode_1.ExecutionMode {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('HG', execution_mode_1.ExecutionModeVariants.PROD);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.HgExecutionMode = HgExecutionMode;
|
|
11
|
+
//# sourceMappingURL=hg.execution-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hg.execution-mode.js","sourceRoot":"","sources":["../src/hg.execution-mode.ts"],"names":[],"mappings":";;;AAAA,qDAG0B;AAE1B,MAAa,eAAgB,SAAQ,8BAAa;IACjD;QACC,KAAK,CAAC,IAAI,EAAE,sCAAqB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACD;AAJD,0CAIC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
require("@hg-ts/types");
|
|
5
|
+
tslib_1.__exportStar(require("./execution-mode"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./hg.execution-mode"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./mock.execution-mode"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wBAAsB;AAEtB,2DAAiC;AACjC,8DAAoC;AACpC,gEAAsC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExecutionMode, ExecutionModeVariants } from './execution-mode';
|
|
2
|
+
export declare class MockExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> extends ExecutionMode<ValueType> {
|
|
3
|
+
constructor(value: ValueType);
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=mock.execution-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.execution-mode.d.ts","sourceRoot":"","sources":["../src/mock.execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAiB,CAAC,SAAS,SAAS,qBAAqB,GAAG,qBAAqB,CAC7F,SAAQ,aAAa,CAAC,SAAS,CAAC;gBACb,KAAK,EAAE,SAAS;CAGnC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockExecutionMode = void 0;
|
|
4
|
+
const execution_mode_1 = require("./execution-mode");
|
|
5
|
+
class MockExecutionMode extends execution_mode_1.ExecutionMode {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super('NEVER_USED', value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MockExecutionMode = MockExecutionMode;
|
|
11
|
+
//# sourceMappingURL=mock.execution-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.execution-mode.js","sourceRoot":"","sources":["../src/mock.execution-mode.ts"],"names":[],"mappings":";;;AAAA,qDAG0B;AAE1B,MAAa,iBACZ,SAAQ,8BAAwB;IAChC,YAAmB,KAAgB;QAClC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACD;AALD,8CAKC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum ExecutionModeVariants {
|
|
2
|
+
DEBUG = "debug",
|
|
3
|
+
DEV = "dev",
|
|
4
|
+
TEST = "test",
|
|
5
|
+
QA = "qa",
|
|
6
|
+
DEMO = "demo",
|
|
7
|
+
PROD = "prod"
|
|
8
|
+
}
|
|
9
|
+
export declare class ExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> {
|
|
10
|
+
private value;
|
|
11
|
+
private readonly projectName;
|
|
12
|
+
private readonly defaultValue;
|
|
13
|
+
constructor(projectName: string, defaultValue: ValueType);
|
|
14
|
+
isDebug(): boolean;
|
|
15
|
+
isDev(): boolean;
|
|
16
|
+
isTest(): boolean;
|
|
17
|
+
isQa(): boolean;
|
|
18
|
+
isDemo(): boolean;
|
|
19
|
+
isProd(): boolean;
|
|
20
|
+
getValue(): ValueType;
|
|
21
|
+
isValueIn(variants: ValueType[]): boolean;
|
|
22
|
+
is(expected: ValueType): boolean;
|
|
23
|
+
protected getEnvName(): string;
|
|
24
|
+
protected isValueValid(value?: string): value is ValueType;
|
|
25
|
+
protected getRawValue(): string | undefined;
|
|
26
|
+
private initValue;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=execution-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-mode.d.ts","sourceRoot":"","sources":["../src/execution-mode.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB;IAChC,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,EAAE,OAAO;IACT,IAAI,SAAS;IACb,IAAI,SAAS;CACb;AAED,qBAAa,aAAa,CAAC,SAAS,SAAS,qBAAqB,GAAG,qBAAqB;IACzF,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;gBAEtB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS;IAMxD,OAAO,IAAI,OAAO;IAIlB,KAAK,IAAI,OAAO;IAIhB,MAAM,IAAI,OAAO;IAIjB,IAAI,IAAI,OAAO;IAIf,MAAM,IAAI,OAAO;IAIjB,MAAM,IAAI,OAAO;IAIjB,QAAQ,IAAI,SAAS;IAIrB,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO;IAIzC,EAAE,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO;IAIvC,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS;IAI1D,SAAS,CAAC,WAAW,IAAI,MAAM,GAAG,SAAS;IAI3C,OAAO,CAAC,SAAS;CASjB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export var ExecutionModeVariants;
|
|
2
|
+
(function (ExecutionModeVariants) {
|
|
3
|
+
ExecutionModeVariants["DEBUG"] = "debug";
|
|
4
|
+
ExecutionModeVariants["DEV"] = "dev";
|
|
5
|
+
ExecutionModeVariants["TEST"] = "test";
|
|
6
|
+
ExecutionModeVariants["QA"] = "qa";
|
|
7
|
+
ExecutionModeVariants["DEMO"] = "demo";
|
|
8
|
+
ExecutionModeVariants["PROD"] = "prod";
|
|
9
|
+
})(ExecutionModeVariants || (ExecutionModeVariants = {}));
|
|
10
|
+
export class ExecutionMode {
|
|
11
|
+
value;
|
|
12
|
+
projectName;
|
|
13
|
+
defaultValue;
|
|
14
|
+
constructor(projectName, defaultValue) {
|
|
15
|
+
this.projectName = projectName.toUpperCase();
|
|
16
|
+
this.defaultValue = defaultValue;
|
|
17
|
+
this.initValue();
|
|
18
|
+
}
|
|
19
|
+
isDebug() {
|
|
20
|
+
return this.value === ExecutionModeVariants.DEBUG;
|
|
21
|
+
}
|
|
22
|
+
isDev() {
|
|
23
|
+
return this.value === ExecutionModeVariants.DEV;
|
|
24
|
+
}
|
|
25
|
+
isTest() {
|
|
26
|
+
return this.value === ExecutionModeVariants.TEST;
|
|
27
|
+
}
|
|
28
|
+
isQa() {
|
|
29
|
+
return this.value === ExecutionModeVariants.QA;
|
|
30
|
+
}
|
|
31
|
+
isDemo() {
|
|
32
|
+
return this.value === ExecutionModeVariants.DEMO;
|
|
33
|
+
}
|
|
34
|
+
isProd() {
|
|
35
|
+
return this.value === ExecutionModeVariants.PROD;
|
|
36
|
+
}
|
|
37
|
+
getValue() {
|
|
38
|
+
return this.value;
|
|
39
|
+
}
|
|
40
|
+
isValueIn(variants) {
|
|
41
|
+
return variants.includes(this.value);
|
|
42
|
+
}
|
|
43
|
+
is(expected) {
|
|
44
|
+
return expected === this.value;
|
|
45
|
+
}
|
|
46
|
+
getEnvName() {
|
|
47
|
+
return `${this.projectName}_ENV`;
|
|
48
|
+
}
|
|
49
|
+
isValueValid(value) {
|
|
50
|
+
return Object.keys(ExecutionModeVariants).includes(value);
|
|
51
|
+
}
|
|
52
|
+
getRawValue() {
|
|
53
|
+
return process.env[this.getEnvName()];
|
|
54
|
+
}
|
|
55
|
+
initValue() {
|
|
56
|
+
const value = this.getRawValue();
|
|
57
|
+
if (this.isValueValid(value)) {
|
|
58
|
+
this.value = value;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.value = this.defaultValue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=execution-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-mode.js","sourceRoot":"","sources":["../src/execution-mode.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAChC,wCAAe,CAAA;IACf,oCAAW,CAAA;IACX,sCAAa,CAAA;IACb,kCAAS,CAAA;IACT,sCAAa,CAAA;IACb,sCAAa,CAAA;AACd,CAA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AC,KAAY,CAAC,CAAC;IAClE,CAAC;IAES,WAAW;QACpB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACvC,CAAC;IAEO,SAAS;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACnB;aAAM;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;SAC/B;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum ExecutionModeVariants {
|
|
2
|
+
DEBUG = "debug",
|
|
3
|
+
DEV = "dev",
|
|
4
|
+
TEST = "test",
|
|
5
|
+
QA = "qa",
|
|
6
|
+
DEMO = "demo",
|
|
7
|
+
PROD = "prod"
|
|
8
|
+
}
|
|
9
|
+
export declare class ExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> {
|
|
10
|
+
private value;
|
|
11
|
+
private readonly projectName;
|
|
12
|
+
private readonly defaultValue;
|
|
13
|
+
constructor(projectName: string, defaultValue: ValueType);
|
|
14
|
+
isDebug(): boolean;
|
|
15
|
+
isDev(): boolean;
|
|
16
|
+
isTest(): boolean;
|
|
17
|
+
isQa(): boolean;
|
|
18
|
+
isDemo(): boolean;
|
|
19
|
+
isProd(): boolean;
|
|
20
|
+
getValue(): ValueType;
|
|
21
|
+
isValueIn(variants: ValueType[]): boolean;
|
|
22
|
+
is(expected: ValueType): boolean;
|
|
23
|
+
protected getEnvName(): string;
|
|
24
|
+
protected isValueValid(value?: string): value is ValueType;
|
|
25
|
+
private initValue;
|
|
26
|
+
private getRawValue;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=execution.mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.mode.d.ts","sourceRoot":"","sources":["../src/execution.mode.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB;IAChC,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,EAAE,OAAO;IACT,IAAI,SAAS;IACb,IAAI,SAAS;CACb;AAED,qBAAa,aAAa,CAAC,SAAS,SAAS,qBAAqB,GAAG,qBAAqB;IACzF,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;gBAEtB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS;IAMxD,OAAO,IAAI,OAAO;IAIlB,KAAK,IAAI,OAAO;IAIhB,MAAM,IAAI,OAAO;IAIjB,IAAI,IAAI,OAAO;IAIf,MAAM,IAAI,OAAO;IAIjB,MAAM,IAAI,OAAO;IAIjB,QAAQ,IAAI,SAAS;IAIrB,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO;IAIzC,EAAE,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO;IAIvC,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS;IAI1D,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,WAAW;CAGnB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export var ExecutionModeVariants;
|
|
2
|
+
(function (ExecutionModeVariants) {
|
|
3
|
+
ExecutionModeVariants["DEBUG"] = "debug";
|
|
4
|
+
ExecutionModeVariants["DEV"] = "dev";
|
|
5
|
+
ExecutionModeVariants["TEST"] = "test";
|
|
6
|
+
ExecutionModeVariants["QA"] = "qa";
|
|
7
|
+
ExecutionModeVariants["DEMO"] = "demo";
|
|
8
|
+
ExecutionModeVariants["PROD"] = "prod";
|
|
9
|
+
})(ExecutionModeVariants || (ExecutionModeVariants = {}));
|
|
10
|
+
export class ExecutionMode {
|
|
11
|
+
value;
|
|
12
|
+
projectName;
|
|
13
|
+
defaultValue;
|
|
14
|
+
constructor(projectName, defaultValue) {
|
|
15
|
+
this.projectName = projectName.toUpperCase();
|
|
16
|
+
this.defaultValue = defaultValue;
|
|
17
|
+
this.initValue();
|
|
18
|
+
}
|
|
19
|
+
isDebug() {
|
|
20
|
+
return this.value === ExecutionModeVariants.DEBUG;
|
|
21
|
+
}
|
|
22
|
+
isDev() {
|
|
23
|
+
return this.value === ExecutionModeVariants.DEV;
|
|
24
|
+
}
|
|
25
|
+
isTest() {
|
|
26
|
+
return this.value === ExecutionModeVariants.TEST;
|
|
27
|
+
}
|
|
28
|
+
isQa() {
|
|
29
|
+
return this.value === ExecutionModeVariants.QA;
|
|
30
|
+
}
|
|
31
|
+
isDemo() {
|
|
32
|
+
return this.value === ExecutionModeVariants.DEMO;
|
|
33
|
+
}
|
|
34
|
+
isProd() {
|
|
35
|
+
return this.value === ExecutionModeVariants.PROD;
|
|
36
|
+
}
|
|
37
|
+
getValue() {
|
|
38
|
+
return this.value;
|
|
39
|
+
}
|
|
40
|
+
isValueIn(variants) {
|
|
41
|
+
return variants.includes(this.value);
|
|
42
|
+
}
|
|
43
|
+
is(expected) {
|
|
44
|
+
return expected === this.value;
|
|
45
|
+
}
|
|
46
|
+
getEnvName() {
|
|
47
|
+
return `ENV_${this.projectName}`;
|
|
48
|
+
}
|
|
49
|
+
isValueValid(value) {
|
|
50
|
+
return Object.keys(ExecutionModeVariants).includes(value);
|
|
51
|
+
}
|
|
52
|
+
initValue() {
|
|
53
|
+
const value = this.getRawValue();
|
|
54
|
+
if (this.isValueValid(value)) {
|
|
55
|
+
this.value = value;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.value = this.defaultValue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getRawValue() {
|
|
62
|
+
return process.env[this.getEnvName()];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=execution.mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.mode.js","sourceRoot":"","sources":["../src/execution.mode.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAChC,wCAAe,CAAA;IACf,oCAAW,CAAA;IACX,sCAAa,CAAA;IACb,kCAAS,CAAA;IACT,sCAAa,CAAA;IACb,sCAAa,CAAA;AACd,CAAC,EAPW,qBAAqB,KAArB,qBAAqB,QAOhC;AAED,MAAM,OAAO,aAAa;IACjB,KAAK,CAAY;IACR,WAAW,CAAS;IACpB,YAAY,CAAY;IAEzC,YAAmB,WAAmB,EAAE,YAAuB;QAC9D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,KAAK,CAAC;IACnD,CAAC;IAEM,KAAK;QACX,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,GAAG,CAAC;IACjD,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,IAAI,CAAC;IAClD,CAAC;IAEM,IAAI;QACV,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,EAAE,CAAC;IAChD,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,IAAI,CAAC;IAClD,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,IAAI,CAAC;IAClD,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAEM,SAAS,CAAC,QAAqB;QACrC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAEM,EAAE,CAAC,QAAmB;QAC5B,OAAO,QAAQ,KAAK,IAAI,CAAC,KAAK,CAAC;IAChC,CAAC;IAES,UAAU;QACnB,OAAO,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC;IAES,YAAY,CAAC,KAAc;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,KAAY,CAAC,CAAC;IAClE,CAAC;IAEO,SAAS;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACnB;aAAM;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;SAC/B;IACF,CAAC;IAEO,WAAW;QAClB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hg.execution-mode.d.ts","sourceRoot":"","sources":["../src/hg.execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAEb,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,eAAgB,SAAQ,aAAa;;CAIjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hg.execution-mode.js","sourceRoot":"","sources":["../src/hg.execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,qBAAqB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,eAAgB,SAAQ,aAAa;IACjD;QACC,KAAK,CAAC,IAAI,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExecutionMode, ExecutionModeVariants } from './execution-mode';
|
|
2
|
+
export declare class MockExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> extends ExecutionMode<ValueType> {
|
|
3
|
+
constructor(value: ValueType);
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=mock.execution-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.execution-mode.d.ts","sourceRoot":"","sources":["../src/mock.execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAiB,CAAC,SAAS,SAAS,qBAAqB,GAAG,qBAAqB,CAC7F,SAAQ,aAAa,CAAC,SAAS,CAAC;gBACb,KAAK,EAAE,SAAS;CAGnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.execution-mode.js","sourceRoot":"","sources":["../src/mock.execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,GAEb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,iBACZ,SAAQ,aAAwB;IAChC,YAAmB,KAAgB;QAClC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hg-ts/execution-mode",
|
|
3
|
+
"version": "0.0.15",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist-esm/index.js",
|
|
6
|
+
"repository": "git@gitlab.com:hyper-graph/framework.git",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepack": "yarn build && yarn lint",
|
|
9
|
+
"build": "hg build",
|
|
10
|
+
"build:dev": "hg build:dev",
|
|
11
|
+
"lint": "hg lint",
|
|
12
|
+
"lint:fix": "hg lint:fix"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@hg-ts-config/eslint-config": "0.0.15",
|
|
16
|
+
"@hg-ts-config/typescript": "0.0.15",
|
|
17
|
+
"@hg-ts/cli": "0.0.15",
|
|
18
|
+
"@hg-ts/types": "0.0.15",
|
|
19
|
+
"@types/node": "18.0.3",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "5.33.1",
|
|
21
|
+
"@typescript-eslint/parser": "5.33.1",
|
|
22
|
+
"eslint": "8.24.0",
|
|
23
|
+
"eslint-formatter-codeframe": "7.32.1",
|
|
24
|
+
"mocha": "10.0.0",
|
|
25
|
+
"mocha-junit-reporter": "2.0.2",
|
|
26
|
+
"reflect-metadata": "0.1.13",
|
|
27
|
+
"tsc-watch": "5.0.3",
|
|
28
|
+
"tslib": "2.4.0",
|
|
29
|
+
"typescript": "4.7.4"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"reflect-metadata": "*",
|
|
33
|
+
"tslib": "*"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export enum ExecutionModeVariants {
|
|
2
|
+
DEBUG = 'debug',
|
|
3
|
+
DEV = 'dev',
|
|
4
|
+
TEST = 'test',
|
|
5
|
+
QA = 'qa',
|
|
6
|
+
DEMO = 'demo',
|
|
7
|
+
PROD = 'prod',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants> {
|
|
11
|
+
private value: ValueType;
|
|
12
|
+
private readonly projectName: string;
|
|
13
|
+
private readonly defaultValue: ValueType;
|
|
14
|
+
|
|
15
|
+
public constructor(projectName: string, defaultValue: ValueType) {
|
|
16
|
+
this.projectName = projectName.toUpperCase();
|
|
17
|
+
this.defaultValue = defaultValue;
|
|
18
|
+
this.initValue();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public isDebug(): boolean {
|
|
22
|
+
return this.value === ExecutionModeVariants.DEBUG;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public isDev(): boolean {
|
|
26
|
+
return this.value === ExecutionModeVariants.DEV;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public isTest(): boolean {
|
|
30
|
+
return this.value === ExecutionModeVariants.TEST;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public isQa(): boolean {
|
|
34
|
+
return this.value === ExecutionModeVariants.QA;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public isDemo(): boolean {
|
|
38
|
+
return this.value === ExecutionModeVariants.DEMO;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public isProd(): boolean {
|
|
42
|
+
return this.value === ExecutionModeVariants.PROD;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getValue(): ValueType {
|
|
46
|
+
return this.value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public isValueIn(variants: ValueType[]): boolean {
|
|
50
|
+
return variants.includes(this.value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public is(expected: ValueType): boolean {
|
|
54
|
+
return expected === this.value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected getEnvName(): string {
|
|
58
|
+
return `${this.projectName}_ENV`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected isValueValid(value?: string): value is ValueType {
|
|
62
|
+
return Object.keys(ExecutionModeVariants).includes(value as any);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected getRawValue(): string | undefined {
|
|
66
|
+
return process.env[this.getEnvName()];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private initValue(): void {
|
|
70
|
+
const value = this.getRawValue();
|
|
71
|
+
|
|
72
|
+
if (this.isValueValid(value)) {
|
|
73
|
+
this.value = value;
|
|
74
|
+
} else {
|
|
75
|
+
this.value = this.defaultValue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExecutionMode,
|
|
3
|
+
ExecutionModeVariants,
|
|
4
|
+
} from './execution-mode';
|
|
5
|
+
|
|
6
|
+
export class MockExecutionMode<ValueType extends ExecutionModeVariants = ExecutionModeVariants>
|
|
7
|
+
extends ExecutionMode<ValueType> {
|
|
8
|
+
public constructor(value: ValueType) {
|
|
9
|
+
super('NEVER_USED', value);
|
|
10
|
+
}
|
|
11
|
+
}
|