@visulima/vis 1.0.0-alpha.40 → 1.0.0-alpha.41
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 +27 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +2 -2
- package/dist/config/index.d.ts +18 -0
- package/dist/packem_chunks/bin.js +202 -202
- package/dist/packem_chunks/handler10.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 +1 -1
- 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/handler21.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/handler30.js +1 -2
- package/dist/packem_chunks/handler31.js +2 -2
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +2 -3
- package/dist/packem_chunks/handler34.js +3 -6
- package/dist/packem_chunks/handler35.js +6 -1
- package/dist/packem_chunks/handler36.js +1 -42
- package/dist/packem_chunks/handler37.js +42 -8
- package/dist/packem_chunks/handler38.js +8 -9
- package/dist/packem_chunks/handler39.js +9 -75
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +75 -5
- package/dist/packem_chunks/handler41.js +5 -4
- package/dist/packem_chunks/handler42.js +4 -3
- package/dist/packem_chunks/handler43.js +3 -2
- package/dist/packem_chunks/handler44.js +2 -1
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -3
- package/dist/packem_chunks/handler48.js +3 -1
- package/dist/packem_chunks/handler49.js +1 -7
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +6 -32
- package/dist/packem_chunks/handler51.js +33 -3
- package/dist/packem_chunks/handler52.js +3 -8
- package/dist/packem_chunks/handler53.js +6 -2
- package/dist/packem_chunks/handler54.js +4 -1
- package/dist/packem_chunks/handler55.js +1 -12
- package/dist/packem_chunks/handler56.js +11 -6
- package/dist/packem_chunks/handler57.js +7 -5
- package/dist/packem_chunks/handler58.js +5 -11
- package/dist/packem_chunks/handler59.js +11 -3
- package/dist/packem_chunks/handler60.js +3 -22
- package/dist/packem_chunks/handler61.js +21 -60
- package/dist/packem_chunks/handler62.js +61 -3
- package/dist/packem_chunks/handler63.js +3 -6
- package/dist/packem_chunks/handler64.js +6 -708
- package/dist/packem_chunks/handler65.js +708 -24
- package/dist/packem_chunks/handler66.js +24 -25
- package/dist/packem_chunks/handler67.js +25 -153
- package/dist/packem_chunks/handler68.js +153 -10
- package/dist/packem_chunks/handler69.js +10 -24
- package/dist/packem_chunks/handler70.js +24 -322
- package/dist/packem_chunks/handler71.js +322 -48
- package/dist/packem_chunks/handler72.js +48 -27
- package/dist/packem_chunks/handler73.js +27 -3
- package/dist/packem_chunks/handler74.js +3 -190
- package/dist/packem_chunks/handler75.js +189 -37
- package/dist/packem_chunks/handler76.js +38 -0
- 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/help-command.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/orchestrator.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_chunks/version-resolver.js +1 -1
- package/dist/packem_shared/command-runtime-CR70qSUM.js +1 -0
- package/dist/packem_shared/{cyclonedx-kYozDyxp.js → cyclonedx-Cadls41z.js} +1 -1
- package/dist/packem_shared/{index-Du8RWawQ.js → index-3jMNqQom.js} +1 -1
- package/dist/packem_shared/index-Bt521H5J.js +30 -0
- package/dist/packem_shared/{index-CgcF6_wo.js → index-DGSsjmpV.js} +1 -1
- package/dist/packem_shared/{pm-runner-OGResYrA.js → pm-runner-BKZQo7Ts.js} +1 -1
- package/dist/packem_shared/{provenance-_CJjMKwu.js → provenance-BFEwKgI3.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-CMDl55Nz.js → resolve-explicit-C6WM-I2u.js} +1 -1
- package/dist/packem_shared/{s1ngularity-Dhr3bPk0.js → s1ngularity-DCPmPE5M.js} +1 -1
- package/dist/packem_shared/{signatures-C730vkyK.js → signatures-Xpd6HjG_.js} +1 -1
- package/index.d.ts +201 -201
- package/index.js +26 -26
- package/package.json +13 -13
- package/schemas/vis-config.schema.json +12 -0
- package/dist/packem_shared/index-yBikBkHT.js +0 -30
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`,"utf8")},it={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},st=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of it[i])l.has(a.target)||c.push(a);const o=Object.keys(t);for(const{featureMatch:a,mounts:m}of st)if(o.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},N=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],K=i=>structuredClone(i);class ct{#o=new Set;#e;constructor(t,n,c=null){const l=t===null,o=t??{name:""},a=K(o);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:K(o),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#o.add(t),()=>{this.#o.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const t=(N.indexOf(this.#e.section)+1)%N.length;this.setSection(N[t])}previousSection(){const t=(N.indexOf(this.#e.section)-1+N.length)%N.length;this.setSection(N[t])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,W.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=W.find(c=>c.id===t);n&&this.#t(this.#r({...this.#e,config:K(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#r({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],o=l.indexOf(t);o===-1?l.push(t):l.splice(o,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",o={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:o},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:K(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=K(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#r(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#o)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},lt=/^[a-z]$/i,at=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},dt=(i,t)=>i.length===0||at(i)?!1:t.ctrl&&t.meta?!lt.test(i):!(t.ctrl||t.meta),ut=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,Se=-1,ht=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:Se,mt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ut,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:o,suggestions:a}){const[m,g]=p.useState(i),[f,j]=p.useState(i.length),x=p.useRef(m);x.current=m;const v=p.useRef(f);v.current=f;const b=p.useRef(c);b.current=c;const S=p.useRef(l);S.current=l;const D=se(m,a),R=p.useCallback((T,I)=>{const{current:E}=v,k=x.current;if(I.return){const w=se(k,a),C=w?k+w:k;w&&(g(C),j(C.length),b.current?.(C)),S.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(k,a);if(E===k.length&&w){const C=k+w;g(C),j(C.length),b.current?.(C);return}j(Math.min(k.length,E+1));return}const P=ht(T,I,E,k.length);if(P!==Se){j(P);return}const H=mt(T,I,k,E);if(H){const[w,C]=H;g(w),j(C),b.current?.(w);return}if(dt(T,I)){const w=k.slice(0,E)+T+k.slice(E);g(w),j(E+T.length),b.current?.(w)}},[a]);U(R,{isActive:!t});const L=n?"*".repeat(m.length):m,X=L.slice(0,f),V=L[f],Q=L.slice(f+1);return t?e.jsx(s,{children:e.jsx(r,{dimColor:!0,children:L||o||""})}):m.length===0&&o?e.jsxs(s,{children:[e.jsx(r,{dimColor:!0,inverse:!0,children:o[0]}),e.jsx(r,{dimColor:!0,children:o.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(r,{children:[X,e.jsx(r,{inverse:!0,children:V??" "}),Q]}),D?e.jsx(r,{dimColor:!0,children:D}):void 0]})}const Ee=["dockerComposeFile","service"],gt={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},ft={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},pt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,o=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),o&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(r,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const g=m===n,f=i[a]??"",j=Array.isArray(i[a])?i[a].join(", "):f;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:g,color:g?"cyan":"white",children:[g?"❯ ":" ",gt[a],":"]})}),e.jsx(s,{flexGrow:1,children:g&&t?e.jsx(he,{defaultValue:j,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(r,{color:j?"white":"gray",children:j||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(r,{dimColor:!0,children:ft[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},xt=Ee.length,jt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),o=Object.keys(c),a=l.length,m=l.length+1,g=m+o.length,f=t<=a,j=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(r,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),e.jsx(r,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,v)=>{const b=v===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(r,{bold:!0,children:x}),e.jsx(r,{dimColor:!0,children:" = "}),e.jsx(r,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(r,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:j?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:o.length>0?1:0,children:[e.jsx(r,{bold:!0,color:j?"cyan":"white",children:"remoteEnv"}),e.jsx(r,{dimColor:!0,children:" — set at runtime by the IDE"})]}),o.map((x,v)=>{const b=m+v===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(r,{bold:!0,children:x}),e.jsx(r,{dimColor:!0,children:" = "}),e.jsx(r,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:o.length>0?1:0,children:e.jsxs(r,{color:t===g?"cyan":"gray",inverse:t===g,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(r,{dimColor:!0,wrap:"truncate",children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(r,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},vt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const o=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,g=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),c&&e.jsxs(r,{dimColor:!0,children:["— filter:"," ",e.jsx(r,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((f,j)=>{const x=j===t,v=o.has(f.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:x?">":" "}),e.jsxs(r,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(r,{dimColor:!0,children:[" ","-",f.id]})]})})]},f.id)})})}),g&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(r,{dimColor:!0,children:"No extensions match the search."})})]})},bt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const o=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,g=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),c&&e.jsxs(r,{dimColor:!0,children:["— filter:"," ",e.jsx(r,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((f,j)=>{const x=j===t,v=o.has(f.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:x?">":" "}),e.jsxs(r,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(r,{dimColor:!0,children:[" ","-",f.description]})]})})]},f.id)})})}),g&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(r,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],wt={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},ye={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],kt={overrideCommand:"Override Command",privileged:"Privileged"},Ct=ae.length+te.length,St=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,o)=>{const a=o===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",wt[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:g=>{c({[l]:g})},placeholder:ye[l]}):e.jsx(r,{color:m?"white":"gray",children:m||ye[l]})})]},l)}),te.map((l,o)=>{const a=ae.length+o===n,m=i[l]??!1;return e.jsxs(s,{marginBottom:o<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",kt[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{color:m?"green":"gray",children:[m?"yes":"no",a&&e.jsx(r,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(r,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=Ct,ce=te,Te=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],Et={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},It={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Te.map((l,o)=>{const a=o===n,m=i[l],g=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",Et[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(r,{dimColor:!0,children:It[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:g,onChange:f=>{c(l,f)},placeholder:"e.g. npm install"}):e.jsx(r,{color:g?"green":"gray",children:g||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Dt=Te.length,be=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Pt=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:o,mountTarget:a,mountType:m,suggestedMounts:g})=>{const f=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[f.length," ","mounts"]}),n&&e.jsxs(r,{dimColor:!0,children:["— detected:"," ",e.jsx(r,{color:"white",children:n})]})]}),g.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(r,{dimColor:!0,children:[" ","— press"," ",e.jsx(r,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),g.map((j,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" + ",be(j)]})},`suggestion-${String(x)}`))]}),f.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:f.map((j,x)=>{const v=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:v?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:v,inverse:v,wrap:"truncate",children:[" ",be(j)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:c===f.length?"cyan":"gray",inverse:c===f.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(r,{color:o?"yellow":"gray",children:o||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(r,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(r,{children:[e.jsx(r,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(r,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(r,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(r,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(r,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!i&&g.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(r,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ft=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],o=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(r,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const g=m===c;return e.jsx(s,{children:e.jsxs(r,{color:g?"cyan":void 0,inverse:g,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(r,{color:o?"cyan":"gray",inverse:o,children:[" ",o&&i?e.jsxs(r,{children:["Enter port:"," ",e.jsx(r,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ",o?"type port number, Enter to confirm":"select"," ",e.jsx(r,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},At=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(r,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(r,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(r,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
|
|
3
|
-
`).map((o,a)=>e.jsx(r,{color:"green",children:o},`line-${String(a)}`))})]}),Ot=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,o]of i.forwardPorts.entries())typeof o=="number"&&(o<1||o>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(o)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},we=80,ke=15,Mt=120,De=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Lt=new Map(De.map(i=>[i.id,i.description])),Bt=(i,t,n,c)=>{switch(i){case"compose":return xt;case"environment":return vt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return Dt;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Nt=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=_e(),o=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[g,f]=p.useState(!1),[j,x]=p.useState(!1),[v,b]=p.useState(null),[S,D]=p.useState("editor"),[R,L]=p.useState(0),[X,V]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[k,P]=p.useState(""),[H,w]=p.useState(""),[C,z]=p.useState("key"),[re,Z]=p.useState(!1),[oe,G]=p.useState(""),[ne,_]=p.useState(""),[me,J]=p.useState("volume"),[A,$]=p.useState("source"),ie=p.useRef(null),B=p.useRef(null),M=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,M.current&&clearTimeout(M.current)}),[]);const ge=Bt(o.section,o.config,o.featureSearch,o.extensionSearch),q=Math.max(1,l-9);p.useEffect(()=>{o.section!=="features"&&o.section!=="extensions"||L(u=>o.fieldIndex>=u+q?o.fieldIndex-q+1:o.fieldIndex<u?o.fieldIndex:u)},[o.fieldIndex,o.section,q]),p.useEffect(()=>{L(0)},[o.section,o.featureSearch,o.extensionSearch]);const Pe=p.useCallback(()=>{const u=t.cleanConfig(),h=Ot(u);if(!h.valid){const y=h.errors[0];b(y?`Error: ${y.message}`:"Validation failed"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{ee.current&&b(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;b(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{ee.current&&b(null)},2e3)},[i,t]);U((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(o.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(o.templateIndex-1);else if(h.return){const d=W[o.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),U((u,h)=>{if(h.escape){V(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),V(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:X}),U((u,h)=>{if(h.escape){E(null),P(""),w(""),z("key");return}if(h.return){if(C==="key"&&k){z("value");return}if(C==="value"&&k){t.addEnvVar(I,k,H),E(null),P(""),w(""),z("key");return}}if(h.backspace){C==="key"?P(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?P(d=>d+u):w(d=>d+u))},{isActive:I!==null}),U((u,h)=>{if(h.escape){Z(!1),G(""),_(""),$("source");return}if(h.return){if(A==="source"&&oe){$("target");return}if(A==="target"&&ne){$("type");return}if(A==="type"){t.addMount({source:oe,target:ne,type:me}),Z(!1),G(""),_(""),$("source");return}}if(A==="type"){switch(u){case"1":{J("volume");break}case"2":{J("bind");break}case"3":{J("tmpfs");break}}return}if(h.backspace){A==="source"?G(d=>d.slice(0,-1)):A==="target"&&_(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(A==="source"?G(d=>d+u):A==="target"&&_(d=>d+u))},{isActive:re}),U((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!g){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),f(!0));return}if(j){if(h.escape){x(!1),o.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){o.section==="features"?t.setFeatureSearch(o.featureSearch.slice(0,-1)):t.setExtensionSearch(o.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){o.section==="features"?t.setFeatureSearch(o.featureSearch+u):t.setExtensionSearch(o.extensionSearch+u);return}return}if(o.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){o.isDirty?f(!0):n();return}if(u==="s"){Pe();return}if(h.tab){D(d=>d==="editor"?"preview":"editor");return}if(S==="preview"){if(h.downArrow||u==="j"){B.current?.scrollBy(1);return}if(h.upArrow||u==="k"){B.current?.scrollBy(-1);return}if(h.pageDown){B.current?.scrollBy(10);return}if(h.pageUp){B.current?.scrollBy(-10);return}if(h.home){B.current?.scrollToTop();return}if(h.end){B.current?.scrollToBottom();return}h.escape&&D("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(o.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(o.fieldIndex-1,0));return}if(h.return){switch(o.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(o.config.containerEnv??{}).length,y=d,O=d+1+Object.keys(o.config.remoteEnv??{}).length;o.fieldIndex===y?(E("container"),P(""),w(""),z("key")):o.fieldIndex===O&&(E("remote"),P(""),w(""),z("key"));break}case"mounts":{const d=o.config.mounts??[];o.fieldIndex===d.length&&(Z(!0),G(""),_(""),J("volume"),$("source"));break}case"ports":{const d=o.config.forwardPorts??[];o.fieldIndex===d.length&&(V(!0),T(""));break}}return}if(u===" "){switch(o.section){case"extensions":{const d=ue(o.extensionSearch)[o.fieldIndex];d&&t.toggleExtension(d.id);break}case"features":{const d=de(o.featureSearch)[o.fieldIndex];d&&t.toggleFeature(d.id);break}case"general":{const d=Ie-ce.length,y=o.fieldIndex-d;if(y>=0&&y<ce.length){const O=ce[y];t.updateConfig({[O]:!o.config[O]})}break}}return}if(u==="/"){(o.section==="features"||o.section==="extensions")&&x(!0);return}if(u==="A"&&o.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(o.section==="environment"){const d=Object.keys(o.config.containerEnv??{}).length,y=o.fieldIndex<=d?"container":"remote";E(y),P(""),w(""),z("key")}else o.section==="mounts"&&(Z(!0),G(""),_(""),J("volume"),$("source"));return}if(u==="d")switch(o.section){case"environment":{const d=Object.keys(o.config.containerEnv??{}),y=Object.keys(o.config.remoteEnv??{});if(o.fieldIndex<d.length)t.removeEnvVar("container",d[o.fieldIndex]),d.length===1||o.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const O=o.fieldIndex-d.length-1;O>=0&&O<y.length&&(t.removeEnvVar("remote",y[O]),y.length===1||O>=y.length-1&&t.setFieldIndex(o.fieldIndex-1))}break}case"mounts":{const d=o.config.mounts??[];if(o.fieldIndex<d.length){t.removeMount(o.fieldIndex);const y=d.length-1;o.fieldIndex>=y&&y>0&&t.setFieldIndex(y-1)}break}case"ports":{const d=o.config.forwardPorts??[];if(o.fieldIndex<d.length){t.removePort(o.fieldIndex);const y=d.length-1;o.fieldIndex>=y&&y>0&&t.setFieldIndex(y-1)}break}}}},{isActive:!o.showTemplateSelector&&!X&&I===null&&!re});const Fe=p.useMemo(()=>t.getJsonPreview(),[o.config]);if(c<we||l<ke)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",we,"x",ke]})});if(o.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Select a Template"})}),W.map((u,h)=>{const d=h===o.templateIndex;return e.jsx(s,{children:e.jsxs(r,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(r,{bold:d,children:u.name}),e.jsxs(r,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let F;switch(o.section){case"compose":{F=e.jsx(pt,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{F=e.jsxs(s,{flexDirection:"column",children:[e.jsx(jt,{config:o.config,fieldIndex:o.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(r,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(r,{children:["key=",e.jsx(r,{color:"yellow",children:k||"_"})," ","(Enter to set value)"]}):e.jsxs(r,{children:[k,"=",e.jsx(r,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{F=e.jsx(yt,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:R,searchText:o.extensionSearch,viewportHeight:q});break}case"features":{F=e.jsx(bt,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:R,searchText:o.featureSearch,viewportHeight:q});break}case"general":{F=e.jsx(St,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{F=e.jsx(Tt,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{F=e.jsx(Pt,{addingMount:re,config:o.config,detectedPm:o.detectedPm,fieldIndex:o.fieldIndex,mountPhase:A,mountSource:oe,mountTarget:ne,mountType:me,suggestedMounts:o.suggestedMounts});break}case"ports":{F=e.jsx(Ft,{addingPort:X,addPortValue:Q,config:o.config,fieldIndex:o.fieldIndex});break}default:F=e.jsx(r,{children:"Unknown section"})}const Ae=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]}),(o.section==="features"||o.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]}),(o.section==="features"||o.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"s"}),e.jsx(r,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[v&&e.jsxs(r,{color:v.startsWith("Error")?"red":"green",children:[v," "]}),o.isDirty&&e.jsx(r,{color:"yellow",children:"[modified]"}),!o.isDirty&&!v&&e.jsx(r,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs($e,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"?"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(r,{bold:!0,color:"white",children:"j/k"}),e.jsx(r,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Enter"}),e.jsx(r,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Esc"}),e.jsx(r,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"d"}),e.jsx(r,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"s"}),e.jsx(r,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:" Quit"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:" Toggle help"})]})]})]}),Me=e.jsx(At,{focused:S==="preview",hadComments:o.hadComments,jsonPreview:Fe,mode:o.mode,scrollRef:B}),fe=c>=Mt,Le=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[o.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(et,{defaultValue:o.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),D("editor")},showIndex:!1,children:De.map(({id:u,label:h})=>e.jsx(tt,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(r,{dimColor:!0,wrap:"truncate",children:Lt.get(o.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:S==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:F}),fe&&e.jsx(s,{flexShrink:0,width:Le,children:Me})]}),Ae,e.jsx(Ue,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Oe]})},Ut=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,o=t.output,a=!!process.stdout.isTTY&&!Ve;let m=null;try{m=Je(c).name}catch{}const g=ot(c);let f=g?.config??null;const j=g?.hadComments??!1;if(l&&!g){const S=W.find(D=>D.id===l);if(!S){const D=W.map(R=>R.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${D}`)}f=S.config}if(!a){f?i.info(JSON.stringify(f,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),v=new ct(f,j,m);l&&!g&&v.dismissTemplateSelector();let b=null;if(await We(Xe.createElement(Nt,{onSave:S=>{nt(c,S,o),b=S},store:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),b){const S=o??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${S}`)}};export{Ut as default};
|
|
1
|
+
import{createRequire as mt}from"node:module";import{y as b,J as it,B as yt,A as at,m as O,f as B,k as kt}from"../packem_shared/index-BDmTbWX1.js";import{$ as vt,a4 as w,a5 as C,m as x,t as Tt,W as St}from"./bin.js";import ot from"./index.js";import{x as ct}from"tinyexec";import{o as It}from"../packem_shared/spinner-CV3WVJLv.js";import{C as dt,D as _,T as lt}from"../packem_shared/symbols-DPTlrJ3B.js";import{s as V,E as $,q as P,V as G,I as Et}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{withEnhancedPath as Mt}from"@visulima/task-runner";const wt=mt(import.meta.url),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,H=t=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[e,s]=A.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return A.getBuiltinModule(t)}return wt(t)},{readFileSync:xt,writeFileSync:bt,unlinkSync:$t}=H("node:fs"),{randomBytes:Ct}=H("node:crypto"),{availableParallelism:z}=H("node:os");class E extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class At extends E{}class v extends E{}class W extends E{}class R extends E{stderr;constructor(e,s,r){super(e,r),this.stderr=s}}class K extends E{}class I extends E{commandTitle;constructor(e,s,r){super(s,r),this.commandTitle=e}}const ut=t=>t.includes("/"),D=(t,e)=>e?t.toLowerCase():t,jt=(t,e,s,r={})=>{const n=ut(t),a=r.caseInsensitive===!0,c=D(t,a),i=[];for(const o of e){const l=n?b(s,o):it(o);ot(c,D(l,a))&&i.push(o)}return i},Rt=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(a=>{for(const c of e){const i=ut(c)?b(s,a):it(a),o=D(c,n);if(ot(o,D(i,n)))return!1}return!0})},L=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",N=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Nt=(t,e)=>{const s=b(t,e);return s===""||!s.startsWith("..")&&!at(s)},Ot=(t,e)=>{let s;for(const r of e)Nt(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},_t=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),a=(o,l,h,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],p=new Map;for(const f of h){const g=Ot(f,u)??t.cwd,y=p.get(g)??[];y.push(b(g,f)),p.set(g,y)}for(const f of[...p.keys()].sort()){const g=b(t.cwd,f)||".";d.push({command:o.command,cwd:f,files:p.get(f)??[],id:n(),source:"string",title:`${o.command} — ${g}`})}return}if(o.cwd!==void 0){const u=yt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:h,id:n(),source:"string",title:`${o.command} — ${b(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:n(),source:"string",title:o.command})},c=async(o,l,h,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:n(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,h,d);return}if(N(o)){a(o,l,h,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const p of u)if(typeof p=="string")d.push({command:p,files:l,id:n(),source:"function",title:p});else if(N(p))a(p,l,h,d);else if(L(p))d.push({files:l,id:n(),run:p.task,source:"custom",title:p.title});else throw new v("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(N(u)){a(u,l,h,d);return}if(L(u)){d.push({files:l,id:n(),run:u.task,source:"custom",title:u.title});return}throw new v("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(L(o)){d.push({files:l,id:n(),run:o.task,source:"custom",title:o.title});return}throw new v("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},i=[];for(const[o,l]of Object.entries(t.config)){const h=jt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(h.length===0)continue;const d=t.relative?h.map(p=>b(t.cwd,p)):h,u=[];await c(l,d,h,u),u.length!==0&&i.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${h.length} file${h.length===1?"":"s"}`})}return i},Dt=async t=>{if(t.config!==void 0)return t.config;throw new v(`No staged config provided. Add \`staged\` to your vis.config.ts:
|
|
2
|
+
|
|
3
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
staged: { "*.ts": "eslint --fix" },
|
|
7
|
+
});
|
|
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.`)},Y=t=>{if(typeof t!="object"||t===null)throw new v("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new v("Staged config is empty — at least one glob pattern is required.");for(const[s,r]of e){if(!s||s.trim()==="")throw new v("Staged config keys must be non-empty glob patterns.");ht(s,r)}return t},ht=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new v(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new v(`Task array for "${t}" is empty.`);for(const s of e)ht(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new v(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(N(e)){if(e.command.trim()==="")throw new v(`Command task for "${t}" has an empty \`command\`.`);return}if(!Ft(e))throw new v(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Ft=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",J=2048,m=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ct("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const{stderr:a}=r,c=a.length>J?`${a.slice(0,J)}…`:a;throw new R(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,a)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},M=async(t,e)=>{const{stdout:s}=await m(t,e);return s.trim()},Pt=async t=>{const e=await m(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Gt=async t=>M(["rev-parse","--absolute-git-dir"],{cwd:t}),ft=async t=>M(["rev-parse","--show-toplevel"],{cwd:t}),Q=async t=>M(["write-tree"],{cwd:t}),Lt=async t=>{const e=await m(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},j={major:2,minor:32},Ht=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),r=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(r)?null:{major:s,minor:r}},qt=async t=>{const e=Ht(await M(["--version"],{cwd:t}));if(e!==null&&(e.major<j.major||e.major===j.major&&e.minor<j.minor))throw new R(`Git ${j.major}.${j.minor} or newer is required; found ${e.major}.${e.minor}.`)},Ut="ACMR",X=500,Bt=async t=>{const{stdout:e}=await m(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(n=>n.length>0),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(!a?.startsWith(":"))continue;const c=a.slice(1).split(" "),i=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&i!==void 0&&/^0+$/.test(i)&&l!==void 0&&r.push(l)}return r},Z=async t=>{const{stdout:e}=await m(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},Vt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},zt=async t=>{const e=t.diffFilter??Ut,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:r}=await m(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const a=t.workTree??await ft(t.cwd);return n.map(c=>at(c)?c:O(a,c))},Wt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let a=0;a<t.length;a+=X){const c=t.slice(a,a+X),{stdout:i}=await m(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});i.length>0&&s.push(i)}if(s.length===0)return null;const r=s.join(""),n=r.endsWith(`
|
|
10
|
+
`)?r:`${r}
|
|
11
|
+
`;return Buffer.from(n,"utf8")},Kt=async t=>{const{stdout:e}=await m(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(a===void 0||a.length<4)continue;const c=a.charAt(0),i=a.charAt(1),o=a.slice(3),l=c==="R"||c==="C"||i==="R"||i==="C";c!==" "&&c!=="?"&&i!==" "&&i!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await m(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await m(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Qt="vis_staged_automatic_backup",pt=()=>`${Qt}-${process.pid}-${Date.now()}-${Ct(3).toString("hex")}`,Xt=async t=>{const e=await M(["stash","create"],{cwd:t});return e.length===0?null:(await m(["stash","store","-m",pt(),e],{cwd:t}),e)},Zt=async t=>{const e=pt(),{exitCode:s,stdout:r}=await m(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const n=r.trim();return n.length>0&&/no local changes/i.test(n)?null:M(["rev-parse","stash@{0}"],{cwd:t})},q=async(t,e)=>{const{exitCode:s,stdout:r}=await m(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[a,c]=n.split(/\s+/,2);if(a===e&&c!==void 0)return c}return null},tt=async(t,e)=>{if(e===null)return;const s=await q(t,e);s!==null&&await m(["stash","drop","--quiet",s],{cwd:t})},te=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");const s=await q(t,e);if(s===null)throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await m(["reset","--hard","HEAD"],{cwd:t}),await m(["stash","apply","--index","--quiet",s],{cwd:t})},ee=async(t,e)=>{if(e===null)return;const s=await q(t,e);s!==null&&await m(["stash","pop","--quiet",s],{cwd:t})};class se{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(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Pt(this.cwd))throw new R(`Not a git repository: ${this.cwd}`);await qt(this.cwd),this.workTree=await ft(this.cwd),this.gitDir=await Gt(this.cwd),this.stagedFiles=await zt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Kt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await Bt(this.workTree),this.intentToAddPaths.length>0&&await Vt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Xt(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 Zt(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await Q(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await Lt(this.workTree),this.preTaskUntracked=new Set(await Z(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(r=>b(this.workTree,r));if(await Jt(s,{cwd:this.workTree}),e){const r=(await Z(this.workTree)).filter(n=>!this.preTaskUntracked.has(n));if(r.length>0){const n=`${r.join("\0")}\0`;await m(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:n})}}if(this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await Q(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 e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let s;try{await m(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof R?r.stderr:String(r)}try{await m([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof R&&r.stderr?r.stderr:String(r);throw new K(`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
|
+
First attempt: ${s??"(no stderr)"}
|
|
13
|
+
Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await te(this.workTree,this.backupStashSha)}catch(e){throw new K("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await ee(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(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 e=new Set(this.stagedFiles.map(r=>b(this.workTree,r))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(r=>e.has(r)):[];s.length!==0&&(this.patch=await Wt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=O(this.gitDir,e);return B(s)?{body:xt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=O(this.gitDir,e.name);try{e.existed&&e.body!==null?bt(s,e.body):B(s)&&$t(s)}catch{}}}}const re=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},et=t=>{if(t==="running")return w.jsx(It,{type:"dots"});const e=t==="failed"?dt:t==="skipped"?_:t==="success"?lt:_;return w.jsx(x,{color:re(t),children:e})},st=({state:t,tick:e,verbose:s})=>w.jsxs(C,{flexDirection:"column",children:[[...t.patterns.values()].map(r=>w.jsxs(C,{flexDirection:"column",children:[w.jsxs(C,{children:[et(r.status),w.jsxs(x,{children:[" ",r.title]})]}),[...r.commands.values()].map(n=>w.jsxs(C,{flexDirection:"column",marginLeft:2,children:[w.jsxs(C,{children:[et(n.status),w.jsxs(x,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?w.jsxs(x,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),s&&n.output?w.jsx(C,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((a,c)=>w.jsx(x,{color:"gray",children:a},`${n.id}-line-${c}`))}):null,n.status==="failed"&&n.error?w.jsx(C,{marginLeft:2,children:w.jsx(x,{color:"red",children:n.error.message})}):null]},n.id))]},r.id)),t.infoMessages.map((r,n)=>w.jsx(x,{color:"gray",children:r},`info-${n}`)),t.warnMessages.map((r,n)=>w.jsx(x,{color:"yellow",children:r},`warn-${n}`)),t.errorMessages.map(({message:r},n)=>w.jsx(x,{color:"red",children:r},`err-${n}`))]}),ne=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=vt(w.jsx(st,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),a=()=>{r+=1,n.rerender(w.jsx(st,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:i,error:o,output:l,patternId:h,status:d}){const u=s.patterns.get(h)?.commands.get(c);u&&(u.status=d,u.durationMs=i,u.output=l,u.error=o,a())},commandStart({commandId:c,patternId:i}){const o=s.patterns.get(i)?.commands.get(c);o&&(o.status="running",a())},error({error:c,message:i}){s.errorMessages.push({error:c,message:i}),a()},info({message:c}){s.infoMessages.push(c),a()},patternEnd({patternId:c,status:i}){const o=s.patterns.get(c);o&&(o.status=i,a())},patternStart({patternId:c}){const i=s.patterns.get(c);i&&(i.status="running",a())},start({patterns:c}){s.started=!0;for(const i of c){const o=new Map;for(const l of i.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(i.id,{commands:o,id:i.id,status:"pending",title:i.title})}a()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),a()}}},rt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,a=i=>{e||process.stderr.write(`${i}
|
|
14
|
+
`)},c=i=>{switch(i){case"failed":return G(dt);case"running":return P(">");case"skipped":return V(_);case"success":return Et(lt);default:return $(_)}};return{commandEnd({commandId:i,durationMs:o,error:l,output:h,status:d}){const u=n.get(i)??i,p=$(`(${o}ms)`);if(a(` ${c(d)} ${u} ${p}`),d==="failed"&&l&&a($(l.message)),(d==="failed"||s)&&h&&h.trim().length>0)for(const f of h.split(/\r?\n/))a(` ${$(f)}`)},commandStart({commandId:i}){if(!s)return;const o=n.get(i)??i;a(` ${$("…")} ${o}`)},error({error:i,message:o}){e?process.stderr.write(`${G(o)}
|
|
15
|
+
`):a(G(o)),i?.stack&&(s||!e)&&process.stderr.write(`${$(i.stack)}
|
|
16
|
+
`)},info({message:i}){a($(i))},patternEnd({patternId:i,status:o}){const l=r.get(i)??i;a(`${c(o)} ${l}`)},patternStart({patternId:i}){const o=r.get(i)??i;a(`${P(">")} ${o}`)},start({patterns:i}){if(i.length===0){a($("No staged files matched any pattern."));return}const o=new Set(i.flatMap(l=>l.files)).size;a(`${P(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${i.length} pattern${i.length===1?"":"s"}`);for(const l of i){r.set(l.id,l.title);for(const h of l.commands)n.set(h.id,h.title)}},stop(){},warn({message:i}){a(V(i))}}},ie=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return rt({quiet:t.quiet,verbose:t.verbose});try{return ne({verbose:t.verbose})}catch{return rt({quiet:t.quiet,verbose:t.verbose})}},ae=t=>{const e=[];let s="",r=!1,n=!1;for(let a=0;a<t.length;a+=1){const c=t[a];if(c===void 0)break;if(c==="\\"&&!r&&a+1<t.length){const i=t[a+1];if(i!==void 0){n&&i!=='"'&&i!=="\\"&&(s+=c),s+=i,a+=1;continue}}if(c==='"'&&!r){n=!n;continue}if(c==="'"&&!n){r=!r;continue}if(!r&&!n&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(r||n)throw new v(`Unterminated ${r?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},gt=process.platform==="win32"?28e3:131072,oe=(t,e,s)=>{const r=[];let n=[],a=e;const c=s<=0?gt:s;for(const i of t){const o=Buffer.byteLength(i)+1;n.length>0&&a+o>c&&(r.push(n),n=[],a=e),n.push(i),a+=o}return n.length>0&&r.push(n),r},ce=async(t,e,s)=>{const r=ae(t);if(r.length===0)throw new I(t,"Empty command for staged task.");const[n,...a]=r;if(n===void 0)throw new I(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+a.reduce((h,d)=>h+Buffer.byteLength(d)+1,0),i=oe(e,c,s.maxArgLength??gt),o=Date.now(),l=[];for(const h of i){if(s.signal?.aborted===!0)throw new I(t,"Task aborted by earlier failure.");const d=ct(n,[...a,...h],{nodeOptions:{cwd:s.cwd,env:de(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,p=[u.stdout,u.stderr].filter(g=>g.length>0).join(`
|
|
17
|
+
`);p.length>0&&l.push(p);const f=d.process?.signalCode??null;if(d.aborted||f!==null||u.exitCode===void 0){const g=d.aborted?"Task aborted by earlier failure.":f===null?p.trim()||"Task exited without a numeric status code.":`Task killed by signal ${f}.`;throw new I(t,g)}if(u.exitCode!==0)throw new I(t,p.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
|
|
18
|
+
`)}},de=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return Mt(r,e)},le=async(t,e,s)=>{const r=he(s.concurrent,t.length),n=[],a=new AbortController;let c=!1,i=0;const o=()=>{c||(c=!0,s.continueOnError||a.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=f=>{for(const g of f.commands)e.commandEnd({commandId:g.id,durationMs:0,patternId:f.id,status:"skipped"})},h=async f=>{if(c){l(f),e.patternEnd({patternId:f.id,status:"skipped"});return}e.patternStart({patternId:f.id});let g="success";for(const y of f.commands){if(c){e.commandEnd({commandId:y.id,durationMs:0,patternId:f.id,status:"skipped"}),g=g==="success"?"skipped":g;continue}e.commandStart({commandId:y.id,patternId:f.id});const T=await ue(y,s,a.signal),S=T.status==="failed"&&a.signal.aborted?{...T,status:"skipped"}:T;if(e.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:f.id,status:S.status}),S.status==="failed"){n.push(y.title),g="failed",o();break}if(S.status==="skipped"){g=g==="success"?"skipped":g;break}}e.patternEnd({patternId:f.id,status:g})},d=async()=>{for(;i<t.length;){const f=t[i];i+=1,f&&await h(f)}},u=[];for(let f=0;f<Math.min(r,t.length);f+=1)u.push(d());await Promise.all(u);const p=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!p}},ue=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await ce(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new I(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const a=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:a,output:a instanceof I?a.message:void 0,status:"failed"}}},he=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof z=="function"?z():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},fe=!0,pe=t=>{try{return!kt(t)}catch{return!1}},ge=t=>{try{const e=Tt(t);return e?St(t,e).map(s=>O(t,s)):[]}catch{return[]}},me=async(t={})=>{const e=t.cwd??process.cwd(),s=await ie(t),r=await Dt(t);typeof r!="function"&&Y(r);const n=new se({...t,cwd:e}),a=new AbortController;let c=!1;const i=d=>{if(c){process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),a.abort()};process.on("SIGINT",i),process.on("SIGTERM",i);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,h=!1;try{await n.prepare(),l=!0;for(const T of n.warnings)s.warn({message:T});if(n.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=pe(e),u=Rt(n.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&n.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const p=typeof r=="function"?Y(await r([...u])):r,f=await _t({caseInsensitive:d,config:p,cwd:e,files:u,relative:t.relative,workspacePackages:ge(e)});if(s.start({patterns:f}),f.length===0)return s.info({message:"No staged files matched any pattern."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:g,success:y}=await le(f,s,{concurrent:t.concurrent??fe,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:a.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:g,ranTasks:!0,success:y},y){if(t.diff===void 0&&(await n.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&n.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...g],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new At("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)s.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const T=n.recoveryHint();T&&s.warn({message:T})}return await n.restoreUnstagedChanges(),h=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),p=d instanceof Error?d:new Error(u);if(s.error({error:p,message:u}),d instanceof E)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),l)try{await n.cleanup(h)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},we="VIS_STAGED_CONCURRENT",nt=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},ye=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=k=>t[k]===void 0?void 0:!!t[k],n=k=>{const F=t[k];return typeof F=="string"&&F.length>0?F:void 0},a=r("allow-empty");a!==void 0&&(s.allowEmpty=a);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const i=r("continue-on-error");i!==void 0&&(s.continueOnError=i);const o=r("debug");o!==void 0&&(s.debug=o);const l=r("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const h=r("hide-partially-staged");h!==void 0&&(s.hidePartiallyStaged=h);const d=r("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=r("quiet");u!==void 0&&(s.quiet=u);const p=r("relative");p!==void 0&&(s.relative=p);const f=r("revert");f!==void 0&&(s.revert=f);const g=r("stash");g!==void 0&&(s.stash=g);const y=r("verbose");y!==void 0&&(s.verbose=y);const T=n("cwd");T!==void 0&&(s.cwd=T);const S=n("diff");S!==void 0&&(s.diff=S);const U=n("diff-filter");if(U!==void 0&&(s.diffFilter=U),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const k=process.env[we];k!==void 0&&(s.concurrent=nt(k.trim()))}else{const{concurrent:k}=t;s.concurrent=nt(typeof k=="string"?k:typeof k=="number"||typeof k=="boolean"?String(k):"")}return s},Ee=async({options:t,visConfig:e})=>{const s=(e??{}).staged;if(!s)throw new Error(`No "staged" config found in vis.config.ts. Add one:
|
|
19
|
+
|
|
20
|
+
// vis.config.ts
|
|
21
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
staged: { '*': 'vis check --fix' },
|
|
25
|
+
});
|
|
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 me(ye(t,s))).success||(process.exitCode=1)};export{ye as buildRunOptions,Ee as default};
|