@visulima/vis 1.0.0-alpha.44 → 1.0.0-alpha.45
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 +51 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +63 -62
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +172 -973
- package/dist/packem_chunks/detect.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +2 -2
- 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/handler24.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/handler4.js +1 -1
- package/dist/packem_chunks/handler5.js +3 -3
- package/dist/packem_chunks/handler50.js +4 -4
- package/dist/packem_chunks/handler51.js +3 -3
- package/dist/packem_chunks/handler57.js +4 -4
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +6 -6
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +1 -1
- package/dist/packem_chunks/handler62.js +2 -2
- package/dist/packem_chunks/handler63.js +4 -4
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +13 -13
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +16 -16
- package/dist/packem_chunks/handler69.js +5 -5
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +2 -2
- package/dist/packem_chunks/handler73.js +13 -13
- package/dist/packem_chunks/handler74.js +3 -3
- package/dist/packem_chunks/handler75.js +3 -3
- package/dist/packem_chunks/handler76.js +5 -5
- 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 +1 -1
- package/dist/packem_chunks/index2.js +802 -7
- package/dist/packem_chunks/index3.js +7 -135
- package/dist/packem_chunks/index4.js +134 -73
- package/dist/packem_chunks/index5.js +74 -0
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/print-config.js +1 -1
- package/dist/packem_chunks/registry.js +2 -2
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +2 -2
- package/dist/packem_chunks/ts-loader.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +2 -2
- package/dist/packem_shared/{Table-CcVkyULl-DLWu6XHL.js → Table-BGIHvenQ-D2oJtNQj.js} +1 -1
- package/dist/packem_shared/affected-shas-CCxG4tvm.js +1 -0
- package/dist/packem_shared/{ai-analysis-CO6S0afy.js → ai-analysis-rC48NLfB.js} +4 -4
- package/dist/packem_shared/{ai-fix-CI0Vvqld.js → ai-fix-D_ijV3Rn.js} +3 -3
- package/dist/packem_shared/bin-CPMo34SM.js +1 -0
- package/dist/packem_shared/{command-runtime-BE-vKsGH.js → command-runtime-3FTGuUsK.js} +1 -1
- package/dist/packem_shared/{env-C2ZCnfP_.js → env-Ct3hMEYB.js} +1 -1
- package/dist/packem_shared/{failure-log-jFfZRJK9.js → failure-log-Dy2G-rKi.js} +1 -1
- package/dist/packem_shared/{index-CQjzW7m8.js → index-Cntyu-w8.js} +1 -1
- package/dist/packem_shared/{index-D7EZ612R.js → index-XAb0QGqA.js} +1 -1
- package/dist/packem_shared/{lifecycle-Dyb47wbD.js → lifecycle-CHcFuWf_.js} +1 -1
- package/dist/packem_shared/{osv-bloom-BsQ-aFiM.js → osv-bloom-DVMlkcAO.js} +2 -2
- package/dist/packem_shared/{packument-DquNPIq9.js → packument-C-A3Uhhx.js} +1 -1
- package/dist/packem_shared/pm-runner-CQcraCcu.js +1 -0
- package/dist/packem_shared/{provenance-DIq8KyBV.js → provenance-R2csDSNg.js} +1 -1
- package/dist/packem_shared/{registry-keys-C8K11ets.js → registry-keys-CMnS_Qt_.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-Dr4kIybR.js → resolve-explicit-C4oQMyoB.js} +1 -1
- package/dist/packem_shared/resolve-runtime-QRaQucfL.js +1 -0
- package/dist/packem_shared/{s1ngularity-CtMmtXJo.js → s1ngularity-BCDt28u0.js} +1 -1
- package/dist/packem_shared/scan-progress-YRpDs90j.js +2 -0
- package/dist/packem_shared/{signatures-CE8OAK-i.js → signatures-B3srzCEv.js} +1 -1
- package/dist/packem_shared/use-measured-height-DHi0xOPO.js +1 -0
- package/dist/packem_shared/{vis-update-app-Cpme_3Du.js → vis-update-app-B3I14Vfy.js} +1 -1
- package/index.js +52 -52
- package/package.json +11 -11
- package/dist/packem_shared/affected-shas-CwRY5aoc.js +0 -1
- package/dist/packem_shared/bin-P6Q5tKrP.js +0 -1
- package/dist/packem_shared/pm-runner-D4jM58Oz.js +0 -1
- package/dist/packem_shared/resolve-runtime-Tx0bvg0h.js +0 -1
- package/dist/packem_shared/scan-progress-D4yywI6P.js +0 -2
- package/dist/packem_shared/use-measured-height-XK9YSwtv.js +0 -1
- package/dist/packem_shared/window-ops-DDePlWLV.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as Be}from"node:module";import{r as p,m as e,n as s,i as r,$ as ze,
|
|
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(qe,{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}=Ye(),{columns:c,rows:l}=Ke(),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(Qe,{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(Ze,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Oe]})},Ht=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&&!$e;let m=null;try{m=Ue(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 ze(Ge.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{Ht as default};
|
|
1
|
+
import{createRequire as Be}from"node:module";import{r as p,m as e,n as s,i as r,$ as ze,d as Ge}from"./catalog.js";import"../packem_shared/env-Ct3hMEYB.js";import{I as Ue}from"../packem_shared/index-B0EsgdzO.js";import{A as We}from"../packem_shared/pm-runner-CQcraCcu.js";import{i as $e,m as le,f as Xe,v as Ve,H as He,a as Je}from"../packem_shared/index-CE6MsgcV.js";import{y as W,_ as Ce,T as qe,U as Ye,Q as Ke,V as Qe,W as Ze}from"./cli-main.js";import{F as et,a as tt}from"../packem_shared/tabs-CgxCvjCY.js";const Ne=Be(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Re=i=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[t,n]=Y.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Y.getBuiltinModule(i)}return Ne(i)},{writeFileSync:_e}=Re("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace($e,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),$=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],ot=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Xe(t))return null;const n=Ve(t),c=rt(n),l=c!==n;let o;try{o=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:o,hadComments:l}},nt=(i,t,n)=>{const c=n?He(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");Je(c),_e(l,`${JSON.stringify(t,null,2)}
|
|
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,$.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=$.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]);W(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(qe,{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}=Ye(),{columns:c,rows:l}=Ke(),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,U]=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]);W((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=$[o.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),W((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}),W((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}),W((u,h)=>{if(h.escape){Z(!1),G(""),_(""),U("source");return}if(h.return){if(A==="source"&&oe){U("target");return}if(A==="target"&&ne){U("type");return}if(A==="type"){t.addMount({source:oe,target:ne,type:me}),Z(!1),G(""),_(""),U("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}),W((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"),U("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"),U("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"})}),$.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(Qe,{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(Ze,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Oe]})},Vt=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&&!Ue;let m=null;try{m=We(c).name}catch{}const g=ot(c);let f=g?.config??null;const j=g?.hadComments??!1;if(l&&!g){const S=$.find(D=>D.id===l);if(!S){const D=$.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 ze(Ge.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{Vt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as rr}from"node:module";import{m as oe,H as js,J as nr,y as or,T as $s,v as ar,l as cr}from"../packem_shared/index-CE6MsgcV.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as hr,expandTokensInString as Ht,parsePartition as fr,TaskScheduler as pr,createTaskGraph as gr,reverseTaskGraph as mr,resolveTurboEnvCompat as wr,CompositeLifeCycle as zt,defaultTaskRunner as Yt,createLogReporter as yr,readLastRunSummary as vr,getLastRunSummaryPath as kr,runConcurrently as Qe,generateRunSummary as Jt,writeChromeTrace as xr,writeRunSummary as jr,TerminalBuffer as mt}from"@visulima/task-runner";import{I as He}from"../packem_shared/index-B0EsgdzO.js";import{
|
|
1
|
+
import{createRequire as rr}from"node:module";import{m as oe,H as js,J as nr,y as or,T as $s,v as ar,l as cr}from"../packem_shared/index-CE6MsgcV.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as hr,expandTokensInString as Ht,parsePartition as fr,TaskScheduler as pr,createTaskGraph as gr,reverseTaskGraph as mr,resolveTurboEnvCompat as wr,CompositeLifeCycle as zt,defaultTaskRunner as Yt,createLogReporter as yr,readLastRunSummary as vr,getLastRunSummaryPath as kr,runConcurrently as Qe,generateRunSummary as Jt,writeChromeTrace as xr,writeRunSummary as jr,TerminalBuffer as mt}from"@visulima/task-runner";import{I as He}from"../packem_shared/index-B0EsgdzO.js";import{T as bs,U as $r,Q as br,y as Kt,V as Sr,W as Tr,X as Cr,al as Ir,b as Rr,am as Er,an as Mr,ao as Fr,ap as Or}from"./cli-main.js";import{r as z,m as n,n as m,i as c,h as he,d as K,$ as Pr,C as Ar,b as Dr,O as Lr}from"./catalog.js";import{d as Br,r as Nr}from"../packem_shared/lockfile-C1qCKGH6.js";import{a as Ts}from"../packem_shared/public-api-WqUCiyIe.js";import{F as Hr}from"../packem_shared/failure-log-Dy2G-rKi.js";import{r as zr}from"../packem_shared/command-runtime-3FTGuUsK.js";import{r as Yr}from"../packem_shared/toolchain-C44mPKPu.js";import{i as Jr,r as Kr,s as Xr,a as Qr,c as Zr,d as ei,e as ti,H as si,f as ri,b as ii}from"../packem_shared/lifecycle-CHcFuWf_.js";import{p as ni,r as oi,f as ai}from"../packem_shared/selectors-D4iCvITE.js";import{r as nt,l as yt,d as ci,s as li,m as di,a as ui}from"../packem_shared/target-options-CR0OuYJr.js";import{o as hi,m as fi,c as Ze}from"../packem_shared/env-Ct3hMEYB.js";import{T as Cs,C as Is,D as ot,E as Rs}from"../packem_shared/symbols-DPTlrJ3B.js";import{V as dt,E as Zt,q as vi,j as ki}from"../packem_shared/index.server-J83sowC4.js";import{parseStacktrace as xi,codeFrame as ji}from"@visulima/error";import{originalPositionFor as $i,sourceContentFor as bi,loadSourceMap as Si}from"@visulima/source-map";import{o as Es}from"../packem_shared/spinner-DuJJvFTl.js";import{c as es,a as Ei,s as ts}from"../packem_shared/watch-BXNI7dC6.js";import ft from"./index.js";const ir=rr(import.meta.url),Ve=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ee=s=>{if(typeof Ve<"u"&&Ve.versions&&Ve.versions.node){const[e,t]=Ve.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Ve.getBuiltinModule(s)}return ir(s)},{existsSync:Ae,mkdirSync:Gr,writeFileSync:wt,readFileSync:Ge,openSync:_r,statSync:Xt,readSync:qr,closeSync:Wr,mkdtempSync:Ur}=Ee("node:fs"),{createInterface:Ss,emitKeypressEvents:Vr}=Ee("node:readline"),{spawn:pi}=Ee("node:child_process"),{isAbsolute:gi,resolve:Qt,dirname:mi,relative:wi}=Ee("node:path"),{fileURLToPath:yi}=Ee("node:url"),{createHash:Ti}=Ee("node:crypto"),{mkdir:Ci,appendFile:at}=Ee("node:fs/promises"),{platform:Ii,homedir:vt,tmpdir:Ri}=Ee("node:os"),ss=new WeakSet,Mi=s=>{if(ss.has(s))return;const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(typeof s.future!="string"||typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");ss.add(s)},Ms=(s,e)=>{e=e||-1;const t=new RegExp(String.raw`^-?\d+(?:\.\d{0,${String(e)}})?`).exec(s.toString());return t===null?s:Number.parseFloat(t[0])},rs=({unitCount:s,unitName:e},t,r)=>{let{spacer:o}=r;const{maxDecimalPoints:a}=r;let i=".";r.decimal!==void 0?i=r.decimal:t.decimal!==void 0&&(i=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,f=s;a!==void 0&&(f=Ms(s,a));const h=f.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const $ of h)u+=$==="."?i:d[$]}else u=h.replace(".",i);else u="";const p=t[e];let l=p;return typeof p=="function"&&(l=p(s)),t._hideCountIf2&&s===2&&(o=""),t._numberFirst?l+o+u:u+o+l},Fi=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,o=e.largest??Number.POSITIVE_INFINITY,a={};let i,d,u,f=s;for(d=0;d<t.length;d++){i=t[d];const p=r[i];u=d===t.length-1?f/p:Math.floor(f/p),a[i]=u,f-=u*p}if(e.round){let p=o;for(d=0;d<t.length;d++)if(i=t[d],u=a[i],u!==0&&(p--,p===0)){for(let l=d+1;l<t.length;l++){const $=t[l],R=a[$];a[i]=(a[i]??0)+R*r[$]/r[i],a[$]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],u=a[i],u===0)continue;const l=Math.round(u);if(a[i]=l,d===0)break;const $=t[d-1],R=r[$],G=Math.floor(l*r[i]/R);if(G)a[$]=(a[$]??0)+G,a[i]=0;else break}}const h=[];for(d=0;d<t.length&&h.length<o;d++){if(i=t[d],u=a[i],u&&!e.round&&h.length===o-1){let p,l=0;for(p=d+1,t.length;p<t.length;p++){const $=t[p];l+=a[$]*(e.unitMeasures[$]/e.unitMeasures[i])}u+=l,e.maxDecimalPoints!==void 0&&(u=Ms(u,e.maxDecimalPoints))}u&&h.push({unitCount:u,unitName:i})}return h},Oi=(s,e,t)=>{const{language:r,units:o}=e;if(s.length===0){const p=o.at(-1);return rs({unitCount:0,unitName:p},r,e)}const{conjunction:a,serialComma:i}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let u="";e.timeAdverb&&t!==0&&(u=r.future??"",t<0&&(u=r.past??""));const f=s.map(p=>rs(p,r,e));let h;return!a||s.length===1?h=f.join(d):s.length===2?h=f.join(a):h=f.slice(0,-1).join(d)+(i?",":"")+a+(f.at(-1)??""),u&&(h=u.replace("%s",h)),h},Pi=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:hi,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Mi(t.language);const r=Math.abs(s),o=Fi(r,t);return Oi(o,t,s)},Fs=s=>s===155||s===157||s===144||s===152||s===158||s===159,Os=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},et=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const o=s.codePointAt(r);if(o===156||t&&o===7)return r;if(o===27&&s.codePointAt(r+1)===92)return r+1}return-1},Ai=(s,e)=>{const t=s.codePointAt(e+1);return t===91?Os(s,e+2):t===93?et(s,e+2,!0):t===80||t===88||t===94||t===95?et(s,e+2,!1):t!==void 0?e+1:-1},Di=(s,e)=>{const t=s.codePointAt(e);return t===155?Os(s,e+1):t===157?et(s,e+1,!0):t===144||t===152||t===158||t===159?et(s,e+1,!1):-1},Li=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Fs(s.codePointAt(e)))return!0;return!1},Bi=s=>{if(!Li(s))return s;let e="",t=0,r=0;const{length:o}=s;for(;r<o;){const a=s.codePointAt(r);let i;if(a===27)i=Ai(s,r);else if(Fs(a))i=Di(s,r);else{r+=1;continue}i===-1&&(i=o-1),e+=s.slice(t,r),t=i+1,r=i+1}return e+=s.slice(t),e},be="@voidzero-dev/vite-task-client",kt="@visulima/task-runner-client",tt=`npm:${kt}@^1`,Ps=oe(".vis",".vite-client-override-declined"),st="pnpm-workspace.yaml",Ni=["dependencies","devDependencies","optionalDependencies","peerDependencies"],As=s=>{try{return JSON.parse(Ge(s,"utf8"))}catch{return}},Gi=s=>{const e=oe(s,st);if(Ae(e))try{return Ts(Ge(e,"utf8")).toJS()?.overrides}catch{return}},_i=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",qi=s=>{const e=oe(s,st);try{const t=Ts(Ge(e,"utf8"));return t.setIn(["overrides",be],tt),wt(e,t.toString()),!0}catch{return!1}},is=s=>s!==void 0&&Ni.some(e=>s[e]?.[be]!==void 0),Wi=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[be]!==void 0||s.overrides?.[be]!==void 0||s.resolutions?.[be]!==void 0)||e?.[be]!==void 0,Ui=(s,e=[])=>{const t=As(oe(s,"package.json")),r=Ae(oe(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:Wi(t,Gi(s)),declined:Ae(oe(s,Ps)),manager:Br(s)?.manager,present:is(t)||r||e.some(o=>is(o))}},Vi=s=>{try{const e=oe(s,Ps);Gr(js(e),{recursive:!0}),wt(e,`Declined adding the ${be} → ${kt} override.
|
|
2
2
|
Delete this file to be asked again.
|
|
3
3
|
`)}catch{}},Hi=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&Ae(oe(s,st))&&qi(s))return{file:st,installCommand:t};const r=oe(s,"package.json"),o=As(r);if(!o)return;const a=_i(e);a==="pnpm.overrides"?(o.pnpm??={},o.pnpm.overrides??={},o.pnpm.overrides[be]=tt):(o[a]??={},o[a][be]=tt);try{wt(r,`${JSON.stringify(o,void 0,4)}
|
|
4
4
|
`)}catch{return}return{file:"package.json",installCommand:t}},zi=async(s,e)=>{const t=Ui(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=Ss({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${be}. Its cache hints no-op under @visulima/task-runner unless aliased to ${kt} (a drop-in replacement).`);const o=await new Promise(i=>{r.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(o.trim()))return Vi(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const a=Hi(s,t.manager);return a===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${be}": "${tt}" to ${a.file}. Run \`${a.installCommand}\` to apply it.`),!0)}finally{r.close()}},Yi=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,Ji=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Ki=(s,e,t)=>{const r=new Set,o=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:o};const a=[...t],i=new Set(a),d=new Map;for(const u of a){const f=u.lastIndexOf(":");if(f===-1)continue;const h=u.slice(f+1),p=d.get(h);p===void 0?d.set(h,[u]):p.push(u)}for(const u of Ji(s)){if(u.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${u}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(u)){r.add(u);continue}const f=ni(u);if(!f){o.push(u);continue}let h=!1;switch(f.kind){case"all":{const p=d.get(f.target)??[];for(const l of p)r.add(l),h=!0;break}case"project":{const p=f.projects?.[0];if(p!==void 0){const l=`${p}:${f.target}`;i.has(l)&&(r.add(l),h=!0)}break}case"tag":{const{tag:p}=f;if(p!==void 0){const l=d.get(f.target)??[];for(const $ of l){const R=$.slice(0,$.lastIndexOf(":"));e.projects[R]?.tags?.includes(p)===!0&&(r.add($),h=!0)}}break}}h||o.push(u)}return{skipTaskIds:r,unmatchedPatterns:o}},Xi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,Qi=new Set(["0","!","#","$","*","-","?","@","_"]),Zi=s=>{const e=new Map;for(const t of s.matchAll(Xi)){const r=t[1],o=t[3],a=t[2],i=r??o;if(i===void 0||Qi.has(i))continue;const d=a!==void 0,u=e.get(i);u===void 0?e.set(i,d):u&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},en=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:o}=s,a=Zi(e);if(a.length===0)return;const i=[];for(const{hasDefault:d,name:u}of a){if(d)continue;const f=r[u],h=t[u];f===void 0&&h===void 0&&i.push(u)}if(i.length!==0)return{missing:i.toSorted(),taskId:o}},tn=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},ns=s=>{const e=new Set;for(const t of Object.values(s.projects))for(const r of Object.keys(t.targets??{}))e.add(r);return[...e].sort()},sn=s=>{const e=new Map;for(const t of s.values())for(const[r,o]of Object.entries(t))for(const a of o.aliases??[])e.has(a)||e.set(a,r);return e},rn=(s,e)=>e.get(s)??s,nn=(s,e)=>{if(s.length===0)return e.length;if(e.length===0)return s.length;const t=[];for(let r=0;r<=e.length;r++)t[r]=[r];for(let r=0;r<=s.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=s.length;o++){const a=e[r-1]===s[o-1]?0:1;t[r][o]=Math.min(t[r-1][o]+1,t[r][o-1]+1,t[r-1][o-1]+a)}return t[e.length][s.length]},on=(s,e,t=3)=>Ds(s,e,1,t)[0],Ds=(s,e,t=3,r=3)=>{const o=[];for(const a of e){const i=nn(s.toLowerCase(),a.toLowerCase());i<=r&&o.push({distance:i,name:a})}return o.sort((a,i)=>a.distance-i.distance||a.name.localeCompare(i.name)),o.slice(0,t).map(a=>a.name)},an=s=>s.length===0?" (no targets found)":s.map(e=>` - ${e}`).join(`
|
|
@@ -6,13 +6,13 @@ Delete this file to be asked again.
|
|
|
6
6
|
`);for(const[o,a]of s.entries())process.stdout.write(` ${String(o+1).padStart(2," ")}. ${a}
|
|
7
7
|
`);process.stdout.write(`
|
|
8
8
|
`);const t=(await new Promise(o=>{e.question("Select a target (number or name, blank to cancel): ",o)})).trim();if(t.length===0)return;const r=Number.parseInt(t,10);return Number.isFinite(r)&&r>=1&&r<=s.length?s[r-1]:s.includes(t)?t:on(t,s)}finally{e.close()}},ln=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),ut=s=>s.replaceAll(ln,"").replaceAll("\r","");class os{#e=[];#r=new Set;#s=new Map;#i=new Map;constructor(e=[]){for(const t of e)this.#i.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#n()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#i.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#i.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#i.has(e)||(this.#i.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const o=r?.message;this.#t(e,a=>({...a,errorMessage:ut(o??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-256).map(o=>ut(o));this.#t(e,o=>({...o,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
|
|
9
|
-
`).map(o=>ut(o)).filter(o=>o.length>0);r.length!==0&&this.#t(e,o=>{const a=[...o.tailLines,...r];for(;a.length>256;)a.shift();let i=0;for(let d=a.length-1;d>=0;d--)if(i+=a[d].length+1,i>65536){a.splice(0,d+1);break}return{...o,lastLine:r[r.length-1],tailLines:a}})}abortBoot(e){let t=!1;const r=new Map(this.#i);for(const[o,a]of r)(a.status==="pending"||a.status==="starting")&&(r.set(o,{...a,errorMessage:e,status:"failed"}),t=!0);t&&(this.#i=r,this.#n(),this.#o())}#t(e,t){const r=this.#i.get(e);r&&(this.#i.set(e,t(r)),this.#n(),this.#o())}#n(){this.#s=new Map(this.#i)}#o(){for(const e of this.#r)try{e()}catch{}}}const dn=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(const[t,r]of s.entries())if(!Object.is(r,e[t]))return!1;return!0},as=({children:s,deps:e,onRender:t,style:r,width:o})=>{const a=z.useRef(null),i=z.useRef(!1),d=z.useRef(e),u=z.useRef(s),f=z.useRef(t);f.current=t;let h=!1;e!==void 0?dn(d.current,e)||(h=!0,d.current=e):s!==u.current&&(h=!0,u.current=s),h&&(i.current=!1,a.current&&(a.current.cachedRender=void 0)),z.useLayoutEffect(()=>{const l=a.current;l&&(l.internal_onRendered=()=>{i.current=!0,f.current?.(l)})}),z.useEffect(()=>()=>{const l=a.current;l&&(l.cachedRender=void 0,l.internal_onRendered=void 0)},[]);const p=z.useMemo(()=>({...r,width:o}),[r,o]);return n.jsx("ink-static-render",{ref:a,style:p,children:i.current?null:s()})},un=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),hn=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${un(t)}`,xt=(s,e,t)=>{const r=new Set(new Set(t.map(l=>l.target.target))),o=new Set(new Set(t.map(l=>l.target.project))),a=e.filter(l=>r.has(l)),i=s.filter(l=>o.has(l)),d=t.length-i.length*a.length,u=a.length===1?"target":"targets",f=a.join(", "),h=i.length===1?`project ${i[0]}`:`${i.length} projects`;let p=`${u} ${f} for ${h}`;return d>0&&(p+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),p},fn={error:"red",info:"white",success:"green"},pt=({children:s,title:e,variant:t})=>{const r=fn[t];return n.jsxs(m,{flexDirection:"column",children:[n.jsxs(m,{gap:1,children:[n.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(c,{bold:!0,color:r,children:"•"}),n.jsx(c,{children:e})]}),s]})},Ls=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:o,skippedIds:a,succeeded:i,targets:d,tasks:u,took:f})=>{const h=xt(r,d,u),p=o??[];if(e===0&&(!a||a.length===0)){const l=s>0?` (${s} read from cache)`:"";return n.jsx(as,{children:()=>n.jsx(pt,{title:`Successfully ran ${h}`,variant:"success",children:n.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n.jsxs(c,{children:[n.jsx(c,{color:"green",children:Cs})," ",i+s," tasks completed",l?n.jsx(c,{dimColor:!0,children:l}):null,n.jsx(c,{dimColor:!0,children:` · Took ${f}`})]}),p.length>0&&n.jsxs(m,{flexDirection:"column",marginTop:1,children:[n.jsxs(c,{children:[n.jsx(c,{color:"yellow",children:"↻"})," ",n.jsx(c,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map($=>n.jsxs(c,{children:[" ",n.jsx(c,{color:"yellow",children:"↻"})," ",$]},$))]})]})})})}return n.jsx(as,{children:()=>n.jsx(pt,{title:`Ran ${h}`,variant:"error",children:n.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[a&&a.length>0&&n.jsxs(m,{flexDirection:"column",children:[n.jsxs(c,{dimColor:!0,children:[a.length," ","task",a.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),a.map(l=>n.jsxs(c,{dimColor:!0,children:[" - ",l]},l)),n.jsx(c,{})]}),e>0&&n.jsxs(m,{flexDirection:"column",children:[n.jsxs(c,{children:[n.jsx(c,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(l=>n.jsxs(c,{children:[" ",n.jsx(c,{color:"red",children:Is})," ",l]},l)),n.jsx(c,{})]}),p.length>0&&n.jsxs(m,{flexDirection:"column",children:[n.jsxs(c,{children:[n.jsx(c,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(l=>n.jsxs(c,{children:[" ",n.jsx(c,{color:"yellow",children:"↻"})," ",l]},l)),n.jsx(c,{})]}),n.jsx(c,{dimColor:!0,children:` Took ${f}`})]})})})};class rt{#e;#r=new Set;#s=new Map;constructor(e,t){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:t??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const t=[...this.#e.rows];for(const r of e){const o=t.findIndex(a=>a.taskId===r.id);o!==-1&&(t[o]={...t[o],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:t,running:this.#e.running+e.length})}endTasks(e){const t=[...this.#e.rows];let{cached:r,completed:o,failed:a,succeeded:i}=this.#e;const d=new Map(this.#e.outputs),u=[...this.#e.retriedIds];for(const p of e){const l=t.findIndex($=>$.taskId===p.task.id);switch(l!==-1&&(t[l]={...t[l],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&u.push(p.task.id),o++,p.status){case"failure":{a++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}p.terminalOutput&&!d.has(p.task.id)&&d.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:f}=this.#e;if(a>this.#e.failed){const p=t.findIndex(l=>l.status==="failure");p!==-1&&(f=p)}const h=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:o,failed:a,outputs:d,retriedIds:u,rows:t,running:h,selectedIndex:f,succeeded:i})}static#i=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>rt.#i&&(r=r.slice(-rt.#i)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const t=[...this.#e.rows];for(let r=0;r<t.length;r++){const o=t[r];if(o.status==="running"){const a=this.#s.get(o.taskId);if(a){const i=process.hrtime(a),d=i[0]*1e3+i[1]/1e6;t[r]={...o,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const r=[...this.#e.pinnedTaskIds];r[e]=t,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],r=t.findIndex(d=>d.taskId===e);let{completed:o,failed:a,succeeded:i}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(a=Math.max(0,a-1),o=Math.max(0,o-1)):d==="success"&&(i=Math.max(0,i-1),o=Math.max(0,o-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:o,done:!1,endTime:null,failed:a,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const t of this.#r)try{t()}catch{}}}const pn=s=>
|
|
9
|
+
`).map(o=>ut(o)).filter(o=>o.length>0);r.length!==0&&this.#t(e,o=>{const a=[...o.tailLines,...r];for(;a.length>256;)a.shift();let i=0;for(let d=a.length-1;d>=0;d--)if(i+=a[d].length+1,i>65536){a.splice(0,d+1);break}return{...o,lastLine:r[r.length-1],tailLines:a}})}abortBoot(e){let t=!1;const r=new Map(this.#i);for(const[o,a]of r)(a.status==="pending"||a.status==="starting")&&(r.set(o,{...a,errorMessage:e,status:"failed"}),t=!0);t&&(this.#i=r,this.#n(),this.#o())}#t(e,t){const r=this.#i.get(e);r&&(this.#i.set(e,t(r)),this.#n(),this.#o())}#n(){this.#s=new Map(this.#i)}#o(){for(const e of this.#r)try{e()}catch{}}}const dn=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(const[t,r]of s.entries())if(!Object.is(r,e[t]))return!1;return!0},as=({children:s,deps:e,onRender:t,style:r,width:o})=>{const a=z.useRef(null),i=z.useRef(!1),d=z.useRef(e),u=z.useRef(s),f=z.useRef(t);f.current=t;let h=!1;e!==void 0?dn(d.current,e)||(h=!0,d.current=e):s!==u.current&&(h=!0,u.current=s),h&&(i.current=!1,a.current&&(a.current.cachedRender=void 0)),z.useLayoutEffect(()=>{const l=a.current;l&&(l.internal_onRendered=()=>{i.current=!0,f.current?.(l)})}),z.useEffect(()=>()=>{const l=a.current;l&&(l.cachedRender=void 0,l.internal_onRendered=void 0)},[]);const p=z.useMemo(()=>({...r,width:o}),[r,o]);return n.jsx("ink-static-render",{ref:a,style:p,children:i.current?null:s()})},un=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),hn=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${un(t)}`,xt=(s,e,t)=>{const r=new Set(new Set(t.map(l=>l.target.target))),o=new Set(new Set(t.map(l=>l.target.project))),a=e.filter(l=>r.has(l)),i=s.filter(l=>o.has(l)),d=t.length-i.length*a.length,u=a.length===1?"target":"targets",f=a.join(", "),h=i.length===1?`project ${i[0]}`:`${i.length} projects`;let p=`${u} ${f} for ${h}`;return d>0&&(p+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),p},fn={error:"red",info:"white",success:"green"},pt=({children:s,title:e,variant:t})=>{const r=fn[t];return n.jsxs(m,{flexDirection:"column",children:[n.jsxs(m,{gap:1,children:[n.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(c,{bold:!0,color:r,children:"•"}),n.jsx(c,{children:e})]}),s]})},Ls=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:o,skippedIds:a,succeeded:i,targets:d,tasks:u,took:f})=>{const h=xt(r,d,u),p=o??[];if(e===0&&(!a||a.length===0)){const l=s>0?` (${s} read from cache)`:"";return n.jsx(as,{children:()=>n.jsx(pt,{title:`Successfully ran ${h}`,variant:"success",children:n.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n.jsxs(c,{children:[n.jsx(c,{color:"green",children:Cs})," ",i+s," tasks completed",l?n.jsx(c,{dimColor:!0,children:l}):null,n.jsx(c,{dimColor:!0,children:` · Took ${f}`})]}),p.length>0&&n.jsxs(m,{flexDirection:"column",marginTop:1,children:[n.jsxs(c,{children:[n.jsx(c,{color:"yellow",children:"↻"})," ",n.jsx(c,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map($=>n.jsxs(c,{children:[" ",n.jsx(c,{color:"yellow",children:"↻"})," ",$]},$))]})]})})})}return n.jsx(as,{children:()=>n.jsx(pt,{title:`Ran ${h}`,variant:"error",children:n.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[a&&a.length>0&&n.jsxs(m,{flexDirection:"column",children:[n.jsxs(c,{dimColor:!0,children:[a.length," ","task",a.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),a.map(l=>n.jsxs(c,{dimColor:!0,children:[" - ",l]},l)),n.jsx(c,{})]}),e>0&&n.jsxs(m,{flexDirection:"column",children:[n.jsxs(c,{children:[n.jsx(c,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(l=>n.jsxs(c,{children:[" ",n.jsx(c,{color:"red",children:Is})," ",l]},l)),n.jsx(c,{})]}),p.length>0&&n.jsxs(m,{flexDirection:"column",children:[n.jsxs(c,{children:[n.jsx(c,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(l=>n.jsxs(c,{children:[" ",n.jsx(c,{color:"yellow",children:"↻"})," ",l]},l)),n.jsx(c,{})]}),n.jsx(c,{dimColor:!0,children:` Took ${f}`})]})})})};class rt{#e;#r=new Set;#s=new Map;constructor(e,t){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:t??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const t=[...this.#e.rows];for(const r of e){const o=t.findIndex(a=>a.taskId===r.id);o!==-1&&(t[o]={...t[o],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:t,running:this.#e.running+e.length})}endTasks(e){const t=[...this.#e.rows];let{cached:r,completed:o,failed:a,succeeded:i}=this.#e;const d=new Map(this.#e.outputs),u=[...this.#e.retriedIds];for(const p of e){const l=t.findIndex($=>$.taskId===p.task.id);switch(l!==-1&&(t[l]={...t[l],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&u.push(p.task.id),o++,p.status){case"failure":{a++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}p.terminalOutput&&!d.has(p.task.id)&&d.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:f}=this.#e;if(a>this.#e.failed){const p=t.findIndex(l=>l.status==="failure");p!==-1&&(f=p)}const h=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:o,failed:a,outputs:d,retriedIds:u,rows:t,running:h,selectedIndex:f,succeeded:i})}static#i=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>rt.#i&&(r=r.slice(-rt.#i)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const t=[...this.#e.rows];for(let r=0;r<t.length;r++){const o=t[r];if(o.status==="running"){const a=this.#s.get(o.taskId);if(a){const i=process.hrtime(a),d=i[0]*1e3+i[1]/1e6;t[r]={...o,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const r=[...this.#e.pinnedTaskIds];r[e]=t,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],r=t.findIndex(d=>d.taskId===e);let{completed:o,failed:a,succeeded:i}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(a=Math.max(0,a-1),o=Math.max(0,o-1)):d==="success"&&(i=Math.max(0,i-1),o=Math.max(0,o-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:o,done:!1,endTime:null,failed:a,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const t of this.#r)try{t()}catch{}}}const pn=s=>Bi(s),gn=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,mn=/^\s*at\s+/,wn=s=>{const e=s.split(`
|
|
10
10
|
`);let t;for(let r=0;r<e.length;r++){const o=gn.exec(e[r].trim());if(!o)continue;const a=[];for(let i=r+1;i<e.length&&i<=r+200;i++){const d=e[i];if(mn.test(d))a.push(d.trim());else if(a.length>0||d.trim()!=="")break}if(a.length>0){const i=o.groups?.name??"Error",d=o.groups?.message??"";t={message:d,name:i,stack:`${i}: ${d}
|
|
11
11
|
${a.map(u=>` ${u}`).join(`
|
|
12
12
|
`)}`}}}return t},Bs=s=>{if(s.startsWith("file://"))try{return yi(s)}catch{return s}return s},yn=s=>!s.includes("node_modules")&&!s.startsWith("node:")&&!s.startsWith("internal/"),vn=s=>{try{return Si(s)}catch{return}},kn=(s,e)=>{if(!s.file||s.line===void 0)return;const t=Bs(s.file),r=gi(t)?t:Qt(e,t);if(!yn(r)||!Ae(r))return;const o=vn(r);if(o){const a=$i(o,{column:s.column===void 0?0:Math.max(0,s.column-1),line:s.line});if(a.source&&a.line!=null){const i=Qt(mi(r),a.source),d=bi(o,a.source)??(Ae(i)?Ge(i,"utf8"):void 0);if(d!==void 0)return{column:a.column==null?void 0:a.column+1,file:i,line:a.line,source:d}}}return{column:s.column,file:r,line:s.line,source:Ge(r,"utf8")}},cs=(s,e)=>{const t=wi(e,s);return t&&!t.startsWith("..")?t:s},Ns=(s,e)=>{if(!s?.trim())return s;try{const t=wn(pn(s));if(!t)return s;const r=new Error(t.message);r.name=t.name,r.stack=t.stack;const o=xi(r);if(o.length===0)return s;const a=e.color,i={dim:l=>a?Zt(l):l,head:l=>a?ki(dt(l)):l,loc:l=>a?vi(l):l};let d,u;for(const l of o){const $=kn(l,e.cwd);if($){d=$,u=l;break}}const f=[i.head(`✖ ${t.name}${t.message?`: ${t.message}`:""}`)];if(d){const l=`${cs(d.file,e.cwd)}:${d.line}${d.column?`:${d.column}`:""}`;f.push(` ${i.loc(l)}`,""),f.push(ji(d.source,{start:{column:d.column,line:d.line}},{color:a?{gutter:Zt,marker:dt,message:dt}:void 0,linesAbove:2,linesBelow:3}))}const h=o.filter(l=>l!==u).slice(0,8).map(l=>{const $=l.methodName??"<anonymous>",R=l.file?`${cs(Bs(l.file),e.cwd)}${l.line?`:${l.line}`:""}`:"";return i.dim(` at ${$}${R?` (${R})`:""}`)});h.length>0&&f.push("",...h);const p=i.dim("─".repeat(40));return`${f.join(`
|
|
13
13
|
`)}
|
|
14
14
|
${p}
|
|
15
|
-
${s}`}catch{return s}},xn={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},De=s=>
|
|
15
|
+
${s}`}catch{return s}},xn={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},De=s=>Pi(s,xn),Ne=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",_e=s=>{switch(s){case"failure":return{color:"red",icon:Is};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Cs};case"skipped":return{color:"gray",icon:ot};default:return{color:"gray",icon:"?"}}},ze=s=>{const{color:e,icon:t}=_e(s);return he(K.createElement(c,{color:e},t),{columns:10}).trim()},jn=s=>{const{color:e,icon:t}=_e(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return he(K.createElement(c,null,K.createElement(c,{color:e},t)," ",K.createElement(c,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return he(K.createElement(c,null,K.createElement(c,{dimColor:!0},t)," ",K.createElement(c,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return he(K.createElement(c,{color:e},t),{columns:10}).trim()}},$n=s=>s==="azure"||s==="buildkite"||s==="github"||s==="gitlab"||s==="off"?s:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",bn=s=>{const e=s.replaceAll(/\W+/g,"_"),t=Ti("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},Sn=(s,e,t,r="auto")=>{const o=t.trim();if(!o)return;const a=`
|
|
16
16
|
`,i=$n(r);if(i==="github"){process.stdout.write(`::group::${ze(e)} ${s}${a}`),process.stdout.write(o+a),process.stdout.write(`::endgroup::${a}`);return}if(i==="gitlab"){const p=Math.floor(Date.now()/1e3),l=bn(s),$=e==="failure"?"":"[collapsed=true]",R="\x1B[0K";process.stdout.write(`${R}section_start:${String(p)}:${l}${$}\r${R}${ze(e)} ${s}${a}`),process.stdout.write(o+a);const G=Math.floor(Date.now()/1e3);process.stdout.write(`${R}section_end:${String(G)}:${l}\r${R}${a}`);return}if(i==="buildkite"){const p=e==="failure"?"+++":"---";process.stdout.write(`${p} ${ze(e)} ${s}${a}`),process.stdout.write(o+a);return}if(i==="azure"){process.stdout.write(`##[group]${ze(e)} ${s}${a}`),process.stdout.write(o+a),process.stdout.write(`##[endgroup]${a}`);return}const d=process.stdout.columns||80,u=he(K.createElement(c,{dimColor:!0},ot.repeat(d)),{columns:d}).trim(),f=jn(e),h=he(K.createElement(c,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${u}${a}`),process.stdout.write(`${f} ${h}${a}`),process.stdout.write(o+a),process.stdout.write(`${u}${a}`)},Tn=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:_e(s),Cn=({autoScroll:s,focused:e,interactiveMode:t,showFullscreenHint:r,statusValue:o,supportsInteractive:a,taskId:i})=>{if(!i)return;if(t)return"Esc cancel | Enter send";const d=s?"":" PAUSED (f resume)",u=a?" i INPUT":"";return e&&o==="running"&&r?`⏎ FULLSCREEN${u} f FOLLOW${d}`:e&&o==="running"?`f FOLLOW${u}${d}`:e&&r?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},ls=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:o,scrollRef:a,showFullscreenHint:i,status:d,supportsInteractive:u=!0,taskId:f})=>{const h=d??"pending",{icon:p}=Tn(h),l=t?"bold":"single",$=h==="failure"?"red":h==="success"||Ne(h)?t?"green":"gray":h==="running"?t?"white":"cyan":t?"white":"gray",R=f?`${p} ${f}`:void 0,G=e===void 0?void 0:De(e),V=Cn({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:i??!1,statusValue:h,supportsInteractive:u,taskId:f});if(!f)return n.jsxs(m,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[n.jsx(c,{dimColor:!0,children:"Select a task to view output"}),n.jsx(c,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const j=[];if(o)for(const I of o.split(`
|
|
17
17
|
`))j.push(I.endsWith("\r")?I.slice(0,-1):I);return!o&&(h==="running"||h==="pending")?n.jsx(m,{borderBottomTitle:V,borderColor:$,borderStyle:l,borderTopRightTitle:G,borderTopTitle:R,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:n.jsx(m,{alignItems:"center",flexGrow:1,justifyContent:"center",children:n.jsx(c,{dimColor:!0,children:"Waiting for task output…"})})}):n.jsxs(m,{borderBottomTitle:V,borderColor:r?"yellow":$,borderStyle:l,borderTopRightTitle:G,borderTopTitle:R,flexDirection:"column",flexGrow:1,children:[n.jsx(m,{flexGrow:1,flexShrink:1,paddingY:1,children:n.jsx(bs,{flexGrow:1,followOutput:s,paddingX:2,ref:a,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:n.jsx(c,{children:j.join(`
|
|
18
18
|
`)})})}),r&&n.jsx(m,{flexShrink:0,justifyContent:"center",paddingX:1,children:n.jsx(c,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},In={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Gs=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",Rn=({status:s})=>s==="starting"?n.jsx(c,{color:"cyan",children:n.jsx(Es,{type:"dots"})}):n.jsx(c,{bold:!0,color:Gs(s),children:In[s]}),En=({active:s,focused:e,state:t})=>{const r=e&&s,o=r?">":" ",a=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return n.jsxs(m,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[n.jsx(c,{children:o}),n.jsx(c,{children:" "}),n.jsx(m,{flexShrink:0,width:3,children:n.jsx(Rn,{status:t.status})}),n.jsx(m,{flexGrow:0,flexShrink:0,width:28,children:n.jsx(c,{bold:r,inverse:r,children:t.id})}),n.jsx(m,{flexGrow:1,flexShrink:1,overflow:"hidden",children:n.jsxs(c,{color:Gs(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",a]})})]})},Mn=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return n.jsxs(m,{paddingX:1,children:[n.jsxs(c,{bold:!0,color:"green",children:["● ","Services"]}),n.jsxs(c,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&n.jsxs(c,{dimColor:!0,children:[" ",t]}),n.jsx(c,{dimColor:!0,children:" [Tab ↓]"})]})},Fn=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?n.jsxs(m,{flexDirection:"column",paddingX:1,children:[n.jsxs(c,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>n.jsxs(c,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):n.jsx(n.Fragment,{})},On=({activeIndex:s,focused:e,store:t})=>{const r=z.useSyncExternalStore(t.subscribe,t.getSnapshot),o=t.getIds();if(o.length===0)return n.jsx(n.Fragment,{});const a=o.map(h=>r.get(h)).filter(h=>h!==void 0),i=t.getDockState(),d=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",u=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",f=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?n.jsx(m,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:n.jsx(Mn,{states:a})}):n.jsxs(m,{borderBottomTitle:f,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&n.jsx(Fn,{states:a}),a.map((h,p)=>n.jsx(En,{active:p===s,focused:e,state:h},h.id))]})},_s=6,qs=8,Ws=12,Pn=s=>s==="running"||s==="pending"?Rs:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":ot,ds=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",us=({compact:s,focused:e,isSelected:t,pinLabel:r,row:o})=>{const{persistent:a,status:i,taskId:d}=o,u=e&&t,f=u?">":" ",h=i==="running"&&a===!0;let p;if(h)p=n.jsx(c,{bold:!0,color:"green",children:" ● "});else if(i==="running")p=n.jsxs(c,{bold:!0,color:"white",children:[" ",n.jsx(Es,{type:"dots"})," "]});else if(i==="pending")p=n.jsx(c,{bold:!0,color:"gray",children:" · "});else{const{color:$,icon:R}=_e(i);p=n.jsxs(c,{bold:!0,color:$,children:[" ",R," "]})}let l=Rs;return h?l="running":i!=="running"&&i!=="pending"?l=o.duration===void 0?ot:De(o.duration):i==="running"&&o.elapsed!==void 0&&(l=De(o.elapsed)),n.jsxs(m,{children:[n.jsx(c,{children:f}),n.jsx(m,{width:_s,children:p}),n.jsxs(m,{flexGrow:1,children:[n.jsx(c,{bold:u,inverse:u,children:d}),r?n.jsx(c,{dimColor:!0,children:` ${r}`}):null]}),!s&&n.jsx(m,{justifyContent:"flex-end",width:qs,children:n.jsx(c,{dimColor:!Ne(i),children:Pn(i)})}),!s&&n.jsx(m,{justifyContent:"flex-end",width:Ws,children:n.jsx(c,{color:h?"green":void 0,dimColor:i==="pending"||h,children:l})})]})},hs=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:o,parallelSlots:a=3,pinnedTaskIds:i,rows:d,scrollRef:u,selectedIndex:f,title:h})=>{const p=o==="error"?"red":o==="success"?"green":r?"white":"gray",l=d[f]?.taskId,$=[];let R=0;for(const I of d)I.status==="running"?$.push(I):I.status==="pending"&&(R+=1);const G=Math.min(a,$.length+R),V=G>1,j=[];if(V)for(let I=0;I<G;I++){const S=$[I];S?j.push(n.jsx(us,{compact:s,focused:r,isSelected:S.taskId===l,pinLabel:ds(S.taskId,i),row:S},`par-${S.taskId}`)):j.push(n.jsxs(m,{children:[n.jsx(c,{children:" "}),n.jsx(m,{width:_s,children:n.jsx(c,{bold:!0,color:"gray",children:" · "})}),n.jsx(c,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(I)}`))}return n.jsxs(m,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n.jsxs(m,{flexShrink:0,paddingX:1,children:[n.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(c,{children:` ${h}`}),!s&&n.jsxs(m,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[n.jsx(m,{justifyContent:"flex-end",width:qs,children:n.jsx(c,{dimColor:!0,children:"Cache"})}),n.jsx(m,{justifyContent:"flex-end",width:Ws,children:n.jsx(c,{dimColor:!0,children:"Duration"})})]})]}),n.jsx(bs,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:u,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(I=>n.jsx(us,{compact:s,focused:r,isSelected:I.taskId===l,pinLabel:ds(I.taskId,i),row:I},I.taskId))}),V&&n.jsx(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:j}),e&&n.jsxs(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[n.jsx(c,{bold:!0,color:"white",children:"/ "}),n.jsx(c,{children:t}),n.jsx(c,{inverse:!0,children:" "})]})]})},fs=40,ps=10,gs=100,An=Object.freeze([]),Dn=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:o,stdinRegistry:a,store:i,targets:d,tasks:u})=>{const{exit:f}=$r(),{columns:h,rows:p}=br(),l=z.useSyncExternalStore(i.subscribe,i.getSnapshot),$=z.useCallback(T=>o?o.subscribe(T):()=>{},[o]);z.useSyncExternalStore($,()=>o?o.getDockState():"ready");const R=o?o.getIds():An,G=R.length>0,[V,j]=z.useState(0),[I,S]=z.useState(null),x=z.useSyncExternalStore($,()=>I&&o?o.getState(I):void 0),[O,w]=z.useState(!1),A=z.useRef(null),b=z.useRef(null),M=z.useRef(null),[H,te]=z.useState(!1),[fe,W]=z.useState(!0),Y=z.useRef({list:0,splitList:0,splitOutput:0}),ce=z.useCallback(()=>{l.viewMode==="list"?Y.current.list=b.current?.getScrollOffset()??0:l.viewMode==="split"&&(Y.current.splitList=b.current?.getScrollOffset()??0,Y.current.splitOutput=M.current?.getScrollOffset()??0)},[l.viewMode]),re=z.useCallback(T=>{setTimeout(()=>{if(T==="list"){const v=Y.current.list;b.current?.scrollTo(v)}else if(T==="split"){const v=Y.current.splitList;v>0?b.current?.scrollTo(v):b.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),M.current?.scrollTo(Y.current.splitOutput)}},0)},[i]),ae=z.useRef(!1);z.useEffect(()=>{l.done&&!ae.current&&(ae.current=!0,s>0&&l.failed===0&&te(!0)),!l.done&&ae.current&&(ae.current=!1,te(!1))},[l.done,l.failed,s]);const ne=z.useMemo(()=>{const T=R.length>0?new Set(R):null,v=l.filterText?l.filterText.toLowerCase():null,C=[];for(const ee of l.rows)T?.has(ee.taskId)||l.statusFilter==="failed"&&ee.status!=="failure"||l.statusFilter==="running"&&ee.status!=="running"&&ee.status!=="pending"||l.statusFilter==="passed"&&ee.status!=="success"&&!Ne(ee.status)||v&&!ee.taskId.toLowerCase().includes(v)||C.push(ee);return C},[l.rows,l.filterText,l.statusFilter,R]),U=(ne[l.selectedIndex]??null)?.taskId??null,_=I?null:l.pinnedTaskIds[0]??U,X=_?l.rows.find(T=>T.taskId===_):null,pe=x??null,je=I?(pe?.tailLines??[]).join(`
|
|
@@ -180,11 +180,11 @@ ${this.#r}`:this.#r}}const zs=s=>{const e=s.overrides.visOptions;if(e&&typeof e=
|
|
|
180
180
|
`));const Y=$?.get(t.id),ce={INIT_CWD:d,VIS_TASK_SLOTS:String(j),...fe,...Y,...r.env,...W,...t.overrides[St]};if(S?.strictEnv??V??!1){const E=en({command:A,processEnv:process.env,taskEnv:ce,taskId:t.id});if(E){const ge=tn(E);return u?.onTaskStderr?.(t,ge),{code:1,terminalOutput:ge}}}const re=S?.pty===!0,ae=!!G,ne=t.pty===!0?!0:t.pty===!1?!1:ae||re;ne&&(t.cache=!1);const U=ne?void 0:new Lo(it),_=ne?new mt(it):void 0;let X;const pe=E=>{if(E.kind==="started"&&(X=E.kill,E.write&&G&&G.set(t.id,{kill:E.kill,resize:E.resize,write:E.write}),R?.onRegistryTaskStarted(t.id)),(E.kind==="stdout"||E.kind==="stderr")&&E.text!==void 0)if(E.kind==="stdout"?u?.onTaskStdout?.(t,E.text):u?.onTaskStderr?.(t,E.text),_)_.write(E.text),ae&&p?.(t.id,_.toString()),R&&R.onTaskOutput(t.id,E.text);else{const ge=`${E.text}
|
|
181
181
|
`;U.append(ge),h?.(t.id,ge)}E.kind==="close"&&(G&&G.delete(t.id),R&&R.onRegistryTaskClosed(t.id,E.exitCode??0,!!E.killed).catch(()=>{}))},je=async()=>{const E=S?.retryCount??0,ge=S?.retryDelay,Ie=l?l.claim(E):E,Me=typeof S?.timeout=="number"&&S.timeout>0?S.timeout:0,Le=typeof S?.killGracePeriodMs=="number"&&S.killGracePeriodMs>=0?S.killGracePeriodMs:5e3;let Fe=!1,Z=0;const Oe=zn({killGracePeriodMs:Le,onTimeout:()=>{Fe=!0},sendSignal:ve=>{X?.(ve)},timeoutMs:Me});let we;try{we=await Qe([{command:te,cwd:x,env:ce,name:t.id,...ne?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:pe,...Ie>0?{restart:{delay:ge??"exponential",onRetry:async(ve,Se,T)=>{Z=ve,i&&await i.callHook("task:retry",t,ve,T)},tries:Ie}}:{}})}finally{Oe.cancel()}const de=we.closeEvents[0],ye=_?_.toString():U.toString();return Fe?{code:124,retryAttempts:Z,terminalOutput:`${ye}
|
|
182
182
|
[timeout] Task "${t.id}" exceeded ${Me}ms budget.
|
|
183
|
-
`}:{code:de?.exitCode??1,retryAttempts:Z,terminalOutput:ye}};return f?_o(f,S?.mutex,je):je()}},Uo=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},Vo=async(s,e)=>{const t=await vr(s,{dataDirectory:Ze(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${kr(s,{dataDirectory:Ze(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const a=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of a){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const o=[...t.tasks].filter(a=>typeof a.duration=="number").sort((a,i)=>(i.duration??0)-(a.duration??0)).slice(0,5);if(o.length>0){e.info("Slowest tasks:");for(const a of o)e.info(` ${a.taskId.padEnd(40)} ${String(a.duration??0).padStart(6)}ms [${a.cacheStatus}]`);e.info("")}},Ho=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},zo=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},Yo=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},
|
|
183
|
+
`}:{code:de?.exitCode??1,retryAttempts:Z,terminalOutput:ye}};return f?_o(f,S?.mutex,je):je()}},Uo=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},Vo=async(s,e)=>{const t=await vr(s,{dataDirectory:Ze(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${kr(s,{dataDirectory:Ze(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const a=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of a){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const o=[...t.tasks].filter(a=>typeof a.duration=="number").sort((a,i)=>(i.duration??0)-(a.duration??0)).slice(0,5);if(o.length>0){e.info("Slowest tasks:");for(const a of o)e.info(` ${a.taskId.padEnd(40)} ${String(a.duration??0).padStart(6)}ms [${a.cacheStatus}]`);e.info("")}},Ho=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},zo=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},Yo=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},wa=async({argument:s,logger:e,options:t,runtime:r,visConfig:o,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=a;if(zr({logger:e,options:t,visConfig:o},i),fi(i),t.lastDetails===!0){await Vo(i,e);return}const d=process.cwd(),u=await Ar(i),{config:f,packageJsons:h,projectOptions:p,workspace:l}=Dr(i,o,u),$=Lr(i,l,h);let R=s[0];if(!R){const g=ns(l);if(process.stdout.isTTY&&process.stdin.isTTY){const y=await cn(g);if(!y){e.info("No target selected.");return}R=y,await qn(`vis run ${y}`)}else{e.info("Available targets:"),e.info(""),e.info(an(g)),e.info(""),e.info("Usage: vis run <target>");return}}if(f.constraints&&!t.skipConstraints){const g=hr($,f.constraints);if(g.length>0){for(const y of g)e.error(`[${y.rule}] ${y.message}`);throw new Error(`${g.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(t.affected){const g=[R];t.parallel!==void 0&&g.push(`--parallel=${String(t.parallel)}`),t.cache||g.push("--no-cache"),t.query&&g.push(`--query=${String(t.query)}`),t.reverse&&g.push("--reverse"),typeof t.runnerTags=="string"&&t.runnerTags!==""&&g.push(`--runner-tags=${t.runnerTags}`),await r.runCommand("affected",{argv:g});return}const G=await oi(R,l,process.cwd(),i),V=sn(p),j=rn(G.target,V);j!==G.target&&e.debug?.(`Resolved alias "${G.target}" → "${j}"`);let I=G.projects;const S=s.slice(1).map(String);if(t.projects){const g=new Set(t.projects.split(",").map(y=>y.trim()));if(I=I.filter(y=>g.has(y)),I.length===0)throw new Error(`No matching projects found for: ${String(t.projects)}`)}if(t.filter&&t.filter.length>0){const g=new Map;for(const[P,q]of h)g.set(P,q.name);const y=await lo(t.filter,{defaultBase:o?.defaultBase,packageNameByProject:g,projectGraph:$,workspaceRoot:i}),k=new Set(y);if(I=I.filter(P=>k.has(P)),I.length===0){e.info(`Filter ${t.filter.map(P=>`"${P}"`).join(", ")} matched no projects.`);return}}if(t.query&&(I=ai(I,l,t.query),I.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}const x=ci(),O=process.env[$t],w=O?O.split(`
|
|
184
184
|
`).filter(Boolean):void 0,A=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,b=A?new Set(A.split(",").map(g=>g.trim()).filter(Boolean)):void 0,M=[],H=new Map;for(const g of I){const y=p.get(g)?.[j];if(!y)continue;const k=y.options;if(!k?.internal){if(!li(k,!!He)){e.debug?.(`Skipping ${g}:${j} — runInCI filter`);continue}if(!di(k,b)){e.debug?.(`Skipping ${g}:${j} — runner-tags filter`);continue}M.push(g),H.set(g,y)}}if(M.length===0){const g=ns(l),y=Object.entries(l.projects).filter(([,k])=>k.targets?.[j]!==void 0).map(([k])=>k);if(e.error(`No projects have the "${j}" target.`),y.length>0){e.info(""),e.info(`Target "${j}" exists in these projects but was filtered out:`);for(const k of y.slice(0,5))e.info(` - ${k}`);y.length>5&&e.info(` …and ${y.length-5} more`)}else{const k=Ds(j,g,3);k.length>0&&(e.info(""),e.info(k.length===1?`Did you mean "${k[0]}"?`:`Did you mean one of: ${k.map(P=>`"${P}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const te=t.pty===!0,fe=M.map(g=>({project:g,schema:H.get(g)?.arguments})).filter(g=>Array.isArray(g.schema)&&g.schema.length>0),W=new Map;for(const{project:g,schema:y}of fe){const k=JSON.stringify(y),P=W.get(k)??[];P.push(g),W.set(k,P)}if(W.size>1){const g=[...W.values()].map(y=>y.join(", ")).join(" | ");throw new Error(`Target "${j}" declares conflicting \`arguments\` schemas across projects (${g}). Run a single project (e.g. \`vis run ${fe[0]?.project}:${j}\` or --projects=<name>) so the argument contract is unambiguous.`)}const Y=fe[0]?.schema,ce=H.get(fe[0]?.project??M[0])?.description,re=Oo(j,ce,Y,S);if(re.kind==="help"){e.info(re.text);return}if(re.kind==="invalid"){e.info(`Invalid arguments for "${j}":`);for(const g of re.errors)e.info(` ✖ ${g}`);throw e.info(""),e.info(re.help),new Error(`Invalid arguments for target "${j}"`)}const ae=re.env,ne=Yo(t.hashMode);let U=M.map(g=>{const y=l.projects[g],k=H.get(g),P={project:g,target:j},q=`${g}:${j}`,J=te?{...k.options,pty:k.options?.pty??!0}:k.options,L=k.command?Ht(k.command,{affectedFiles:w,projectRoot:y?.root}):k.command,D=y?.root&&y.root.length>0?y.root:".",se=(k.outputs??[]).map(F=>typeof F!="string"?F:F.replaceAll("{projectRoot}",D).replaceAll("{projectName}",g));return{cache:k.cache,hashMode:ne??k.hashMode,id:q,outputs:se,overrides:{command:L,...S.length>0?{[Ys]:S}:{},...Object.keys(ae).length>0?{[St]:ae}:{},...J?{visOptions:J}:{}},parallelism:k.parallelism,projectRoot:y?.root,target:P}});const _=[],X=[];for(const g of U)zs(g)?.persistent?(g.cache=!1,_.push(g)):X.push(g);U=X;const pe=fr(t.partition);if(pe&&(U=pr.partitionTasks(U,pe),e.info(`Partition ${pe.index}/${pe.total}: running ${U.length} task(s)`),U.length===0)){e.info("No tasks assigned to this partition.");return}const je=new Set([...U,..._].map(g=>g.id));let E=gr([...U,..._],{onCycleBroken:g=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${g.join(" → ")}`)},projectGraph:$,targetDefaults:f.tasks,workspace:l});for(const[g,y]of Object.entries(E.tasks)){const k=y.target.project,P=y.target.target,q=p.get(k)?.[P];if(!q){je.has(g)||e.warn(`${P} required via dependsOn but no command is configured for ${k} — skipping (no-op).`);continue}const J=l.projects[k];let L=!1;const D={...y.overrides};D.visOptions===void 0&&q.options&&(D.visOptions=q.options,L=!0),D.command===void 0&&q.command&&(D.command=Ht(q.command,{affectedFiles:w,projectRoot:J?.root}),L=!0),L&&(y.overrides=D,E.tasks[g]=y)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const g=Ki(t.skipCache,l,Object.keys(E.tasks));for(const y of g.skipTaskIds){const k=E.tasks[y];k!==void 0&&(k.cache=!1)}g.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${g.unmatchedPatterns.map(y=>`"${y}"`).join(", ")}`),g.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(g.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Yr(i,f.toolchain,{error:g=>{e.error(g)},info:g=>{e.info(g)},warn:g=>{e.warn(g)}},!!t.skipToolchain);const ge=t.preflight!==!1&&f.preflight?.lockfile!==!1,Ie=Nr(i,He,{warn:g=>{e.warn(g)}},{skip:!ge});if(!Ie.shouldContinue)throw new Error(`${Ie.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);ge&&!He&&process.stdin.isTTY&&process.stdout.isTTY&&await zi(i,{logger:{info:g=>{e.info(g)},warn:g=>{e.warn(g)}},projectManifests:[...h.values()]});const Me=process.env.VIS_VERSION??"0.0.0",Le=t.dryRun?void 0:async g=>{try{return await ii(g.config,{timeoutMs:Po}),!0}catch{return!1}},Fe=await Zr(i),Z=await eo({initialTasks:[...U,..._],probe:Le,registeredEntries:Fe,taskGraph:E,visVersion:Me}),Oe=[];let we,de=0;const ye=[],ve=new Map;let Se=[];const T=new Set;let v=null,C=null;if(Z.diagnostics.length>0){const g=!!(process.stdout.isTTY&&process.stdin.isTTY),y=t.dryRun?"off":So({cli:t.services,config:f.run?.services,isCi:!!He,isPersistentTarget:_.length>0,isTty:g,target:j});if(y==="off"){for(const D of Z.diagnostics)e.error(D.message);throw new Error(`${Z.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}const k=Z.diagnostics.map(D=>D.targetId),P=y,q=P==="registry"?Us(i,k,E):void 0,J=process.argv[1]??"vis",L=$o({missingServiceIds:k,mode:P,taskGraph:E,visBin:J,workspaceRoot:i});if(L.skipped.length>0){for(const{id:D,reason:se}of L.skipped)e.error(`Cannot auto-start ${D}: ${se}`);throw new Error(`${L.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Oe.push(...L.ephemeralPidFiles),we=L.runDir,Se=L.chain;for(const D of L.chain)T.add(D);if(P==="registry"&&(de=L.chain.length,ye.push(...L.chain)),L.chain.length>0){const D=new os(L.chain),se=new Map;if(P==="ephemeral"&&L.runDir)for(const F of L.chain){const N=Vs(L.runDir,`${L.runDir}/bootstrap.mjs`,F);se.set(F,{ephemeral:{configFile:N.configFile,cwd:i,logFile:N.logFile,pidFile:N.pidFile,scriptPath:N.scriptPath},mode:"ephemeral"})}else if(P==="registry"&&q)for(const F of q.services)se.set(F.id,{mode:"registry",registry:{command:F.command,config:F.config,cwd:F.cwd,env:F.env}});if(se.size>0){const F=new po({indexToId:new Map,services:se,sink:{crashed:(N,B)=>{D.markCrashed(N,B)},failed:(N,B,Q)=>{D.markFailed(N,B,Q)},log:(N,B)=>{D.appendLog(N,B)},ready:(N,B)=>{D.markReady(N,B)},started:(N,B)=>{D.markStarted(N,B),P==="registry"&&B!==null&&ve.set(N,B)},starting:N=>{D.markStarting(N)}},workspaceRoot:i});v=D,C=F}}for(const[D,se]of L.serviceEnvByTaskId){const F=Z.serviceEnvByTaskId.get(D)??{};Z.serviceEnvByTaskId.set(D,{...F,...se})}}const ee=new Set(_.map(g=>g.id));if(U=Z.initialTasks.filter(g=>!ee.has(g.id)),E=Z.taskGraph,Se.length>0&&(U=[...Se.map(g=>E.tasks[g]).filter(g=>g!==void 0),...U]),_.length>0){const g=new Set(_.map(J=>J.id)),y={};for(const[J,L]of Object.entries(E.tasks))g.has(J)||(y[J]=L);const k={};for(const[J,L]of Object.entries(E.dependencies))g.has(J)||(k[J]=L.filter(D=>!g.has(D)));const P=new Set;for(const J of Object.values(k))for(const L of J)P.add(L);const q=Object.keys(y).filter(J=>!P.has(J));E={dependencies:k,roots:q,tasks:y}}const{serviceEnvByTaskId:Te}=Z;if(Z.satisfiedServices.length>0){const g=Z.satisfiedServices.map(y=>y.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${g}`),v)for(const y of Z.satisfiedServices)v.registerService(y.id);else v=new os(Z.satisfiedServices.map(y=>y.id));for(const y of Z.satisfiedServices){const k=y.config.readiness?.tcp?.port??y.config.port??0,P=y.config.readiness?.tcp?.host??"127.0.0.1";v.markReady(y.id,{host:P,port:k})}}if(t.reverse&&(E=mr(E),e.debug?.(`Reversed task graph: ${String(E.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const g=Object.keys(E.tasks).length,y=E.roots.length;e.info(`Execution plan (${String(g)} task(s), ${String(y)} root(s)):`),e.info("");const k=new Set,P=(q,J)=>{if(k.has(q))return;k.add(q);for(const F of E.dependencies[q]??[])P(F,J+1);const L=E.tasks[q],D=" ".repeat(J+1),se=`${L?.cache===!1?" (no-cache)":""}${L?.hashMode==="trace"?" (trace)":""}`;e.info(`${D}${q}${se}`)};for(const q of E.roots)P(q,0);for(const q of Object.keys(E.tasks))P(q,0);_.length>0&&(e.info(""),e.info(` + ${String(_.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Tt=Date.now(),Ce=ei(),Ct=(g,y)=>{const k=y instanceof Error?y.message:String(y);e.warn(`Plugin error in ${g}: ${k}`)};await ti(Ce,f.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,It=async g=>{if(!qe)return;const y=Jt(g,E,Tt),k=qe.startsWith("/")?qe:`${i}/${qe}`;await xr(y,k),e.info(`Profile written to ${qe}`)},Ye=f.taskRunner??{},Js=Cr(i,t.cacheDir,Ye.cacheDirectory,f.sharedWorktreeCache),Ks=Ir(Js,i,f.branchScopedCache),Be=Uo(process.env.VIS_RUN_CONCURRENCY_LIMIT);Be&&"invalid"in Be&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Be.invalid} is not a positive number; falling back to default concurrency.`);const Xs=Be&&"value"in Be?Be.value:void 0,ct=t.parallel??Xs??3,Rt=t.strictEnv??f.strictEnv??!1,Et=new Set,Pe={dryRun:t.dryRun??!1,parallel:ct,skipNxCache:!t.cache,summarize:t.summarize??!1,...Ye,cacheDirectory:Ks,dataDirectory:Ye.dataDirectory??Ze(i),namedInputs:f.namedInputs,onDiagnostic:(g,y)=>{Et.has(g)||(Et.add(g),e.warn(y))},onFingerprint:async(g,y)=>{await Ce.callHook("task:fingerprint",g,y)}},Mt=wr(Ye.remoteCache);if(Mt){const g=Ho(t.cacheMode),y=zo(t.cacheBackend);if(Pe.remoteCache={...Mt,...g?{mode:g}:{},...y?{backend:y}:{}},Pe.remoteCache.attestation){const{expectedIdentity:k,requireOnDownload:P}=Pe.remoteCache.attestation;if(!(k!==void 0&&("github"in k&&typeof k.github?.ref=="string"&&typeof k.github.repo=="string"&&typeof k.github.workflow=="string"||"oidcIssuer"in k&&typeof k.oidcIssuer=="string"&&(typeof k.san=="string"||typeof k.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in k&&(!k.sanRegex.startsWith("^")||!k.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:q,isSigstoreInstalled:J}=await import("./loader.js");J()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
|
|
185
185
|
${q(i)}`);const{buildCacheAttestationHooks:L}=await import("./cache-attestation.js");Pe.remoteCache.attestation=L({expectedIdentity:k,onReject:(D,se)=>{e.warn(`[vis run] remote cache entry ${D.slice(0,12)} rejected: attestation ${se}. Treating as a cache miss.`)},onVerifyFailure:D=>{e.warn(`[vis run] attestation verification failed: ${D}`)},requireOnDownload:P,workspaceRoot:i})}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const Qs=process.stdout.isTTY&&!He,Zs=o?.run?.quietOnSuccess===!0,er=f.tui?.autoExit??(Zs?3:!1),Ft={args:{parallel:Pe.parallel,targets:[j]},autoExit:er,projectNames:M,tasks:[...U,..._],totalTaskCount:Object.keys(E.tasks).length+_.length},Ot=typeof t.retryBudget=="number"?t.retryBudget:void 0,Pt=Ot===void 0?void 0:qo(Ot),At=new si(Ce,Ct),Dt=new Hr(i),Lt=Nn(t.outputStyle,o?.run?.quietOnSuccess);if(Z.satisfiedServices.length>0)for(const g of Z.satisfiedServices){const y=Z.serviceDependentsByServiceId.get(g.id)??[];try{await Ce.callHook("service:attach",g,y)}catch(k){Ct("service:attach",k)}}await Ce.callHook("run:before",{tasks:U,workspaceRoot:i});const We=t.stopServices===!0;let Bt=!1;const Nt=()=>{if(Bt)return;Bt=!0,C&&C.dispose().catch(()=>{});const g=We?[...ve.values()]:void 0;Do({extraPids:g,pidFiles:Oe,runDir:we})},Je=()=>{Nt()},Gt=Oe.length>0||we!==void 0||We&&ye.length>0;Gt&&(process.on("SIGINT",Je),process.on("SIGTERM",Je));try{if(Qs){const g=new Map,y=Ln({...Ft,onRetryService:C?F=>C.retry(F):void 0,outputStyle:Lt,serviceDockStore:v,stdinRegistry:g}),{lifeCycle:k,store:P}=y,q=new zt([k,At,Dt]),J=xs({affectedFiles:w,currentOs:x,hooks:Ce,initCwd:d,lifeCycle:q,mutexPool:new Map,onOutput:(F,N)=>{C&&T.has(F)?C.onTaskOutput(F,N):P.addOutput(F,N)},onOutputReplace:(F,N)=>{P.setOutput(F,N)},retryBudget:Pt,serviceEnvByTaskId:Te,serviceEventBridge:C??void 0,stdinRegistry:g,strictEnv:Rt,taskSlots:ct,workspaceRoot:i});let L="rerun",D=null,se=new Map;for(;L!=="quit";){if(L==="rerun"){if(se=await Yt(U,Pe,{lifeCycle:q,projectGraph:$,taskExecutor:J,taskGraph:E,workspaceRoot:i}),_.length>0&&!t.failFast){const F=new Promise(N=>{const B=P.subscribe(()=>{const Q=P.getSnapshot();(Q.rerunRequested||Q.retryTaskId)&&(B(),N())});y.renderIsDone.then(()=>{B(),N()}).catch(()=>{B(),N()})});await vs(_,i,w,d,{abortSignal:F,lifeCycle:q,stdinRegistry:g,store:P},Te)}}else if(L==="retry"&&D){const F=U.find(B=>B.id===D),N=F?.overrides.command;if(F&&N){const B=nt(i,F.projectRoot,!1);q.startTasks?.([F]);const Q=new mt(it),ue=(await Qe([{command:N,cwd:B,name:F.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ie=>{ie.kind==="started"&&ie.write&&g.set(F.id,{kill:ie.kill,resize:ie.resize,write:ie.write}),(ie.kind==="stdout"||ie.kind==="stderr")&&ie.text&&(Q.write(ie.text),P.setOutput(F.id,Q.toString())),ie.kind==="close"&&g.delete(F.id)}})).closeEvents[0];q.endTasks?.([{code:ue?.exitCode??1,status:ue?.exitCode===0?"success":"failure",task:F,terminalOutput:P.getSnapshot().outputs.get(F.id)}])}else F&&q.endTasks?.([{code:1,status:"failure",task:F,terminalOutput:`No command configured for ${F.id}`}]);D=null,P.markDone()}L=await new Promise(F=>{const N=P.subscribe(()=>{const B=P.getSnapshot();B.rerunRequested&&(P.acknowledgeRerun(),N(),F("rerun")),B.retryTaskId&&(D=P.acknowledgeRetry(),N(),F("retry"))});y.renderIsDone.then(()=>{N(),F("quit")}).catch(()=>{N(),F("quit")})})}await y.renderIsDone,await Ce.callHook("run:after",se),await It(se),de>0&&(e.info(""),We?e.info(`${String(de)} service(s) stopped (--stop-services).`):e.info(`${String(de)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const g=new Map,y=typeof t.log=="string"?t.log.toLowerCase():"",k=y==="labeled"||y==="grouped"||y==="interleaved"?y:void 0,P=k?yr(k):void 0,q=new zt([new _n({...Ft,ciGrouping:o?.run?.ciGrouping??"auto",logReporter:P,outputStyle:Lt}),At,Dt]),J=xs({affectedFiles:w,currentOs:x,hooks:Ce,initCwd:d,lifeCycle:q,mutexPool:g,retryBudget:Pt,serviceEnvByTaskId:Te,serviceEventBridge:C??void 0,strictEnv:Rt,taskSlots:ct,workspaceRoot:i}),L=async()=>{const B=Date.now(),Q=await Yt(U,Pe,{lifeCycle:q,projectGraph:$,taskExecutor:J,taskGraph:E,workspaceRoot:i}),ue=Date.now()-B;if(t.summarize){const xe=Jt(Q,E,Tt);await jr(xe,i,{dataDirectory:Ze(i)})}let ie=!1;for(const[,xe]of Q)xe.status==="failure"&&(ie=!0);const ke=Mr(Q,ue),$e=Fr(i),Re=Or(i,ue,$e);return e.info(""),e.info(` ${ke}${Re?` ${Re}`:""}`),{hasFailure:ie,results:Q,runHistory:$e}},D=await L();await Ce.callHook("run:after",D.results),await It(D.results);const{hasFailure:se}=D;if(t.watch){const B=M.map(le=>{const me=l.projects[le]?.root;if(me)return me.startsWith("/")?me:`${i}/${me}`}).filter(le=>le!==void 0),Q=U;let ue;const ie=le=>{const me=Yn(Q,le);return ue=me.filter,U=me.tasks,me.tasks.length};let ke=!1,$e=D.results;const Re=()=>{const le=es($e,i);if(le.directories.length>0&&le.files.size>0){const me=Ei(le.files,i,le.directories);return{handle:ts({filter:me,onChange:Ke,paths:le.directories}),mode:"tracked"}}return{handle:ts({onChange:Ke,paths:B}),mode:"roots"}};let xe;const Ke=async le=>{if(!ke){ke=!0;try{e.info(`Change detected in ${le.length} file(s), rerunning…`),$e=(await L()).results,xe?.close(),xe=Re().handle}finally{ke=!1}}},_t=Re();xe=_t.handle;const tr=_t.mode==="tracked"?`Watching ${String(es($e,i).files.size)} tracked file(s)`:`Watching ${String(B.length)} project root(s)`;e.info(`${tr} — edit a file to rerun, press h for keybinds, q to quit.`);const lt=async()=>{if(!ke){ke=!0;try{if(U.length===0){e.info("No tasks match the active filter — press a to clear it.");return}$e=(await L()).results,xe?.close(),xe=Re().handle}finally{ke=!1}}};await new Promise(le=>{let me=!1,qt;const Wt=()=>{Ut()},Ut=()=>{me||(me=!0,qt?.close(),process.off("SIGINT",Wt),xe?.close(),le())};process.on("SIGINT",Wt),qt=Qn({handlers:{onClearFilter:async()=>{const Ue=ie(void 0);e.info(`Filter cleared — running ${String(Ue)} task(s).`),await lt()},onFilter:async Ue=>{const sr=ue,Vt=ie(Ue);if(Vt===0){e.info(`Filter "${Ue}" matched no projects — keeping previous filter.`),ie(sr);return}e.info(`Filter "${Ue}" matched ${String(Vt)} task(s).`),await lt()},onHelp:()=>{Kn(process.stdout)},onQuit:()=>{Ut()},onRerun:lt}})});return}if(t.flaky!==!1){const B=Rr(i,{minRuns:2},D.runHistory);if(B.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const Q of Er(B))e.info(` ${Q}`);e.info("")}}const F=[];for(const[B,Q]of D.results)Q.retryAttempts&&Q.retryAttempts>0&&F.push(B);const N=t.failOnRetry===!0&&F.length>0;if(N){const B=F.slice(0,5),Q=F.length-B.length,ue=Q>0?`${B.join(", ")}, and ${String(Q)} more`:B.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(F.length)} task(s) succeeded only after retry: ${ue}`)}if(se||N){const B=N&&!se?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",Q=2e3,ue=[];for(const[ie,ke]of D.results){if(ke.status!=="failure")continue;const $e=ke.terminalOutput??"",Re=$e.length>Q?`…${$e.slice(-Q)}`:$e,xe=ke.code??"?";ue.push(` ${ie} (exit ${String(xe)}):
|
|
186
186
|
${Re.split(`
|
|
187
187
|
`).map(Ke=>` ${Ke}`).join(`
|
|
188
188
|
`)}`)}throw new Error(ue.length>0?`${B}
|
|
189
189
|
${ue.join(`
|
|
190
|
-
`)}`:B)}_.length>0&&!t.failFast&&await vs(_,i,w,d,void 0,Te),de>0&&(e.info(""),We?e.info(`${String(de)} service(s) stopped (--stop-services).`):e.info(`${String(de)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Nt(),Gt&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),We&&ye.length>0&&await Promise.all(ye.map(async g=>{try{await ri(i,g)}catch{}}))}};export{qo as createRetryBudget,
|
|
190
|
+
`)}`:B)}_.length>0&&!t.failFast&&await vs(_,i,w,d,void 0,Te),de>0&&(e.info(""),We?e.info(`${String(de)} service(s) stopped (--stop-services).`):e.info(`${String(de)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Nt(),Gt&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),We&&ye.length>0&&await Promise.all(ye.map(async g=>{try{await ri(i,g)}catch{}}))}};export{qo as createRetryBudget,wa as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as t,M as l}from"../packem_shared/pm-runner-CQcraCcu.js";import{r as p,a as m}from"../packem_shared/command-runtime-3FTGuUsK.js";const g=async({logger:n,options:a,visConfig:o,workspaceRoot:c})=>{const s=c??process.cwd(),i=p({logger:n,options:a,visConfig:o},s),r=t(s,{backend:m(i),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),e=l(r,a.check||!1,s,n);e!==0&&(process.exitCode=e)};export{g as default};
|