-
Notifications
You must be signed in to change notification settings - Fork 299
Expand file tree
/
Copy pathfeatureFlags.ts
More file actions
143 lines (136 loc) · 4.99 KB
/
featureFlags.ts
File metadata and controls
143 lines (136 loc) · 4.99 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Determine whether feature flag is enabled based on environment variable setting
export function isFeatureFlagEnabled(featureFlagName: string, defaultValue = false): boolean {
const flag = process.env[featureFlagName];
if (flag === undefined) {
return defaultValue; // allows consumer to set a default value when environment variable not set
} else {
return flag === "1" || flag.toLowerCase() === "true"; // can enable feature flag by set environment variable value to "1" or "true"
}
}
export class FeatureFlagName {
static readonly CLIDotNet = "TEAMSFX_CLI_DOTNET";
static readonly SampleConfigBranch = "TEAMSFX_SAMPLE_CONFIG_BRANCH";
static readonly ChatParticipantUIEntries = "TEAMSFX_CHAT_PARTICIPANT_ENTRIES";
static readonly HideGitHubCopilotPreviewTag = "TEAMSFX_HIDE_GITHUB_COPILOT_PREVIEW_TAG";
static readonly SMEOAuth = "SME_OAUTH";
static readonly ShowDiagnostics = "TEAMSFX_SHOW_DIAGNOSTICS";
static readonly TelemetryTest = "TEAMSFX_TELEMETRY_TEST";
static readonly DevTunnelTest = "TEAMSFX_DEV_TUNNEL_TEST";
static readonly SyncManifest = "TEAMSFX_SYNC_MANIFEST";
static readonly KiotaNPMIntegration = "TEAMSFX_KIOTA_NPM_INTEGRATION";
static readonly CEAEnabled = "TEAMSFX_CEA_ENABLED";
static readonly SandBoxedTeam = "TEAMSFX_SANDBOXED_TEAM";
static readonly SensitivityLabelEnabled = "TEAMSFX_SENSITIVITY_LABEL";
static readonly DAMetaOS = "TEAMSFX_DA_METAOS";
static readonly CFShortcutMetaOS = "TEAMSFX_CF_SHORTCUT_METAOS";
static readonly MCPForDA = "TEAMSFX_MCP_FOR_DA";
static readonly BrokerAuth = "TEAMSFX_BROKER_AUTH";
static readonly AgentSkillsEnabled = "TEAMSFX_AGENT_SKILLS";
// Add config files to existing project to make it toolkit compatible
static readonly GenerateConfigFiles = "TEAMSFX_GENERATE_CONFIG_FILES";
// Permanent feature flag for sovereign cloud environment setting
static readonly SovereignCloudEnvironment = "TEAMSFX_SOVEREIGN_CLOUD_ENVIRONMENT";
}
export interface FeatureFlag {
name: string;
defaultValue: string;
description?: string;
}
export class FeatureFlags {
// Testing feature flags - not for production use
static readonly CLIDotNet = { name: FeatureFlagName.CLIDotNet, defaultValue: "false" };
static readonly ChatParticipantUIEntries = {
name: FeatureFlagName.ChatParticipantUIEntries,
defaultValue: "false",
};
static readonly HideGitHubCopilotPreviewTag = {
name: FeatureFlagName.HideGitHubCopilotPreviewTag,
defaultValue: "false",
};
static readonly SMEOAuth = { name: FeatureFlagName.SMEOAuth, defaultValue: "false" };
static readonly ShowDiagnostics = {
name: FeatureFlagName.ShowDiagnostics,
defaultValue: "false",
};
static readonly TelemetryTest = {
name: FeatureFlagName.TelemetryTest,
defaultValue: "false",
};
static readonly DevTunnelTest = {
name: FeatureFlagName.DevTunnelTest,
defaultValue: "false",
};
static readonly SyncManifest = {
name: FeatureFlagName.SyncManifest,
defaultValue: "false",
};
static readonly KiotaNPMIntegration = {
name: FeatureFlagName.KiotaNPMIntegration,
defaultValue: "true",
};
static readonly CEAEnabled = {
name: FeatureFlagName.CEAEnabled,
defaultValue: "false",
};
static readonly SandBoxedTeam = {
name: FeatureFlagName.SandBoxedTeam,
defaultValue: "false",
};
static readonly SensitivityLabelEnabled = {
name: FeatureFlagName.SensitivityLabelEnabled,
defaultValue: "false",
};
static readonly DAMetaOS = {
name: FeatureFlagName.DAMetaOS,
defaultValue: "false",
};
static readonly CFShortcutMetaOS = {
name: FeatureFlagName.CFShortcutMetaOS,
defaultValue: "false",
};
static readonly MCPForDA = {
name: FeatureFlagName.MCPForDA,
defaultValue: "true",
};
static readonly BrokerAuth = {
name: FeatureFlagName.BrokerAuth,
defaultValue: "false",
};
static readonly AgentSkillsEnabled = {
name: FeatureFlagName.AgentSkillsEnabled,
defaultValue: "false",
};
static readonly GenerateConfigFiles = {
name: FeatureFlagName.GenerateConfigFiles,
defaultValue: "false",
};
static readonly SovereignCloudEnvironment = {
name: FeatureFlagName.SovereignCloudEnvironment,
defaultValue: "",
};
}
export class FeatureFlagManager {
getBooleanValue(featureFlag: FeatureFlag): boolean {
return isFeatureFlagEnabled(
featureFlag.name,
featureFlag.defaultValue === "true" || featureFlag.defaultValue === "1"
);
}
setBooleanValue(featureFlag: FeatureFlag, value: boolean): void {
process.env[featureFlag.name] = value ? "true" : "false";
}
getStringValue(featureFlag: FeatureFlag): string {
return process.env[featureFlag.name] || featureFlag.defaultValue;
}
list(): FeatureFlag[] {
return Object.values(FeatureFlags);
}
listEnabled(): string[] {
return this.list()
.filter((f) => isFeatureFlagEnabled(f.name))
.map((f) => f.name);
}
}
export const featureFlagManager = new FeatureFlagManager();