knarr 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/add-ODK52RZI.mjs +3 -0
- package/dist/bell-YD6IWNXO.mjs +2 -0
- package/dist/check-YVEJEI2G.mjs +6 -0
- package/dist/chokidar-LVDD2IK4.mjs +4 -0
- package/dist/chunk-23HXXAGG.mjs +5 -0
- package/dist/chunk-2EZDTBUU.mjs +3 -0
- package/dist/chunk-2GDRDQA5.mjs +3 -0
- package/dist/chunk-2QPLXLJW.mjs +3 -0
- package/dist/chunk-2VCW5RWI.mjs +3 -0
- package/dist/chunk-3KNUBUPH.mjs +3 -0
- package/dist/chunk-7DZPDPP6.mjs +3 -0
- package/dist/chunk-7HVPEBK5.mjs +7 -0
- package/dist/chunk-7JG555TZ.mjs +3 -0
- package/dist/chunk-B3DZ5HVQ.mjs +3 -0
- package/dist/chunk-BS4VKVYH.mjs +3 -0
- package/dist/chunk-FU7FCNTW.mjs +3 -0
- package/dist/chunk-FUINO5RD.mjs +3 -0
- package/dist/chunk-HQ7NKBQW.mjs +4 -0
- package/dist/chunk-IM555H3S.mjs +4 -0
- package/dist/chunk-KXLQGVT2.mjs +13 -0
- package/dist/chunk-MBKCCWSD.mjs +3 -0
- package/dist/chunk-NBSJGM2X.mjs +3 -0
- package/dist/chunk-OLUZ7T7G.mjs +3 -0
- package/dist/chunk-OXI2KGCW.mjs +14 -0
- package/dist/chunk-SFLWVTJC.mjs +3 -0
- package/dist/chunk-SYADAYF4.mjs +3 -0
- package/dist/chunk-TEFMLGCB.mjs +3 -0
- package/dist/chunk-U5ZZAYNU.mjs +13 -0
- package/dist/chunk-V2ED74ZQ.mjs +3 -0
- package/dist/chunk-XQPVRRTN.mjs +3 -0
- package/dist/chunk-XQVMCMO7.mjs +7 -0
- package/dist/chunk-YZCBBQCH.mjs +19 -0
- package/dist/chunk-Z22BYXWQ.mjs +3 -0
- package/dist/clean-XMLDIZDZ.mjs +3 -0
- package/dist/cli.mjs +10 -0
- package/dist/dev-7L35BV6M.mjs +3 -0
- package/dist/doctor-4TTAYNGW.mjs +4 -0
- package/dist/fs-35635IS7.mjs +2 -0
- package/dist/history-XUZSDCNE.mjs +2 -0
- package/dist/index.d.ts +434 -0
- package/dist/index.mjs +3530 -0
- package/dist/init-OBJFQ6OB.mjs +7 -0
- package/dist/list-AQKUBZ2I.mjs +5 -0
- package/dist/migrate-7B7ACQHY.mjs +8 -0
- package/dist/preflight-TVJFHRI2.mjs +2 -0
- package/dist/publish-Q4JYQPQP.mjs +3 -0
- package/dist/push-NHCPN6MO.mjs +3 -0
- package/dist/remove-PDERBH66.mjs +2 -0
- package/dist/reset-3FXWAAPQ.mjs +3 -0
- package/dist/restore-YGPO42W4.mjs +11 -0
- package/dist/rollback-FKNGLGFC.mjs +3 -0
- package/dist/status-3VUPPR5D.mjs +4 -0
- package/dist/tailwind-source-ND5FE6PQ.mjs +5 -0
- package/dist/topo-sort-WEIVPJKN.mjs +2 -0
- package/dist/tracker-R4ZZIDJV.mjs +2 -0
- package/dist/update-QPBWYDSG.mjs +3 -0
- package/dist/use-NKLXGPIZ.mjs +3 -0
- package/dist/vite-config-URP2SYRQ.mjs +2 -0
- package/dist/vite-plugin.d.ts +5 -0
- package/dist/vite-plugin.mjs +215 -0
- package/dist/watch-orchestrator-F6S5WQQX.mjs +3 -0
- package/dist/watcher-PTPUN2HE.mjs +3 -0
- package/dist/webpack-plugin.d.ts +47 -0
- package/dist/webpack-plugin.mjs +143 -0
- package/dist/workspace-L5CGPK7U.mjs +2 -0
- package/dist/xxhash-wasm-DTW44IIQ.mjs +3 -0
- package/package.json +126 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$2}from'./chunk-IM555H3S.mjs';import {b as b$1,c}from'./chunk-V2ED74ZQ.mjs';import {a as a$7}from'./chunk-XQVMCMO7.mjs';import {b as b$3,a as a$5,e}from'./chunk-YZCBBQCH.mjs';import {a as a$3}from'./chunk-TEFMLGCB.mjs';import {d}from'./chunk-KXLQGVT2.mjs';import {a as a$4,b as b$2,c as c$1,d as d$4}from'./chunk-HQ7NKBQW.mjs';import {a as a$1}from'./chunk-MBKCCWSD.mjs';import {a as a$6}from'./chunk-BS4VKVYH.mjs';import {f,d as d$1,h}from'./chunk-OLUZ7T7G.mjs';import {d as d$2}from'./chunk-Z22BYXWQ.mjs';import {A,k,r}from'./chunk-23HXXAGG.mjs';import {b as b$4,c as c$2,d as d$3}from'./chunk-NBSJGM2X.mjs';import {b}from'./chunk-B3DZ5HVQ.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {spawn}from'child_process';import {platform}from'os';import {resolve,join,basename}from'path';import {readFile}from'fs/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
async function vn(e){let t=e.timer??new a$1,i=resolve("."),{name:n,version:r$1}=G(e.packageArg);if(U(n,e.packageArg),e.from){let m=resolve(e.from);b.info(`Publishing from ${m}...`),await a$2(m);}let a=r$1?await b$1(n,r$1):await c(n);if(!a){let m=r$1?`@${r$1}`:"";a$3(`Package "${n}${m}" not found in store. Run 'knarr publish' in the package directory first, or use --from <path>.`),process.exit(1);}let c$2=!await A(k(i)),o=await a$4(i);if(c$2&&(await d(i,o),b.success("Auto-initialized knarr (consumer mode)")),b.info(`Detected package manager: ${o}`),o==="yarn"){let m=await b$2(i);(m==="pnp"||m===null&&await c$1(i))&&(b.error(`Yarn PnP mode is not compatible with knarr.
|
|
4
|
+
|
|
5
|
+
knarr works by copying files into node_modules/, but PnP eliminates
|
|
6
|
+
node_modules/ entirely. To use knarr with Yarn Berry, add this to
|
|
7
|
+
.yarnrc.yml:
|
|
8
|
+
|
|
9
|
+
nodeLinker: node-modules
|
|
10
|
+
|
|
11
|
+
Then run: yarn install`),process.exit(1));}let u=await f(i,n);u&&(u.version===a.version?b.info(`Updating ${n}@${a.version} (already linked)`):b.info(`Updating ${n}: ${u.version} -> ${a.version}`));let p=await b$3(i,n,o);p&&b.info(`Backed up existing ${n} installation`);let l=await a$5(a,i,o);b.success(`Linked ${n}@${a.version} -> node_modules/${n} (${l.copied} files copied, ${l.skipped} unchanged)`),l.binLinks>0&&b.info(`Created ${l.binLinks} bin link(s)`);let V={version:a.version,contentHash:a.meta.contentHash,linkedAt:new Date().toISOString(),sourcePath:a.meta.sourcePath,backupExists:p,packageManager:o,buildId:a.meta.buildId??""};await d$1(i,n,V),await h(n,i),await d$2(i,n,a.version),await N(a,i,o,e.yes??false),await Q(i,n,o),b.info(`Done in ${t.elapsed()}`),a$6({package:n,version:a.version,copied:l.copied,skipped:l.skipped,binLinks:l.binLinks,elapsed:t.elapsedMs()}),b$4()&&r();}a(vn,"addPackageToConsumer");async function Pn(e){let t=resolve(e);await A(t)||(a$3(`Source path not found: ${t}`),process.exit(1));let i=join(t,"package.json");await A(i)||(a$3(`No package.json found at ${i}. Pass a package directory to 'knarr use'.`),process.exit(1));let n;try{n=JSON.parse(await readFile(i,"utf-8"));}catch(a){a$3(`Could not read package.json at ${i}: ${a instanceof Error?a.message:String(a)}`),process.exit(1);}(!n||typeof n!="object"||typeof n.name!="string")&&(a$3(`package.json at ${i} must include a package name for 'knarr use'.`),process.exit(1));let r=n.name.trim();return U(r,r),r}a(Pn,"readPackageNameFromSource");function G(e){if(e.startsWith("@")){let i=e.indexOf("/");if(i>0){let n=e.indexOf("@",i);if(n>i)return {name:e.slice(0,n),version:e.slice(n+1)}}return {name:e,version:null}}let t=e.lastIndexOf("@");return t>0?{name:e.slice(0,t),version:e.slice(t+1)}:{name:e,version:null}}a(G,"parsePackageArg");function U(e,t){(!e||e==="@"||e.startsWith("@")&&!e.includes("/"))&&(a$3(`Invalid package name "${t}". Use format: package-name or @scope/package-name.`),process.exit(1));}a(U,"validatePackageName");async function N(e$1,t,i,n){let r=await e(e$1,t);if(r.length===0)return;if(c$2()){d$3(`[add] Missing transitive deps (json mode): ${r.join(", ")}`);return}if(n){let c=w(i,r);b.info(`Installing missing dependencies: ${r.join(", ")}`),await $(c,t)?b.success("Installed missing dependencies"):b.warn(`Install failed. Run manually: ${c}`);return}if(await b.prompt(`Install ${r.length} missing dependencies? (${r.join(", ")})`,{type:"confirm",initial:true})){let c=w(i,r);await $(c,t)?b.success("Installed missing dependencies"):b.warn(`Install failed. Run manually: ${c}`);}else b.warn(`Missing transitive dependencies: ${r.join(", ")}
|
|
12
|
+
Run: ${w(i,r)}`);}a(N,"handleMissingDeps");async function Q(e,t,i){let n=await d$4(e);if(n.type==="next"&&n.configFile){let o=await a$7(n.configFile,t);o.modified?b.success(`Added ${t} to transpilePackages in ${basename(n.configFile)}`):o.error&&b.info(`Add to next.config manually: transpilePackages: ['${t}']`);}else if(n.type==="vite"&&n.configFile){let{addKnarrVitePlugin:o}=await import('./vite-config-URP2SYRQ.mjs'),u=await o(n.configFile);if(u.modified){b.success(`Added knarr plugin to ${basename(n.configFile)}`);let p=X(i,"knarr");b.info("Installing knarr as devDependency..."),await $(p,e)?b.success("Installed knarr"):b.warn(`Install failed. Run manually: ${p}`);}else u.error&&b.info(`Add manually:
|
|
13
|
+
import knarr from "knarr/vite"
|
|
14
|
+
plugins: [knarr()]`);}let{findTailwindCss:r,addTailwindSource:a}=await import('./tailwind-source-ND5FE6PQ.mjs'),c=await r(e);if(c){let o=await a(c,t,e);o.modified?b.success(`Added @source for ${t} to ${basename(c)}`):o.error&&b.info(`Add to your CSS manually: @source "../node_modules/${t}";`);}}a(Q,"configureBundler");function w(e,t){let i=t.join(" ");switch(e){case "pnpm":return `pnpm add ${i}`;case "yarn":return `yarn add ${i}`;case "bun":return `bun add ${i}`;default:return `npm install ${i}`}}a(w,"buildInstallCommand");function X(e,t){switch(e){case "pnpm":return `pnpm add -D ${t}`;case "yarn":return `yarn add -D ${t}`;case "bun":return `bun add -d ${t}`;default:return `npm install -D ${t}`}}a(X,"buildDevInstallCommand");function $(e,t){return new Promise(i=>{let n=platform()==="win32",c=spawn(n?"cmd":"sh",[n?"/c":"-c",e],{cwd:t,stdio:"inherit"});c.on("close",o=>i(o===0)),c.on("error",()=>i(false));})}a($,"runInstallCommand");export{vn as a,Pn as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a}from'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var d=class extends Error{static{a(this,"CycleError");}cycle;constructor(t){super(`Dependency cycle detected: ${t.join(" \u2192 ")}`),this.name="CycleError",this.cycle=t;}};function u(s){let t=new Map,i=new Map;for(let e of s.keys())t.has(e)||t.set(e,0),i.has(e)||i.set(e,[]);for(let[e,n]of s)for(let o of n){if(!s.has(o))continue;t.set(e,(t.get(e)??0)+1);let g=i.get(o);g?g.push(e):i.set(o,[e]);}let r=[];for(let[e,n]of t)n===0&&r.push(e);let c=[];for(;r.length>0;){let e=r.shift();c.push(e);for(let n of i.get(e)??[]){let o=(t.get(n)??1)-1;t.set(n,o),o===0&&r.push(n);}}if(c.length!==s.size){let e=[...s.keys()].filter(n=>!c.includes(n));throw new d(e)}return c}a(u,"topoSort");export{d as a,u as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a,b}from'./chunk-B3DZ5HVQ.mjs';import {c as c$1,a as a$1}from'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var r=c$1(a(),1);var p=[{pattern:/not found in store/i,message:"Run 'knarr publish' in the package directory first, or use --from <path>."},{pattern:/is not linked/i,message:"Run 'knarr 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 'knarr 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 'knarr clean' then re-publish."},{pattern:/Failed to acquire lock/i,message:"Another Knarr 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 KNARR_HOOK_TIMEOUT to a higher value (in ms) if your scripts need more time."},{pattern:/state.*corrupt|corrupt.*state/i,message:"Delete .knarr/state.json and re-run 'knarr 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(a){b.error(a);for(let{pattern:s,message:i}of p)if(s.test(a)){b.info(`${r.default.dim("Suggestion:")} ${i}`);break}}a$1(c,"errorWithSuggestion");export{c as a};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {B}from'./chunk-23HXXAGG.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 m(n){return n.includes("knarr/vite")||n.includes("vite-plugin-knarr")}a(m,"hasKnarrPlugin");function w(n){let i=/(^|[^A-Za-z0-9_$])defineConfig\s*\(/g,o;for(;(o=i.exec(n))!==null;){let l=o.index+o[0].length-1,r=1,e=l+1,s=false,f=false;for(;e<n.length&&r>0;){let t=n[e];if(f){f=false,e++;continue}if(t==="\\"){f=true,e++;continue}if(s){t===s&&(s=false),e++;continue}if(t==='"'||t==="'"||t==="`"){s=t,e++;continue}if(t==="/"&&n[e+1]==="/"){let c=n.indexOf(`
|
|
4
|
+
`,e);e=c===-1?n.length:c+1;continue}if(t==="/"&&n[e+1]==="*"){let c=n.indexOf("*/",e+2);e=c===-1?n.length:c+2;continue}if(t==="?"){let c=n[e+1];if(c==="."||c==="?"){e+=2;continue}return true}t==="("&&r++,t===")"&&r--,e++;}i.lastIndex=e;}return false}a(w,"defineConfigUsesTernary");function p(n){let i=[],o="",l=0;for(let e of n)if(e==="("&&l++,e===")"&&l--,e===","&&l===0){let s=o.trim();s&&i.push(s),o="";}else o+=e;let r=o.trim();return r&&i.push(r),i}a(p,"parsePluginItems");function h(n,i){return n.length===0?"[]":n.length===1?`[${n[0]}]`:`[
|
|
5
|
+
${n.map(l=>`${i}${i}${l},`).join(`
|
|
6
|
+
`)}
|
|
7
|
+
${i}]`}a(h,"formatPlugins");function x(n){let o=/plugins\s*:\s*\[/g.exec(n);if(!o)return null;let l=o.index+o[0].length-1,r=1,e=l+1,s=false,f=false;for(;e<n.length&&r>0;){let t=n[e];if(f){f=false,e++;continue}if(t==="\\"){f=true,e++;continue}if(s){t===s&&(s=false),e++;continue}if(t==='"'||t==="'"||t==="`"){s=t,e++;continue}if(t==="/"&&n[e+1]==="/"){let c=n.indexOf(`
|
|
8
|
+
`,e);e=c===-1?n.length:c+1;continue}if(t==="/"&&n[e+1]==="*"){let c=n.indexOf("*/",e+2);e=c===-1?n.length:c+2;continue}(t==="["||t==="("||t==="{")&&r++,(t==="]"||t===")"||t==="}")&&r--,e++;}return r!==0?null:{start:l,end:e,inner:n.slice(l+1,e-1)}}a(x,"findPluginsArray");function y(n){let i=0,o=/^import\s/gm,l;for(;(l=o.exec(n))!==null;){let r=l.index,e=r+l[0].length,s=false,f=0;for(;e<n.length;){let t=n[e];if(s){t===s&&(s=false),e++;continue}if(t==='"'||t==="'"||t==="`"){s=t,e++;continue}if(t==="{"&&f++,t==="}"&&f--,t===";"&&f<=0){e++;break}if(t===`
|
|
9
|
+
`&&f<=0){let c=n.slice(r,e).trimEnd();if(c.endsWith('"')||c.endsWith("'"))break}e++;}i=e;}return i}a(y,"findLastImportEnd");function k(n){return w(n)?{complex:true,reason:"conditional defineConfig"}:/export\s+default\s+function/.test(n)?{complex:true,reason:"dynamic export (function)"}:/plugins\s*:\s*\[\s*\.\.\./.test(n)?{complex:true,reason:"spread operator in plugins array"}:/defineConfig\s*\(\s*async/.test(n)||/mergeConfig\s*\(/.test(n)?{complex:true,reason:"async or merged config"}:{complex:false}}a(k,"isComplexConfig");async function P(n){let i;try{i=await readFile(n,"utf-8");}catch{return {modified:false,error:"could not read config file"}}if(m(i))return {modified:false};let o=k(i);if(o.complex)return {modified:false,error:`config too complex (${o.reason})`};let l=d(i),r=x(i);if(r){let f=p(r.inner);f.push("knarr()");let t=h(f,l);i=i.slice(0,r.start)+t+i.slice(r.end);}else {let t=/(?:defineConfig\s*\(\s*\{|export\s+default\s+\{)/.exec(i);if(t){let c=t.index+t[0].length,b=`
|
|
10
|
+
${l}plugins: [knarr()],`;i=i.slice(0,c)+b+i.slice(c);}else return {modified:false,error:"unrecognized Vite config pattern"}}let e=`import knarr from "knarr/vite";
|
|
11
|
+
`,s=y(i);return s>0?i=i.slice(0,s)+`
|
|
12
|
+
`+e+i.slice(s):i=e+`
|
|
13
|
+
`+i,await B(n,i),{modified:true}}a(P,"addKnarrVitePlugin");async function R(n){let i;try{i=await readFile(n,"utf-8");}catch{return {modified:false}}if(!m(i))return {modified:false};let o=false,l=/^import\s+\w+\s+from\s+["']knarr\/vite["'];?\s*\n?/m;l.test(i)&&(i=i.replace(l,""),o=true);let r=x(i);if(r){let e=p(r.inner),s=e.filter(f=>!f.startsWith("knarr("));if(s.length!==e.length){let f=d(i),t=h(s,f);i=i.slice(0,r.start)+t+i.slice(r.end),o=true;}}return o&&await B(n,i),{modified:o}}a(R,"removeFromViteConfig");export{k as a,P as b,R as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {b}from'./chunk-Z22BYXWQ.mjs';import {g,s,f,A as A$1,a as a$1,c,d,x,e}from'./chunk-23HXXAGG.mjs';import {b as b$1}from'./chunk-B3DZ5HVQ.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$1=g(t,r);try{let a=await readFile(s$1,"utf-8"),e=JSON.parse(a);return b(e)?e:(b$1.warn(`Invalid metadata for ${t}@${r}, ignoring`),null)}catch(a){return s(a)&&a.code!=="ENOENT"&&b$1.warn(`Failed to read metadata for ${t}@${r}: ${a instanceof Error?a.message:String(a)}`),null}}a(y,"readMeta");async function j(t,r){let s=f(t,r),a=await y(t,r);return !a||!await A$1(s)?null:{name:t,version:r,packageDir:s,meta:a}}a(j,"getStoreEntry");async function A(t){let r=a$1();if(!await A$1(r))return null;let s=c(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(A,"findStoreEntry");async function J(){let t=a$1();if(!await A$1(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(J,"listStoreEntries");async function W(t,r){await x(e(t,r));}a(W,"removeStoreEntry");export{y as a,j as b,A as c,J as d,W as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {d}from'./chunk-NBSJGM2X.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile,stat}from'fs/promises';import {join,resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
async function S(s){let t=[],n;try{n=await readFile(join(s,"package.json"),"utf-8");}catch{return t.push({code:"NO_PACKAGE_JSON",severity:"error",message:"No package.json found"}),t}let e;try{e=JSON.parse(n);}catch{return t.push({code:"INVALID_PACKAGE_JSON",severity:"error",message:"package.json is not valid JSON"}),t}let i=e.files;if((!i||i.length===0)&&t.push({code:"EMPTY_FILES",severity:"warn",message:'No "files" field in package.json \u2014 npm will include almost everything. Consider adding a "files" field to control what gets published.'}),typeof e.main=="string"&&await r(s,e.main,"main",t),typeof e.module=="string"&&await r(s,e.module,"module",t),typeof e.types=="string"?await r(s,e.types,"types",t):typeof e.typings=="string"&&await r(s,e.typings,"typings",t),typeof e.exports=="string"?await r(s,e.exports,"exports",t):e.exports&&typeof e.exports=="object"&&await P(s,e.exports,t),typeof e.bin=="string")await r(s,e.bin,"bin",t);else if(e.bin&&typeof e.bin=="object")for(let[f,c]of Object.entries(e.bin))typeof c=="string"&&await r(s,c,`bin.${f}`,t);return d(`[preflight] ${t.length} issue(s) found in ${s}`),t}a(S,"runPreflightChecks");async function l(s){try{return (await stat(s)).isFile()}catch{return false}}a(l,"fileExists");async function r(s,t,n,e){let i=resolve(s,t);await l(i)||e.push({code:"MISSING_PATH",severity:"warn",message:`"${n}" points to "${t}" which does not exist`});}a(r,"checkPath");async function P(s,t,n){for(let[e,i]of Object.entries(t))if(typeof i=="string"){if(i.startsWith(".")){let f=resolve(s,i);await l(f)||n.push({code:"EXPORTS_PATH_MISSING",severity:"warn",message:`exports["${e}"] points to "${i}" which does not exist`});}}else i&&typeof i=="object"&&await h(s,e,i,n);}a(P,"checkExports");async function h(s,t,n,e){let i=Object.keys(n),f=i.indexOf("types"),c=i.indexOf("import"),g=i.indexOf("require"),y=i.indexOf("default");if(f!==-1){let d=Math.min(c===-1?1/0:c,g===-1?1/0:g,y===-1?1/0:y);f>d&&d!==1/0&&e.push({code:"TYPES_CONDITION_ORDER",severity:"warn",message:`exports["${t}"].types should come before import/require/default for TypeScript to resolve it correctly`});}for(let[d,o]of Object.entries(n))if(typeof o=="string"&&o.startsWith(".")){let m=resolve(s,o);await l(m)||e.push({code:"EXPORTS_PATH_MISSING",severity:"warn",message:`exports["${t}"].${d} points to "${o}" which does not exist`});}else o&&typeof o=="object"&&await h(s,t,o,e);}a(h,"checkExportsConditions");export{S as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$1}from'./chunk-U5ZZAYNU.mjs';import {B}from'./chunk-23HXXAGG.mjs';import {a}from'./chunk-2VCW5RWI.mjs';import {readFile}from'fs/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
function g(e){return e.match(/^(\s+)\S/m)?.[1]||" "}a(g,"detectIndent");function x(e){let r=[],t=/['"]([^'"]*)['"]/g,n;for(;(n=t.exec(e))!==null;)r.push(n[1]);return r}a(x,"parseArrayItems");function w(e,r){return e.length===0?"[]":e.length<=3?`[${e.map(n=>`'${n}'`).join(", ")}]`:`[
|
|
4
|
+
${e.map(n=>`${r}${r}'${n}',`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
${r}]`}a(w,"formatArray");function y(e){let r=a$1(e);return r.complex?r:/(?:module\.exports\s*=\s*|export\s+default\s+)[\w.]+\s*\(\s*\{/.test(e)?{complex:true,reason:"wrapper function pattern"}:/\w+\s*\(\s*\w+\s*\(/.test(e)&&e.includes("module.exports")?{complex:true,reason:"chained wrapper functions"}:{complex:false}}a(y,"isComplexNextConfig");async function b(e,r){let t;try{t=await readFile(e,"utf-8");}catch{return {modified:false,error:"could not read config file"}}let n=y(t);if(n.complex)return {modified:false,error:`config too complex (${n.reason})`};let c=g(t),l=/transpilePackages\s*:\s*\[([^\]]*)\]/s,f=l.exec(t);if(f){let s=x(f[1]);if(s.includes(r))return {modified:false};s.push(r);let i=w(s,c),a=t.replace(l,`transpilePackages: ${i}`);return await B(e,a),{modified:true}}let p=[/module\.exports\s*=\s*\{/,/export\s+default\s+\{/,/(?:const|let|var)\s+\w*[Cc]onfig\w*\s*=\s*\{/];for(let s of p){let i=s.exec(t);if(i){let a=i.index+i[0].length,h=`
|
|
7
|
+
${c}transpilePackages: ['${r}'],`,$=t.slice(0,a)+h+t.slice(a);return await B(e,$),{modified:true}}}return {modified:false,error:"unrecognized config pattern"}}a(b,"addToTranspilePackages");async function A(e,r){let t;try{t=await readFile(e,"utf-8");}catch{return {modified:false}}let n=g(t),c=/transpilePackages\s*:\s*\[([^\]]*)\]/s,l=c.exec(t);if(!l)return {modified:false};let f=x(l[1]),p=f.filter(a=>a!==r);if(p.length===f.length)return {modified:false};let s=w(p,n),i=t.replace(c,`transpilePackages: ${s}`);return await B(e,i),{modified:true}}a(A,"removeFromTranspilePackages");export{b as a,A as b};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {e,b as b$2}from'./chunk-HQ7NKBQW.mjs';import {q,m,s,A,x as x$1,y,v,l,D,n}from'./chunk-23HXXAGG.mjs';import {b,d}from'./chunk-NBSJGM2X.mjs';import {b as b$1}from'./chunk-B3DZ5HVQ.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 W(e){return e.bin?typeof e.bin=="string"?{[e.name.startsWith("@")?e.name.split("/")[1]:e.name]:e.bin}:e.bin:{}}a(W,"resolveBinEntries");async function F(e,n,i){let r=W(i);if(Object.keys(r).length===0)return 0;if(b()){for(let o of Object.keys(r))q({type:"bin-link",path:join(e,"node_modules",".bin",o),detail:n});return d(`[dry-run] would create ${Object.keys(r).length} bin link(s) for ${n}`),Object.keys(r).length}let t=join(e,"node_modules",".bin");await mkdir(t,{recursive:true});let s$1=platform()==="win32",a=0;for(let[o,g]of Object.entries(r)){let l=join(e,"node_modules",n),f=join(l,g),R=resolve(f);if(!R.startsWith(resolve(l)+sep)&&R!==resolve(l)){b$1.warn(`bin "${o}" points outside package directory, skipping`);continue}let $=m(relative(t,f));if(s$1){let b=join(t,`${o}.cmd`),O=`@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%\\${$.replace(/\//g,"\\")}" %*\r
|
|
11
|
+
`;await writeFile(b,O);let Y=join(t,`${o}.ps1`),q=`#!/usr/bin/env pwsh
|
|
12
|
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
13
|
+
& node "$basedir/${$}" $args
|
|
14
|
+
exit $LASTEXITCODE
|
|
15
|
+
`;await writeFile(Y,q);let K=join(t,o),Q=`#!/bin/sh
|
|
16
|
+
exec node "${$}" "$@"
|
|
17
|
+
`;await writeFile(K,Q);}else {let b=join(t,o);try{await rm(b,{force:!0});}catch{}try{await symlink($,b),await chmod(f,493);}catch(w){if(s(w)&&(w.code==="EPERM"||w.code==="EACCES")){d(`[bin-linker] Symlink failed (${w.code}), using shell wrapper for ${o}`);let O=`#!/bin/sh
|
|
18
|
+
exec node "${$}" "$@"
|
|
19
|
+
`;await writeFile(b,O),await chmod(b,493);}else throw w}}a++;}return a}a(F,"createBinLinks");async function H(e,n){let i=W(n);if(b()){for(let s of Object.keys(i))q({type:"bin-unlink",path:join(e,"node_modules",".bin",s)});d(`[dry-run] would remove ${Object.keys(i).length} bin link(s)`);return}let r=join(e,"node_modules",".bin"),t=platform()==="win32";for(let s of Object.keys(i))try{await rm(join(r,s),{force:!0}),t&&(await rm(join(r,`${s}.cmd`),{force:!0}),await rm(join(r,`${s}.ps1`),{force:!0}));}catch{}}a(H,"removeBinLinks");var te={next:[".next/cache"],webpack:["node_modules/.cache"]},X=new Map;async function z(e$1){if(b()){d(`[dry-run] would invalidate bundler caches for ${e$1}`),q({type:"cache-invalidate",path:e$1});return}let n=X.get(e$1);n||(n=await e(e$1),X.set(e$1,n));for(let i of n){if(!i.type)continue;let r=te[i.type];if(r)for(let t of r){let s=join(e$1,t);if(await A(s))try{await x$1(s),d(`[inject] Invalidated ${i.type} cache: ${t}`);}catch{d(`[inject] Could not clear ${i.type} cache: ${t} (locked?)`);}}}}a(z,"invalidateBundlerCache");async function Ie(e,n,i,r={}){let t=await x(n,e.name,i,e.version);d(`[inject] ${e.name}@${e.version} \u2192 ${t}`),await y(t);let{copied:s,removed:a,skipped:o}=await v(e.packageDir,t,{force:r.force});d(`[inject] ${s} copied, ${a} removed, ${o} skipped`),(s>0||a>0)&&await z(n);let g=await M(e.packageDir),l=g?await F(n,e.name,g):0;return l>0&&d(`[inject] Created ${l} bin link(s)`),{copied:s,removed:a,skipped:o,binLinks:l}}a(Ie,"inject");async function Ne(e,n,i){let r=await x(e,n,i);if(!await A(r))return false;let t=l(e,n);return await x$1(t),await D(r,t),true}a(Ne,"backupExisting");async function Te(e,n,i){let r=l(e,n);if(!await A(r))return false;let t=await x(e,n,i);return await x$1(t),await D(r,t),await x$1(r),true}a(Te,"restoreBackup");async function Le(e,n,i){let r=await x(e,n,i),t=await M(r);t&&await H(e,t),await x$1(r);}a(Le,"removeInjected");async function Je(e,n){let i=await M(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 t=Object.keys(r);return (await Promise.all(t.map(async a=>({dep:a,installed:await A(join(n,"node_modules",a))})))).filter(a=>!a.installed).map(a=>a.dep)}a(Je,"checkMissingDeps");async function x(e,n$1,i,r){let t=n(e,n$1);if(!(i==="pnpm"||i==="yarn"&&await b$2(e)==="pnpm"))return t;try{let o=await se(t);if(o!==resolve(t))return d(`[inject] pnpm: resolved symlink \u2192 ${o}`),o}catch(o){s(o)&&o.code!=="ENOENT"&&b$1.debug(`pnpm symlink resolution error: ${o instanceof Error?o.message:String(o)}`);}let a=join(e,"node_modules",".pnpm");if(await A(a)){d(`[inject] pnpm: scanning .pnpm/ for ${n$1}`);let o=n$1.replaceAll("/","+");if(r){let l=`${o}@${r}`,f=join(a,l,"node_modules",n$1);if(await A(f))return d(`[inject] pnpm: exact version match in .pnpm/ \u2192 ${f}`),f}let g=await readdir(a);for(let l of g)if(l.startsWith(o+"@")){let f=join(a,l,"node_modules",n$1);if(await A(f))return d(`[inject] pnpm: found in .pnpm/ \u2192 ${f}`),f}}return b$1.warn(`pnpm: Could not find ${n$1} in .pnpm/ virtual store, using direct node_modules path. If this causes issues, run 'pnpm install' to rebuild the virtual store, then 'knarr add' again.`),t}a(x,"resolveTargetDir");async function se(e){try{return await stat(e),await realpath(e)}catch(n){if(s(n)&&n.code==="ENOENT")return resolve(e);throw n}}a(se,"resolveRealPath");async function M(e){try{let n=await readFile(join(e,"package.json"),"utf-8");return JSON.parse(n)}catch(n){return s(n)&&n.code!=="ENOENT"&&b$1.warn(`Failed to read package.json in ${e}: ${n instanceof Error?n.message:String(n)}`),null}}a(M,"readPackageJson");export{Ie as a,Ne as b,Te as c,Le as d,Je as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {q,s}from'./chunk-23HXXAGG.mjs';import {b}from'./chunk-NBSJGM2X.mjs';import {b as b$1}from'./chunk-B3DZ5HVQ.mjs';import {a as a$1}from'./chunk-2VCW5RWI.mjs';import {mkdir,stat,rm,readFile}from'fs/promises';import {dirname,join}from'path';import {setTimeout}from'timers/promises';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var a={retries:5,minTimeout:100,maxTimeout:1e3,factor:2,stale:3e4};async function C(r,t,n){if(b())return q({type:"lock-skip",path:r}),t();await mkdir(dirname(r),{recursive:true});let e=r+".lk",c=n?.stale??a.stale,s$1=false;for(let i=0;i<=a.retries;i++)try{await mkdir(e),s$1=!0;break}catch(u){if(s(u)&&u.code==="EEXIST"){try{let f=await stat(e);if(Date.now()-f.mtimeMs>c){await rm(e,{recursive:!0,force:!0});continue}}catch{continue}if(i<a.retries){let f=Math.min(a.minTimeout*a.factor**i,a.maxTimeout);await setTimeout(f);}}else throw u}if(!s$1)throw new Error(`Failed to acquire lock after ${a.retries} attempts. Another Knarr process may be running. If this persists, delete ${e} and retry.`);try{return await t()}finally{await rm(e,{recursive:true,force:true});}}a$1(C,"withFileLock");function F(r){if(typeof r!="object"||r===null)return false;let t=r;return typeof t.contentHash=="string"&&typeof t.publishedAt=="string"&&typeof t.sourcePath=="string"&&(t.buildId===void 0||typeof t.buildId=="string")&&(t.schemaVersion===void 0||typeof t.schemaVersion=="number")}a$1(F,"isKnarrMeta");function M(r){if(typeof r!="object"||r===null)return false;let t=r;return typeof t.version=="string"&&typeof t.contentHash=="string"&&typeof t.linkedAt=="string"&&typeof t.sourcePath=="string"&&typeof t.backupExists=="boolean"&&typeof t.packageManager=="string"&&["npm","pnpm","yarn","bun"].includes(t.packageManager)&&(t.buildId===void 0||typeof t.buildId=="string")}a$1(M,"isLinkEntry");function K(r){if(typeof r!="object"||r===null)return false;let t=r;if(t.version!=="1"||typeof t.links!="object"||t.links===null)return false;let n=t.links;for(let e of Object.values(n))if(!M(e))return false;return true}a$1(K,"isConsumerState");async function O(r,t,n){try{let e=await readFile(join(r,"package.json"),"utf-8"),c=JSON.parse(e),s=c.dependencies?.[t]??c.devDependencies?.[t]??c.peerDependencies?.[t];if(!s||/^(workspace:|catalog:|\*)/.test(s))return;let i=s.match(/(\d+)\.\d+\.\d+/);if(!i)return;let u=parseInt(i[1],10),f=parseInt(n.split(".")[0],10);u!==f&&b$1.warn(`Version mismatch: store has ${t}@${n} but your package.json declares "${s}". Consider updating your dependency range.`);}catch{}}a$1(O,"warnVersionMismatch");function P(r){if(typeof r!="object"||r===null)return false;let t=r;for(let n of Object.values(t)){if(!Array.isArray(n))return false;for(let e of n)if(typeof e!="string")return false}return true}a$1(P,"isConsumersRegistry");export{C as a,F as b,K as c,O as d,P as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$2}from'./chunk-2GDRDQA5.mjs';import {d as d$1,e}from'./chunk-V2ED74ZQ.mjs';import {a}from'./chunk-MBKCCWSD.mjs';import {b,a as a$3}from'./chunk-BS4VKVYH.mjs';import'./chunk-7HVPEBK5.mjs';import {k,g,b as b$2}from'./chunk-OLUZ7T7G.mjs';import'./chunk-Z22BYXWQ.mjs';import {m,a as a$1,A,C,x,r}from'./chunk-23HXXAGG.mjs';import {d,b as b$3}from'./chunk-NBSJGM2X.mjs';import {b as b$1}from'./chunk-B3DZ5HVQ.mjs';import'./chunk-2VCW5RWI.mjs';import {readdir}from'fs/promises';import {join}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var ne={meta:{name:"clean",description:"Remove unreferenced store entries and stale consumer registrations"},args:{yes:{type:"boolean",alias:"y",description:"Skip confirmation prompts",default:false}},async run({args:A$1}){b();let y=new a;b$1.start("Checking consumer registrations...");let{removedConsumers:l,removedPackages:v}=await k();l>0&&b$1.success(`Removed ${l} stale consumer registration(s) across ${v} package(s)`);let $=await g(),f=new Set,F=[...new Set(Object.values($).flat())],w=await Promise.all(F.map(async e=>{let{state:t,reliable:o}=await b$2(e);return {path:e,state:t,reliable:o}}));for(let{state:e,reliable:t}of w)if(t)for(let[o,g]of Object.entries(e.links))f.add(`${o}@${g.version}`);let d$2=new Set,u=w.filter(e=>!e.reliable);if(u.length>0){b$1.warn(`${u.length} consumer(s) have corrupt state; their store entries will be preserved`);let e=new Set(u.map(t=>m(t.path)));for(let[t,o]of Object.entries($))o.some(g=>e.has(g))&&d$2.add(t);d(`[clean] Protected packages (corrupt state): ${[...d$2].join(", ")}`);}d(`[clean] Referenced entries: ${[...f].join(", ")||"(none)"}`);let H=await d$1(),s=[];for(let e of H){let t=`${e.name}@${e.version}`;if(!f.has(t)){if(d$2.has(e.name)){d(`[clean] Preserving ${t} (consumer state unreadable)`);continue}let o=Date.now()-new Date(e.meta.publishedAt).getTime();if(o<300*1e3){d(`[clean] Skipping recently published entry: ${t} (${Math.round(o/1e3)}s old)`);continue}s.push(e);}}let n=[],p=a$1();if(await A(p)){let e=await readdir(p,{withFileTypes:true});for(let t of e)t.isDirectory()&&(t.name.includes(".tmp-")||t.name.includes(".old-"))&&n.push(t.name);}if(s.length+n.length>0&&!A$1.yes){let e=[];s.length>0&&e.push(`${s.length} unreferenced store entry(ies)`),n.length>0&&e.push(`${n.length} orphaned temp directory(ies)`);let t=await b$1.prompt(`Remove ${e.join(" and ")}?`,{type:"confirm"});if(!t||typeof t=="symbol"){b$1.info("Cancelled");return}}let a$4=0,q=await Promise.all(s.map(e=>C(e.packageDir))),G=await Promise.all(n.map(e=>C(join(p,e)))),m$1=0;for(let e$1=0;e$1<s.length;e$1++){let t=s[e$1];d(`[clean] Removing unreferenced store entry: ${t.name}@${t.version}`),await e(t.name,t.version),a$4+=q[e$1],m$1++;}m$1>0&&b$1.success(`Removed ${m$1} unreferenced store entry(ies)`);let c=0;for(let e=0;e<n.length;e++)d(`[clean] Removing orphaned directory: ${n[e]}`),await x(join(p,n[e])),a$4+=G[e],c++;c>0&&b$1.success(`Removed ${c} orphaned temp directory(ies)`),l===0&&m$1===0&&c===0&&b$1.info("Store is clean; no stale entries or registrations found");let I=a$4>0?` (reclaimed ${a$2(a$4)})`:"";b$1.info(`Clean complete in ${y.elapsed()}${I}`),a$3({removedConsumers:l,removedPackages:v,removedEntries:m$1,removedOrphans:c,reclaimedBytes:a$4,elapsed:y.elapsedMs()}),b$3()&&r();}};export{ne as default};
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$4}from'./chunk-7HVPEBK5.mjs';import {a as a$3}from'./chunk-NBSJGM2X.mjs';import {a as a$1,b as b$1}from'./chunk-B3DZ5HVQ.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 _=`
|
|
4
|
+
_ __
|
|
5
|
+
| |/ /_ __ __ _ _ __ _ __
|
|
6
|
+
| ' /| '_ \\ / _\` | '__| '__|
|
|
7
|
+
| . \\| | | | (_| | | | |
|
|
8
|
+
|_|\\_\\_| |_|\\__,_|_| |_|
|
|
9
|
+
`;function s(){console.log(o.default.yellow(_)),console.log(o.default.cyan(" Local npm package development without symlinks")),console.log(o.default.dim(` Copies built files into consumer node_modules with incremental sync
|
|
10
|
+
`));}a$2(s,"showBanner");process.env.UV_THREADPOOL_SIZE??=String(Math.max(availableParallelism(),8));a$3();var a=process.argv.slice(2),b=["init","publish","add","use","remove","push","dev","restore","list","status","update","clean","gc","doctor","migrate","reset","rollback","check"],u=a.some(e=>!e.startsWith("-")&&b.includes(e)),v=a.includes("--help")||a.includes("-h")||a.includes("--version");if(!u&&!v&&process.stdin.isTTY){s();let e=await g();e&&process.argv.splice(2,0,e);}else u||s();async function g(){try{let{readConsumerStateSafe:c}=await import('./tracker-R4ZZIDJV.mjs'),{resolve:p}=await import('path'),{state:d}=await c(p(".")),n=Object.keys(d.links).length;n>0&&b$1.info(`${n} package(s) linked in this project`);}catch{}return await b$1.prompt("What would you like to do?",{type:"select",options:[{label:"init - Set up knarr in this project",value:"init"},{label:"publish - Publish package to the knarr store",value:"publish"},{label:"add - Link a package from the store",value:"add"},{label:"use - Link a local package path",value:"use"},{label:"push - Publish and push to all consumers",value:"push"},{label:"dev - Watch, rebuild, and push continuously",value:"dev"},{label:"list - Show linked packages",value:"list"},{label:"status - Show project status",value:"status"},{label:"help - Show help",value:"--help"}]})||null}a$2(g,"showInteractiveMenu");var k={meta:{name:"knarr",version:"0.0.1",description:"Local npm package development - copies built files into consumer node_modules"},args:{verbose:{type:"boolean",alias:"v",description:"Enable verbose debug logging",default:false},"dry-run":{type:"boolean",description:"Preview changes without writing files",default:false},json:{type:"boolean",description:"Output machine-readable JSON",default:false}},subCommands:{init:a$2(()=>import('./init-OBJFQ6OB.mjs').then(e=>e.default),"init"),publish:a$2(()=>import('./publish-Q4JYQPQP.mjs').then(e=>e.default),"publish"),add:a$2(()=>import('./add-ODK52RZI.mjs').then(e=>e.default),"add"),use:a$2(()=>import('./use-NKLXGPIZ.mjs').then(e=>e.default),"use"),remove:a$2(()=>import('./remove-PDERBH66.mjs').then(e=>e.default),"remove"),push:a$2(()=>import('./push-NHCPN6MO.mjs').then(e=>e.default),"push"),dev:a$2(()=>import('./dev-7L35BV6M.mjs').then(e=>e.default),"dev"),restore:a$2(()=>import('./restore-YGPO42W4.mjs').then(e=>e.default),"restore"),list:a$2(()=>import('./list-AQKUBZ2I.mjs').then(e=>e.default),"list"),status:a$2(()=>import('./status-3VUPPR5D.mjs').then(e=>e.default),"status"),update:a$2(()=>import('./update-QPBWYDSG.mjs').then(e=>e.default),"update"),clean:a$2(()=>import('./clean-XMLDIZDZ.mjs').then(e=>e.default),"clean"),gc:a$2(()=>import('./clean-XMLDIZDZ.mjs').then(e=>e.default),"gc"),doctor:a$2(()=>import('./doctor-4TTAYNGW.mjs').then(e=>e.default),"doctor"),migrate:a$2(()=>import('./migrate-7B7ACQHY.mjs').then(e=>e.default),"migrate"),reset:a$2(()=>import('./reset-3FXWAAPQ.mjs').then(e=>e.default),"reset"),rollback:a$2(()=>import('./rollback-FKNGLGFC.mjs').then(e=>e.default),"rollback"),check:a$2(()=>import('./check-YVEJEI2G.mjs').then(e=>e.default),"check")}};a$4(k);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {a as a$1}from'./chunk-7DZPDPP6.mjs';import'./chunk-SYADAYF4.mjs';import {a,e,b as b$1,c}from'./chunk-FU7FCNTW.mjs';import'./chunk-IM555H3S.mjs';import'./chunk-V2ED74ZQ.mjs';import'./chunk-YZCBBQCH.mjs';import'./chunk-TEFMLGCB.mjs';import'./chunk-7JG555TZ.mjs';import'./chunk-HQ7NKBQW.mjs';import'./chunk-MBKCCWSD.mjs';import {b}from'./chunk-BS4VKVYH.mjs';import'./chunk-7HVPEBK5.mjs';import'./chunk-OLUZ7T7G.mjs';import'./chunk-Z22BYXWQ.mjs';import'./chunk-2EZDTBUU.mjs';import'./chunk-3KNUBUPH.mjs';import {r}from'./chunk-23HXXAGG.mjs';import {b as b$2}from'./chunk-NBSJGM2X.mjs';import'./chunk-B3DZ5HVQ.mjs';import {a as a$2}from'./chunk-2VCW5RWI.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
|
|
3
|
+
var W={meta:{name:"dev",description:"Watch, rebuild, and push to all consumers. Auto-detects build command."},args:{all:{type:"boolean",description:"Watch all workspace packages in dependency order",default:false},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},force:{type:"boolean",alias:"f",description:"Force copy all files, bypassing hash comparison",default:false},notify:{type:"boolean",description:"Ring terminal bell on push completion",default:false},"no-cascade":{type:"boolean",description:"Disable cascading rebuilds in --all mode",default:false}},async run({args:e$1}){b();let o=resolve("."),m=await a(o),t={runScripts:!e$1["no-scripts"],force:e$1.force,historyLimit:m.historyLimit};if(e$1.all)await a$1(o,t),await e(o,e$1,t);else {let i=a$2(()=>b$1(o,t),"push");if(await i(),b$2()){r();return}await c(o,e$1,i);}}};export{W as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';import {d,b as b$4}from'./chunk-V2ED74ZQ.mjs';import {a as a$2,b as b$5,c as c$1,d as d$1}from'./chunk-HQ7NKBQW.mjs';import {b,a as a$3}from'./chunk-BS4VKVYH.mjs';import'./chunk-7HVPEBK5.mjs';import {g,b as b$3}from'./chunk-OLUZ7T7G.mjs';import'./chunk-Z22BYXWQ.mjs';import {a as a$1,A,b as b$2}from'./chunk-23HXXAGG.mjs';import'./chunk-NBSJGM2X.mjs';import {a,b as b$1}from'./chunk-B3DZ5HVQ.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 z={meta:{name:"doctor",description:"Run diagnostic checks on your Knarr setup"},async run(){b();let n=resolve("."),s=[];b$1.info(`Running Knarr diagnostics...
|
|
4
|
+
`);let m=a$1();if(await A(m)){let e=await d();s.push({name:"Store directory",status:"pass",message:`${e.length} entries in ${m}`});}else s.push({name:"Store directory",status:"warn",message:`Store not found at ${m}. Run 'knarr publish' to create it.`});let _=b$2();if(await A(_)){let e=await g(),a=Object.values(e).flat().length;s.push({name:"Global registry",status:"pass",message:`${Object.keys(e).length} packages, ${a} consumer registrations`});}else s.push({name:"Global registry",status:"warn",message:"No consumers registered yet. Use 'knarr add' to link packages."});let{state:x,reliable:A$1}=await b$3(n);A$1||s.push({name:"Consumer state",status:"fail",message:"state.json is corrupt or unreadable. Delete .knarr/state.json and re-run 'knarr add' for each package."});let l=Object.entries(x.links);if(l.length>0){s.push({name:"Consumer state",status:"pass",message:`${l.length} linked package(s)`});for(let[e,a]of l){let u=await b$4(e,a.version);u?u.meta.contentHash!==a.contentHash?s.push({name:`Store: ${e}`,status:"warn",message:"Store has newer content. Run 'knarr update' to sync."}):s.push({name:`Store: ${e}`,status:"pass",message:`${e}@${a.version} in sync`}):s.push({name:`Store: ${e}`,status:"fail",message:`Store entry missing for ${e}@${a.version}. Re-publish it.`});let k=join(n,"node_modules",e);if(!await A(k))s.push({name:`node_modules: ${e}`,status:"fail",message:"Missing from node_modules. Run 'knarr restore'."});else try{let{readFile:F}=await import('fs/promises'),d=JSON.parse(await F(join(k,"package.json"),"utf-8"));d.version&&d.version!==a.version&&s.push({name:`node_modules: ${e}`,status:"warn",message:`node_modules has v${d.version} but Knarr linked v${a.version}. Run 'knarr restore'.`});}catch{}}}else s.push({name:"Consumer state",status:"warn",message:"No packages linked. Use 'knarr add' to link a package."});let f=await a$2(n);if(s.push({name:"Package manager",status:"pass",message:f}),f==="yarn"){let e=await b$5(n);await c$1(n)?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 (Knarr 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(n);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(n,".gitignore");if(await A(h)){let{readFile:e}=await import('fs/promises');(await e(h,"utf-8")).includes(".knarr")?s.push({name:".gitignore",status:"pass",message:".knarr/ is ignored"}):s.push({name:".gitignore",status:"warn",message:".knarr/ not in .gitignore. Run 'knarr 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}; Knarr 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 c=s.filter(e=>e.status==="fail").length,p=s.filter(e=>e.status==="warn").length;b$1.log(""),c>0?b$1.error(`${c} issue(s) found that need attention`):p>0?b$1.warn(`${p} warning(s), but no critical issues`):b$1.success("All checks passed!"),a$3({results:s.map(({name:e,status:a,message:u})=>({name:e,status:a,message:u})),failures:c,warnings:p});}};export{z as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';export{B as atomicWriteFile,u as collectFiles,D as copyDir,t as copyWithCoW,C as dirSize,y as ensureDir,z as ensurePrivateDir,A as exists,v as incrementalCopy,s as isNodeError,w as moveDir,x as removeDir}from'./chunk-23HXXAGG.mjs';import'./chunk-NBSJGM2X.mjs';import'./chunk-B3DZ5HVQ.mjs';import'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {createRequire}from'node:module';export{a as captureHistory,f as clearHistory,c as getHistoryEntry,b as listHistory,e as pruneHistory,g as resolveHistoryLimit,d as restoreHistoryEntry}from'./chunk-2QPLXLJW.mjs';import'./chunk-23HXXAGG.mjs';import'./chunk-NBSJGM2X.mjs';import'./chunk-B3DZ5HVQ.mjs';import'./chunk-2VCW5RWI.mjs';globalThis.require=createRequire(import.meta.url);
|