@visulima/vis 1.0.0-alpha.23 → 1.0.0-alpha.25
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/CHANGELOG.md +88 -0
- package/LICENSE.md +1262 -151
- package/README.md +5 -3
- package/dashboard/dist/index.html +29 -29
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +27 -8
- package/dist/packem_chunks/bin.js +299 -290
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +2 -2
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +10 -10
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +2 -2
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +5 -5
- package/dist/packem_chunks/handler22.js +2 -2
- package/dist/packem_chunks/handler23.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler32.js +3 -3
- package/dist/packem_chunks/handler34.js +5 -26
- package/dist/packem_chunks/handler35.js +22 -5
- package/dist/packem_chunks/handler36.js +60 -21
- package/dist/packem_chunks/handler37.js +6 -61
- package/dist/packem_chunks/handler38.js +24 -6
- package/dist/packem_chunks/handler39.js +152 -707
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +10 -24
- package/dist/packem_chunks/handler41.js +25 -286
- package/dist/packem_chunks/handler42.js +707 -152
- package/dist/packem_chunks/handler43.js +24 -10
- package/dist/packem_chunks/handler44.js +322 -25
- package/dist/packem_chunks/handler45.js +46 -24
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +7 -7
- package/dist/packem_chunks/handler48.js +65 -53
- package/dist/packem_chunks/handler5.js +3 -3
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +6 -6
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +2 -2
- package/dist/packem_chunks/prune.js +3 -3
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/affected-shas-Dm7eqcI8.js +1 -0
- package/dist/packem_shared/{ai-analysis-B8pDCOuT.js → ai-analysis-Csn82p17.js} +1 -1
- package/dist/packem_shared/{ai-fix-DiGSrGKv.js → ai-fix-BlYyz5bI.js} +3 -3
- package/dist/packem_shared/{cyclonedx-B293T7R0.js → cyclonedx-D6F9rAay.js} +1 -1
- package/dist/packem_shared/dependency-scan-s2MD0vi-.js +1 -0
- package/dist/packem_shared/{docker-BhBBfWfc.js → docker-BU-7veP5.js} +1 -1
- package/dist/packem_shared/index-D9ZIw4ra.js +29 -0
- package/dist/packem_shared/index-PexbdLyT.js +1 -0
- package/dist/packem_shared/lifecycle-ChCFTm5Q.js +2 -0
- package/dist/packem_shared/{lockfile-CQLFNyVa.js → lockfile-BG1HvBzH.js} +1 -1
- package/dist/packem_shared/{min-release-age-Cz6HbF-I.js → min-release-age-heJgeP7o.js} +1 -1
- package/dist/packem_shared/peer-warnings-EvSJ18gE.js +1 -0
- package/dist/packem_shared/pm-runner-Cj76BV8q.js +1 -0
- package/dist/packem_shared/{provenance-BcldGs02.js → provenance-CdvMwB2R.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-2G-2HWtR.js → resolve-explicit-CRFybyxv.js} +1 -1
- package/dist/packem_shared/{s1ngularity-Boxkax0D.js → s1ngularity-CiZla5EP.js} +1 -1
- package/dist/packem_shared/{signatures-SO-fyExV.js → signatures-BsEDWhME.js} +1 -1
- package/dist/packem_shared/{typosquats-CioMnpnb.js → typosquats-_7T7U2q2.js} +1 -1
- package/dist/packem_shared/vis-update-app-qhQPV97i.js +1 -0
- package/index.js +52 -52
- package/package.json +14 -25
- package/schemas/project.schema.json +4 -0
- package/schemas/vis-config.schema.json +18 -13
- package/dist/packem_shared/dependency-scan-BbtivycX.js +0 -1
- package/dist/packem_shared/index-C1w1GXdS.js +0 -1
- package/dist/packem_shared/index-CZX_II5N.js +0 -29
- package/dist/packem_shared/lifecycle-wRE7ymVc.js +0 -2
- package/dist/packem_shared/pm-runner-CVliR6Ie.js +0 -1
- package/dist/packem_shared/vis-update-app-BWA1kA1q.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Fe=Object.defineProperty;var f=(e,t)=>Fe(e,"name",{value:t,configurable:!0});import{createRequire as Ne}from"node:module";import{a as He,M as re,z as B,i as oe,Q as
|
|
1
|
+
var Fe=Object.defineProperty;var f=(e,t)=>Fe(e,"name",{value:t,configurable:!0});import{createRequire as Ne}from"node:module";import{a as He,M as re,z as B,i as oe,Q as Se}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{x as $e}from"tinyexec";import{o as xe}from"../packem_shared/index-DH-5hsrC.js";import{jsx as b,jsxs as C}from"react/jsx-runtime";import{render as Ue}from"@visulima/tui";import{Box as M}from"@visulima/tui/components/box";import{Spinner as ze}from"@visulima/tui/components/spinner";import{Text as $}from"@visulima/tui/components/text";import{C as Ce,D as q,T as Ie}from"../packem_shared/symbols-CQmER5MT.js";import{E as I,I as Ve,e as ce,q as J,T as X}from"../packem_shared/index.server-B7ETiT4C.js";import{withEnhancedPath as We}from"@visulima/task-runner";const Ge=Ne(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=f(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[t,r]=F.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return F.getBuiltinModule(e)}return Ge(e)},"__cjs_getBuiltinModule"),{createRequire:_e}=z("node:module"),{readFileSync:De,writeFileSync:Be,unlinkSync:Le}=z("node:fs"),{randomBytes:qe}=z("node:crypto"),{availableParallelism:de}=z("node:os");var Ke=Object.defineProperty,Ye=f((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"u$4"),Qe=Object.defineProperty,Ee=Ye((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"c");const Je=_e(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=Ee(e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,r]=N.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return N.getBuiltinModule(e)}return Je(e)},"__cjs_getBuiltinModule"),Xe=ne("fs"),Ze=ne("os"),et=ne("path");var tt=Object.defineProperty,rt=Ee((e,t)=>tt(e,"name",{value:t,configurable:!0}),"a"),st=Object.defineProperty,V=rt((e,t)=>st(e,"name",{value:t,configurable:!0}),"s");const Me=V(e=>{let t="";for(let r=0;r<e.length;r+=1){const s=e[r],n=s.toUpperCase();t+=s===n?s.toLowerCase():n}return t},"invertCase"),Z=new Map,le=V((e,t)=>{const r=et.join(e,`.is-fs-case-sensitive-test-${process.pid}`);try{return t.writeFileSync(r,""),!t.existsSync(Me(r))}finally{try{t.unlinkSync(r)}catch{}}},"checkDirectoryCaseWithWrite"),nt=V((e,t,r)=>{try{return le(e,r)}catch(s){if(t===void 0)return le(Ze.tmpdir(),r);throw s}},"checkDirectoryCaseWithFallback"),at=V((e,t=Xe,r=!0)=>{const s=e??process.cwd();if(r&&Z.has(s))return Z.get(s);let n;const i=Me(s);return i!==s&&t.existsSync(s)?n=!t.existsSync(i):n=nt(s,e,t),r&&Z.set(s,n),n},"isFsCaseSensitive");var it=Object.defineProperty,ot=f((e,t)=>it(e,"name",{value:t,configurable:!0}),"s$3");class A extends Error{static{f(this,"StagedError")}static{ot(this,"StagedError")}constructor(t,r){super(t,r),this.name=this.constructor.name}}var ct=Object.defineProperty,dt=f((e,t)=>ct(e,"name",{value:t,configurable:!0}),"o$6");class lt extends A{static{f(this,"ApplyEmptyCommitError")}static{dt(this,"ApplyEmptyCommitError")}}var ut=Object.defineProperty,ft=f((e,t)=>ut(e,"name",{value:t,configurable:!0}),"o$5");class T extends A{static{f(this,"ConfigError")}static{ft(this,"ConfigError")}}var ht=Object.defineProperty,pt=f((e,t)=>ht(e,"name",{value:t,configurable:!0}),"t$1");class ue extends A{static{f(this,"GetBackupStashError")}static{pt(this,"GetBackupStashError")}}var gt=Object.defineProperty,mt=f((e,t)=>gt(e,"name",{value:t,configurable:!0}),"s$2");class D extends A{static{f(this,"GitError")}static{mt(this,"GitError")}stderr;constructor(t,r,s){super(t,s),this.stderr=r}}var wt=Object.defineProperty,vt=f((e,t)=>wt(e,"name",{value:t,configurable:!0}),"e");class fe extends A{static{f(this,"RestoreOriginalStateError")}static{vt(this,"RestoreOriginalStateError")}}var yt=Object.defineProperty,kt=f((e,t)=>yt(e,"name",{value:t,configurable:!0}),"o$2");class O extends A{static{f(this,"TaskError")}static{kt(this,"TaskError")}commandTitle;constructor(t,r,s){super(r,s),this.commandTitle=t}}var bt=Object.defineProperty,W=f((e,t)=>bt(e,"name",{value:t,configurable:!0}),"i");const Tt=W(async e=>{if(e.config!==void 0)return e.config;throw new T(`No staged config provided. Add \`staged\` to your vis.config.ts:
|
|
2
2
|
|
|
3
3
|
import { defineConfig } from "@visulima/vis/config";
|
|
4
4
|
|
|
@@ -6,16 +6,16 @@ var Fe=Object.defineProperty;var f=(e,t)=>Fe(e,"name",{value:t,configurable:!0})
|
|
|
6
6
|
staged: { "*.ts": "eslint --fix" },
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},"resolveConfig"),he=W(e=>{if(typeof e!="object"||e===null)throw new
|
|
9
|
+
Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},"resolveConfig"),he=W(e=>{if(typeof e!="object"||e===null)throw new T("Staged config must be an object mapping glob patterns to tasks.");const t=Object.entries(e);if(t.length===0)throw new T("Staged config is empty — at least one glob pattern is required.");for(const[r,s]of t){if(!r||r.trim()==="")throw new T("Staged config keys must be non-empty glob patterns.");Oe(r,s)}return e},"validateConfig"),Oe=W((e,t)=>{if(typeof t=="string"){if(t.trim()==="")throw new T(`Task for "${e}" is an empty string.`);return}if(Array.isArray(t)){if(t.length===0)throw new T(`Task array for "${e}" is empty.`);for(const r of t)Oe(e,r);return}if(typeof t!="function"&&!St(t))throw new T(`Invalid task for "${e}" — expected string, string[], function, or { title, task } object.`)},"validateTask"),St=W(e=>typeof e=="object"&&e!==null&&typeof e.title=="string"&&typeof e.task=="function","isCustomTask");var $t=Object.defineProperty,x=f((e,t)=>$t(e,"name",{value:t,configurable:!0}),"r$2");const pe=2048,g=x(async(e,t)=>{const r=t.input===void 0?void 0:typeof t.input=="string"?t.input:t.input.toString("utf8"),s=await $e("git",[...e],{nodeOptions:{cwd:t.cwd,env:t.env?{...process.env,...t.env}:void 0,stdio:r===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:r}),n=typeof s.exitCode=="number"?s.exitCode:1;if(n!==0&&!t.lenient){const{stderr:i}=s,o=i.length>pe?`${i.slice(0,pe)}…`:i;throw new D(`git ${e.join(" ")} failed with exit code ${n}: ${o.trim()}`,i)}return{exitCode:n,stderr:s.stderr,stdout:s.stdout}},"git"),R=x(async(e,t)=>{const{stdout:r}=await g(e,t);return r.trim()},"gitOut"),xt=x(async e=>{const t=await g(["rev-parse","--is-inside-work-tree"],{cwd:e,lenient:!0});return t.exitCode===0&&t.stdout.trim()==="true"},"isGitRepo"),Ct=x(async e=>R(["rev-parse","--absolute-git-dir"],{cwd:e}),"getGitDirectory"),je=x(async e=>R(["rev-parse","--show-toplevel"],{cwd:e}),"getWorkTree"),ge=x(async e=>R(["write-tree"],{cwd:e}),"writeIndexTree"),It=x(async e=>{const t=await g(["rev-parse","HEAD^{tree}"],{cwd:e,lenient:!0});return t.exitCode===0?t.stdout.trim():""},"headTreeSha"),G={major:2,minor:32},Et=x(e=>{const t=/git version (\d+)\.(\d+)/.exec(e);if(!t)return null;const r=Number.parseInt(t[1]??"",10),s=Number.parseInt(t[2]??"",10);return Number.isNaN(r)||Number.isNaN(s)?null:{major:r,minor:s}},"parseGitVersion"),Mt=x(async e=>{const t=Et(await R(["--version"],{cwd:e}));if(t!==null&&(t.major<G.major||t.major===G.major&&t.minor<G.minor))throw new D(`Git ${G.major}.${G.minor} or newer is required; found ${t.major}.${t.minor}.`)},"assertGitVersion");var Ot=Object.defineProperty,E=f((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"a$2");const jt="ACMR",me=500,At=E(async e=>{const{stdout:t}=await g(["diff-files","--raw","-z"],{cwd:e}),r=t.split("\0").filter(n=>n.length>0),s=[];for(let n=0;n<r.length;n+=1){const i=r[n];if(!i?.startsWith(":"))continue;const o=i.slice(1).split(" "),a=o[3],c=o[4],d=r[n+1];n+=1,c==="A"&&a!==void 0&&/^0+$/.test(a)&&d!==void 0&&s.push(d)}return s},"getIntentToAddPaths"),we=E(async e=>{const{stdout:t}=await g(["ls-files","--others","--exclude-standard","-z"],{cwd:e});return t.split("\0").filter(r=>r.length>0)},"getUntrackedFiles"),Pt=E(async(e,t)=>{if(e.length===0)return;const r=`${e.join("\0")}\0`;await g(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:t.cwd,input:r})},"removeFromIndex"),Rt=E(async e=>{const t=e.diffFilter??jt,r=e.diff===void 0?["diff","--name-only","-z",`--diff-filter=${t}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${t}`,...e.diff.split(/\s+/).filter(Boolean)],{stdout:s}=await g(r,{cwd:e.cwd}),n=s.split("\0").filter(o=>o.length>0);if(n.length===0)return[];const i=e.workTree??await je(e.cwd);return n.map(o=>He(o)?o:re(i,o))},"getFiles"),Ft=E(async(e,t)=>{if(e.length===0)return null;const r=[];for(let i=0;i<e.length;i+=me){const o=e.slice(i,i+me),{stdout:a}=await g(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...o],{cwd:t.cwd});a.length>0&&r.push(a)}if(r.length===0)return null;const s=r.join(""),n=s.endsWith(`
|
|
10
10
|
`)?s:`${s}
|
|
11
|
-
`;return Buffer.from(n,"utf8")},"capturePatch"),
|
|
11
|
+
`;return Buffer.from(n,"utf8")},"capturePatch"),Nt=E(async e=>{const{stdout:t}=await g(["status","--porcelain=v1","-z"],{cwd:e}),r=t.split("\0"),s=[];for(let n=0;n<r.length;n+=1){const i=r[n];if(i===void 0||i.length<4)continue;const o=i.charAt(0),a=i.charAt(1),c=i.slice(3),d=o==="R"||o==="C"||a==="R"||a==="C";o!==" "&&o!=="?"&&a!==" "&&a!=="?"&&s.push(c),d&&(n+=1)}return s},"getPartiallyStagedFiles"),Gt=E(async(e,t)=>{if(e.length===0)return;const r=`${e.join("\0")}\0`;await g(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:t.cwd,input:r})},"checkoutPaths"),_t=E(async(e,t)=>{if(await g(["update-index","--again"],{cwd:t.cwd,lenient:!0}),e.length===0)return;const r=`${e.join("\0")}\0`;await g(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:t.cwd,input:r})},"updateIndexAgain");var Dt=Object.defineProperty,P=f((e,t)=>Dt(e,"name",{value:t,configurable:!0}),"r$1");const Bt="vis_staged_automatic_backup",Ae=P(()=>`${Bt}-${process.pid}-${Date.now()}-${qe(3).toString("hex")}`,"buildMessage"),Lt=P(async e=>{const t=await R(["stash","create"],{cwd:e});return t.length===0?null:(await g(["stash","store","-m",Ae(),t],{cwd:e}),t)},"createBackupStash"),Ht=P(async e=>{const t=Ae(),{exitCode:r,stdout:s}=await g(["stash","push","--keep-index","--include-untracked","--quiet","-m",t],{cwd:e,lenient:!0});if(r!==0)return null;const n=s.trim();return n.length>0&&/no local changes/i.test(n)?null:R(["rev-parse","stash@{0}"],{cwd:e})},"createHideAllStash"),ae=P(async(e,t)=>{const{exitCode:r,stdout:s}=await g(["reflog","--format=%H %gd","refs/stash"],{cwd:e,lenient:!0});if(r!==0)return null;for(const n of s.split(/\r?\n/)){const[i,o]=n.split(/\s+/,2);if(i===t&&o!==void 0)return o}return null},"findStashRefBySha"),ve=P(async(e,t)=>{if(t===null)return;const r=await ae(e,t);r!==null&&await g(["stash","drop","--quiet",r],{cwd:e})},"dropBackupStash"),qt=P(async(e,t)=>{if(t===null)throw new ue("Backup stash was not found — can't revert working tree.");const r=await ae(e,t);if(r===null)throw new ue(`Backup stash ${t} is no longer reachable — can't revert working tree.`);await g(["reset","--hard","HEAD"],{cwd:e}),await g(["stash","apply","--index","--quiet",r],{cwd:e})},"applyBackupStash"),Ut=P(async(e,t)=>{if(t===null)return;const r=await ae(e,t);r!==null&&await g(["stash","pop","--quiet",r],{cwd:e})},"popHideAllStash");var zt=Object.defineProperty,Vt=f((e,t)=>zt(e,"name",{value:t,configurable:!0}),"l");class Wt{static{f(this,"GitWorkflow")}static{Vt(this,"GitWorkflow")}stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(t){this.cwd=t.cwd??process.cwd(),this.options=t,this.shouldStash=t.stash!==!1&&t.diff===void 0,this.shouldHidePartial=t.hidePartiallyStaged!==!1,this.shouldHideUnstaged=t.hideUnstaged===!0,this.shouldHideAll=t.hideAll===!0}async prepare(){if(!await xt(this.cwd))throw new D(`Not a git repository: ${this.cwd}`);await Mt(this.cwd),this.workTree=await je(this.cwd),this.gitDir=await Ct(this.cwd),this.stagedFiles=await Rt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Nt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await At(this.workTree),this.intentToAddPaths.length>0&&await Pt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Lt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await Ht(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await ge(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await It(this.workTree),this.preTaskUntracked=new Set(await we(this.workTree))}async applyModifications({autoStage:t=!1}={}){if(this.stagedFiles.length===0)return;const r=this.stagedFiles.map(s=>B(this.workTree,s));if(await _t(r,{cwd:this.workTree}),t){const s=(await we(this.workTree)).filter(n=>!this.preTaskUntracked.has(n));if(s.length>0){const n=`${s.join("\0")}\0`;await g(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:n})}}if(this.intentToAddPaths.length>0)try{await g(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await ge(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const t=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let r;try{await g(t,{cwd:this.workTree,input:this.patch});return}catch(s){r=s instanceof D?s.stderr:String(s)}try{await g([...t,"--3way"],{cwd:this.workTree,input:this.patch})}catch(s){const n=s instanceof D&&s.stderr?s.stderr:String(s);throw new fe(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
|
|
12
12
|
First attempt: ${r??"(no stderr)"}
|
|
13
|
-
Second attempt: ${n}`,{cause:s})}}async revert(){if(this.backupStashSha!==null){try{await
|
|
13
|
+
Second attempt: ${n}`,{cause:s})}}async revert(){if(this.backupStashSha!==null){try{await qt(this.workTree,this.backupStashSha)}catch(t){throw new fe("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:t})}if(await ve(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await g(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(t){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await Ut(this.workTree,this.hideAllStashSha)}catch{}t&&this.backupStashSha!==null&&!this.revertApplied&&await ve(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const t=new Set(this.stagedFiles.map(s=>B(this.workTree,s))),r=this.shouldHideUnstaged?[...t]:this.shouldHidePartial?this.partiallyStaged.filter(s=>t.has(s)):[];r.length!==0&&(this.patch=await Ft(r,{cwd:this.workTree}),this.patch!==null&&await Gt(r,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(t=>{const r=re(this.gitDir,t);return oe(r)?{body:De(r),existed:!0,name:t}:{body:null,existed:!1,name:t}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const t of this.merge){const r=re(this.gitDir,t.name);try{t.existed&&t.body!==null?Be(r,t.body):oe(r)&&Le(r)}catch{}}}}var Kt=Object.defineProperty,K=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"r");const Pe=K(e=>e.includes("/"),"isPathStyle"),U=K((e,t)=>t?e.toLowerCase():e,"normalizeForMatch"),Yt=K((e,t,r,s={})=>{const n=Pe(e),i=s.caseInsensitive===!0,o=U(e,i),a=[];for(const c of t){const d=n?B(r,c):Se(c);xe(o,U(d,i))&&a.push(c)}return a},"matchFiles"),Qt=K((e,t,r,s={})=>{if(!t||t.length===0)return[...e];const n=s.caseInsensitive===!0;return e.filter(i=>{for(const o of t){const a=Pe(o)?B(r,i):Se(i),c=U(o,n);if(xe(c,U(a,n)))return!1}return!0})},"applyIgnore");var Jt=Object.defineProperty,L=f((e,t)=>Jt(e,"name",{value:t,configurable:!0}),"g");const Xt=L(e=>{switch(e){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},"colorForStatus"),ye=L(e=>{if(e==="running")return b(ze,{type:"dots"});const t=e==="failed"?Ce:e==="skipped"?q:e==="success"?Ie:q;return b($,{color:Xt(e),children:t})},"iconForStatus"),ke=L(({state:e,tick:t,verbose:r})=>C(M,{flexDirection:"column",children:[[...e.patterns.values()].map(s=>C(M,{flexDirection:"column",children:[C(M,{children:[ye(s.status),C($,{children:[" ",s.title]})]}),[...s.commands.values()].map(n=>C(M,{flexDirection:"column",marginLeft:2,children:[C(M,{children:[ye(n.status),C($,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?C($,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),r&&n.output?b(M,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((i,o)=>b($,{color:"gray",children:i},`${n.id}-line-${o}`))}):null,n.status==="failed"&&n.error?b(M,{marginLeft:2,children:b($,{color:"red",children:n.error.message})}):null]},n.id))]},s.id)),e.infoMessages.map((s,n)=>b($,{color:"gray",children:s},`info-${n}`)),e.warnMessages.map((s,n)=>b($,{color:"yellow",children:s},`warn-${n}`)),e.errorMessages.map(({message:s},n)=>b($,{color:"red",children:s},`err-${n}`))]}),"App"),Zt=L((e={})=>{const t=e.verbose===!0,r={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let s=0;const n=Ue(b(ke,{state:r,tick:s,verbose:t}),{exitOnCtrlC:!1,stdout:process.stderr}),i=L(()=>{s+=1,n.rerender(b(ke,{state:r,tick:s,verbose:t}))},"refresh");return{commandEnd({commandId:o,durationMs:a,error:c,output:d,patternId:u,status:l}){const p=r.patterns.get(u)?.commands.get(o);p&&(p.status=l,p.durationMs=a,p.output=d,p.error=c,i())},commandStart({commandId:o,patternId:a}){const c=r.patterns.get(a)?.commands.get(o);c&&(c.status="running",i())},error({error:o,message:a}){r.errorMessages.push({error:o,message:a}),i()},info({message:o}){r.infoMessages.push(o),i()},patternEnd({patternId:o,status:a}){const c=r.patterns.get(o);c&&(c.status=a,i())},patternStart({patternId:o}){const a=r.patterns.get(o);a&&(a.status="running",i())},start({patterns:o}){r.started=!0;for(const a of o){const c=new Map;for(const d of a.commands)c.set(d.id,{durationMs:0,id:d.id,status:"pending",title:d.title});r.patterns.set(a.id,{commands:c,id:a.id,status:"pending",title:a.title})}i()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:o}){r.warnMessages.push(o),i()}}},"createInkRenderer");var er=Object.defineProperty,ee=f((e,t)=>er(e,"name",{value:t,configurable:!0}),"a$1");const be=ee((e={})=>{const{quiet:t=!1,verbose:r=!1}=e,s=new Map,n=new Map,i=ee(a=>{t||process.stderr.write(`${a}
|
|
14
14
|
`)},"print"),o=ee(a=>{switch(a){case"failed":return X(Ce);case"running":return J(">");case"skipped":return ce(q);case"success":return Ve(Ie);default:return I(q)}},"iconFor");return{commandEnd({commandId:a,durationMs:c,error:d,output:u,status:l}){const p=n.get(a)??a,w=I(`(${c}ms)`);if(i(` ${o(l)} ${p} ${w}`),l==="failed"&&d&&i(I(d.message)),(l==="failed"||r)&&u&&u.trim().length>0)for(const h of u.split(/\r?\n/))i(` ${I(h)}`)},commandStart({commandId:a}){if(!r)return;const c=n.get(a)??a;i(` ${I("…")} ${c}`)},error({error:a,message:c}){t?process.stderr.write(`${X(c)}
|
|
15
15
|
`):i(X(c)),a?.stack&&(r||!t)&&process.stderr.write(`${I(a.stack)}
|
|
16
|
-
`)},info({message:a}){i(I(a))},patternEnd({patternId:a,status:c}){const d=s.get(a)??a;i(`${o(c)} ${d}`)},patternStart({patternId:a}){const c=s.get(a)??a;i(`${J(">")} ${c}`)},start({patterns:a}){if(a.length===0){i(I("No staged files matched any pattern."));return}const c=new Set(a.flatMap(d=>d.files)).size;i(`${J(">")} Running staged tasks on ${c} file${c===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const d of a){s.set(d.id,d.title);for(const u of d.commands)n.set(u.id,u.title)}},stop(){},warn({message:a}){i(ce(a))}}},"createPlainRenderer");var
|
|
16
|
+
`)},info({message:a}){i(I(a))},patternEnd({patternId:a,status:c}){const d=s.get(a)??a;i(`${o(c)} ${d}`)},patternStart({patternId:a}){const c=s.get(a)??a;i(`${J(">")} ${c}`)},start({patterns:a}){if(a.length===0){i(I("No staged files matched any pattern."));return}const c=new Set(a.flatMap(d=>d.files)).size;i(`${J(">")} Running staged tasks on ${c} file${c===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const d of a){s.set(d.id,d.title);for(const u of d.commands)n.set(u.id,u.title)}},stop(){},warn({message:a}){i(ce(a))}}},"createPlainRenderer");var tr=Object.defineProperty,rr=f((e,t)=>tr(e,"name",{value:t,configurable:!0}),"t");const sr=rr(async e=>{const{env:t}=process;if(e.debug===!0||e.quiet===!0||t.NODE_ENV==="test"||t.TERM==="dumb"||t.CI!==void 0||!process.stderr.isTTY)return be({quiet:e.quiet,verbose:e.verbose});try{return Zt({verbose:e.verbose})}catch{return be({quiet:e.quiet,verbose:e.verbose})}},"pickRenderer");var nr=Object.defineProperty,_=f((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a");const te=_(e=>typeof e=="object"&&e!==null&&typeof e.title=="string"&&typeof e.task=="function","isCustomTask"),ar=_(async e=>{let t=0,r=0;const s=_(()=>(t+=1,`pattern-${t}`),"nextPatternId"),n=_(()=>(r+=1,`cmd-${r}`),"nextCommandId"),i=_(async(a,c,d)=>{if(typeof a=="string"){d.push({command:a,files:c,id:n(),source:"string",title:a});return}if(Array.isArray(a)){for(const u of a)await i(u,c,d);return}if(typeof a=="function"){const u=await a([...c]);if(typeof u=="string"){d.push({command:u,files:c,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const l of u)if(typeof l=="string")d.push({command:l,files:c,id:n(),source:"function",title:l});else if(te(l))d.push({files:c,id:n(),run:l.task,source:"custom",title:l.title});else throw new T("Task function returned an array with an unsupported entry — expected strings or { title, task }.");return}if(te(u)){d.push({files:c,id:n(),run:u.task,source:"custom",title:u.title});return}throw new T("Task function returned an unsupported value — expected string, string[], or { title, task }.")}if(te(a)){d.push({files:c,id:n(),run:a.task,source:"custom",title:a.title});return}throw new T("Unsupported task value — expected string, string[], function, or { title, task }.")},"expandTask"),o=[];for(const[a,c]of Object.entries(e.config)){const d=Yt(a,e.files,e.cwd,{caseInsensitive:e.caseInsensitive===!0});if(d.length===0)continue;const u=e.relative?d.map(p=>B(e.cwd,p)):d,l=[];await i(c,u,l),l.length!==0&&o.push({commands:l,files:u,id:s(),pattern:a,title:`${a} — ${d.length} file${d.length===1?"":"s"}`})}return o},"buildTaskGraph");var ir=Object.defineProperty,Y=f((e,t)=>ir(e,"name",{value:t,configurable:!0}),"c");const or=Y(e=>{const t=[];let r="",s=!1,n=!1;for(let i=0;i<e.length;i+=1){const o=e[i];if(o===void 0)break;if(o==="\\"&&!s&&i+1<e.length){const a=e[i+1];if(a!==void 0){n&&a!=='"'&&a!=="\\"&&(r+=o),r+=a,i+=1;continue}}if(o==='"'&&!s){n=!n;continue}if(o==="'"&&!n){s=!s;continue}if(!s&&!n&&/\s/.test(o)){r.length>0&&(t.push(r),r="");continue}r+=o}if(s||n)throw new T(`Unterminated ${s?"single":"double"} quote in command: ${e}`);return r.length>0&&t.push(r),t},"parseCommandString"),Re=process.platform==="win32"?28e3:131072,cr=Y((e,t,r)=>{const s=[];let n=[],i=t;const o=r<=0?Re:r;for(const a of e){const c=Buffer.byteLength(a)+1;n.length>0&&i+c>o&&(s.push(n),n=[],i=t),n.push(a),i+=c}return n.length>0&&s.push(n),s},"chunkFiles"),dr=Y(async(e,t,r)=>{const s=or(e);if(s.length===0)throw new O(e,"Empty command for staged task.");const[n,...i]=s;if(n===void 0)throw new O(e,"Empty command for staged task.");const o=Buffer.byteLength(n)+i.reduce((u,l)=>u+Buffer.byteLength(l)+1,0),a=cr(t,o,r.maxArgLength??Re),c=Date.now(),d=[];for(const u of a){if(r.signal?.aborted===!0)throw new O(e,"Task aborted by earlier failure.");const l=$e(n,[...i,...u],{nodeOptions:{cwd:r.cwd,env:lr(r.env,r.cwd),killSignal:r.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...r.signal===void 0?{}:{signal:r.signal}}),p=await l,w=[p.stdout,p.stderr].filter(m=>m.length>0).join(`
|
|
17
17
|
`);w.length>0&&d.push(w);const h=l.process?.signalCode??null;if(l.aborted||h!==null||p.exitCode===void 0){const m=l.aborted?"Task aborted by earlier failure.":h===null?w.trim()||"Task exited without a numeric status code.":`Task killed by signal ${h}.`;throw new O(e,m)}if(p.exitCode!==0)throw new O(e,w.trim()||`Exit code ${p.exitCode} from ${n}`)}return{durationMs:Date.now()-c,output:d.join(`
|
|
18
|
-
`)}},"execCommand"),
|
|
18
|
+
`)}},"execCommand"),lr=Y((e,t)=>{const r={...process.env};process.stderr.isTTY&&r.FORCE_COLOR===void 0&&r.NO_COLOR===void 0&&(r.FORCE_COLOR="1");const s=e?{...r,...e}:r;return We(s,t)},"buildTaskEnv");var ur=Object.defineProperty,j=f((e,t)=>ur(e,"name",{value:t,configurable:!0}),"o");const fr=j(async(e,t,r)=>{const s=pr(r.concurrent,e.length),n=[],i=new AbortController;let o=!1,a=0;const c=j(()=>{o||(o=!0,r.continueOnError||i.abort())},"cancel");r.externalSignal&&(r.externalSignal.aborted?c():r.externalSignal.addEventListener("abort",()=>{c()},{once:!0}));const d=j(h=>{for(const m of h.commands)t.commandEnd({commandId:m.id,durationMs:0,patternId:h.id,status:"skipped"})},"emitSkippedCommands"),u=j(async h=>{if(o){d(h),t.patternEnd({patternId:h.id,status:"skipped"});return}t.patternStart({patternId:h.id});let m="success";for(const y of h.commands){if(o){t.commandEnd({commandId:y.id,durationMs:0,patternId:h.id,status:"skipped"}),m=m==="success"?"skipped":m;continue}t.commandStart({commandId:y.id,patternId:h.id});const k=await hr(y,r,i.signal),S=k.status==="failed"&&i.signal.aborted?{...k,status:"skipped"}:k;if(t.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:h.id,status:S.status}),S.status==="failed"){n.push(y.title),m="failed",c();break}if(S.status==="skipped"){m=m==="success"?"skipped":m;break}}t.patternEnd({patternId:h.id,status:m})},"runOne"),l=j(async()=>{for(;a<e.length;){const h=e[a];a+=1,h&&await u(h)}},"pickNext"),p=[];for(let h=0;h<Math.min(s,e.length);h+=1)p.push(l());await Promise.all(p);const w=r.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!w}},"runTasks"),hr=j(async(e,t,r)=>{const s=Date.now();try{if(e.source==="custom"&&e.run)return await e.run([...e.files]),{durationMs:Date.now()-s,status:"success"};if(e.command){const n=await dr(e.command,e.files,{cwd:t.cwd,killSignal:t.killSignal,maxArgLength:t.maxArgLength,signal:r});return{durationMs:n.durationMs,output:t.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-s,error:new O(e.title,"Command has no invocation target."),status:"failed"}}catch(n){const i=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-s,error:i,output:i instanceof O?i.message:void 0,status:"failed"}}},"runCommand"),pr=j((e,t)=>{if(e===!1)return 1;if(e===!0){const s=Math.max(1,typeof de=="function"?de():4);return Math.min(Math.max(1,t),s)}const r=Math.floor(e);return r>0?r:1},"concurrencyLimit");var gr=Object.defineProperty,se=f((e,t)=>gr(e,"name",{value:t,configurable:!0}),"u");const mr=!0,wr=se(e=>{try{return!at(e)}catch{return!1}},"detectCaseInsensitive"),vr=se(async(e={})=>{const t=e.cwd??process.cwd(),r=await sr(e),s=await Tt(e);typeof s!="function"&&he(s);const n=new Wt({...e,cwd:t}),i=new AbortController;let o=!1;const a=se(l=>{if(o){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,l);return}o=!0,r.warn({message:`Received ${l} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()},"onInterrupt");process.on("SIGINT",a),process.on("SIGTERM",a);let c={failedCommands:[],ranTasks:!1,success:!0},d=!1,u=!1;try{await n.prepare(),d=!0;for(const k of n.warnings)r.warn({message:k});if(n.stagedFiles.length===0)return e.allowEmpty!==!0&&r.info({message:"No staged files found."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const l=wr(t),p=Qt(n.stagedFiles,e.ignore,t,{caseInsensitive:l});if(p.length===0&&n.stagedFiles.length>0)return r.info({message:"Every staged file was excluded by the `ignore` list."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const w=typeof s=="function"?he(await s([...p])):s,h=await ar({caseInsensitive:l,config:w,cwd:t,files:p,relative:e.relative});if(r.start({patterns:h}),h.length===0)return r.info({message:"No staged files matched any pattern."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:m,success:y}=await fr(h,r,{concurrent:e.concurrent??mr,continueOnError:e.continueOnError===!0,cwd:t,externalSignal:i.signal,killSignal:e.killSignal,maxArgLength:e.maxArgLength,verbose:e.verbose});if(c={failedCommands:m,ranTasks:!0,success:y},y){if(e.diff===void 0&&(await n.applyModifications({autoStage:e.autoStage===!0}),e.failOnChanges===!0&&n.indexTreeChanged()&&(r.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),c={failedCommands:[...m],ranTasks:!0,success:!1}),e.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new lt("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(e.revert===!0)r.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const k=n.recoveryHint();k&&r.warn({message:k})}return await n.restoreUnstagedChanges(),u=c.success,c}catch(l){const p=l instanceof Error?l.message:String(l),w=l instanceof Error?l:new Error(p);if(r.error({error:w,message:p}),l instanceof A)return{failedCommands:c.failedCommands,ranTasks:c.ranTasks,success:!1};throw l}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),d)try{await n.cleanup(u)}catch(l){r.error({error:l,message:"Cleanup failed."})}await r.stop()}},"runStaged");var yr=Object.defineProperty,kr=f((e,t)=>yr(e,"name",{value:t,configurable:!0}),"n");const br="VIS_STAGED_CONCURRENT",Te=kr(e=>{const t=e.trim();if(t==="true"||t==="")return!0;if(t==="false")return!1;const r=Number(t);return Number.isNaN(r)?!0:r},"parseConcurrent");var Tr=Object.defineProperty,H=f((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"d");const Sr=H((e,t)=>{const r={};t!==void 0&&(r.config=t);const s=H(v=>e[v]===void 0?void 0:!!e[v],"readBool"),n=H(v=>{const Q=e[v];return typeof Q=="string"&&Q.length>0?Q:void 0},"readString"),i=s("allow-empty");i!==void 0&&(r.allowEmpty=i);const o=s("auto-stage");o!==void 0&&(r.autoStage=o);const a=s("continue-on-error");a!==void 0&&(r.continueOnError=a);const c=s("debug");c!==void 0&&(r.debug=c);const d=s("fail-on-changes");d!==void 0&&(r.failOnChanges=d);const u=s("hide-partially-staged");u!==void 0&&(r.hidePartiallyStaged=u);const l=s("hide-unstaged");l!==void 0&&(r.hideUnstaged=l);const p=s("quiet");p!==void 0&&(r.quiet=p);const w=s("relative");w!==void 0&&(r.relative=w);const h=s("revert");h!==void 0&&(r.revert=h);const m=s("stash");m!==void 0&&(r.stash=m);const y=s("verbose");y!==void 0&&(r.verbose=y);const k=n("cwd");k!==void 0&&(r.cwd=k);const S=n("diff");S!==void 0&&(r.diff=S);const ie=n("diff-filter");if(ie!==void 0&&(r.diffFilter=ie),s("force-kill")===!0&&(r.killSignal="SIGKILL"),e.concurrent===void 0){const v=process.env[br];v!==void 0&&(r.concurrent=Te(v.trim()))}else{const{concurrent:v}=e;r.concurrent=Te(typeof v=="string"?v:typeof v=="number"||typeof v=="boolean"?String(v):"")}return r},"buildRunOptions"),Gr=H(async({options:e,visConfig:t})=>{const r=(t??{}).staged;if(!r)throw new Error(`No "staged" config found in vis.config.ts. Add one:
|
|
19
19
|
|
|
20
20
|
// vis.config.ts
|
|
21
21
|
import { defineConfig } from "@visulima/vis/config";
|
|
@@ -24,4 +24,4 @@ Second attempt: ${n}`,{cause:s})}}async revert(){if(this.backupStashSha!==null){
|
|
|
24
24
|
staged: { '*': 'vis check --fix' },
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await
|
|
27
|
+
Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await vr(Sr(e,r))).success||(process.exitCode=1)},"execute");export{Sr as buildRunOptions,Gr as default};
|