@visulima/vis 1.0.0-alpha.10 → 1.0.0-alpha.11

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 (120) hide show
  1. package/CHANGELOG.md +95 -42
  2. package/LICENSE.md +213 -0
  3. package/README.md +8 -4
  4. package/dist/bin.js +9 -1
  5. package/dist/config/index.d.ts +1818 -0
  6. package/dist/config/index.js +2 -0
  7. package/dist/generate/index.d.ts +1 -1
  8. package/dist/generate/index.js +3 -1
  9. package/dist/packem_chunks/applyDefaults.js +336 -0
  10. package/dist/packem_chunks/bin.js +9554 -64
  11. package/dist/packem_chunks/doctor-probe.js +112 -0
  12. package/dist/packem_chunks/fix.js +229 -48
  13. package/dist/packem_chunks/handler.js +99 -1
  14. package/dist/packem_chunks/handler10.js +53 -1
  15. package/dist/packem_chunks/handler11.js +32 -1
  16. package/dist/packem_chunks/handler12.js +100 -2
  17. package/dist/packem_chunks/handler13.js +25 -1
  18. package/dist/packem_chunks/handler14.js +916 -5
  19. package/dist/packem_chunks/handler15.js +206 -1
  20. package/dist/packem_chunks/handler16.js +122 -18
  21. package/dist/packem_chunks/handler17.js +13 -1
  22. package/dist/packem_chunks/handler18.js +106 -1
  23. package/dist/packem_chunks/handler19.js +19 -1
  24. package/dist/packem_chunks/handler2.js +75 -1
  25. package/dist/packem_chunks/handler20.js +29 -1
  26. package/dist/packem_chunks/handler21.js +222 -1
  27. package/dist/packem_chunks/handler22.js +237 -5
  28. package/dist/packem_chunks/handler23.js +101 -1
  29. package/dist/packem_chunks/handler24.js +110 -1
  30. package/dist/packem_chunks/handler25.js +402 -5
  31. package/dist/packem_chunks/handler26.js +13 -1
  32. package/dist/packem_chunks/handler27.js +63 -3
  33. package/dist/packem_chunks/handler28.js +34 -1
  34. package/dist/packem_chunks/handler29.js +458 -7
  35. package/dist/packem_chunks/handler3.js +95 -2
  36. package/dist/packem_chunks/handler30.js +168 -21
  37. package/dist/packem_chunks/handler31.js +530 -3
  38. package/dist/packem_chunks/handler32.js +214 -2
  39. package/dist/packem_chunks/handler33.js +119 -24
  40. package/dist/packem_chunks/handler34.js +630 -2
  41. package/dist/packem_chunks/handler35.js +283 -19
  42. package/dist/packem_chunks/handler36.js +521 -407
  43. package/dist/packem_chunks/handler37.js +762 -22
  44. package/dist/packem_chunks/handler38.js +989 -22
  45. package/dist/packem_chunks/handler39.js +574 -22
  46. package/dist/packem_chunks/handler4.js +90 -4
  47. package/dist/packem_chunks/handler40.js +1685 -3
  48. package/dist/packem_chunks/handler41.js +1088 -10
  49. package/dist/packem_chunks/handler42.js +785 -141
  50. package/dist/packem_chunks/handler43.js +2658 -42
  51. package/dist/packem_chunks/handler44.js +3886 -3
  52. package/dist/packem_chunks/handler45.js +2568 -21
  53. package/dist/packem_chunks/handler46.js +3769 -0
  54. package/dist/packem_chunks/handler47.js +1491 -0
  55. package/dist/packem_chunks/handler5.js +174 -2
  56. package/dist/packem_chunks/handler6.js +95 -13
  57. package/dist/packem_chunks/handler7.js +115 -8
  58. package/dist/packem_chunks/handler8.js +12 -1
  59. package/dist/packem_chunks/handler9.js +29 -1
  60. package/dist/packem_chunks/heal-accept.js +522 -0
  61. package/dist/packem_chunks/heal.js +673 -0
  62. package/dist/packem_chunks/index.js +873 -7
  63. package/dist/packem_chunks/loader.js +23 -1
  64. package/dist/packem_shared/VisUpdateApp-D-Yz_wvg.js +1316 -0
  65. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  66. package/dist/packem_shared/ai-analysis-CHeB1joD.js +367 -0
  67. package/dist/packem_shared/ai-cache-Be_jexe4.js +142 -0
  68. package/dist/packem_shared/ai-fix-B9iQVcD2.js +379 -0
  69. package/dist/packem_shared/cache-directory-2qvs4goY.js +98 -0
  70. package/dist/packem_shared/catalog-BJTtyi-O.js +1371 -0
  71. package/dist/packem_shared/dependency-scan-A0KSklpG.js +188 -0
  72. package/dist/packem_shared/docker-2iZzc280.js +181 -0
  73. package/dist/packem_shared/failure-log-Cz3Z4SKL.js +100 -0
  74. package/dist/packem_shared/flakiness-goTxXuCX.js +180 -0
  75. package/dist/packem_shared/otel-DCvqCTz_.js +158 -0
  76. package/dist/packem_shared/otelPlugin-DFaLDvJf.js +3 -0
  77. package/dist/packem_shared/registry-CbqXI0rc.js +272 -0
  78. package/dist/packem_shared/run-summary-utils-PVMl4aIh.js +130 -0
  79. package/dist/packem_shared/runtime-check-Cobi3p6l.js +127 -0
  80. package/dist/packem_shared/selectors-SM69TfqC.js +194 -0
  81. package/dist/packem_shared/symbols-Ta7g2nU-.js +14 -0
  82. package/dist/packem_shared/toolchain-BdZd9eBi.js +975 -0
  83. package/dist/packem_shared/typosquats-C-bCh3PX.js +1210 -0
  84. package/dist/packem_shared/use-measured-height-CNP0vT4M.js +20 -0
  85. package/dist/packem_shared/utils-CthVdBPS.js +40 -0
  86. package/dist/packem_shared/xxh3-Ck8mXNg1.js +239 -0
  87. package/index.js +727 -555
  88. package/package.json +35 -17
  89. package/schemas/project.schema.json +8 -10
  90. package/schemas/vis-config.schema.json +132 -8
  91. package/skills/vis/SKILL.md +96 -0
  92. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  93. package/templates/buildkite-ci/template.yml +20 -0
  94. package/dist/errors/index.d.ts +0 -26
  95. package/dist/errors/index.js +0 -1
  96. package/dist/packem_chunks/config.js +0 -2
  97. package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +0 -1
  98. package/dist/packem_shared/VisConfigError-B5LP1zRf.js +0 -1
  99. package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +0 -2
  100. package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +0 -5
  101. package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +0 -1
  102. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +0 -1
  103. package/dist/packem_shared/ai-analysis-CGuy7dfE.js +0 -67
  104. package/dist/packem_shared/ai-cache-Bynt6Y9x.js +0 -1
  105. package/dist/packem_shared/cache-directory-D72ZEag2.js +0 -1
  106. package/dist/packem_shared/catalog-BVPerCwG.js +0 -12
  107. package/dist/packem_shared/dependency-scan-Du0tBu64.js +0 -2
  108. package/dist/packem_shared/docker-BcfqH4Av.js +0 -2
  109. package/dist/packem_shared/failure-log-DqYen0LC.js +0 -2
  110. package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
  111. package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +0 -1
  112. package/dist/packem_shared/runtime-check-CGHal8SO.js +0 -1
  113. package/dist/packem_shared/selectors-CfH9ZY08.js +0 -3
  114. package/dist/packem_shared/symbols-CQmER5MT.js +0 -1
  115. package/dist/packem_shared/target-merge-DNa-6eWu.js +0 -1
  116. package/dist/packem_shared/toolchain-DQfTQY8E.js +0 -5
  117. package/dist/packem_shared/typosquats-DOR8izpX.js +0 -1
  118. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
  119. package/dist/packem_shared/utils-DrNg0XTR.js +0 -1
  120. package/dist/packem_shared/xxh3-DrAUNq4n.js +0 -1
@@ -1,19 +1,283 @@
1
- var ne=Object.defineProperty;var v=(t,e)=>ne(t,"name",{value:e,configurable:!0});import{createRequire as ie}from"node:module";import{dim as l,bold as b,cyan as S}from"@visulima/colorize";import{join as k,isAbsolute as C,relative as z,sep as ce,dirname as le,resolve as fe}from"@visulima/path";import{isAccessibleSync as D,walkSync as J,ensureDirSync as Q,writeFileSync as pe}from"@visulima/fs";import{downloadTemplate as ge}from"giget";import{p as f}from"./bin.js";const ae=ie(import.meta.url),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=v(t=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[e,r]=j.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return j.getBuiltinModule(t)}return ae(t)},"__cjs_getBuiltinModule"),{createInterface:ue}=I("node:readline"),{mkdtempSync:de,rmSync:me}=I("node:fs"),{tmpdir:he}=I("node:os"),{spawnSync:we}=I("node:child_process");var $e=Object.defineProperty,w=v((t,e)=>$e(t,"name",{value:e,configurable:!0}),"i");const X=[".ts",".mts",".cts",".js",".mjs",".cjs"],ye="template.yml",ve=[".d",".test",".spec",".config",".bench",".stories"],be=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Z=w(t=>{for(const e of X)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Se=w(t=>{if(be.some(r=>t.endsWith(r))||!X.some(r=>t.endsWith(r)))return!1;const e=Z(t);return!ve.some(r=>e.endsWith(r))},"isNativeFile"),U=w((t,e)=>{const r=[];if(!D(t))return r;for(const s of J(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Se(s.name))continue;const o=Z(s.name);r.push({load:w(()=>Te(s.path),"load"),name:o,path:s.path,source:e})}return r},"scanNativeDirectory"),M=w((t,e)=>{const r=[];if(!D(t))return r;for(const s of J(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const o=k(s.path,ye);D(o)&&r.push({load:w(()=>Oe(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),q=w(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,o=[];o.push(...U(k(s,".vis","templates"),"native")),o.push(...M(k(s,".vis","templates"),"moon")),o.push(...M(k(s,".moon","templates"),"moon"));for(const n of e)o.push(...M(n,"config")),o.push(...U(n,"config"));const a=new Map;for(const n of o){const i=a.get(n.name);if(!i){a.set(n.name,n);continue}r&&r(`Template "${n.name}" exists in multiple sources — using ${i.source} (${i.path}), ignoring ${n.source} (${n.path}).`)}return[...a.values()].sort((n,i)=>n.name.localeCompare(i.name))},"discoverTemplates"),Te=w(async t=>{const{loadNativeTemplate:e}=await import("./loader.js");return e(t)},"loadNativeFromPath"),Oe=w(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var ke=Object.defineProperty,g=v((t,e)=>ke(t,"name",{value:e,configurable:!0}),"c");const W=g((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),Re=g(async(t,e,r)=>{const s=await W(t,` ${e} ${l(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),Ee=g(async(t,e,r,s)=>{process.stderr.write(` ${e}
2
- `);for(const[o,a]of r.entries()){const n=b(S(` ${String(o+1)}.`)),i=a===s?l(" (default)"):"";process.stderr.write(`${n} ${a}${i}
3
- `)}for(;;){const o=await W(t,`
4
- ${l(`Enter choice (1-${String(r.length)}):`)} `);if(o===""&&s!==void 0)return s;const a=Number.parseInt(o,10);if(Number.isInteger(a)&&a>=1&&a<=r.length)return r[a-1];const n=r.find(i=>i===o);if(n)return n;process.stderr.write(` ${l("Invalid choice. Try again.")}
5
- `)}},"selectOne"),Ne=g(async(t,e,r,s)=>{process.stderr.write(` ${e} ${l("(comma-separated numbers)")}
6
- `);for(const[o,a]of r.entries()){const n=b(S(` ${String(o+1)}.`)),i=s.includes(a)?l(" (default)"):"";process.stderr.write(`${n} ${a}${i}
7
- `)}for(;;){const o=await W(t,`
8
- ${l("Enter choices:")} `);if(o===""&&s.length>0)return s;const a=o.split(",").map(n=>Number.parseInt(n.trim(),10)).filter(n=>Number.isInteger(n)&&n>=1&&n<=r.length);if(a.length>0)return a.map(n=>r[n-1]);process.stderr.write(` ${l("Invalid choice. Try again.")}
9
- `)}},"selectMany"),je=g(t=>` ${l(`${t}:`)} `,"promptText"),xe=g((t,e)=>e.prompt??t,"variableLabel"),_e=g(t=>Object.entries(t).sort(([e,r],[s,o])=>{const a=r.order??0,n=o.order??0;return a!==n?a-n:e.localeCompare(s)}),"sortVariables"),Y=g((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),F=g((t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const o of s)if(typeof o!="string"||!e.values.includes(o))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(o)}")`)}},"validateValue"),Pe=g(async t=>{const{defaults:e,interactive:r,overrides:s,variables:o}=t,a={},n=r?ue({input:process.stdin,output:process.stderr}):null;try{for(const[i,c]of _e(o)){if(Object.hasOwn(s,i)){const h=Y(c,s[i]??"");F(i,c,h),a[i]=h;continue}if(e||!r||c.internal){if(c.default!==void 0){F(i,c,c.default),a[i]=c.default;continue}if(c.required)throw new Error(`Required variable "${i}" not provided. Pass --${i}=<value> or remove --defaults.`);continue}const m=xe(i,c);let p;if(c.type==="boolean")p=await Re(n,m,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const h=Array.isArray(c.default)?c.default:[];p=await Ne(n,m,c.values,h)}else{const h=typeof c.default=="string"?c.default:void 0;p=await Ee(n,m,c.values,h)}else{const h=c.default===void 0?"":` (${String(c.default)})`,$=await W(n,je(`${m}${h}`));if($===""&&c.default!==void 0)p=c.default;else if($===""){if(c.required)throw new Error(`Variable "${i}" is required`);continue}else p=Y(c,$)}F(i,c,p),a[i]=p}return a}finally{n?.close()}},"collectOptions");var De=Object.defineProperty,L=v((t,e)=>De(t,"name",{value:e,configurable:!0}),"o");const Ie=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],We=L(t=>Ie.some(e=>t.startsWith(e)),"isRemoteSource"),Be=L(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??de(k(he(),"vis-generate-")),o=L(()=>{if(r)try{me(s,{force:!0,recursive:!0})}catch{}},"cleanup");f.info(`Downloading ${t}…`);try{const a=await ge(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:o,directory:a.dir}}catch(a){o();const n=a instanceof Error?a.message:String(a);throw f.warn(`Failed to download template: ${n}`),a}},"fetchRemoteTemplate");var Ae=Object.defineProperty,T=v((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const ee=T((t,e="")=>{const r=[];for(const[s,o]of Object.entries(t)){const a=e?`${e}/${s}`:s;typeof o=="string"||Buffer.isBuffer(o)?r.push({content:o,path:a}):o&&typeof o=="object"&&r.push(...ee(o,a))}return r},"flattenTree"),Me=T(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),qe=T((t,e)=>{if(C(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=k(t,e),s=z(t,r);if(s===".."||s.startsWith(`..${ce}`)||C(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Fe=T((t,e)=>{Q(le(t)),pe(t,e)},"writeOne"),Ce=T((t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,o=typeof t=="string"?r:t.silent??r;for(const a of s){o||f.info(`$ ${a}`);const n=we(a,{cwd:e,shell:!0,stdio:o?"ignore":"inherit"});if(n.status!==0)return f.warn(`Script failed (exit ${String(n.status)}): ${a}`),!1}return!0},"runScript"),Le=T(t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,o=e.get(s);o?o.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},"groupByPhase"),Ve=T(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:z(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),o=s.files?ee(s.files):[],a=s.filesMeta??{},n=[];for(const i of o){const c=qe(e.destination,i.path);n.push({file:i,meta:a[i.path]??{},target:c})}if(e.dryRun){f.info(`${b(S("Plan"))} ${l("(dry-run, no files written)")}`);for(const i of n){const c=Buffer.isBuffer(i.file.content)?i.file.content.length:Buffer.byteLength(i.file.content,"utf8");process.stderr.write(` ${l("write")} ${i.file.path} ${l(`(${Me(c)})`)}
10
- `)}}else{Q(e.destination);let i=0,c=0;for(const m of n){const{file:p,meta:h,target:$}=m,B=D($),y=e.force||h.force===!0;if(B&&!y){f.warn(`Skipped existing file: ${p.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Fe($,p.content),i+=1}f.success(`Wrote ${String(i)} file${i===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const i=Le(s.scripts);f.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(i.length)} phase${i.length===1?"":"s"}…`);for(const[,c]of i)if((await Promise.all(c.map(m=>Promise.resolve(Ce(m,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
11
- `),f.notice("Next steps:");for(const i of s.suggestions)process.stderr.write(` ${l("•")} ${i}
12
- `)}},"runTemplate");var Ge=Object.defineProperty,R=v((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"p");const He=R(t=>{if(t.length===0){f.info("No templates found."),f.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}f.info("Available templates:");for(const e of t){const r=l(`(${e.source})`);process.stderr.write(` ${b(S(e.name))} ${r}
13
- `)}},"printList"),Ke=R(t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const o=s.indexOf("=");if(o===-1){const i=s.slice(2);i.startsWith("no-")?e[i.slice(3)]="false":e[i]="true";continue}const a=s.slice(2,o),n=s.slice(o+1);e[a]=n}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),Ue=R(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${b(S("vis generate"))} ${l("— pick a template")}
14
-
15
- `);for(const[s,o]of t.entries()){const a=b(S(` ${String(s+1)}.`));process.stderr.write(`${a} ${o.name} ${l(`(${o.source})`)}
16
- `)}return new Promise((s,o)=>{r.question(`
17
- ${l(`Enter choice (1-${String(t.length)}):`)} `,a=>{const n=Number.parseInt(a.trim(),10);Number.isInteger(n)&&n>=1&&n<=t.length?s(t[n-1].name):o(new Error("Invalid choice."))})})}finally{r.close()}},"pickInteractive"),tt=R(async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:o})=>{const a=e.cwd||o||process.cwd(),n=o??a,i=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const d=q({extraDirectories:i?.templates??[],onWarning:R(u=>{f.warn(u)},"onWarning"),workspaceRoot:n});He(d);return}let m=[...r??[]];if(m.length===0){const d=process.argv.slice(2),u=d.indexOf("--");u!==-1&&(m=d.slice(u+1))}const p=c.indexOf("--"),h=p===-1?[]:c.slice(p+1),$=p===-1?c:c.slice(0,p),{overrides:B}=Ke([...h,...m]);let y,x,_;const E=$[0];let P;if(E&&We(E)){const d=await Be(E,{auth:i?.auth,preferOffline:!!e.preferOffline||i?.preferOffline});P=d.cleanup;try{const u=q({extraDirectories:[d.directory],workspaceRoot:n}).find(N=>N.path.startsWith(d.directory));if(!u)throw new Error(`Downloaded template at ${d.directory} contains no template.yml or *.ts entrypoint.`);y=await u.load(),x=u.name,_=y.destination}catch(u){throw P(),P=void 0,u}}else{const d=q({extraDirectories:i?.templates??[],onWarning:R(A=>{f.warn(A)},"onWarning"),workspaceRoot:n});if(d.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let u;if(E)u=E;else{if(e.noInteractive||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");u=await Ue(d)}const N=d.find(A=>A.name===u);if(!N)throw new Error(`Template "${u}" not found. Run 'vis generate --list' to see available templates.`);y=await N.load(),x=N.name,_=y.destination}const V=e.to,G=!!e.dryRun,te=!!e.force,H=!!e.defaults,re=!!e.skipScripts,se=!e.noInteractive&&!!process.stdin.isTTY&&!H;let O;V?O=V:_?O=_:O=".";const K=C(O)?O:fe(a,O);f.info(`Template: ${b(S(x))}`),f.info(`Target: ${l(K)}`),process.stderr.write(`
18
- `);const oe=await Pe({defaults:H,interactive:se,overrides:B,variables:y.options??{}});try{await Ve(y,{cwd:a,destination:K,dryRun:G,force:te,options:oe,skipScripts:re,workspaceRoot:n}),G||(process.stderr.write(`
19
- `),f.success(`Template '${x}' applied.`))}finally{P?.()}},"execute");export{tt as default};
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ import { L as migrateDeps, M as printSummary, N as migrateLintStaged, O as migrateNanoStaged, P as migrateTurborepo, Q as migrateNx, R as migrateMoon, T as migrateGitleaks, U as migrateKingfisher, V as migrateSecretlint, W as createMigrationReport, X as detectPackageManager } from './bin.js';
21
+ const {
22
+ stdin,
23
+ stdout
24
+ } = __cjs_getProcess;
25
+ const {
26
+ createInterface
27
+ } = __cjs_getBuiltinModule("node:readline/promises");
28
+ import { isAccessibleSync, readFileSync } from '@visulima/fs';
29
+ import { join } from '@visulima/path';
30
+
31
+ const confirm = async (question) => {
32
+ if (!stdin.isTTY) {
33
+ return true;
34
+ }
35
+ const rl = createInterface({ input: stdin, output: stdout });
36
+ try {
37
+ const answer = (await rl.question(`${question} [Y/n] `)).trim().toLowerCase();
38
+ if (answer === "" || answer === "y" || answer === "yes") {
39
+ return true;
40
+ }
41
+ return false;
42
+ } finally {
43
+ rl.close();
44
+ }
45
+ };
46
+
47
+ const HOOK_CANDIDATES = [".husky/pre-commit", ".vis-hooks/pre-commit", ".git/hooks/pre-commit"];
48
+ const SECRETLINT_CONFIG_FILES = [
49
+ ".secretlintrc",
50
+ ".secretlintrc.json",
51
+ ".secretlintrc.js",
52
+ ".secretlintrc.mjs",
53
+ ".secretlintrc.cjs",
54
+ ".secretlintrc.yml",
55
+ ".secretlintrc.yaml"
56
+ ];
57
+ const scanPackageJson = (root) => {
58
+ const packageJsonPath = join(root, "package.json");
59
+ if (!isAccessibleSync(packageJsonPath)) {
60
+ return [];
61
+ }
62
+ let pkg;
63
+ try {
64
+ pkg = JSON.parse(readFileSync(packageJsonPath));
65
+ } catch {
66
+ return [];
67
+ }
68
+ const issues = [];
69
+ if (pkg.scripts) {
70
+ for (const [name, value] of Object.entries(pkg.scripts)) {
71
+ if (typeof value !== "string") {
72
+ continue;
73
+ }
74
+ if (/\bgitleaks\b/.test(value)) {
75
+ issues.push({ detail: `Script "${name}" still invokes gitleaks: ${value}`, kind: "script", location: "package.json" });
76
+ }
77
+ if (/\bsecretlint\b/.test(value)) {
78
+ issues.push({ detail: `Script "${name}" still invokes secretlint: ${value}`, kind: "script", location: "package.json" });
79
+ }
80
+ }
81
+ }
82
+ if (pkg.devDependencies) {
83
+ for (const dep of Object.keys(pkg.devDependencies)) {
84
+ if (dep === "gitleaks" || dep === "@gitleaks/cli") {
85
+ issues.push({ detail: `devDependency \`${dep}\` is still installed`, kind: "devDep", location: "package.json" });
86
+ }
87
+ if (dep === "secretlint" || dep.startsWith("@secretlint/")) {
88
+ issues.push({ detail: `devDependency \`${dep}\` is still installed`, kind: "devDep", location: "package.json" });
89
+ }
90
+ }
91
+ }
92
+ return issues;
93
+ };
94
+ const scanHooks = (root) => {
95
+ const issues = [];
96
+ for (const rel of HOOK_CANDIDATES) {
97
+ const abs = join(root, rel);
98
+ if (!isAccessibleSync(abs)) {
99
+ continue;
100
+ }
101
+ const content = readFileSync(abs);
102
+ if (/\bgitleaks\b/.test(content)) {
103
+ issues.push({ detail: "gitleaks invocation still present in hook", kind: "hook", location: rel });
104
+ }
105
+ if (/\bsecretlint\b/.test(content)) {
106
+ issues.push({ detail: "secretlint invocation still present in hook", kind: "hook", location: rel });
107
+ }
108
+ }
109
+ return issues;
110
+ };
111
+ const scanConfigs = (root) => {
112
+ const issues = [];
113
+ for (const name of SECRETLINT_CONFIG_FILES) {
114
+ if (isAccessibleSync(join(root, name))) {
115
+ issues.push({ detail: "secretlint config should be removed after migration", kind: "config", location: name });
116
+ }
117
+ }
118
+ return issues;
119
+ };
120
+ const verifyMigration = (root, logger) => {
121
+ const issues = [...scanPackageJson(root), ...scanHooks(root), ...scanConfigs(root)];
122
+ if (issues.length === 0) {
123
+ logger.info("✓ No unmigrated gitleaks/secretlint references found.");
124
+ return [];
125
+ }
126
+ logger.warn(`Found ${String(issues.length)} unmigrated reference(s):`);
127
+ for (const issue of issues) {
128
+ logger.warn(` [${issue.kind}] ${issue.location} — ${issue.detail}`);
129
+ }
130
+ return issues;
131
+ };
132
+
133
+ const buildContext = (toolbox) => {
134
+ const root = toolbox.workspaceRoot ?? process.cwd();
135
+ return {
136
+ config: toolbox.visConfig ?? {},
137
+ dryRun: Boolean(toolbox.options.dryRun),
138
+ logger: toolbox.logger,
139
+ packageManager: detectPackageManager(root),
140
+ report: createMigrationReport(),
141
+ root
142
+ };
143
+ };
144
+ const maybeConfirm = async (name, options, logger) => {
145
+ if (options.yes || options.dryRun) {
146
+ return true;
147
+ }
148
+ const confirmed = await confirm(`This will edit files, scripts, and hooks for "${name}". Backups (.bak) will be created. Continue?`);
149
+ if (!confirmed) {
150
+ logger.info("Aborted.");
151
+ }
152
+ return confirmed;
153
+ };
154
+ const announceDryRun = (ctx) => {
155
+ if (ctx.dryRun) {
156
+ ctx.logger.info("Running in dry-run mode — no changes will be made.\n");
157
+ }
158
+ };
159
+ const migrateDepsExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
160
+ if (!await maybeConfirm("deps", options, logger)) {
161
+ return;
162
+ }
163
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
164
+ announceDryRun(ctx);
165
+ logger.info("── Migrating dependencies and scripts ──");
166
+ migrateDeps(
167
+ ctx.root,
168
+ ctx.packageManager,
169
+ ctx.config,
170
+ { dryRun: ctx.dryRun },
171
+ logger,
172
+ ctx.report
173
+ );
174
+ logger.info("");
175
+ printSummary(ctx.report, logger);
176
+ };
177
+ const migrateLintStagedExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
178
+ if (!await maybeConfirm("lint-staged", options, logger)) {
179
+ return;
180
+ }
181
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
182
+ announceDryRun(ctx);
183
+ logger.info("── Migrating lint-staged ──");
184
+ migrateLintStaged(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
185
+ logger.info("");
186
+ printSummary(ctx.report, logger);
187
+ };
188
+ const migrateNanoStagedExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
189
+ if (!await maybeConfirm("nano-staged", options, logger)) {
190
+ return;
191
+ }
192
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
193
+ announceDryRun(ctx);
194
+ logger.info("── Migrating nano-staged ──");
195
+ migrateNanoStaged(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
196
+ logger.info("");
197
+ printSummary(ctx.report, logger);
198
+ };
199
+ const migrateTurborepoExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
200
+ if (!await maybeConfirm("turborepo", options, logger)) {
201
+ return;
202
+ }
203
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
204
+ announceDryRun(ctx);
205
+ logger.info("── Migrating turborepo ──");
206
+ migrateTurborepo(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
207
+ logger.info("");
208
+ printSummary(ctx.report, logger);
209
+ };
210
+ const migrateNxExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
211
+ if (!await maybeConfirm("nx", options, logger)) {
212
+ return;
213
+ }
214
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
215
+ announceDryRun(ctx);
216
+ logger.info("── Migrating nx ──");
217
+ migrateNx(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
218
+ logger.info("");
219
+ printSummary(ctx.report, logger);
220
+ };
221
+ const migrateMoonExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
222
+ if (!await maybeConfirm("moon", options, logger)) {
223
+ return;
224
+ }
225
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
226
+ announceDryRun(ctx);
227
+ logger.info("── Migrating moon ──");
228
+ migrateMoon(ctx.root, { copyTemplates: Boolean(options.copyTemplates), dryRun: ctx.dryRun }, logger, ctx.report);
229
+ logger.info("");
230
+ printSummary(ctx.report, logger);
231
+ };
232
+ const migrateGitleaksExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
233
+ if (!await maybeConfirm("gitleaks", options, logger)) {
234
+ return;
235
+ }
236
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
237
+ announceDryRun(ctx);
238
+ logger.info("── Migrating gitleaks ──");
239
+ migrateGitleaks(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
240
+ logger.info("");
241
+ printSummary(ctx.report, logger);
242
+ };
243
+ const migrateKingfisherExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
244
+ if (!await maybeConfirm("kingfisher", options, logger)) {
245
+ return;
246
+ }
247
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
248
+ announceDryRun(ctx);
249
+ logger.info("── Migrating Kingfisher ──");
250
+ migrateKingfisher(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
251
+ logger.info("");
252
+ printSummary(ctx.report, logger);
253
+ };
254
+ const migrateSecretlintExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
255
+ if (!await maybeConfirm("secretlint", options, logger)) {
256
+ return;
257
+ }
258
+ const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
259
+ announceDryRun(ctx);
260
+ logger.info("── Migrating secretlint ──");
261
+ migrateSecretlint(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
262
+ logger.info("");
263
+ printSummary(ctx.report, logger);
264
+ };
265
+ const migrateVerifyExecuteImpl = ({ logger, workspaceRoot }) => {
266
+ const root = workspaceRoot ?? process.cwd();
267
+ const issues = verifyMigration(root, logger);
268
+ if (issues.length > 0) {
269
+ process.exitCode = 1;
270
+ }
271
+ };
272
+ const migrateDepsExecute = migrateDepsExecuteImpl;
273
+ const migrateLintStagedExecute = migrateLintStagedExecuteImpl;
274
+ const migrateNanoStagedExecute = migrateNanoStagedExecuteImpl;
275
+ const migrateTurborepoExecute = migrateTurborepoExecuteImpl;
276
+ const migrateNxExecute = migrateNxExecuteImpl;
277
+ const migrateMoonExecute = migrateMoonExecuteImpl;
278
+ const migrateGitleaksExecute = migrateGitleaksExecuteImpl;
279
+ const migrateKingfisherExecute = migrateKingfisherExecuteImpl;
280
+ const migrateSecretlintExecute = migrateSecretlintExecuteImpl;
281
+ const migrateVerifyExecute = migrateVerifyExecuteImpl;
282
+
283
+ export { migrateDepsExecute, migrateGitleaksExecute, migrateKingfisherExecute, migrateLintStagedExecute, migrateMoonExecute, migrateNanoStagedExecute, migrateNxExecute, migrateSecretlintExecute, migrateTurborepoExecute, migrateVerifyExecute };