-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathexperiment.go
More file actions
79 lines (66 loc) · 2.58 KB
/
experiment.go
File metadata and controls
79 lines (66 loc) · 2.58 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
// Copyright 2022-2025 Salesforce, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package experiment
import (
"regexp"
"slices"
)
type Experiment string
// When developing features that you would like gated behind an experiment
// add yours here in alphabetical order.
//
// To configure an experiment on at the command level, you may use the experiment
// flag --experiment, -e with value(s) in comma-separated format.
//
// e.g. --experiment=first-toggle,second-toggle
const (
// BoltFrameworks experiment adds CLI support for Bolt JavaScript & Bolt Python.
// These frameworks will be introducing remote function support.
BoltFrameworks Experiment = "bolt"
// BoltInstall experiment enables developerInstall to work with Bolt projects that
// manage their app manifest on app settings (remote manifest).
BoltInstall Experiment = "bolt-install"
// Extension experiment unlocks the extension commands.
Extension Experiment = "extension"
// The ReadOnlyAppCollaborators experiment enables creating and modifying collaborator
// permissions via the `collaborator` commands.
ReadOnlyAppCollaborators Experiment = "read-only-collaborators"
// Placeholder experiment is a placeholder for testing and does nothing... or does it?
Placeholder Experiment = "placeholder"
)
// Please also add here 👇
// AllExperiment is a list of all available experiments that can be enabled
var AllExperiments = []Experiment{
BoltFrameworks,
BoltInstall,
Extension,
ReadOnlyAppCollaborators,
Placeholder,
}
// Please also add here 👇
// EnabledExperiments is a list of experiments that are permanently enabled
var EnabledExperiments = []Experiment{
BoltFrameworks,
BoltInstall,
}
// Includes checks that a supplied experiment is included within AllExperiments
func Includes(expToCheck Experiment) bool {
return slices.Contains(AllExperiments, expToCheck)
}
// isValid returns true if experiment follows standard
func isValid(experimentToCheck string) bool {
experimentPattern := regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)
match := experimentPattern.Match([]byte(experimentToCheck))
return match
}