knarr 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/README.md +26 -23
  2. package/dist/cli.mjs +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -16,9 +16,9 @@
16
16
 
17
17
  # Knarr
18
18
 
19
- Test local npm packages in real apps without `npm link`, duplicate React, or dirty `package.json` diffs.
19
+ Test local npm packages in real apps without `npm link` symlink surprises or local package references in `package.json`.
20
20
 
21
- Knarr copies the built package output directly into the consumer app's `node_modules/`, so your package behaves like the version you would publish to npm. It works well with pnpm, Vite, Next.js, Webpack/rspack, Turbopack, and teams that want local package overrides to stay out of git.
21
+ Knarr copies the package files you would publish into the consumer app's `node_modules/`, then keeps registered consumers updated. It detects npm, pnpm, Bun, and Yarn projects that use `node_modules` or Yarn's pnpm linker. Yarn PnP is not compatible because it removes `node_modules`.
22
22
 
23
23
  ```bash
24
24
  cd my-app
@@ -35,15 +35,17 @@ If you have not installed Knarr globally, use `npx knarr dev` for the second com
35
35
  ## Who this is for
36
36
 
37
37
  - Library and design-system authors testing packages inside real consumer apps
38
- - React developers avoiding duplicate React instances and invalid hook calls from symlinks
39
- - pnpm users where `npm link` or yalc do not match the installed dependency tree
40
- - Teams that want clean git diffs while iterating on local packages
38
+ - React developers avoiding duplicate dependency instances and invalid hook calls from symlinks
39
+ - pnpm users who want updates copied into the existing virtual-store install when possible
40
+ - Teams that want local package overrides to stay out of dependency specs and lockfiles
41
41
 
42
42
  ## Why Knarr?
43
43
 
44
- `npm link` creates symlinks that can break module resolution: duplicate React instances, peer dependency mismatches, and bundlers that cannot follow links outside the project root. yalc improves this by copying files, but it rewrites consumer dependency specs and usually needs extra watch tooling.
44
+ `npm link` creates symlinks that can break module resolution: duplicate dependency instances, peer dependency mismatches, and bundlers that cannot follow links outside the project root. yalc improves this by copying files, but its workflow can rewrite consumer dependency specs or require extra watch tooling.
45
45
 
46
- Knarr keeps your `package.json` and lockfile clean. It publishes a local package into `~/.knarr/store/`, injects that package into every registered consumer, and can watch, rebuild, and push changes continuously.
46
+ Knarr keeps the local override out of your dependency spec. It publishes a local package into `~/.knarr/store/`, injects that package into every registered consumer, and can watch, rebuild, and push changes continuously. Setup helpers may still add `.knarr/`, `.gitignore`, a restore hook, or bundler config when needed.
47
+
48
+ If pnpm workspaces, `file:`, or `dependenciesMeta.*.injected` already fit your repo, use those native features first. Knarr is for the narrower case where you want publishable package files copied into real consumers while their dependency specs stay normal.
47
49
 
48
50
  ## Quick Start
49
51
 
@@ -65,7 +67,7 @@ knarr dev
65
67
 
66
68
  If Knarr is not installed globally, run `npx knarr dev` instead.
67
69
 
68
- That is the everyday loop: edit `my-lib`, Knarr rebuilds it, pushes changed files into `my-app/node_modules/`, and your bundler sees the update.
70
+ That is the everyday loop: edit `my-lib`, Knarr rebuilds it, pushes changed files into `my-app/node_modules/`, and your dev server sees normal file changes there.
69
71
 
70
72
  If you prefer the explicit steps:
71
73
 
@@ -98,20 +100,20 @@ graph LR
98
100
  4. `push` publishes and copies to all registered consumers
99
101
  5. `dev` watches, builds, publishes, and pushes continuously
100
102
 
101
- ## At A Glance
103
+ ## What Knarr Does
102
104
 
103
- | | npm link | yalc | Knarr |
104
- | ---------------------- | ----------------------- | --------------------------- | ------------------- |
105
- | Mechanism | Symlinks | Copy + package.json rewrite | Copy only |
106
- | Module resolution | Broken (dual instances) | Works | Works |
107
- | Git contamination | None | package.json + .yalc/ | None |
108
- | Bundler HMR | Often broken | Varies | Works |
109
- | pnpm support | Fragile | Limited | Full |
110
- | Watch mode | None | External | Built-in |
111
- | Survives `npm install` | No | No | `knarr restore` |
112
- | Incremental sync | N/A | Full copy each time | mtime + xxhash diff |
105
+ | Area | Behavior |
106
+ | --- | --- |
107
+ | Store | `~/.knarr/store/<name>@<version>/package/`, or `KNARR_HOME/store/...` when `KNARR_HOME` is set |
108
+ | Consumer copy | Copies package files into `node_modules/<package>/` and records link state in `.knarr/state.json` |
109
+ | Package files | Uses npm-pack-compatible file resolution, including the `files` field and `publishConfig.directory` |
110
+ | pnpm | Follows existing pnpm virtual-store symlinks when present; falls back to a direct `node_modules` path |
111
+ | Watch loop | `knarr dev` runs an initial push, then watches, rebuilds, publishes, and pushes again |
112
+ | Reinstall recovery | `knarr restore` re-injects registered packages after `node_modules` is replaced |
113
+ | Bundlers | Vite plugin triggers reload/restart, Next.js uses `transpilePackages`, Webpack/rspack plugin invalidates watch/cache, and other bundlers rely on file changes under `node_modules` |
114
+ | Incremental sync | Skips same size and mtime, hashes same-size changed-mtime files with xxHash64, and removes stale destination files |
113
115
 
114
- See [detailed comparison](docs/comparison.md) for a deeper breakdown.
116
+ See [detailed comparison](docs/comparison.md) for native pnpm options, yalc, symlink workflows, and Knarr tradeoffs.
115
117
 
116
118
  ## Migrate From yalc In 60 Seconds
117
119
 
@@ -129,13 +131,13 @@ See [Migrating from yalc](docs/migrating-from-yalc.md) for the full guide.
129
131
  ## Install
130
132
 
131
133
  ```bash
132
- pnpm add -g knarr # or npm, yarn, bun
133
- npx knarr init # one-off setup for a consumer project
134
+ pnpm add -g knarr # or npm install -g knarr
135
+ npx knarr init # optional consumer setup and repair helpers
134
136
  ```
135
137
 
136
138
  ## Performance Notes
137
139
 
138
- knarr uses CoW reflinks for instant copy-on-write on APFS/btrfs/ReFS, with automatic fallback. Reflink support is probed once per volume and cached. Incremental sync checks size and mtime first, then falls back to xxhash only when needed, so unchanged files are skipped quickly.
140
+ Knarr uses Node's copy-on-write reflink mode when the current filesystem supports it, with automatic fallback to a normal copy. Reflink support is probed once per volume and cached. Incremental sync checks size and mtime first, then falls back to xxHash64 only when needed, so unchanged files are skipped quickly.
139
141
 
140
142
  ## Documentation
141
143
 
@@ -143,6 +145,7 @@ knarr uses CoW reflinks for instant copy-on-write on APFS/btrfs/ReFS, with autom
143
145
  - [Commands](docs/commands.md)
144
146
  - [Comparison](docs/comparison.md)
145
147
  - [Troubleshooting](docs/troubleshooting.md)
148
+ - [CI/CD](docs/ci-cd.md)
146
149
  - [Examples](examples/)
147
150
  - [Contributing](CONTRIBUTING.md)
148
151
 
package/dist/cli.mjs CHANGED
@@ -7,4 +7,4 @@ var a=c(a$1(),1);var _=`
7
7
  | . \\| | | | (_| | | | |
8
8
  |_|\\_\\_| |_|\\__,_|_| |_|
9
9
  `;function n(){console.log(a.default.yellow(_)),console.log(a.default.cyan(" Local npm package development without symlinks")),console.log(a.default.dim(` Copies built files into consumer node_modules with incremental sync
10
- `));}a$2(n,"showBanner");process.env.UV_THREADPOOL_SIZE??=String(Math.max(availableParallelism(),8));a$3();var l=process.argv.slice(2),b=["init","publish","add","use","remove","push","dev","restore","list","status","update","clean","gc","doctor","explain","migrate","reset","rollback","check"],u=l.some(e=>!e.startsWith("-")&&b.includes(e)),v=l.includes("--help")||l.includes("-h")||l.includes("--version");if(!u&&!v&&process.stdin.isTTY){n();let e=await g();e&&process.argv.splice(2,0,e);}else u||n();async function g(){try{let{readConsumerStateSafe:p}=await import('./tracker-QAKEXYUJ.mjs'),{resolve:c}=await import('path'),{state:d}=await p(c(".")),i=Object.keys(d.links).length;i>0&&b$1.info(`${i} package(s) linked in this project`);}catch{}return await b$1.prompt("What would you like to do?",{type:"select",options:[{label:"init - Set up knarr in this project",value:"init"},{label:"publish - Publish package to the knarr store",value:"publish"},{label:"add - Link a package from the store",value:"add"},{label:"use - Link a local package path",value:"use"},{label:"push - Publish and push to all consumers",value:"push"},{label:"dev - Watch, rebuild, and push continuously",value:"dev"},{label:"list - Show linked packages",value:"list"},{label:"status - Show project status",value:"status"},{label:"explain - Explain linked package state",value:"explain"},{label:"help - Show help",value:"--help"}]})||null}a$2(g,"showInteractiveMenu");var k={meta:{name:"knarr",version:"0.1.0",description:"Local npm package development - copies built files into consumer node_modules"},args:{verbose:{type:"boolean",alias:"v",description:"Enable verbose debug logging",default:false},"dry-run":{type:"boolean",description:"Preview changes without writing files",default:false},json:{type:"boolean",description:"Output machine-readable JSON",default:false}},subCommands:{init:a$2(()=>import('./init-X4F3XKVC.mjs').then(e=>e.default),"init"),publish:a$2(()=>import('./publish-UGDDG6OT.mjs').then(e=>e.default),"publish"),add:a$2(()=>import('./add-4Z3V5722.mjs').then(e=>e.default),"add"),use:a$2(()=>import('./use-LZ2GIXYZ.mjs').then(e=>e.default),"use"),remove:a$2(()=>import('./remove-EPVDMWCS.mjs').then(e=>e.default),"remove"),push:a$2(()=>import('./push-V575ASM4.mjs').then(e=>e.default),"push"),dev:a$2(()=>import('./dev-PUNHH4MS.mjs').then(e=>e.default),"dev"),restore:a$2(()=>import('./restore-QPISOGEK.mjs').then(e=>e.default),"restore"),list:a$2(()=>import('./list-4PTHMIQ4.mjs').then(e=>e.default),"list"),status:a$2(()=>import('./status-3ZXM3CRH.mjs').then(e=>e.default),"status"),explain:a$2(()=>import('./explain-BDTONX7H.mjs').then(e=>e.default),"explain"),update:a$2(()=>import('./update-RSPDDAJK.mjs').then(e=>e.default),"update"),clean:a$2(()=>import('./clean-EJIYYQZM.mjs').then(e=>e.default),"clean"),gc:a$2(()=>import('./clean-EJIYYQZM.mjs').then(e=>e.default),"gc"),doctor:a$2(()=>import('./doctor-ZK4OPSD4.mjs').then(e=>e.default),"doctor"),migrate:a$2(()=>import('./migrate-VHDLW6I7.mjs').then(e=>e.default),"migrate"),reset:a$2(()=>import('./reset-5M6AU4FU.mjs').then(e=>e.default),"reset"),rollback:a$2(()=>import('./rollback-CTGK7SXG.mjs').then(e=>e.default),"rollback"),check:a$2(()=>import('./check-7CJHAF6Y.mjs').then(e=>e.default),"check")}};a$4(k);
10
+ `));}a$2(n,"showBanner");process.env.UV_THREADPOOL_SIZE??=String(Math.max(availableParallelism(),8));a$3();var l=process.argv.slice(2),b=["init","publish","add","use","remove","push","dev","restore","list","status","update","clean","gc","doctor","explain","migrate","reset","rollback","check"],u=l.some(e=>!e.startsWith("-")&&b.includes(e)),v=l.includes("--help")||l.includes("-h")||l.includes("--version");if(!u&&!v&&process.stdin.isTTY){n();let e=await g();e&&process.argv.splice(2,0,e);}else u||n();async function g(){try{let{readConsumerStateSafe:p}=await import('./tracker-QAKEXYUJ.mjs'),{resolve:c}=await import('path'),{state:d}=await p(c(".")),i=Object.keys(d.links).length;i>0&&b$1.info(`${i} package(s) linked in this project`);}catch{}return await b$1.prompt("What would you like to do?",{type:"select",options:[{label:"init - Set up knarr in this project",value:"init"},{label:"publish - Publish package to the knarr store",value:"publish"},{label:"add - Link a package from the store",value:"add"},{label:"use - Link a local package path",value:"use"},{label:"push - Publish and push to all consumers",value:"push"},{label:"dev - Watch, rebuild, and push continuously",value:"dev"},{label:"list - Show linked packages",value:"list"},{label:"status - Show project status",value:"status"},{label:"explain - Explain linked package state",value:"explain"},{label:"help - Show help",value:"--help"}]})||null}a$2(g,"showInteractiveMenu");var k={meta:{name:"knarr",version:"0.1.1",description:"Local npm package development - copies built files into consumer node_modules"},args:{verbose:{type:"boolean",alias:"v",description:"Enable verbose debug logging",default:false},"dry-run":{type:"boolean",description:"Preview changes without writing files",default:false},json:{type:"boolean",description:"Output machine-readable JSON",default:false}},subCommands:{init:a$2(()=>import('./init-X4F3XKVC.mjs').then(e=>e.default),"init"),publish:a$2(()=>import('./publish-UGDDG6OT.mjs').then(e=>e.default),"publish"),add:a$2(()=>import('./add-4Z3V5722.mjs').then(e=>e.default),"add"),use:a$2(()=>import('./use-LZ2GIXYZ.mjs').then(e=>e.default),"use"),remove:a$2(()=>import('./remove-EPVDMWCS.mjs').then(e=>e.default),"remove"),push:a$2(()=>import('./push-V575ASM4.mjs').then(e=>e.default),"push"),dev:a$2(()=>import('./dev-PUNHH4MS.mjs').then(e=>e.default),"dev"),restore:a$2(()=>import('./restore-QPISOGEK.mjs').then(e=>e.default),"restore"),list:a$2(()=>import('./list-4PTHMIQ4.mjs').then(e=>e.default),"list"),status:a$2(()=>import('./status-3ZXM3CRH.mjs').then(e=>e.default),"status"),explain:a$2(()=>import('./explain-BDTONX7H.mjs').then(e=>e.default),"explain"),update:a$2(()=>import('./update-RSPDDAJK.mjs').then(e=>e.default),"update"),clean:a$2(()=>import('./clean-EJIYYQZM.mjs').then(e=>e.default),"clean"),gc:a$2(()=>import('./clean-EJIYYQZM.mjs').then(e=>e.default),"gc"),doctor:a$2(()=>import('./doctor-ZK4OPSD4.mjs').then(e=>e.default),"doctor"),migrate:a$2(()=>import('./migrate-VHDLW6I7.mjs').then(e=>e.default),"migrate"),reset:a$2(()=>import('./reset-5M6AU4FU.mjs').then(e=>e.default),"reset"),rollback:a$2(()=>import('./rollback-CTGK7SXG.mjs').then(e=>e.default),"rollback"),check:a$2(()=>import('./check-7CJHAF6Y.mjs').then(e=>e.default),"check")}};a$4(k);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knarr",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Copy local npm package builds into consumer node_modules with incremental sync and watch mode.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",