@olegkuibar/plunk 0.2.3 → 0.3.0-canary.0807dec
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/dist/add-4LHIITHV.mjs +14 -0
- package/dist/chokidar-LVDD2IK4.mjs +4 -0
- package/dist/chunk-2VCW5RWI.mjs +3 -0
- package/dist/chunk-4QWBGXB5.mjs +15 -0
- package/dist/chunk-4TNTNSAB.mjs +4 -0
- package/dist/chunk-6YX2BGO2.mjs +3 -0
- package/dist/chunk-7JG555TZ.mjs +3 -0
- package/dist/chunk-AR7AKSKG.mjs +3 -0
- package/dist/chunk-HW7AEGI3.mjs +3 -0
- package/dist/chunk-KVVUZ6KL.mjs +4 -0
- package/dist/chunk-LI4HG26F.mjs +4 -0
- package/dist/chunk-MBKCCWSD.mjs +3 -0
- package/dist/chunk-OL7SNXMX.mjs +7 -0
- package/dist/chunk-QUI5JAIH.mjs +3 -0
- package/dist/chunk-RITKSDMP.mjs +3 -0
- package/dist/chunk-UAGG5WMD.mjs +3 -0
- package/dist/chunk-UDONDVIM.mjs +7 -0
- package/dist/chunk-ZAUWE3N7.mjs +12 -0
- package/dist/chunk-ZIXSXQRE.mjs +3 -0
- package/dist/chunk-ZJMZKJNW.mjs +3 -0
- package/dist/clean-EWBL6FW2.mjs +3 -0
- package/dist/cli.mjs +2 -56
- package/dist/dev-NCLIWE2E.mjs +3 -0
- package/dist/doctor-PXC45S34.mjs +4 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.mjs +572 -244
- package/dist/init-TZ76GAWN.mjs +7 -0
- package/dist/list-CCR7QD7N.mjs +5 -0
- package/dist/migrate-6RZ3SEU5.mjs +8 -0
- package/dist/publish-4TDT6TTS.mjs +3 -0
- package/dist/push-M4RSFETI.mjs +3 -0
- package/dist/remove-R55FIXPL.mjs +3 -0
- package/dist/restore-XBFOHISI.mjs +11 -0
- package/dist/status-GCATYK2I.mjs +4 -0
- package/dist/tailwind-source-VPNLLSRJ.mjs +5 -0
- package/dist/update-6PLGM37S.mjs +3 -0
- package/dist/vite-config-ZMDIOTXC.mjs +10 -0
- package/dist/vite-plugin.mjs +2 -1
- package/dist/workspace-VREEJZ76.mjs +3 -0
- package/package.json +2 -8
- package/dist/add-5ZRFUL6Z.mjs +0 -258
- package/dist/chokidar-XGAEDN45.mjs +0 -1746
- package/dist/chunk-34UXZ622.mjs +0 -98
- package/dist/chunk-4O2QOKVO.mjs +0 -1958
- package/dist/chunk-CSMZ6DZA.mjs +0 -367
- package/dist/chunk-CZM4TNAI.mjs +0 -292
- package/dist/chunk-EDUXIQ5W.mjs +0 -1729
- package/dist/chunk-GAAB2TLH.mjs +0 -160
- package/dist/chunk-HKNM3UWU.mjs +0 -496
- package/dist/chunk-I6SN7BBN.mjs +0 -1131
- package/dist/chunk-KYDBD2KQ.mjs +0 -39
- package/dist/chunk-LKQINKH4.mjs +0 -130
- package/dist/chunk-PUSXMPOF.mjs +0 -82
- package/dist/chunk-S4HJSJ32.mjs +0 -69
- package/dist/chunk-W3C72UKC.mjs +0 -113
- package/dist/chunk-WSECI6M7.mjs +0 -85
- package/dist/chunk-XMIZ7OUZ.mjs +0 -26
- package/dist/chunk-XZK5T4GK.mjs +0 -23
- package/dist/chunk-ZOYNYK5Y.mjs +0 -23
- package/dist/chunk-ZQCGJUBJ.mjs +0 -92
- package/dist/clean-LTR5MZTY.mjs +0 -84
- package/dist/dev-LFXQP6SA.mjs +0 -194
- package/dist/dist-DUFCZSIL.mjs +0 -813
- package/dist/doctor-R7ZVR7PY.mjs +0 -230
- package/dist/hash-worker.mjs +0 -65
- package/dist/init-SWCNRISY.mjs +0 -310
- package/dist/list-B77L2F34.mjs +0 -119
- package/dist/migrate-X5TIC5SS.mjs +0 -124
- package/dist/prompt-HTPH6HQ7.mjs +0 -756
- package/dist/publish-UXCLPNM6.mjs +0 -63
- package/dist/push-JI6HGCFG.mjs +0 -197
- package/dist/remove-DCR7KKD5.mjs +0 -149
- package/dist/restore-SUN3WGSW.mjs +0 -124
- package/dist/status-MESRBH54.mjs +0 -103
- package/dist/tailwind-source-JBBEIXIJ.mjs +0 -89
- package/dist/update-SKDSA673.mjs +0 -100
- package/dist/vite-config-BAK67JHB.mjs +0 -128
- package/dist/workspace-76HJPAK2.mjs +0 -97
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$2}from'./chunk-7JG555TZ.mjs';import {a as a$5,b as b$2}from'./chunk-ZAUWE3N7.mjs';import {a as a$4,d}from'./chunk-LI4HG26F.mjs';import {a as a$6,b as b$3}from'./chunk-QUI5JAIH.mjs';import {a as a$3}from'./chunk-MBKCCWSD.mjs';import'./chunk-KVVUZ6KL.mjs';import {b as b$1,a as a$7}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import {j,h}from'./chunk-6YX2BGO2.mjs';import {a,b}from'./chunk-AR7AKSKG.mjs';import {c,a as a$1}from'./chunk-2VCW5RWI.mjs';import {join,resolve,basename}from'path';import {readFile,writeFile}from'fs/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var n=c(a(),1);var ee={meta:{name:"init",description:"Set up plunk in the current project"},args:{yes:{type:"boolean",alias:"y",description:"Skip confirmation prompts",default:false},role:{type:"string",description:'Project role: "consumer" or "library"'}},async run({args:a}){b$1();let o=new a$3,s=resolve("."),p=a.yes;b.info(`Initializing plunk in ${n.default.cyan(s)}
|
|
4
|
+
`);let i=await a$4(s),d$1={pnpm:"pnpm-lock.yaml",bun:"bun.lockb",yarn:"yarn.lock",npm:"package-lock.json"};b.success(`Detected package manager: ${n.default.cyan(i)}`+(d$1[i]?` (from ${d$1[i]})`:""));let l=i;if(!p&&await b.prompt(`Use ${i}?`,{type:"confirm",initial:true})===false){let c=["npm","pnpm","yarn","bun"].filter(u=>u!==i),f=await b.prompt("Select package manager:",{type:"select",options:c.map(u=>({label:u,value:u}))});typeof f=="string"&&(l=f);}let r="consumer";a.role==="consumer"||a.role==="library"?r=a.role:p||await b.prompt("How will you use plunk in this project?",{type:"select",options:[{label:"Consumer (app) \u2014 I want to link packages INTO this project",value:"consumer"},{label:"Library (package) \u2014 I want to publish this package FOR other projects",value:"library"}]})==="library"&&(r="library"),b.success(`Project role: ${n.default.cyan(r)}`);let R=join(s,".gitignore");await a$5(R)&&b.success("Added .plunk/ to .gitignore");let m=join(s,"package.json");if(await j(m))if(r==="consumer"){await b$2(m)&&b.success('Added "postinstall": "plunk restore" to package.json scripts');let c="{package-name}";if(!p){let u=await b.prompt("Package name to link (leave blank to skip):",{type:"text",default:""});typeof u=="string"&&u.trim()&&(c=u.trim());}await $(m,"plunk:add",`plunk add ${c}`)&&b.success(`Added "plunk:add": "plunk add ${c}" to package.json scripts`);}else {await T(m,l,p);let t=await V(m);for(let c of t)b.success(`Added "${c}" script to package.json`);}let y=join(s,".plunk");if(!await j(y))await h(y),await writeFile(join(y,"state.json"),JSON.stringify({version:"1",packageManager:l,role:r,links:{}},null,2)),b.success("Created .plunk/ state directory");else {let t=await a$6(s);t.packageManager=l,t.role=r,await b$3(s,t);}if(r==="consumer"){let t=await d(s);if(t.type==="vite"&&t.configFile){b.success(`Detected bundler: ${n.default.cyan("Vite")} (${basename(t.configFile)})`);let{addPlunkVitePlugin:c}=await import('./vite-config-ZMDIOTXC.mjs'),f=await c(t.configFile);f.modified?b.success(`Added plunk plugin to ${basename(t.configFile)}`):f.error&&b.info(`Add the Vite plugin for automatic dev server restarts:
|
|
5
|
+
${n.default.cyan('import plunk from "@olegkuibar/plunk/vite"')}
|
|
6
|
+
${n.default.cyan("plugins: [plunk()]")}`);}else if(t.type==="next"&&t.configFile)b.success(`Detected bundler: ${n.default.cyan("Next.js")} (${basename(t.configFile)})`),b.info(`Next.js transpilePackages will be auto-configured when you run ${n.default.cyan("plunk add")}`);else if(t.type){let c={webpack:"Webpack",turbo:"Turbopack",rollup:"Rollup"};b.success(`Detected bundler: ${n.default.cyan(c[t.type]||t.type)} \u2014 no config needed, works out of the box`);}b.log(""),b.info(`${n.default.bold("Next steps:")}`),b.log(` 1. ${n.default.cyan("cd ../my-lib && plunk publish")}`),b.log(` 2. ${n.default.cyan("plunk add my-lib")}${t.type==="vite"?" \u2190 auto-updates vite config":t.type==="next"?" \u2190 auto-updates next config":""}`),b.log(` 3. ${n.default.cyan("cd ../my-lib && plunk dev")} \u2190 watch + rebuild + auto-push`);}else b.log(""),b.info(`${n.default.bold("Next steps:")}`),b.log(` 1. ${n.default.cyan("plunk publish")} \u2190 copy built files to plunk store`),b.log(` 2. ${n.default.cyan(`${l} run plunk:dev`)} \u2190 watch + rebuild + auto-push to consumers`),b.log(` 3. In consumer project: ${n.default.cyan("plunk add "+await H(m))}`);b.info(`Done in ${o.elapsed()}`),a$7({packageManager:l,role:r,elapsed:o.elapsedMs()});}};async function $(a,o,s){let p=await readFile(a,"utf-8"),i=JSON.parse(p);if(i.scripts?.[o])return false;i.scripts||(i.scripts={}),i.scripts[o]=s;let d=p.match(/^(\s+)"/m)?.[1]||" ";return await writeFile(a,JSON.stringify(i,null,d)+`
|
|
7
|
+
`),true}a$1($,"addScript");async function T(a,o,s){let p=join(a,".."),i=await a$2(p,o);if(i)return b.success(`Detected build script: ${n.default.cyan(i)}`),i;let d=o==="npm"?"npm run ":`${o} `;if(!s){b.warn("No build script found in package.json");let r=await b.prompt("Build command (e.g. tsc, tsup, rollup -c):",{type:"text",default:""});if(typeof r=="string"&&r.trim())return r.trim()}let l=`${d}build`;return b.warn(`Using ${n.default.cyan(l)} as placeholder \u2014 add a "build" script to package.json`),l}a$1(T,"detectBuildCommand");async function V(a){let o=[];return await $(a,"plunk:publish","plunk publish")&&o.push("plunk:publish"),await $(a,"plunk:dev","plunk dev")&&o.push("plunk:dev"),o}a$1(V,"addLibraryScripts");async function H(a){try{return JSON.parse(await readFile(a,"utf-8")).name||"my-package"}catch{return "my-package"}}a$1(H,"readPkgName");export{ee as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b as b$1,d}from'./chunk-UAGG5WMD.mjs';import {a as a$2}from'./chunk-QUI5JAIH.mjs';import'./chunk-KVVUZ6KL.mjs';import {a as a$3,b as b$2}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-6YX2BGO2.mjs';import {a,b}from'./chunk-AR7AKSKG.mjs';import {c,a as a$1}from'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var o=c(a(),1);var E={meta:{name:"list",description:"List linked packages in current project or in the store"},args:{store:{type:"boolean",description:"List all packages in the global plunk store",default:false}},async run({args:n}){b$2(),n.store?await I():await y();}};async function y(){let n=await a$2(resolve(".")),s=Object.entries(n.links);if(s.length===0){b.info("No linked packages in this project"),a$3({packages:[]});return}b.info(`Linked packages (${s.length}):
|
|
4
|
+
`);let t=[];for(let[i,e]of s){let c=e.buildId?`[${e.buildId}]`:"[--------]",u=false,d=await b$1(i,e.version);d&&d.meta.buildId&&e.buildId&&d.meta.buildId!==e.buildId&&(u=true);let h=u?o.default.yellow(" (stale)"):"";b.log(` ${o.default.cyan(i)} ${o.default.dim("@"+e.version)} ${o.default.dim(c)}${h} \u2190 ${o.default.dim(e.sourcePath)}`),t.push({name:i,version:e.version,buildId:e.buildId??null,stale:u,sourcePath:e.sourcePath});}a$3({packages:t});}a$1(y,"listProject");async function I(){let n=await d();if(n.length===0){b.info("Plunk store is empty"),a$3({entries:[]});return}b.info(`Store entries (${n.length}):
|
|
5
|
+
`);let s=[];for(let t of n){let i=v(new Date(t.meta.publishedAt)),e=t.meta.buildId?`[${t.meta.buildId}]`:"[--------]";b.log(` ${o.default.cyan(t.name)} ${o.default.dim("@"+t.version)} ${o.default.dim(e)} ${o.default.dim(`published ${i}`)}`),b.log(` ${o.default.dim(`from: ${t.meta.sourcePath}`)}`),s.push({name:t.name,version:t.version,buildId:t.meta.buildId??null,publishedAt:t.meta.publishedAt,sourcePath:t.meta.sourcePath});}a$3({entries:s});}a$1(I,"listStore");function v(n){let s=Date.now()-n.getTime(),t=Math.floor(s/1e3);if(t<60)return `${t}s ago`;let i=Math.floor(t/60);if(i<60)return `${i}m ago`;let e=Math.floor(i/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}a$1(v,"getRelativeTime");export{E as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$1}from'./chunk-MBKCCWSD.mjs';import {b,a as a$2}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import {j}from'./chunk-6YX2BGO2.mjs';import {a,b as b$1}from'./chunk-AR7AKSKG.mjs';import {c}from'./chunk-2VCW5RWI.mjs';import {resolve,join}from'path';import {readFile,writeFile,rm}from'fs/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var n=c(a(),1);var x={meta:{name:"migrate",description:"Migrate from yalc to plunk"},async run(){b();let m=new a$1,i=resolve(".");b$1.info(`Checking for yalc usage...
|
|
4
|
+
`);let y=join(i,".yalc"),s=join(i,"yalc.lock"),l=join(i,"package.json"),k=await j(y),p=await j(s);if(!k&&!p){b$1.info("No yalc usage detected in this project."),a$2({migrated:false,packages:[]});return}let o=[];if(p)try{let t=await readFile(s,"utf-8"),a=JSON.parse(t);a.packages&&(o.push(...Object.keys(a.packages)),b$1.info(`Found ${o.length} yalc-linked package(s): ${o.map(c=>n.default.cyan(c)).join(", ")}`));}catch{b$1.warn("Could not parse yalc.lock \u2014 the file may be corrupted. Continuing with cleanup.");}if(await j(l))try{let t=await readFile(l,"utf-8"),a=JSON.parse(t),c=!1;for(let f of ["dependencies","devDependencies","peerDependencies"]){let g=a[f];if(g)for(let[h,w]of Object.entries(g))typeof w=="string"&&w.includes(".yalc/")&&(delete g[h],c=!0,b$1.info(`Removed file:.yalc/ reference for ${n.default.cyan(h)}`));}if(c){let f=t.match(/^(\s+)"/m)?.[1]||" ";await writeFile(l,JSON.stringify(a,null,f)+`
|
|
5
|
+
`),b$1.success("Cleaned up package.json");}}catch(t){b$1.warn(`Could not clean package.json: ${t instanceof Error?t.message:String(t)}. You may need to manually remove file:.yalc/ references.`);}if(k&&(await rm(y,{recursive:true,force:true}),b$1.success("Removed .yalc/ directory")),p&&(await rm(s,{force:true}),b$1.success("Removed yalc.lock")),b$1.log(""),b$1.info(`${n.default.bold("Migration complete!")} Next steps:
|
|
6
|
+
`),b$1.log(` 1. ${n.default.cyan("plunk init")}`),o.length>0)for(let t of o)b$1.log(` 2. ${n.default.cyan(`plunk add ${t} --from <path-to-${t}>`)}`);b$1.log(`
|
|
7
|
+
Run ${n.default.cyan("plunk doctor")} to verify your setup.
|
|
8
|
+
`),b$1.info(`Migrated in ${m.elapsed()}`),a$2({migrated:true,packages:o,elapsed:m.elapsedMs()});}};export{x as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$2}from'./chunk-4TNTNSAB.mjs';import'./chunk-UAGG5WMD.mjs';import'./chunk-HW7AEGI3.mjs';import {a as a$1}from'./chunk-ZJMZKJNW.mjs';import {a}from'./chunk-MBKCCWSD.mjs';import'./chunk-KVVUZ6KL.mjs';import {b,a as a$3}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-6YX2BGO2.mjs';import {f,b as b$1}from'./chunk-AR7AKSKG.mjs';import'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var M={meta:{name:"publish",description:"Publish current package to the plunk store"},args:{dir:{type:"positional",description:"Package directory (default: current directory)",required:false},private:{type:"boolean",description:"Allow publishing private packages",default:false},"no-scripts":{type:"boolean",description:"Skip prepack/postpack lifecycle hooks",default:false},recursive:{type:"boolean",alias:"r",description:"Publish all packages in the workspace",default:false}},async run({args:r}){b();let f$1=new a,s=resolve(r.dir||"."),m={allowPrivate:r.private,runScripts:!r["no-scripts"]};if(r.recursive){f(`[publish] Discovering workspace packages from ${s}`);let{findWorkspacePackages:e}=await import('./workspace-VREEJZ76.mjs'),i=await e(s);i.length===0&&(a$1("No workspace packages found. Make sure you're in a workspace root or subdirectory."),process.exit(1));let o=0,a=0,p=0;for(let k of i)try{(await a$2(k,m)).skipped?a++:o++;}catch(t){p++,b$1.warn(`Failed to publish ${k}: ${t instanceof Error?t.message:String(t)}`);}b$1.success(`Workspace publish: ${o} published, ${a} up to date, ${p} failed`),a$3({recursive:true,packages:i.length,published:o,skipped:a,failed:p,elapsed:f$1.elapsedMs()});}else {f(`[publish] Publishing from ${s}`);try{let e=await a$2(s,m);a$3({...e,elapsed:f$1.elapsedMs()});}catch(e){a$1(e instanceof Error?e.message:String(e)),process.exit(1);}}}};export{M as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$1,b as b$2,c}from'./chunk-ZIXSXQRE.mjs';import'./chunk-7JG555TZ.mjs';import'./chunk-4TNTNSAB.mjs';import'./chunk-UAGG5WMD.mjs';import'./chunk-HW7AEGI3.mjs';import'./chunk-4QWBGXB5.mjs';import'./chunk-LI4HG26F.mjs';import'./chunk-QUI5JAIH.mjs';import'./chunk-ZJMZKJNW.mjs';import'./chunk-MBKCCWSD.mjs';import'./chunk-KVVUZ6KL.mjs';import {b as b$1}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-6YX2BGO2.mjs';import'./chunk-AR7AKSKG.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var b={meta:{name:"push",description:"Publish and push to all consumers. Use --watch for continuous mode."},args:{watch:{type:"boolean",description:"Watch for changes and auto-push",default:false},build:{type:"string",description:"Build command to run before publishing (watch mode)"},"skip-build":{type:"boolean",description:"Watch output dirs directly, skip build command detection",default:false},debounce:{type:"string",description:"Debounce delay in ms for watch mode (default: 300)"},"no-scripts":{type:"boolean",description:"Skip prepack/postpack lifecycle hooks",default:false}},async run({args:e}){b$1();let o=resolve("."),t=a(()=>a$1(o,{runScripts:!e["no-scripts"]}),"push");if(await t(),e.watch){let{buildCmd:d,patterns:r}=await b$2(o,e);await c(o,{patterns:r,buildCmd:d,debounce:e.debounce&&Number.isFinite(parseInt(e.debounce,10))?parseInt(e.debounce,10):void 0},t),await new Promise(i=>{process.once("SIGINT",i),process.once("SIGTERM",i);});}}};export{b as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b as b$1}from'./chunk-UDONDVIM.mjs';import {d,c}from'./chunk-4QWBGXB5.mjs';import {d as d$1}from'./chunk-LI4HG26F.mjs';import {d as d$2,h,a as a$1,e}from'./chunk-QUI5JAIH.mjs';import {a as a$4}from'./chunk-ZJMZKJNW.mjs';import {a as a$2}from'./chunk-MBKCCWSD.mjs';import'./chunk-KVVUZ6KL.mjs';import {b as b$2,a as a$3}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-6YX2BGO2.mjs';import {f,b}from'./chunk-AR7AKSKG.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {basename,resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var U={meta:{name:"remove",description:"Remove a plunk-linked package and restore the original"},args:{package:{type:"positional",description:"Package name to remove",required:false},all:{type:"boolean",description:"Remove all linked packages",default:false},force:{type:"boolean",description:"Skip error checking",default:false}},async run({args:o}){b$2();let i=new a$2,t=resolve(".");if(o.all){let c=await a$1(t),n=Object.entries(c.links);if(n.length===0){b.info("No linked packages to remove"),a$3({removed:0});return}let r=0;for(let[p,k]of n)await M(t,p,k),r++;b.success(`Removed ${r} plunk link(s) in ${i.elapsed()}`),a$3({removed:r,elapsed:i.elapsedMs()});return}let e$1=o.package;e$1||(a$4("Package name required. Use --all to remove all linked packages."),process.exit(1));let m=await e(t,e$1);if(!m){if(o.force){b.warn(`Package "${e$1}" is not linked, skipping`),a$3({removed:0});return}a$4(`Package "${e$1}" is not linked in this project`),process.exit(1);}await M(t,e$1,m),b.success(`Removed plunk link for ${e$1} in ${i.elapsed()}`),a$3({removed:1,package:e$1,elapsed:i.elapsedMs()});}};async function M(o,i,t){f(`[remove] Removing ${i}`),await d(o,i,t.packageManager),t.backupExists&&await c(o,i,t.packageManager)&&b.success(`Restored original ${i} from backup`);let e=await d$1(o);e.type==="next"&&e.configFile&&(await b$1(e.configFile,i)).modified&&f(`[remove] Removed ${i} from ${basename(e.configFile)}`);let{findTailwindCss:m,removeTailwindSource:c$1}=await import('./tailwind-source-VPNLLSRJ.mjs'),n=await m(o);if(n&&(await c$1(n,i)).modified&&f(`[remove] Removed @source for ${i} from ${basename(n)}`),await d$2(o,i),await h(i,o),e.type==="vite"&&e.configFile){let r=await a$1(o);if(Object.keys(r.links).length===0){let{removeFromViteConfig:p}=await import('./vite-config-ZMDIOTXC.mjs');(await p(e.configFile)).modified&&f(`[remove] Removed plunk plugin from ${basename(e.configFile)}`);}}}a(M,"removeSinglePackage");export{U as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b as b$3}from'./chunk-UAGG5WMD.mjs';import {a as a$5}from'./chunk-4QWBGXB5.mjs';import {a as a$3,b as b$1,c}from'./chunk-LI4HG26F.mjs';import {a as a$2}from'./chunk-QUI5JAIH.mjs';import {a as a$1}from'./chunk-MBKCCWSD.mjs';import'./chunk-KVVUZ6KL.mjs';import {b,a as a$4}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import {a}from'./chunk-6YX2BGO2.mjs';import {b as b$2,f}from'./chunk-AR7AKSKG.mjs';import'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var Y=a(4),F={meta:{name:"restore",description:"Re-inject all linked packages (use after npm install wipes overrides)"},args:{silent:{type:"boolean",description:"Suppress output when no packages are linked (for postinstall scripts)",default:false}},async run({args:b$4}){b();let l=new a$1,s=resolve("."),P=await a$2(s);if(await a$3(s)==="yarn"){let e=await b$1(s);(e==="pnp"||e===null&&await c(s))&&(b$2.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 c$1=Object.entries(P.links);if(c$1.length===0){b$4.silent||b$2.info("No linked packages in this project"),a$4({restored:0,failed:0});return}let n=0,i=0,v=await Promise.all(c$1.map(([e,o])=>Y(async()=>{let p=await b$3(e,o.version);if(!p)return b$2.warn(`Store entry missing for ${e}@${o.version}. Re-publish it.`),{packageName:e,success:false};try{let t=await a$5(p,s,o.packageManager);return f(`[restore] ${e}@${o.version}: ${t.copied} files`),{packageName:e,success:!0,copied:t.copied}}catch(t){return b$2.error(`Failed to restore ${e}: ${t instanceof Error?t.message:String(t)}`),{packageName:e,success:false}}})));for(let e of v)e.success?(b$2.success(`Restored ${e.packageName} (${e.copied} files)`),n++):i++;b$2.info(`Restore complete: ${n} restored, ${i} failed in ${l.elapsed()}`),a$4({restored:n,failed:i,elapsed:l.elapsedMs()});}};export{F as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b as b$2}from'./chunk-UAGG5WMD.mjs';import {a as a$2}from'./chunk-QUI5JAIH.mjs';import'./chunk-KVVUZ6KL.mjs';import {b,a as a$3}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import {a as a$1,j}from'./chunk-6YX2BGO2.mjs';import {a,b as b$1}from'./chunk-AR7AKSKG.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 w=a$1(4),L={meta:{name:"status",description:"Show status of linked packages with health checks"},async run(){b();let u=resolve("."),h=await a$2(u),r=Object.entries(h.links);if(r.length===0){b$1.info("No linked packages in this project"),a$3({packages:[]});return}b$1.info(`Package status (${r.length} linked):
|
|
4
|
+
`);let c=await Promise.all(r.map(([t,s])=>w(async()=>{let e=[],n=await b$2(t,s.version);n?n.meta.contentHash!==s.contentHash&&e.push("unpublished changes in store"):e.push("store entry missing");let f=join(u,"node_modules",t);return await j(f)||e.push("missing from node_modules (run plunk restore)"),{name:t,version:s.version,buildId:s.buildId??"",issues:e,linkedAt:s.linkedAt,sourcePath:s.sourcePath}})));for(let t of c){let s=t.issues.length===0?o.default.green("\u2713"):o.default.yellow("!"),e=t.buildId?`[${t.buildId}]`:"[--------]";b$1.log(` ${s} ${o.default.cyan(t.name)} ${o.default.dim("@"+t.version)} ${o.default.dim(e)}`),b$1.log(` ${o.default.dim(`linked ${new Date(t.linkedAt).toLocaleString()} from ${t.sourcePath}`)}`);for(let n of t.issues)b$1.log(` ${o.default.yellow("\u26A0")} ${n}`);}a$3({packages:c.map(({name:t,version:s,buildId:e,issues:n})=>({name:t,version:s,buildId:e||null,healthy:n.length===0,issues:n}))});}};export{L as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {k}from'./chunk-6YX2BGO2.mjs';import'./chunk-AR7AKSKG.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readdir,readFile}from'fs/promises';import {join,dirname,relative}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var x=new Set(["node_modules",".plunk","dist",".git"]);async function R(t){let n;try{n=await readdir(t,{recursive:!0,encoding:"utf-8"});}catch{return null}let r=n.filter(e=>e.endsWith(".css")?!e.replace(/\\/g,"/").split("/").some(c=>x.has(c)):false).map(e=>join(t,e));for(let e of r){let i;try{i=await readFile(e,"utf-8");}catch{continue}if(i.includes('@import "tailwindcss"')||i.includes("@import 'tailwindcss'"))return e}return null}a(R,"findTailwindCss");async function $(t,n,r){let e;try{e=await readFile(t,"utf-8");}catch{return {modified:false,error:"could not read CSS file"}}if(e.includes(`node_modules/${n}`))return {modified:false};let i=h(t,n,r),c=/^@(import|source|plugin|theme)\s.+$/gm,o=null,a;for(;(a=c.exec(e))!==null;)o=a;let d=`@source "${i}";`;if(o){let f=o.index+o[0].length;e=e.slice(0,f)+`
|
|
4
|
+
`+d+e.slice(f);}else e=d+`
|
|
5
|
+
`+e;return await k(t,e),{modified:true}}a($,"addTailwindSource");async function _(t,n){let r;try{r=await readFile(t,"utf-8");}catch{return {modified:false}}let e=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`^@source\\s+["'][^"']*node_modules/${e}["'];?\\s*\\n?`,"m");return i.test(r)?(r=r.replace(i,""),await k(t,r),{modified:true}):{modified:false}}a(_,"removeTailwindSource");function h(t,n,r){let e=dirname(t),i=join(r,"node_modules",n);return relative(e,i).replace(/\\/g,"/")}a(h,"computeSourcePath");export{$ as addTailwindSource,R as findTailwindCss,_ as removeTailwindSource};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {c}from'./chunk-UAGG5WMD.mjs';import {a as a$4}from'./chunk-4QWBGXB5.mjs';import'./chunk-LI4HG26F.mjs';import {a as a$1,c as c$1}from'./chunk-QUI5JAIH.mjs';import {a as a$3}from'./chunk-ZJMZKJNW.mjs';import {a}from'./chunk-MBKCCWSD.mjs';import'./chunk-KVVUZ6KL.mjs';import {b,a as a$2}from'./chunk-RITKSDMP.mjs';import'./chunk-OL7SNXMX.mjs';import'./chunk-6YX2BGO2.mjs';import {b as b$1,f}from'./chunk-AR7AKSKG.mjs';import'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var M={meta:{name:"update",description:"Pull latest versions from the store for linked packages"},args:{package:{type:"positional",description:"Package name to update (default: all linked)",required:false}},async run({args:o}){b();let c$2=new a,a$5=resolve("."),v=await a$1(a$5),i=Object.entries(v.links);if(i.length===0){b$1.info("No linked packages in this project"),a$2({updated:0,skipped:0});return}let m=o.package?i.filter(([t])=>t===o.package):i;o.package&&m.length===0&&(a$3(`Package "${o.package}" is not linked in this project. Run 'plunk list' to see linked packages.`),process.exit(1));let r=0,s=0;for(let[t,p]of m){let e=await c(t);if(!e){b$1.warn(`Store entry missing for ${t}. Re-publish it.`);continue}if(e.meta.contentHash===p.contentHash){f(`[update] ${t}@${e.version} already up to date`),s++;continue}let w=await a$4(e,a$5,p.packageManager),S={...p,version:e.version,contentHash:e.meta.contentHash,buildId:e.meta.buildId??"",linkedAt:new Date().toISOString()};await c$1(a$5,t,S),b$1.success(`Updated ${t}@${e.version} (${w.copied} files changed)`),r++;}b$1.info(`Update complete: ${r} updated, ${s} unchanged in ${c$2.elapsed()}`),a$2({updated:r,skipped:s,elapsed:c$2.elapsedMs()});}};export{M as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {k as k$1}from'./chunk-6YX2BGO2.mjs';import'./chunk-AR7AKSKG.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile}from'fs/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
function d(n){return n.match(/^(\s+)\S/m)?.[1]||" "}a(d,"detectIndent");function h(n){return n.includes("@olegkuibar/plunk/vite")||n.includes("vite-plugin-plunk")}a(h,"hasPlunkPlugin");function x(n){let e=[],t="",i=0;for(let r of n)if(r==="("&&i++,r===")"&&i--,r===","&&i===0){let o=t.trim();o&&e.push(o),t="";}else t+=r;let s=t.trim();return s&&e.push(s),e}a(x,"parsePluginItems");function k(n,e){return n.length===0?"[]":n.length===1?`[${n[0]}]`:`[
|
|
4
|
+
${n.map(i=>`${e}${e}${i},`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
${e}]`}a(k,"formatPlugins");async function P(n){let e;try{e=await readFile(n,"utf-8");}catch{return {modified:false,error:"could not read config file"}}if(h(e))return {modified:false};let t=d(e),i=/plugins\s*:\s*\[([\s\S]*?)\]/,s=i.exec(e);if(s){let f=x(s[1]);f.push("plunk()");let g=k(f,t);e=e.replace(i,`plugins: ${g}`);}else {let g=/(?:defineConfig\s*\(\s*\{|export\s+default\s+\{)/.exec(e);if(g){let m=g.index+g[0].length,$=`
|
|
7
|
+
${t}plugins: [plunk()],`;e=e.slice(0,m)+$+e.slice(m);}else return {modified:false,error:"unrecognized Vite config pattern"}}let r=`import plunk from "@olegkuibar/plunk/vite";
|
|
8
|
+
`,o=/^import\s.+$/gm,l=0,c;for(;(c=o.exec(e))!==null;)l=c.index+c[0].length;return l>0?e=e.slice(0,l)+`
|
|
9
|
+
`+r+e.slice(l+1):e=r+`
|
|
10
|
+
`+e,await k$1(n,e),{modified:true}}a(P,"addPlunkVitePlugin");async function R(n){let e;try{e=await readFile(n,"utf-8");}catch{return {modified:false}}if(!h(e))return {modified:false};let t=false,i=/^import\s+\w+\s+from\s+["']@olegkuibar\/plunk\/vite["'];?\s*\n?/m;i.test(e)&&(e=e.replace(i,""),t=true);let s=/plugins\s*:\s*\[([\s\S]*?)\]/,r=s.exec(e);if(r){let o=x(r[1]),l=o.filter(c=>!c.startsWith("plunk("));if(l.length!==o.length){let c=d(e),f=k(l,c);e=e.replace(s,`plugins: ${f}`),t=true;}}return t&&await k$1(n,e),{modified:t}}a(R,"removeFromViteConfig");export{P as addPlunkVitePlugin,R as removeFromViteConfig};
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a}from'./chunk-HW7AEGI3.mjs';import {j}from'./chunk-6YX2BGO2.mjs';import'./chunk-AR7AKSKG.mjs';import {c,a as a$1}from'./chunk-2VCW5RWI.mjs';import {readFile,readdir}from'fs/promises';import {join,dirname,relative,resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var w=c(a(),1);async function R(r){let t=r;for(;;){if(await j(join(t,"pnpm-workspace.yaml")))return t;let n=dirname(t);if(n===t)return null;t=n;}}a$1(R,"findWorkspaceRoot");async function O(r){let t={default:{},named:{}},n=join(r,"pnpm-workspace.yaml"),e;try{e=await readFile(n,"utf-8");}catch{return t}let a=e.split(/\r?\n/),s="top",l="";for(let c of a){if(c.trim()===""||c.trim().startsWith("#"))continue;let i=c.length-c.trimStart().length;if(i===0){if(c.startsWith("catalog:")){s="default-catalog";continue}if(c.startsWith("catalogs:")){s="named-catalogs";continue}s="top";continue}if(s==="default-catalog"&&i>=2){let o=h(c);o&&(t.default[o[0]]=o[1]);continue}if(s==="named-catalogs"&&i>=2&&i<4){let o=c.trim();o.endsWith(":")&&(l=o.slice(0,-1),t.named[l]={},s="named-catalog-entries");continue}if(s==="named-catalog-entries"&&i>=4){let o=h(c);o&&l&&(t.named[l][o[0]]=o[1]);continue}if(s==="named-catalog-entries"&&i>=2&&i<4){let o=c.trim();o.endsWith(":")?(l=o.slice(0,-1),t.named[l]={}):s="named-catalogs";continue}}return t}a$1(O,"parseCatalogs");async function A(r){let t=await R(r);if(t){let e=await C(t);if(e.length>0)return d(t,e)}let n=t??await b(r);if(!n)return [];try{let e=JSON.parse(await readFile(join(n,"package.json"),"utf-8")),a=Array.isArray(e.workspaces)?e.workspaces:e.workspaces?.packages??[];return a.length===0?[]:d(n,a)}catch{return []}}a$1(A,"findWorkspacePackages");async function C(r){let t=join(r,"pnpm-workspace.yaml"),n;try{n=await readFile(t,"utf-8");}catch{return []}let e=[],a=false;for(let s of n.split(/\r?\n/)){let l=s.trim();if(l===""||l.startsWith("#"))continue;let c=s.length-s.trimStart().length;if(c===0){a=l==="packages:";continue}if(a&&c>=2){let i=l.match(/^-\s+["']?([^"']+)["']?$/);i&&(i[1].startsWith("!")||e.push(i[1]));}}return e}a$1(C,"parsePnpmWorkspacePackages");async function b(r){let t=r;for(;;){try{if(JSON.parse(await readFile(join(t,"package.json"),"utf-8")).workspaces)return t}catch{}let n=dirname(t);if(n===t)return null;t=n;}}a$1(b,"findPackageJsonWorkspaceRoot");async function d(r,t){let n=[];for(let e of t)if(e.includes("*")){let a=e.split("/"),s=r,l=[],c=false;for(let i of a)c||i.includes("*")?(c=true,l.push(i)):s=join(s,i);if(l.length===1&&l[0]==="*")try{let i=await readdir(s,{withFileTypes:!0});for(let o of i)if(o.isDirectory()){let g=join(s,o.name);await j(join(g,"package.json"))&&n.push(g);}}catch{}else {let i=(0, w.default)(e),o=await P(r,8);for(let g of o){let W=relative(r,g).replace(/\\/g,"/");i(W)&&await j(join(g,"package.json"))&&n.push(g);}}}else {let a=resolve(r,e);await j(join(a,"package.json"))&&n.push(a);}return [...new Set(n)]}a$1(d,"resolveWorkspaceGlobs");async function P(r,t){if(t<=0)return [];let n=[];try{let e=await readdir(r,{withFileTypes:!0});for(let a of e){if(!a.isDirectory()||a.name==="node_modules"||a.name===".git")continue;let s=join(r,a.name);n.push(s),n.push(...await P(s,t-1));}}catch{}return n}a$1(P,"collectDirs");function h(r){let t=r.trim(),n=t.indexOf(":");if(n<=0)return null;let e=t.slice(0,n).trim(),a=t.slice(n+1).trim();if(!e||!a)return null;let s=a.replace(/^["']|["']$/g,"");return [e,s]}a$1(h,"parseKeyValue");export{A as findWorkspacePackages,R as findWorkspaceRoot,O as parseCatalogs};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olegkuibar/plunk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-canary.0807dec",
|
|
4
4
|
"description": "Modern local package development tool. Smart file copying into node_modules — no symlinks, no git contamination.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -70,7 +70,6 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.2.3",
|
|
72
72
|
"@types/picomatch": "^4.0.2",
|
|
73
|
-
"@types/proper-lockfile": "^4.1.4",
|
|
74
73
|
"tsup": "^8.5.1",
|
|
75
74
|
"typescript": "^5.9.3",
|
|
76
75
|
"vite": "^7.3.1",
|
|
@@ -87,12 +86,7 @@
|
|
|
87
86
|
"dependencies": {
|
|
88
87
|
"chokidar": "^5.0.0",
|
|
89
88
|
"citty": "^0.2.1",
|
|
90
|
-
"consola": "^3.4.2",
|
|
91
|
-
"p-limit": "^7.3.0",
|
|
92
89
|
"picocolors": "^1.1.1",
|
|
93
|
-
"picomatch": "^4.0.3"
|
|
94
|
-
"proper-lockfile": "^4.1.2",
|
|
95
|
-
"tinypool": "^2.1.0",
|
|
96
|
-
"xxhash-wasm": "^1.1.0"
|
|
90
|
+
"picomatch": "^4.0.3"
|
|
97
91
|
}
|
|
98
92
|
}
|
package/dist/add-5ZRFUL6Z.mjs
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
addToTranspilePackages
|
|
5
|
-
} from "./chunk-WSECI6M7.mjs";
|
|
6
|
-
import {
|
|
7
|
-
backupExisting,
|
|
8
|
-
checkMissingDeps,
|
|
9
|
-
inject
|
|
10
|
-
} from "./chunk-CZM4TNAI.mjs";
|
|
11
|
-
import {
|
|
12
|
-
ensureConsumerInit
|
|
13
|
-
} from "./chunk-ZQCGJUBJ.mjs";
|
|
14
|
-
import {
|
|
15
|
-
detectBundler,
|
|
16
|
-
detectPackageManager,
|
|
17
|
-
detectYarnNodeLinker,
|
|
18
|
-
hasYarnrcYml
|
|
19
|
-
} from "./chunk-34UXZ622.mjs";
|
|
20
|
-
import {
|
|
21
|
-
addLink,
|
|
22
|
-
registerConsumer
|
|
23
|
-
} from "./chunk-GAAB2TLH.mjs";
|
|
24
|
-
import {
|
|
25
|
-
publish
|
|
26
|
-
} from "./chunk-4O2QOKVO.mjs";
|
|
27
|
-
import {
|
|
28
|
-
errorWithSuggestion
|
|
29
|
-
} from "./chunk-S4HJSJ32.mjs";
|
|
30
|
-
import {
|
|
31
|
-
findStoreEntry
|
|
32
|
-
} from "./chunk-W3C72UKC.mjs";
|
|
33
|
-
import {
|
|
34
|
-
Timer
|
|
35
|
-
} from "./chunk-XZK5T4GK.mjs";
|
|
36
|
-
import "./chunk-PUSXMPOF.mjs";
|
|
37
|
-
import {
|
|
38
|
-
getConsumerStatePath
|
|
39
|
-
} from "./chunk-EDUXIQ5W.mjs";
|
|
40
|
-
import {
|
|
41
|
-
output,
|
|
42
|
-
suppressHumanOutput
|
|
43
|
-
} from "./chunk-ZOYNYK5Y.mjs";
|
|
44
|
-
import {
|
|
45
|
-
defineCommand
|
|
46
|
-
} from "./chunk-CSMZ6DZA.mjs";
|
|
47
|
-
import {
|
|
48
|
-
exists
|
|
49
|
-
} from "./chunk-HKNM3UWU.mjs";
|
|
50
|
-
import {
|
|
51
|
-
consola,
|
|
52
|
-
isJsonOutput,
|
|
53
|
-
verbose
|
|
54
|
-
} from "./chunk-I6SN7BBN.mjs";
|
|
55
|
-
import "./chunk-KYDBD2KQ.mjs";
|
|
56
|
-
|
|
57
|
-
// src/commands/add.ts
|
|
58
|
-
import { spawn } from "child_process";
|
|
59
|
-
import { platform } from "os";
|
|
60
|
-
import { resolve, basename } from "path";
|
|
61
|
-
var add_default = defineCommand({
|
|
62
|
-
meta: {
|
|
63
|
-
name: "add",
|
|
64
|
-
description: "Link a package from the plunk store into this project"
|
|
65
|
-
},
|
|
66
|
-
args: {
|
|
67
|
-
package: {
|
|
68
|
-
type: "positional",
|
|
69
|
-
description: "Package name to add",
|
|
70
|
-
required: true
|
|
71
|
-
},
|
|
72
|
-
from: {
|
|
73
|
-
type: "string",
|
|
74
|
-
description: "Path to package source (will publish first)"
|
|
75
|
-
},
|
|
76
|
-
yes: {
|
|
77
|
-
type: "boolean",
|
|
78
|
-
alias: "y",
|
|
79
|
-
description: "Auto-accept prompts (install missing deps, etc.)",
|
|
80
|
-
default: false
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
async run({ args }) {
|
|
84
|
-
suppressHumanOutput();
|
|
85
|
-
const timer = new Timer();
|
|
86
|
-
const consumerPath = resolve(".");
|
|
87
|
-
const packageName = args.package;
|
|
88
|
-
if (args.from) {
|
|
89
|
-
const fromPath = resolve(args.from);
|
|
90
|
-
consola.info(`Publishing from ${fromPath}...`);
|
|
91
|
-
await publish(fromPath);
|
|
92
|
-
}
|
|
93
|
-
const entry = await findStoreEntry(packageName);
|
|
94
|
-
if (!entry) {
|
|
95
|
-
errorWithSuggestion(
|
|
96
|
-
`Package "${packageName}" not found in store. Run 'plunk publish' in the package directory first, or use --from <path>.`
|
|
97
|
-
);
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
const needsInit = !await exists(getConsumerStatePath(consumerPath));
|
|
101
|
-
const pm = await detectPackageManager(consumerPath);
|
|
102
|
-
if (needsInit) {
|
|
103
|
-
await ensureConsumerInit(consumerPath, pm);
|
|
104
|
-
consola.success("Auto-initialized plunk (consumer mode)");
|
|
105
|
-
}
|
|
106
|
-
verbose(`[add] Detected package manager: ${pm}`);
|
|
107
|
-
consola.info(`Detected package manager: ${pm}`);
|
|
108
|
-
if (pm === "yarn") {
|
|
109
|
-
const linker = await detectYarnNodeLinker(consumerPath);
|
|
110
|
-
if (linker === "pnp" || linker === null && await hasYarnrcYml(consumerPath)) {
|
|
111
|
-
consola.error(
|
|
112
|
-
`Yarn PnP mode is not compatible with plunk.
|
|
113
|
-
|
|
114
|
-
plunk works by copying files into node_modules/, but PnP eliminates
|
|
115
|
-
node_modules/ entirely. To use plunk with Yarn Berry, add this to
|
|
116
|
-
.yarnrc.yml:
|
|
117
|
-
|
|
118
|
-
nodeLinker: node-modules
|
|
119
|
-
|
|
120
|
-
Then run: yarn install`
|
|
121
|
-
);
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const hasBackup = await backupExisting(consumerPath, packageName, pm);
|
|
126
|
-
if (hasBackup) {
|
|
127
|
-
consola.info(`Backed up existing ${packageName} installation`);
|
|
128
|
-
}
|
|
129
|
-
const result = await inject(entry, consumerPath, pm);
|
|
130
|
-
consola.success(
|
|
131
|
-
`Linked ${packageName}@${entry.version} \u2192 node_modules/${packageName} (${result.copied} files copied, ${result.skipped} unchanged)`
|
|
132
|
-
);
|
|
133
|
-
if (result.binLinks > 0) {
|
|
134
|
-
consola.info(`Created ${result.binLinks} bin link(s)`);
|
|
135
|
-
}
|
|
136
|
-
const linkEntry = {
|
|
137
|
-
version: entry.version,
|
|
138
|
-
contentHash: entry.meta.contentHash,
|
|
139
|
-
linkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
140
|
-
sourcePath: entry.meta.sourcePath,
|
|
141
|
-
backupExists: hasBackup,
|
|
142
|
-
packageManager: pm,
|
|
143
|
-
buildId: entry.meta.buildId ?? ""
|
|
144
|
-
};
|
|
145
|
-
await addLink(consumerPath, packageName, linkEntry);
|
|
146
|
-
await registerConsumer(packageName, consumerPath);
|
|
147
|
-
const missing = await checkMissingDeps(entry, consumerPath);
|
|
148
|
-
if (missing.length > 0) {
|
|
149
|
-
if (isJsonOutput()) {
|
|
150
|
-
verbose(`[add] Missing transitive deps (json mode): ${missing.join(", ")}`);
|
|
151
|
-
} else if (args.yes) {
|
|
152
|
-
const cmd = buildInstallCommand(pm, missing);
|
|
153
|
-
consola.info(`Installing missing dependencies: ${missing.join(", ")}`);
|
|
154
|
-
const ok = await runInstallCommand(cmd, consumerPath);
|
|
155
|
-
if (ok) {
|
|
156
|
-
consola.success("Installed missing dependencies");
|
|
157
|
-
} else {
|
|
158
|
-
consola.warn(`Install failed. Run manually: ${cmd}`);
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
const confirm = await consola.prompt(
|
|
162
|
-
`Install ${missing.length} missing dependencies? (${missing.join(", ")})`,
|
|
163
|
-
{ type: "confirm", initial: true }
|
|
164
|
-
);
|
|
165
|
-
if (confirm) {
|
|
166
|
-
const cmd = buildInstallCommand(pm, missing);
|
|
167
|
-
const ok = await runInstallCommand(cmd, consumerPath);
|
|
168
|
-
if (ok) {
|
|
169
|
-
consola.success("Installed missing dependencies");
|
|
170
|
-
} else {
|
|
171
|
-
consola.warn(`Install failed. Run manually: ${cmd}`);
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
174
|
-
consola.warn(
|
|
175
|
-
`Missing transitive dependencies: ${missing.join(", ")}
|
|
176
|
-
Run: ${buildInstallCommand(pm, missing)}`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const bundler = await detectBundler(consumerPath);
|
|
182
|
-
if (bundler.type === "next" && bundler.configFile) {
|
|
183
|
-
const configResult = await addToTranspilePackages(
|
|
184
|
-
bundler.configFile,
|
|
185
|
-
packageName
|
|
186
|
-
);
|
|
187
|
-
if (configResult.modified) {
|
|
188
|
-
consola.success(
|
|
189
|
-
`Added ${packageName} to transpilePackages in ${basename(bundler.configFile)}`
|
|
190
|
-
);
|
|
191
|
-
} else if (configResult.error) {
|
|
192
|
-
consola.info(
|
|
193
|
-
`Add to next.config manually: transpilePackages: ['${packageName}']`
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
} else if (bundler.type === "vite" && bundler.configFile) {
|
|
197
|
-
const { addPlunkVitePlugin } = await import("./vite-config-BAK67JHB.mjs");
|
|
198
|
-
const viteResult = await addPlunkVitePlugin(bundler.configFile);
|
|
199
|
-
if (viteResult.modified) {
|
|
200
|
-
consola.success(`Added plunk plugin to ${basename(bundler.configFile)}`);
|
|
201
|
-
} else if (viteResult.error) {
|
|
202
|
-
consola.info(
|
|
203
|
-
`Add manually:
|
|
204
|
-
import plunk from "@olegkuibar/plunk/vite"
|
|
205
|
-
plugins: [plunk()]`
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
const { findTailwindCss, addTailwindSource } = await import("./tailwind-source-JBBEIXIJ.mjs");
|
|
210
|
-
const tailwindCss = await findTailwindCss(consumerPath);
|
|
211
|
-
if (tailwindCss) {
|
|
212
|
-
const twResult = await addTailwindSource(tailwindCss, packageName, consumerPath);
|
|
213
|
-
if (twResult.modified) {
|
|
214
|
-
consola.success(`Added @source for ${packageName} to ${basename(tailwindCss)}`);
|
|
215
|
-
} else if (twResult.error) {
|
|
216
|
-
consola.info(`Add to your CSS manually: @source "../node_modules/${packageName}";`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
consola.info(`Done in ${timer.elapsed()}`);
|
|
220
|
-
output({
|
|
221
|
-
package: packageName,
|
|
222
|
-
version: entry.version,
|
|
223
|
-
copied: result.copied,
|
|
224
|
-
skipped: result.skipped,
|
|
225
|
-
binLinks: result.binLinks,
|
|
226
|
-
elapsed: timer.elapsedMs()
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
function buildInstallCommand(pm, deps) {
|
|
231
|
-
const joined = deps.join(" ");
|
|
232
|
-
switch (pm) {
|
|
233
|
-
case "pnpm":
|
|
234
|
-
return `pnpm add ${joined}`;
|
|
235
|
-
case "yarn":
|
|
236
|
-
return `yarn add ${joined}`;
|
|
237
|
-
case "bun":
|
|
238
|
-
return `bun add ${joined}`;
|
|
239
|
-
default:
|
|
240
|
-
return `npm install ${joined}`;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function runInstallCommand(cmd, cwd) {
|
|
244
|
-
return new Promise((resolve2) => {
|
|
245
|
-
const isWin = platform() === "win32";
|
|
246
|
-
const shell = isWin ? "cmd" : "sh";
|
|
247
|
-
const shellFlag = isWin ? "/c" : "-c";
|
|
248
|
-
const child = spawn(shell, [shellFlag, cmd], {
|
|
249
|
-
cwd,
|
|
250
|
-
stdio: "inherit"
|
|
251
|
-
});
|
|
252
|
-
child.on("close", (code) => resolve2(code === 0));
|
|
253
|
-
child.on("error", () => resolve2(false));
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
export {
|
|
257
|
-
add_default as default
|
|
258
|
-
};
|