Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b922840
feat(prepare): add `mise prepare` command for dependency preparation
jdx Dec 13, 2025
93a4ba3
fix(prepare): run prepare after tool installation and add tests
jdx Dec 14, 2025
b523a5e
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 14, 2025
6bd9a83
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 14, 2025
2a9909e
refactor(prepare): make providers opt-in with per-provider auto setting
jdx Dec 15, 2025
dcf587f
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 15, 2025
7b246d7
feat(prepare): show staleness warning in mise activate shells
jdx Dec 15, 2025
8e41edb
refactor(prepare): split npm provider into npm/yarn/pnpm/bun
jdx Dec 15, 2025
3eb9fb4
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 15, 2025
ce14743
feat(prepare): add cargo, go, pip, poetry, uv, bundler, composer prov…
jdx Dec 15, 2025
1d04a19
perf(prepare): run providers in parallel
jdx Dec 15, 2025
5595530
docs(prepare): add documentation and experimental badge
jdx Dec 15, 2025
affbf15
fix(prepare): fix multiple bugs in prepare system
jdx Dec 15, 2025
6564ba9
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 15, 2025
62f30c3
fix(prepare): use shell_words for proper command parsing
jdx Dec 15, 2025
d31d4b1
fix(prepare): fix toolset env and duplicate dry-run output
jdx Dec 15, 2025
a761d0a
fix(prepare): use &Path instead of &PathBuf in provider constructors
jdx Dec 15, 2025
7c9ceb2
fix(e2e-win): make prepare and task tests self-contained
jdx Dec 15, 2025
f0e689f
fix(prepare): fix remaining clippy warning and Windows e2e tests
jdx Dec 15, 2025
9646869
fix(run): check task --help before toolset/prepare; fix Windows e2e t…
jdx Dec 15, 2025
1af1bdf
fix(e2e): use physical path instead of PSDrive path in Windows tests
jdx Dec 15, 2025
612bb52
Merge remote-tracking branch 'origin/main' into feat/prepare
jdx Dec 15, 2025
cab891a
fix(prepare): remove cargo provider with broken freshness check
jdx Dec 15, 2025
27a874d
docs(prepare): remove cargo provider references
jdx Dec 15, 2025
9e07b69
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 15, 2025
d6771e9
fix(prepare): update CLI doc comment to remove cargo reference
jdx Dec 15, 2025
13d8186
test(prepare): remove cargo provider e2e test
jdx Dec 15, 2025
4dab79f
fix(e2e): use explicit $TestDrive paths in prepare tests
jdx Dec 15, 2025
2a1c8a5
fix(prepare): use go mod vendor when vendor/ exists
jdx Dec 15, 2025
30c20fc
fix(prepare): consistent freshness for globs matching no files
jdx Dec 15, 2025
f6fa6e3
fix(prepare): Windows test PSDrive path and Go provider applicability
jdx Dec 15, 2025
072fef2
fix(prepare): Windows tests and directory freshness check
jdx Dec 15, 2025
d988a0d
fix(prepare): Windows e2e tests use isolated subdirectories
jdx Dec 15, 2025
8ee5668
fix(prepare): don't remove MISE_EXPERIMENTAL in Windows tests
jdx Dec 15, 2025
6337151
fix(test): set MISE_EXPERIMENTAL in vfox test
jdx Dec 15, 2025
e379ef8
fix(prepare): Windows tests set MISE_CONFIG_FILE to prevent parent co…
jdx Dec 15, 2025
b3e0ed3
fix(prepare): skip complex Windows tests, keep basic test
jdx Dec 15, 2025
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
3 changes: 3 additions & 0 deletions docs/.vitepress/cli_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ export const commands: { [key: string]: Command } = {
},
},
},
prepare: {
hide: false,
},
prune: {
hide: false,
},
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default withMermaid(
{ text: "Tool Stubs", link: "/dev-tools/tool-stubs" },
{ text: "Registry", link: "/registry" },
{ text: "mise.lock Lockfile", link: "/dev-tools/mise-lock" },
{ text: "Prepare", link: "/dev-tools/prepare" },
{
text: "Backend Architecture",
link: "/dev-tools/backend_architecture",
Expand Down
4 changes: 4 additions & 0 deletions docs/cli/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Command string to execute
Number of jobs to run in parallel
[default: 4]

### `--no-prepare`

Skip automatic dependency preparation

### `--raw`

Directly pipe stdin/stdout/stderr from plugin to user Sets --jobs=1
Expand Down
1 change: 1 addition & 0 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Can also use `MISE_NO_CONFIG=1`
- [`mise plugins ls-remote [-u --urls] [--only-names]`](/cli/plugins/ls-remote.md)
- [`mise plugins uninstall [-a --all] [-p --purge] [PLUGIN]…`](/cli/plugins/uninstall.md)
- [`mise plugins update [-j --jobs <JOBS>] [PLUGIN]…`](/cli/plugins/update.md)
- [`mise prepare [FLAGS]`](/cli/prepare.md)
- [`mise prune [FLAGS] [INSTALLED_TOOL]…`](/cli/prune.md)
- [`mise registry [FLAGS] [NAME]`](/cli/registry.md)
- [`mise reshim [-f --force]`](/cli/reshim.md)
Expand Down
71 changes: 71 additions & 0 deletions docs/cli/prepare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!-- @generated by usage-cli from usage spec -->
# `mise prepare`

- **Usage**: `mise prepare [FLAGS]`
- **Aliases**: `prep`
- **Source code**: [`src/cli/prepare.rs`](https://github.com/jdx/mise/blob/main/src/cli/prepare.rs)

[experimental] Ensure project dependencies are ready

Runs all applicable prepare steps for the current project.
This checks if dependency lockfiles are newer than installed outputs
(e.g., package-lock.json vs node_modules/) and runs install commands
if needed.

Providers with `auto = true` are automatically invoked before `mise x` and `mise run`
unless skipped with the --no-prepare flag.

## Flags

### `-f --force`

Force run all prepare steps even if outputs are fresh

### `--list`

Show what prepare steps are available

### `-n --dry-run`

Only check if prepare is needed, don't run commands

### `--only… <ONLY>`

Run specific prepare rule(s) only

### `--skip… <SKIP>`

Skip specific prepare rule(s)

Examples:

```
mise prepare # Run all applicable prepare steps
mise prepare --dry-run # Show what would run without executing
mise prepare --force # Force run even if outputs are fresh
mise prepare --list # List available prepare providers
mise prepare --only npm # Run only npm prepare
mise prepare --skip npm # Skip npm prepare
```

Configuration:

```
Configure prepare providers in mise.toml:

```toml
# Built-in npm provider (auto-detects lockfile)
[prepare.npm]
auto = true # Auto-run before mise x/run

# Custom provider
[prepare.codegen]
auto = true
sources = ["schema/*.graphql"]
outputs = ["src/generated/"]
run = "npm run codegen"

[prepare]
disable = ["npm"] # Disable specific providers at runtime
```
```
4 changes: 4 additions & 0 deletions docs/cli/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 python@3.

Do not use cache on remote tasks

### `--no-prepare`

Skip automatic dependency preparation

### `--no-timings`

Hides elapsed time after each task completes
Expand Down
4 changes: 4 additions & 0 deletions docs/cli/tasks/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 python@3.

Do not use cache on remote tasks

### `--no-prepare`

Skip automatic dependency preparation

### `--no-timings`

Hides elapsed time after each task completes
Expand Down
200 changes: 200 additions & 0 deletions docs/dev-tools/prepare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Prepare <Badge type="warning" text="experimental" />

The `mise prepare` command ensures project dependencies are ready by checking if lockfiles
are newer than installed outputs (e.g., `package-lock.json` vs `node_modules/`) and running
install commands if needed.

## Quick Start

```bash
# Enable experimental features
export MISE_EXPERIMENTAL=1

# Run all applicable prepare steps
mise prepare

# Or use the alias
mise prep
```

## Configuration

Configure prepare providers in `mise.toml`:

```toml
# Built-in npm provider (auto-detects lockfile)
[prepare.npm]
auto = true # Auto-run before mise x/run

# Built-in providers for other package managers
[prepare.yarn]
[prepare.pnpm]
[prepare.bun]
[prepare.go]
[prepare.pip]
[prepare.poetry]
[prepare.uv]
[prepare.bundler]
[prepare.composer]

# Custom provider
[prepare.codegen]
auto = true
sources = ["schema/*.graphql"]
outputs = ["src/generated/"]
run = "npm run codegen"

# Disable specific providers
[prepare]
disable = ["npm"]
```

## Built-in Providers

mise includes built-in providers for common package managers:

| Provider | Lockfile | Output | Command |
| ---------- | ------------------------- | --------------------- | ------------------------------------ |
| `npm` | `package-lock.json` | `node_modules/` | `npm install` |
| `yarn` | `yarn.lock` | `node_modules/` | `yarn install` |
| `pnpm` | `pnpm-lock.yaml` | `node_modules/` | `pnpm install` |
| `bun` | `bun.lockb` or `bun.lock` | `node_modules/` | `bun install` |
| `go` | `go.mod` | `vendor/` or `go.sum` | `go mod vendor` or `go mod download` |
| `pip` | `requirements.txt` | `.venv/` | `pip install -r requirements.txt` |
| `poetry` | `poetry.lock` | `.venv/` | `poetry install` |
| `uv` | `uv.lock` | `.venv/` | `uv sync` |
| `bundler` | `Gemfile.lock` | `vendor/bundle/` | `bundle install` |
| `composer` | `composer.lock` | `vendor/` | `composer install` |

Built-in providers are only active when explicitly configured in `mise.toml` and their lockfile exists.

## Custom Providers

Create custom providers for project-specific build steps:

```toml
[prepare.codegen]
sources = ["schema/*.graphql", "codegen.yml"]
outputs = ["src/generated/"]
run = "npm run codegen"
description = "Generate GraphQL types"

[prepare.prisma]
sources = ["prisma/schema.prisma"]
outputs = ["node_modules/.prisma/"]
run = "npx prisma generate"
```

### Provider Options

| Option | Type | Description |
| ------------- | -------- | -------------------------------------------------------- |
| `auto` | bool | Auto-run before `mise x` and `mise run` (default: false) |
| `sources` | string[] | Files/patterns to check for changes |
| `outputs` | string[] | Files/directories that should be newer than sources |
| `run` | string | Command to run when stale |
| `env` | table | Environment variables to set |
| `dir` | string | Working directory for the command |
| `description` | string | Description shown in output |

## Freshness Checking

mise uses modification time (mtime) comparison to determine if outputs are stale:

1. Find the most recent mtime among all source files
2. Find the most recent mtime among all output files
3. If any source is newer than all outputs, the provider is stale

This means:

- If you modify `package-lock.json`, `node_modules/` will be considered stale
- If `node_modules/` doesn't exist, the provider is always stale
- If sources don't exist, the provider is considered fresh (nothing to do)

## Auto-Prepare

When `auto = true` is set on a provider, it will automatically run before:

- `mise run` (task execution)
- `mise x` (exec command)

This ensures dependencies are always up-to-date before running tasks or commands.

To skip auto-prepare for a single invocation:

```bash
mise run --no-prepare build
mise x --no-prepare -- npm test
```

## Staleness Warnings

When using `mise activate`, mise will warn you if any auto-enabled providers have stale dependencies:

```
mise WARN prepare: npm may need update, run `mise prep`
```

This can be disabled with:

```toml
[settings]
status.show_prepare_stale = false
```

## CLI Usage

```bash
# Run all applicable prepare steps
mise prepare

# Show what would run without executing
mise prepare --dry-run

# Force run even if outputs are fresh
mise prepare --force

# List available prepare providers
mise prepare --list

# Run only specific providers
mise prepare --only npm --only codegen

# Skip specific providers
mise prepare --skip npm
```

## Parallel Execution

Prepare providers run in parallel, respecting the `jobs` setting for concurrency limits.
This speeds up preparation when multiple providers need to run (e.g., both npm and pip).

```toml
[settings]
jobs = 4 # Run up to 4 providers in parallel
```

## Example: Full-Stack Project

```toml
# mise.toml for a project with Node.js frontend and Python backend

[prepare.npm]
auto = true

[prepare.poetry]
auto = true

[prepare.prisma]
auto = true
sources = ["prisma/schema.prisma"]
outputs = ["node_modules/.prisma/"]
run = "npx prisma generate"

[prepare.frontend-codegen]
sources = ["schema.graphql", "codegen.ts"]
outputs = ["src/generated/"]
run = "npm run codegen"
```

Running `mise prep` will check all four providers and run any that are stale, in parallel.
Loading
Loading