Skip to content

Commit 0ab9e87

Browse files
authored
Merge branch 'main' into ale-agent-install-script
2 parents b3aae94 + 5ee9e10 commit 0ab9e87

File tree

13 files changed

+98
-78
lines changed

13 files changed

+98
-78
lines changed

cmd/app/app.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
func NewCommand(clients *shared.ClientFactory) *cobra.Command {
2626
cmd := &cobra.Command{
2727
Use: "app",
28-
Aliases: []string{"workspace", "app", "apps", "team", "teams", "workspaces"},
28+
Aliases: []string{"app", "apps"},
2929
Short: "Install, uninstall, and list teams with the app installed",
3030
Long: "Install, uninstall, and list teams with the app installed",
3131
Example: style.ExampleCommandsf([]style.ExampleCommand{
@@ -45,20 +45,6 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
4545
RunE: func(cmd *cobra.Command, args []string) error {
4646
return runListCommand(cmd, clients)
4747
},
48-
PostRunE: func(cmd *cobra.Command, args []string) error {
49-
ctx := cmd.Context()
50-
// DEPRECATED(semver:major): remove the "workspace" alias
51-
if cmd.CalledAs() == "workspace" {
52-
clients.IO.PrintInfo(ctx, false,
53-
"\n%s It looks like you used %s. This command will be deprecated in an upcoming release.\n You can now use %s instead of %s.\n ",
54-
style.Emoji("bulb"),
55-
style.Commandf("workspace", true),
56-
style.Commandf("app", true),
57-
style.Commandf("workspace", true),
58-
)
59-
}
60-
return nil
61-
},
6248
}
6349

6450
// Add child commands

cmd/app/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/stretchr/testify/assert"
2525
)
2626

27-
func TestWorkspaceCommand(t *testing.T) {
27+
func TestAppCommand(t *testing.T) {
2828
// Create mocks
2929
ctx := slackcontext.MockContext(t.Context())
3030
clientsMock := shared.NewClientsMock()

cmd/env/env.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
3535
cmd := &cobra.Command{
3636
Use: "env <subcommand>",
3737
Aliases: []string{"var", "vars", "variable", "variables"},
38-
Short: "Add, remove, or list environment variables",
38+
Short: "Set, unset, or list environment variables",
3939
Long: strings.Join([]string{
40-
"Add, remove, or list environment variables for the app.",
40+
"Set, unset, or list environment variables for the project.",
4141
"",
4242
"Commands that run in the context of a project source environment variables from",
4343
"the \".env\" file. This includes the \"run\" command.",
@@ -49,16 +49,16 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
4949
}, "\n"),
5050
Example: style.ExampleCommandsf([]style.ExampleCommand{
5151
{
52-
Meaning: "Add an environment variable",
53-
Command: "env add MAGIC_PASSWORD abracadbra",
52+
Meaning: "Set an environment variable",
53+
Command: "env set MAGIC_PASSWORD abracadbra",
5454
},
5555
{
5656
Meaning: "List all environment variables",
5757
Command: "env list",
5858
},
5959
{
60-
Meaning: "Remove an environment variable",
61-
Command: "env remove MAGIC_PASSWORD",
60+
Meaning: "Unset an environment variable",
61+
Command: "env unset MAGIC_PASSWORD",
6262
},
6363
}),
6464
RunE: func(cmd *cobra.Command, args []string) error {
@@ -67,9 +67,9 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
6767
}
6868

6969
// Add child commands
70-
cmd.AddCommand(NewEnvAddCommand(clients))
70+
cmd.AddCommand(NewEnvSetCommand(clients))
7171
cmd.AddCommand(NewEnvListCommand(clients))
72-
cmd.AddCommand(NewEnvRemoveCommand(clients))
72+
cmd.AddCommand(NewEnvUnsetCommand(clients))
7373

7474
return cmd
7575
}

cmd/env/env_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ func Test_Env_Command(t *testing.T) {
3232
testutil.TableTestCommand(t, testutil.CommandTests{
3333
"shows the help page without commands or arguments or flags": {
3434
ExpectedStdoutOutputs: []string{
35-
"Add an environment variable",
35+
"Set an environment variable",
3636
"List all environment variables",
37-
"Remove an environment variable",
37+
"Unset an environment variable",
3838
},
3939
},
4040
}, func(clients *shared.ClientFactory) *cobra.Command {

cmd/env/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import (
3333
func NewEnvListCommand(clients *shared.ClientFactory) *cobra.Command {
3434
cmd := &cobra.Command{
3535
Use: "list [flags]",
36-
Short: "List all environment variables for the app",
36+
Short: "List all environment variables of the project",
3737
Long: strings.Join([]string{
38-
"List environment variables available to the app at runtime.",
38+
"List the environment variables available to the project.",
3939
"",
4040
"Commands that run in the context of a project source environment variables from",
4141
"the \".env\" file. This includes the \"run\" command.",

cmd/env/add.go renamed to cmd/env/set.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ import (
3030
"github.com/spf13/cobra"
3131
)
3232

33-
func NewEnvAddCommand(clients *shared.ClientFactory) *cobra.Command {
33+
func NewEnvSetCommand(clients *shared.ClientFactory) *cobra.Command {
3434
cmd := &cobra.Command{
35-
Use: "add <name> [value] [flags]",
36-
Short: "Add an environment variable to the project",
35+
Use: "set [name] [value] [flags]",
36+
Aliases: []string{"add"},
37+
Short: "Set an environment variable for the project",
3738
Long: strings.Join([]string{
38-
"Add an environment variable to the project.",
39+
"Set an environment variable for the project.",
3940
"",
4041
"If a name or value is not provided, you will be prompted to provide these.",
4142
"",
@@ -48,24 +49,24 @@ func NewEnvAddCommand(clients *shared.ClientFactory) *cobra.Command {
4849
Example: style.ExampleCommandsf([]style.ExampleCommand{
4950
{
5051
Meaning: "Prompt for an environment variable",
51-
Command: "env add",
52+
Command: "env set",
5253
},
5354
{
54-
Meaning: "Add an environment variable",
55-
Command: "env add MAGIC_PASSWORD abracadbra",
55+
Meaning: "Set an environment variable",
56+
Command: "env set MAGIC_PASSWORD abracadbra",
5657
},
5758
{
5859
Meaning: "Prompt for an environment variable value",
59-
Command: "env add SECRET_PASSWORD",
60+
Command: "env set SECRET_PASSWORD",
6061
},
6162
}),
6263
Args: cobra.MaximumNArgs(2),
6364
PreRunE: func(cmd *cobra.Command, args []string) error {
6465
ctx := cmd.Context()
65-
return preRunEnvAddCommandFunc(ctx, clients, cmd)
66+
return preRunEnvSetCommandFunc(ctx, clients, cmd)
6667
},
6768
RunE: func(cmd *cobra.Command, args []string) error {
68-
return runEnvAddCommandFunc(clients, cmd, args)
69+
return runEnvSetCommandFunc(clients, cmd, args)
6970
},
7071
}
7172

@@ -74,15 +75,15 @@ func NewEnvAddCommand(clients *shared.ClientFactory) *cobra.Command {
7475
return cmd
7576
}
7677

77-
// preRunEnvAddCommandFunc determines if the command is run in a valid project
78+
// preRunEnvSetCommandFunc determines if the command is run in a valid project
7879
// and configures flags
79-
func preRunEnvAddCommandFunc(ctx context.Context, clients *shared.ClientFactory, cmd *cobra.Command) error {
80+
func preRunEnvSetCommandFunc(ctx context.Context, clients *shared.ClientFactory, cmd *cobra.Command) error {
8081
clients.Config.SetFlags(cmd)
8182
return cmdutil.IsValidProjectDirectory(clients)
8283
}
8384

84-
// runEnvAddCommandFunc sets an app environment variable to given values
85-
func runEnvAddCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, args []string) error {
85+
// runEnvSetCommandFunc sets an app environment variable to given values
86+
func runEnvSetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, args []string) error {
8687
ctx := cmd.Context()
8788

8889
// Hosted apps require selecting an app before gathering variable inputs.
@@ -137,7 +138,7 @@ func runEnvAddCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
137138
if err != nil {
138139
return err
139140
}
140-
clients.IO.PrintTrace(ctx, slacktrace.EnvAddSuccess)
141+
clients.IO.PrintTrace(ctx, slacktrace.EnvSetSuccess)
141142
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
142143
Emoji: "evergreen_tree",
143144
Text: "App Environment",
@@ -154,7 +155,7 @@ func runEnvAddCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
154155
if err != nil {
155156
return err
156157
}
157-
clients.IO.PrintTrace(ctx, slacktrace.EnvAddSuccess)
158+
clients.IO.PrintTrace(ctx, slacktrace.EnvSetSuccess)
158159
var details []string
159160
if !exists {
160161
details = append(details, "Created a project .env file that shouldn't be added to version control")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func Test_Env_AddCommandPreRun(t *testing.T) {
6565
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(cf *shared.ClientFactory) {
6666
cf.SDKConfig.WorkingDirectory = tc.mockWorkingDirectory
6767
})
68-
cmd := NewEnvAddCommand(clients)
68+
cmd := NewEnvSetCommand(clients)
6969
err := cmd.PreRunE(cmd, nil)
7070
if tc.expectedError != nil {
7171
assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackerror.ToSlackError(err).Code)
@@ -97,7 +97,7 @@ func Test_Env_AddCommand(t *testing.T) {
9797
t,
9898
"PrintTrace",
9999
mock.Anything,
100-
slacktrace.EnvAddSuccess,
100+
slacktrace.EnvSetSuccess,
101101
mock.Anything,
102102
)
103103
},
@@ -258,7 +258,7 @@ func Test_Env_AddCommand(t *testing.T) {
258258
},
259259
},
260260
}, func(cf *shared.ClientFactory) *cobra.Command {
261-
cmd := NewEnvAddCommand(cf)
261+
cmd := NewEnvSetCommand(cf)
262262
cmd.PreRunE = func(cmd *cobra.Command, args []string) error { return nil }
263263
return cmd
264264
})
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ import (
3030
"github.com/spf13/cobra"
3131
)
3232

33-
func NewEnvRemoveCommand(clients *shared.ClientFactory) *cobra.Command {
33+
func NewEnvUnsetCommand(clients *shared.ClientFactory) *cobra.Command {
3434
cmd := &cobra.Command{
35-
Use: "remove <name> [flags]",
36-
Short: "Remove an environment variable from the project",
35+
Use: "unset [name] [flags]",
36+
Aliases: []string{"remove"},
37+
Short: "Unset an environment variable from the project",
3738
Long: strings.Join([]string{
38-
"Remove an environment variable from the project.",
39+
"Unset an environment variable from the project.",
3940
"",
4041
"If no variable name is provided, you will be prompted to select one.",
4142
"",
@@ -47,21 +48,21 @@ func NewEnvRemoveCommand(clients *shared.ClientFactory) *cobra.Command {
4748
}, "\n"),
4849
Example: style.ExampleCommandsf([]style.ExampleCommand{
4950
{
50-
Meaning: "Select an environment variable to remove",
51-
Command: "env remove",
51+
Meaning: "Select an environment variable to unset",
52+
Command: "env unset",
5253
},
5354
{
54-
Meaning: "Remove an environment variable",
55-
Command: "env remove MAGIC_PASSWORD",
55+
Meaning: "Unset an environment variable",
56+
Command: "env unset MAGIC_PASSWORD",
5657
},
5758
}),
5859
Args: cobra.MaximumNArgs(1),
5960
PreRunE: func(cmd *cobra.Command, args []string) error {
6061
ctx := cmd.Context()
61-
return preRunEnvRemoveCommandFunc(ctx, clients, cmd)
62+
return preRunEnvUnsetCommandFunc(ctx, clients, cmd)
6263
},
6364
RunE: func(cmd *cobra.Command, args []string) error {
64-
return runEnvRemoveCommandFunc(clients, cmd, args)
65+
return runEnvUnsetCommandFunc(clients, cmd, args)
6566
},
6667
}
6768

@@ -70,15 +71,15 @@ func NewEnvRemoveCommand(clients *shared.ClientFactory) *cobra.Command {
7071
return cmd
7172
}
7273

73-
// preRunEnvRemoveCommandFunc determines if the command is run in a valid project
74+
// preRunEnvUnsetCommandFunc determines if the command is run in a valid project
7475
// and configures flags
75-
func preRunEnvRemoveCommandFunc(ctx context.Context, clients *shared.ClientFactory, cmd *cobra.Command) error {
76+
func preRunEnvUnsetCommandFunc(ctx context.Context, clients *shared.ClientFactory, cmd *cobra.Command) error {
7677
clients.Config.SetFlags(cmd)
7778
return cmdutil.IsValidProjectDirectory(clients)
7879
}
7980

80-
// runEnvRemoveCommandFunc removes an environment variable from an app
81-
func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, args []string) error {
81+
// runEnvUnsetCommandFunc removes an environment variable from an app
82+
func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, args []string) error {
8283
ctx := cmd.Context()
8384

8485
// Hosted apps require selecting an app before gathering variable inputs.
@@ -106,7 +107,7 @@ func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command,
106107
return err
107108
}
108109
if len(variables) <= 0 {
109-
clients.IO.PrintTrace(ctx, slacktrace.EnvRemoveSuccess)
110+
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
110111
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
111112
Emoji: "evergreen_tree",
112113
Text: "App Environment",
@@ -135,7 +136,7 @@ func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command,
135136
return err
136137
}
137138
if len(dotEnv) <= 0 {
138-
clients.IO.PrintTrace(ctx, slacktrace.EnvRemoveSuccess)
139+
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
139140
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
140141
Emoji: "evergreen_tree",
141142
Text: "App Environment",
@@ -177,7 +178,7 @@ func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command,
177178
if err != nil {
178179
return err
179180
}
180-
clients.IO.PrintTrace(ctx, slacktrace.EnvRemoveSuccess)
181+
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
181182
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
182183
Emoji: "evergreen_tree",
183184
Text: "App Environment",
@@ -190,7 +191,7 @@ func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command,
190191
if err != nil {
191192
return err
192193
}
193-
clients.IO.PrintTrace(ctx, slacktrace.EnvRemoveSuccess)
194+
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
194195
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
195196
Emoji: "evergreen_tree",
196197
Text: "App Environment",
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Test_Env_RemoveCommandPreRun(t *testing.T) {
5454
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(cf *shared.ClientFactory) {
5555
cf.SDKConfig.WorkingDirectory = tc.mockWorkingDirectory
5656
})
57-
cmd := NewEnvRemoveCommand(clients)
57+
cmd := NewEnvUnsetCommand(clients)
5858
err := cmd.PreRunE(cmd, nil)
5959
if tc.expectedError != nil {
6060
assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackerror.ToSlackError(err).Code)
@@ -115,7 +115,7 @@ func Test_Env_RemoveCommand(t *testing.T) {
115115
t,
116116
"PrintTrace",
117117
mock.Anything,
118-
slacktrace.EnvRemoveSuccess,
118+
slacktrace.EnvUnsetSuccess,
119119
mock.Anything,
120120
)
121121
},
@@ -172,7 +172,7 @@ func Test_Env_RemoveCommand(t *testing.T) {
172172
t,
173173
"PrintTrace",
174174
mock.Anything,
175-
slacktrace.EnvRemoveSuccess,
175+
slacktrace.EnvUnsetSuccess,
176176
mock.Anything,
177177
)
178178
content, err := afero.ReadFile(cm.Fs, ".env")
@@ -241,7 +241,7 @@ func Test_Env_RemoveCommand(t *testing.T) {
241241
},
242242
},
243243
}, func(cf *shared.ClientFactory) *cobra.Command {
244-
cmd := NewEnvRemoveCommand(cf)
244+
cmd := NewEnvUnsetCommand(cf)
245245
cmd.PreRunE = func(cmd *cobra.Command, args []string) error { return nil }
246246
return cmd
247247
})

docs/guides/using-environment-variables-with-the-slack-cli.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ While the `.env` file should **never** be committed to source control for securi
2626

2727
### Storing deployed environment variables {#deployed-env-vars}
2828

29-
When your app is [deployed](/tools/deno-slack-sdk/guides/deploying-to-slack), it will no longer use the `.env` file. Instead, you will have to add the environment variables using the [`env add`](/tools/slack-cli/reference/commands/slack_env_add) command. Environment variables added with `env add` will be made available to your deployed app's [custom functions](/tools/deno-slack-sdk/guides/creating-custom-functions) just as they are locally; see examples in the next section.
29+
When your app is [deployed](/tools/deno-slack-sdk/guides/deploying-to-slack), it will no longer use the `.env` file. Instead, you will have to add the environment variables using the [`env set`](/tools/slack-cli/reference/commands/slack_env_set) command. Environment variables added with `env set` will be made available to your deployed app's [custom functions](/tools/deno-slack-sdk/guides/creating-custom-functions) just as they are locally; see examples in the next section.
3030

3131
For the above example, we could run the following command before deploying our app:
3232

3333
```zsh
34-
slack env add MY_ENV_VAR asdf1234
34+
slack env set MY_ENV_VAR asdf1234
3535
```
3636

3737
If your token contains non-alphanumeric characters, wrap it in quotes like this:
3838

3939
```zsh
40-
slack env add SLACK_API_URL "https://dev<yournumber>.slack.com/api/"
40+
slack env set SLACK_API_URL "https://dev<yournumber>.slack.com/api/"
4141
```
4242

4343
Your environment variables are always encrypted before being stored on our servers and will be automatically decrypted when you use them&mdash;including when listing environment variables with `slack env list`.
@@ -145,14 +145,14 @@ SLACK_DEBUG=true
145145
For deployed apps, run the following command before deployment:
146146

147147
```
148-
slack env add SLACK_DEBUG true
148+
slack env set SLACK_DEBUG true
149149
```
150150

151151
## Included local and deployed variables {#included}
152152

153153
Slack provides two environment variables by default, `SLACK_WORKSPACE` and `SLACK_ENV`. The workspace name is specified by `SLACK_WORKSPACE` and `SLACK_ENV` provides a distinction between the `local` and `deployed` app. Use these values if you want to have different values based on the workspace or environment that the app is installed in.
154154

155-
These variables are automatically included when generating the manifest or triggers only. For access from within a custom function, these variables can be set from the `.env` file or with the [`env add`](/tools/slack-cli/reference/commands/slack_env_add) command.
155+
These variables are automatically included when generating the manifest or triggers only. For access from within a custom function, these variables can be set from the `.env` file or with the [`env set`](/tools/slack-cli/reference/commands/slack_env_set) command.
156156

157157
A custom `WorkspaceMapSchema` can be created and used with these variables to decide which values to use for certain instances of an app. This can be used as an alternative to a local `.env` file or in conjunction with it. The following snippet works well for inclusion in your app manifest, or for triggers (for example, to change event trigger channel IDs):
158158

0 commit comments

Comments
 (0)