@visulima/vis 0.0.1 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +360 -0
- package/LICENSE.md +91 -0
- package/README.md +364 -29
- package/dist/bin.js +2 -0
- package/dist/errors/index.d.ts +26 -0
- package/dist/errors/index.js +1 -0
- package/dist/generate/index.d.ts +157 -0
- package/dist/generate/index.js +1 -0
- package/dist/packem_chunks/bin.js +87 -0
- package/dist/packem_chunks/config.js +2 -0
- package/dist/packem_chunks/fix.js +53 -0
- package/dist/packem_chunks/handler.js +1 -0
- package/dist/packem_chunks/handler10.js +1 -0
- package/dist/packem_chunks/handler11.js +1 -0
- package/dist/packem_chunks/handler12.js +2 -0
- package/dist/packem_chunks/handler13.js +1 -0
- package/dist/packem_chunks/handler14.js +5 -0
- package/dist/packem_chunks/handler15.js +1 -0
- package/dist/packem_chunks/handler16.js +20 -0
- package/dist/packem_chunks/handler17.js +1 -0
- package/dist/packem_chunks/handler18.js +1 -0
- package/dist/packem_chunks/handler19.js +1 -0
- package/dist/packem_chunks/handler2.js +1 -0
- package/dist/packem_chunks/handler20.js +1 -0
- package/dist/packem_chunks/handler21.js +1 -0
- package/dist/packem_chunks/handler22.js +5 -0
- package/dist/packem_chunks/handler23.js +1 -0
- package/dist/packem_chunks/handler24.js +1 -0
- package/dist/packem_chunks/handler25.js +5 -0
- package/dist/packem_chunks/handler26.js +1 -0
- package/dist/packem_chunks/handler27.js +3 -0
- package/dist/packem_chunks/handler28.js +1 -0
- package/dist/packem_chunks/handler29.js +7 -0
- package/dist/packem_chunks/handler3.js +2 -0
- package/dist/packem_chunks/handler30.js +23 -0
- package/dist/packem_chunks/handler31.js +3 -0
- package/dist/packem_chunks/handler32.js +2 -0
- package/dist/packem_chunks/handler33.js +24 -0
- package/dist/packem_chunks/handler34.js +2 -0
- package/dist/packem_chunks/handler35.js +19 -0
- package/dist/packem_chunks/handler36.js +428 -0
- package/dist/packem_chunks/handler37.js +22 -0
- package/dist/packem_chunks/handler38.js +22 -0
- package/dist/packem_chunks/handler39.js +22 -0
- package/dist/packem_chunks/handler4.js +4 -0
- package/dist/packem_chunks/handler40.js +3 -0
- package/dist/packem_chunks/handler41.js +10 -0
- package/dist/packem_chunks/handler42.js +153 -0
- package/dist/packem_chunks/handler43.js +42 -0
- package/dist/packem_chunks/handler44.js +3 -0
- package/dist/packem_chunks/handler45.js +27 -0
- package/dist/packem_chunks/handler5.js +2 -0
- package/dist/packem_chunks/handler6.js +13 -0
- package/dist/packem_chunks/handler7.js +8 -0
- package/dist/packem_chunks/handler8.js +1 -0
- package/dist/packem_chunks/handler9.js +1 -0
- package/dist/packem_chunks/index.js +7 -0
- package/dist/packem_chunks/loader.js +1 -0
- package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +1 -0
- package/dist/packem_shared/VisConfigError-B5LP1zRf.js +1 -0
- package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +2 -0
- package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +5 -0
- package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
- package/dist/packem_shared/ai-analysis-CGuy7dfE.js +67 -0
- package/dist/packem_shared/ai-cache-Bynt6Y9x.js +1 -0
- package/dist/packem_shared/cache-directory-D72ZEag2.js +1 -0
- package/dist/packem_shared/catalog-BVPerCwG.js +12 -0
- package/dist/packem_shared/dependency-scan-Du0tBu64.js +2 -0
- package/dist/packem_shared/docker-BcfqH4Av.js +2 -0
- package/dist/packem_shared/failure-log-DqYen0LC.js +2 -0
- package/dist/packem_shared/flakiness-DSIHZGBT.js +1 -0
- package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +1 -0
- package/dist/packem_shared/runtime-check-CGHal8SO.js +1 -0
- package/dist/packem_shared/selectors-CfH9ZY08.js +3 -0
- package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
- package/dist/packem_shared/target-merge-DNa-6eWu.js +1 -0
- package/dist/packem_shared/toolchain-DQfTQY8E.js +5 -0
- package/dist/packem_shared/typosquats-DOR8izpX.js +1 -0
- package/dist/packem_shared/use-measured-height-DjYgUOKk.js +1 -0
- package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
- package/dist/packem_shared/xxh3-DrAUNq4n.js +1 -0
- package/index.js +601 -0
- package/package.json +124 -7
- package/schemas/project.schema.json +422 -0
- package/schemas/vis-config.schema.json +377 -0
package/README.md
CHANGED
|
@@ -1,45 +1,380 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<a href="https://www.anolilab.com/open-source" align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<img src="__assets__/package-og.svg" alt="vis" />
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
</a>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
<h3 align="center">A CLI task runner for monorepo workspaces, powered by @visulima/task-runner</h3>
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@visulima/vis`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
11
|
+
<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
<br />
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
<div align="center">
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
[![typescript-image][typescript-badge]][typescript-url]
|
|
18
|
+
[![mit licence][license-badge]][license]
|
|
19
|
+
[![npm downloads][npm-downloads-badge]][npm-downloads]
|
|
20
|
+
[![Chat][chat-badge]][chat]
|
|
21
|
+
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
</div>
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
25
|
+
---
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
<div align="center">
|
|
28
|
+
<p>
|
|
29
|
+
<sup>
|
|
30
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
31
|
+
</sup>
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
35
|
+
---
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Features
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
39
|
+
- **Workspace-aware**: Automatically discovers projects from `pnpm-workspace.yaml` or `package.json` workspaces
|
|
40
|
+
- **Task caching**: Powered by `@visulima/task-runner` with local and remote caching support
|
|
41
|
+
- **Dependency-aware scheduling**: Runs tasks in topological order with configurable parallelism
|
|
42
|
+
- **Affected detection**: Only runs tasks for projects changed since a given git ref
|
|
43
|
+
- **Pluggable installer**: Defaults to the lockfile-detected PM (pnpm/npm/yarn/bun); auto-uses [aube](https://github.com/endevco/aube) when on `PATH`, with a single switch (`install.backend` / `--installer` / `--no-aube`) to pin or bypass it
|
|
44
|
+
- **Catalog management**: Check and update dependencies in pnpm/bun workspace catalogs
|
|
45
|
+
- **Security scanning**: Check for known vulnerabilities via OSV.dev
|
|
46
|
+
- **Graph visualization**: View your project dependency graph in ASCII, DOT, JSON, or HTML
|
|
47
|
+
- **Git hooks**: Install, manage, and migrate git hooks (husky migration supported)
|
|
48
|
+
- **Configurable**: `vis.json` for target defaults, cache settings, and task runner options
|
|
49
|
+
- **Built on Cerebro**: Uses `@visulima/cerebro` for a robust CLI experience with built-in help, version, and completion
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install @visulima/vis
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
yarn add @visulima/vis
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
pnpm add @visulima/vis
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Cold start (no Node? no manager?)
|
|
66
|
+
|
|
67
|
+
One-liner bootstrap that installs a version manager, Node LTS, and `vis` in one go.
|
|
68
|
+
|
|
69
|
+
**Linux / macOS / WSL** (bash):
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
curl -fsSL https://visulima.com/install.sh | bash
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Windows** (PowerShell 5.1+):
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
irm https://visulima.com/install.ps1 | iex
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Pass `--yes --manager=proto` (POSIX) or `-Yes -Manager proto` (PowerShell) for non-interactive / CI usage. See [`vis toolchain` docs](./docs/commands/toolchain.mdx#cold-start--no-node-no-manager) for details.
|
|
82
|
+
|
|
83
|
+
## Quick Start
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Run a target across all workspace projects
|
|
87
|
+
vis run build
|
|
88
|
+
|
|
89
|
+
# Run tests only on affected projects
|
|
90
|
+
vis affected test --base=main
|
|
91
|
+
|
|
92
|
+
# Visualize the project dependency graph
|
|
93
|
+
vis graph
|
|
94
|
+
|
|
95
|
+
# Check for outdated catalog dependencies
|
|
96
|
+
vis check
|
|
97
|
+
|
|
98
|
+
# Check with security vulnerability scanning
|
|
99
|
+
vis check --security
|
|
100
|
+
|
|
101
|
+
# Update catalog dependencies interactively
|
|
102
|
+
vis update --interactive
|
|
103
|
+
|
|
104
|
+
# Install git hooks
|
|
105
|
+
vis hook install
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Installer backend (aube)
|
|
109
|
+
|
|
110
|
+
`vis install`, `vis add`, `vis remove`, `vis update`, `vis dlx`, `vis exec`, `vis link`, `vis unlink`, `vis dedupe`, `vis why`, `vis outdated`, `vis info`, and `vis pm` honor [aube](https://github.com/endevco/aube) — a Rust-native package manager that reads and writes pnpm/npm/yarn/bun lockfiles in place — as a drop-in installer. Aube also supports the pnpm `catalog:` and `catalog:<name>` protocol from `pnpm-workspace.yaml`, including walk-up resolution from subpackages.
|
|
111
|
+
|
|
112
|
+
`vis` does not bundle aube. Install it once via your tool of choice and `vis` will auto-detect it on `PATH`:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm install -g @endevco/aube # or
|
|
116
|
+
mise use -g aube # or
|
|
117
|
+
brew install endevco/tap/aube
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Resolution precedence (highest first):
|
|
121
|
+
|
|
122
|
+
1. `--installer <name>` CLI flag (or `--no-aube` to force the lockfile-detected PM for one run)
|
|
123
|
+
2. `VIS_INSTALLER` environment variable
|
|
124
|
+
3. `install.backend` in `vis.config.ts`
|
|
125
|
+
4. Auto-detect — uses `aube` when it's on `PATH`, otherwise the lockfile-detected PM
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// vis.config.ts — pin the installer for the team
|
|
129
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
130
|
+
|
|
131
|
+
export default defineConfig({
|
|
132
|
+
install: { backend: "aube" }, // "auto" | "aube" | "pnpm" | "npm" | "yarn" | "bun"
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Lockfile drift
|
|
137
|
+
|
|
138
|
+
Aube reuses pnpm/npm/yarn/bun lockfile formats but its serialized output isn't byte-identical to the original tool's. The first install on a workspace whose lockfile was written by another PM produces a one-time churn diff; teams that mix tools on the same lockfile see ongoing drift. `vis install` warns when this is about to happen — pin `install.backend` to keep the team consistent.
|
|
139
|
+
|
|
140
|
+
### Lifecycle scripts
|
|
141
|
+
|
|
142
|
+
Aube already skips dependency lifecycle scripts by default. `--ignore-scripts` is a no-op under aube (`vis install` warns when you pass it). To opt specific packages back in, run `aube approve-builds` — the inverse direction from the pnpm/npm `--ignore-scripts` model.
|
|
143
|
+
|
|
144
|
+
## Commands
|
|
145
|
+
|
|
146
|
+
| Command | Alias | Description |
|
|
147
|
+
| ----------------------- | ------ | -------------------------------------------------------------------- |
|
|
148
|
+
| `vis create [template]` | | Scaffold a new project from templates, npm packages, or git repos |
|
|
149
|
+
| `vis generate [name]` | | Scaffold files from an in-repo template (native TS or moon-format) |
|
|
150
|
+
| `vis init` | | Initialize vis.config.ts with security defaults |
|
|
151
|
+
| `vis run <target>` | | Run a target across workspace projects with caching |
|
|
152
|
+
| `vis affected <target>` | | Run tasks only on projects affected by git changes |
|
|
153
|
+
| `vis ignore <project>` | | CI build gating for Vercel / Netlify "Ignored Build Step" |
|
|
154
|
+
| `vis graph` | | Visualize the project dependency graph |
|
|
155
|
+
| `vis check [packages]` | `c` | Check for outdated dependencies in workspace catalogs |
|
|
156
|
+
| `vis update [packages]` | `up` | Update packages to their latest versions |
|
|
157
|
+
| `vis install` | `i` | Install dependencies via the detected package manager |
|
|
158
|
+
| `vis info <package>` | `view` | Show npm registry metadata for a package (wraps `npm view` et al.) |
|
|
159
|
+
| `vis dlx <package>` | | Execute a remote package without permanent installation |
|
|
160
|
+
| `vis audit` | | Audit dependencies for security vulnerabilities |
|
|
161
|
+
| `vis clean` | | Remove build artifacts, caches, and node_modules |
|
|
162
|
+
| `vis cache <action>` | | Inspect cache (`list`, `size`, `hash`, `why`), or `prune` / `clean` |
|
|
163
|
+
| `vis hook <action>` | | Manage git hooks (install, uninstall, migrate) |
|
|
164
|
+
| `vis secrets [paths]` | | Scan for hardcoded secrets / credentials (Rust-native) |
|
|
165
|
+
| `vis toolchain <cmd>` | | Inspect / delegate to the version manager (proto, mise, fnm, volta…) |
|
|
166
|
+
| `vis staged` | | Run tasks on staged files (built-in `lint-staged` replacement) |
|
|
167
|
+
| `vis migrate <type>` | | Migrate from other tools — now including `gitleaks` and `secretlint` |
|
|
168
|
+
|
|
169
|
+
For `vis ignore`, see the [command reference](./docs/commands/ignore.mdx) and the [deployment build gating section](./docs/guides/ci-cd.mdx#deployment-build-gating) of the CI/CD guide.
|
|
170
|
+
|
|
171
|
+
### Diagnosing cache misses
|
|
172
|
+
|
|
173
|
+
When a task you expected to be cached re-ran, ask vis what changed:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
vis cache why @myorg/app:build # human-friendly diff vs. previous run
|
|
177
|
+
vis cache why @myorg/app:build --json # stable shape for CI
|
|
178
|
+
vis cache hash @myorg/app:build # just print the hash + per-bucket inputs
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`vis cache why` reads `.task-runner/last-summary.json` and diffs the task's `hashDetails` (`command`, `nodes`, `runtime`, `implicitDeps`) against the previous run, so you can pinpoint exactly which bucket rotated. Past runs only land in `.task-runner/runs/` when you pass `--summarize`, so use `vis run :build --summarize` (or set it as a default in CI) for diffs you'll want to inspect later.
|
|
182
|
+
|
|
183
|
+
### Cache retention
|
|
184
|
+
|
|
185
|
+
`vis cache prune` evicts entries by any combination of age, total size, and count:
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
vis cache prune --max-age-days=7 # drop entries older than a week
|
|
189
|
+
vis cache prune --max-size=2GB # evict oldest until under 2 GB
|
|
190
|
+
vis cache prune --keep-last=30 # keep only the 30 newest entries
|
|
191
|
+
vis cache prune --keep-last=30 --max-age-days=14 # combine: 30-newest floor, then age cap
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`--keep-last` enforces a count floor first (newest-first by mtime), then `--max-age-days` and `--max-size` apply.
|
|
195
|
+
|
|
196
|
+
### Sharing the cache across git worktrees
|
|
197
|
+
|
|
198
|
+
When the workspace is a linked worktree (created with `git worktree add`), vis stores the cache at `<mainWorktreeRoot>/.task-runner-cache` so sibling worktrees driven by parallel agents share one cache instead of rebuilding the same hash N times. Set `sharedWorktreeCache: false` in `vis.config.ts` to opt out, or use `--scope=worktree|shared|all` on `vis cache list/size/prune` to inspect or operate on a specific store.
|
|
199
|
+
|
|
200
|
+
### Quieting successful runs
|
|
201
|
+
|
|
202
|
+
`--output-style=quiet` skips stdout/stderr from successful and cached tasks while keeping failures fully visible. Pair it with per-target `options.outputStyle` to mute a single noisy task — or to keep one critical task verbose under a global quiet flag:
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
vis run :build --output-style=quiet # only failures print
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"targets": {
|
|
211
|
+
"lint": { "options": { "outputStyle": "quiet" } },
|
|
212
|
+
"migrate": { "options": { "outputStyle": "normal" } }
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
See the [`vis cache`](./docs/commands/cache.mdx) and [`vis run`](./docs/commands/run.mdx) command references for the full surface.
|
|
218
|
+
|
|
219
|
+
### Scanning for secrets
|
|
220
|
+
|
|
221
|
+
`vis secrets` wraps [`@visulima/secret-scanner`](../secret-scanner) — a Rust port of the gitleaks detection engine — with ergonomic flags for the common workflows.
|
|
222
|
+
|
|
223
|
+
```sh
|
|
224
|
+
vis secrets # scan the workspace (grouped, colourised output)
|
|
225
|
+
vis secrets --staged # pre-commit mode: scan staged files only
|
|
226
|
+
vis secrets --since main # scan files changed since the `main` branch
|
|
227
|
+
vis secrets --affected # scan only files affected by the current branch
|
|
228
|
+
vis secrets --init # scaffold an initial .secrets-baseline.json
|
|
229
|
+
vis secrets --list-rules # print all bundled detection rules
|
|
230
|
+
vis secrets --enable-rule tag:preset:weak-passwords # enable an opt-in rule group additively
|
|
231
|
+
vis secrets --exclude 'dist/**' --exclude-from .secretsignore # extra walker exclusions
|
|
232
|
+
vis secrets --include-rule stripe-access-token # check a single rule
|
|
233
|
+
vis secrets --exclude-rule generic-api-key # drop a noisy rule
|
|
234
|
+
vis secrets --baseline .secrets-baseline.json # suppress triaged findings; print diff
|
|
235
|
+
vis secrets --update-baseline # merge current findings into the baseline
|
|
236
|
+
vis secrets --format sarif > report.sarif # SARIF for GitHub code-scanning
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Suppression** — inline (`// gitleaks:allow`), block (`gitleaks:allow-start` … `gitleaks:allow-end`), or a baseline JSON (sole fingerprint store). See the [secret-scanner README](../secret-scanner/README.md#suppression) for details.
|
|
240
|
+
|
|
241
|
+
**CI example** (GitHub Actions, SARIF upload):
|
|
242
|
+
|
|
243
|
+
```yaml
|
|
244
|
+
name: Secrets
|
|
245
|
+
on: [push, pull_request]
|
|
246
|
+
jobs:
|
|
247
|
+
scan:
|
|
248
|
+
runs-on: ubuntu-latest
|
|
249
|
+
permissions: { security-events: write, contents: read }
|
|
250
|
+
steps:
|
|
251
|
+
- uses: actions/checkout@v4
|
|
252
|
+
- uses: pnpm/action-setup@v4
|
|
253
|
+
- run: pnpm install
|
|
254
|
+
- run: pnpm vis secrets --format sarif > report.sarif
|
|
255
|
+
continue-on-error: true
|
|
256
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
257
|
+
with: { sarif_file: report.sarif }
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Migrations
|
|
261
|
+
|
|
262
|
+
`vis migrate` now speaks two security tools:
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
vis migrate gitleaks # keeps gitleaks.toml, rewrites scripts/hooks to `vis secrets`
|
|
266
|
+
vis migrate secretlint # removes @secretlint/*, rewrites scripts/hooks, notes active rules
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Every destructive step writes a `.bak` sidecar first and prompts for confirmation (skip with `-y`). Dry-run previews are available via `--dry-run`.
|
|
270
|
+
|
|
271
|
+
### Running tasks on staged files
|
|
272
|
+
|
|
273
|
+
`vis staged` is a built-in replacement for `lint-staged` — the same config shape, no peer dependency, and an integrated task renderer. Requires Git ≥ 2.32.
|
|
274
|
+
|
|
275
|
+
Declare the patterns and tasks under `staged` in `vis.config.ts`:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
// vis.config.ts
|
|
279
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
280
|
+
|
|
281
|
+
export default defineConfig({
|
|
282
|
+
staged: {
|
|
283
|
+
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
|
|
284
|
+
"*.md": "prettier --write",
|
|
285
|
+
"package.json": (files) => `sort-package-json ${files.join(" ")}`,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Each key is a glob (basename or path-style — path-style matches resolve relative to `cwd`). Each value is one of:
|
|
291
|
+
|
|
292
|
+
- a command string — split into argv, invoked with matched files appended;
|
|
293
|
+
- a `string[]` array — commands run serially for that pattern;
|
|
294
|
+
- a function `(files) => string | string[] | {title, task}` — generate dynamic commands or a custom task;
|
|
295
|
+
- a `{ title, task }` object — runs `task(files)` with no argv construction, useful for in-process side effects.
|
|
296
|
+
|
|
297
|
+
`vis.config.ts` is the single source of truth — no standalone `.lintstagedrc*` or `.vis-staged.*` files are read at runtime. Migrating from lint-staged or nano-staged? Run `vis migrate lint-staged` (or `vis migrate nano-staged`) to move the config in and remove the legacy files.
|
|
298
|
+
|
|
299
|
+
#### Command-line flags
|
|
300
|
+
|
|
301
|
+
```sh
|
|
302
|
+
vis staged # run tasks on the current staged set
|
|
303
|
+
vis staged --verbose # show stdout/stderr on success as well as failure
|
|
304
|
+
vis staged --no-stash # skip the backup stash (faster, but no recovery on failure)
|
|
305
|
+
vis staged --diff HEAD~1 # operate on a range instead of `--staged`
|
|
306
|
+
vis staged --diff-filter=ACM # override the default ACMR filter
|
|
307
|
+
vis staged --concurrent 4 # cap parallel pattern execution
|
|
308
|
+
vis staged --continue-on-error # don't short-circuit on the first failure
|
|
309
|
+
vis staged --fail-on-changes # non-zero exit if tasks modified staged content
|
|
310
|
+
vis staged --hide-unstaged # hide all unstaged edits on tracked files
|
|
311
|
+
vis staged --hide-all # hide unstaged edits AND untracked files
|
|
312
|
+
vis staged --relative # pass paths relative to cwd to tasks
|
|
313
|
+
vis staged --revert # restore pre-task state on failure
|
|
314
|
+
vis staged --allow-empty # allow a commit when tasks revert everything
|
|
315
|
+
vis staged --auto-stage # auto-stage new files tasks create (codegen, lockfile regen, …)
|
|
316
|
+
vis staged --force-kill # kill in-flight tasks with SIGKILL on fast-fail (default: SIGTERM)
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### Environment variables
|
|
320
|
+
|
|
321
|
+
| Variable | Description |
|
|
322
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
323
|
+
| `VIS_STAGED_CONCURRENT` | Concurrency fallback when `--concurrent` is not passed. Same value shape as the flag (`true`, `false`, or an integer). Useful in CI so you don't repeat the flag on every invocation. |
|
|
324
|
+
|
|
325
|
+
#### How it behaves
|
|
326
|
+
|
|
327
|
+
1. A hidden backup stash is created (via `git stash create` + `git stash store`, so the working tree is untouched).
|
|
328
|
+
2. For partially-staged files, the unstaged delta is captured as a patch and the working tree is reset to the staged content. `--hide-all` extends this to every unstaged change _and_ untracked files via a single `git stash push --include-untracked`.
|
|
329
|
+
3. Tasks run — patterns in parallel (capped at `os.availableParallelism()` by default), commands within a pattern serially.
|
|
330
|
+
4. Task-driven edits are re-staged with `git update-index --again` (with a `git add -u` fallback for deletions), so commits made via pathspec (`git commit -m "…" .`) keep working.
|
|
331
|
+
5. The unstaged patch — or the hide-all stash — is re-applied and the backup stash is dropped on success. On failure without `--revert`, the backup stash is preserved and the recovery sha is surfaced to the user. Ctrl+C aborts in-flight commands and still runs the restore path; a second Ctrl+C exits immediately.
|
|
332
|
+
|
|
333
|
+
#### Migrating from lint-staged
|
|
334
|
+
|
|
335
|
+
```sh
|
|
336
|
+
vis migrate lint-staged # moves the config into vis.config.ts and rewrites hooks
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
The migrator detects `package.json` keys, `.lintstagedrc*` files, and `lint-staged.config.*`, prompts before rewriting husky/vis hooks to call `vis staged`, and removes `lint-staged` from the dependency list.
|
|
340
|
+
|
|
341
|
+
## Documentation
|
|
342
|
+
|
|
343
|
+
For full documentation including command reference, configuration options, best practices, and CI/CD integration guides, see the [docs](./docs) folder.
|
|
344
|
+
|
|
345
|
+
## Supported Node.js Versions
|
|
346
|
+
|
|
347
|
+
Libraries in this ecosystem make the best effort to track [Node.js' release schedule](https://github.com/nodejs/release#release-schedule).
|
|
348
|
+
Here's [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
349
|
+
|
|
350
|
+
## Contributing
|
|
351
|
+
|
|
352
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guidelines.
|
|
353
|
+
|
|
354
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
355
|
+
|
|
356
|
+
## Credits
|
|
357
|
+
|
|
358
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
359
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
360
|
+
|
|
361
|
+
## Made with ❤️ at Anolilab
|
|
362
|
+
|
|
363
|
+
This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
|
|
364
|
+
|
|
365
|
+
## License
|
|
366
|
+
|
|
367
|
+
The visulima vis is open-sourced software licensed under the [MIT][license]
|
|
368
|
+
|
|
369
|
+
<!-- badges -->
|
|
44
370
|
|
|
45
|
-
|
|
371
|
+
[license-badge]: https://img.shields.io/npm/l/@visulima/vis?style=for-the-badge
|
|
372
|
+
[license]: https://github.com/visulima/visulima/blob/main/LICENSE
|
|
373
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/vis?style=for-the-badge
|
|
374
|
+
[npm-downloads]: https://www.npmjs.com/package/@visulima/vis
|
|
375
|
+
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
|
|
376
|
+
[prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
|
|
377
|
+
[chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
|
|
378
|
+
[chat]: https://discord.gg/TtFJY8xkFK
|
|
379
|
+
[typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
380
|
+
[typescript-url]: https://www.typescriptlang.org/
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import"@visulima/cerebro";import"@visulima/cerebro/command/completion";import"@visulima/cerebro/compile-cache";import"@visulima/cerebro/heap-tuning";import"@visulima/cerebro/plugins/error-handler";import"@visulima/fs";import"@visulima/package";import"@visulima/path";import"./packem_chunks/bin.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all `vis.config.ts` / `vis.task.ts` loader failures.
|
|
3
|
+
* Consumers switch on `instanceof VisConfigError` to distinguish loader
|
|
4
|
+
* failures from arbitrary user-code exceptions thrown inside a config.
|
|
5
|
+
*/
|
|
6
|
+
declare class VisConfigError extends Error {
|
|
7
|
+
readonly chain: ReadonlyArray<string>;
|
|
8
|
+
constructor(message: string, chain: ReadonlyArray<string>, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
/** An `extends` chain re-enters a path that is still loading. */
|
|
11
|
+
declare class VisConfigCycleError extends VisConfigError {
|
|
12
|
+
constructor(reentered: string, chain: ReadonlyArray<string>);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Wraps any throw raised by jiti while compiling a `vis.config.ts` /
|
|
16
|
+
* `vis.task.ts`. Without this wrapper a user's syntax error surfaces as
|
|
17
|
+
* "TypeError in workspace.ts" — which sends them debugging the wrong file.
|
|
18
|
+
*/
|
|
19
|
+
declare class VisConfigLoadError extends VisConfigError {
|
|
20
|
+
constructor(filePath: string, chain: ReadonlyArray<string>, cause: unknown);
|
|
21
|
+
}
|
|
22
|
+
/** An entry in `extends` could not be resolved on disk or via npm. */
|
|
23
|
+
declare class VisConfigNotFoundError extends VisConfigError {
|
|
24
|
+
constructor(specifier: string, chain: ReadonlyArray<string>, attempted: ReadonlyArray<string>);
|
|
25
|
+
}
|
|
26
|
+
export { VisConfigCycleError, VisConfigError, VisConfigLoadError, VisConfigNotFoundError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{VisConfigCycleError as f}from"../packem_shared/VisConfigCycleError-CAYNC7d-.js";import{VisConfigError as e}from"../packem_shared/VisConfigError-B5LP1zRf.js";import{VisConfigLoadError as t}from"../packem_shared/VisConfigLoadError-CeqBSd2Z.js";import{VisConfigNotFoundError as g}from"../packem_shared/VisConfigNotFoundError-DZ9KC527.js";export{f as VisConfigCycleError,e as VisConfigError,t as VisConfigLoadError,g as VisConfigNotFoundError};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the `vis generate` template runtime.
|
|
3
|
+
*
|
|
4
|
+
* The shape intentionally echoes Bingo's `Template` so a future Bingo
|
|
5
|
+
* adapter (re-exporting `bingo` Templates through this runtime) is a
|
|
6
|
+
* one-pager. Authors do not depend on Bingo to write a vis generator.
|
|
7
|
+
*/
|
|
8
|
+
type VariableType = "array" | "boolean" | "enum" | "number" | "string";
|
|
9
|
+
/** Common variable fields (all types). */
|
|
10
|
+
interface VariableBase {
|
|
11
|
+
/**
|
|
12
|
+
* Default value when the user accepts the prompt without typing.
|
|
13
|
+
* For `boolean` this is `true|false`; for `enum` it must match `values`.
|
|
14
|
+
*/
|
|
15
|
+
default?: boolean | number | string | string[];
|
|
16
|
+
/** Hide from prompts; can still be set via CLI or `--defaults`. */
|
|
17
|
+
internal?: boolean;
|
|
18
|
+
/** Sort order in prompts (lower first). Defaults to declaration order. */
|
|
19
|
+
order?: number;
|
|
20
|
+
/** Override the prompt text. Defaults to the variable name. */
|
|
21
|
+
prompt?: string;
|
|
22
|
+
/** When true, the user must provide a non-empty value. */
|
|
23
|
+
required?: boolean;
|
|
24
|
+
}
|
|
25
|
+
type StringVariable = VariableBase & {
|
|
26
|
+
type: "string";
|
|
27
|
+
};
|
|
28
|
+
type NumberVariable = VariableBase & {
|
|
29
|
+
type: "number";
|
|
30
|
+
};
|
|
31
|
+
type BooleanVariable = VariableBase & {
|
|
32
|
+
default?: boolean;
|
|
33
|
+
type: "boolean";
|
|
34
|
+
};
|
|
35
|
+
type ArrayVariable = VariableBase & {
|
|
36
|
+
type: "array";
|
|
37
|
+
};
|
|
38
|
+
interface EnumVariable extends VariableBase {
|
|
39
|
+
/** Allow multiple selections (returns `string[]`). */
|
|
40
|
+
multiple?: boolean;
|
|
41
|
+
type: "enum";
|
|
42
|
+
/** Selectable values. */
|
|
43
|
+
values: string[];
|
|
44
|
+
}
|
|
45
|
+
type Variable = ArrayVariable | BooleanVariable | EnumVariable | NumberVariable | StringVariable;
|
|
46
|
+
/** Map of variable name → spec, as authors declare them. */
|
|
47
|
+
type VariableMap = Record<string, Variable>;
|
|
48
|
+
/** Resolved option values passed to `produce()`. */
|
|
49
|
+
type Options = Record<string, unknown>;
|
|
50
|
+
/** A file in a Creation can be a string, a Buffer (binary asset), or a nested directory. */
|
|
51
|
+
type CreationFile = Buffer | string;
|
|
52
|
+
interface CreationDirectory {
|
|
53
|
+
[key: string]: CreationDirectory | CreationFile;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Script entry produced by `produce()`.
|
|
57
|
+
* - `string`: shell command, runs in the destination directory.
|
|
58
|
+
* - `object`: shell commands with optional phase ordering.
|
|
59
|
+
*/
|
|
60
|
+
type Script = ScriptObject | string;
|
|
61
|
+
interface ScriptObject {
|
|
62
|
+
/** Shell command(s) to run sequentially. */
|
|
63
|
+
commands: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Phase ordering. Phases run in ascending order; scripts within
|
|
66
|
+
* the same phase are dispatched concurrently. Default: 0.
|
|
67
|
+
*/
|
|
68
|
+
phase?: number;
|
|
69
|
+
/** Suppress command output. Default: false. */
|
|
70
|
+
silent?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** Object returned by a template's `produce()` function. */
|
|
73
|
+
interface Creation {
|
|
74
|
+
/** Recursive directory tree. Keys with `/` are auto-split. */
|
|
75
|
+
files?: CreationDirectory;
|
|
76
|
+
/**
|
|
77
|
+
* Per-file metadata keyed by the *flattened* destination path
|
|
78
|
+
* (e.g. `src/foo.ts`). Optional — native templates usually omit
|
|
79
|
+
* this; the moon adapter populates it from per-file frontmatter
|
|
80
|
+
* so `force: true` survives the trip to the runner without
|
|
81
|
+
* changing the shape of `files`.
|
|
82
|
+
*/
|
|
83
|
+
filesMeta?: Record<string, FileMeta>;
|
|
84
|
+
/** Shell scripts to run after files are written. */
|
|
85
|
+
scripts?: Script[];
|
|
86
|
+
/** User-facing tips printed after the run. */
|
|
87
|
+
suggestions?: string[];
|
|
88
|
+
}
|
|
89
|
+
interface FileMeta {
|
|
90
|
+
/**
|
|
91
|
+
* Overwrite an existing file at this path without prompting or
|
|
92
|
+
* consulting the global `--force` flag.
|
|
93
|
+
*/
|
|
94
|
+
force?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Context object passed to `produce()`. */
|
|
97
|
+
interface TemplateContext {
|
|
98
|
+
/** Built-in variables: `dest_dir`, `dest_rel_dir`, `working_dir`, `workspace_root`. */
|
|
99
|
+
builtins: BuiltinVars;
|
|
100
|
+
/** Resolved option values (after prompts + CLI overrides + defaults). */
|
|
101
|
+
options: Options;
|
|
102
|
+
}
|
|
103
|
+
interface BuiltinVars {
|
|
104
|
+
/** Absolute destination directory. */
|
|
105
|
+
dest_dir: string;
|
|
106
|
+
/** Destination relative to the workspace root. */
|
|
107
|
+
dest_rel_dir: string;
|
|
108
|
+
/** Caller's current working directory. */
|
|
109
|
+
working_dir: string;
|
|
110
|
+
/** Absolute workspace root (from `findMonorepoRootSync`, fallback to `working_dir`). */
|
|
111
|
+
workspace_root: string;
|
|
112
|
+
}
|
|
113
|
+
/** Top-level "About" metadata for a template. */
|
|
114
|
+
interface TemplateAbout {
|
|
115
|
+
/** One-line description. */
|
|
116
|
+
description: string;
|
|
117
|
+
/** Short identifier shown in `vis generate --list` and prompts. */
|
|
118
|
+
name: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The author-facing template shape.
|
|
122
|
+
* Both native (`.vis/templates/<name>.ts`) and moon-adapter outputs
|
|
123
|
+
* normalize to this.
|
|
124
|
+
*/
|
|
125
|
+
interface Template {
|
|
126
|
+
about: TemplateAbout;
|
|
127
|
+
/**
|
|
128
|
+
* Default destination directory (relative to workspace root unless
|
|
129
|
+
* absolute or starting with `./`). Honored when the user does not
|
|
130
|
+
* pass `--to`. Maps to moon's `template.yml` `destination`.
|
|
131
|
+
*/
|
|
132
|
+
destination?: string;
|
|
133
|
+
/** Variable schema for prompts. */
|
|
134
|
+
options?: VariableMap;
|
|
135
|
+
/** Build the Creation given resolved options and built-in vars. */
|
|
136
|
+
produce: (context: TemplateContext) => Creation | Promise<Creation>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Discovery record: a Template plus where it came from.
|
|
140
|
+
* Surfaced by `vis generate --list`.
|
|
141
|
+
*/
|
|
142
|
+
interface DiscoveredTemplate {
|
|
143
|
+
/** Lazy loader — invoke to materialize the Template. */
|
|
144
|
+
load: () => Promise<Template>;
|
|
145
|
+
/** Stable name used by `vis generate <name>`. */
|
|
146
|
+
name: string;
|
|
147
|
+
/** Absolute path on disk (file for native, directory for moon). */
|
|
148
|
+
path: string;
|
|
149
|
+
/** Source classification — affects load + listing. */
|
|
150
|
+
source: "config" | "moon" | "native" | "remote";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Identity helper for type inference. Authors get autocomplete + checks
|
|
154
|
+
* without having to annotate the export.
|
|
155
|
+
*/
|
|
156
|
+
declare const createTemplate: (template: Template) => Template;
|
|
157
|
+
export { type ArrayVariable, type BooleanVariable, type BuiltinVars, type Creation, type CreationDirectory, type CreationFile, type DiscoveredTemplate, type EnumVariable, type FileMeta, type NumberVariable, type Options, type Script, type ScriptObject, type StringVariable, type Template, type TemplateAbout, type TemplateContext, type Variable, type VariableMap, type VariableType, createTemplate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty;var r=(e,a)=>t(e,"name",{value:a,configurable:!0});var c=Object.defineProperty,l=r((e,a)=>c(e,"name",{value:a,configurable:!0}),"a");const o=l(e=>e,"createTemplate");export{o as createTemplate};
|