-
Notifications
You must be signed in to change notification settings - Fork 5
/
flags.ts
53 lines (49 loc) · 1.14 KB
/
flags.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
import { unstable_flag as flag } from "@vercel/flags/next";
function takeLocalEnv(localEnvironemntKey: string) {
if (process.env.NODE_ENV !== "development") {
return false;
}
if (
process.env[localEnvironemntKey] === undefined ||
process.env[localEnvironemntKey] === "false"
) {
return false;
}
return true;
}
export const debugFlag = flag<boolean>({
key: "debug",
async decide() {
return takeLocalEnv("DEBUG_FLAG");
},
description: "Enable debug mode",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});
export const viewFlag = flag<boolean>({
key: "view",
async decide() {
return takeLocalEnv("VIEW_FLAG");
},
description: "Enable view mode",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});
export const githubIntegrationFlag = flag<boolean>({
key: "github-integration",
async decide() {
return takeLocalEnv("GITHUB_INTEGRATION_FLAG");
},
description: "Enable GitHub Integration",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});