@olegkuibar/plunk 0.3.1 → 0.4.0-canary.15df40d
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/README.md +31 -9
- package/dist/add-32QF7GZO.mjs +14 -0
- package/dist/{chunk-KVVUZ6KL.mjs → chunk-22YCXJTS.mjs} +1 -1
- package/dist/{chunk-ZAUWE3N7.mjs → chunk-4ZGIZZSF.mjs} +3 -3
- package/dist/chunk-AC5FETT7.mjs +4 -0
- package/dist/chunk-BRC4A5PJ.mjs +3 -0
- package/dist/chunk-EMRPZYLU.mjs +3 -0
- package/dist/chunk-HHV6VEYA.mjs +7 -0
- package/dist/chunk-HPF6K6WO.mjs +3 -0
- package/dist/chunk-ICCM7US5.mjs +3 -0
- package/dist/chunk-IZRTKGYZ.mjs +15 -0
- package/dist/chunk-LLVBXPQN.mjs +3 -0
- package/dist/chunk-OJJZ7CLB.mjs +3 -0
- package/dist/chunk-PVMVWPLG.mjs +4 -0
- package/dist/chunk-R3RSOZXN.mjs +3 -0
- package/dist/chunk-TMH7HIJ2.mjs +3 -0
- package/dist/clean-F2IWAVRP.mjs +3 -0
- package/dist/cli.mjs +10 -2
- package/dist/dev-ZBELDIBF.mjs +3 -0
- package/dist/doctor-GJGAAT6J.mjs +4 -0
- package/dist/fs-BUNURH4P.mjs +2 -0
- package/dist/index.d.ts +38 -5
- package/dist/index.mjs +557 -252
- package/dist/init-C6XCSFCU.mjs +7 -0
- package/dist/list-QSPN7FE5.mjs +5 -0
- package/dist/migrate-4TFDXO4G.mjs +8 -0
- package/dist/publish-6A7PX5IH.mjs +3 -0
- package/dist/push-GUFND2MN.mjs +3 -0
- package/dist/remove-V3T3XXOY.mjs +3 -0
- package/dist/restore-I5W7PTSI.mjs +11 -0
- package/dist/status-22YV26A3.mjs +4 -0
- package/dist/{tailwind-source-VPNLLSRJ.mjs → tailwind-source-YCRZUHUP.mjs} +2 -2
- package/dist/update-NK2BQY7K.mjs +3 -0
- package/dist/{vite-config-ZMDIOTXC.mjs → vite-config-LXMLHR7V.mjs} +4 -4
- package/dist/vite-plugin.mjs +142 -19
- package/dist/watcher-J4T66EOT.mjs +3 -0
- package/dist/workspace-SKJJQMMK.mjs +3 -0
- package/dist/xxhash-wasm-DTW44IIQ.mjs +3 -0
- package/package.json +6 -3
- package/dist/add-4LHIITHV.mjs +0 -14
- package/dist/chunk-4QWBGXB5.mjs +0 -15
- package/dist/chunk-4TNTNSAB.mjs +0 -4
- package/dist/chunk-6YX2BGO2.mjs +0 -3
- package/dist/chunk-AR7AKSKG.mjs +0 -3
- package/dist/chunk-LI4HG26F.mjs +0 -4
- package/dist/chunk-QUI5JAIH.mjs +0 -3
- package/dist/chunk-RITKSDMP.mjs +0 -3
- package/dist/chunk-UAGG5WMD.mjs +0 -3
- package/dist/chunk-UDONDVIM.mjs +0 -7
- package/dist/chunk-ZIXSXQRE.mjs +0 -3
- package/dist/chunk-ZJMZKJNW.mjs +0 -3
- package/dist/clean-EWBL6FW2.mjs +0 -3
- package/dist/dev-NCLIWE2E.mjs +0 -3
- package/dist/doctor-PXC45S34.mjs +0 -4
- package/dist/init-TZ76GAWN.mjs +0 -7
- package/dist/list-CCR7QD7N.mjs +0 -5
- package/dist/migrate-6RZ3SEU5.mjs +0 -8
- package/dist/publish-4TDT6TTS.mjs +0 -3
- package/dist/push-M4RSFETI.mjs +0 -3
- package/dist/remove-R55FIXPL.mjs +0 -3
- package/dist/restore-XBFOHISI.mjs +0 -11
- package/dist/status-GCATYK2I.mjs +0 -4
- package/dist/update-6PLGM37S.mjs +0 -3
- package/dist/workspace-VREEJZ76.mjs +0 -3
package/README.md
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
+
<a href="https://plunk-playground.vercel.app"><img src="https://img.shields.io/badge/Try_in_Browser-Playground-58a6ff?style=flat&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0tMiAxNWwtNS01IDEuNDEtMS40MUwxMCAxNC4xN2w3LjU5LTcuNTlMMTkgOGwtOSA5eiIvPjwvc3ZnPg==" alt="Playground" /></a>
|
|
6
7
|
<a href="https://www.npmjs.com/package/@olegkuibar/plunk"><img src="https://img.shields.io/npm/v/@olegkuibar/plunk?color=blue" alt="npm version" /></a>
|
|
7
8
|
<a href="https://www.npmjs.com/package/@olegkuibar/plunk"><img src="https://img.shields.io/npm/dm/@olegkuibar/plunk" alt="npm downloads" /></a>
|
|
9
|
+
<a href="https://bundlephobia.com/package/@olegkuibar/plunk"><img src="https://badgen.net/bundlephobia/minzip/@olegkuibar/plunk" alt="minzipped size" /></a>
|
|
10
|
+
<a href="https://bundlephobia.com/package/@olegkuibar/plunk"><img src="https://badgen.net/bundlephobia/dependency-count/@olegkuibar/plunk" alt="dependency count" /></a>
|
|
11
|
+
<a href="https://bundlephobia.com/package/@olegkuibar/plunk"><img src="https://badgen.net/bundlephobia/tree-shaking/@olegkuibar/plunk" alt="tree-shaking" /></a>
|
|
8
12
|
<a href="https://github.com/oleg-kuibar/plunk/actions/workflows/ci.yml"><img src="https://github.com/oleg-kuibar/plunk/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
9
13
|
<a href="https://github.com/oleg-kuibar/plunk/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license" /></a>
|
|
10
14
|
<img src="https://img.shields.io/badge/node-%3E%3D22.12-brightgreen" alt="node version" />
|
|
@@ -12,7 +16,7 @@
|
|
|
12
16
|
|
|
13
17
|
# plunk
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
Local npm package development without symlinks. Copies built files directly into consumer `node_modules/` with incremental sync, watch mode, and support for every package manager and bundler.
|
|
16
20
|
|
|
17
21
|
```bash
|
|
18
22
|
npx plunk init # set up your app
|
|
@@ -20,11 +24,11 @@ plunk add my-lib # link a package
|
|
|
20
24
|
plunk push --watch # continuous dev mode
|
|
21
25
|
```
|
|
22
26
|
|
|
23
|
-
## Why
|
|
27
|
+
## Why plunk?
|
|
24
28
|
|
|
25
|
-
`npm link` creates symlinks that break module resolution
|
|
29
|
+
`npm link` creates symlinks that break module resolution — duplicate React instances, peer dep mismatches, bundlers that can't follow links outside the project root. Tools like [yalc](https://github.com/wclr/yalc) improved on this by copying files instead, but still modify `package.json` and lack built-in watch mode.
|
|
26
30
|
|
|
27
|
-
**plunk**
|
|
31
|
+
**plunk** copies built files directly into `node_modules/` without touching your `package.json` or lock file. Incremental sync (xxhash diffing + mtime fast-skip), built-in watch mode, and multi-consumer push make it practical for daily development across projects.
|
|
28
32
|
|
|
29
33
|
## How it works
|
|
30
34
|
|
|
@@ -72,30 +76,48 @@ plunk push --watch --build "pnpm build"
|
|
|
72
76
|
|
|
73
77
|
| | npm link | yalc | plunk |
|
|
74
78
|
|---|---|---|---|
|
|
79
|
+
| Mechanism | Symlinks | Copy + package.json rewrite | Copy only |
|
|
75
80
|
| Module resolution | Broken (dual instances) | Works | Works |
|
|
76
81
|
| Git contamination | None | package.json + .yalc/ | None |
|
|
77
|
-
| Bundler HMR | Often broken |
|
|
78
|
-
| pnpm support | Fragile |
|
|
82
|
+
| Bundler HMR | Often broken | Varies | Works |
|
|
83
|
+
| pnpm support | Fragile | Limited | Full |
|
|
79
84
|
| Watch mode | None | External | Built-in |
|
|
80
85
|
| Survives `npm install` | No | No | `plunk restore` |
|
|
86
|
+
| Incremental sync | N/A | Full copy each time | mtime + xxhash diff |
|
|
87
|
+
|
|
88
|
+
See [detailed comparison](docs/comparison.md) for a deeper breakdown.
|
|
81
89
|
|
|
82
90
|
## Install
|
|
83
91
|
|
|
84
92
|
```bash
|
|
85
|
-
pnpm add -g plunk # or npm, yarn, bun
|
|
86
|
-
npx plunk init # set up a consumer project
|
|
93
|
+
pnpm add -g @olegkuibar/plunk # or npm, yarn, bun
|
|
94
|
+
npx @olegkuibar/plunk init # set up a consumer project
|
|
87
95
|
```
|
|
88
96
|
|
|
97
|
+
## Try it online
|
|
98
|
+
|
|
99
|
+
Experience plunk directly in your browser with our interactive playground:
|
|
100
|
+
|
|
101
|
+
**[Open Playground](https://plunk-playground.vercel.app)** — Run real `plunk publish`, `plunk add`, and `plunk push` commands with live HMR preview.
|
|
102
|
+
|
|
89
103
|
## Documentation
|
|
90
104
|
|
|
91
105
|
| | |
|
|
92
|
-
|
|
106
|
+
| --- | --- |
|
|
93
107
|
| [Getting Started](docs/getting-started.md) | Install, first publish/add cycle, watch mode |
|
|
94
108
|
| [Commands](docs/commands.md) | Every command, every flag |
|
|
95
109
|
| [How It Works](docs/how-it-works.md) | Store format, injection, CoW copies |
|
|
96
110
|
| [Bundler Guide](docs/bundlers.md) | Vite, Webpack, esbuild, Turbopack setup |
|
|
97
111
|
| [Comparison](docs/comparison.md) | npm link vs yalc vs plunk |
|
|
112
|
+
| [CI/CD](docs/ci-cd.md) | Using plunk in CI pipelines |
|
|
113
|
+
| [Monorepo Guide](docs/monorepo.md) | Workspace setup and recursive publish |
|
|
114
|
+
| [Troubleshooting](docs/troubleshooting.md) | Common issues and fixes |
|
|
115
|
+
| [FAQ](docs/faq.md) | Frequently asked questions |
|
|
116
|
+
| [Migrating from yalc](docs/migrating-from-yalc.md) | Step-by-step migration guide |
|
|
117
|
+
| [Architecture](docs/architecture.md) | Internals for contributors |
|
|
118
|
+
| [API Reference](docs/api.md) | Programmatic API (TypeScript) |
|
|
98
119
|
| [Examples](examples/) | Try it yourself with real packages |
|
|
120
|
+
| [Playground](playground/) | Interactive browser-based playground |
|
|
99
121
|
| [Contributing](CONTRIBUTING.md) | Dev setup and guidelines |
|
|
100
122
|
|
|
101
123
|
## License
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$6}from'./chunk-HHV6VEYA.mjs';import {b as b$5,a as a$5,e}from'./chunk-IZRTKGYZ.mjs';import {c as c$1}from'./chunk-4ZGIZZSF.mjs';import {a as a$4,b as b$4,c as c$2,d as d$2}from'./chunk-AC5FETT7.mjs';import {f,d,h}from'./chunk-LLVBXPQN.mjs';import {a as a$3}from'./chunk-PVMVWPLG.mjs';import {a as a$2}from'./chunk-HPF6K6WO.mjs';import {b as b$3,c}from'./chunk-EMRPZYLU.mjs';import {a as a$1}from'./chunk-MBKCCWSD.mjs';import {i}from'./chunk-22YCXJTS.mjs';import {b as b$2,a as a$7}from'./chunk-OJJZ7CLB.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-HW7AEGI3.mjs';import {k}from'./chunk-TMH7HIJ2.mjs';import {c as c$3,d as d$1}from'./chunk-R3RSOZXN.mjs';import {b as b$1}from'./chunk-ICCM7US5.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile}from'fs/promises';import {spawn}from'child_process';import {platform}from'os';import {join,resolve,basename}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var Pn={meta:{name:"add",description:"Link a package from the plunk store into this project"},args:{package:{type:"positional",description:"Package name to add",required:true},from:{type:"string",description:"Path to package source (will publish first)"},yes:{type:"boolean",alias:"y",description:"Auto-accept prompts (install missing deps, etc.)",default:false}},async run({args:t}){b$2();let s=new a$1,n=resolve("."),{name:e$1,version:c$4}=nn(t.package);if((!e$1||e$1==="@"||e$1.startsWith("@")&&!e$1.includes("/"))&&(a$2(`Invalid package name "${t.package}". Use format: package-name or @scope/package-name`),process.exit(1)),t.from){let o=resolve(t.from);b$1.info(`Publishing from ${o}...`),await a$3(o);}let a=c$4?await b$3(e$1,c$4):await c(e$1);if(!a){let o=c$4?`@${c$4} `:"";a$2(`Package "${e$1}"${o?" "+o:""} not found in store. Run 'plunk publish' in the package directory first, or use --from <path>.`),process.exit(1);}let p=!await k(i(n)),r=await a$4(n);if(p&&(await c$1(n,r),b$1.success("Auto-initialized plunk (consumer mode)")),b$1.info(`Detected package manager: ${r}`),r==="yarn"){let o=await b$4(n);(o==="pnp"||o===null&&await c$2(n))&&(b$1.error(`Yarn PnP mode is not compatible with plunk.
|
|
4
|
+
|
|
5
|
+
plunk works by copying files into node_modules/, but PnP eliminates
|
|
6
|
+
node_modules/ entirely. To use plunk with Yarn Berry, add this to
|
|
7
|
+
.yarnrc.yml:
|
|
8
|
+
|
|
9
|
+
nodeLinker: node-modules
|
|
10
|
+
|
|
11
|
+
Then run: yarn install`),process.exit(1));}let g=await f(n,e$1);g&&(g.version===a.version?b$1.info(`Updating ${e$1}@${a.version} (already linked)`):b$1.info(`Updating ${e$1}: ${g.version} \u2192 ${a.version}`));let v=await b$5(n,e$1,r);v&&b$1.info(`Backed up existing ${e$1} installation`);let u=await a$5(a,n,r);b$1.success(`Linked ${e$1}@${a.version} \u2192 node_modules/${e$1} (${u.copied} files copied, ${u.skipped} unchanged)`),u.binLinks>0&&b$1.info(`Created ${u.binLinks} bin link(s)`);let q={version:a.version,contentHash:a.meta.contentHash,linkedAt:new Date().toISOString(),sourcePath:a.meta.sourcePath,backupExists:v,packageManager:r,buildId:a.meta.buildId??""};await d(n,e$1,q),await h(e$1,n),await en(n,e$1,a.version);let l=await e(a,n);if(l.length>0)if(c$3())d$1(`[add] Missing transitive deps (json mode): ${l.join(", ")}`);else if(t.yes){let o=y(r,l);b$1.info(`Installing missing dependencies: ${l.join(", ")}`),await b(o,n)?b$1.success("Installed missing dependencies"):b$1.warn(`Install failed. Run manually: ${o}`);}else if(await b$1.prompt(`Install ${l.length} missing dependencies? (${l.join(", ")})`,{type:"confirm",initial:true})){let m=y(r,l);await b(m,n)?b$1.success("Installed missing dependencies"):b$1.warn(`Install failed. Run manually: ${m}`);}else b$1.warn(`Missing transitive dependencies: ${l.join(", ")}
|
|
12
|
+
Run: ${y(r,l)}`);let d$3=await d$2(n);if(d$3.type==="next"&&d$3.configFile){let o=await a$6(d$3.configFile,e$1);o.modified?b$1.success(`Added ${e$1} to transpilePackages in ${basename(d$3.configFile)}`):o.error&&b$1.info(`Add to next.config manually: transpilePackages: ['${e$1}']`);}else if(d$3.type==="vite"&&d$3.configFile){let{addPlunkVitePlugin:o}=await import('./vite-config-LXMLHR7V.mjs'),m=await o(d$3.configFile);if(m.modified){b$1.success(`Added plunk plugin to ${basename(d$3.configFile)}`);let w=Z(r,"@olegkuibar/plunk");b$1.info("Installing @olegkuibar/plunk as devDependency..."),await b(w,n)?b$1.success("Installed @olegkuibar/plunk"):b$1.warn(`Install failed. Run manually: ${w}`);}else m.error&&b$1.info(`Add manually:
|
|
13
|
+
import plunk from "@olegkuibar/plunk/vite"
|
|
14
|
+
plugins: [plunk()]`);}let{findTailwindCss:z,addTailwindSource:G}=await import('./tailwind-source-YCRZUHUP.mjs'),k$1=await z(n);if(k$1){let o=await G(k$1,e$1,n);o.modified?b$1.success(`Added @source for ${e$1} to ${basename(k$1)}`):o.error&&b$1.info(`Add to your CSS manually: @source "../node_modules/${e$1}";`);}b$1.info(`Done in ${s.elapsed()}`),a$7({package:e$1,version:a.version,copied:u.copied,skipped:u.skipped,binLinks:u.binLinks,elapsed:s.elapsedMs()});}};function y(t,s){let n=s.join(" ");switch(t){case "pnpm":return `pnpm add ${n}`;case "yarn":return `yarn add ${n}`;case "bun":return `bun add ${n}`;default:return `npm install ${n}`}}a(y,"buildInstallCommand");function Z(t,s){switch(t){case "pnpm":return `pnpm add -D ${s}`;case "yarn":return `yarn add -D ${s}`;case "bun":return `bun add -d ${s}`;default:return `npm install -D ${s}`}}a(Z,"buildDevInstallCommand");function b(t,s){return new Promise(n=>{let e=platform()==="win32",p=spawn(e?"cmd":"sh",[e?"/c":"-c",t],{cwd:s,stdio:"inherit"});p.on("close",r=>n(r===0)),p.on("error",()=>n(false));})}a(b,"runInstallCommand");function nn(t){if(t.startsWith("@")){let n=t.indexOf("/");if(n>0){let e=t.indexOf("@",n);if(e>n)return {name:t.slice(0,e),version:t.slice(e+1)}}return {name:t,version:null}}let s=t.lastIndexOf("@");return s>0?{name:t.slice(0,s),version:t.slice(s+1)}:{name:t,version:null}}a(nn,"parsePackageArg");async function en(t,s,n){try{let e=await readFile(join(t,"package.json"),"utf-8"),c=JSON.parse(e),a=c.dependencies?.[s]??c.devDependencies?.[s]??c.peerDependencies?.[s];if(!a||/^(workspace:|catalog:|\*)/.test(a))return;let p=a.match(/(\d+)\.\d+\.\d+/);if(!p)return;let r=parseInt(p[1],10),g=parseInt(n.split(".")[0],10);r!==g&&b$1.warn(`Version mismatch: store has ${s}@${n} but your package.json declares "${a}". Consider updating your dependency range.`);}catch{}}a(en,"warnVersionMismatch");export{Pn as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {createRequire}from'node:module';import {c}from'./chunk-
|
|
2
|
+
import {createRequire}from'node:module';import {c}from'./chunk-TMH7HIJ2.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {homedir}from'os';import {join,dirname}from'path';import {mkdir,stat,rm}from'fs/promises';import {setTimeout}from'timers/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
3
|
function p(){return process.env.PLUNK_HOME||join(homedir(),".plunk")}a(p,"getPlunkHome");function x(){return join(p(),"store")}a(x,"getStorePath");function M(){return join(p(),"consumers.json")}a(M,"getConsumersPath");function l(t){return t.replace(/\//g,"+")}a(l,"encodePackageName");function S(t){if(t.startsWith("@")){let r=t.indexOf("+");if(r!==-1)return t.slice(0,r)+"/"+t.slice(r+1)}return t}a(S,"decodePackageName");function m(t,r){return join(x(),`${l(t)}@${r}`)}a(m,"getStoreEntryPath");function T(t,r){return join(m(t,r),"package")}a(T,"getStorePackagePath");function v(t,r){return join(m(t,r),".plunk-meta.json")}a(v,"getStoreMetaPath");function R(t){return join(t,".plunk")}a(R,"getConsumerPlunkDir");function I(t){return join(t,".plunk","state.json")}a(I,"getConsumerStatePath");function A(t,r){return join(t,".plunk","backups",l(r))}a(A,"getConsumerBackupPath");function L(t,r){return join(t,"node_modules",r)}a(L,"getNodeModulesPackagePath");var s={retries:5,minTimeout:100,maxTimeout:1e3,factor:2,stale:1e4};async function q(t,r,i){await mkdir(dirname(t),{recursive:true});let o=t+".lk",d=i?.stale??s.stale,c$1=false;for(let u=0;u<=s.retries;u++)try{await mkdir(o),c$1=!0;break}catch(a){if(c(a)&&a.code==="EEXIST"){try{let f=await stat(o);if(Date.now()-f.mtimeMs>d){await rm(o,{recursive:!0,force:!0});continue}}catch{continue}if(u<s.retries){let f=Math.min(s.minTimeout*s.factor**u,s.maxTimeout);await setTimeout(f);}}else throw a}if(!c$1)throw new Error(`Failed to acquire lock after ${s.retries} attempts. Another plunk process may be running. If this persists, delete ${o} and retry.`);try{return await r()}finally{await rm(o,{recursive:true,force:true});}}a(q,"withFileLock");function _(t){if(typeof t!="object"||t===null)return false;let r=t;return typeof r.contentHash=="string"&&typeof r.publishedAt=="string"&&typeof r.sourcePath=="string"&&(r.buildId===void 0||typeof r.buildId=="string")&&(r.schemaVersion===void 0||typeof r.schemaVersion=="number")}a(_,"isPlunkMeta");function j(t){if(typeof t!="object"||t===null)return false;let r=t;return typeof r.version=="string"&&typeof r.contentHash=="string"&&typeof r.linkedAt=="string"&&typeof r.sourcePath=="string"&&typeof r.backupExists=="boolean"&&typeof r.packageManager=="string"&&["npm","pnpm","yarn","bun"].includes(r.packageManager)&&(r.buildId===void 0||typeof r.buildId=="string")}a(j,"isLinkEntry");function B(t){if(typeof t!="object"||t===null)return false;let r=t;if(r.version!=="1"||typeof r.links!="object"||r.links===null)return false;let i=r.links;for(let o of Object.values(i))if(!j(o))return false;return true}a(B,"isConsumerState");function K(t){if(typeof t!="object"||t===null)return false;let r=t;for(let i of Object.values(r)){if(!Array.isArray(i))return false;for(let o of i)if(typeof o!="string")return false}return true}a(K,"isConsumersRegistry");
|
|
4
4
|
export{x as a,M as b,l as c,S as d,m as e,T as f,v as g,R as h,I as i,A as j,L as k,q as l,_ as m,B as n,K as o};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {createRequire}from'node:module';import {
|
|
2
|
+
import {createRequire}from'node:module';import {c as c$1,a as a$2}from'./chunk-LLVBXPQN.mjs';import {h,i}from'./chunk-22YCXJTS.mjs';import {k,i as i$1}from'./chunk-TMH7HIJ2.mjs';import {a,b}from'./chunk-ICCM7US5.mjs';import {c,a as a$1}from'./chunk-2VCW5RWI.mjs';import {readFile,writeFile}from'fs/promises';import {join}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
3
|
var y=c(a(),1);async function x(t){let n="";try{n=await readFile(t,"utf-8");}catch{}if(n.split(`
|
|
4
4
|
`).some(a=>a.trim()===".plunk/"||a.trim()===".plunk"||a.trim()==="/.plunk/"||a.trim()==="/.plunk"))return false;let o=n.length>0&&!n.endsWith(`
|
|
5
5
|
`)?`
|
|
@@ -8,5 +8,5 @@ var y=c(a(),1);async function x(t){let n="";try{n=await readFile(t,"utf-8");}cat
|
|
|
8
8
|
.plunk/
|
|
9
9
|
`:`# plunk local links
|
|
10
10
|
.plunk/
|
|
11
|
-
`;return await writeFile(t,n+o+r),true}a$1(x,"ensureGitignore");async function C(t){let n=await readFile(t,"utf-8"),e=JSON.parse(n);if(e.scripts?.postinstall)return e.scripts.postinstall.includes("plunk")||b.warn(`Existing postinstall script found. Add ${y.default.cyan("plunk restore")} manually if needed.`),false;e.scripts||(e.scripts={}),e.scripts.postinstall="plunk restore || true";let s=n.match(/^(\s+)"/m)?.[1]||" ";return await writeFile(t,JSON.stringify(e,null,s)+`
|
|
12
|
-
`),true}a$1(C,"addPostinstall");async function J(t,n){let e=h(t),s=i(t);if(!await
|
|
11
|
+
`;return await writeFile(t,n+o+r),true}a$1(x,"ensureGitignore");async function C(t){let n=await readFile(t,"utf-8"),e=JSON.parse(n);if(e.scripts?.postinstall)return e.scripts.postinstall.includes("plunk")||b.warn(`Existing postinstall script found. Add ${y.default.cyan("npx @olegkuibar/plunk restore")} manually if needed.`),false;e.scripts||(e.scripts={}),e.scripts.postinstall="npx @olegkuibar/plunk restore || true";let s=n.match(/^(\s+)"/m)?.[1]||" ";return await writeFile(t,JSON.stringify(e,null,s)+`
|
|
12
|
+
`),true}a$1(C,"addPostinstall");async function J(t,n){let e=h(t),s=i(t);if(!await k(s))await i$1(e),await c$1(t,{version:"1",packageManager:n,role:"consumer",links:{}});else {let a=await a$2(t);a.packageManager||(a.packageManager=n,a.role=a.role??"consumer",await c$1(t,a));}let o=join(t,".gitignore");await x(o);let r=join(t,"package.json");await k(r)&&await C(r);}a$1(J,"ensureConsumerInit");export{x as a,C as b,J as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {k}from'./chunk-TMH7HIJ2.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {stat,readFile}from'fs/promises';import {join,dirname}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var y=[["pnpm-lock.yaml","pnpm"],["bun.lockb","bun"],["bun.lock","bun"],["yarn.lock","yarn"],["package-lock.json","npm"]];async function b(o){let n=o;for(;;){let t=(await Promise.all(y.map(async([r,c])=>{try{return await stat(join(n,r)),c}catch{return null}}))).find(r=>r!==null);if(t)return t;let e=dirname(n);if(e===n)return "npm";n=e;}}a(b,"detectPackageManager");async function w(o){let n=o;for(;;){let i;try{i=await readFile(join(n,".yarnrc.yml"),"utf-8");}catch{let t=dirname(n);if(t===n)return null;n=t;continue}for(let t of i.split(`
|
|
4
|
+
`)){let e=t.trim();if(e.startsWith("#")||!e.includes("nodeLinker"))continue;let r=e.match(/^nodeLinker:\s*(.+)$/);if(r){let c=r[1].trim().replace(/^["']|["']$/g,"");if(c==="node-modules"||c==="pnpm"||c==="pnp")return c}}return null}}a(w,"detectYarnNodeLinker");async function P(o){let n=o;for(;;)try{return await stat(join(n,".yarnrc.yml")),!0}catch{let i=dirname(n);if(i===n)return false;n=i;}}a(P,"hasYarnrcYml");var g=[["vite",["vite.config.ts","vite.config.js","vite.config.mts","vite.config.mjs"]],["next",["next.config.js","next.config.ts","next.config.mjs"]],["webpack",["webpack.config.js","webpack.config.ts"]],["turbo",["turbo.json"]],["rollup",["rollup.config.js","rollup.config.ts","rollup.config.mjs"]]];async function L(o){for(let[n,i]of g)for(let t of i){let e=join(o,t);if(await k(e))return {type:n,configFile:e}}return {type:null,configFile:null}}a(L,"detectBundler");async function v(o){let n=g.flatMap(([r,c])=>c.map(async l=>({type:r,configFile:join(o,l),found:await k(join(o,l))}))),i=await Promise.all(n),t=new Set,e=[];for(let{type:r,configFile:c,found:l}of i)l&&!t.has(r)&&(t.add(r),e.push({type:r,configFile:c}));return e}a(v,"detectAllBundlers");export{b as a,w as b,P as c,L as d,v as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$6}from'./chunk-IZRTKGYZ.mjs';import {a as a$8}from'./chunk-7JG555TZ.mjs';import {a as a$7}from'./chunk-AC5FETT7.mjs';import {j,f,d as d$1}from'./chunk-LLVBXPQN.mjs';import {a as a$3}from'./chunk-PVMVWPLG.mjs';import {a as a$4}from'./chunk-HPF6K6WO.mjs';import {b as b$1}from'./chunk-EMRPZYLU.mjs';import {a as a$2}from'./chunk-MBKCCWSD.mjs';import {a as a$5}from'./chunk-OJJZ7CLB.mjs';import {a}from'./chunk-TMH7HIJ2.mjs';import {d}from'./chunk-R3RSOZXN.mjs';import {b}from'./chunk-ICCM7US5.mjs';import {a as a$1}from'./chunk-2VCW5RWI.mjs';import {readFile}from'fs/promises';import {join}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var E=a(4);async function X(n,i={}){let a=new a$2,e=await a$3(n,{runScripts:i.runScripts,force:i.force});if(e.skipped){b.info("No changes to push");return}let t=await b$1(e.name,e.version);if(!t){a$4(`Failed to read store entry for ${e.name}@${e.version} after publish`);return}let r=await j(e.name);if(r.length===0){b.success(`Published ${e.name}@${e.version} to store`),b.info("No consumers registered yet. Run 'plunk add "+e.name+"' in a consumer project to start receiving pushes."),a$5({name:e.name,version:e.version,buildId:e.buildId,consumers:0,failedConsumers:0,copied:0,skipped:0,elapsed:a.elapsedMs()});return}let d$2=0,o=0,l=0,b$2=0,N=await Promise.all(r.map(c=>E(async()=>{let f$1=await f(c,e.name);if(!f$1)return d(`[push] No link found for ${e.name} in ${c}, skipping`),null;try{let m=await a$6(t,c,f$1.packageManager,{force:i.force});return await d$1(c,e.name,{...f$1,contentHash:t.meta.contentHash,linkedAt:new Date().toISOString(),buildId:t.meta.buildId??""}),m}catch(m){return b.warn(`Failed to push to ${c}: ${m instanceof Error?m.message:String(m)}`),null}})));for(let c of N)c?(d$2+=c.copied,o+=c.skipped,l++):b$2++;let M=e.buildId?` [${e.buildId}]`:"";b.success(`Pushed ${e.name}@${e.version}${M} to ${l} consumer(s) in ${a.elapsed()} (${d$2} files changed, ${o} unchanged)`),a$5({name:e.name,version:e.version,buildId:e.buildId,consumers:l,failedConsumers:b$2,copied:d$2,skipped:o,elapsed:a.elapsedMs()});}a$1(X,"doPush");function W(n){if(!n)return;let i=parseInt(n,10);return Number.isFinite(i)?i:void 0}a$1(W,"parseMs");async function Y(n,i,a){let{startWatcher:e}=await import('./watcher-J4T66EOT.mjs'),{buildCmd:t,patterns:r}=await F(n,i),d=await e(n,{patterns:r,buildCmd:t,debounce:W(i.debounce),cooldown:W(i.cooldown)},a);await new Promise(o=>{let l=a$1(async()=>{b.info("Stopping watcher..."),await d.close(),o();},"cleanup");process.once("SIGINT",l),process.once("SIGTERM",l);});}a$1(Y,"startWatchMode");async function F(n,i){let a=i.build,e;if(!i.build){if(!i["skip-build"]){let t=await a$7(n),r=await a$8(n,t);r&&(a=r,b.info(`Auto-detected build command: ${r}`));}}if(a){let{exists:t}=await import('./fs-BUNURH4P.mjs'),r=["src","lib","source","app","pages","components"],d$1=(await Promise.all(r.map(async o=>({dir:o,exists:await t(join(n,o))})))).filter(o=>o.exists).map(o=>o.dir);e=d$1.length>0?d$1:["src","lib"],d(`[watch] Using source patterns with build command: ${e.join(", ")}`);}else {b.info("No build command detected \u2014 watching output directories directly");try{let t=JSON.parse(await readFile(join(n,"package.json"),"utf-8"));t.files&&t.files.length>0?(e=t.files,b.info(`Watching from package.json "files": ${e.join(", ")}`)):b.warn('No "files" field in package.json \u2014 falling back to watching src/ and lib/. Add a "files" field or use --build to specify a build command.');}catch(t){d(`[watch] Could not read package.json: ${t instanceof Error?t.message:String(t)}`);}}return {buildCmd:a,patterns:e}}a$1(F,"resolveWatchConfig");export{X as a,Y as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {g,m,f,a as a$1,c as c$1,d,e}from'./chunk-22YCXJTS.mjs';import {c,k,h}from'./chunk-TMH7HIJ2.mjs';import {b}from'./chunk-ICCM7US5.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile,readdir}from'fs/promises';import'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
async function y(t,r){let s=g(t,r);try{let a=await readFile(s,"utf-8"),e=JSON.parse(a);return m(e)?e:(b.warn(`Invalid metadata for ${t}@${r}, ignoring`),null)}catch(a){return c(a)&&a.code!=="ENOENT"&&b.warn(`Failed to read metadata for ${t}@${r}: ${a instanceof Error?a.message:String(a)}`),null}}a(y,"readMeta");async function A(t,r){let s=f(t,r),a=await y(t,r);return !a||!await k(s)?null:{name:t,version:r,packageDir:s,meta:a}}a(A,"getStoreEntry");async function J(t){let r=a$1();if(!await k(r))return null;let s=c$1(t)+"@",e=(await readdir(r,{withFileTypes:true})).filter(n=>n.isDirectory()&&n.name.startsWith(s)),u=(await Promise.all(e.map(async n=>{let i=n.name.slice(s.length),c=await y(t,i);return c?{name:t,version:i,packageDir:f(t,i),meta:c}:null}))).filter(n=>n!==null);return u.length===0?null:u.reduce((n,i)=>new Date(i.meta.publishedAt).getTime()>new Date(n.meta.publishedAt).getTime()?i:n)}a(J,"findStoreEntry");async function W(){let t=a$1();if(!await k(t))return [];let s=(await readdir(t,{withFileTypes:true})).filter(e=>e.isDirectory()?e.name.lastIndexOf("@")>0:false);return (await Promise.all(s.map(async e=>{let l=e.name.lastIndexOf("@"),u=e.name.slice(0,l),n=e.name.slice(l+1),i=d(u),c=await y(i,n);return c?{name:i,version:n,packageDir:f(i,n),meta:c}:null}))).filter(e=>e!==null)}a(W,"listStoreEntries");async function q(t,r){await h(e(t,r));}a(q,"removeStoreEntry");export{y as a,A as b,J as c,W as d,q as e};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {l}from'./chunk-TMH7HIJ2.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile}from'fs/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
function m(e){return e.match(/^(\s+)\S/m)?.[1]||" "}a(m,"detectIndent");function p(e){let n=[],t=/['"]([^'"]*)['"]/g,r;for(;(r=t.exec(e))!==null;)n.push(r[1]);return n}a(p,"parseArrayItems");function x(e,n){return e.length===0?"[]":e.length<=3?`[${e.map(r=>`'${r}'`).join(", ")}]`:`[
|
|
4
|
+
${e.map(r=>`${n}${n}'${r}',`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
${n}]`}a(x,"formatArray");async function w(e,n){let t;try{t=await readFile(e,"utf-8");}catch{return {modified:false,error:"could not read config file"}}let r=m(t),a=/transpilePackages\s*:\s*\[([^\]]*)\]/s,c=a.exec(t);if(c){let i=p(c[1]);if(i.includes(n))return {modified:false};i.push(n);let l$1=x(i,r),d=t.replace(a,`transpilePackages: ${l$1}`);return await l(e,d),{modified:true}}let s=/(?:module\.exports\s*=\s*\{|export\s+default\s+\{|nextConfig\s*=\s*\{)/.exec(t);if(s){let i=s.index+s[0].length,l$1=`
|
|
7
|
+
${r}transpilePackages: ['${n}'],`,d=t.slice(0,i)+l$1+t.slice(i);return await l(e,d),{modified:true}}return {modified:false,error:"unrecognized config pattern"}}a(w,"addToTranspilePackages");async function y(e,n){let t;try{t=await readFile(e,"utf-8");}catch{return {modified:false}}let r=m(t),a=/transpilePackages\s*:\s*\[([^\]]*)\]/s,c=a.exec(t);if(!c)return {modified:false};let g=p(c[1]),s=g.filter(d=>d!==n);if(s.length===g.length)return {modified:false};let i=x(s,r),l$1=t.replace(a,`transpilePackages: ${i}`);return await l(e,l$1),{modified:true}}a(y,"removeFromTranspilePackages");export{w as a,y as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a,b}from'./chunk-ICCM7US5.mjs';import {c as c$1,a as a$1}from'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var s=c$1(a(),1);var p=[{pattern:/not found in store/i,message:"Run 'plunk publish' in the package directory first, or use --from <path>."},{pattern:/is not linked/i,message:"Run 'plunk add <package>' to link it first."},{pattern:/No package\.json/i,message:"Make sure you're in a valid package directory with a package.json."},{pattern:/missing 'name'/i,message:"Add a 'name' field to your package.json."},{pattern:/missing 'version'/i,message:"Add a 'version' field to your package.json."},{pattern:/store entry missing/i,message:"Re-publish the package with 'plunk publish'."},{pattern:/EACCES|EPERM/i,message:"Permission denied. Try running with elevated privileges or check file ownership."},{pattern:/ENOSPC/i,message:"Disk is full. Free up some space and try again."},{pattern:/No publishable files/i,message:"Check the 'files' field in package.json, or ensure the build output exists."},{pattern:/private.*package/i,message:"Use --private flag to publish private packages."},{pattern:/Failed to read store entry/i,message:"The store may be corrupted. Try 'plunk clean' then re-publish."},{pattern:/Failed to acquire lock/i,message:"Another plunk process may be running. Wait or delete stale .lk directories."},{pattern:/not a directory/i,message:"Check that the path exists and is a directory."},{pattern:/timed out/i,message:"Set PLUNK_HOOK_TIMEOUT to a higher value (in ms) if your scripts need more time."},{pattern:/state.*corrupt|corrupt.*state/i,message:"Delete .plunk/state.json and re-run 'plunk add' for each package."},{pattern:/EBUSY/i,message:"A file is locked by another process (e.g. dev server). Stop the process and retry."},{pattern:/Invalid package name/i,message:"Package names must be non-empty. Use format: package-name or @scope/package-name."}];function c(t){b.error(t);for(let{pattern:i,message:r}of p)if(i.test(t)){b.info(`${s.default.dim("Suggestion:")} ${r}`);break}}a$1(c,"errorWithSuggestion");export{c as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b,a,c}from'./chunk-2VCW5RWI.mjs';import {createInterface}from'readline/promises';import {stdout,stdin}from'process';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var f=b((v,g)=>{var s=process||{},c=s.argv||[],x=s.env||{},y=!(x.NO_COLOR||c.includes("--no-color"))&&(!!x.FORCE_COLOR||c.includes("--color")||s.platform==="win32"||(s.stdout||{}).isTTY&&x.TERM!=="dumb"||!!x.CI),w=a((e,t,o=e)=>b=>{let i=""+b,n=i.indexOf(t,e.length);return ~n?e+O(i,t,o,n)+t:e+i+t},"formatter"),O=a((e,t,o,b)=>{let i="",n=0;do i+=e.substring(n,b)+o,n=b+t.length,b=e.indexOf(t,n);while(~b);return i+e.substring(n)},"replaceClose"),u=a((e=y)=>{let t=e?w:()=>String;return {isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}},"createColors");g.exports=u();g.exports.createColors=u;});var r=c(f(),1);var m=3;async function k(e,t){let o=createInterface({input:stdin,output:stdout});try{if(t.type==="confirm"){let n=t.initial!==!1?"Y/n":"y/N",a=(await o.question(`${r.default.cyan("?")} ${e} ${r.default.dim(`(${n})`)} `)).trim().toLowerCase();return a===""?t.initial!==!1:a==="y"||a==="yes"}if(t.type==="text"){let n=t.default?r.default.dim(` (${t.default})`):"";return (await o.question(`${r.default.cyan("?")} ${e}${n} `)).trim()||t.default||""}console.log(`${r.default.cyan("?")} ${e}`);for(let n=0;n<t.options.length;n++)console.log(` ${r.default.cyan(`${n+1}.`)} ${t.options[n].label}`);let b=await o.question(`${r.default.dim("Enter number:")} `),i=parseInt(b,10)-1;return i>=0&&i<t.options.length?t.options[i].value:t.options[0].value}finally{o.close();}}a(k,"prompt");var T={get level(){return m},set level(e){m=e;},info(e,...t){m>=3&&console.log(r.default.cyan("\u2139"),e,...t);},success(e,...t){m>=3&&console.log(r.default.green("\u2714"),e,...t);},warn(e,...t){m>=2&&console.warn(r.default.yellow("\u26A0"),e,...t);},error(e,...t){m>=1&&console.error(r.default.red("\u2716"),e,...t);},start(e,...t){m>=3&&console.log(r.default.cyan("\u25D0"),e,...t);},debug(e,...t){m>=4&&console.debug(r.default.dim("D"),e,...t);},log(e,...t){m>=3&&console.log(e,...t);},prompt:k};export{f as a,T as b};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {e,b as b$1}from'./chunk-AC5FETT7.mjs';import {j,k as k$1}from'./chunk-22YCXJTS.mjs';import {c,k,h,i,f,m}from'./chunk-TMH7HIJ2.mjs';import {d}from'./chunk-R3RSOZXN.mjs';import {b}from'./chunk-ICCM7US5.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {mkdir,writeFile,rm,symlink,chmod,readdir,stat,realpath,readFile}from'fs/promises';import {join,resolve,sep,relative}from'path';import {platform}from'os';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
function J(e){return e.bin?typeof e.bin=="string"?{[e.name.startsWith("@")?e.name.split("/")[1]:e.name]:e.bin}:e.bin:{}}a(J,"resolveBinEntries");async function L(e,t,i){let r=J(i);if(Object.keys(r).length===0)return 0;let n=join(e,"node_modules",".bin");await mkdir(n,{recursive:true});let c$1=platform()==="win32",a=0;for(let[o,g]of Object.entries(r)){let p=join(e,"node_modules",t),l=join(p,g),B=resolve(l);if(!B.startsWith(resolve(p)+sep)&&B!==resolve(p)){b.warn(`bin "${o}" points outside package directory, skipping`);continue}let h=relative(n,l).replace(/\\/g,"/");if(c$1){let w=join(n,`${o}.cmd`),j=`@ECHO off\r
|
|
4
|
+
GOTO start\r
|
|
5
|
+
:find_dp0\r
|
|
6
|
+
SET dp0=%~dp0\r
|
|
7
|
+
EXIT /b\r
|
|
8
|
+
:start\r
|
|
9
|
+
CALL :find_dp0\r
|
|
10
|
+
"%dp0%\\${h.replace(/\//g,"\\")}" %*\r
|
|
11
|
+
`;await writeFile(w,j);let G=join(n,o),X=`#!/bin/sh
|
|
12
|
+
exec node "${h}" "$@"
|
|
13
|
+
`;await writeFile(G,X);}else {let w=join(n,o);try{await rm(w,{force:!0});}catch{}try{await symlink(h,w),await chmod(l,493);}catch(b){if(c(b)&&(b.code==="EPERM"||b.code==="EACCES")){d(`[bin-linker] Symlink failed (${b.code}), using shell wrapper for ${o}`);let j=`#!/bin/sh
|
|
14
|
+
exec node "${h}" "$@"
|
|
15
|
+
`;await writeFile(w,j),await chmod(w,493);}else throw b}}a++;}return a}a(L,"createBinLinks");async function W(e,t){let i=J(t),r=join(e,"node_modules",".bin"),n=platform()==="win32";for(let c of Object.keys(i))try{await rm(join(r,c),{force:!0}),n&&await rm(join(r,`${c}.cmd`),{force:!0});}catch{}}a(W,"removeBinLinks");var U={vite:["node_modules/.vite"],next:[".next/cache"],webpack:["node_modules/.cache"]},A=new Map;async function F(e$1){let t=A.get(e$1);t||(t=await e(e$1),A.set(e$1,t));for(let i of t){if(!i.type)continue;let r=U[i.type];if(r)for(let n of r){let c=join(e$1,n);if(await k(c))try{await h(c),d(`[inject] Invalidated ${i.type} cache: ${n}`);}catch{d(`[inject] Could not clear ${i.type} cache: ${n} (locked?)`);}}}}a(F,"invalidateBundlerCache");async function Ee(e,t,i$1,r={}){let n=await $(t,e.name,i$1,e.version);d(`[inject] ${e.name}@${e.version} \u2192 ${n}`),await i(n);let{copied:c,removed:a,skipped:o}=await f(e.packageDir,n,{force:r.force});d(`[inject] ${c} copied, ${a} removed, ${o} skipped`),(c>0||a>0)&&await F(t);let g=await O(e.packageDir),p=g?await L(t,e.name,g):0;return p>0&&d(`[inject] Created ${p} bin link(s)`),{copied:c,removed:a,skipped:o,binLinks:p}}a(Ee,"inject");async function Ce(e,t,i){let r=await $(e,t,i);if(!await k(r))return false;let n=j(e,t);return await h(n),await m(r,n),true}a(Ce,"backupExisting");async function Oe(e,t,i){let r=j(e,t);if(!await k(r))return false;let n=await $(e,t,i);return await h(n),await m(r,n),await h(r),true}a(Oe,"restoreBackup");async function Be(e,t,i){let r=await $(e,t,i),n=await O(r);n&&await W(e,n),await h(r);}a(Be,"removeInjected");async function _e(e,t){let i=await O(e.packageDir);if(!i)return [];let r={...i.dependencies,...Object.fromEntries(Object.entries(i.peerDependencies??{}).filter(([a])=>!i.peerDependenciesMeta?.[a]?.optional))};if(Object.keys(r).length===0)return [];let n=Object.keys(r);return (await Promise.all(n.map(async a=>({dep:a,installed:await k(join(t,"node_modules",a))})))).filter(a=>!a.installed).map(a=>a.dep)}a(_e,"checkMissingDeps");async function $(e,t,i,r){let n=k$1(e,t);if(!(i==="pnpm"||i==="yarn"&&await b$1(e)==="pnpm"))return n;try{let o=await ne(n);if(o!==resolve(n))return d(`[inject] pnpm: resolved symlink \u2192 ${o}`),o}catch(o){c(o)&&o.code!=="ENOENT"&&b.debug(`pnpm symlink resolution error: ${o instanceof Error?o.message:String(o)}`);}let a=join(e,"node_modules",".pnpm");if(await k(a)){d(`[inject] pnpm: scanning .pnpm/ for ${t}`);let o=t.replaceAll("/","+");if(r){let p=`${o}@${r}`,l=join(a,p,"node_modules",t);if(await k(l))return d(`[inject] pnpm: exact version match in .pnpm/ \u2192 ${l}`),l}let g=await readdir(a);for(let p of g)if(p.startsWith(o+"@")){let l=join(a,p,"node_modules",t);if(await k(l))return d(`[inject] pnpm: found in .pnpm/ \u2192 ${l}`),l}}return b.warn(`pnpm: Could not find ${t} in .pnpm/ virtual store, using direct node_modules path. If this causes issues, run 'pnpm install' to rebuild the virtual store, then 'plunk add' again.`),n}a($,"resolveTargetDir");async function ne(e){try{return await stat(e),await realpath(e)}catch(t){if(c(t)&&t.code==="ENOENT")return resolve(e);throw t}}a(ne,"resolveRealPath");async function O(e){try{let t=await readFile(join(e,"package.json"),"utf-8");return JSON.parse(t)}catch(t){return c(t)&&t.code!=="ENOENT"&&b.warn(`Failed to read package.json in ${e}: ${t instanceof Error?t.message:String(t)}`),null}}a(O,"readPackageJson");export{Ee as a,Ce as b,Oe as c,Be as d,_e as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {i,n,h,l as l$1,b as b$2,o}from'./chunk-22YCXJTS.mjs';import {c,i as i$1,l,j,k}from'./chunk-TMH7HIJ2.mjs';import {b as b$1}from'./chunk-ICCM7US5.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile}from'fs/promises';import {dirname}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
async function O(t){let{state:e}=await w(t);return e}a(O,"readConsumerState");async function w(t){let e=i(t);try{let r=await readFile(e,"utf-8"),s=JSON.parse(r);return n(s)?{state:s,reliable:!0}:(b$1.warn(`Invalid consumer state in ${e}, using defaults`),{state:{version:"1",links:{}},reliable:!1})}catch(r){return c(r)&&r.code==="ENOENT"?{state:{version:"1",links:{}},reliable:true}:(b$1.warn(`Failed to read consumer state: ${r instanceof Error?r.message:String(r)}`),{state:{version:"1",links:{}},reliable:false})}}a(w,"readConsumerStateSafe");async function b(t,e){await i$1(h(t));let r=i(t);await l(r,JSON.stringify(e,null,2));}a(b,"writeConsumerState");async function I(t,e,r){let s=i(t);await l$1(s,async()=>{let{state:i,reliable:c}=await w(t);if(!c)throw new Error(`Consumer state in ${s} is corrupt \u2014 refusing to write to avoid destroying existing links. Delete .plunk/state.json and re-run 'plunk add' for each package.`);i.links[e]=r,await b(t,i);});}a(I,"addLink");async function T(t,e){let r=i(t);await l$1(r,async()=>{let{state:s,reliable:i}=await w(t);if(!i)throw new Error(`Consumer state in ${r} is corrupt \u2014 refusing to write to avoid destroying existing links. Delete .plunk/state.json and re-run 'plunk add' for each package.`);delete s.links[e],await b(t,s);});}a(T,"removeLink");async function M(t,e){return (await O(t)).links[e]??null}a(M,"getLink");async function g(){let t=b$2();try{let e=await readFile(t,"utf-8"),r=JSON.parse(e);return o(r)?r:(b$1.warn("Invalid consumers registry, using empty registry"),{})}catch(e){return c(e)&&e.code!=="ENOENT"&&b$1.warn(`Failed to read consumers registry: ${e instanceof Error?e.message:String(e)}`),{}}}a(g,"readConsumersRegistry");async function p(t){let e=b$2();await j(dirname(b$2())),await l(e,JSON.stringify(t,null,2));}a(p,"writeConsumersRegistry");async function W(t,e){let r=b$2();await l$1(r,async()=>{let s=await g();s[t]||(s[t]=[]);let i=e.replace(/\\/g,"/");s[t].includes(i)||s[t].push(i),await p(s);});}a(W,"registerConsumer");async function q(t,e){let r=b$2();await l$1(r,async()=>{let s=await g();if(!s[t])return;let i=e.replace(/\\/g,"/");s[t]=s[t].filter(c=>c!==i),s[t].length===0&&delete s[t],await p(s);});}a(q,"unregisterConsumer");async function A(t){return (await g())[t]??[]}a(A,"getConsumers");async function B(){let t=b$2(),e=0,r=0;return await l$1(t,async()=>{let s=await g(),i={};for(let[c,C]of Object.entries(s)){let d=(await Promise.all(C.map(async a=>({consumerPath:a,valid:await k(a)})))).filter(a=>a.valid).map(a=>a.consumerPath);e+=C.length-d.length,d.length>0?i[c]=d:r++;}await p(i);}),{removedConsumers:e,removedPackages:r}}a(B,"cleanStaleConsumers");export{O as a,w as b,b as c,I as d,T as e,M as f,g,W as h,q as i,A as j,B as k};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {c}from'./chunk-R3RSOZXN.mjs';import {b}from'./chunk-ICCM7US5.mjs';import {a}from'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
function r(u){c()&&console.log(JSON.stringify(u,null,2));}a(r,"output");function s(){c()&&(b.level=-1);}a(s,"suppressHumanOutput");export{r as a,s as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$3}from'./chunk-EMRPZYLU.mjs';import {e,l}from'./chunk-22YCXJTS.mjs';import {a}from'./chunk-HW7AEGI3.mjs';import {a as a$2,c as c$1,b as b$1,j,i,d as d$1,k as k$1,g,h}from'./chunk-TMH7HIJ2.mjs';import {d}from'./chunk-R3RSOZXN.mjs';import {b}from'./chunk-ICCM7US5.mjs';import {c,a as a$1}from'./chunk-2VCW5RWI.mjs';import {stat,readFile,readdir,writeFile,rename}from'fs/promises';import {resolve,join,relative,sep,dirname}from'path';import {spawn}from'child_process';import {availableParallelism,platform}from'os';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var P=c(a(),1);async function z(s,n){let o=[],t=resolve(s);o.push(join(t,"package.json"));let e=await Q(t,t),r=e.map(a=>relative(t,a).replace(/\\/g,"/"));if(n.files&&n.files.length>0)for(let a of n.files){let i=join(t,a),u=resolve(i);if(!u.startsWith(t+sep)&&u!==t){b.warn(`files pattern "${a}" escapes package directory, skipping`);continue}let l=false;try{if((await stat(i)).isDirectory()){let w=relative(t,i).replace(/\\/g,"/")+"/";for(let f=0;f<r.length;f++)r[f].startsWith(w)&&o.push(e[f]);l=!0;}else o.push(i),l=!0;}catch(g){if(c$1(g)&&g.code!=="ENOENT")throw g}if(!l){let g=(0, P.default)(a,{dot:true}),w=0;for(let f=0;f<r.length;f++)if(g(r[f])){let E=resolve(e[f]);if(!E.startsWith(t+sep)&&E!==t)continue;o.push(e[f]),w++;}w===0&&b.warn(`files pattern "${a}" matched no files`);}}else {let a=await ce(t);for(let i=0;i<r.length;i++)le(r[i],a)||o.push(e[i]);}let p=new Set(o),c=new Set(e);for(let a of ["README.md","README","LICENSE","LICENCE","CHANGELOG.md"]){let i=join(t,a);p.has(i)||c.has(i)&&(o.push(i),p.add(i));}return [...p]}a$1(z,"resolvePackFiles");var ae=new Set(["node_modules",".git",".svn",".hg",".DS_Store",".npmrc",".plunk","test","tests","__tests__",".github",".vscode",".idea","coverage",".nyc_output","tsconfig.json","tsconfig.build.json",".eslintrc",".eslintrc.js",".eslintrc.json",".prettierrc",".prettierrc.js","jest.config.js","jest.config.ts","vitest.config.ts","vitest.config.js"]);function le(s,n){for(let t of n.negations)if(t(s))return false;let o=s.split(/[\\/]/);for(let t of o)if(ae.has(t)||n.literals.has(t))return true;if(n.literals.has(s))return true;for(let t of n.patterns)if(t(s))return true;return false}a$1(le,"shouldIgnore");async function ce(s){let n={literals:new Set,patterns:[],negations:[]};try{let o=await readFile(join(s,".npmignore"),"utf-8");for(let t of o.split(`
|
|
4
|
+
`)){let e=t.trim();if(!(!e||e.startsWith("#")))if(e.startsWith("!")){let r=e.slice(1);B(r)?n.negations.push((0,P.default)(r,{dot:!0})):n.negations.push((0,P.default)(r,{dot:!0}));}else B(e)?n.patterns.push((0,P.default)(e,{dot:!0})):n.literals.add(e.replace(/\/$/,""));}}catch(o){if(c$1(o)&&o.code!=="ENOENT")throw o}return n}a$1(ce,"loadNpmIgnore");function B(s){return /[*?[\]{}()]/.test(s)}a$1(B,"hasGlobChars");async function Q(s,n){let o=[];try{let t=await readdir(s,{withFileTypes:!0});for(let e of t){let r=join(s,e.name);if(e.isDirectory()){if(e.name===".git"||s===n&&e.name==="node_modules"||e.isSymbolicLink())continue;o.push(...await Q(r,n));}else e.isSymbolicLink()||o.push(r);}}catch(t){if(c$1(t)&&t.code==="ENOENT")return [];throw t}return o}a$1(Q,"collectAllFiles");var he=a$2(Math.max(availableParallelism(),8));async function Ke(s,n={}){let o=join(s,"package.json"),t;try{t=await readFile(o,"utf-8");}catch{throw new Error(`No package.json found in ${s}`)}let e$1=JSON.parse(t);if(!e$1.name)throw new Error("package.json missing 'name' field");if(!e$1.version)throw new Error("package.json missing 'version' field");if(e$1.private&&!n.allowPrivate)throw new Error(`Package "${e$1.name}" is private. Use --private flag to publish private packages.`);await S(s,e$1,"preplunk"),n.runScripts!==false&&await S(s,e$1,"prepack");let r=s;if(e$1.publishConfig?.directory){r=resolve(s,e$1.publishConfig.directory);try{if(!(await stat(r)).isDirectory())throw new Error(`publishConfig.directory "${e$1.publishConfig.directory}" is not a directory`)}catch(l){throw l instanceof Error&&"code"in l&&l.code==="ENOENT"?new Error(`publishConfig.directory "${e$1.publishConfig.directory}" does not exist`):l}d(`[publish] Using publishConfig.directory: ${r}`);}let p=r!==s?JSON.parse(await readFile(join(r,"package.json"),"utf-8").catch(()=>JSON.stringify(e$1))):e$1,c=await z(r,p);if(c.length===0)throw new Error("No publishable files found");d(`[publish] Resolved ${c.length} files for ${e$1.name}@${e$1.version}`);let a=await b$1(c,r);if(await Pe(e$1,s),await Ee(e$1,s),!n.force){let l=await a$3(e$1.name,e$1.version);if(l&&l.contentHash===a)return b.info(`${e$1.name}@${e$1.version} already up to date (no changes since last publish)`),{name:e$1.name,version:e$1.version,fileCount:c.length,skipped:true,contentHash:a,buildId:l.buildId??""}}let i$1=e(e$1.name,e$1.version),u=await l(i$1+".lock",async()=>{if(!n.force){let f=await a$3(e$1.name,e$1.version);if(f&&f.contentHash===a)return b.info(`${e$1.name}@${e$1.version} already up to date (no changes since last publish)`),{name:e$1.name,version:e$1.version,fileCount:c.length,skipped:true,contentHash:a,buildId:f.buildId??""}}let l=i$1+`.tmp-${process.pid}-${Date.now()}`,g$1=join(l,"package"),w=a.slice(9,17);try{await j(g$1);let f=ve(e$1);f=be(f),d("[publish] Copying files to temp store...");let E=new Set(c.map(v=>dirname(join(g$1,relative(r,v)))));await Promise.all([...E].map(v=>i(v))),await Promise.all(c.map(v=>he(async()=>{let _=relative(r,v),D=join(g$1,_);_==="package.json"&&f!==e$1?await writeFile(D,JSON.stringify(f,null,2)):await d$1(v,D,{ensureParent:!1});}))),r!==s&&await writeFile(join(g$1,"package.json"),JSON.stringify(f,null,2));let te={schemaVersion:1,contentHash:a,publishedAt:new Date().toISOString(),sourcePath:s,buildId:w};await writeFile(join(l,".plunk-meta.json"),JSON.stringify(te,null,2));let W=await k$1(i$1),R=i$1+".old-"+Date.now();W&&await rename(i$1,R),await g(l,i$1),W&&await h(R),d(`[publish] Stored at ${i$1}`);}catch(f){throw await h(l),f}return {name:e$1.name,version:e$1.version,fileCount:c.length,skipped:false,contentHash:a,buildId:w}},{stale:6e4});return u.skipped||(n.runScripts!==false&&await S(s,e$1,"postpack"),await S(s,e$1,"postplunk"),b.success(`Published ${e$1.name}@${e$1.version} (${c.length} files) [${u.buildId}]`)),u}a$1(Ke,"publish");var Y=parseInt(process.env.PLUNK_HOOK_TIMEOUT??"30000",10);async function S(s,n,o){let t=n.scripts?.[o];if(t)return d(`[lifecycle] Running ${o}: ${t}`),new Promise((e,r)=>{let p=platform()==="win32",i=spawn(p?"cmd":"sh",[p?"/c":"-c",t],{cwd:s,stdio:"inherit"}),u=setTimeout(()=>{i.kill("SIGTERM"),r(new Error(`${o} script timed out after ${Y/1e3}s. Increase PLUNK_HOOK_TIMEOUT env var if the script needs more time.`));},Y);i.on("close",l=>{clearTimeout(u),l===0?e():r(new Error(`${o} script failed with exit code ${l}`));}),i.on("error",l=>{clearTimeout(u),r(new Error(`${o} script error: ${l.message}`));});})}a$1(S,"runLifecycleHook");var we=["main","module","exports","types","typings","browser","bin"];function be(s){if(!s.publishConfig)return s;let n={...s};for(let o of we)o in s.publishConfig&&(n[o]=s.publishConfig[o]);return delete n.publishConfig,n}a$1(be,"applyPublishConfig");function ve(s){let n=false,o={...s},t=null,e=false;for(let r of ["dependencies","devDependencies","peerDependencies","optionalDependencies"]){let p=s[r];if(!p)continue;let c=false,a={...p};for(let[i,u]of Object.entries(p))if(u.startsWith("workspace:")){let l=u.slice(10);if(l==="*"||l==="^"||l==="~"){let g=$?.versions.get(i)??s.version;a[i]=l==="*"?g:l+g;}else a[i]=l;c=true,n=true;}else if(u.startsWith("catalog:"))if(e||(t=ke(),e=true),t){let l=ye(u,i,t);l?(a[i]=l,c=true,n=true):b.warn(`catalog: specifier for "${i}" could not be resolved \u2014 published package.json will contain "${u}" which may cause install failures`);}else d(`[publish] No pnpm-workspace.yaml found, cannot resolve catalog: for "${i}"`);c&&(o[r]=a);}return n?o:s}a$1(ve,"rewriteProtocolVersions");function ye(s,n,o){let t=s.slice(8);return t===""||t==="default"?o.default[n]??null:o.named[t]?.[n]??null}a$1(ye,"resolveCatalogVersion");var N=null;async function ee(s){if(N?.dir===s)return N.root;let{findWorkspaceRoot:n}=await import('./workspace-SKJJQMMK.mjs'),o=await n(s);return N={dir:s,root:o},o}a$1(ee,"getWorkspaceRoot");var $=null;async function Pe(s,n){if(!["dependencies","devDependencies","peerDependencies","optionalDependencies"].some(c=>{let a=s[c];return a&&Object.values(a).some(i=>i.startsWith("workspace:"))}))return;let t=await ee(n);if(!t){$=null;return}if($?.root===t)return;let{findWorkspacePackages:e}=await import('./workspace-SKJJQMMK.mjs'),r=await e(t),p=new Map;await Promise.all(r.map(async c=>{try{let a=JSON.parse(await readFile(join(c,"package.json"),"utf-8"));a.name&&a.version&&p.set(a.name,a.version);}catch{}})),$={root:t,versions:p};}a$1(Pe,"preloadWorkspaceVersions");var k=null;function ke(){return k?.catalogs??null}a$1(ke,"loadCatalogsFromCache");async function Ee(s,n){if(!["dependencies","devDependencies","peerDependencies","optionalDependencies"].some(a=>{let i=s[a];return i&&Object.values(i).some(u=>u.startsWith("catalog:"))}))return;let t=await ee(n);if(!t){k=null;return}let e=join(t,"pnpm-workspace.yaml"),r=(await stat(e).catch(()=>null))?.mtimeMs??0;if(k?.root===t&&k.mtimeMs===r)return;let{parseCatalogs:p}=await import('./workspace-SKJJQMMK.mjs'),c=await p(t);k={root:t,mtimeMs:r,catalogs:c};}a$1(Ee,"preloadCatalogs");export{Ke as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b}from'./chunk-ICCM7US5.mjs';import {a as a$1}from'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var n=false,r=false,s=false;function l(){n=process.argv.includes("--verbose")||process.argv.includes("-v"),r=process.argv.includes("--dry-run"),s=process.argv.includes("--json"),n&&(b.level=4);}a$1(l,"initFlags");function c(){return r}a$1(c,"isDryRun");function a(){return s}a$1(a,"isJsonOutput");function p(t,...u){n&&b.debug(t,...u);}a$1(p,"verbose");export{l as a,c as b,a as c,p as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {d,b as b$1}from'./chunk-R3RSOZXN.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {stat,readFile,mkdir,copyFile,constants,readdir,utimes,rm,rename,cp,writeFile}from'fs/promises';import {relative,parse,dirname,join}from'path';import {availableParallelism}from'os';import {createHash}from'crypto';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
function y(e){let t=0,r=[],s=a(()=>{r.length>0&&t<e&&(t++,r.shift()());},"next");return l=>new Promise((w,p)=>{let h=a(()=>{l().then(o=>{t--,w(o),s();},o=>{t--,p(o),s();});},"run");t<e?(t++,h()):r.push(h);})}a(y,"pLimit");var P=null;function D(){return P||(P=import('./xxhash-wasm-DTW44IIQ.mjs').then(e=>e.default()).catch(e=>{throw P=null,e})),P}a(D,"getXXHash");var W=1024*1024,Y=y(Math.max(availableParallelism(),8)),v=new Map;async function ce(e,t){let r=[...e].sort((i,m)=>{let a=relative(t,i).replace(/\\/g,"/"),f=relative(t,m).replace(/\\/g,"/");return a.localeCompare(f)}),s=new Set(r),l=0,w=await Promise.all(r.map(i=>Y(async()=>{let m=relative(t,i).replace(/\\/g,"/"),a=await stat(i),f=v.get(i);if(f&&f.mtimeMs===a.mtimeMs&&f.size===a.size)return l++,{rel:m,content:f.content};let c=await readFile(i);return v.set(i,{mtimeMs:a.mtimeMs,size:a.size,content:c}),{rel:m,content:c}})));for(let i of v.keys())s.has(i)||v.delete(i);d(`[hash] Computing content hash for ${e.length} files (${l} cached)`);let p=createHash("sha256"),h=Buffer.alloc(4);for(let{rel:i,content:m}of w)p.update(i),p.update("\0"),h.writeUInt32LE(m.length),p.update(h),p.update(m);let o="sha256v2:"+p.digest("hex");return d(`[hash] Result: ${o.slice(0,20)}...`),o}a(ce,"computeContentHash");async function z(e,t){let r=t??(await stat(e)).size,s=await D();if(r>W)return j(e,s);let l=await readFile(e);return s.h64Raw(l).toString(16)}a(z,"hashFile");async function j(e,t){let{createReadStream:r}=await import('fs'),s=t.create64();return new Promise((l,w)=>{let p=r(e);p.on("data",h=>s.update(h)),p.on("end",()=>l(s.digest().toString(16))),p.on("error",w);})}a(j,"hashFileStream");var S=y(Math.max(availableParallelism(),8));function b(e){return e instanceof Error&&"code"in e}a(b,"isNodeError");var F=new Map;function Q(e){let{root:t}=parse(e);return t||"/"}a(Q,"volumeRoot");async function Z(e,t,r){if(b$1()){d(`[dry-run] would copy ${e} \u2192 ${t}`);return}r?.ensureParent!==false&&await mkdir(dirname(t),{recursive:true});let s=Q(t),l=F.get(s);if(l===false){await copyFile(e,t);return}if(l===true){await copyFile(e,t,constants.COPYFILE_FICLONE);return}try{await copyFile(e,t,constants.COPYFILE_FICLONE_FORCE),F.set(s,!0);}catch{F.set(s,false),d(`[copy] reflink not supported on ${s}, using plain copy`),await copyFile(e,t);}}a(Z,"copyWithCoW");async function T(e){return (await readdir(e,{recursive:true,withFileTypes:true})).filter(r=>r.isFile()).map(r=>join(r.parentPath,r.name))}a(T,"collectFiles");async function ge(e,t,r={}){let s=await T(e),l=0,w=0,p=0,h=await Promise.all(s.map(o=>S(async()=>{let i=relative(e,o),m=join(t,i),a=true,f=null;if(r.force)d(`[copy] ${i} (forced)`);else try{let[c,g]=await Promise.all([stat(o),stat(m)]);if(f={atime:c.atime,mtime:c.mtime},c.size!==g.size)d(`[copy] ${i} (size differs: ${c.size} vs ${g.size})`);else if(c.mtimeMs===g.mtimeMs)a=!1,d(`[skip] ${i} (size+mtime match)`);else {let[N,A]=await Promise.all([z(o,c.size),z(m,g.size)]);N===A?(a=!1,d(`[skip] ${i} (unchanged)`)):d(`[copy] ${i} (hash differs)`);}}catch(c){if(b(c)&&c.code==="ENOENT")d(`[copy] ${i} (new file)`);else throw c}if(a){if(await Z(o,m),!f){let c=await stat(o);f={atime:c.atime,mtime:c.mtime};}return await utimes(m,f.atime,f.mtime),"copied"}return "skipped"})));for(let o of h)o==="copied"?l++:p++;try{let o=await T(t),i=new Set(s.map(a=>relative(e,a))),m=o.filter(a=>!i.has(relative(t,a)));await Promise.all(m.map(a=>S(async()=>{d(`[remove] ${relative(t,a)} (no longer in source)`),b$1()||await rm(a);}))),w=m.length;}catch(o){if(!(b(o)&&o.code==="ENOENT"))throw o}return {copied:l,removed:w,skipped:p}}a(ge,"incrementalCopy");async function Pe(e,t){try{await rename(e,t);}catch(r){if(b(r)&&r.code==="EXDEV")await cp(e,t,{recursive:true}),await rm(e,{recursive:true,force:true});else throw r}}a(Pe,"moveDir");async function ve(e){if(b$1()){d(`[dry-run] would remove ${e}`);return}await rm(e,{recursive:true,force:true});}a(ve,"removeDir");async function xe(e){await mkdir(e,{recursive:true});}a(xe,"ensureDir");async function Ee(e){await mkdir(e,{recursive:true,mode:448});}a(Ee,"ensurePrivateDir");async function $e(e){try{return await stat(e),!0}catch{return false}}a($e,"exists");async function Ce(e,t){if(b$1()){d(`[dry-run] would write ${e}`);return}let r=e+`.tmp-${process.pid}-${Date.now()}`;await writeFile(r,t),await rename(r,e);}a(Ce,"atomicWriteFile");async function ze(e,t){await cp(e,t,{recursive:true});}a(ze,"copyDir");export{y as a,ce as b,b as c,Z as d,T as e,ge as f,Pe as g,ve as h,xe as i,Ee as j,$e as k,Ce as l,ze as m};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {k,g,b as b$2}from'./chunk-LLVBXPQN.mjs';import {d as d$1,e}from'./chunk-EMRPZYLU.mjs';import {a}from'./chunk-MBKCCWSD.mjs';import {a as a$1}from'./chunk-22YCXJTS.mjs';import {b,a as a$2}from'./chunk-OJJZ7CLB.mjs';import'./chunk-OL7SNXMX.mjs';import {k as k$1,h}from'./chunk-TMH7HIJ2.mjs';import {d}from'./chunk-R3RSOZXN.mjs';import {b as b$1}from'./chunk-ICCM7US5.mjs';import'./chunk-2VCW5RWI.mjs';import {readdir}from'fs/promises';import {join}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var I={meta:{name:"clean",description:"Remove unreferenced store entries and stale consumer registrations"},async run(){b();let p=new a;b$1.start("Checking consumer registrations...");let{removedConsumers:i,removedPackages:u}=await k();i>0&&b$1.success(`Removed ${i} stale consumer registration(s) across ${u} package(s)`);let g$1=await g(),c=new Set,D=[...new Set(Object.values(g$1).flat())],h$1=await Promise.all(D.map(async t=>{let{state:e,reliable:r}=await b$2(t);return {path:t,state:e,reliable:r}}));for(let{state:t,reliable:e}of h$1)if(e)for(let[r,d]of Object.entries(t.links))c.add(`${r}@${d.version}`);let m=new Set,l=h$1.filter(t=>!t.reliable);if(l.length>0){b$1.warn(`${l.length} consumer(s) have corrupt state \u2014 their store entries will be preserved`);let t=new Set(l.map(e=>e.path.replace(/\\/g,"/")));for(let[e,r]of Object.entries(g$1))r.some(d=>t.has(d))&&m.add(e);d(`[clean] Protected packages (corrupt state): ${[...m].join(", ")}`);}d(`[clean] Referenced entries: ${[...c].join(", ")||"(none)"}`);let O=await d$1(),o=0;for(let t of O){let e$1=`${t.name}@${t.version}`;if(!c.has(e$1)){if(m.has(t.name)){d(`[clean] Preserving ${e$1} (consumer state unreadable)`);continue}let r=Date.now()-new Date(t.meta.publishedAt).getTime();if(r<300*1e3){d(`[clean] Skipping recently published entry: ${e$1} (${Math.round(r/1e3)}s old)`);continue}d(`[clean] Removing unreferenced store entry: ${e$1}`),await e(t.name,t.version),o++;}}o>0&&b$1.success(`Removed ${o} unreferenced store entry(ies)`);let a$3=0,f=a$1();if(await k$1(f)){let t=await readdir(f,{withFileTypes:true});for(let e of t)e.isDirectory()&&(e.name.includes(".tmp-")||e.name.includes(".old-"))&&(d(`[clean] Removing orphaned directory: ${e.name}`),await h(join(f,e.name)),a$3++);a$3>0&&b$1.success(`Removed ${a$3} orphaned temp directory(ies)`);}i===0&&o===0&&a$3===0&&b$1.info("Store is clean \u2014 no stale entries or registrations found"),b$1.info(`Clean complete in ${p.elapsed()}`),a$2({removedConsumers:i,removedPackages:u,removedEntries:o,removedOrphans:a$3,elapsed:p.elapsedMs()});}};export{I as default};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {createRequire}from'node:module';import {a as a$
|
|
3
|
-
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$4}from'./chunk-OL7SNXMX.mjs';import {a as a$3}from'./chunk-R3RSOZXN.mjs';import {a as a$1}from'./chunk-ICCM7US5.mjs';import {c,a as a$2}from'./chunk-2VCW5RWI.mjs';import {availableParallelism}from'os';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var o=c(a$1(),1);var r=`
|
|
4
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557
|
|
5
|
+
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u255D
|
|
6
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
7
|
+
\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557
|
|
8
|
+
\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557
|
|
9
|
+
\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
|
|
10
|
+
`;function a(){console.log(o.default.yellow(r)),console.log(o.default.cyan(" \u{1F4E6} Local npm package development without symlinks")),console.log(o.default.dim(` Copies built files into consumer node_modules with incremental sync
|
|
11
|
+
`));}a$2(a,"showBanner");process.env.UV_THREADPOOL_SIZE??=String(Math.max(availableParallelism(),8));a$3();var d=process.argv.slice(2),p=d.some(e=>!e.startsWith("-")&&["init","publish","add","remove","push","dev","restore","list","status","update","clean","gc","doctor","migrate"].includes(e));p||a();var u={meta:{name:"plunk",version:"0.4.0-canary.15df40d",description:"Local npm package development \u2014 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-C6XCSFCU.mjs').then(e=>e.default),"init"),publish:a$2(()=>import('./publish-6A7PX5IH.mjs').then(e=>e.default),"publish"),add:a$2(()=>import('./add-32QF7GZO.mjs').then(e=>e.default),"add"),remove:a$2(()=>import('./remove-V3T3XXOY.mjs').then(e=>e.default),"remove"),push:a$2(()=>import('./push-GUFND2MN.mjs').then(e=>e.default),"push"),dev:a$2(()=>import('./dev-ZBELDIBF.mjs').then(e=>e.default),"dev"),restore:a$2(()=>import('./restore-I5W7PTSI.mjs').then(e=>e.default),"restore"),list:a$2(()=>import('./list-QSPN7FE5.mjs').then(e=>e.default),"list"),status:a$2(()=>import('./status-22YV26A3.mjs').then(e=>e.default),"status"),update:a$2(()=>import('./update-NK2BQY7K.mjs').then(e=>e.default),"update"),clean:a$2(()=>import('./clean-F2IWAVRP.mjs').then(e=>e.default),"clean"),gc:a$2(()=>import('./clean-F2IWAVRP.mjs').then(e=>e.default),"gc"),doctor:a$2(()=>import('./doctor-GJGAAT6J.mjs').then(e=>e.default),"doctor"),migrate:a$2(()=>import('./migrate-4TFDXO4G.mjs').then(e=>e.default),"migrate")}};a$4(u);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$1,b as b$1}from'./chunk-BRC4A5PJ.mjs';import'./chunk-IZRTKGYZ.mjs';import'./chunk-7JG555TZ.mjs';import'./chunk-AC5FETT7.mjs';import'./chunk-LLVBXPQN.mjs';import'./chunk-PVMVWPLG.mjs';import'./chunk-HPF6K6WO.mjs';import'./chunk-EMRPZYLU.mjs';import'./chunk-MBKCCWSD.mjs';import'./chunk-22YCXJTS.mjs';import {b}from'./chunk-OJJZ7CLB.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-HW7AEGI3.mjs';import'./chunk-TMH7HIJ2.mjs';import'./chunk-R3RSOZXN.mjs';import'./chunk-ICCM7US5.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var u={meta:{name:"dev",description:"Watch, rebuild, and push to all consumers. Auto-detects build command."},args:{build:{type:"string",description:"Override build command (default: auto-detect from package.json)"},"skip-build":{type:"boolean",description:"Watch output dirs directly, skip build command detection",default:false},debounce:{type:"string",description:"Debounce delay in ms (default: 500)"},cooldown:{type:"string",description:"Minimum time between builds in ms (default: 500)"},"no-scripts":{type:"boolean",description:"Skip prepack/postpack lifecycle hooks",default:false}},async run({args:e}){b();let t=resolve("."),i=a(()=>a$1(t,{runScripts:!e["no-scripts"]}),"push");await i(),await b$1(t,e,i);}};export{u as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$2,b as b$5,c as c$1,d as d$1}from'./chunk-AC5FETT7.mjs';import {g,b as b$3}from'./chunk-LLVBXPQN.mjs';import {d,b as b$4}from'./chunk-EMRPZYLU.mjs';import {a as a$1,b as b$2}from'./chunk-22YCXJTS.mjs';import {b,a as a$3}from'./chunk-OJJZ7CLB.mjs';import'./chunk-OL7SNXMX.mjs';import {k}from'./chunk-TMH7HIJ2.mjs';import'./chunk-R3RSOZXN.mjs';import {a,b as b$1}from'./chunk-ICCM7US5.mjs';import {c}from'./chunk-2VCW5RWI.mjs';import {resolve,join}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var o=c(a(),1);var K={meta:{name:"doctor",description:"Run diagnostic checks on your plunk setup"},async run(){b();let t=resolve("."),s=[];b$1.info(`Running plunk diagnostics...
|
|
4
|
+
`);let l=a$1();if(await k(l)){let e=await d();s.push({name:"Store directory",status:"pass",message:`${e.length} entries in ${l}`});}else s.push({name:"Store directory",status:"warn",message:`Store not found at ${l}. Run 'plunk publish' to create it.`});let _=b$2();if(await k(_)){let e=await g(),n=Object.values(e).flat().length;s.push({name:"Global registry",status:"pass",message:`${Object.keys(e).length} packages, ${n} consumer registrations`});}else s.push({name:"Global registry",status:"warn",message:"No consumers registered yet. Use 'plunk add' to link packages."});let{state:x,reliable:A}=await b$3(t);A||s.push({name:"Consumer state",status:"fail",message:"state.json is corrupt or unreadable. Delete .plunk/state.json and re-run 'plunk add' for each package."});let m=Object.entries(x.links);if(m.length>0){s.push({name:"Consumer state",status:"pass",message:`${m.length} linked package(s)`});for(let[e,n]of m){let u=await b$4(e,n.version);u?u.meta.contentHash!==n.contentHash?s.push({name:`Store: ${e}`,status:"warn",message:"Store has newer content. Run 'plunk update' to sync."}):s.push({name:`Store: ${e}`,status:"pass",message:`${e}@${n.version} in sync`}):s.push({name:`Store: ${e}`,status:"fail",message:`Store entry missing for ${e}@${n.version}. Re-publish it.`});let k$1=join(t,"node_modules",e);if(!await k(k$1))s.push({name:`node_modules: ${e}`,status:"fail",message:"Missing from node_modules. Run 'plunk restore'."});else try{let{readFile:F}=await import('fs/promises'),d=JSON.parse(await F(join(k$1,"package.json"),"utf-8"));d.version&&d.version!==n.version&&s.push({name:`node_modules: ${e}`,status:"warn",message:`node_modules has v${d.version} but plunk linked v${n.version}. Run 'plunk restore'.`});}catch{}}}else s.push({name:"Consumer state",status:"warn",message:"No packages linked. Use 'plunk add' to link a package."});let f=await a$2(t);if(s.push({name:"Package manager",status:"pass",message:f}),f==="yarn"){let e=await b$5(t);await c$1(t)?e==="node-modules"?s.push({name:"Yarn linker",status:"pass",message:"Yarn Berry with node-modules linker"}):e==="pnpm"?s.push({name:"Yarn linker",status:"pass",message:"Yarn pnpm linker mode (plunk handles this)"}):e==="pnp"?s.push({name:"Yarn linker",status:"fail",message:"Yarn PnP is not compatible. Set `nodeLinker: node-modules` in .yarnrc.yml"}):s.push({name:"Yarn linker",status:"warn",message:"Yarn Berry defaults to PnP. Add `nodeLinker: node-modules` to .yarnrc.yml"}):s.push({name:"Yarn linker",status:"pass",message:"Yarn Classic, node_modules mode"});}let i=await d$1(t);i.type?s.push({name:"Bundler",status:"pass",message:`${i.type}${i.configFile?` (${i.configFile})`:""}`}):s.push({name:"Bundler",status:"warn",message:"No bundler config detected"});let h=join(t,".gitignore");if(await k(h)){let{readFile:e}=await import('fs/promises');(await e(h,"utf-8")).includes(".plunk")?s.push({name:".gitignore",status:"pass",message:".plunk/ is ignored"}):s.push({name:".gitignore",status:"warn",message:".plunk/ not in .gitignore. Run 'plunk init' to fix."});}parseInt(process.versions.node.split(".")[0],10)>=22?s.push({name:"Node.js version",status:"pass",message:`v${process.versions.node}`}):s.push({name:"Node.js version",status:"fail",message:`v${process.versions.node} \u2014 plunk requires Node.js >= 22`});let B={pass:o.default.green("PASS"),fail:o.default.red("FAIL"),warn:o.default.yellow("WARN")};for(let e of s)b$1.log(` ${B[e.status]} ${e.name}: ${o.default.dim(e.message)}`);let p=s.filter(e=>e.status==="fail").length,c=s.filter(e=>e.status==="warn").length;b$1.log(""),p>0?b$1.error(`${p} issue(s) found that need attention`):c>0?b$1.warn(`${c} warning(s), but no critical issues`):b$1.success("All checks passed!"),a$3({results:s.map(({name:e,status:n,message:u})=>({name:e,status:n,message:u})),failures:p,warnings:c});}};export{K as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';export{l as atomicWriteFile,e as collectFiles,m as copyDir,d as copyWithCoW,i as ensureDir,j as ensurePrivateDir,k as exists,f as incrementalCopy,c as isNodeError,g as moveDir,h as removeDir}from'./chunk-TMH7HIJ2.mjs';import'./chunk-R3RSOZXN.mjs';import'./chunk-ICCM7US5.mjs';import'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ interface PublishOptions {
|
|
|
2
2
|
allowPrivate?: boolean;
|
|
3
3
|
/** Whether to run prepack/postpack lifecycle hooks (default: true) */
|
|
4
4
|
runScripts?: boolean;
|
|
5
|
+
/** Force publish, bypassing hash comparison */
|
|
6
|
+
force?: boolean;
|
|
5
7
|
}
|
|
6
8
|
interface PublishResult {
|
|
7
9
|
name: string;
|
|
@@ -31,7 +33,8 @@ interface PlunkMeta {
|
|
|
31
33
|
contentHash: string;
|
|
32
34
|
publishedAt: string;
|
|
33
35
|
sourcePath: string;
|
|
34
|
-
buildId
|
|
36
|
+
/** 8-char hex ID derived from content hash. Missing in pre-buildId store entries. */
|
|
37
|
+
buildId?: string;
|
|
35
38
|
}
|
|
36
39
|
/** A store entry representing a published package */
|
|
37
40
|
interface StoreEntry {
|
|
@@ -48,7 +51,8 @@ interface LinkEntry {
|
|
|
48
51
|
sourcePath: string;
|
|
49
52
|
backupExists: boolean;
|
|
50
53
|
packageManager: PackageManager;
|
|
51
|
-
buildId
|
|
54
|
+
/** 8-char hex ID. Missing in pre-buildId state files. */
|
|
55
|
+
buildId?: string;
|
|
52
56
|
}
|
|
53
57
|
/** Consumer project state file (.plunk/state.json) */
|
|
54
58
|
interface ConsumerState {
|
|
@@ -69,8 +73,10 @@ interface WatchOptions {
|
|
|
69
73
|
patterns?: string[];
|
|
70
74
|
/** Build command to run before publishing */
|
|
71
75
|
buildCmd?: string;
|
|
72
|
-
/** Debounce delay in ms (default:
|
|
76
|
+
/** Debounce delay in ms (default: 500) */
|
|
73
77
|
debounce?: number;
|
|
78
|
+
/** Minimum time between builds in ms (default: 500) */
|
|
79
|
+
cooldown?: number;
|
|
74
80
|
/** Enable awaitWriteFinish for large/slow writes (auto-enabled when no buildCmd) */
|
|
75
81
|
awaitWriteFinish?: boolean | {
|
|
76
82
|
stabilityThreshold: number;
|
|
@@ -117,13 +123,17 @@ interface InjectResult {
|
|
|
117
123
|
skipped: number;
|
|
118
124
|
binLinks: number;
|
|
119
125
|
}
|
|
126
|
+
interface InjectOptions {
|
|
127
|
+
/** Force copy all files, bypassing hash comparison */
|
|
128
|
+
force?: boolean;
|
|
129
|
+
}
|
|
120
130
|
/**
|
|
121
131
|
* Inject a package from the store into a consumer's node_modules.
|
|
122
132
|
* Strategy depends on the package manager:
|
|
123
133
|
* - npm/yarn/bun: direct node_modules/<pkg>/
|
|
124
134
|
* - pnpm: follow .pnpm/ structure
|
|
125
135
|
*/
|
|
126
|
-
declare function inject(storeEntry: StoreEntry, consumerPath: string, pm: PackageManager): Promise<InjectResult>;
|
|
136
|
+
declare function inject(storeEntry: StoreEntry, consumerPath: string, pm: PackageManager, options?: InjectOptions): Promise<InjectResult>;
|
|
127
137
|
/**
|
|
128
138
|
* Back up the existing installed version of a package before overwriting.
|
|
129
139
|
*/
|
|
@@ -152,10 +162,22 @@ declare function listStoreEntries(): Promise<StoreEntry[]>;
|
|
|
152
162
|
|
|
153
163
|
/** Read the consumer state file, or return an empty state if not found */
|
|
154
164
|
declare function readConsumerState(consumerPath: string): Promise<ConsumerState>;
|
|
165
|
+
/**
|
|
166
|
+
* Read consumer state with reliability information.
|
|
167
|
+
* Returns `reliable: true` when the state is trustworthy (valid file or ENOENT).
|
|
168
|
+
* Returns `reliable: false` when the file exists but is corrupt/unreadable,
|
|
169
|
+
* meaning the consumer might have links we can't see.
|
|
170
|
+
*/
|
|
171
|
+
declare function readConsumerStateSafe(consumerPath: string): Promise<{
|
|
172
|
+
state: ConsumerState;
|
|
173
|
+
reliable: boolean;
|
|
174
|
+
}>;
|
|
155
175
|
/** Add or update a link entry in the consumer state */
|
|
156
176
|
declare function addLink(consumerPath: string, packageName: string, entry: LinkEntry): Promise<void>;
|
|
157
177
|
/** Remove a link entry from the consumer state */
|
|
158
178
|
declare function removeLink(consumerPath: string, packageName: string): Promise<void>;
|
|
179
|
+
/** Get a specific link entry */
|
|
180
|
+
declare function getLink(consumerPath: string, packageName: string): Promise<LinkEntry | null>;
|
|
159
181
|
/** Register a consumer for a package */
|
|
160
182
|
declare function registerConsumer(packageName: string, consumerPath: string): Promise<void>;
|
|
161
183
|
/** Unregister a consumer for a package */
|
|
@@ -171,6 +193,17 @@ declare function cleanStaleConsumers(): Promise<{
|
|
|
171
193
|
removedPackages: number;
|
|
172
194
|
}>;
|
|
173
195
|
|
|
196
|
+
interface PushOptions {
|
|
197
|
+
runScripts?: boolean;
|
|
198
|
+
/** Force copy all files, bypassing hash comparison */
|
|
199
|
+
force?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Publish a package to the store, then inject into all registered consumers.
|
|
203
|
+
* Shared by both `push` and `dev` commands.
|
|
204
|
+
*/
|
|
205
|
+
declare function doPush(packageDir: string, options?: PushOptions): Promise<void>;
|
|
206
|
+
|
|
174
207
|
/** Kill the active build process if one is running */
|
|
175
208
|
declare function killActiveBuild(): void;
|
|
176
209
|
/**
|
|
@@ -208,4 +241,4 @@ declare class Timer {
|
|
|
208
241
|
/** Type guard for Node.js system errors with an error code */
|
|
209
242
|
declare function isNodeError(err: unknown): err is NodeJS.ErrnoException;
|
|
210
243
|
|
|
211
|
-
export { type ConsumerState, type ConsumersRegistry, type LinkEntry, type PackageJson, type PackageManager, type PlunkMeta, type PublishOptions, type PublishResult, type StoreEntry, Timer, type WatchOptions, addLink, backupExisting, checkMissingDeps, cleanStaleConsumers, detectPackageManager, findStoreEntry, getConsumers, getStoreEntry, inject, isNodeError, killActiveBuild, listStoreEntries, publish, readConsumerState, registerConsumer, removeInjected, removeLink, restoreBackup, startWatcher, unregisterConsumer };
|
|
244
|
+
export { type ConsumerState, type ConsumersRegistry, type InjectOptions, type InjectResult, type LinkEntry, type PackageJson, type PackageManager, type PlunkMeta, type PublishOptions, type PublishResult, type PushOptions, type StoreEntry, Timer, type WatchOptions, addLink, backupExisting, checkMissingDeps, cleanStaleConsumers, detectPackageManager, doPush, findStoreEntry, getConsumers, getLink, getStoreEntry, inject, isNodeError, killActiveBuild, listStoreEntries, publish, readConsumerState, readConsumerStateSafe, registerConsumer, removeInjected, removeLink, restoreBackup, startWatcher, unregisterConsumer };
|