@visulima/vis 2.0.1 → 2.0.2
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 +28 -0
- package/LICENSE.md +862 -170
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +3 -3
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +68 -68
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +145 -143
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +3 -3
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +3 -3
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +3 -3
- 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/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -2
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.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 +4 -4
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +5 -5
- package/dist/packem_chunks/handler51.js +2 -2
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +4 -4
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler60.js +2 -2
- package/dist/packem_chunks/handler61.js +13 -13
- package/dist/packem_chunks/handler62.js +3 -3
- package/dist/packem_chunks/handler63.js +2 -2
- package/dist/packem_chunks/handler64.js +4 -4
- package/dist/packem_chunks/handler66.js +1 -1
- package/dist/packem_chunks/handler67.js +16 -16
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +15 -15
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +5 -5
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +23 -23
- package/dist/packem_chunks/handler73.js +5 -5
- package/dist/packem_chunks/handler74.js +22 -22
- package/dist/packem_chunks/handler75.js +2 -2
- package/dist/packem_chunks/handler76.js +5 -5
- package/dist/packem_chunks/handler77.js +18 -18
- package/dist/packem_chunks/handler78.js +25 -25
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +4 -4
- package/dist/packem_chunks/help-command.js +46 -46
- package/dist/packem_chunks/index3.js +3 -3
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +2 -2
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/status.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 +1 -1
- package/dist/packem_chunks/ts-loader.js +6 -6
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/{advisories-BGeuHJQg.js → advisories-CCBGdU8U.js} +1 -1
- package/dist/packem_shared/{affected-selection-B85ND6JV.js → affected-selection-Dj-ymxhw.js} +1 -1
- package/dist/packem_shared/{affected-shas-BWRRAB47.js → affected-shas-PwkVbPch.js} +1 -1
- package/dist/packem_shared/ai-analysis-bGCAc1jR.js +68 -0
- package/dist/packem_shared/{ai-fix-BgBU0TOz.js → ai-fix-DV5-dHBY.js} +4 -4
- package/dist/packem_shared/{augment-HVeX6LpU.js → augment-24KX2nkI.js} +1 -1
- package/dist/packem_shared/{bin-DKod8Iqo.js → bin-CtzhnYMp.js} +1 -1
- package/dist/packem_shared/{build-scripts-CM8M1xcG.js → build-scripts-w4SNeR7D.js} +1 -1
- package/dist/packem_shared/{command-runtime-BVi4lL8k.js → command-runtime-BLFPUYAT.js} +1 -1
- package/dist/packem_shared/{cyclonedx-y7VLI-1d.js → cyclonedx-C4KaVTn1.js} +3 -3
- package/dist/packem_shared/{dependency-scan-BAzKpXdW.js → dependency-scan-D_ona0Qm.js} +1 -1
- package/dist/packem_shared/{docker-D1LStSlH.js → docker-DaVs-9wK.js} +27 -27
- package/dist/packem_shared/{en-BxrK-n-J.js → en-D3CfXlO7.js} +13 -13
- package/dist/packem_shared/{failure-log-ChuFC-8f.js → failure-log-CTneNcio.js} +2 -2
- package/dist/packem_shared/glob-BUjyjdE8-C4M8e02u.js +1 -0
- package/dist/packem_shared/index-CTMU29dI.js +1 -0
- package/dist/packem_shared/index-uBVnF4ji.js +35 -0
- package/dist/packem_shared/index.server-CusjRLCh.js +2 -0
- package/dist/packem_shared/{lifecycle-Db0qh6vR.js → lifecycle-B8A2T3gx.js} +1 -1
- package/dist/packem_shared/{lockfile-CDQ0n4P5.js → lockfile-Bccery3L.js} +1 -1
- package/dist/packem_shared/{manifests-Da_no4ZH.js → manifests-BDkwiVbh.js} +1 -1
- package/dist/packem_shared/{min-release-age-V6L6dpiP.js → min-release-age-OaYpLwux.js} +1 -1
- package/dist/packem_shared/missing-package-json-BqS-OnKd.js +1 -0
- package/dist/packem_shared/{native-config-sync-C0pUePad.js → native-config-sync-Ds1FtcrM.js} +3 -3
- package/dist/packem_shared/{osv-bloom-DNFpvSSO.js → osv-bloom-pKp7urSB.js} +2 -2
- package/dist/packem_shared/package-version-C47v64aB.js +4 -0
- package/dist/packem_shared/packument-HBVbyf7x.js +1 -0
- package/dist/packem_shared/pm-runner-C6eTANt1.js +1 -0
- package/dist/packem_shared/{project-name-filter-u2Q7YpQH.js → project-name-filter-CJ3XX2TI.js} +1 -1
- package/dist/packem_shared/{provenance-9OT8sTqn.js → provenance-D4Cza8cp.js} +1 -1
- package/dist/packem_shared/{readJsonSync-BnWiH5-R-BpnwAB0Z.js → readJsonSync-DweZd5ZA-0eZh9sGm.js} +1 -1
- package/dist/packem_shared/{registry-keys-CYHd7qU2.js → registry-keys-C0ez2VND.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-DC3XssJa.js → resolve-explicit-BbT764KS.js} +1 -1
- package/dist/packem_shared/{resolve-runtime-f5l4ODsH.js → resolve-runtime-D_vZovbB.js} +1 -1
- package/dist/packem_shared/{run-file-zB4ACnUy.js → run-file-DyPFFN9U.js} +1 -1
- package/dist/packem_shared/{runtime-check-CWvAfu5u.js → runtime-check-D4um-yQq.js} +1 -1
- package/dist/packem_shared/{s1ngularity-DsmC71xt.js → s1ngularity-St6dhKiq.js} +1 -1
- package/dist/packem_shared/scan-progress-q-N2JtIp.js +2 -0
- package/dist/packem_shared/{selectors-CtxnIT4X.js → selectors-Ce_6UAoY.js} +1 -1
- package/dist/packem_shared/{signatures-Dwx5fD4g.js → signatures-Dyeyg1q9.js} +1 -1
- package/dist/packem_shared/target-merge-Cfy7c__2.js +11 -0
- package/dist/packem_shared/{target-options-BO4Uxt0k.js → target-options-7XcbqGDe.js} +1 -1
- package/dist/packem_shared/{toolchain-BY8lJaSN.js → toolchain-C_pNMBM6.js} +1 -1
- package/dist/packem_shared/{typosquats-BUGgotNu.js → typosquats-xzcAGPiM.js} +1 -1
- package/dist/packem_shared/{use-measured-height-BLZt9dW2.js → use-measured-height-CBjN0fle.js} +1 -1
- package/dist/packem_shared/{verify-B0ztxKMa.js → verify-Dve9PQj3.js} +1 -1
- package/dist/packem_shared/vis-update-app-DMAC2pPf.js +1 -0
- package/dist/packem_shared/vis-user-error-xmha3L4n.js +30 -0
- package/dist/packem_shared/{watch-CGrUW_JD.js → watch-BXOOX7lx.js} +1 -1
- package/dist/packem_shared/{watch-loop-DIwSMjlA.js → watch-loop-Q7UpkVbr.js} +4 -4
- package/dist/runtime/preload.js +1 -1
- package/index.js +52 -52
- package/package.json +16 -16
- package/dist/packem_shared/ai-analysis-oNMAj1wd.js +0 -68
- package/dist/packem_shared/glob-BUjyjdE8-BSrdzgma.js +0 -1
- package/dist/packem_shared/index-BJw7gKD1.js +0 -1
- package/dist/packem_shared/index-DND6ptxQ.js +0 -35
- package/dist/packem_shared/index.server-qvZ-cy29.js +0 -2
- package/dist/packem_shared/missing-package-json-Jw8IEHct.js +0 -1
- package/dist/packem_shared/package-version-DjHDww_5.js +0 -4
- package/dist/packem_shared/packument-N3EWbZpL.js +0 -1
- package/dist/packem_shared/pm-runner-Bssje5qH.js +0 -1
- package/dist/packem_shared/scan-progress-Ch8s3Uwl.js +0 -2
- package/dist/packem_shared/target-merge-b7bE1AEx.js +0 -11
- package/dist/packem_shared/vis-update-app-D1gLJB1O.js +0 -1
- package/dist/packem_shared/vis-user-error-DjFv8uxy.js +0 -28
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as Me}from"node:module";import{
|
|
1
|
+
import{createRequire as Me}from"node:module";import{l as e,m as n,i as o,r as p,X as Re,R as ze}from"./catalog.js";import"../packem_shared/en-D3CfXlO7.js";import{I as Ge}from"../packem_shared/index-BWl4DbMp.js";import{A as _e}from"../packem_shared/pm-runner-C6eTANt1.js";import{o as We,w as ne,l as Xe,z as $e,J as Ve,d as He}from"../packem_shared/index-uBVnF4ji.js";import{J as Je,I as qe,K as $,M as Ye}from"./cli-main.js";import{Dialog as Ke}from"@visulima/tui-kit/dialog";import{Tab as Qe}from"@visulima/tui-kit/tab";import{Tabs as Ze}from"@visulima/tui-kit/tabs";import{TextInput as se}from"@visulima/tui-kit/text-input";import{ScrollBar as ke}from"@visulima/tui-kit/scroll-bar";import{ScrollView as et}from"@visulima/tui-kit/scroll-view";let Le;const Be=s=>(Le??=Me(import.meta.url))(s),X=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ne=s=>{if(typeof X<"u"&&X.versions&&X.versions.node){const[t,i]=X.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return X.getBuiltinModule(s)}return Be(s)},{writeFileSync:Ue}=Ne("node:fs"),tt=(s,{whitespace:t=!0}={})=>s.replace(We,i=>i.startsWith('"')||i[1]==="*"&&!i.endsWith("*/")?i:t?i.replaceAll(/\S/g," "):""),B=[{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=s=>{const t=ne(s,".devcontainer","devcontainer.json");if(!Xe(t))return null;const i=$e(t),l=tt(i),c=l!==i;let r;try{r=JSON.parse(l)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:c}},rt=(s,t,i)=>{const l=i?Ve(i):ne(s,".devcontainer"),c=i??ne(l,"devcontainer.json");He(l),Ue(c,`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,"utf8")},nt={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"}]},it=[{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"}]}],fe=(s,t,i)=>{const l=[],c=new Set(i.map(a=>typeof a=="string"?a:a.target));if(s)for(const a of nt[s])c.has(a.target)||l.push(a);const r=Object.keys(t);for(const{featureMatch:a,mounts:m}of it)if(r.some(g=>g.includes(a)))for(const g of m)c.has(g.target)||l.push(g);return l},F=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],V=s=>structuredClone(s);class st{#r=new Set;#e;constructor(t,i,l=null){const c=t===null,r=t??{name:""},a=V(r);this.#e={config:a,detectedPm:l,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:i,isDirty:!1,mode:c?"create":"edit",originalConfig:c?null:V(r),section:"general",showTemplateSelector:c,suggestedMounts:fe(l,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#r.add(t),()=>{this.#r.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const t=(F.indexOf(this.#e.section)+1)%F.length;this.setSection(F[t])}previousSection(){const t=(F.indexOf(this.#e.section)-1+F.length)%F.length;this.setSection(F[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 i=Math.max(0,Math.min(t,B.length-1));i!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:i})}applyTemplate(t){const i=B.find(l=>l.id===t);i&&this.#t(this.#o({...this.#e,config:V(i.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 i={...this.#e.config.features};i[t]===void 0?i[t]={}:delete i[t],this.#t(this.#o({...this.#e,config:{...this.#e.config,features:i},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const i=this.#e.config.forwardPorts??[];if(i.includes(t))return;const l=[...i,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:l},isDirty:!0})}removePort(t){const i=[...this.#e.config.forwardPorts??[]];i.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:i.length>0?i:void 0},isDirty:!0})}toggleExtension(t){const i={...this.#e.config.customizations},l={...i.vscode},c=[...l.extensions??[]],r=c.indexOf(t);r===-1?c.push(t):c.splice(r,1),l.extensions=c.length>0?c:void 0,i.vscode=l.extensions||l.settings?l:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:i.vscode||i.jetbrains?i:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,i,l){const c=t==="container"?"containerEnv":"remoteEnv",r={...this.#e.config[c],[i]:l};this.#t({...this.#e,config:{...this.#e.config,[c]:r},isDirty:!0})}removeEnvVar(t,i){const l=t==="container"?"containerEnv":"remoteEnv",c={...this.#e.config[l]};delete c[i],this.#t({...this.#e,config:{...this.#e.config,[l]:Object.keys(c).length>0?c:void 0},isDirty:!0})}addMount(t){const i=[...this.#e.config.mounts??[],t];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:i},isDirty:!0}))}removeMount(t){const i=[...this.#e.config.mounts??[]];i.splice(t,1),this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:i.length>0?i:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,i){this.#t({...this.#e,config:{...this.#e.config,[t]:i||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:V(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=V(this.#e.config);for(const[i,l]of Object.entries(t))(l===""||l===void 0)&&delete t[i];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}#o(t){return{...t,suggestedMounts:fe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const i of this.#r)try{i()}catch{}}}const pe=[{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"}],xe=[{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"}],ce=s=>{if(!s)return xe;const t=s.toLowerCase();return xe.filter(i=>i.name.toLowerCase().includes(t)||i.id.toLowerCase().includes(t)||i.description.toLowerCase().includes(t))},le=s=>{if(!s)return pe;const t=s.toLowerCase();return pe.filter(i=>i.name.toLowerCase().includes(t)||i.id.toLowerCase().includes(t)||i.description.toLowerCase().includes(t))},Ce=["dockerComposeFile","service"],ct={dockerComposeFile:"Compose File",service:"Service"},je={dockerComposeFile:"docker-compose.yml",service:"app"},lt={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},at=({config:s,fieldEditing:t,fieldIndex:i,onUpdate:l})=>{const c=!!s.dockerComposeFile,r=!!(s.image||s.build);return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsx(n,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),r&&c&&e.jsx(n,{marginBottom:1,children:e.jsx(o,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ce.map((a,m)=>{const g=m===i,f=s[a]??"",y=Array.isArray(s[a])?s[a].join(", "):f;return e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{children:[e.jsx(n,{width:20,children:e.jsxs(o,{bold:g,color:g?"cyan":"white",children:[g?"❯ ":" ",ct[a],":"]})}),e.jsx(n,{flexGrow:1,children:g&&t?e.jsx(se,{defaultValue:y,onChange:x=>{l({[a]:x||void 0})},placeholder:je[a]}):e.jsx(o,{color:y?"white":"gray",children:y||je[a]})})]}),e.jsx(n,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:lt[a]})})]},a)}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},dt=Ce.length,ut=({config:s,fieldIndex:t})=>{const i=s.containerEnv??{},l=s.remoteEnv??{},c=Object.keys(i),r=Object.keys(l),a=c.length,m=c.length+1,g=m+r.length,f=t<=a,y=t>a;return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsxs(n,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(n,{flexShrink:0,marginBottom:c.length>0?1:0,children:[e.jsx(o,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),e.jsx(o,{dimColor:!0,children:" — baked into the container image"})]}),c.map((x,v)=>{const b=v===t;return e.jsx(n,{flexShrink:0,children:e.jsxs(o,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:i[x]})]})},x)}),e.jsx(n,{flexShrink:0,marginTop:c.length>0?1:0,children:e.jsxs(o,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(n,{borderColor:y?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(n,{flexShrink:0,marginBottom:r.length>0?1:0,children:[e.jsx(o,{bold:!0,color:y?"cyan":"white",children:"remoteEnv"}),e.jsx(o,{dimColor:!0,children:" — set at runtime by the IDE"})]}),r.map((x,v)=>{const b=m+v===t;return e.jsx(n,{flexShrink:0,children:e.jsxs(o,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:l[x]})]})},x)}),e.jsx(n,{flexShrink:0,marginTop:r.length>0?1:0,children:e.jsxs(o,{color:t===g?"cyan":"gray",inverse:t===g,children:[" ","+ Add variable..."]})})]}),e.jsx(n,{flexShrink:0,marginTop:1,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[e.jsx(o,{bold:!0,color:"white",children:"a"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},ht=s=>{const t=Object.keys(s.containerEnv??{}).length,i=Object.keys(s.remoteEnv??{}).length;return t+1+i+1},mt=({config:s,fieldIndex:t,scrollOffset:i,searchText:l,viewportHeight:c})=>{const r=p.useMemo(()=>new Set(s.customizations?.vscode?.extensions),[s.customizations?.vscode?.extensions]),a=p.useMemo(()=>le(l),[l]),m=a.length,g=m>c&&c>0;return e.jsxs(n,{flexDirection:"column",flexGrow:1,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),l&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:l})," ","(",a.length," ","results)"]})]}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(n,{flexDirection:"column",marginTop:-i,children:a.map((f,y)=>{const x=y===t,v=r.has(f.id);return e.jsxs(n,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(o,{dimColor:!0,children:[" ","-",f.id]})]})})]},f.id)})})}),g&&e.jsx(n,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(ke,{contentHeight:m,placement:"inset",scrollOffset:i,style:"block",viewportHeight:c})})]}),a.length===0&&e.jsx(n,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No extensions match the search."})})]})},gt=({config:s,fieldIndex:t,scrollOffset:i,searchText:l,viewportHeight:c})=>{const r=p.useMemo(()=>new Set(Object.keys(s.features??{})),[s.features]),a=p.useMemo(()=>ce(l),[l]),m=a.length,g=m>c&&c>0;return e.jsxs(n,{flexDirection:"column",flexGrow:1,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),l&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:l})," ","(",a.length," ","results)"]})]}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(n,{flexDirection:"column",marginTop:-i,children:a.map((f,y)=>{const x=y===t,v=r.has(f.id);return e.jsxs(n,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(o,{dimColor:!0,children:[" ","-",f.description]})]})})]},f.id)})})}),g&&e.jsx(n,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(ke,{contentHeight:m,placement:"inset",scrollOffset:i,style:"block",viewportHeight:c})})]}),a.length===0&&e.jsx(n,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No features match the search."})})]})},ie=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],ft={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},ve={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"},Y=["privileged","overrideCommand"],pt={overrideCommand:"Override Command",privileged:"Privileged"},xt=ie.length+Y.length,jt=({config:s,fieldEditing:t,fieldIndex:i,onUpdate:l})=>e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsx(n,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"General Configuration"})}),ie.map((c,r)=>{const a=r===i,m=s[c]??"";return e.jsxs(n,{marginBottom:1,children:[e.jsx(n,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",ft[c],":"]})}),e.jsx(n,{flexGrow:1,children:a&&t?e.jsx(se,{defaultValue:m,onChange:g=>{l({[c]:g})},placeholder:ve[c]}):e.jsx(o,{color:m?"white":"gray",children:m||ve[c]})})]},c)}),Y.map((c,r)=>{const a=ie.length+r===i,m=s[c]??!1;return e.jsxs(n,{marginBottom:r<Y.length-1?1:0,children:[e.jsx(n,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",pt[c],":"]})}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{color:m?"green":"gray",children:[m?"yes":"no",a&&e.jsx(o,{dimColor:!0,children:" (Space to toggle)"})]})})]},c)}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Se=xt,re=Y,Ee=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],vt={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},yt={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"},bt=({config:s,fieldEditing:t,fieldIndex:i,onSetCommand:l})=>e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsx(n,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Ee.map((c,r)=>{const a=r===i,m=s[c],g=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsx(n,{children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",vt[c]]})}),e.jsx(n,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:yt[c]})}),e.jsx(n,{paddingLeft:4,children:a&&t?e.jsx(se,{defaultValue:g,onChange:f=>{l(c,f)},placeholder:"e.g. npm install"}):e.jsx(o,{color:g?"green":"gray",children:g||"(not set)"})})]},c)}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),wt=Ee.length,ye=s=>typeof s=="string"?s:`[${s.type}] ${s.source} → ${s.target}`,kt=({addingMount:s,config:t,detectedPm:i,fieldIndex:l,mountPhase:c,mountSource:r,mountTarget:a,mountType:m,suggestedMounts:g})=>{const f=t.mounts??[];return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[f.length," ","mounts"]}),i&&e.jsxs(o,{dimColor:!0,children:["— detected:"," ",e.jsx(o,{color:"white",children:i})]})]}),g.length>0&&!s&&e.jsxs(n,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(n,{flexShrink:0,children:[e.jsx(o,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(o,{dimColor:!0,children:[" ","— press"," ",e.jsx(o,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),g.map((y,x)=>e.jsx(n,{flexShrink:0,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[" + ",ye(y)]})},`suggestion-${String(x)}`))]}),f.length>0&&e.jsx(n,{flexDirection:"column",marginBottom:1,children:f.map((y,x)=>{const v=x===l;return e.jsxs(n,{flexShrink:0,height:1,children:[e.jsx(o,{children:v?">":" "}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{bold:v,inverse:v,wrap:"truncate",children:[" ",ye(y)]})})]},`mount-${String(x)}`)})}),!s&&e.jsx(n,{flexShrink:0,children:e.jsxs(o,{color:l===f.length?"cyan":"gray",inverse:l===f.length,children:[" ","+ Add mount..."]})}),s&&e.jsxs(n,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(n,{flexShrink:0,marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(n,{flexShrink:0,children:[e.jsx(n,{width:12,children:e.jsxs(o,{bold:c==="source",color:c==="source"?"cyan":"white",children:[c==="source"?"❯ ":" ","Source:"]})}),e.jsx(o,{color:r?"yellow":"gray",children:r||(c==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(n,{flexShrink:0,children:[e.jsx(n,{width:12,children:e.jsxs(o,{bold:c==="target",color:c==="target"?"cyan":"white",children:[c==="target"?"❯ ":" ","Target:"]})}),e.jsx(o,{color:a?"yellow":"gray",children:a||(c==="target"?"_":"/container/path")})]}),e.jsxs(n,{flexShrink:0,children:[e.jsx(n,{width:12,children:e.jsxs(o,{bold:c==="type",color:c==="type"?"cyan":"white",children:[c==="type"?"❯ ":" ","Type:"]})}),c==="type"?e.jsxs(o,{children:[e.jsx(o,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(o,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(o,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(o,{color:"gray",children:m})]}),e.jsx(n,{flexShrink:0,marginTop:1,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:c==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!s&&g.length===0&&e.jsx(n,{marginTop:1,children:e.jsx(o,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ct=({addingPort:s,addPortValue:t,config:i,fieldIndex:l})=>{const c=i.forwardPorts??[],r=l===c.length;return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(o,{dimColor:!0,children:[" ","(",c.length," ","ports)"]})]}),c.map((a,m)=>{const g=m===l;return e.jsx(n,{children:e.jsxs(o,{color:g?"cyan":void 0,inverse:g,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(n,{marginTop:c.length>0?1:0,children:e.jsxs(o,{color:r?"cyan":"gray",inverse:r,children:[" ",r&&s?e.jsxs(o,{children:["Enter port:"," ",e.jsx(o,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ",r?"type port number, Enter to confirm":"select"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},St=({focused:s,hadComments:t,jsonPreview:i,mode:l,scrollRef:c})=>e.jsxs(n,{borderColor:s?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(n,{flexShrink:0,paddingX:1,children:[e.jsx(o,{bold:!0,color:s?"cyan":"white",children:"Preview"}),e.jsxs(o,{dimColor:!0,children:[" ","(",l==="create"?"new":"edit",")"]})]}),t&&l==="edit"&&e.jsx(n,{flexShrink:0,paddingX:1,children:e.jsx(o,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(et,{flexGrow:1,ref:c,scrollbar:!0,scrollbarColor:"gray",children:i.split(`
|
|
3
|
-
`).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Et=s=>{const t=[],i=[],l=[];if(!s.image&&!s.build&&!s.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),s.build&&(s.image&&i.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),s.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),s.dockerComposeFile&&!s.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),s.features!==void 0&&(typeof s.features!="object"||Array.isArray(s.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),s.forwardPorts)if(Array.isArray(s.forwardPorts))for(const[c,r]of s.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(c)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return s.customizations?.vscode?.extensions&&!Array.isArray(s.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),s.customizations?.vscode?.settings&&typeof s.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),s.name||l.push({field:"name",message:"Consider adding a name for better identification"}),(!s.features||Object.keys(s.features).length===0)&&l.push({field:"features",message:"Consider adding features for common tools"}),(!s.customizations?.vscode?.extensions||s.customizations.vscode.extensions.length===0)&&l.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),s.privileged&&i.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:l,valid:t.length===0,warnings:i}},be=80,we=15,It=120,Ie=[{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"}],Tt=new Map(Ie.map(s=>[s.id,s.description])),Dt=(s,t,i,l)=>{switch(s){case"compose":return dt;case"environment":return ht(t);case"extensions":return le(l).length;case"features":return ce(i).length;case"general":return Se;case"lifecycle":return wt;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Pt=({onSave:s,store:t})=>{const{exit:i}=Je(),{columns:l,rows:c}=qe(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[g,f]=p.useState(!1),[y,x]=p.useState(!1),[v,b]=p.useState(null),[w,I]=p.useState("editor"),[H,ae]=p.useState(0),[K,Q]=p.useState(!1),[de,N]=p.useState(""),[R,z]=p.useState(null),[G,T]=p.useState(""),[ue,D]=p.useState(""),[_,A]=p.useState("key"),[Z,J]=p.useState(!1),[ee,O]=p.useState(""),[te,M]=p.useState(""),[he,U]=p.useState("volume"),[C,L]=p.useState("source"),oe=p.useRef(null),P=p.useRef(null),E=p.useRef(null),q=p.useRef(!0);p.useEffect(()=>(q.current=!0,()=>{q.current=!1,E.current&&clearTimeout(E.current)}),[]);const me=Dt(r.section,r.config,r.featureSearch,r.extensionSearch),W=Math.max(1,c-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||ae(u=>r.fieldIndex>=u+W?r.fieldIndex-W+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,W]),p.useEffect(()=>{ae(0)},[r.section,r.featureSearch,r.extensionSearch]);const Te=p.useCallback(()=>{const u=t.cleanConfig(),h=Et(u);if(!h.valid){const j=h.errors[0];b(j?`Error: ${j.message}`:"Validation failed"),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{q.current&&b(null)},3e3);return}s(u),t.markClean();const d=h.warnings.length;b(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{q.current&&b(null)},2e3)},[s,t]);X((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=B[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),X((u,h)=>{if(h.escape){Q(!1),N("");return}if(h.return){const d=Number.parseInt(de,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),Q(!1),N("");return}if(h.backspace){N(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&N(d=>d+u)},{isActive:K}),X((u,h)=>{if(h.escape){z(null),T(""),D(""),A("key");return}if(h.return){if(_==="key"&&G){A("value");return}if(_==="value"&&G){t.addEnvVar(R,G,ue),z(null),T(""),D(""),A("key");return}}if(h.backspace){_==="key"?T(d=>d.slice(0,-1)):D(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(_==="key"?T(d=>d+u):D(d=>d+u))},{isActive:R!==null}),X((u,h)=>{if(h.escape){J(!1),O(""),M(""),L("source");return}if(h.return){if(C==="source"&&ee){L("target");return}if(C==="target"&&te){L("type");return}if(C==="type"){t.addMount({source:ee,target:te,type:he}),J(!1),O(""),M(""),L("source");return}}if(C==="type"){switch(u){case"1":{U("volume");break}case"2":{U("bind");break}case"3":{U("tmpfs");break}}return}if(h.backspace){C==="source"?O(d=>d.slice(0,-1)):C==="target"&&M(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="source"?O(d=>d+u):C==="target"&&M(d=>d+u))},{isActive:Z}),X((u,h)=>{if(u==="c"&&h.ctrl){i();return}if(!g){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?oe.current?.scrollBy(1):h.upArrow||u==="k"?oe.current?.scrollBy(-1):u==="q"&&(m(!1),f(!0));return}if(y){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?f(!0):i();return}if(u==="s"){Te();return}if(h.tab){I(d=>d==="editor"?"preview":"editor");return}if(w==="preview"){if(h.downArrow||u==="j"){P.current?.scrollBy(1);return}if(h.upArrow||u==="k"){P.current?.scrollBy(-1);return}if(h.pageDown){P.current?.scrollBy(10);return}if(h.pageUp){P.current?.scrollBy(-10);return}if(h.home){P.current?.scrollToTop();return}if(h.end){P.current?.scrollToBottom();return}h.escape&&I("editor");return}if(h.downArrow||u==="j"){me>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,me-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,S=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(z("container"),T(""),D(""),A("key")):r.fieldIndex===S&&(z("remote"),T(""),D(""),A("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(J(!0),O(""),M(""),U("volume"),L("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(Q(!0),N(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const d=le(r.extensionSearch)[r.fieldIndex];d&&t.toggleExtension(d.id);break}case"features":{const d=ce(r.featureSearch)[r.fieldIndex];d&&t.toggleFeature(d.id);break}case"general":{const d=Se-re.length,j=r.fieldIndex-d;if(j>=0&&j<re.length){const S=re[j];t.updateConfig({[S]:!r.config[S]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";z(j),T(""),D(""),A("key")}else r.section==="mounts"&&(J(!0),O(""),M(""),U("volume"),L("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const S=r.fieldIndex-d.length-1;S>=0&&S<j.length&&(t.removeEnvVar("remote",j[S]),j.length===1||S>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!K&&R===null&&!Z});const De=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(l<be||c<we)return e.jsx(n,{alignItems:"center",height:c,justifyContent:"center",width:l,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",l,"x",c,"), need"," ",be,"x",we]})});if(r.showTemplateSelector)return e.jsx(n,{alignItems:"center",flexDirection:"column",height:c,justifyContent:"center",width:l,children:e.jsxs(n,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(n,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),B.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(n,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(n,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let k;switch(r.section){case"compose":{k=e.jsx(at,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{k=e.jsxs(n,{flexDirection:"column",children:[e.jsx(ut,{config:r.config,fieldIndex:r.fieldIndex}),R!==null&&e.jsx(n,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",R," ","env:"," ",_==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:G||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[G,"=",e.jsx(o,{color:"yellow",children:ue||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{k=e.jsx(mt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:H,searchText:r.extensionSearch,viewportHeight:W});break}case"features":{k=e.jsx(gt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:H,searchText:r.featureSearch,viewportHeight:W});break}case"general":{k=e.jsx(jt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{k=e.jsx(bt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{k=e.jsx(kt,{addingMount:Z,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:C,mountSource:ee,mountTarget:te,mountType:he,suggestedMounts:r.suggestedMounts});break}case"ports":{k=e.jsx(Ct,{addingPort:K,addPortValue:de,config:r.config,fieldIndex:r.fieldIndex});break}default:k=e.jsx(o,{children:"Unknown section"})}const Pe=e.jsxs(n,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(n,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(n,{paddingX:1,children:[v&&e.jsxs(o,{color:v.startsWith("Error")?"red":"green",children:[v," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!v&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Fe=e.jsxs(Ke,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:oe,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(n,{flexDirection:"column",children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Ae=e.jsx(St,{focused:w==="preview",hadComments:r.hadComments,jsonPreview:De,mode:r.mode,scrollRef:P}),ge=l>=It,Oe=ge?Math.floor(l*.38):0;return e.jsxs(n,{flexDirection:"column",height:c,width:l,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(n,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(Ze,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),I("editor")},showIndex:!1,children:Ie.map(({id:u,label:h})=>e.jsx(Qe,{name:u,children:h},u))})}),e.jsx(n,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Tt.get(r.section)??""})}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{borderColor:w==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:k}),ge&&e.jsx(n,{flexShrink:0,width:Oe,children:Ae})]}),Pe,e.jsx(Ye,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Fe]})},$t=async({logger:s,options:t,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const l=i,c=t.template,r=t.output,a=!!process.stdout.isTTY&&!Ge;let m=null;try{m=_e(l).name}catch{}const g=ot(l);let f=g?.config??null;const y=g?.hadComments??!1;if(c&&!g){const w=B.find(I=>I.id===c);if(!w){const I=B.map(H=>H.id).join(", ");throw new Error(`Unknown template "${c}". Valid templates: ${I}`)}f=w.config}if(!a){f?s.info(JSON.stringify(f,null,2)):(s.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 st(f,y,m);c&&!g&&v.dismissTemplateSelector();let b=null;if(await Re(ze.createElement(Pt,{onSave:w=>{rt(l,w,r),b=w},store:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),b){const w=r??".devcontainer/devcontainer.json";s.info(`DevContainer config saved to ${w}`)}};export{$t as default};
|
|
3
|
+
`).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Et=s=>{const t=[],i=[],l=[];if(!s.image&&!s.build&&!s.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),s.build&&(s.image&&i.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),s.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),s.dockerComposeFile&&!s.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),s.features!==void 0&&(typeof s.features!="object"||Array.isArray(s.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),s.forwardPorts)if(Array.isArray(s.forwardPorts))for(const[c,r]of s.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(c)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return s.customizations?.vscode?.extensions&&!Array.isArray(s.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),s.customizations?.vscode?.settings&&typeof s.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),s.name||l.push({field:"name",message:"Consider adding a name for better identification"}),(!s.features||Object.keys(s.features).length===0)&&l.push({field:"features",message:"Consider adding features for common tools"}),(!s.customizations?.vscode?.extensions||s.customizations.vscode.extensions.length===0)&&l.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),s.privileged&&i.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:l,valid:t.length===0,warnings:i}},be=80,we=15,It=120,Ie=[{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"}],Tt=new Map(Ie.map(s=>[s.id,s.description])),Dt=(s,t,i,l)=>{switch(s){case"compose":return dt;case"environment":return ht(t);case"extensions":return le(l).length;case"features":return ce(i).length;case"general":return Se;case"lifecycle":return wt;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Pt=({onSave:s,store:t})=>{const{exit:i}=Je(),{columns:l,rows:c}=qe(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[g,f]=p.useState(!1),[y,x]=p.useState(!1),[v,b]=p.useState(null),[w,I]=p.useState("editor"),[H,ae]=p.useState(0),[K,Q]=p.useState(!1),[de,N]=p.useState(""),[R,z]=p.useState(null),[G,T]=p.useState(""),[ue,D]=p.useState(""),[_,A]=p.useState("key"),[Z,J]=p.useState(!1),[ee,O]=p.useState(""),[te,M]=p.useState(""),[he,U]=p.useState("volume"),[C,L]=p.useState("source"),oe=p.useRef(null),P=p.useRef(null),E=p.useRef(null),q=p.useRef(!0);p.useEffect(()=>(q.current=!0,()=>{q.current=!1,E.current&&clearTimeout(E.current)}),[]);const me=Dt(r.section,r.config,r.featureSearch,r.extensionSearch),W=Math.max(1,c-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||ae(u=>r.fieldIndex>=u+W?r.fieldIndex-W+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,W]),p.useEffect(()=>{ae(0)},[r.section,r.featureSearch,r.extensionSearch]);const Te=p.useCallback(()=>{const u=t.cleanConfig(),h=Et(u);if(!h.valid){const j=h.errors[0];b(j?`Error: ${j.message}`:"Validation failed"),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{q.current&&b(null)},3e3);return}s(u),t.markClean();const d=h.warnings.length;b(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{q.current&&b(null)},2e3)},[s,t]);$((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=B[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),$((u,h)=>{if(h.escape){Q(!1),N("");return}if(h.return){const d=Number.parseInt(de,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),Q(!1),N("");return}if(h.backspace){N(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&N(d=>d+u)},{isActive:K}),$((u,h)=>{if(h.escape){z(null),T(""),D(""),A("key");return}if(h.return){if(_==="key"&&G){A("value");return}if(_==="value"&&G){t.addEnvVar(R,G,ue),z(null),T(""),D(""),A("key");return}}if(h.backspace){_==="key"?T(d=>d.slice(0,-1)):D(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(_==="key"?T(d=>d+u):D(d=>d+u))},{isActive:R!==null}),$((u,h)=>{if(h.escape){J(!1),O(""),M(""),L("source");return}if(h.return){if(C==="source"&&ee){L("target");return}if(C==="target"&&te){L("type");return}if(C==="type"){t.addMount({source:ee,target:te,type:he}),J(!1),O(""),M(""),L("source");return}}if(C==="type"){switch(u){case"1":{U("volume");break}case"2":{U("bind");break}case"3":{U("tmpfs");break}}return}if(h.backspace){C==="source"?O(d=>d.slice(0,-1)):C==="target"&&M(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="source"?O(d=>d+u):C==="target"&&M(d=>d+u))},{isActive:Z}),$((u,h)=>{if(u==="c"&&h.ctrl){i();return}if(!g){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?oe.current?.scrollBy(1):h.upArrow||u==="k"?oe.current?.scrollBy(-1):u==="q"&&(m(!1),f(!0));return}if(y){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?f(!0):i();return}if(u==="s"){Te();return}if(h.tab){I(d=>d==="editor"?"preview":"editor");return}if(w==="preview"){if(h.downArrow||u==="j"){P.current?.scrollBy(1);return}if(h.upArrow||u==="k"){P.current?.scrollBy(-1);return}if(h.pageDown){P.current?.scrollBy(10);return}if(h.pageUp){P.current?.scrollBy(-10);return}if(h.home){P.current?.scrollToTop();return}if(h.end){P.current?.scrollToBottom();return}h.escape&&I("editor");return}if(h.downArrow||u==="j"){me>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,me-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,S=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(z("container"),T(""),D(""),A("key")):r.fieldIndex===S&&(z("remote"),T(""),D(""),A("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(J(!0),O(""),M(""),U("volume"),L("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(Q(!0),N(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const d=le(r.extensionSearch)[r.fieldIndex];d&&t.toggleExtension(d.id);break}case"features":{const d=ce(r.featureSearch)[r.fieldIndex];d&&t.toggleFeature(d.id);break}case"general":{const d=Se-re.length,j=r.fieldIndex-d;if(j>=0&&j<re.length){const S=re[j];t.updateConfig({[S]:!r.config[S]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";z(j),T(""),D(""),A("key")}else r.section==="mounts"&&(J(!0),O(""),M(""),U("volume"),L("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const S=r.fieldIndex-d.length-1;S>=0&&S<j.length&&(t.removeEnvVar("remote",j[S]),j.length===1||S>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!K&&R===null&&!Z});const De=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(l<be||c<we)return e.jsx(n,{alignItems:"center",height:c,justifyContent:"center",width:l,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",l,"x",c,"), need"," ",be,"x",we]})});if(r.showTemplateSelector)return e.jsx(n,{alignItems:"center",flexDirection:"column",height:c,justifyContent:"center",width:l,children:e.jsxs(n,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(n,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),B.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(n,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(n,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let k;switch(r.section){case"compose":{k=e.jsx(at,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{k=e.jsxs(n,{flexDirection:"column",children:[e.jsx(ut,{config:r.config,fieldIndex:r.fieldIndex}),R!==null&&e.jsx(n,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",R," ","env:"," ",_==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:G||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[G,"=",e.jsx(o,{color:"yellow",children:ue||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{k=e.jsx(mt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:H,searchText:r.extensionSearch,viewportHeight:W});break}case"features":{k=e.jsx(gt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:H,searchText:r.featureSearch,viewportHeight:W});break}case"general":{k=e.jsx(jt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{k=e.jsx(bt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{k=e.jsx(kt,{addingMount:Z,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:C,mountSource:ee,mountTarget:te,mountType:he,suggestedMounts:r.suggestedMounts});break}case"ports":{k=e.jsx(Ct,{addingPort:K,addPortValue:de,config:r.config,fieldIndex:r.fieldIndex});break}default:k=e.jsx(o,{children:"Unknown section"})}const Pe=e.jsxs(n,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(n,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(n,{paddingX:1,children:[v&&e.jsxs(o,{color:v.startsWith("Error")?"red":"green",children:[v," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!v&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Fe=e.jsxs(Ke,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:oe,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(n,{flexDirection:"column",children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Ae=e.jsx(St,{focused:w==="preview",hadComments:r.hadComments,jsonPreview:De,mode:r.mode,scrollRef:P}),ge=l>=It,Oe=ge?Math.floor(l*.38):0;return e.jsxs(n,{flexDirection:"column",height:c,width:l,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(n,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(Ze,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),I("editor")},showIndex:!1,children:Ie.map(({id:u,label:h})=>e.jsx(Qe,{name:u,children:h},u))})}),e.jsx(n,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Tt.get(r.section)??""})}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{borderColor:w==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:k}),ge&&e.jsx(n,{flexShrink:0,width:Oe,children:Ae})]}),Pe,e.jsx(Ye,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Fe]})},Xt=async({logger:s,options:t,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const l=i,c=t.template,r=t.output,a=!!process.stdout.isTTY&&!Ge;let m=null;try{m=_e(l).name}catch{}const g=ot(l);let f=g?.config??null;const y=g?.hadComments??!1;if(c&&!g){const w=B.find(I=>I.id===c);if(!w){const I=B.map(H=>H.id).join(", ");throw new Error(`Unknown template "${c}". Valid templates: ${I}`)}f=w.config}if(!a){f?s.info(JSON.stringify(f,null,2)):(s.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 st(f,y,m);c&&!g&&v.dismissTemplateSelector();let b=null;if(await Re(ze.createElement(Pt,{onSave:w=>{rt(l,w,r),b=w},store:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),b){const w=r??".devcontainer/devcontainer.json";s.info(`DevContainer config saved to ${w}`)}};export{Xt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as mt}from"node:module";import{
|
|
1
|
+
import{createRequire as mt}from"node:module";import{b as x,K as it,P as kt,v as at,w as O,l as B,n as vt}from"../packem_shared/index-uBVnF4ji.js";import{X as Tt,l as w,m as C,i as b,P as St,e as bt}from"./catalog.js";import ot from"./index.js";import{k as ct}from"../packem_shared/main-D_cam4hv.js";import"../packem_shared/en-D3CfXlO7.js";import{Spinner as Et}from"@visulima/tui-kit/spinner";import{C as dt,D as _,T as lt}from"../packem_shared/symbols-DPTlrJ3B.js";import{s as V,E as $,q as F,V as G,I as Mt}from"../packem_shared/index.server-CusjRLCh.js";import{withEnhancedPath as At}from"@visulima/task-runner";let wt;const yt=t=>(wt??=mt(import.meta.url))(t),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=t=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[e,s]=A.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return A.getBuiltinModule(t)}return yt(t)},{readFileSync:xt,writeFileSync:$t,unlinkSync:Ct}=q("node:fs"),{randomBytes:It}=q("node:crypto"),{availableParallelism:z}=q("node:os");class E extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class jt extends E{}class v extends E{}class W extends E{}class R extends E{stderr;constructor(e,s,r){super(e,r),this.stderr=s}}class K extends E{}class I extends E{commandTitle;constructor(e,s,r){super(s,r),this.commandTitle=e}}const ut=t=>t.includes("/"),P=(t,e)=>e?t.toLowerCase():t,Rt=(t,e,s,r={})=>{const n=ut(t),a=r.caseInsensitive===!0,c=P(t,a),i=[];for(const o of e){const l=n?x(s,o):it(o);ot(c,P(l,a))&&i.push(o)}return i},Nt=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(a=>{for(const c of e){const i=ut(c)?x(s,a):it(a),o=P(c,n);if(ot(o,P(i,n)))return!1}return!0})},L=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",N=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Ot=(t,e)=>{const s=x(t,e);return s===""||!s.startsWith("..")&&!at(s)},_t=(t,e)=>{let s;for(const r of e)Ot(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},Pt=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),a=(o,l,h,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],p=new Map;for(const f of h){const g=_t(f,u)??t.cwd,y=p.get(g)??[];y.push(x(g,f)),p.set(g,y)}for(const f of[...p.keys()].sort()){const g=x(t.cwd,f)||".";d.push({command:o.command,cwd:f,files:p.get(f)??[],id:n(),source:"string",title:`${o.command} — ${g}`})}return}if(o.cwd!==void 0){const u=kt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:h,id:n(),source:"string",title:`${o.command} — ${x(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:n(),source:"string",title:o.command})},c=async(o,l,h,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:n(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,h,d);return}if(N(o)){a(o,l,h,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const p of u)if(typeof p=="string")d.push({command:p,files:l,id:n(),source:"function",title:p});else if(N(p))a(p,l,h,d);else if(L(p))d.push({files:l,id:n(),run:p.task,source:"custom",title:p.title});else throw new v("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(N(u)){a(u,l,h,d);return}if(L(u)){d.push({files:l,id:n(),run:u.task,source:"custom",title:u.title});return}throw new v("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(L(o)){d.push({files:l,id:n(),run:o.task,source:"custom",title:o.title});return}throw new v("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},i=[];for(const[o,l]of Object.entries(t.config)){const h=Rt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(h.length===0)continue;const d=t.relative?h.map(p=>x(t.cwd,p)):h,u=[];await c(l,d,h,u),u.length!==0&&i.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${h.length} file${h.length===1?"":"s"}`})}return i},Dt=async t=>{if(t.config!==void 0)return t.config;throw new v(`No staged config provided. Add \`staged\` to your vis.config.ts:
|
|
2
2
|
|
|
3
3
|
import { defineConfig } from "@visulima/vis/config";
|
|
4
4
|
|
|
@@ -6,16 +6,16 @@ import{createRequire as mt}from"node:module";import{y as b,J as it,B as kt,A as
|
|
|
6
6
|
staged: { "*.ts": "eslint --fix" },
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},
|
|
9
|
+
Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},X=t=>{if(typeof t!="object"||t===null)throw new v("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new v("Staged config is empty — at least one glob pattern is required.");for(const[s,r]of e){if(!s||s.trim()==="")throw new v("Staged config keys must be non-empty glob patterns.");ht(s,r)}return t},ht=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new v(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new v(`Task array for "${t}" is empty.`);for(const s of e)ht(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new v(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(N(e)){if(e.command.trim()==="")throw new v(`Command task for "${t}" has an empty \`command\`.`);return}if(!Ft(e))throw new v(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Ft=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",Y=2048,m=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ct("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const{stderr:a}=r,c=a.length>Y?`${a.slice(0,Y)}…`:a;throw new R(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,a)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},M=async(t,e)=>{const{stdout:s}=await m(t,e);return s.trim()},Gt=async t=>{const e=await m(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Lt=async t=>M(["rev-parse","--absolute-git-dir"],{cwd:t}),ft=async t=>M(["rev-parse","--show-toplevel"],{cwd:t}),J=async t=>M(["write-tree"],{cwd:t}),qt=async t=>{const e=await m(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},j={major:2,minor:32},Ht=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),r=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(r)?null:{major:s,minor:r}},Ut=async t=>{const e=Ht(await M(["--version"],{cwd:t}));if(e!==null&&(e.major<j.major||e.major===j.major&&e.minor<j.minor))throw new R(`Git ${j.major}.${j.minor} or newer is required; found ${e.major}.${e.minor}.`)},Bt="ACMR",Q=500,Vt=async t=>{const{stdout:e}=await m(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(n=>n.length>0),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(!a?.startsWith(":"))continue;const c=a.slice(1).split(" "),i=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&i!==void 0&&/^0+$/.test(i)&&l!==void 0&&r.push(l)}return r},Z=async t=>{const{stdout:e}=await m(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},zt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Wt=async t=>{const e=t.diffFilter??Bt,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:r}=await m(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const a=t.workTree??await ft(t.cwd);return n.map(c=>at(c)?c:O(a,c))},Kt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let a=0;a<t.length;a+=Q){const c=t.slice(a,a+Q),{stdout:i}=await m(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});i.length>0&&s.push(i)}if(s.length===0)return null;const r=s.join(""),n=r.endsWith(`
|
|
10
10
|
`)?r:`${r}
|
|
11
|
-
`;return Buffer.from(n,"utf8")},
|
|
11
|
+
`;return Buffer.from(n,"utf8")},Xt=async t=>{const{stdout:e}=await m(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(a===void 0||a.length<4)continue;const c=a.charAt(0),i=a.charAt(1),o=a.slice(3),l=c==="R"||c==="C"||i==="R"||i==="C";c!==" "&&c!=="?"&&i!==" "&&i!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await m(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await m(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Qt="vis_staged_automatic_backup",pt=()=>`${Qt}-${process.pid}-${Date.now()}-${It(3).toString("hex")}`,Zt=async t=>{const e=await M(["stash","create"],{cwd:t});return e.length===0?null:(await m(["stash","store","-m",pt(),e],{cwd:t}),e)},te=async t=>{const e=pt(),{exitCode:s,stdout:r}=await m(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const n=r.trim();return n.length>0&&/no local changes/i.test(n)?null:M(["rev-parse","stash@{0}"],{cwd:t})},H=async(t,e)=>{const{exitCode:s,stdout:r}=await m(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[a,c]=n.split(/\s+/,2);if(a===e&&c!==void 0)return c}return null},tt=async(t,e)=>{if(e===null)return;const s=await H(t,e);s!==null&&await m(["stash","drop","--quiet",s],{cwd:t})},ee=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");const s=await H(t,e);if(s===null)throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await m(["reset","--hard","HEAD"],{cwd:t}),await m(["stash","apply","--index","--quiet",s],{cwd:t})},se=async(t,e)=>{if(e===null)return;const s=await H(t,e);s!==null&&await m(["stash","pop","--quiet",s],{cwd:t})};class re{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Gt(this.cwd))throw new R(`Not a git repository: ${this.cwd}`);await Ut(this.cwd),this.workTree=await ft(this.cwd),this.gitDir=await Lt(this.cwd),this.stagedFiles=await Wt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Xt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await Vt(this.workTree),this.intentToAddPaths.length>0&&await zt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Zt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await te(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await J(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await qt(this.workTree),this.preTaskUntracked=new Set(await Z(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(r=>x(this.workTree,r));if(await Jt(s,{cwd:this.workTree}),e){const r=(await Z(this.workTree)).filter(n=>!this.preTaskUntracked.has(n));if(r.length>0){const n=`${r.join("\0")}\0`;await m(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:n})}}if(this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await J(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let s;try{await m(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof R?r.stderr:String(r)}try{await m([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof R&&r.stderr?r.stderr:String(r);throw new K(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
|
|
12
12
|
First attempt: ${s??"(no stderr)"}
|
|
13
|
-
Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await ee(this.workTree,this.backupStashSha)}catch(e){throw new K("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await se(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(r=>
|
|
13
|
+
Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await ee(this.workTree,this.backupStashSha)}catch(e){throw new K("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await se(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(r=>x(this.workTree,r))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(r=>e.has(r)):[];s.length!==0&&(this.patch=await Kt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=O(this.gitDir,e);return B(s)?{body:xt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=O(this.gitDir,e.name);try{e.existed&&e.body!==null?$t(s,e.body):B(s)&&Ct(s)}catch{}}}}const ne=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},et=t=>{if(t==="running")return w.jsx(Et,{type:"dots"});const e=t==="failed"?dt:t==="skipped"?_:t==="success"?lt:_;return w.jsx(b,{color:ne(t),children:e})},st=({state:t,tick:e,verbose:s})=>w.jsxs(C,{flexDirection:"column",children:[[...t.patterns.values()].map(r=>w.jsxs(C,{flexDirection:"column",children:[w.jsxs(C,{children:[et(r.status),w.jsxs(b,{children:[" ",r.title]})]}),[...r.commands.values()].map(n=>w.jsxs(C,{flexDirection:"column",marginLeft:2,children:[w.jsxs(C,{children:[et(n.status),w.jsxs(b,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?w.jsxs(b,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),s&&n.output?w.jsx(C,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((a,c)=>w.jsx(b,{color:"gray",children:a},`${n.id}-line-${c}`))}):null,n.status==="failed"&&n.error?w.jsx(C,{marginLeft:2,children:w.jsx(b,{color:"red",children:n.error.message})}):null]},n.id))]},r.id)),t.infoMessages.map((r,n)=>w.jsx(b,{color:"gray",children:r},`info-${n}`)),t.warnMessages.map((r,n)=>w.jsx(b,{color:"yellow",children:r},`warn-${n}`)),t.errorMessages.map(({message:r},n)=>w.jsx(b,{color:"red",children:r},`err-${n}`))]}),ie=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=Tt(w.jsx(st,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),a=()=>{r+=1,n.rerender(w.jsx(st,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:i,error:o,output:l,patternId:h,status:d}){const u=s.patterns.get(h)?.commands.get(c);u&&(u.status=d,u.durationMs=i,u.output=l,u.error=o,a())},commandStart({commandId:c,patternId:i}){const o=s.patterns.get(i)?.commands.get(c);o&&(o.status="running",a())},error({error:c,message:i}){s.errorMessages.push({error:c,message:i}),a()},info({message:c}){s.infoMessages.push(c),a()},patternEnd({patternId:c,status:i}){const o=s.patterns.get(c);o&&(o.status=i,a())},patternStart({patternId:c}){const i=s.patterns.get(c);i&&(i.status="running",a())},start({patterns:c}){s.started=!0;for(const i of c){const o=new Map;for(const l of i.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(i.id,{commands:o,id:i.id,status:"pending",title:i.title})}a()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),a()}}},rt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,a=i=>{e||process.stderr.write(`${i}
|
|
14
14
|
`)},c=i=>{switch(i){case"failed":return G(dt);case"running":return F(">");case"skipped":return V(_);case"success":return Mt(lt);default:return $(_)}};return{commandEnd({commandId:i,durationMs:o,error:l,output:h,status:d}){const u=n.get(i)??i,p=$(`(${o}ms)`);if(a(` ${c(d)} ${u} ${p}`),d==="failed"&&l&&a($(l.message)),(d==="failed"||s)&&h&&h.trim().length>0)for(const f of h.split(/\r?\n/))a(` ${$(f)}`)},commandStart({commandId:i}){if(!s)return;const o=n.get(i)??i;a(` ${$("…")} ${o}`)},error({error:i,message:o}){e?process.stderr.write(`${G(o)}
|
|
15
15
|
`):a(G(o)),i?.stack&&(s||!e)&&process.stderr.write(`${$(i.stack)}
|
|
16
16
|
`)},info({message:i}){a($(i))},patternEnd({patternId:i,status:o}){const l=r.get(i)??i;a(`${c(o)} ${l}`)},patternStart({patternId:i}){const o=r.get(i)??i;a(`${F(">")} ${o}`)},start({patterns:i}){if(i.length===0){a($("No staged files matched any pattern."));return}const o=new Set(i.flatMap(l=>l.files)).size;a(`${F(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${i.length} pattern${i.length===1?"":"s"}`);for(const l of i){r.set(l.id,l.title);for(const h of l.commands)n.set(h.id,h.title)}},stop(){},warn({message:i}){a(V(i))}}},ae=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return rt({quiet:t.quiet,verbose:t.verbose});try{return ie({verbose:t.verbose})}catch{return rt({quiet:t.quiet,verbose:t.verbose})}},oe=t=>{const e=[];let s="",r=!1,n=!1;for(let a=0;a<t.length;a+=1){const c=t[a];if(c===void 0)break;if(c==="\\"&&!r&&a+1<t.length){const i=t[a+1];if(i!==void 0){n&&i!=='"'&&i!=="\\"&&(s+=c),s+=i,a+=1;continue}}if(c==='"'&&!r){n=!n;continue}if(c==="'"&&!n){r=!r;continue}if(!r&&!n&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(r||n)throw new v(`Unterminated ${r?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},gt=process.platform==="win32"?28e3:131072,ce=(t,e,s)=>{const r=[];let n=[],a=e;const c=s<=0?gt:s;for(const i of t){const o=Buffer.byteLength(i)+1;n.length>0&&a+o>c&&(r.push(n),n=[],a=e),n.push(i),a+=o}return n.length>0&&r.push(n),r},de=async(t,e,s)=>{const r=oe(t);if(r.length===0)throw new I(t,"Empty command for staged task.");const[n,...a]=r;if(n===void 0)throw new I(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+a.reduce((h,d)=>h+Buffer.byteLength(d)+1,0),i=ce(e,c,s.maxArgLength??gt),o=Date.now(),l=[];for(const h of i){if(s.signal?.aborted===!0)throw new I(t,"Task aborted by earlier failure.");const d=ct(n,[...a,...h],{nodeOptions:{cwd:s.cwd,env:le(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,p=[u.stdout,u.stderr].filter(g=>g.length>0).join(`
|
|
17
17
|
`);p.length>0&&l.push(p);const f=d.process?.signalCode??null;if(d.aborted||f!==null||u.exitCode===void 0){const g=d.aborted?"Task aborted by earlier failure.":f===null?p.trim()||"Task exited without a numeric status code.":`Task killed by signal ${f}.`;throw new I(t,g)}if(u.exitCode!==0)throw new I(t,p.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
|
|
18
|
-
`)}},le=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return At(r,e)},ue=async(t,e,s)=>{const r=fe(s.concurrent,t.length),n=[],a=new AbortController;let c=!1,i=0;const o=()=>{c||(c=!0,s.continueOnError||a.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=f=>{for(const g of f.commands)e.commandEnd({commandId:g.id,durationMs:0,patternId:f.id,status:"skipped"})},h=async f=>{if(c){l(f),e.patternEnd({patternId:f.id,status:"skipped"});return}e.patternStart({patternId:f.id});let g="success";for(const y of f.commands){if(c){e.commandEnd({commandId:y.id,durationMs:0,patternId:f.id,status:"skipped"}),g=g==="success"?"skipped":g;continue}e.commandStart({commandId:y.id,patternId:f.id});const T=await he(y,s,a.signal),S=T.status==="failed"&&a.signal.aborted?{...T,status:"skipped"}:T;if(e.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:f.id,status:S.status}),S.status==="failed"){n.push(y.title),g="failed",o();break}if(S.status==="skipped"){g=g==="success"?"skipped":g;break}}e.patternEnd({patternId:f.id,status:g})},d=async()=>{for(;i<t.length;){const f=t[i];i+=1,f&&await h(f)}},u=[];for(let f=0;f<Math.min(r,t.length);f+=1)u.push(d());await Promise.all(u);const p=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!p}},he=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await de(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new I(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const a=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:a,output:a instanceof I?a.message:void 0,status:"failed"}}},fe=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof z=="function"?z():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},pe=!0,ge=t=>{try{return!vt(t)}catch{return!1}},me=t=>{try{const e=St(t);return e?
|
|
18
|
+
`)}},le=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return At(r,e)},ue=async(t,e,s)=>{const r=fe(s.concurrent,t.length),n=[],a=new AbortController;let c=!1,i=0;const o=()=>{c||(c=!0,s.continueOnError||a.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=f=>{for(const g of f.commands)e.commandEnd({commandId:g.id,durationMs:0,patternId:f.id,status:"skipped"})},h=async f=>{if(c){l(f),e.patternEnd({patternId:f.id,status:"skipped"});return}e.patternStart({patternId:f.id});let g="success";for(const y of f.commands){if(c){e.commandEnd({commandId:y.id,durationMs:0,patternId:f.id,status:"skipped"}),g=g==="success"?"skipped":g;continue}e.commandStart({commandId:y.id,patternId:f.id});const T=await he(y,s,a.signal),S=T.status==="failed"&&a.signal.aborted?{...T,status:"skipped"}:T;if(e.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:f.id,status:S.status}),S.status==="failed"){n.push(y.title),g="failed",o();break}if(S.status==="skipped"){g=g==="success"?"skipped":g;break}}e.patternEnd({patternId:f.id,status:g})},d=async()=>{for(;i<t.length;){const f=t[i];i+=1,f&&await h(f)}},u=[];for(let f=0;f<Math.min(r,t.length);f+=1)u.push(d());await Promise.all(u);const p=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!p}},he=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await de(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new I(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const a=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:a,output:a instanceof I?a.message:void 0,status:"failed"}}},fe=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof z=="function"?z():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},pe=!0,ge=t=>{try{return!vt(t)}catch{return!1}},me=t=>{try{const e=St(t);return e?bt(t,e).map(s=>O(t,s)):[]}catch{return[]}},we=async(t={})=>{const e=t.cwd??process.cwd(),s=await ae(t),r=await Dt(t);typeof r!="function"&&X(r);const n=new re({...t,cwd:e}),a=new AbortController;let c=!1;const i=d=>{if(c){process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),a.abort()};process.on("SIGINT",i),process.on("SIGTERM",i);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,h=!1;try{await n.prepare(),l=!0;for(const T of n.warnings)s.warn({message:T});if(n.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=ge(e),u=Nt(n.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&n.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const p=typeof r=="function"?X(await r([...u])):r,f=await Pt({caseInsensitive:d,config:p,cwd:e,files:u,relative:t.relative,workspacePackages:me(e)});if(s.start({patterns:f}),f.length===0)return s.info({message:"No staged files matched any pattern."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:g,success:y}=await ue(f,s,{concurrent:t.concurrent??pe,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:a.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:g,ranTasks:!0,success:y},y){if(t.diff===void 0&&(await n.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&n.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...g],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new jt("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)s.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const T=n.recoveryHint();T&&s.warn({message:T})}return await n.restoreUnstagedChanges(),h=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),p=d instanceof Error?d:new Error(u);if(s.error({error:p,message:u}),d instanceof E)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),l)try{await n.cleanup(h)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},ye="VIS_STAGED_CONCURRENT",nt=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},ke=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=k=>t[k]===void 0?void 0:!!t[k],n=k=>{const D=t[k];return typeof D=="string"&&D.length>0?D:void 0},a=r("allow-empty");a!==void 0&&(s.allowEmpty=a);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const i=r("continue-on-error");i!==void 0&&(s.continueOnError=i);const o=r("debug");o!==void 0&&(s.debug=o);const l=r("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const h=r("hide-partially-staged");h!==void 0&&(s.hidePartiallyStaged=h);const d=r("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=r("quiet");u!==void 0&&(s.quiet=u);const p=r("relative");p!==void 0&&(s.relative=p);const f=r("revert");f!==void 0&&(s.revert=f);const g=r("stash");g!==void 0&&(s.stash=g);const y=r("verbose");y!==void 0&&(s.verbose=y);const T=n("cwd");T!==void 0&&(s.cwd=T);const S=n("diff");S!==void 0&&(s.diff=S);const U=n("diff-filter");if(U!==void 0&&(s.diffFilter=U),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const k=process.env[ye];k!==void 0&&(s.concurrent=nt(k.trim()))}else{const{concurrent:k}=t;s.concurrent=nt(typeof k=="string"?k:typeof k=="number"||typeof k=="boolean"?String(k):"")}return s},Ae=async({options:t,visConfig:e})=>{const s=(e??{}).staged;if(!s)throw new Error(`No "staged" config found in vis.config.ts. Add one:
|
|
19
19
|
|
|
20
20
|
// vis.config.ts
|
|
21
21
|
import { defineConfig } from "@visulima/vis/config";
|