From c7463589172dea9548b647b059454ed23ede1136 Mon Sep 17 00:00:00 2001 From: "m.kindritskiy" Date: Thu, 12 Mar 2026 17:37:16 +0200 Subject: [PATCH 1/2] Update docs for eval_env removal --- AGENTS.md | 2 +- docs/docs/advanced_usage.md | 12 ++++---- docs/docs/changelog.md | 1 + docs/docs/config.md | 51 +------------------------------ examples/python/lets.yaml | 11 ++++--- internal/config/config/command.go | 12 -------- internal/config/config/config.go | 9 ------ internal/config/config/env.go | 2 +- tests/command_eval_env.bats | 15 --------- tests/command_eval_env/lets.yaml | 14 --------- tests/global_eval_env.bats | 7 ++--- 11 files changed, 19 insertions(+), 117 deletions(-) delete mode 100644 tests/command_eval_env.bats delete mode 100644 tests/command_eval_env/lets.yaml diff --git a/AGENTS.md b/AGENTS.md index 794b23f7..5cd5c29c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,7 +49,7 @@ lets publish-docs # deploy docs site ## Key lets.yaml Fields -- Top-level: `shell`, `env`, `eval_env`, `before`, `init`, `mixins`, `commands` +- Top-level: `shell`, `env`, `before`, `init`, `mixins`, `commands` - Command: `cmd`, `description`, `depends`, `env`, `options` (docopt), `work_dir`, `after`, `checksum`, `persist_checksum`, `ref`, `args`, `shell` ## Project Rules diff --git a/docs/docs/advanced_usage.md b/docs/docs/advanced_usage.md index 1457d8f9..f811a209 100644 --- a/docs/docs/advanced_usage.md +++ b/docs/docs/advanced_usage.md @@ -35,19 +35,19 @@ commands: cmd: npm run server ``` -### Eval env +### Dynamic env values -Also if the value of the environment variable must be evaluated, you can add global or per-command `eval_env`: +If the environment variable value must be evaluated, use `env` with `sh`: ```yaml shell: bash env: DEBUG: "0" - -eval_env: - CURRENT_UID: echo "`id -u`:`id -g`" - CURRENT_USER_NAME: echo "`id -un`" + CURRENT_UID: + sh: echo "`id -u`:`id -g`" + CURRENT_USER_NAME: + sh: echo "`id -un`" commands: run: diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md index 7f938fb7..d7509db5 100644 --- a/docs/docs/changelog.md +++ b/docs/docs/changelog.md @@ -7,6 +7,7 @@ title: Changelog * `[Added]` Show similar command suggestions on typos. * `[Changed]` Exit code 2 on unknown command. +* `[Removed]` Drop deprecated `eval_env` directive. Use `env` with `sh` execution mode instead. ## [0.0.59](https://github.com/lets-cli/lets/releases/tag/v0.0.59) diff --git a/docs/docs/config.md b/docs/docs/config.md index 14113435..da236e02 100644 --- a/docs/docs/config.md +++ b/docs/docs/config.md @@ -7,7 +7,6 @@ title: Config reference - [Version](#version) - [Shell](#shell) - [Global env](#global-env) - - [Global eval\_env](#global-eval_env) - [Global before](#global-before) - [Global init](#global-init) - [Conditional init](#conditional-init) @@ -26,7 +25,6 @@ title: Config reference - [Override arguments in depends command](#override-arguments-in-depends-command) - [`options`](#options) - [`env`](#env) - - [`eval_env`](#eval_env) - [`checksum`](#checksum) - [`persist_checksum`](#persist_checksum) - [`ref`](#ref) @@ -91,26 +89,6 @@ env: checksum: [Readme.md, package.json] ``` -### Global eval_env - -**`Deprecated`** - -`key: eval_env` - -`type: mapping string => string` - -> Since `env` now has `sh` execution mode, `eval_env` is deprecated. - -Specify global eval_env for all commands. - -Example: - -```yaml -shell: bash -eval_env: - CURRENT_UID: echo "`id -u`:`id -g`" -``` - ### Global before `key: before` @@ -692,33 +670,6 @@ commands: ``` -### `eval_env` - -**`Deprecated`** - -`key: eval_env` - -`type: mapping string => string` - -> Since `env` now has `sh` execution mode, `eval_env` is deprecated. - -Same as env but allows you to dynamically compute env: - -Example: - -```yaml -commands: - test: - description: Test something - eval_env: - CURRENT_UID: echo "`id -u`:`id -g`" - CURRENT_USER_NAME: echo "`id -un`" - cmd: go build -o lets *.go -``` - -Value will be executed in shell and result will be saved in env. - - ### `checksum` `key: checksum` @@ -931,4 +882,4 @@ env: HELLO: WORLD ``` -This will merge `env` and `.default-env`. Any environment variables declarations after `<<: ` will override variables defined in aliased map. \ No newline at end of file +This will merge `env` and `.default-env`. Any environment variables declarations after `<<: ` will override variables defined in aliased map. diff --git a/examples/python/lets.yaml b/examples/python/lets.yaml index 1c0a6c63..a22587df 100644 --- a/examples/python/lets.yaml +++ b/examples/python/lets.yaml @@ -3,11 +3,12 @@ shell: bash env: DOCKER_BUILDKIT: "1" COMPOSE_DOCKER_CLI_BUILD: "1" - -eval_env: - CURRENT_UID: echo "`id -u`:`id -g`" - CURRENT_USER_NAME: echo "`id -un`" - DOCKER_GATEWAY: echo $(docker network inspect uaprom_default --format="{{(index .IPAM.Config 0).Gateway}}") + CURRENT_UID: + sh: echo "`id -u`:`id -g`" + CURRENT_USER_NAME: + sh: echo "`id -un`" + DOCKER_GATEWAY: + sh: echo $(docker network inspect uaprom_default --format="{{(index .IPAM.Config 0).Gateway}}") commands: build-server: diff --git a/internal/config/config/command.go b/internal/config/config/command.go index 7602945e..26df5dfc 100644 --- a/internal/config/config/command.go +++ b/internal/config/config/command.go @@ -9,7 +9,6 @@ import ( "strings" "github.com/lets-cli/lets/internal/checksum" - log "github.com/sirupsen/logrus" ) type Command struct { @@ -63,7 +62,6 @@ func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error { Description string Shell string Env *Envs - EvalEnv *Envs `yaml:"eval_env"` Options string Depends *Deps WorkDir string `yaml:"work_dir"` @@ -90,16 +88,6 @@ func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error { c.Env = &Envs{} } - // support for deprecated eval_env - if !cmd.EvalEnv.Empty() { - log.Debug("eval_env is deprecated, consider using 'env' with 'sh' executor") - } - _ = cmd.EvalEnv.Range(func(name string, value Env) error { - c.Env.Set(name, Env{Name: name, Sh: value.Value}) - - return nil - }) - c.Shell = cmd.Shell c.Docopts = cmd.Options if c.Docopts == "" { diff --git a/internal/config/config/config.go b/internal/config/config/config.go index 17f15935..8af927b5 100644 --- a/internal/config/config/config.go +++ b/internal/config/config/config.go @@ -18,7 +18,6 @@ var keywords = set.NewSet[string]( "version", "shell", "env", - "eval_env", "init", "before", "mixins", @@ -69,7 +68,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { Before string Init string Env *Envs - EvalEnv *Envs `yaml:"eval_env"` } if err := unmarshal(&config); err != nil { @@ -95,13 +93,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { c.Env = &Envs{} } - // support for deprecated eval_env - _ = config.EvalEnv.Range(func(name string, value Env) error { - c.Env.Set(name, Env{Name: name, Sh: value.Value}) - - return nil - }) - for name, cmd := range c.Commands { cmd.Name = name } diff --git a/internal/config/config/env.go b/internal/config/config/env.go index bf2dbf53..72f6e886 100644 --- a/internal/config/config/env.go +++ b/internal/config/config/env.go @@ -193,7 +193,7 @@ func executeScript(shell string, script string) (string, error) { out, err := cmd.Output() if err != nil { - return "", fmt.Errorf("can not get output from eval_env script: %s: %w", script, err) + return "", fmt.Errorf("can not get output from env.sh script: %s: %w", script, err) } res := string(out) diff --git a/tests/command_eval_env.bats b/tests/command_eval_env.bats deleted file mode 100644 index a44e49b7..00000000 --- a/tests/command_eval_env.bats +++ /dev/null @@ -1,15 +0,0 @@ -load test_helpers - -setup() { - load "${BATS_UTILS_PATH}/bats-support/load.bash" - load "${BATS_UTILS_PATH}/bats-assert/load.bash" - cd ./tests/command_eval_env -} - -@test "command_eval_env: should compute and provide env to command" { - run lets eval-env - assert_success - assert_line --index 0 "ONE=1" - assert_line --index 1 "TWO=two" - assert_line --index 2 "COMPUTED=Computed env" -} diff --git a/tests/command_eval_env/lets.yaml b/tests/command_eval_env/lets.yaml deleted file mode 100644 index a1f1620e..00000000 --- a/tests/command_eval_env/lets.yaml +++ /dev/null @@ -1,14 +0,0 @@ -shell: bash - -commands: - eval-env: - description: Test command env - env: - ONE: "1" - TWO: two - eval_env: - COMPUTED: echo "Computed env" - cmd: | - echo ONE=${ONE} - echo TWO=${TWO} - echo COMPUTED=${COMPUTED} diff --git a/tests/global_eval_env.bats b/tests/global_eval_env.bats index 7361191e..fedfecf9 100644 --- a/tests/global_eval_env.bats +++ b/tests/global_eval_env.bats @@ -6,9 +6,8 @@ setup() { cd ./tests/global_eval_env } -@test "global_eval_env: should compute env from eval_env and provide env to command" { +@test "global_eval_env: should fail because eval_env is not supported" { run lets global-eval_env - assert_success - assert_line --index 0 "ONE=1" - assert_line --index 1 "TWO=2" + assert_failure + assert_output --partial "keyword 'eval_env' not supported" } From 10da0a8216b707aeb02e8cfba08bd83fb9a8dbdf Mon Sep 17 00:00:00 2001 From: "m.kindritskiy" Date: Thu, 12 Mar 2026 17:47:45 +0200 Subject: [PATCH 2/2] Remove deprecated eval env tests --- tests/global_eval_env.bats | 13 ------------- tests/global_eval_env/lets.yaml | 13 ------------- 2 files changed, 26 deletions(-) delete mode 100644 tests/global_eval_env.bats delete mode 100644 tests/global_eval_env/lets.yaml diff --git a/tests/global_eval_env.bats b/tests/global_eval_env.bats deleted file mode 100644 index fedfecf9..00000000 --- a/tests/global_eval_env.bats +++ /dev/null @@ -1,13 +0,0 @@ -load test_helpers - -setup() { - load "${BATS_UTILS_PATH}/bats-support/load.bash" - load "${BATS_UTILS_PATH}/bats-assert/load.bash" - cd ./tests/global_eval_env -} - -@test "global_eval_env: should fail because eval_env is not supported" { - run lets global-eval_env - assert_failure - assert_output --partial "keyword 'eval_env' not supported" -} diff --git a/tests/global_eval_env/lets.yaml b/tests/global_eval_env/lets.yaml deleted file mode 100644 index 3221273b..00000000 --- a/tests/global_eval_env/lets.yaml +++ /dev/null @@ -1,13 +0,0 @@ -shell: bash - -eval_env: - TWO: echo "2" - -commands: - global-eval_env: - description: Test global env - env: - ONE: "1" - cmd: | - echo ONE=${ONE} - echo TWO=${TWO}