Skip to content

Commit d8e1763

Browse files
committed
v3.40.0
1 parent 1c68f0f commit d8e1763

File tree

11 files changed

+174
-30
lines changed

11 files changed

+174
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Unreleased
3+
## v3.40.0 - 2024-11-05
44

55
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
66
for loops (#1822, #1823 by @stawii).

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@go-task/cli",
3-
"version": "3.39.2",
3+
"version": "3.40.0",
44
"description": "A task runner / simpler Make alternative written in Go",
55
"scripts": {
66
"postinstall": "go-npm install",

website/docs/changelog.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ sidebar_position: 14
55

66
# Changelog
77

8+
## v3.40.0 - 2024-11-05
9+
10+
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
11+
for loops (#1822, #1823 by @stawii).
12+
- Added a new `TASK_OFFLINE` environment variable to configure the `--offline`
13+
flag and expose it as a special variable in the templating system (#1470,
14+
#1716 by @vmaerten and @pd93).
15+
- Fixed a bug where multiple remote includes caused all prompts to display
16+
without waiting for user input (#1832, #1833 by @vmaerten and @pd93).
17+
- When using the
18+
"[Remote Taskfiles](https://taskfile.dev/experiments/remote-taskfiles/)".
19+
experiment, you can now include Taskfiles from Git repositories (#1652 by
20+
@vmaerten).
21+
- Improved the error message when a dotenv file cannot be parsed (#1842 by
22+
@pbitty).
23+
- Fix issue with directory when using the remote experiment (#1757 by @pbitty).
24+
- Fixed an issue where a special variable was used in combination with a dotenv
25+
file (#1232, #1810 by @vmaerten).
26+
- Refactor the way Task reads Taskfiles to improve readability (#1771 by
27+
@pbitty).
28+
- Added a new option to ensure variable is within the list of values (#1827 by
29+
@vmaerten).
30+
- Allow multiple prompts to be specified for a task (#1861, #1866 by @mfbmina).
31+
- Added new template function: `numCPU`, which returns the number of logical
32+
CPUs usable (#1890, #1887 by @Amoghrd).
33+
- Fixed a bug where non-nil, empty dynamic variables are returned as an empty
34+
interface (#1903, #1904 by @pd93).
35+
836
## v3.39.2 - 2024-09-19
937

1038
- Fix dynamic variables not working properly for a defer: statement (#1803,

website/versioned_docs/version-latest/changelog.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ sidebar_position: 14
55

66
# Changelog
77

8+
## v3.40.0 - 2024-11-05
9+
10+
- Fixed output of some functions (e.g. `splitArgs`/`splitLines`) not working in
11+
for loops (#1822, #1823 by @stawii).
12+
- Added a new `TASK_OFFLINE` environment variable to configure the `--offline`
13+
flag and expose it as a special variable in the templating system (#1470,
14+
#1716 by @vmaerten and @pd93).
15+
- Fixed a bug where multiple remote includes caused all prompts to display
16+
without waiting for user input (#1832, #1833 by @vmaerten and @pd93).
17+
- When using the
18+
"[Remote Taskfiles](https://taskfile.dev/experiments/remote-taskfiles/)".
19+
experiment, you can now include Taskfiles from Git repositories (#1652 by
20+
@vmaerten).
21+
- Improved the error message when a dotenv file cannot be parsed (#1842 by
22+
@pbitty).
23+
- Fix issue with directory when using the remote experiment (#1757 by @pbitty).
24+
- Fixed an issue where a special variable was used in combination with a dotenv
25+
file (#1232, #1810 by @vmaerten).
26+
- Refactor the way Task reads Taskfiles to improve readability (#1771 by
27+
@pbitty).
28+
- Added a new option to ensure variable is within the list of values (#1827 by
29+
@vmaerten).
30+
- Allow multiple prompts to be specified for a task (#1861, #1866 by @mfbmina).
31+
- Added new template function: `numCPU`, which returns the number of logical
32+
CPUs usable (#1890, #1887 by @Amoghrd).
33+
- Fixed a bug where non-nil, empty dynamic variables are returned as an empty
34+
interface (#1903, #1904 by @pd93).
35+
836
## v3.39.2 - 2024-09-19
937

1038
- Fix dynamic variables not working properly for a defer: statement (#1803,

website/versioned_docs/version-latest/experiments/remote_taskfiles.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ includes:
6262
`TOKEN=my-token task my-remote-namespace:hello` will be resolved by Task to
6363
`https://my-token@raw.githubusercontent.com/my-org/my-repo/main/Taskfile.yml`
6464

65+
## Git nodes
66+
67+
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`.
68+
69+
You need to follow this pattern : `<baseUrl>.git//<path>?ref=<ref>`.
70+
The `ref` parameter, optional, can be a branch name or a tag, if not provided it'll pick up the default branch.
71+
The `path` is the path to the Taskfile in the repository.
72+
73+
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.
74+
6575
## Security
6676

6777
Running commands from sources that you do not control is always a potential

website/versioned_docs/version-latest/reference/cli.mdx

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,26 @@ four groups with the following ranges:
6262

6363
A full list of the exit codes and their descriptions can be found below:
6464

65-
| Code | Description |
66-
| ---- | ------------------------------------------------------------ |
67-
| 0 | Success |
68-
| 1 | An unknown error occurred |
69-
| 100 | No Taskfile was found |
70-
| 101 | A Taskfile already exists when trying to initialize one |
71-
| 102 | The Taskfile is invalid or cannot be parsed |
72-
| 103 | A remote Taskfile could not be downloaded |
73-
| 104 | A remote Taskfile was not trusted by the user |
74-
| 105 | A remote Taskfile was could not be fetched securely |
75-
| 106 | No cache was found for a remote Taskfile in offline mode |
76-
| 107 | No schema version was defined in the Taskfile |
77-
| 200 | The specified task could not be found |
78-
| 201 | An error occurred while executing a command inside of a task |
79-
| 202 | The user tried to invoke a task that is internal |
80-
| 203 | There a multiple tasks with the same name or alias |
81-
| 204 | A task was called too many times |
82-
| 205 | A task was cancelled by the user |
83-
| 206 | A task was not executed due to missing required variables |
65+
| Code | Description |
66+
|------|---------------------------------------------------------------------|
67+
| 0 | Success |
68+
| 1 | An unknown error occurred |
69+
| 100 | No Taskfile was found |
70+
| 101 | A Taskfile already exists when trying to initialize one |
71+
| 102 | The Taskfile is invalid or cannot be parsed |
72+
| 103 | A remote Taskfile could not be downloaded |
73+
| 104 | A remote Taskfile was not trusted by the user |
74+
| 105 | A remote Taskfile was could not be fetched securely |
75+
| 106 | No cache was found for a remote Taskfile in offline mode |
76+
| 107 | No schema version was defined in the Taskfile |
77+
| 200 | The specified task could not be found |
78+
| 201 | An error occurred while executing a command inside of a task |
79+
| 202 | The user tried to invoke a task that is internal |
80+
| 203 | There a multiple tasks with the same name or alias |
81+
| 204 | A task was called too many times |
82+
| 205 | A task was cancelled by the user |
83+
| 206 | A task was not executed due to missing required variables |
84+
| 207 | A task was not executed due to a variable having an incorrect value |
8485

8586
These codes can also be found in the repository in
8687
[`errors/errors.go`](https://github.com/go-task/task/blob/main/errors/errors.go).

website/versioned_docs/version-latest/reference/environment.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ sidebar_position: 4
88
Task allows you to configure some behavior using environment variables. This
99
page lists all the environment variables that Task supports.
1010

11-
| ENV | Default | Description |
12-
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
13-
| `TASK_TEMP_DIR` | `.task` | Location of the temp dir. Can relative to the project like `tmp/task` or absolute like `/tmp/.task` or `~/.task`. |
14-
| `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`. |
15-
| `FORCE_COLOR` | | Force color output usage. |
11+
| ENV | Default | Description |
12+
|-------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
13+
| `TASK_TEMP_DIR` | `.task` | Location of the temp dir. Can relative to the project like `tmp/task` or absolute like `/tmp/.task` or `~/.task`. |
14+
| `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`. |
15+
| `TASK_OFFLINE` | `false` | Set the `--offline` flag through the environment variable. Only for remote experiment. CLI flag `--offline` takes precedence over the env variable |
16+
| `FORCE_COLOR` | | Force color output usage. |
1617

1718
## Custom Colors
1819

1920
| ENV | Default | Description |
20-
| --------------------------- | ------- | ----------------------- |
21+
|-----------------------------|---------|-------------------------|
2122
| `TASK_COLOR_RESET` | `0` | Color used for white. |
2223
| `TASK_COLOR_RED` | `31` | Color used for red. |
2324
| `TASK_COLOR_GREEN` | `32` | Color used for green. |

website/versioned_docs/version-latest/reference/schema.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ vars:
8888
| `deps` | [`[]Dependency`](#dependency) | | A list of dependencies of this task. Tasks defined here will run in parallel before this task. |
8989
| `label` | `string` | | Overrides the name of the task in the output when a task is run. Supports variables. |
9090
| `desc` | `string` | | A short description of the task. This is displayed when calling `task --list`. |
91-
| `prompt` | `string` | | A prompt that will be presented before a task is run. Declining will cancel running the current and any subsequent tasks. |
91+
| `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. |
9292
| `summary` | `string` | | A longer description of the task. This is displayed when calling `task --summary [task]`. |
9393
| `aliases` | `[]string` | | A list of alternative names by which the task can be called. |
9494
| `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. |

website/versioned_docs/version-latest/reference/templating.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ special variable will be overridden.
106106
| `CLI_FORCE` | A boolean containing whether the `--force` or `--force-all` flags were set. |
107107
| `CLI_SILENT` | A boolean containing whether the `--silent` flag was set. |
108108
| `CLI_VERBOSE` | A boolean containing whether the `--verbose` flag was set. |
109+
| `CLI_OFFLINE` | A boolean containing whether the `--offline` flag was set. |
109110
| `TASK` | The name of the current task. |
110111
| `ALIAS` | The alias used for the current task, otherwise matches `TASK`. |
111112
| `TASK_EXE` | The Task executable name or path. |
@@ -373,7 +374,8 @@ Lastly, Task itself provides a few functions:
373374
| Function | Description |
374375
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
375376
| `OS` | Returns the operating system. Possible values are `windows`, `linux`, `darwin` (macOS) and `freebsd`. |
376-
| `ARCH` | return the architecture Task was compiled to: `386`, `amd64`, `arm` or `s390x`. |
377+
| `ARCH` | Returns the architecture Task was compiled to: `386`, `amd64`, `arm` or `s390x`. |
378+
| `numCPU` | Returns the number of logical CPU's usable by the current process. |
377379
| `splitLines` | Splits Unix (`\n`) and Windows (`\r\n`) styled newlines. |
378380
| `catLines` | Replaces Unix (`\n`) and Windows (`\r\n`) styled newlines with a space. |
379381
| `toSlash` | Does nothing on Unix, but on Windows converts a string from `\` path format to `/`. |

website/versioned_docs/version-latest/usage.mdx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,40 @@ tasks:
10601060
vars: [IMAGE_NAME, IMAGE_TAG]
10611061
```
10621062

1063+
### Ensuring required variables have allowed values
1064+
1065+
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.
1066+
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.
1067+
1068+
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.
1069+
If the variable does not match any of these values, the task will raise an error and stop execution.
1070+
1071+
This check applies both to user-defined variables and environment variables.
1072+
1073+
Example of using `requires`:
1074+
1075+
```yaml
1076+
version: '3'
1077+
1078+
tasks:
1079+
deploy:
1080+
cmds:
1081+
- echo "deploying to {{.ENV}}"
1082+
1083+
requires:
1084+
vars:
1085+
- name: ENV
1086+
enum: [dev, beta, prod]
1087+
```
1088+
1089+
If `ENV` is not one of 'dev', 'beta' or 'prod' an error will be raised.
1090+
1091+
:::note
1092+
1093+
This is supported only for string variables.
1094+
1095+
:::
1096+
10631097
## Variables
10641098

10651099
Task allows you to set variables using the `vars` keyword. The following
@@ -1178,6 +1212,28 @@ tasks:
11781212
- echo "{{.GREETING}}"
11791213
```
11801214

1215+
Example of a `default` value to be overriden from CLI:
1216+
1217+
```yaml
1218+
version: '3'
1219+
1220+
greet_user:
1221+
desc: "Greet the user with a name."
1222+
vars:
1223+
USER_NAME: '{{.USER_NAME| default "DefaultUser"}}'
1224+
cmds:
1225+
- echo "Hello, {{.USER_NAME}}!"
1226+
```
1227+
1228+
```shell
1229+
$ task greet_user
1230+
task: [greet_user] echo "Hello, DefaultUser!"
1231+
Hello, DefaultUser!
1232+
$ task greet_user USER_NAME="Bob"
1233+
task: [greet_user] echo "Hello, Bob!"
1234+
Hello, Bob!
1235+
```
1236+
11811237
### Dynamic variables
11821238

11831239
The below syntax (`sh:` prop in a variable) is considered a dynamic variable.
@@ -1844,6 +1900,24 @@ tasks:
18441900
task: "This is a dangerous command... Do you want to continue?" [y/N]
18451901
```
18461902

1903+
Prompts can be a single value or a list of prompts, like below:
1904+
1905+
```yaml
1906+
version: '3'
1907+
1908+
tasks:
1909+
example:
1910+
cmds:
1911+
- task: dangerous
1912+
1913+
dangerous:
1914+
prompt:
1915+
- This is a dangerous command... Do you want to continue?
1916+
- Are you sure?
1917+
cmds:
1918+
- echo 'dangerous command'
1919+
```
1920+
18471921
Warning prompts are called before executing a task. If a prompt is denied Task
18481922
will exit with [exit code](/api#exit-codes) 205. If approved, Task will continue
18491923
as normal.

0 commit comments

Comments
 (0)