Thanks to visit codestin.com
Credit goes to github.com

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
10 changes: 7 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ jobs:
steps:
- uses: actions/checkout@v6
# Unix
- run: bash ./website/static/install/moon.sh
- run: bash ./website/static/install/moon.sh latest
if: ${{ runner.os != 'Windows' }}
- run: bash ./website/static/install/moon.sh 1.20.0
if: ${{ runner.os != 'Windows' }}
- run: bash ./website/static/install/proto.sh
- run: bash ./website/static/install/moon.sh 2.0.0-beta.0
if: ${{ runner.os != 'Windows' }}
- run: bash ./website/static/install/proto.sh latest
if: ${{ runner.os != 'Windows' }}
- run: bash ./website/static/install/proto.sh 0.40.0
if: ${{ runner.os != 'Windows' }}
# Windows
- run: pwsh.exe ./website/static/install/moon.ps1
- run: pwsh.exe ./website/static/install/moon.ps1 latest
if: ${{ runner.os == 'Windows' }}
- run: pwsh.exe ./website/static/install/moon.ps1 1.20.0
if: ${{ runner.os == 'Windows' }}
- run: pwsh.exe ./website/static/install/moon.ps1 2.0.0-beta.0
if: ${{ runner.os == 'Windows' }}
- run: pwsh.exe ./website/static/install/proto.ps1
if: ${{ runner.os == 'Windows' }}
- run: pwsh.exe ./website/static/install/proto.ps1 0.40.0
Expand Down
25 changes: 17 additions & 8 deletions crates/task-builder/src/tasks_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ impl<'proj> TasksBuilder<'proj> {
let mut args = vec![];
let mut env = EnvMap::default();

let mut handle_arg = |arg: &Argument, ignore_env: bool| {
let mut handle_arg = |arg: &Argument, extract_env: bool| {
if let Argument::Value(value) = arg {
if !res.requires_shell
&& matches!(
Expand All @@ -976,10 +976,12 @@ impl<'proj> TasksBuilder<'proj> {
args.push(TaskArg::new_unquoted(value.to_string()));
}
} else if let Argument::EnvVar(key, value, _) = arg {
if !ignore_env
&& !matches!(value, Value::Expansion(_) | Value::Substitution(_))
{
env.insert(key.to_owned(), Some(value.as_str().to_owned()));
if extract_env {
if !matches!(value, Value::Expansion(_) | Value::Substitution(_)) {
env.insert(key.to_owned(), Some(value.as_str().to_owned()));
}
} else {
args.push(TaskArg::new_unquoted(arg.to_string()));
}
} else {
args.push(TaskArg::new_unquoted(arg.to_string()));
Expand Down Expand Up @@ -1018,20 +1020,27 @@ impl<'proj> TasksBuilder<'proj> {
allow_next_sequence = command
.iter()
.all(|arg| matches!(arg, Argument::EnvVar(_, _, _)));
let mut extract_env = true;

for arg in command.iter() {
handle_arg(arg, false);
handle_arg(arg, extract_env);

if extract_env
&& !matches!(arg, Argument::EnvVar(_, _, _))
{
extract_env = false;
}
}
}
// Capture anything after `--`
Sequence::Passthrough(command) => {
handle_arg(
&Argument::Value(Value::Unquoted("--".into())),
true,
false,
);

for arg in command.iter() {
handle_arg(arg, true);
handle_arg(arg, false);
}
}
Sequence::Stop(term) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ tasks:
options:
shell: false

env-inside:
command: 'foo --env FOO=abc arg'
options:
shell: false

env-ignore:
command: 'FOO=$(exp) BAR=${sub} exit 0'
options:
Expand Down
14 changes: 14 additions & 0 deletions crates/task-builder/tests/tasks_builder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,20 @@ mod tasks_builder {
assert_eq!(task.options.shell, Some(false));
}

#[tokio::test(flavor = "multi_thread")]
async fn ignores_env_assignments_when_inside_command() {
let sandbox = create_sandbox("builder");
let container = TasksBuilderContainer::new(sandbox.path());

let tasks = container.build_tasks("syntax").await;
let task = tasks.get("env-inside").unwrap();

assert_eq!(task.command, "foo");
assert_eq!(task.args, ["--env", "FOO=abc", "arg"]);
assert_eq!(task.env, EnvMap::default());
assert_eq!(task.options.shell, Some(false));
}

// We can't place these invalid commands in the fixture,
// because they would trigger a failure upon creating
// the test container and break other tests!
Expand Down
4 changes: 2 additions & 2 deletions website/blog/2026-01-13_moon-v2-beta.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/moonrepo/moon/releases/
powershell -ExecutionPolicy Bypass -c "irm https://github.com/moonrepo/moon/releases/download/v2.0.0-beta.0/moon_cli-installer.ps1 | iex"
```

> The existing shell install script has not been updated for v2 yet.

## What's changed since alpha?

We've been hard at work the past few weeks working on the following:

- The `@moonrepo` npm packages have been updated (and published) to support v2. Additionally, they
are now published using OIDC tokens for improved security, and now support provenance.
- The official shell install scripts have been updated to support v2, but "latest" does not point to
v2 yet. This means that the `moonrepo/setup-toolchain` GitHub Action can now point to v2.
- Updated the task `command` and `args` settings with a
[new parser](https://github.com/moonrepo/starbase/tree/master/crates/args) that better handles
shell syntax, preserves quoting, and much more. We've also made a breaking change where these
Expand Down
13 changes: 13 additions & 0 deletions website/static/install/moon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}


# If >= v2, use the cargo-dist installer instead!
if ($Version -notmatch '^[01]\.' -and $Version -ne "latest") {
$ScriptUrl = if ($Version -eq "latest") {
"https://github.com/moonrepo/moon/releases/latest/download/moon_cli-installer.ps1"
} else {
"https://github.com/moonrepo/moon/releases/download/v${Version}/moon_cli-installer.ps1"
}

powershell.exe -ExecutionPolicy Bypass -c "irm ${ScriptUrl} | iex"
exit $LASTEXITCODE
}

$DownloadUrl = if ($Version -eq "latest") {
"https://github.com/moonrepo/moon/releases/latest/download/${Target}"
} else {
Expand Down
12 changes: 12 additions & 0 deletions website/static/install/moon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ bin="moon"
arch=$(uname -sm)
version="${1:-latest}"

# If >= v2, use the cargo-dist installer instead!
if [[ $version != 0.* && $version != 1.* && $version != "latest" ]]; then
if [[ "$version" == "latest" ]]; then
script_url="https://github.com/moonrepo/moon/releases/latest/download/moon_cli-installer.sh"
else
script_url="https://github.com/moonrepo/moon/releases/download/v${version}/moon_cli-installer.sh"
fi

curl --proto '=https' --tlsv1.2 -LsSf "$script_url" | sh
exit $?
fi

if [[ "$OS" == "Windows_NT" ]]; then
target="moon-x86_64-pc-windows-msvc.exe"
bin="moon.exe"
Expand Down
Loading