mirror of
https://github.com/go-task/task.git
synced 2024-12-04 10:24:45 +02:00
v3.40.0
This commit is contained in:
parent
1c68f0fee4
commit
d8e176311d
@ -1,6 +1,6 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Unreleased
|
## v3.40.0 - 2024-11-05
|
||||||
|
|
||||||
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
|
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
|
||||||
for loops (#1822, #1823 by @stawii).
|
for loops (#1822, #1823 by @stawii).
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@go-task/cli",
|
"name": "@go-task/cli",
|
||||||
"version": "3.39.2",
|
"version": "3.40.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@go-task/cli",
|
"name": "@go-task/cli",
|
||||||
"version": "3.39.2",
|
"version": "3.40.0",
|
||||||
"description": "A task runner / simpler Make alternative written in Go",
|
"description": "A task runner / simpler Make alternative written in Go",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "go-npm install",
|
"postinstall": "go-npm install",
|
||||||
|
@ -5,6 +5,34 @@ sidebar_position: 14
|
|||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v3.40.0 - 2024-11-05
|
||||||
|
|
||||||
|
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
|
||||||
|
for loops (#1822, #1823 by @stawii).
|
||||||
|
- Added a new `TASK_OFFLINE` environment variable to configure the `--offline`
|
||||||
|
flag and expose it as a special variable in the templating system (#1470,
|
||||||
|
#1716 by @vmaerten and @pd93).
|
||||||
|
- Fixed a bug where multiple remote includes caused all prompts to display
|
||||||
|
without waiting for user input (#1832, #1833 by @vmaerten and @pd93).
|
||||||
|
- When using the
|
||||||
|
"[Remote Taskfiles](https://taskfile.dev/experiments/remote-taskfiles/)".
|
||||||
|
experiment, you can now include Taskfiles from Git repositories (#1652 by
|
||||||
|
@vmaerten).
|
||||||
|
- Improved the error message when a dotenv file cannot be parsed (#1842 by
|
||||||
|
@pbitty).
|
||||||
|
- Fix issue with directory when using the remote experiment (#1757 by @pbitty).
|
||||||
|
- Fixed an issue where a special variable was used in combination with a dotenv
|
||||||
|
file (#1232, #1810 by @vmaerten).
|
||||||
|
- Refactor the way Task reads Taskfiles to improve readability (#1771 by
|
||||||
|
@pbitty).
|
||||||
|
- Added a new option to ensure variable is within the list of values (#1827 by
|
||||||
|
@vmaerten).
|
||||||
|
- Allow multiple prompts to be specified for a task (#1861, #1866 by @mfbmina).
|
||||||
|
- Added new template function: `numCPU`, which returns the number of logical
|
||||||
|
CPUs usable (#1890, #1887 by @Amoghrd).
|
||||||
|
- Fixed a bug where non-nil, empty dynamic variables are returned as an empty
|
||||||
|
interface (#1903, #1904 by @pd93).
|
||||||
|
|
||||||
## v3.39.2 - 2024-09-19
|
## v3.39.2 - 2024-09-19
|
||||||
|
|
||||||
- Fix dynamic variables not working properly for a defer: statement (#1803,
|
- Fix dynamic variables not working properly for a defer: statement (#1803,
|
||||||
|
@ -5,6 +5,34 @@ sidebar_position: 14
|
|||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v3.40.0 - 2024-11-05
|
||||||
|
|
||||||
|
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
|
||||||
|
for loops (#1822, #1823 by @stawii).
|
||||||
|
- Added a new `TASK_OFFLINE` environment variable to configure the `--offline`
|
||||||
|
flag and expose it as a special variable in the templating system (#1470,
|
||||||
|
#1716 by @vmaerten and @pd93).
|
||||||
|
- Fixed a bug where multiple remote includes caused all prompts to display
|
||||||
|
without waiting for user input (#1832, #1833 by @vmaerten and @pd93).
|
||||||
|
- When using the
|
||||||
|
"[Remote Taskfiles](https://taskfile.dev/experiments/remote-taskfiles/)".
|
||||||
|
experiment, you can now include Taskfiles from Git repositories (#1652 by
|
||||||
|
@vmaerten).
|
||||||
|
- Improved the error message when a dotenv file cannot be parsed (#1842 by
|
||||||
|
@pbitty).
|
||||||
|
- Fix issue with directory when using the remote experiment (#1757 by @pbitty).
|
||||||
|
- Fixed an issue where a special variable was used in combination with a dotenv
|
||||||
|
file (#1232, #1810 by @vmaerten).
|
||||||
|
- Refactor the way Task reads Taskfiles to improve readability (#1771 by
|
||||||
|
@pbitty).
|
||||||
|
- Added a new option to ensure variable is within the list of values (#1827 by
|
||||||
|
@vmaerten).
|
||||||
|
- Allow multiple prompts to be specified for a task (#1861, #1866 by @mfbmina).
|
||||||
|
- Added new template function: `numCPU`, which returns the number of logical
|
||||||
|
CPUs usable (#1890, #1887 by @Amoghrd).
|
||||||
|
- Fixed a bug where non-nil, empty dynamic variables are returned as an empty
|
||||||
|
interface (#1903, #1904 by @pd93).
|
||||||
|
|
||||||
## v3.39.2 - 2024-09-19
|
## v3.39.2 - 2024-09-19
|
||||||
|
|
||||||
- Fix dynamic variables not working properly for a defer: statement (#1803,
|
- Fix dynamic variables not working properly for a defer: statement (#1803,
|
||||||
|
@ -62,6 +62,16 @@ includes:
|
|||||||
`TOKEN=my-token task my-remote-namespace:hello` will be resolved by Task to
|
`TOKEN=my-token task my-remote-namespace:hello` will be resolved by Task to
|
||||||
`https://my-token@raw.githubusercontent.com/my-org/my-repo/main/Taskfile.yml`
|
`https://my-token@raw.githubusercontent.com/my-org/my-repo/main/Taskfile.yml`
|
||||||
|
|
||||||
|
## Git nodes
|
||||||
|
|
||||||
|
You can also include a Taskfile from a Git node. We currently support ssh-style and http / https addresses like `git@example.com/foo/bar.git//Taskfiles.yml?ref=v1` and `https://example.com/foo/bar.git//Taskfiles.yml?ref=v1`.
|
||||||
|
|
||||||
|
You need to follow this pattern : `<baseUrl>.git//<path>?ref=<ref>`.
|
||||||
|
The `ref` parameter, optional, can be a branch name or a tag, if not provided it'll pick up the default branch.
|
||||||
|
The `path` is the path to the Taskfile in the repository.
|
||||||
|
|
||||||
|
If you want to use the SSH protocol, you need to make sure that your ssh-agent has your private ssh keys added so that they can be used during authentication.
|
||||||
|
|
||||||
## Security
|
## Security
|
||||||
|
|
||||||
Running commands from sources that you do not control is always a potential
|
Running commands from sources that you do not control is always a potential
|
||||||
|
@ -63,7 +63,7 @@ four groups with the following ranges:
|
|||||||
A full list of the exit codes and their descriptions can be found below:
|
A full list of the exit codes and their descriptions can be found below:
|
||||||
|
|
||||||
| Code | Description |
|
| Code | Description |
|
||||||
| ---- | ------------------------------------------------------------ |
|
|------|---------------------------------------------------------------------|
|
||||||
| 0 | Success |
|
| 0 | Success |
|
||||||
| 1 | An unknown error occurred |
|
| 1 | An unknown error occurred |
|
||||||
| 100 | No Taskfile was found |
|
| 100 | No Taskfile was found |
|
||||||
@ -81,6 +81,7 @@ A full list of the exit codes and their descriptions can be found below:
|
|||||||
| 204 | A task was called too many times |
|
| 204 | A task was called too many times |
|
||||||
| 205 | A task was cancelled by the user |
|
| 205 | A task was cancelled by the user |
|
||||||
| 206 | A task was not executed due to missing required variables |
|
| 206 | A task was not executed due to missing required variables |
|
||||||
|
| 207 | A task was not executed due to a variable having an incorrect value |
|
||||||
|
|
||||||
These codes can also be found in the repository in
|
These codes can also be found in the repository in
|
||||||
[`errors/errors.go`](https://github.com/go-task/task/blob/main/errors/errors.go).
|
[`errors/errors.go`](https://github.com/go-task/task/blob/main/errors/errors.go).
|
||||||
|
@ -9,15 +9,16 @@ Task allows you to configure some behavior using environment variables. This
|
|||||||
page lists all the environment variables that Task supports.
|
page lists all the environment variables that Task supports.
|
||||||
|
|
||||||
| ENV | Default | Description |
|
| ENV | Default | Description |
|
||||||
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|-------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `TASK_TEMP_DIR` | `.task` | Location of the temp dir. Can relative to the project like `tmp/task` or absolute like `/tmp/.task` or `~/.task`. |
|
| `TASK_TEMP_DIR` | `.task` | Location of the temp dir. Can relative to the project like `tmp/task` or absolute like `/tmp/.task` or `~/.task`. |
|
||||||
| `TASK_REMOTE_DIR` | `TASK_TEMP_DIR` | Location of the remote temp dir (used for caching). Can relative to the project like `tmp/task` or absolute like `/tmp/.task` or `~/.task`. |
|
| `TASK_REMOTE_DIR` | `TASK_TEMP_DIR` | Location of the remote temp dir (used for caching). Can relative to the project like `tmp/task` or absolute like `/tmp/.task` or `~/.task`. |
|
||||||
|
| `TASK_OFFLINE` | `false` | Set the `--offline` flag through the environment variable. Only for remote experiment. CLI flag `--offline` takes precedence over the env variable |
|
||||||
| `FORCE_COLOR` | | Force color output usage. |
|
| `FORCE_COLOR` | | Force color output usage. |
|
||||||
|
|
||||||
## Custom Colors
|
## Custom Colors
|
||||||
|
|
||||||
| ENV | Default | Description |
|
| ENV | Default | Description |
|
||||||
| --------------------------- | ------- | ----------------------- |
|
|-----------------------------|---------|-------------------------|
|
||||||
| `TASK_COLOR_RESET` | `0` | Color used for white. |
|
| `TASK_COLOR_RESET` | `0` | Color used for white. |
|
||||||
| `TASK_COLOR_RED` | `31` | Color used for red. |
|
| `TASK_COLOR_RED` | `31` | Color used for red. |
|
||||||
| `TASK_COLOR_GREEN` | `32` | Color used for green. |
|
| `TASK_COLOR_GREEN` | `32` | Color used for green. |
|
||||||
|
@ -88,7 +88,7 @@ vars:
|
|||||||
| `deps` | [`[]Dependency`](#dependency) | | A list of dependencies of this task. Tasks defined here will run in parallel before this task. |
|
| `deps` | [`[]Dependency`](#dependency) | | A list of dependencies of this task. Tasks defined here will run in parallel before this task. |
|
||||||
| `label` | `string` | | Overrides the name of the task in the output when a task is run. Supports variables. |
|
| `label` | `string` | | Overrides the name of the task in the output when a task is run. Supports variables. |
|
||||||
| `desc` | `string` | | A short description of the task. This is displayed when calling `task --list`. |
|
| `desc` | `string` | | A short description of the task. This is displayed when calling `task --list`. |
|
||||||
| `prompt` | `string` | | A prompt that will be presented before a task is run. Declining will cancel running the current and any subsequent tasks. |
|
| `prompt` | `[]string` | | One or more prompts that will be presented before a task is run. Declining will cancel running the current and any subsequent tasks. |
|
||||||
| `summary` | `string` | | A longer description of the task. This is displayed when calling `task --summary [task]`. |
|
| `summary` | `string` | | A longer description of the task. This is displayed when calling `task --summary [task]`. |
|
||||||
| `aliases` | `[]string` | | A list of alternative names by which the task can be called. |
|
| `aliases` | `[]string` | | A list of alternative names by which the task can be called. |
|
||||||
| `sources` | `[]string` | | A list of sources to check before running this task. Relevant for `checksum` and `timestamp` methods. Can be file paths or star globs. |
|
| `sources` | `[]string` | | A list of sources to check before running this task. Relevant for `checksum` and `timestamp` methods. Can be file paths or star globs. |
|
||||||
|
@ -106,6 +106,7 @@ special variable will be overridden.
|
|||||||
| `CLI_FORCE` | A boolean containing whether the `--force` or `--force-all` flags were set. |
|
| `CLI_FORCE` | A boolean containing whether the `--force` or `--force-all` flags were set. |
|
||||||
| `CLI_SILENT` | A boolean containing whether the `--silent` flag was set. |
|
| `CLI_SILENT` | A boolean containing whether the `--silent` flag was set. |
|
||||||
| `CLI_VERBOSE` | A boolean containing whether the `--verbose` flag was set. |
|
| `CLI_VERBOSE` | A boolean containing whether the `--verbose` flag was set. |
|
||||||
|
| `CLI_OFFLINE` | A boolean containing whether the `--offline` flag was set. |
|
||||||
| `TASK` | The name of the current task. |
|
| `TASK` | The name of the current task. |
|
||||||
| `ALIAS` | The alias used for the current task, otherwise matches `TASK`. |
|
| `ALIAS` | The alias used for the current task, otherwise matches `TASK`. |
|
||||||
| `TASK_EXE` | The Task executable name or path. |
|
| `TASK_EXE` | The Task executable name or path. |
|
||||||
@ -373,7 +374,8 @@ Lastly, Task itself provides a few functions:
|
|||||||
| Function | Description |
|
| Function | Description |
|
||||||
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| `OS` | Returns the operating system. Possible values are `windows`, `linux`, `darwin` (macOS) and `freebsd`. |
|
| `OS` | Returns the operating system. Possible values are `windows`, `linux`, `darwin` (macOS) and `freebsd`. |
|
||||||
| `ARCH` | return the architecture Task was compiled to: `386`, `amd64`, `arm` or `s390x`. |
|
| `ARCH` | Returns the architecture Task was compiled to: `386`, `amd64`, `arm` or `s390x`. |
|
||||||
|
| `numCPU` | Returns the number of logical CPU's usable by the current process. |
|
||||||
| `splitLines` | Splits Unix (`\n`) and Windows (`\r\n`) styled newlines. |
|
| `splitLines` | Splits Unix (`\n`) and Windows (`\r\n`) styled newlines. |
|
||||||
| `catLines` | Replaces Unix (`\n`) and Windows (`\r\n`) styled newlines with a space. |
|
| `catLines` | Replaces Unix (`\n`) and Windows (`\r\n`) styled newlines with a space. |
|
||||||
| `toSlash` | Does nothing on Unix, but on Windows converts a string from `\` path format to `/`. |
|
| `toSlash` | Does nothing on Unix, but on Windows converts a string from `\` path format to `/`. |
|
||||||
|
@ -1060,6 +1060,40 @@ tasks:
|
|||||||
vars: [IMAGE_NAME, IMAGE_TAG]
|
vars: [IMAGE_NAME, IMAGE_TAG]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Ensuring required variables have allowed values
|
||||||
|
|
||||||
|
If you want to ensure that a variable is set to one of a predefined set of valid values before executing a task, you can use requires.
|
||||||
|
This is particularly useful when there are strict requirements for what values a variable can take, and you want to provide clear feedback to the user when an invalid value is detected.
|
||||||
|
|
||||||
|
To use `requires`, you specify an array of allowed values in the vars sub-section under requires. Task will check if the variable is set to one of the allowed values.
|
||||||
|
If the variable does not match any of these values, the task will raise an error and stop execution.
|
||||||
|
|
||||||
|
This check applies both to user-defined variables and environment variables.
|
||||||
|
|
||||||
|
Example of using `requires`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
deploy:
|
||||||
|
cmds:
|
||||||
|
- echo "deploying to {{.ENV}}"
|
||||||
|
|
||||||
|
requires:
|
||||||
|
vars:
|
||||||
|
- name: ENV
|
||||||
|
enum: [dev, beta, prod]
|
||||||
|
```
|
||||||
|
|
||||||
|
If `ENV` is not one of 'dev', 'beta' or 'prod' an error will be raised.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
This is supported only for string variables.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
Task allows you to set variables using the `vars` keyword. The following
|
Task allows you to set variables using the `vars` keyword. The following
|
||||||
@ -1178,6 +1212,28 @@ tasks:
|
|||||||
- echo "{{.GREETING}}"
|
- echo "{{.GREETING}}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example of a `default` value to be overriden from CLI:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
greet_user:
|
||||||
|
desc: "Greet the user with a name."
|
||||||
|
vars:
|
||||||
|
USER_NAME: '{{.USER_NAME| default "DefaultUser"}}'
|
||||||
|
cmds:
|
||||||
|
- echo "Hello, {{.USER_NAME}}!"
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ task greet_user
|
||||||
|
task: [greet_user] echo "Hello, DefaultUser!"
|
||||||
|
Hello, DefaultUser!
|
||||||
|
$ task greet_user USER_NAME="Bob"
|
||||||
|
task: [greet_user] echo "Hello, Bob!"
|
||||||
|
Hello, Bob!
|
||||||
|
```
|
||||||
|
|
||||||
### Dynamic variables
|
### Dynamic variables
|
||||||
|
|
||||||
The below syntax (`sh:` prop in a variable) is considered a dynamic variable.
|
The below syntax (`sh:` prop in a variable) is considered a dynamic variable.
|
||||||
@ -1844,6 +1900,24 @@ tasks:
|
|||||||
task: "This is a dangerous command... Do you want to continue?" [y/N]
|
task: "This is a dangerous command... Do you want to continue?" [y/N]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Prompts can be a single value or a list of prompts, like below:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
example:
|
||||||
|
cmds:
|
||||||
|
- task: dangerous
|
||||||
|
|
||||||
|
dangerous:
|
||||||
|
prompt:
|
||||||
|
- This is a dangerous command... Do you want to continue?
|
||||||
|
- Are you sure?
|
||||||
|
cmds:
|
||||||
|
- echo 'dangerous command'
|
||||||
|
```
|
||||||
|
|
||||||
Warning prompts are called before executing a task. If a prompt is denied Task
|
Warning prompts are called before executing a task. If a prompt is denied Task
|
||||||
will exit with [exit code](/api#exit-codes) 205. If approved, Task will continue
|
will exit with [exit code](/api#exit-codes) 205. If approved, Task will continue
|
||||||
as normal.
|
as normal.
|
||||||
|
Loading…
Reference in New Issue
Block a user