@microbt/environment 1.2.4 → 1.2.5
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/dist/esm/environment/factory.js +4 -0
- package/dist/esm/environment/index.js +2 -0
- package/dist/esm/environment/strategies/fronai.d.ts +7 -0
- package/dist/esm/environment/strategies/fronai.js +42 -0
- package/dist/esm/environment/strategies/superacmeglobal.d.ts +7 -0
- package/dist/esm/environment/strategies/superacmeglobal.js +42 -0
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/environment/factory.ts
|
|
2
2
|
import { CinmooreEnvironmentStrategy } from "./strategies/cinmoore";
|
|
3
|
+
import { FronAIEnvironmentStrategy } from "./strategies/fronai";
|
|
3
4
|
import { LocalEnvironmentStrategy } from "./strategies/local";
|
|
4
5
|
import { Safio365EnvironmentStrategy } from "./strategies/safio365";
|
|
5
6
|
import { SensforgeEnvironmentStrategy } from "./strategies/sensforge";
|
|
6
7
|
import { SuperAcmeEnvironmentStrategy } from "./strategies/superacme";
|
|
8
|
+
import { SuperacmeGlobalEnvironmentStrategy } from "./strategies/superacmeglobal";
|
|
7
9
|
var _EnvironmentStrategyFactory = class {
|
|
8
10
|
static getStrategy(domain) {
|
|
9
11
|
if (this.localStrategy.getEnvironment(domain) === "local") {
|
|
@@ -25,6 +27,8 @@ EnvironmentStrategyFactory.localStrategy = new LocalEnvironmentStrategy();
|
|
|
25
27
|
_EnvironmentStrategyFactory.strategies.set("sensforge.com", new SensforgeEnvironmentStrategy());
|
|
26
28
|
_EnvironmentStrategyFactory.strategies.set("cinmoore.com", new CinmooreEnvironmentStrategy());
|
|
27
29
|
_EnvironmentStrategyFactory.strategies.set("cinmoore.cn", new CinmooreEnvironmentStrategy());
|
|
30
|
+
_EnvironmentStrategyFactory.strategies.set("fronai.cn", new FronAIEnvironmentStrategy());
|
|
31
|
+
_EnvironmentStrategyFactory.strategies.set("superacmeglobal.com", new SuperacmeGlobalEnvironmentStrategy());
|
|
28
32
|
})();
|
|
29
33
|
export {
|
|
30
34
|
EnvironmentStrategyFactory
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/environment/strategies/fronai.ts
|
|
2
|
+
var FronAIEnvironmentStrategy = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.features = {
|
|
5
|
+
supportEnv: true,
|
|
6
|
+
supportRegion: false,
|
|
7
|
+
supportAWS: false
|
|
8
|
+
};
|
|
9
|
+
this.ENV_PATTERNS = {
|
|
10
|
+
// 匹配 -dev、-dev1、-dev-1、-dev. 等
|
|
11
|
+
dev: /-dev(?:\d*)?(?:-|\.|\b|$)/,
|
|
12
|
+
// 匹配 -test、-test1、-test-1、-test. 等
|
|
13
|
+
test: /-test(?:\d*)?(?:-|\.|\b|$)/,
|
|
14
|
+
// 匹配 -pre、-pre1、-pre-1、-pre. 等
|
|
15
|
+
pre: /-pre(?:\d*)?(?:-|\.|\b|$)/,
|
|
16
|
+
// 匹配 -gray、-gray1、-gray-1、-gray. 等
|
|
17
|
+
gray: /-gray(?:\d*)?(?:-|\.|\b|$)/,
|
|
18
|
+
// 本地环境
|
|
19
|
+
local: /^(localhost|127\.0\.0\.1|0\.0\.0\.0)(?::\d+)?$/
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getEnvironment(host) {
|
|
23
|
+
if (this.ENV_PATTERNS.local.test(host)) {
|
|
24
|
+
return "local";
|
|
25
|
+
}
|
|
26
|
+
for (const [env, pattern] of Object.entries(this.ENV_PATTERNS)) {
|
|
27
|
+
if (pattern.test(host)) {
|
|
28
|
+
return env;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return "prod";
|
|
32
|
+
}
|
|
33
|
+
getRegion() {
|
|
34
|
+
return "unknown";
|
|
35
|
+
}
|
|
36
|
+
isAWS() {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
FronAIEnvironmentStrategy
|
|
42
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/environment/strategies/superacmeglobal.ts
|
|
2
|
+
var SuperacmeGlobalEnvironmentStrategy = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.features = {
|
|
5
|
+
supportEnv: true,
|
|
6
|
+
supportRegion: false,
|
|
7
|
+
supportAWS: false
|
|
8
|
+
};
|
|
9
|
+
this.ENV_PATTERNS = {
|
|
10
|
+
// 匹配 -dev、-dev1、-dev-1、-dev. 等
|
|
11
|
+
dev: /-dev(?:\d*)?(?:-|\.|\b|$)/,
|
|
12
|
+
// 匹配 -test、-test1、-test-1、-test. 等
|
|
13
|
+
test: /-test(?:\d*)?(?:-|\.|\b|$)/,
|
|
14
|
+
// 匹配 -pre、-pre1、-pre-1、-pre. 等
|
|
15
|
+
pre: /-pre(?:\d*)?(?:-|\.|\b|$)/,
|
|
16
|
+
// 匹配 -gray、-gray1、-gray-1、-gray. 等
|
|
17
|
+
gray: /-gray(?:\d*)?(?:-|\.|\b|$)/,
|
|
18
|
+
// 本地环境
|
|
19
|
+
local: /^(localhost|127\.0\.0\.1|0\.0\.0\.0)(?::\d+)?$/
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getEnvironment(host) {
|
|
23
|
+
if (this.ENV_PATTERNS.local.test(host)) {
|
|
24
|
+
return "local";
|
|
25
|
+
}
|
|
26
|
+
for (const [env, pattern] of Object.entries(this.ENV_PATTERNS)) {
|
|
27
|
+
if (pattern.test(host)) {
|
|
28
|
+
return env;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return "prod";
|
|
32
|
+
}
|
|
33
|
+
getRegion() {
|
|
34
|
+
return "unknown";
|
|
35
|
+
}
|
|
36
|
+
isAWS() {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
SuperacmeGlobalEnvironmentStrategy
|
|
42
|
+
};
|