Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/advanced_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
51 changes: 1 addition & 50 deletions docs/docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Use singular 'variable' in 'environment variable declarations' for correct grammar.

Change "Any environment variables declarations" to "Any environment variable declarations" to correct the grammar.

This will merge `env` and `.default-env`. Any environment variables declarations after `<<: ` will override variables defined in aliased map.
11 changes: 6 additions & 5 deletions examples/python/lets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 0 additions & 12 deletions internal/config/config/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/lets-cli/lets/internal/checksum"
log "github.com/sirupsen/logrus"
)

type Command struct {
Expand Down Expand Up @@ -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"`
Expand All @@ -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 == "" {
Expand Down
9 changes: 0 additions & 9 deletions internal/config/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var keywords = set.NewSet[string](
"version",
"shell",
"env",
"eval_env",
"init",
"before",
"mixins",
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 0 additions & 15 deletions tests/command_eval_env.bats

This file was deleted.

14 changes: 0 additions & 14 deletions tests/command_eval_env/lets.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/global_eval_env.bats

This file was deleted.

13 changes: 0 additions & 13 deletions tests/global_eval_env/lets.yaml

This file was deleted.

Loading