Skip to content

Commit 382563d

Browse files
authored
Merge pull request #292 from lets-cli/codex/remove-deprecated-evalenv
Remove deprecated eval_env references
2 parents 0c22143 + 10da0a8 commit 382563d

12 files changed

Lines changed: 16 additions & 140 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ lets publish-docs # deploy docs site
4949

5050
## Key lets.yaml Fields
5151

52-
- Top-level: `shell`, `env`, `eval_env`, `before`, `init`, `mixins`, `commands`
52+
- Top-level: `shell`, `env`, `before`, `init`, `mixins`, `commands`
5353
- Command: `cmd`, `description`, `depends`, `env`, `options` (docopt), `work_dir`, `after`, `checksum`, `persist_checksum`, `ref`, `args`, `shell`
5454

5555
## Project Rules

docs/docs/advanced_usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ commands:
3535
cmd: npm run server
3636
```
3737

38-
### Eval env
38+
### Dynamic env values
3939

40-
Also if the value of the environment variable must be evaluated, you can add global or per-command `eval_env`:
40+
If the environment variable value must be evaluated, use `env` with `sh`:
4141

4242
```yaml
4343
shell: bash
4444
4545
env:
4646
DEBUG: "0"
47-
48-
eval_env:
49-
CURRENT_UID: echo "`id -u`:`id -g`"
50-
CURRENT_USER_NAME: echo "`id -un`"
47+
CURRENT_UID:
48+
sh: echo "`id -u`:`id -g`"
49+
CURRENT_USER_NAME:
50+
sh: echo "`id -un`"
5151

5252
commands:
5353
run:

docs/docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ title: Changelog
77

88
* `[Added]` Show similar command suggestions on typos.
99
* `[Changed]` Exit code 2 on unknown command.
10+
* `[Removed]` Drop deprecated `eval_env` directive. Use `env` with `sh` execution mode instead.
1011

1112
## [0.0.59](https://github.com/lets-cli/lets/releases/tag/v0.0.59)
1213

docs/docs/config.md

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ title: Config reference
77
- [Version](#version)
88
- [Shell](#shell)
99
- [Global env](#global-env)
10-
- [Global eval\_env](#global-eval_env)
1110
- [Global before](#global-before)
1211
- [Global init](#global-init)
1312
- [Conditional init](#conditional-init)
@@ -26,7 +25,6 @@ title: Config reference
2625
- [Override arguments in depends command](#override-arguments-in-depends-command)
2726
- [`options`](#options)
2827
- [`env`](#env)
29-
- [`eval_env`](#eval_env)
3028
- [`checksum`](#checksum)
3129
- [`persist_checksum`](#persist_checksum)
3230
- [`ref`](#ref)
@@ -91,26 +89,6 @@ env:
9189
checksum: [Readme.md, package.json]
9290
```
9391
94-
### Global eval_env
95-
96-
**`Deprecated`**
97-
98-
`key: eval_env`
99-
100-
`type: mapping string => string`
101-
102-
> Since `env` now has `sh` execution mode, `eval_env` is deprecated.
103-
104-
Specify global eval_env for all commands.
105-
106-
Example:
107-
108-
```yaml
109-
shell: bash
110-
eval_env:
111-
CURRENT_UID: echo "`id -u`:`id -g`"
112-
```
113-
11492
### Global before
11593
11694
`key: before`
@@ -692,33 +670,6 @@ commands:
692670
```
693671
694672
695-
### `eval_env`
696-
697-
**`Deprecated`**
698-
699-
`key: eval_env`
700-
701-
`type: mapping string => string`
702-
703-
> Since `env` now has `sh` execution mode, `eval_env` is deprecated.
704-
705-
Same as env but allows you to dynamically compute env:
706-
707-
Example:
708-
709-
```yaml
710-
commands:
711-
test:
712-
description: Test something
713-
eval_env:
714-
CURRENT_UID: echo "`id -u`:`id -g`"
715-
CURRENT_USER_NAME: echo "`id -un`"
716-
cmd: go build -o lets *.go
717-
```
718-
719-
Value will be executed in shell and result will be saved in env.
720-
721-
722673
### `checksum`
723674

724675
`key: checksum`
@@ -931,4 +882,4 @@ env:
931882
HELLO: WORLD
932883
```
933884

934-
This will merge `env` and `.default-env`. Any environment variables declarations after `<<: ` will override variables defined in aliased map.
885+
This will merge `env` and `.default-env`. Any environment variables declarations after `<<: ` will override variables defined in aliased map.

examples/python/lets.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ shell: bash
33
env:
44
DOCKER_BUILDKIT: "1"
55
COMPOSE_DOCKER_CLI_BUILD: "1"
6-
7-
eval_env:
8-
CURRENT_UID: echo "`id -u`:`id -g`"
9-
CURRENT_USER_NAME: echo "`id -un`"
10-
DOCKER_GATEWAY: echo $(docker network inspect uaprom_default --format="{{(index .IPAM.Config 0).Gateway}}")
6+
CURRENT_UID:
7+
sh: echo "`id -u`:`id -g`"
8+
CURRENT_USER_NAME:
9+
sh: echo "`id -un`"
10+
DOCKER_GATEWAY:
11+
sh: echo $(docker network inspect uaprom_default --format="{{(index .IPAM.Config 0).Gateway}}")
1112

1213
commands:
1314
build-server:

internal/config/config/command.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010

1111
"github.com/lets-cli/lets/internal/checksum"
12-
log "github.com/sirupsen/logrus"
1312
)
1413

1514
type Command struct {
@@ -63,7 +62,6 @@ func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error {
6362
Description string
6463
Shell string
6564
Env *Envs
66-
EvalEnv *Envs `yaml:"eval_env"`
6765
Options string
6866
Depends *Deps
6967
WorkDir string `yaml:"work_dir"`
@@ -90,16 +88,6 @@ func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error {
9088
c.Env = &Envs{}
9189
}
9290

93-
// support for deprecated eval_env
94-
if !cmd.EvalEnv.Empty() {
95-
log.Debug("eval_env is deprecated, consider using 'env' with 'sh' executor")
96-
}
97-
_ = cmd.EvalEnv.Range(func(name string, value Env) error {
98-
c.Env.Set(name, Env{Name: name, Sh: value.Value})
99-
100-
return nil
101-
})
102-
10391
c.Shell = cmd.Shell
10492
c.Docopts = cmd.Options
10593
if c.Docopts == "" {

internal/config/config/config.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var keywords = set.NewSet[string](
1818
"version",
1919
"shell",
2020
"env",
21-
"eval_env",
2221
"init",
2322
"before",
2423
"mixins",
@@ -69,7 +68,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
6968
Before string
7069
Init string
7170
Env *Envs
72-
EvalEnv *Envs `yaml:"eval_env"`
7371
}
7472

7573
if err := unmarshal(&config); err != nil {
@@ -95,13 +93,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
9593
c.Env = &Envs{}
9694
}
9795

98-
// support for deprecated eval_env
99-
_ = config.EvalEnv.Range(func(name string, value Env) error {
100-
c.Env.Set(name, Env{Name: name, Sh: value.Value})
101-
102-
return nil
103-
})
104-
10596
for name, cmd := range c.Commands {
10697
cmd.Name = name
10798
}

internal/config/config/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func executeScript(shell string, script string) (string, error) {
193193

194194
out, err := cmd.Output()
195195
if err != nil {
196-
return "", fmt.Errorf("can not get output from eval_env script: %s: %w", script, err)
196+
return "", fmt.Errorf("can not get output from env.sh script: %s: %w", script, err)
197197
}
198198

199199
res := string(out)

tests/command_eval_env.bats

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/command_eval_env/lets.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)