Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install mise
uses: jdx/mise-action@v2
- name: Build CLI
run: |
make build
run: mise run build
- name: Run tests
run: |
make test
run: mise run test
12 changes: 12 additions & 0 deletions .mise/run-in-caller-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail

program="$1"
shift
if [[ "$program" != /* ]]; then
program="$(cd -- "$(dirname -- "$program")" && pwd)/$(basename -- "$program")"
fi
caller="${NV_DEV_CWD:-${MISE_ORIGINAL_CWD:-$PWD}}"
cd "$caller"
unset NV_DEV_CWD
exec "$program" "$@"
9 changes: 9 additions & 0 deletions .mise/tasks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
#MISE description="Run nv from source in the caller's directory"
#MISE raw=true
set -euo pipefail

export NV_DEV_CWD="${NV_DEV_CWD:-${MISE_ORIGINAL_CWD:-$PWD}}"
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$root"
exec go run -exec "$root/.mise/run-in-caller-dir" . "$@"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ There are a couple ways to change your resolver behavior by environment.
2. If more control is needed than above, create a separate resolver entry for the different resolver versions and target the environment-appropriate resolver in the relevant `.env` files.

When/if configuration for resolvers becomes more complex, additional ways to manage environment overrides will likely be introduced.

## Development (mise)

Run `mise run setup` to install Go and watchexec, download modules, and build `dist/nv`. `mise run build` rebuilds the artifact; `mise dev` builds and watches Go sources for changes. `mise run test` builds and runs the test suite. Activate the mise environment with `eval "$(mise env -s bash)"` to put `dist/` on `PATH`, so `nv` invokes the built artifact. `mise run run -- <args...>` runs the CLI from source in your current directory, and `mise run install` installs the artifact under `${NV_INSTALL_DIR:-$HOME/.local/bin}`. `mise run release` builds binaries for all platforms.
2 changes: 1 addition & 1 deletion bin/release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! bash
#!/usr/bin/env bash

OS_TARGETS=( darwin linux )
ARCH_TARGETS=( amd64 arm64 )
Expand Down
17 changes: 0 additions & 17 deletions makefile

This file was deleted.

44 changes: 44 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[tools]
go = "1.27"
watchexec = "latest"

[env]
_.path = ["{{config_root}}/dist"]

[tasks.setup]
description = "Install project tools and download Go modules"
run = ["mise install", "go mod download", "mise run build"]

[tasks.build]
description = "Build the nv CLI"
sources = ["*.go", "cmd/**/*.go", "internal/**/*.go", "go.mod", "go.sum"]
outputs = ["dist/nv"]
run = "mkdir -p dist && go build -o dist/nv main.go"

[tasks.dev]
description = "Build the CLI and watch source files for changes"
run = "mise watch build"

[tasks.test]
description = "Build the CLI and run all tests"
depends = ["build"]
run = "go test ./..."

[tasks.install]
description = "Build and install nv globally"
depends = ["build"]
run = '''
set -eu
install_dir="${NV_INSTALL_DIR:-$HOME/.local/bin}"
mkdir -p "$install_dir"
cp dist/nv "$install_dir/nv"
printf 'Installed nv to %s\n' "$install_dir/nv"
case ":$PATH:" in
*":$install_dir:"*) ;;
*) printf 'Warning: %s is not on PATH\n' "$install_dir" >&2 ;;
esac
'''

[tasks.release]
description = "Build release binaries for all platforms into dist/"
run = "rm -rf dist && bash bin/release.sh"
Loading