knarr 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +66 -107
  2. package/dist/add-B_xzUp5y.mjs +3 -0
  3. package/dist/add-flow-cvrMO_aV.mjs +5 -0
  4. package/dist/batch-push-DXtZxRx0.mjs +3 -0
  5. package/dist/build-detect-BTHh2OBm.mjs +3 -0
  6. package/dist/bundler-detect-Dq-QAbQj.mjs +3 -0
  7. package/dist/check-CbVdpTsw.mjs +3 -0
  8. package/dist/chokidar-BkIWf7Ix.mjs +3 -0
  9. package/dist/clean-CyDDqbBD.mjs +3 -0
  10. package/dist/cli.mjs +4 -4
  11. package/dist/config-BJsL6NqN.mjs +4 -0
  12. package/dist/console-CIiXr7ge.mjs +3 -0
  13. package/dist/console-CyaBcUd-.mjs +98 -0
  14. package/dist/dev-kqgY9NjI.mjs +3 -0
  15. package/dist/dist-CFkjiIqD.mjs +7 -0
  16. package/dist/doctor-D-S1P0UG.mjs +6 -0
  17. package/dist/dry-run-BkdMYSIx.mjs +3 -0
  18. package/dist/errors-BlOfexcH.mjs +3 -0
  19. package/dist/explain-9Y4SZHjC.mjs +3 -0
  20. package/dist/format-DRqD29u-.mjs +3 -0
  21. package/dist/fs-C4juVCTd.mjs +3 -0
  22. package/dist/fs-CPnWm9CR.mjs +3 -0
  23. package/dist/fs-DzsciYAL.mjs +757 -0
  24. package/dist/hints-Hz3V4h3A.mjs +3 -0
  25. package/dist/history-DRhLwzhq.mjs +3 -0
  26. package/dist/history-vS3w4EGu.mjs +3 -0
  27. package/dist/index.d.ts +249 -264
  28. package/dist/index.mjs +3426 -4668
  29. package/dist/init-TN84d5jM.mjs +4 -0
  30. package/dist/init-helpers-CYYWQm-P.mjs +15 -0
  31. package/dist/injector-nt40JxVt.mjs +3 -0
  32. package/dist/json-DbSkpxtr.mjs +3 -0
  33. package/dist/list-9hWJjw19.mjs +3 -0
  34. package/dist/logger-9C6B9Na8.mjs +3 -0
  35. package/dist/migrate-Co4qcFt6.mjs +5 -0
  36. package/dist/nextjs-config-BQgTWZ96.mjs +3 -0
  37. package/dist/nextjs-config-dUw2J6B9.mjs +4 -0
  38. package/dist/output-BxR2v-jn.mjs +3 -0
  39. package/dist/package-manager-DJ8CE0zL.mjs +13 -0
  40. package/dist/picomatch-B0_Pxgms.mjs +3 -0
  41. package/dist/preflight-BDsxR2Ct.mjs +3 -0
  42. package/dist/preflight-MzNjLXiy.mjs +3 -0
  43. package/dist/publish-C7ZUvHkE.mjs +3 -0
  44. package/dist/publisher-CvXTbkLP.mjs +4 -0
  45. package/dist/push-B5KrkILW.mjs +3 -0
  46. package/dist/push-engine-BpNr8qXR.mjs +3 -0
  47. package/dist/remove-DkOgVQMZ.mjs +3 -0
  48. package/dist/remove-J5tY_BFk.mjs +3 -0
  49. package/dist/reset-ClGouUb5.mjs +3 -0
  50. package/dist/restore-Bx2V59SL.mjs +3 -0
  51. package/dist/rollback-RPjHZWtG.mjs +3 -0
  52. package/dist/rolldown-runtime-BZbIAPMk.mjs +3 -0
  53. package/dist/shell-RQ7Hf1kp.mjs +3 -0
  54. package/dist/status-Rnvw6dG2.mjs +3 -0
  55. package/dist/store-DjPdOKqg.mjs +3 -0
  56. package/dist/tailwind-source-D1cUiG-t.mjs +5 -0
  57. package/dist/timer-DqgB175x.mjs +3 -0
  58. package/dist/topo-sort-DOCpHjT7.mjs +3 -0
  59. package/dist/topo-sort-yd4jxr_E.mjs +3 -0
  60. package/dist/tracker-89eW0ArT.mjs +3 -0
  61. package/dist/tracker-B3Fqx94J.mjs +3 -0
  62. package/dist/update-CAKFICZu.mjs +3 -0
  63. package/dist/use-CCx6J0mc.mjs +3 -0
  64. package/dist/vite-config-BHmawlD2.mjs +12 -0
  65. package/dist/vite-config-BRlYc4ni.mjs +3 -0
  66. package/dist/vite-plugin.d.ts +6 -5
  67. package/dist/vite-plugin.mjs +206 -211
  68. package/dist/watch-orchestrator-BfuCaZLA.mjs +3 -0
  69. package/dist/watcher-T123sBDg.mjs +3 -0
  70. package/dist/webpack-plugin.d.ts +29 -30
  71. package/dist/webpack-plugin.mjs +140 -138
  72. package/dist/workspace-CdLSxPFS.mjs +3 -0
  73. package/dist/workspace-DBxNrowu.mjs +3 -0
  74. package/dist/xxhash-wasm-D_QjdUuv.mjs +3 -0
  75. package/package.json +23 -31
  76. package/dist/add-LQ6WMCGD.mjs +0 -3
  77. package/dist/bell-SIN4ERLS.mjs +0 -2
  78. package/dist/check-7CJHAF6Y.mjs +0 -6
  79. package/dist/chokidar-2G63V464.mjs +0 -4
  80. package/dist/chunk-3SXN6MQL.mjs +0 -4
  81. package/dist/chunk-7GCKCCHU.mjs +0 -3
  82. package/dist/chunk-BH2WXCLS.mjs +0 -4
  83. package/dist/chunk-CBOYKBSM.mjs +0 -13
  84. package/dist/chunk-E3HZCU3S.mjs +0 -5
  85. package/dist/chunk-G7HFTV5Y.mjs +0 -3
  86. package/dist/chunk-HVN6HBWZ.mjs +0 -3
  87. package/dist/chunk-ICU4V73X.mjs +0 -3
  88. package/dist/chunk-IP5ROSRE.mjs +0 -3
  89. package/dist/chunk-J6HZHQVL.mjs +0 -3
  90. package/dist/chunk-K6OAYJKS.mjs +0 -6
  91. package/dist/chunk-KRX4JX6V.mjs +0 -4
  92. package/dist/chunk-KUQULMM6.mjs +0 -3
  93. package/dist/chunk-L7O2RSTN.mjs +0 -3
  94. package/dist/chunk-M3TRMEJV.mjs +0 -3
  95. package/dist/chunk-MN4DV2NO.mjs +0 -3
  96. package/dist/chunk-N3B2JO4H.mjs +0 -13
  97. package/dist/chunk-NGPAGRK4.mjs +0 -7
  98. package/dist/chunk-NV3ASN6X.mjs +0 -3
  99. package/dist/chunk-OQDZJP55.mjs +0 -3
  100. package/dist/chunk-QEH5VHRO.mjs +0 -13
  101. package/dist/chunk-QFHYSC3K.mjs +0 -3
  102. package/dist/chunk-QHNHLR6T.mjs +0 -3
  103. package/dist/chunk-RIHOZDFW.mjs +0 -22
  104. package/dist/chunk-SMR4HT6A.mjs +0 -3
  105. package/dist/chunk-SPHWZS5P.mjs +0 -3
  106. package/dist/chunk-U6O35NZ7.mjs +0 -3
  107. package/dist/chunk-W2MMKBWU.mjs +0 -3
  108. package/dist/chunk-WBTSRLB6.mjs +0 -7
  109. package/dist/chunk-WN3DOKIM.mjs +0 -3
  110. package/dist/chunk-XDWZZBCM.mjs +0 -3
  111. package/dist/chunk-Z5K6DFA6.mjs +0 -3
  112. package/dist/clean-EJIYYQZM.mjs +0 -3
  113. package/dist/dev-WU5KB5PJ.mjs +0 -3
  114. package/dist/doctor-W2G34POC.mjs +0 -6
  115. package/dist/explain-LZLNIMVZ.mjs +0 -5
  116. package/dist/fs-NU36NNEG.mjs +0 -2
  117. package/dist/history-MLJHRV3Q.mjs +0 -2
  118. package/dist/init-SNG5LBZK.mjs +0 -7
  119. package/dist/list-4PTHMIQ4.mjs +0 -5
  120. package/dist/migrate-USY26Y5R.mjs +0 -8
  121. package/dist/nextjs-config-T5D6LOJE.mjs +0 -2
  122. package/dist/preflight-IXICTR6G.mjs +0 -2
  123. package/dist/publish-2IH7IQV4.mjs +0 -3
  124. package/dist/push-W3TM2QYK.mjs +0 -3
  125. package/dist/remove-MVQOIN2I.mjs +0 -2
  126. package/dist/reset-BTOJ54MJ.mjs +0 -3
  127. package/dist/restore-TWOOF2BN.mjs +0 -3
  128. package/dist/rollback-CFYSE5YG.mjs +0 -3
  129. package/dist/status-3ZXM3CRH.mjs +0 -4
  130. package/dist/tailwind-source-HCTY2XDU.mjs +0 -5
  131. package/dist/topo-sort-ZNGR6D7M.mjs +0 -2
  132. package/dist/tracker-QAKEXYUJ.mjs +0 -2
  133. package/dist/update-TGGCUOOO.mjs +0 -3
  134. package/dist/use-4Z5KXRVR.mjs +0 -3
  135. package/dist/vite-config-XOGAKYGQ.mjs +0 -2
  136. package/dist/watch-orchestrator-6BQYU5YS.mjs +0 -3
  137. package/dist/watcher-ES2APFH4.mjs +0 -3
  138. package/dist/workspace-T6PNO4L3.mjs +0 -2
  139. package/dist/xxhash-wasm-I6Q3T2SL.mjs +0 -3
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import"./rolldown-runtime-BZbIAPMk.mjs";import{existsSync as e}from"node:fs";import{delimiter as t,isAbsolute as n,join as r,relative as i}from"node:path";let a;function knarrCommand(n=process.env,i=process.platform){if(n===process.env&&a)return a;let o=n.PATH??n.Path??n.path??``,s=i===`win32`?[`knarr.cmd`,`knarr.exe`,`knarr.ps1`,`knarr`]:[`knarr`],c=i===`win32`?`;`:t,l=o.split(c).filter(Boolean).some(t=>s.some(n=>e(r(t,n))))?`knarr`:`npx knarr`;return n===process.env&&(a=l),l}function displayPath(e,t=process.cwd()){let r=i(t,e),a=r===``?`.`:!n(r)&&r.length<e.length?r:e;return/\s/.test(a)?`"${a}"`:a}function devLoopHint(e,t=process.cwd(),n){return n&&n!==e?`cd ${displayPath(n,t)} && ${knarrCommand()} dev --all`:`cd ${displayPath(e,t)} && ${knarrCommand()} dev`}export{knarrCommand as n,devLoopHint as t};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ export{t as captureHistory}from"./history-vS3w4EGu.mjs";
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import"./rolldown-runtime-BZbIAPMk.mjs";import{C as e,O as t,S as n,b as r,c as i,d as a,f as o,o as s,t as c}from"./fs-CPnWm9CR.mjs";import{i as l}from"./logger-9C6B9Na8.mjs";import{o as u}from"./json-DbSkpxtr.mjs";import{readFile as d,readdir as f}from"node:fs/promises";import{join as p}from"node:path";async function readMetaFile(e){let n=u(await d(e,`utf-8`));if(!t(n))throw Error(`Invalid build metadata: ${e}`);return n}async function captureHistory(t,n,u,d){let f=p(u,`.knarr-meta.json`),m;try{m=await readMetaFile(f)}catch{l(`[history] Could not read meta from ${f}, skipping history capture`);return}let h=m.buildId;if(!h){l(`[history] No buildId in meta, skipping history capture`);return}let g=e(t,n),_=r(t,n,h);if(await i(_)){l(`[history] Build ${h} already in history, skipping`);return}await s(g);let v=_+`.tmp-${process.pid}`;try{await s(v);let e=p(u,`package`);await i(e)&&await a(e,p(v,`package`)),await c(p(v,`.knarr-meta.json`),JSON.stringify(m,null,2)),await a(v,_),l(`[history] Captured build ${h} to history`)}catch(e){l(`[history] Failed to capture history: ${e instanceof Error?e.message:String(e)}`),await o(v)}await pruneHistory(t,n,d??3)}async function listHistory(t,n){let r=e(t,n);if(!await i(r))return[];let a;try{a=await f(r)}catch{return[]}let o=[];for(let e of a){let t=p(r,e),n=p(t,`.knarr-meta.json`);try{let r=await readMetaFile(n);o.push({buildId:r.buildId??e,contentHash:r.contentHash,publishedAt:r.publishedAt,sourcePath:r.sourcePath,packageDir:p(t,`package`)})}catch{}}return o.sort((e,t)=>new Date(t.publishedAt).getTime()-new Date(e.publishedAt).getTime()),o}async function getHistoryEntry(e,t,n){let i=r(e,t,n),a=p(i,`.knarr-meta.json`);try{let e=await readMetaFile(a);return{buildId:e.buildId??n,contentHash:e.contentHash,publishedAt:e.publishedAt,sourcePath:e.sourcePath,packageDir:p(i,`package`)}}catch{return null}}async function restoreHistoryEntry(e,t,u,f){let m=await getHistoryEntry(e,t,u);if(!m)return null;let h=n(e,t),g=r(e,t,u),_=p(g,`package`),v=p(g,`.knarr-meta.json`),y=await d(v,`utf-8`),b=p(h,`package`),x=p(h,`.knarr-meta.json`);if(!await i(_))throw Error(`History entry ${u} is missing its package directory`);let S=await d(x,`utf-8`).catch(()=>null),C=h+`.restore-old-${process.pid}-${Date.now()}`,w=p(C,`package`),T=!1,E=!1;try{if((await i(b)||S)&&(await s(C),await i(b)&&await a(b,w),S&&await c(p(C,`.knarr-meta.json`),S),T=!0),await a(_,b),E=!0,await c(x,y),await o(g),T)try{await captureHistory(e,t,C,f)}finally{await o(C)}}catch(e){throw E&&await i(b)?(await s(g),await a(b,_)):T&&await i(b)&&await o(b),T&&await i(w)&&await a(w,b),S&&await c(x,S),await o(C),e}return l(`[history] Restored build ${u} as current`),m}async function pruneHistory(e,t,n){if(n<0)return 0;let i=await listHistory(e,t);if(i.length<=n)return 0;let a=i.slice(n),s=0;for(let n of a){let i=r(e,t,n.buildId);try{await o(i),s++,l(`[history] Pruned old build ${n.buildId}`)}catch{}}return s}function resolveHistoryLimit(e){return e??3}export{resolveHistoryLimit as a,pruneHistory as i,getHistoryEntry as n,restoreHistoryEntry as o,listHistory as r,captureHistory as t};