This repository was archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathruntime.ts
108 lines (93 loc) · 2.37 KB
/
runtime.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
export enum Runtime {
NODE10 = "nodejs10",
NODE12 = "nodejs12",
NODE14 = "nodejs14",
NODE16 = "nodejs16",
NODE18 = "nodejs18",
NODE20 = "nodejs20",
PYTHON36 = "python3.6",
PYTHON37 = "python3.7",
PYTHON38 = "python3.8",
DOTNET22 = "dotnet2.2",
DOTNET31 = "dotnet3.1",
}
export const supportedRuntimes = [
Runtime.NODE10,
Runtime.NODE12,
Runtime.NODE14,
Runtime.NODE16,
Runtime.NODE18,
Runtime.NODE20,
Runtime.PYTHON36,
Runtime.PYTHON37,
Runtime.PYTHON38,
Runtime.DOTNET22,
Runtime.DOTNET31
]
export const supportedRuntimeSet = new Set(supportedRuntimes);
export enum RuntimeLanguage {
NODE = "nodejs",
PYTHON = "python",
DOTNET = "dotnet",
}
export const supportedLanguages = [
RuntimeLanguage.NODE,
RuntimeLanguage.PYTHON,
RuntimeLanguage.DOTNET,
]
export enum BuildMode {
RELEASE = "release",
DEBUG = "debug",
}
export const compiledRuntimes = new Set([
Runtime.DOTNET22,
Runtime.DOTNET31
]);
export function isCompiledRuntime(runtime: Runtime): boolean {
return compiledRuntimes.has(runtime);
}
export function isNodeRuntime(runtime: Runtime): boolean {
return getRuntimeLanguage(runtime) === RuntimeLanguage.NODE;
}
export function isPythonRuntime(runtime: Runtime): boolean {
return getRuntimeLanguage(runtime) === RuntimeLanguage.PYTHON;
}
export function getRuntimeVersion(runtime: Runtime): string {
for (const language of supportedLanguages) {
if (runtime.includes(language)) {
return runtime.replace(language, "");
}
}
throw new Error(`Runtime ${runtime} not included in supportedRuntimes`);
}
export function getRuntimeLanguage(runtime: Runtime): string {
for (const language of supportedLanguages) {
if (runtime.includes(language)) {
return language;
}
}
throw new Error(`Runtime ${runtime} not included in supportedRuntimes`);
}
export function getFunctionWorkerRuntime(runtime: Runtime): string {
const language = getRuntimeLanguage(runtime);
if (language === RuntimeLanguage.NODE){
return "node";
}
return language;
}
export enum FunctionAppOS {
WINDOWS = "windows",
LINUX = "linux"
}
export const dockerImages = {
nodejs10: "NODE|10",
nodejs12: "NODE|12",
nodejs14: "NODE|14",
nodejs16: "NODE|16",
nodejs18: "NODE|18",
nodejs20: "NODE|20",
"python3.6": "PYTHON|3.6",
"python3.7": "PYTHON|3.7",
"python3.8": "PYTHON|3.8",
"dotnet3.1": "DOTNET|3.1",
}