@visulima/vis 1.0.0-alpha.4 → 1.0.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1243 -78
- package/LICENSE.md +13068 -6
- package/README.md +388 -26
- package/dashboard/dist/index.html +152 -0
- package/dist/bin.js +1 -853
- package/dist/binx.js +3 -0
- package/dist/config/index.d.ts +3276 -0
- package/dist/config/index.js +1 -0
- package/dist/generate/index.d.ts +157 -0
- package/dist/generate/index.js +1 -0
- package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -0
- package/dist/packem_chunks/bin.js +1198 -0
- package/dist/packem_chunks/bloom-status.js +2 -0
- package/dist/packem_chunks/bloom-sync.js +2 -0
- package/dist/packem_chunks/cache-attestation.js +1 -0
- package/dist/packem_chunks/catalog-detector.js +1 -0
- package/dist/packem_chunks/config.js +21 -0
- package/dist/packem_chunks/detect.js +3 -0
- package/dist/packem_chunks/detect2.js +8 -0
- package/dist/packem_chunks/devtools.js +81 -0
- package/dist/packem_chunks/discord.js +4 -0
- package/dist/packem_chunks/doctor-probe.js +2 -0
- package/dist/packem_chunks/dynamic-import.js +1 -0
- package/dist/packem_chunks/extra-files.js +3 -0
- package/dist/packem_chunks/fix.js +11 -0
- package/dist/packem_chunks/git.js +3 -0
- package/dist/packem_chunks/handler.js +1 -0
- package/dist/packem_chunks/handler10.js +1 -0
- package/dist/packem_chunks/handler11.js +5 -0
- package/dist/packem_chunks/handler12.js +1 -0
- package/dist/packem_chunks/handler13.js +27 -0
- package/dist/packem_chunks/handler14.js +5 -0
- package/dist/packem_chunks/handler15.js +1 -0
- package/dist/packem_chunks/handler16.js +1 -0
- package/dist/packem_chunks/handler17.js +1 -0
- package/dist/packem_chunks/handler18.js +1 -0
- package/dist/packem_chunks/handler19.js +1 -0
- package/dist/packem_chunks/handler2.js +4 -0
- package/dist/packem_chunks/handler20.js +5 -0
- package/dist/packem_chunks/handler21.js +2 -0
- package/dist/packem_chunks/handler22.js +2 -0
- package/dist/packem_chunks/handler23.js +1 -0
- package/dist/packem_chunks/handler24.js +1 -0
- package/dist/packem_chunks/handler25.js +1 -0
- package/dist/packem_chunks/handler26.js +5 -0
- package/dist/packem_chunks/handler27.js +1 -0
- package/dist/packem_chunks/handler28.js +3 -0
- package/dist/packem_chunks/handler29.js +1 -0
- package/dist/packem_chunks/handler3.js +4 -0
- package/dist/packem_chunks/handler30.js +1 -0
- package/dist/packem_chunks/handler31.js +2 -0
- package/dist/packem_chunks/handler32.js +2 -0
- package/dist/packem_chunks/handler33.js +2 -0
- package/dist/packem_chunks/handler34.js +3 -0
- package/dist/packem_chunks/handler35.js +6 -0
- package/dist/packem_chunks/handler36.js +1 -0
- package/dist/packem_chunks/handler37.js +42 -0
- package/dist/packem_chunks/handler38.js +8 -0
- package/dist/packem_chunks/handler39.js +9 -0
- package/dist/packem_chunks/handler4.js +6 -0
- package/dist/packem_chunks/handler40.js +75 -0
- package/dist/packem_chunks/handler41.js +5 -0
- package/dist/packem_chunks/handler42.js +4 -0
- package/dist/packem_chunks/handler43.js +3 -0
- package/dist/packem_chunks/handler44.js +2 -0
- package/dist/packem_chunks/handler45.js +1 -0
- package/dist/packem_chunks/handler46.js +1 -0
- package/dist/packem_chunks/handler47.js +1 -0
- package/dist/packem_chunks/handler48.js +3 -0
- package/dist/packem_chunks/handler49.js +1 -0
- package/dist/packem_chunks/handler5.js +8 -0
- package/dist/packem_chunks/handler50.js +7 -0
- package/dist/packem_chunks/handler51.js +33 -0
- package/dist/packem_chunks/handler52.js +3 -0
- package/dist/packem_chunks/handler53.js +8 -0
- package/dist/packem_chunks/handler54.js +4 -0
- package/dist/packem_chunks/handler55.js +1 -0
- package/dist/packem_chunks/handler56.js +12 -0
- package/dist/packem_chunks/handler57.js +7 -0
- package/dist/packem_chunks/handler58.js +5 -0
- package/dist/packem_chunks/handler59.js +11 -0
- package/dist/packem_chunks/handler6.js +1 -0
- package/dist/packem_chunks/handler60.js +3 -0
- package/dist/packem_chunks/handler61.js +22 -0
- package/dist/packem_chunks/handler62.js +61 -0
- package/dist/packem_chunks/handler63.js +3 -0
- package/dist/packem_chunks/handler64.js +6 -0
- package/dist/packem_chunks/handler65.js +708 -0
- package/dist/packem_chunks/handler66.js +24 -0
- package/dist/packem_chunks/handler67.js +25 -0
- package/dist/packem_chunks/handler68.js +153 -0
- package/dist/packem_chunks/handler69.js +10 -0
- package/dist/packem_chunks/handler7.js +1 -0
- package/dist/packem_chunks/handler70.js +24 -0
- package/dist/packem_chunks/handler71.js +322 -0
- package/dist/packem_chunks/handler72.js +48 -0
- package/dist/packem_chunks/handler73.js +27 -0
- package/dist/packem_chunks/handler74.js +3 -0
- package/dist/packem_chunks/handler75.js +190 -0
- package/dist/packem_chunks/handler76.js +38 -0
- package/dist/packem_chunks/handler8.js +1 -0
- package/dist/packem_chunks/handler9.js +1 -0
- package/dist/packem_chunks/heal-accept.js +10 -0
- package/dist/packem_chunks/heal.js +14 -0
- package/dist/packem_chunks/help-command.js +31 -0
- package/dist/packem_chunks/index.js +1 -0
- package/dist/packem_chunks/index2.js +7 -0
- package/dist/packem_chunks/interface.js +2 -0
- package/dist/packem_chunks/keys-refresh.js +4 -0
- package/dist/packem_chunks/list.js +3 -0
- package/dist/packem_chunks/loader.js +4 -0
- package/dist/packem_chunks/loader2.js +1 -0
- package/dist/packem_chunks/orchestrator.js +39 -0
- package/dist/packem_chunks/pre-mode.js +2 -0
- package/dist/packem_chunks/print-config.js +2 -0
- package/dist/packem_chunks/prompts.js +7 -0
- package/dist/packem_chunks/prune.js +3 -0
- package/dist/packem_chunks/publish-guards.js +1 -0
- package/dist/packem_chunks/registry.js +48 -0
- package/dist/packem_chunks/resolveFormatter.js +9 -0
- package/dist/packem_chunks/run.js +1 -0
- package/dist/packem_chunks/security.js +1 -0
- package/dist/packem_chunks/shell-runner.js +1 -0
- package/dist/packem_chunks/slack.js +2 -0
- package/dist/packem_chunks/snapshot.js +2 -0
- package/dist/packem_chunks/stage-publisher.js +1 -0
- package/dist/packem_chunks/staged-registry.js +2 -0
- package/dist/packem_chunks/state.js +3 -0
- package/dist/packem_chunks/status.js +2 -0
- package/dist/packem_chunks/success-walk.js +8 -0
- package/dist/packem_chunks/sync.js +2 -0
- package/dist/packem_chunks/sync2.js +2 -0
- package/dist/packem_chunks/tar.js +3 -0
- package/dist/packem_chunks/tripwire.js +2 -0
- package/dist/packem_chunks/verify-lockfile.js +2 -0
- package/dist/packem_chunks/version-resolver.js +2 -0
- package/dist/packem_chunks/webhook.js +1 -0
- package/dist/packem_chunks/workflow-templates.js +167 -0
- package/dist/packem_chunks/workspace.js +2 -0
- package/dist/packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js +1 -0
- package/dist/packem_shared/CONFIG_FILES-BfaR0jKT.js +1 -0
- package/dist/packem_shared/MultiSpinner-B9U0-aE3-B-gIXhFk.js +3 -0
- package/dist/packem_shared/ReleaseClient-YHzBIxYS.js +1 -0
- package/dist/packem_shared/Table-CcVkyULl-B_ef6zfS.js +35 -0
- package/dist/packem_shared/VisReleaseError-DMGRBTNO.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +1 -0
- package/dist/packem_shared/advisories-DLeO5KMN.js +1 -0
- package/dist/packem_shared/affected-shas-cVnX8-zs.js +1 -0
- package/dist/packem_shared/ai-analysis-BUeX2J2H.js +68 -0
- package/dist/packem_shared/ai-fix-9Vzlp6XU.js +43 -0
- package/dist/packem_shared/anolilab-text-CAM_E6uK.js +13 -0
- package/dist/packem_shared/api.d-BPftyU9r.d.ts +27 -0
- package/dist/packem_shared/build-scripts-CCCi8U66.js +1 -0
- package/dist/packem_shared/command-runtime-CR70qSUM.js +1 -0
- package/dist/packem_shared/createAdapter-bU4DIP3F.js +1 -0
- package/dist/packem_shared/createVersionActions-BK43SNDH.js +1 -0
- package/dist/packem_shared/cyclonedx-Cadls41z.js +4 -0
- package/dist/packem_shared/defineFormatter-D5dCp6Kv.js +1 -0
- package/dist/packem_shared/definePlugin-DoUcoYSy.js +1 -0
- package/dist/packem_shared/dependency-scan-DnTgYleU.js +1 -0
- package/dist/packem_shared/docker-BMLrNtWm.js +59 -0
- package/dist/packem_shared/failure-log-CEWP3bP0.js +2 -0
- package/dist/packem_shared/giget-DHY1sQZC.js +2 -0
- package/dist/packem_shared/glob-fqg4KepW-B7EjLRvw.js +1 -0
- package/dist/packem_shared/index-3jMNqQom.js +1 -0
- package/dist/packem_shared/index-BDmTbWX1.js +19 -0
- package/dist/packem_shared/index-Bt521H5J.js +30 -0
- package/dist/packem_shared/index-DGSsjmpV.js +1 -0
- package/dist/packem_shared/interface.d-B7VK2rcH.d.ts +148 -0
- package/dist/packem_shared/interface.d-Cezzifoh.d.ts +106 -0
- package/dist/packem_shared/license-t5KnNX6v.js +1 -0
- package/dist/packem_shared/lifecycle-4z9hHE5b.js +2 -0
- package/dist/packem_shared/lockfile-C8Q1_4KK.js +1 -0
- package/dist/packem_shared/manifests-Dj3pRKBT.js +1 -0
- package/dist/packem_shared/min-release-age-D1alDE3K.js +34 -0
- package/dist/packem_shared/missing-package-json-8vNHwbqw.js +1 -0
- package/dist/packem_shared/native-config-sync-BEkJW7g3.js +21 -0
- package/dist/packem_shared/osv-bloom-B03tUWf3.js +2 -0
- package/dist/packem_shared/otelPlugin-DmKDBaPo.js +1 -0
- package/dist/packem_shared/peer-warnings-BXAzXqY3.js +1 -0
- package/dist/packem_shared/pm-runner-BKZQo7Ts.js +1 -0
- package/dist/packem_shared/provenance-BFEwKgI3.js +1 -0
- package/dist/packem_shared/public-api-WqUCiyIe.js +131 -0
- package/dist/packem_shared/registry-keys-BfFto6vI.js +1 -0
- package/dist/packem_shared/resolve-explicit-C6WM-I2u.js +5 -0
- package/dist/packem_shared/runtime-check-Stc9AI78.js +1 -0
- package/dist/packem_shared/s1ngularity-DCPmPE5M.js +1 -0
- package/dist/packem_shared/scan-progress-CFhc0CMj.js +2 -0
- package/dist/packem_shared/selectors-GCJIe342.js +3 -0
- package/dist/packem_shared/signatures-Xpd6HjG_.js +2 -0
- package/dist/packem_shared/slug-DoueYuLo.js +1 -0
- package/dist/packem_shared/spinner-CV3WVJLv.js +1 -0
- package/dist/packem_shared/sticky-comment-D6_7-w8T.js +1 -0
- package/dist/packem_shared/subtree-C7bZuiSQ.js +2 -0
- package/dist/packem_shared/symbols-DPTlrJ3B.js +1 -0
- package/dist/packem_shared/tabs-BuTy5gPV.js +1 -0
- package/dist/packem_shared/toolchain-pR7AJ-tB.js +5 -0
- package/dist/packem_shared/typosquats-DN78xx1x.js +1 -0
- package/dist/packem_shared/use-measured-height-_eVGWtWt.js +1 -0
- package/dist/packem_shared/utils-Cxree603.js +1 -0
- package/dist/packem_shared/verify-6WCmFmy8.js +1 -0
- package/dist/packem_shared/vis-update-app-k3fDxech.js +1 -0
- package/dist/packem_shared/watch-BvIwLG4N.js +1 -0
- package/dist/packem_shared/watch-loop-DWkvv2tK.js +11 -0
- package/dist/release/core/changelog/index.d.ts +5 -0
- package/dist/release/core/changelog/index.js +1 -0
- package/dist/release/core/package-managers/index.d.ts +6 -0
- package/dist/release/core/package-managers/index.js +1 -0
- package/dist/release/core/version-actions/index.d.ts +14 -0
- package/dist/release/core/version-actions/index.js +1 -0
- package/dist/release/index.d.ts +196 -0
- package/dist/release/index.js +1 -0
- package/dist/release/plugin-sdk.d.ts +127 -0
- package/dist/release/plugin-sdk.js +1 -0
- package/dist/release/presets.d.ts +225 -0
- package/dist/release/presets.js +1 -0
- package/dist/release/types.d.ts +1377 -0
- package/dist/release/types.js +1 -0
- package/index.d.ts +436 -0
- package/index.js +80 -57
- package/package.json +109 -45
- package/schemas/project.schema.json +991 -0
- package/schemas/vis-config.schema.json +6389 -0
- package/schemas/vis-release-config.schema.json +1390 -0
- package/skills/vis/SKILL.md +96 -0
- package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
- package/templates/buildkite-ci/template.yml +20 -0
- package/dist/ai-analysis.d.ts +0 -40
- package/dist/ai-cache.d.ts +0 -21
- package/dist/audit-config.d.ts +0 -24
- package/dist/bin.d.ts +0 -1
- package/dist/catalog.d.ts +0 -118
- package/dist/commands/add.d.ts +0 -3
- package/dist/commands/affected.d.ts +0 -3
- package/dist/commands/ai.d.ts +0 -3
- package/dist/commands/analyze.d.ts +0 -3
- package/dist/commands/approve-builds.d.ts +0 -3
- package/dist/commands/audit.d.ts +0 -23
- package/dist/commands/check.d.ts +0 -3
- package/dist/commands/clean.d.ts +0 -3
- package/dist/commands/create/discovery.d.ts +0 -42
- package/dist/commands/create/index.d.ts +0 -13
- package/dist/commands/create/prompts.d.ts +0 -31
- package/dist/commands/create/random-name.d.ts +0 -15
- package/dist/commands/create/templates/builtin.d.ts +0 -15
- package/dist/commands/create/templates/generator.d.ts +0 -14
- package/dist/commands/create/templates/index.d.ts +0 -13
- package/dist/commands/create/templates/monorepo.d.ts +0 -16
- package/dist/commands/create/templates/remote.d.ts +0 -41
- package/dist/commands/create/templates/types.d.ts +0 -46
- package/dist/commands/create/utils.d.ts +0 -42
- package/dist/commands/dedupe.d.ts +0 -3
- package/dist/commands/devcontainer.d.ts +0 -3
- package/dist/commands/dlx.d.ts +0 -3
- package/dist/commands/doctor.d.ts +0 -15
- package/dist/commands/exec.d.ts +0 -3
- package/dist/commands/graph.d.ts +0 -3
- package/dist/commands/hook/constants.d.ts +0 -8
- package/dist/commands/hook/index.d.ts +0 -3
- package/dist/commands/hook/install.d.ts +0 -7
- package/dist/commands/hook/migrate.d.ts +0 -27
- package/dist/commands/hook/uninstall.d.ts +0 -3
- package/dist/commands/implode.d.ts +0 -3
- package/dist/commands/init.d.ts +0 -14
- package/dist/commands/install.d.ts +0 -3
- package/dist/commands/link.d.ts +0 -3
- package/dist/commands/migrate/constants.d.ts +0 -12
- package/dist/commands/migrate/deps.d.ts +0 -32
- package/dist/commands/migrate/index.d.ts +0 -3
- package/dist/commands/migrate/json.d.ts +0 -20
- package/dist/commands/migrate/lint-staged.d.ts +0 -62
- package/dist/commands/migrate/types.d.ts +0 -20
- package/dist/commands/optimize.d.ts +0 -38
- package/dist/commands/pm.d.ts +0 -3
- package/dist/commands/remove.d.ts +0 -3
- package/dist/commands/run.d.ts +0 -3
- package/dist/commands/sort-package-json.d.ts +0 -3
- package/dist/commands/staged.d.ts +0 -3
- package/dist/commands/unlink.d.ts +0 -3
- package/dist/commands/update.d.ts +0 -3
- package/dist/commands/upgrade.d.ts +0 -3
- package/dist/commands/why.d.ts +0 -3
- package/dist/config.d.ts +0 -67
- package/dist/config.js +0 -1
- package/dist/native-binding.d.ts +0 -151
- package/dist/output.d.ts +0 -40
- package/dist/overrides.d.ts +0 -82
- package/dist/package-manager.d.ts +0 -23
- package/dist/plugins/config-loader.d.ts +0 -3
- package/dist/plugins/post-command.d.ts +0 -3
- package/dist/plugins/security-enforcement.d.ts +0 -3
- package/dist/pm-runner.d.ts +0 -23
- package/dist/security.d.ts +0 -64
- package/dist/socket-security.d.ts +0 -129
- package/dist/tips.d.ts +0 -41
- package/dist/tui/components/CheckProgressApp.d.ts +0 -6
- package/dist/tui/components/CommandSummary.d.ts +0 -17
- package/dist/tui/components/Header.d.ts +0 -13
- package/dist/tui/components/OutputPanel.d.ts +0 -16
- package/dist/tui/components/QuitDialog.d.ts +0 -15
- package/dist/tui/components/TaskListPanel.d.ts +0 -19
- package/dist/tui/components/TaskRow.d.ts +0 -12
- package/dist/tui/components/TaskStore.d.ts +0 -80
- package/dist/tui/components/VisTaskRunnerApp.d.ts +0 -17
- package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +0 -66
- package/dist/tui/components/devcontainer/VisDevcontainerApp.d.ts +0 -9
- package/dist/tui/components/devcontainer/catalogs/extensions.d.ts +0 -8
- package/dist/tui/components/devcontainer/catalogs/features.d.ts +0 -8
- package/dist/tui/components/devcontainer/catalogs/filters.d.ts +0 -4
- package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +0 -19
- package/dist/tui/components/devcontainer/catalogs/templates.d.ts +0 -8
- package/dist/tui/components/devcontainer/devcontainer-io.d.ts +0 -14
- package/dist/tui/components/devcontainer/sections/DockerComposeSection.d.ts +0 -11
- package/dist/tui/components/devcontainer/sections/EnvironmentSection.d.ts +0 -16
- package/dist/tui/components/devcontainer/sections/ExtensionsSection.d.ts +0 -11
- package/dist/tui/components/devcontainer/sections/FeaturesSection.d.ts +0 -11
- package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +0 -12
- package/dist/tui/components/devcontainer/sections/LifecycleSection.d.ts +0 -13
- package/dist/tui/components/devcontainer/sections/MountsSection.d.ts +0 -16
- package/dist/tui/components/devcontainer/sections/PortsSection.d.ts +0 -10
- package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +0 -11
- package/dist/tui/components/devcontainer/types.d.ts +0 -53
- package/dist/tui/components/devcontainer/validate.d.ts +0 -16
- package/dist/tui/components/graph/GraphStore.d.ts +0 -42
- package/dist/tui/components/graph/ProjectDetailPanel.d.ts +0 -10
- package/dist/tui/components/graph/ProjectListPanel.d.ts +0 -20
- package/dist/tui/components/graph/VisGraphApp.d.ts +0 -8
- package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +0 -9
- package/dist/tui/components/optimize/OptimizeListPanel.d.ts +0 -16
- package/dist/tui/components/optimize/OptimizeStore.d.ts +0 -50
- package/dist/tui/components/optimize/VisOptimizeApp.d.ts +0 -8
- package/dist/tui/components/optimize/constants.d.ts +0 -7
- package/dist/tui/components/update/PackageDetailPanel.d.ts +0 -12
- package/dist/tui/components/update/PackageListPanel.d.ts +0 -18
- package/dist/tui/components/update/UpdateStore.d.ts +0 -62
- package/dist/tui/components/update/VisUpdateApp.d.ts +0 -11
- package/dist/tui/dynamic-life-cycle.d.ts +0 -21
- package/dist/tui/formatting-utils.d.ts +0 -17
- package/dist/tui/pretty-time.d.ts +0 -8
- package/dist/tui/static-life-cycle.d.ts +0 -22
- package/dist/tui/status-utils.d.ts +0 -20
- package/dist/tui/symbols.d.ts +0 -7
- package/dist/tui/types.d.ts +0 -11
- package/dist/typosquats.d.ts +0 -70
- package/dist/upgrade-check.d.ts +0 -30
- package/dist/utils.d.ts +0 -22
- package/dist/workspace.d.ts +0 -315
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{createRequire as ct}from"node:module";import{I as We,s as O,E as P,q as Le,V as G,j as ut}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as V,f as U,v as K,I as J,A as dt,T as pt}from"../packem_shared/index-BDmTbWX1.js";import"smol-toml";import{P as ft,ba as gt,bb as mt,bc as ht,bd as $t,u as Re,b0 as yt,r as ae,l as de,j as kt,R as wt,c as vt,V as bt,be as Rt,bf as He,$ as xe,d as M,h as pe,m as L,H as Fe,bg as xt,F as q,B as At,bh as St,bi as Ct,o as Et,G as Tt}from"./bin.js";import{E as jt}from"../packem_shared/public-api-WqUCiyIe.js";import{K as Dt,Z as Ot,W as Ae}from"../packem_shared/ai-analysis-BUeX2J2H.js";import{v as Ut,I as Bt,s as ze}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{a as Vt,r as _t}from"../packem_shared/command-runtime-CR70qSUM.js";import{r as Mt,a as Pt,p as qt}from"../packem_shared/resolve-explicit-C6WM-I2u.js";import{S as Wt}from"../packem_shared/min-release-age-D1alDE3K.js";import{r as Lt,s as Ht}from"../packem_shared/typosquats-DN78xx1x.js";import{U as Ft,b as zt,u as Se}from"../packem_shared/vis-update-app-k3fDxech.js";import{h as Ge,P as Ke}from"../packem_shared/peer-warnings-BXAzXqY3.js";import{f as Je}from"../packem_shared/utils-Cxree603.js";import{s as ee}from"../packem_shared/index-DGSsjmpV.js";import{r as Gt,q as Kt}from"../packem_shared/advisories-DLeO5KMN.js";const lt=ct(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Pe=e=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[t,n]=Z.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Z.getBuiltinModule(e)}return lt(e)},{createInterface:qe}=Pe("node:readline"),{existsSync:It,realpathSync:Nt}=Pe("node:fs"),Jt=e=>{const t=[];for(const n of e.filters)t.push("--filter",n);return e.workspaceRoot&&t.push("--filter","."),t.push("update"),e.latest&&t.push("--latest"),e.recursive&&t.push("--recursive"),e.interactive&&t.push("--interactive"),e.dev&&t.push("--dev"),e.prod&&t.push("--prod"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"pnpm"}},Yt=e=>{const t=[];return e.filters.length>0&&t.push("workspace",e.filters[0]),t.push("upgrade"),e.latest&&t.push("--latest"),t.push(...e.packages),{args:t,bin:"yarn"}},Xt=e=>{const t=[];if(e.filters.length>0||e.recursive){t.push("workspaces","foreach","--all");for(const n of e.filters)t.push("--include",n)}return t.push("up"),e.interactive&&t.push("--interactive"),t.push(...e.packages),{args:t,bin:"yarn"}},Zt=(e,t)=>{const n=["update"];e.latest&&t.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&t.push("npm does not support --interactive mode.");for(const s of e.filters)n.push("--workspace",s);return e.recursive&&n.push("--workspaces"),e.workspaceRoot&&n.push("--include-workspace-root"),e.dev&&n.push("--dev"),e.prod&&n.push("--production"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"npm"}},Qt=e=>{const t=["update"];e.latest&&t.push("--latest");for(const n of e.filters)t.push("--filter",n);return t.push(...e.packages),{args:t,bin:"bun"}},en=(e,t)=>{const n=["outdated","--update"];return e.latest&&n.push("--latest"),e.interactive&&n.push("--interactive"),e.filters.length>0&&t.push("deno outdated has no --filter flag; ignoring."),(e.dev||e.prod)&&t.push("deno outdated has no --dev / --prod flags; dev/prod is governed by deno.json."),e.noOptional&&t.push("deno outdated has no --no-optional flag; ignoring."),e.noSave&&t.push("deno outdated has no --no-save flag; ignoring."),n.push(...e.packages),{args:n,bin:"deno"}},tn=(e,t,n)=>{const s=[];if(n.global&&e!=="aube"&&e!=="deno")return{command:{args:["update","--global",...n.packages],bin:"npm"},warnings:s};let r;switch(e){case"aube":{const o=Ut(n);r={args:o.args,bin:o.bin},s.push(...o.warnings);break}case"bun":{r=Qt(n);break}case"deno":{r=en(n,s);break}case"npm":{r=Zt(n,s);break}case"pnpm":{r=Jt(n);break}case"yarn":{r=t.startsWith("1.")?Yt(n):Xt(n);break}default:{const o=e;throw new Error(`Unsupported package manager: ${String(o)}`)}}return{command:r,warnings:s}},Ye=e=>{const t=e.indexOf("@");return t<=0?e:e.slice(0,t)},nn=e=>{switch(e){case"docker":case"docker-compose":return"docker";case"github-actions":return"actions";case"gitlab-ci":return"gitlab";default:return}},sn=(e,t)=>{const n=[".github/dependabot.yml",".github/dependabot.yaml"];for(const s of n){const r=V(e,s);if(!U(r))continue;let o;try{o=jt(K(r))}catch{continue}if(o?.updates){for(const i of o.updates){const a=nn(i["package-ecosystem"]);if(!(!a||!Array.isArray(i.ignore)))for(const d of i.ignore){const c=d["dependency-name"];typeof c=="string"&&c.length>0&&t[a].add(Ye(c))}}return}}},on=Object.freeze({"docker-compose":"docker",dockerfile:"docker","github-actions":"actions",gitlabci:"gitlab","gitlabci-include":"gitlab"}),rn=Object.freeze({docker:"docker","github-tags":"actions"}),fe=(e,t)=>{if(t)for(const n of t)typeof n=="string"&&n.length>0&&e.add(Ye(n))},an=e=>{let t="",n=0;const{length:s}=e;let r=!1,o="";for(;n<s;){const i=e[n]??"";if(r){if(t+=i,i==="\\"&&n+1<s){t+=e[n+1]??"",n+=2;continue}i===o&&(r=!1),n+=1;continue}if(i==='"'||i==="'"){r=!0,o=i,t+=i,n+=1;continue}if(i==="/"&&e[n+1]==="/"){for(;n<s&&e[n]!==`
|
|
2
|
+
`;)n+=1;continue}if(i==="/"&&e[n+1]==="*"){for(n+=2;n<s&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}if(i===","){let a=n+1;for(;a<s&&/\s/.test(e[a]??"");)a+=1;const d=e[a];if(d==="}"||d==="]"){n+=1;continue}}t+=i,n+=1}return t},cn=(e,t)=>{const n=["renovate.json","renovate.json5",".renovaterc",".renovaterc.json"];for(const s of n){const r=V(e,s);if(!U(r))continue;let o;try{const a=K(r);o=JSON.parse(an(a))}catch{continue}if(!o)continue;if(Array.isArray(o.ignoreDeps))for(const a of["actions","docker","gitlab"])fe(t[a],o.ignoreDeps);const i=[["github-actions","actions"],["dockerfile","docker"],["docker-compose","docker"],["gitlabci","gitlab"],["gitlabci-include","gitlab"]];for(const[a,d]of i){const c=o[a];fe(t[d],c?.ignoreDeps)}if(!Array.isArray(o.packageRules))return;for(const a of o.packageRules){if(a.enabled!==!1)continue;const d=new Set;for(const u of a.matchManagers??[]){const f=on[u];f&&d.add(f)}for(const u of a.matchDatasources??[]){const f=rn[u];f&&d.add(f)}d.size===0&&(d.add("actions"),d.add("docker"),d.add("gitlab"));const c=[...a.matchPackageNames??[],...a.matchDepNames??[],...a.matchPackagePatterns??[]];for(const u of d)fe(t[u],c)}return}},ln=e=>{const t={actions:new Set,docker:new Set,gitlab:new Set};return sn(e,t),cn(e,t),t},he=(e,t,n)=>{const s=n[t];if(s.size===0)return!1;if(s.has(e))return!0;for(const r of s)if(/[*?[\]/.+]/.test(r))try{const o=r.replaceAll(/[.+^${}()|]/g,String.raw`\$&`).replaceAll("*",".*").replaceAll("?",".");if(new RegExp(`^${o}$`).test(e))return!0}catch{}return!1},H=e=>{const t=e.trim();if(t==="")return;const n=t.startsWith("v")||t.startsWith("V")?t.slice(1):t,s=(ee.valid(n)?ee.parse(n):void 0)??ee.coerce(n,{includePrerelease:!0});if(s)return{major:s.major,minor:s.minor,normalized:`${String(s.major)}.${String(s.minor)}.${String(s.patch)}${s.prerelease.length>0?`-${s.prerelease.join(".")}`:""}`,patch:s.patch,prerelease:s.prerelease.length>0,raw:t}},un=(e,t)=>ee.rcompare(e.normalized,t.normalized),$e=(e,t,n,s)=>{if(!t&&n!=="latest")return;const r=e.filter(o=>o.prerelease?!1:t?n==="patch"&&(o.major!==t.major||o.minor!==t.minor)||n==="minor"&&o.major!==t.major?!1:ee.gt(o.normalized,t.normalized):!0);if(r.length!==0)return r.toSorted(un)[0]},ye=(e,t)=>!e||!t?"unknown":t.major!==e.major?"major":t.minor!==e.minor?"minor":t.patch!==e.patch?"patch":"unknown",dn="GitHub Actions",Ce=(e,t)=>`${e}@${t}`,pn=e=>({fixedVersions:e.fixedVersions,id:e.id,severity:e.severity,summary:e.summary}),fn=(e,t)=>{if(t.length===0)return t;const n=Gt(e);if(!It(n))return t;const s=new Map;for(const o of t){const i=o.currentVersion??o.currentRef;i&&s.set(Ce(o.name,i),{name:o.name,version:i})}if(s.size===0)return t;const r=new Map;try{for(const[o,i]of s){const a=Kt([i],{ecosystem:dn,workspaceRoot:e}).get(i.name);a&&a.length>0&&r.set(o,a)}}catch{return t}return r.size===0?t:t.map(o=>{const i=o.currentVersion??o.currentRef;if(!i)return o;const a=r.get(Ce(o.name,i));return a?{...o,advisories:a.map(d=>pn(d))}:o})},Xe=e=>{if(!e)return{};const t={};for(const n of e.split(",")){const s=/^\s*<([^>]+)>\s*;\s*(.+)$/.exec(n);if(!s)continue;const r=s[1]??"",o=s[2]??"";switch(/rel\s*=\s*"?([^";\s]+)"?/i.exec(o)?.[1]?.toLowerCase()){case"first":{t.first=r;break}case"last":{t.last=r;break}case"next":{t.next=r;break}case"prev":case"previous":{t.previous=r;break}}}return t};class gn{token;apiBase;fetchImpl;tagsCache=new Map;commitCache=new Map;constructor(t){this.token=t.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN,this.apiBase=t.apiBase??"https://api.github.com",this.fetchImpl=t.fetch??fetch}async listTags(t,n){const s=`${t}/${n}`,r=this.tagsCache.get(s);if(r)return r;const o=this.fetchTags(t,n);return this.tagsCache.set(s,o),o}async resolveRef(t,n,s){const r=`${t}/${n}@${s}`,o=this.commitCache.get(r);if(o)return o;const i=this.fetchCommit(t,n,s);return this.commitCache.set(r,i),i}buildHeaders(){const t={Accept:"application/vnd.github+json","User-Agent":"vis-update-actions","X-GitHub-Api-Version":"2022-11-28"};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}async fetchTags(t,n){const s=`${this.apiBase}/repos/${encodeURIComponent(t)}/${encodeURIComponent(n)}/tags?per_page=100`,r={parsed:[],tags:[]},o=[];let i=s,a=0;for(;i&&a<5;){const c=i;let u;try{u=await this.fetchImpl(c,{headers:this.buildHeaders()})}catch{return r}if(!u.ok)return r;let f;try{f=await u.json()}catch{return r}if(!Array.isArray(f))return r;for(const g of f){const m=typeof g.name=="string"?g.name:"",h=typeof g.commit?.sha=="string"?g.commit.sha:"";m!==""&&h!==""&&o.push({name:m,sha:h})}i=Xe(u.headers.get("link")).next,a+=1}const d=[];for(const c of o){const u=H(c.name);u&&d.push({...u,sha:c.sha})}return{parsed:d,tags:o}}async fetchCommit(t,n,s){const r=`${this.apiBase}/repos/${encodeURIComponent(t)}/${encodeURIComponent(n)}/commits/${encodeURIComponent(s)}`;try{const o=await this.fetchImpl(r,{headers:this.buildHeaders()});if(!o.ok)return;const i=await o.json();return typeof i.sha!="string"?void 0:{committedAt:i.commit?.committer?.date,sha:i.sha}}catch{return}}}const mn=".github/workflows",hn=".github/actions",$n=/^\s*-?\s*uses:\s*(['"]?)([^'"\s#]+)\1(?:\s*#\s*(.+))?\s*$/,yn=/^[a-f0-9]{40}$/i,kn=/actions-up-ignore-next-line(?::\s*(.+))?/i,wn=/actions-up-ignore-start/i,vn=/actions-up-ignore-end/i,bn=e=>{const t=e.split("/");if(t.length<2)return;const[n,s,...r]=t;if(!(!n||!s))return{owner:n,repo:s,subpath:r.length>0?r.join("/"):void 0}},Rn=(e,t)=>{const n=t.split(/\r?\n/),s=[];let r,o=!1;for(const[i,a]of n.entries()){const d=a??"";if(wn.test(d)&&(o=!0),vn.test(d)){o=!1;continue}const c=d.trim(),u=c===""||c.startsWith("#")?kn.exec(d):void 0;if(u){r=u[1]??"actions-up-ignore-next-line";continue}const f=$n.exec(d);if(!f){r=void 0;continue}const g=f[1]??"",m=g==="'"||g==='"'?g:"",h=f[2]??"",v=f[3]?.trim();if(h.startsWith("./")||h.startsWith("../")||h.startsWith("docker://")){r=void 0;continue}const x=h.lastIndexOf("@");if(x<=0){r=void 0;continue}const $=h.slice(0,x),A=h.slice(x+1),y=bn($);if(!y){r=void 0;continue}let p=r??(o?"actions-up-ignore-block":void 0);if(v){const k=/^actions-up-ignore(?:-next-line)?(?::\s*(.+))?(?:\s|$)/i.exec(v);k&&(p=p??k[1]??"actions-up-ignore")}r=void 0,s.push({file:e,ignoreReason:p,isSha:yn.test(A),line:i+1,original:`${m}${h}${m}`,owner:y.owner,quote:m,ref:A,repo:y.repo,slug:$,subpath:y.subpath,trailingComment:v&&!p?v:void 0})}return s},Ee=e=>e.endsWith(".yml")||e.endsWith(".yaml"),xn=(e,t=[])=>{const n=[],s=new Set,r=a=>{if(s.has(a))return;s.add(a);let d;try{d=K(a)}catch{return}const c=Rn(a,d);n.push(...c)},o=V(e,mn);if(U(o))for(const a of J(o,{includeDirs:!1,includeSymlinks:!1,maxDepth:1}))Ee(a.name)&&r(a.path);const i=V(e,hn);if(U(i))for(const a of J(i,{includeDirs:!1,includeSymlinks:!1,maxDepth:3}))(a.name==="action.yml"||a.name==="action.yaml")&&r(a.path);for(const a of["action.yml","action.yaml"]){const d=V(e,a);U(d)&&r(d)}for(const a of t){const d=dt(a)?a:V(e,a);if(U(d))for(const c of J(d,{includeDirs:!1,includeSymlinks:!1}))Ee(c.name)&&r(c.path)}return n},An=40,Sn=1440*60*1e3,Cn=new Set(["develop","edge","main","master","stable","trunk"]),En=e=>e.length===An&&/^[a-f0-9]{40}$/i.test(e)?!1:Cn.has(e.toLowerCase())?!0:H(e)===void 0,Te=(e,t)=>{for(const n of t)try{if(new RegExp(n).test(e))return!0}catch{if(e.includes(n))return!0}return!1},Tn=(e,t,n,s)=>{const r=s==="sha"||e.isSha,{quote:o}=e;return r?`${o}${e.slug}@${t}${o} # ${n}`:`${o}${e.slug}@${n}${o}`},jn=async(e,t)=>{const{ignoreRules:n,options:s,references:r,resolverOptions:o}=t,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const c=new gn({apiBase:o?.apiBase,fetch:o?.fetch,token:s.githubToken??o?.token}),u=new Map;for(const $ of r){const A=`${$.owner}/${$.repo}`,y=u.get(A)??[];y.push($),u.set(A,y)}const f=Math.max(1,s.maxConcurrentRequests),g=[...u.keys()];let m=0;const h=async $=>{const A=u.get($)??[],[y,p]=$.split("/");if(!y||!p)return;let k;try{k=await c.listTags(y,p)}catch{for(const l of A)d.push({file:l.file,reason:`failed to list tags for ${$}`});return}for(const l of A){const S=l.slug;let w;if(l.ignoreReason?w=l.ignoreReason:Te(S,s.exclude)?w="matched --exclude":s.include.length>0&&!Te(S,s.include)?w="not matched by --include":s.respectDependabotConfig&&n&&he(S,"actions",n)&&(w="ignored by dependabot/renovate config"),w){a.push({currentRef:l.ref,currentVersion:l.isSha?l.trailingComment?.replace(/^#\s*/,""):l.ref,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:S,newRef:l.ref,newVersion:void 0,original:l.original,reason:w,replacement:l.original,updateType:"unknown"});continue}if(!s.includeBranches&&!l.isSha&&En(l.ref)){a.push({currentRef:l.ref,currentVersion:l.ref,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:S,newRef:l.ref,newVersion:void 0,original:l.original,reason:"branch reference (use --include-branches)",replacement:l.original,updateType:"unknown"});continue}const C=l.isSha?l.trailingComment?.replace(/^#\s*/,"").split(/\s+/)[0]??"":l.ref,E=H(C);if(l.isSha&&!E&&s.mode!=="latest"){a.push({currentRef:l.ref,currentVersion:void 0,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:S,newRef:l.ref,newVersion:void 0,original:l.original,reason:`SHA pin has no version-hint comment; cannot apply --target=${s.mode}`,replacement:l.original,updateType:"unknown"});continue}const b=$e(k.parsed,E,s.mode);if(!b)continue;if(s.minAgeDays!==void 0){const _=await c.resolveRef(y,p,b.sha),D=_?.committedAt?new Date(_.committedAt).getTime():void 0;if(D&&(Date.now()-D)/Sn<s.minAgeDays){a.push({currentRef:l.ref,currentVersion:E?.raw,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:S,newRef:l.ref,newVersion:b.raw,original:l.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:l.original,updateType:"unknown"});continue}}const T=s.style==="sha"||l.isSha?b.sha:b.raw,N=Tn(l,b.sha,b.raw,s.style);i.push({currentRef:l.ref,currentVersion:E?.raw??l.trailingComment?.replace(/^#\s*/,""),ecosystem:"actions",file:l.file,line:l.line,name:S,newRef:T,newVersion:b.raw,original:l.original,replacement:N,updateType:ye(E,b),url:`https://github.com/${y}/${p}/releases/tag/${b.raw}`})}},v=[];for(let $=0;$<Math.min(f,g.length);$++)v.push((async()=>{for(;m<g.length;){const A=g[m];m+=1,A!==void 0&&await h(A)}})());await Promise.all(v);const x=fn(e,i);return{failed:d,ignored:a,updates:x}},In=e=>e.toSorted((t,n)=>t.file!==n.file?t.file<n.file?-1:1:t.line-n.line),Nn=e=>{const t=[],n=[];if(e.length===0)return{applied:t,skipped:n};const s=In(e),r=new Map;for(const o of s){const i=r.get(o.file)??[];i.push(o),r.set(o.file,i)}for(const[o,i]of r){let a;try{a=K(o)}catch(g){for(const m of i)n.push({reason:`read failed: ${g.message}`,update:m});continue}const d=a.includes(`\r
|
|
3
|
+
`)?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`,c=a.split(/\r?\n/),u=[];for(const g of i){const m=g.line-1,h=c[m];if(h===void 0){n.push({reason:`line ${String(g.line)} out of range`,update:g});continue}const v=h.indexOf(g.original);if(v===-1){n.push({reason:"original token not found on expected line",update:g});continue}const x=h.slice(0,v),$=h.slice(v+g.original.length),A=/#\s*v?\d/.test(g.replacement)&&/^\s*#\s*v?\d[\w.+-]*\s*$/i.test($)?"":$;c[m]=`${x}${g.replacement}${A}`,u.push(g)}if(u.length===0)continue;const f=c.join(d);try{pt(o,f),t.push(...u)}catch(g){for(const m of u)n.push({reason:`write failed: ${g.message}`,update:m})}}return{applied:t,skipped:n}};class Dn{tokens;fetchImpl;tagCache=new Map;constructor(t={}){this.tokens=t.tokens??{},this.fetchImpl=t.fetch??fetch}async listTags(t,n,s){const r=`${t}/${n}/${s}`,o=this.tagCache.get(r);if(o)return o;const i=t==="docker.io"?this.listDockerHubTags(n,s):this.listV2Tags(t,n,s);return this.tagCache.set(r,i),i}async listDockerHubTags(t,n){const s={parsed:[],raw:[]},r=[],o=new Map;let i=`https://hub.docker.com/v2/repositories/${encodeURIComponent(t)}/${encodeURIComponent(n)}/tags?page_size=100`,a=0;for(;i&&a<5;){try{const d=await this.fetchImpl(i,{headers:{Accept:"application/json"}});if(!d.ok)break;const c=await d.json();if(Array.isArray(c.results)){for(const u of c.results)if(typeof u.name=="string"&&(r.push(u.name),typeof u.last_updated=="string")){const f=Date.parse(u.last_updated);Number.isNaN(f)||o.set(u.name,f)}}i=typeof c.next=="string"?c.next:void 0}catch{break}a+=1}return r.length===0?s:{parsed:r.map(d=>{const c=H(d);if(c)return{...c,lastUpdated:o.get(d)}}).filter(d=>d!==void 0),raw:r}}async listV2Tags(t,n,s){const r={parsed:[],raw:[]},o=n==="library"?s:`${n}/${s}`,i={Accept:"application/json"},a=this.tokens[t]??process.env[`DOCKER_REGISTRY_TOKEN_${t.toUpperCase().replaceAll(/[^A-Z0-9]/g,"_")}`];a&&(i.Authorization=`Bearer ${a}`);const d=`https://${t}`,c=[];let u=`${d}/v2/${o}/tags/list?n=100`,f=i,g=0;const m=()=>{const h=[];for(const v of c){const x=H(v);x&&h.push({...x,lastUpdated:void 0})}return{parsed:h,raw:c}};for(;u&&g<5;){try{let h=await this.fetchImpl(u,{headers:f});if(h.status===401&&f===i){const $=Un(h.headers.get("www-authenticate"));if($){const A=await this.fetchBearerToken($);A&&(f={...i,Authorization:`Bearer ${A}`},h=await this.fetchImpl(u,{headers:f}))}}if(!h.ok)return g===0?r:m();const v=await h.json();if(!Array.isArray(v.tags))return g===0?r:m();for(const $ of v.tags)typeof $=="string"&&c.push($);const x=Xe(h.headers.get("link"));u=x.next?new URL(x.next,d).toString():void 0}catch{return g===0?r:m()}g+=1}return c.length===0?r:m()}async fetchBearerToken(t){const n=new URLSearchParams({scope:t.scope,service:t.service}),s=`${t.realm}?${n.toString()}`;try{const r=await this.fetchImpl(s,{headers:{Accept:"application/json"}});if(!r.ok)return;const o=await r.json();return o.token??o.access_token}catch{return}}}const On=e=>{const t=[];let n=0;const{length:s}=e;for(;n<s;){for(;n<s&&/\s/.test(e[n]??"");)n+=1;const r=n;for(;n<s&&e[n]!=="="&&e[n]!==",";)n+=1;const o=e.slice(r,n).trim();if(e[n]!=="="){for(;n<s&&e[n]!==",";)n+=1;n+=1;continue}n+=1;let i="";if(e[n]==='"'){for(n+=1;n<s&&e[n]!=='"';){if(e[n]==="\\"&&n+1<s){i+=e[n+1]??"",n+=2;continue}i+=e[n]??"",n+=1}n+=1}else{for(;n<s&&e[n]!==",";)i+=e[n]??"",n+=1;i=i.trim()}for(o.length>0&&t.push({key:o,value:i});n<s&&(/\s/.test(e[n]??"")||e[n]===",");)n+=1}return t},Un=e=>{if(!e)return;const t=/^Bearer\s+(.*)$/i.exec(e);if(!t)return;const n=new Map;for(const{key:o,value:i}of On(t[1]??""))n.set(o.toLowerCase(),i);const s=n.get("realm"),r=n.get("service");if(s)return{realm:s,scope:n.get("scope")??"",service:r??""}},Bn="docker.io",Vn="sha256:",re=e=>{const t=e.trim();if(t===""||t.startsWith("$")||t.includes("${")||t.includes("$("))return;let n=t,s;const r=n.indexOf(`@${Vn}`);r!==-1&&(s=n.slice(r+1),n=n.slice(0,r));let o=Bn,i=n;const a=n.indexOf("/");if(a>0){const h=n.slice(0,a);(h==="localhost"||h.includes(".")||h.includes(":"))&&(o=h,i=n.slice(a+1))}let d="latest",c=i;const u=i.lastIndexOf(":");u!==-1&&!i.slice(u).includes("/")&&(d=i.slice(u+1),c=i.slice(0,u));let f="library",g=c;const m=c.indexOf("/");if(m!==-1&&(f=c.slice(0,m),g=c.slice(m+1)),g!=="")return{digest:s,name:g,namespace:f,original:t,registry:o,tag:d}},ie=/vis-update-ignore-next-line/i,Ze=/vis-update-ignore(?:\s|$|:)/i,Qe=e=>{const t=e.trim();return t===""||t.startsWith("#")},_n=/^\s*FROM\s+(?:--\S+\s+)*([^\s#]+)(?:\s[^#]*)?(#.*)?$/i,Mn=(e,t)=>{const n=t.split(/\r?\n/),s=[];let r=!1;for(const[o,i]of n.entries()){if(ie.test(i)&&Qe(i)){r=!0;continue}const a=_n.exec(i);if(!a){i.trim()!==""&&!i.trim().startsWith("#")&&(r=!1);continue}const d=a[1]??"";if(d==="scratch"){r=!1;continue}const c=a[2]?.trim();let u=r?"vis-update-ignore-next-line":void 0;c&&ie.test(c)?u=u??"vis-update-ignore-next-line":c&&Ze.test(c)&&(u=u??"vis-update-ignore");const f=re(d);r=!1,f&&s.push({...f,file:e,ignoreReason:u,kind:"dockerfile",line:o+1})}return s},Pn=/^\s*image:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,qn=(e,t)=>{const n=t.split(/\r?\n/),s=[];let r=!1;for(const[o,i]of n.entries()){if(ie.test(i)&&Qe(i)){r=!0;continue}const a=Pn.exec(i);if(!a){i.trim()!==""&&!i.trim().startsWith("#")&&(r=!1);continue}const d=a[2]??"",c=a[3]?.trim();let u=r?"vis-update-ignore-next-line":void 0;c&&ie.test(c)?u=u??"vis-update-ignore-next-line":c&&Ze.test(c)&&(u=u??"vis-update-ignore");const f=re(d);r=!1,f&&s.push({...f,file:e,ignoreReason:u,kind:"compose",line:o+1})}return s},je=e=>{const t=e.toLowerCase();return t==="dockerfile"||t.startsWith("dockerfile.")?!0:t.endsWith(".dockerfile")},Wn=e=>{const t=e.toLowerCase();return/^(?:docker-)?compose(?:\..+)?\.ya?ml$/.test(t)},Ln=new Set([".cache",".git",".nx",".pnpm-store",".turbo","build","dist","node_modules"]),Hn=/(?:^|\/)(?:\.git|node_modules|\.pnpm-store|\.turbo|\.nx|dist|build|\.cache)(?:\/|$)/,Fn=e=>{const t=[];if(!U(e))return t;const n=new Set,s=(r,o)=>{let i;try{i=Nt.native(r)}catch{i=r}if(n.has(i))return;n.add(i);let a;try{a=K(r)}catch{return}t.push(...o==="dockerfile"?Mn(r,a):qn(r,a))};for(const r of J(e,{includeDirs:!1,includeSymlinks:!1,skip:[Hn]})){const{name:o}=r;Ln.has(o)||(je(o)?s(r.path,"dockerfile"):Wn(o)&&s(r.path,"compose"))}for(const r of["Dockerfile","dockerfile","compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"]){const o=V(e,r);U(o)&&s(o,je(r)?"dockerfile":"compose")}return t},zn=864e5,Ie=(e,t)=>{for(const n of t)try{if(new RegExp(n).test(e))return!0}catch{if(e.includes(n))return!0}return!1},Ne=e=>{const t=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return e.registry==="docker.io"?t:`${e.registry}/${t}`},Gn=e=>e.digest!==void 0&&e.digest.length>0,Kn=e=>{if(e.registry==="docker.io")return`https://hub.docker.com/${e.namespace==="library"?`_/${e.name}`:`r/${e.namespace}/${e.name}`}/tags`;const t=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return`https://${e.registry}/${t}`},Jn=(e,t)=>{const n=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return`${e.registry==="docker.io"?n:`${e.registry}/${n}`}:${t}`},et=async(e,t)=>{const{ignoreRules:n,options:s,references:r,registryOptions:o}=t,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const c=new Dn({fetch:o?.fetch,tokens:o?.tokens}),u=new Map;for(const x of r){const $=`${x.registry}|${x.namespace}|${x.name}`,A=u.get($)??[];A.push(x),u.set($,A)}const f=Math.max(1,s.maxConcurrentRequests),g=[...u.keys()];let m=0;const h=async x=>{const $=u.get(x)??[],A=$[0];if(!A)return;let y;try{y=await c.listTags(A.registry,A.namespace,A.name)}catch{for(const p of $)d.push({file:p.file,reason:`failed to list tags for ${Ne(p)}`});return}for(const p of $){const k=Ne(p);let l;if(p.ignoreReason?l=p.ignoreReason:Ie(k,s.exclude)?l="matched --exclude":s.include.length>0&&!Ie(k,s.include)?l="not matched by --include":s.respectDependabotConfig&&n&&he(k,"docker",n)&&(l="ignored by dependabot/renovate config"),l){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:k,newRef:p.tag,newVersion:void 0,original:p.original,reason:l,replacement:p.original,updateType:"unknown"});continue}if(Gn(p)){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:k,newRef:p.tag,newVersion:void 0,original:p.original,reason:"digest-pinned image (refresh the pin manually to update)",replacement:p.original,updateType:"digest"});continue}const S=H(p.tag);if(!S&&!s.includeBranches){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:k,newRef:p.tag,newVersion:void 0,original:p.original,reason:"non-semver tag (use --include-branches)",replacement:p.original,updateType:"unknown"});continue}if(!S&&s.mode!=="latest"){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:k,newRef:p.tag,newVersion:void 0,original:p.original,reason:`branch ref has no version baseline for --target=${s.mode}`,replacement:p.original,updateType:"unknown"});continue}const w=$e(y.parsed,S,s.mode);if(!w)continue;if(s.minAgeDays!==void 0&&w.lastUpdated!==void 0&&(Date.now()-w.lastUpdated)/zn<s.minAgeDays){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:k,newRef:w.raw,newVersion:w.raw,original:p.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:p.original,updateType:"unknown"});continue}const C=w.raw,E=Jn(p,C);i.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,line:p.line,name:k,newRef:C,newVersion:C,original:p.original,replacement:E,updateType:ye(S,w),url:Kn(p)})}},v=[];for(let x=0;x<Math.min(f,g.length);x++)v.push((async()=>{for(;m<g.length;){const $=g[m];m+=1,$!==void 0&&await h($)}})());return await Promise.all(v),{failed:d,ignored:a,updates:i}};class Yn{token;tokenHeader;defaultApiBase;fetchImpl;tagCache=new Map;constructor(t){const n=t.token??process.env.GITLAB_TOKEN;n?(this.token=n,this.tokenHeader="PRIVATE-TOKEN"):process.env.CI_JOB_TOKEN?(this.token=process.env.CI_JOB_TOKEN,this.tokenHeader="JOB-TOKEN"):(this.token=void 0,this.tokenHeader="PRIVATE-TOKEN"),this.defaultApiBase=t.apiBase??"https://gitlab.com",this.fetchImpl=t.fetch??fetch}async listTags(t){const n=this.tagCache.get(t);if(n)return n;const s=this.fetchTags(t);return this.tagCache.set(t,s),s}resolveHostAndPath(t){const n=t.indexOf("/");if(n>0){const s=t.slice(0,n);if(s.includes("."))return{host:`https://${s}`,path:t.slice(n+1)}}return{host:this.defaultApiBase,path:t}}async fetchTags(t){const{host:n,path:s}=this.resolveHostAndPath(t),r=encodeURIComponent(s),o=`${n}/api/v4/projects/${r}/repository/tags?per_page=100`,i={Accept:"application/json","User-Agent":"vis-update-gitlab"};this.token&&(i[this.tokenHeader]=this.token);try{const a=await this.fetchImpl(o,{headers:i});if(!a.ok)return{error:`HTTP ${String(a.status)} from ${n}`,parsed:[],tags:[]};const d=await a.json();if(!Array.isArray(d))return{error:`unexpected response shape from ${n}`,parsed:[],tags:[]};const c=d.map(f=>({name:typeof f.name=="string"?f.name:"",sha:typeof f.commit?.id=="string"?f.commit.id:""})).filter(f=>f.name!==""),u=[];for(const f of c){const g=H(f.name);g&&u.push({...g,sha:f.sha})}return{parsed:u,tags:c}}catch(a){return{error:a instanceof Error?a.message:"fetch failed",parsed:[],tags:[]}}}}const Xn=/vis-update-ignore-next-line/i,Q=/vis-update-ignore(?:\s|$|:)/i,Zn=new Set([".gitlab-ci.yaml",".gitlab-ci.yml"]),Qn=e=>Zn.has(e)||e.endsWith(".gitlab-ci.yml")||e.endsWith(".gitlab-ci.yaml"),es=/^\s*-?\s*project:\s*(['"]?)([^'"\s#]+)\1(?:\s*#.*)?$/,ts=/^\s*ref:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,ns=/^\s*-?\s*component:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,ss=/^\s*image:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,os=/^\s*(?:-\s*)?(?:include:\s*)?\{([^}]*)\}\s*(?:#.*)?$/,rs=/project:\s*(['"]?)([^'"\s,}]+)\1/,is=/ref:\s*(['"]?)([^'"\s,}]+)\1/,as=/component:\s*(['"]?)([^'"\s,}]+)\1/,cs=/^(\s*-\s*name:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,ls=/^(\s*-\s*)(['"]?)([^'"\s#:]+:[^'"\s#]+)\2(\s*#.*)?$/,us=/^\s*-?\s*[a-z_][\w-]*:\s*(?:#.*)?$/i,ds=(e,t)=>{const n=t.split(/\r?\n/),s=[],r=[];let o,i=!1,a=!1,d=-1;for(const[c,u]of n.entries()){const f=u??"",g=f.trim(),m=g===""||g.startsWith("#");if(Xn.test(f)&&m){i=!0;continue}const h=/^(\s*)services:\s*(?:#.*)?$/.exec(f);if(h){a=!0,d=h[1]?.length??0;continue}a&&g!==""&&!g.startsWith("-")&&!g.startsWith("#")&&f.search(/\S/)<=d&&(a=!1,d=-1);const v=ss.exec(f);if(v){const p=v[2]??"",k=re(p);if(k){const l=v[3]?.trim();let S=i?"vis-update-ignore-next-line":void 0;l&&Q.test(l)&&(S=S??"vis-update-ignore"),r.push({...k,file:e,ignoreReason:S,kind:"compose",line:c+1})}i=!1;continue}if(a){const p=cs.exec(f),k=p?void 0:ls.exec(f),l=p??k;if(l){const S=l[3]??"",w=re(S);if(w){const C=l[4]?.trim();let E=i?"vis-update-ignore-next-line":void 0;C&&Q.test(C)&&(E=E??"vis-update-ignore"),r.push({...w,file:e,ignoreReason:E,kind:"compose",line:c+1})}}}const x=es.exec(f);if(x){o={line:c+1,project:x[2]??""};continue}const $=ts.exec(f);if($&&o){const p=$[3]?.trim();let k=i?"vis-update-ignore-next-line":void 0;p&&Q.test(p)&&(k=k??"vis-update-ignore"),s.push({file:e,ignoreReason:k,kind:"project",line:c+1,original:$[2]??"",project:o.project,ref:$[2]??""}),o=void 0,i=!1;continue}const A=ns.exec(f);if(A){const p=A[2]??"",k=p.lastIndexOf("@");if(k>0){const l=p.slice(0,k),S=p.slice(k+1),w=l.lastIndexOf("/"),C=w>0?l.slice(0,w):l,E=w>0?l.slice(w+1):void 0,b=A[3]?.trim();let T=i?"vis-update-ignore-next-line":void 0;b&&Q.test(b)&&(T=T??"vis-update-ignore"),s.push({componentName:E,file:e,ignoreReason:T,kind:"component",line:c+1,original:p,project:C,ref:S})}i=!1;continue}const y=os.exec(f);if(y){const p=y[1]??"",k=/#(.*)$/.exec(f)?.[1]?.trim();let l=i?"vis-update-ignore-next-line":void 0;k&&Q.test(k)&&(l=l??"vis-update-ignore");const S=as.exec(p);if(S){const w=S[2]??"",C=w.lastIndexOf("@");if(C>0){const E=w.slice(0,C),b=w.slice(C+1),T=E.lastIndexOf("/"),N=T>0?E.slice(0,T):E,_=T>0?E.slice(T+1):void 0;s.push({componentName:_,file:e,ignoreReason:l,kind:"component",line:c+1,original:w,project:N,ref:b})}}else{const w=rs.exec(p),C=is.exec(p);w&&C&&s.push({file:e,ignoreReason:l,kind:"project",line:c+1,original:C[2]??"",project:w[2]??"",ref:C[2]??""})}i=!1;continue}g!==""&&!g.startsWith("#")&&!us.test(f)&&(i=!1)}return{images:r,includes:s}},De=/^(?:\.git|node_modules|\.pnpm-store|\.turbo|\.nx|dist|build|\.cache)$/,ps=e=>{const t=[],n=[];if(!U(e))return{images:n,includes:t};const s=o=>{let i;try{i=K(o)}catch{return}const{images:a,includes:d}=ds(o,i);t.push(...d),n.push(...a)};for(const o of[".gitlab-ci.yml",".gitlab-ci.yaml"]){const i=V(e,o);U(i)&&s(i)}const r=V(e,".gitlab");if(U(r))for(const o of J(r,{includeDirs:!1,includeSymlinks:!1,skip:[De]}))(o.name.endsWith(".yml")||o.name.endsWith(".yaml"))&&s(o.path);for(const o of J(e,{includeDirs:!1,includeSymlinks:!1,maxDepth:2,skip:[De]}))Qn(o.name)&&!n.some(i=>i.file===o.path)&&!t.some(i=>i.file===o.path)&&s(o.path);return{images:n,includes:t}},Oe=(e,t)=>{for(const n of t)try{if(new RegExp(n).test(e))return!0}catch{if(e.includes(n))return!0}return!1},fs=(e,t,n)=>{const s=e.indexOf("/");return s>0&&e.slice(0,s).includes(".")?`https://${e.slice(0,s)}/${e.slice(s+1)}/-/releases/${t}`:`${n}/${e}/-/releases/${t}`},gs=async(e,t)=>{const{ignoreRules:n,imageReferences:s,includes:r,options:o,registryOptions:i,resolverOptions:a}=t,d=[],c=[],u=[];if(s.length>0){const y=await et(e,{ignoreRules:n,options:o,references:s,registryOptions:i});for(const p of y.updates)d.push({...p,ecosystem:"gitlab"});for(const p of y.ignored)c.push({...p,ecosystem:"gitlab"});u.push(...y.failed)}if(r.length===0)return{failed:u,ignored:c,updates:d};const f=new Yn({apiBase:a?.apiBase,fetch:a?.fetch,token:o.gitlabToken??a?.token}),g=a?.apiBase??"https://gitlab.com",m=new Map;for(const y of r){const p=m.get(y.project)??[];p.push(y),m.set(y.project,p)}const h=Math.max(1,o.maxConcurrentRequests),v=[...m.keys()];let x=0;const $=async y=>{const p=m.get(y)??[];let k;try{k=await f.listTags(y)}catch{for(const l of p)u.push({file:l.file,reason:`failed to list tags for ${y}`});return}if(k.error){for(const l of p)u.push({file:l.file,reason:`failed to list tags for ${y}: ${k.error}`});return}for(const l of p){const S=l.kind==="component"&&l.componentName?`${l.project}/${l.componentName}`:l.project;let w;l.ignoreReason?w=l.ignoreReason:Oe(S,o.exclude)?w="matched --exclude":o.include.length>0&&!Oe(S,o.include)?w="not matched by --include":o.respectDependabotConfig&&n&&he(S,"gitlab",n)&&(w="ignored by dependabot/renovate config");const C=N=>({currentRef:l.ref,currentVersion:l.ref,ecosystem:"gitlab",file:l.file,ignored:!0,line:l.line,name:S,newRef:l.ref,newVersion:void 0,original:l.original,reason:N,replacement:l.original,updateType:"unknown"});if(w){c.push(C(w));continue}const E=H(l.ref);if(!E&&!o.includeBranches){c.push(C("branch reference (use --include-branches)"));continue}if(!E&&o.mode!=="latest"){c.push(C(`branch ref has no version baseline for --target=${o.mode}`));continue}const b=$e(k.parsed,E,o.mode);if(!b)continue;let T;l.kind==="component"?T=`${l.componentName?`${l.project}/${l.componentName}`:l.project}@${b.raw}`:T=b.raw,d.push({currentRef:l.ref,currentVersion:E?.raw??l.ref,ecosystem:"gitlab",file:l.file,line:l.line,name:S,newRef:b.raw,newVersion:b.raw,original:l.original,replacement:T,updateType:ye(E,b),url:fs(l.project,b.raw,g)})}},A=[];for(let y=0;y<Math.min(h,v.length);y++)A.push((async()=>{for(;x<v.length;){const p=v[x];x+=1,p!==void 0&&await $(p)}})());return await Promise.all(A),{failed:u,ignored:c,updates:d}},ms={disabled:new Set,exclude:[],githubToken:void 0,gitlabToken:void 0,include:[],includeBranches:!1,maxConcurrentRequests:8,minAgeDays:void 0,mode:"latest",respectDependabotConfig:!0,style:"sha"},hs=async e=>{const t={...ms,...e.options,disabled:e.options?.disabled??new Set},n=t.respectDependabotConfig?ln(e.workspaceRoot):void 0,s={actions:{failed:[],ignored:[],updates:[]},docker:{failed:[],ignored:[],updates:[]},gitlab:{failed:[],ignored:[],updates:[]}},r=[];let o=0;if(!t.disabled.has("actions")){const d=xn(e.workspaceRoot);d.length>0&&(o+=1,r.push(jn(e.workspaceRoot,{ignoreRules:n,options:t,references:d}).then(c=>{s.actions=c})))}if(!t.disabled.has("docker")){const d=Fn(e.workspaceRoot);d.length>0&&(o+=1,r.push(et(e.workspaceRoot,{ignoreRules:n,options:t,references:d}).then(c=>{s.docker=c})))}if(!t.disabled.has("gitlab")){const{images:d,includes:c}=ps(e.workspaceRoot);d.length+c.length>0&&(o+=1,r.push(gs(e.workspaceRoot,{ignoreRules:n,imageReferences:d,includes:c,options:t}).then(u=>{s.gitlab=u})))}await Promise.all(r);const i=[...s.actions.updates,...s.docker.updates,...s.gitlab.updates],a=[...s.actions.ignored,...s.docker.ignored,...s.gitlab.ignored];return{failed:[...s.actions.failed,...s.docker.failed,...s.gitlab.failed],ignored:a,perEcosystem:s,scanned:o,updates:i}},$s={actions:"GitHub Actions",docker:"Docker",gitlab:"GitLab CI"},ge=e=>e.updateType==="major",ys=e=>{switch(e){case"major":return G;case"minor":return O;case"patch":return We;default:return Le}},Ue=e=>{const t=ys(e.updateType),n=e.currentVersion??e.currentRef,s=e.newVersion??e.newRef,r=e.url?` ${P(e.url)}`:"",o=e.advisories&&e.advisories.length>0?` ${G(`⚠ ${String(e.advisories.length)} advisor${e.advisories.length===1?"y":"ies"}`)}`:"";return` ${t(e.updateType.padEnd(7))} ${e.name} ${P(n)} → ${s}${o}${r}`},Be=e=>!e.advisories||e.advisories.length===0?[]:e.advisories.map(t=>` ${t.severity==="CRITICAL"||t.severity==="HIGH"?G(t.severity):O(t.severity)} ${t.id} ${P(t.summary)}`),ks=(e,t)=>{const n=[],s=e.updates.length;if(s===0&&e.scanned===0)return"";if(s===0){if(e.failed.length===0&&e.ignored.length===0)return n.push(`${We("✓")} All ecosystem references up to date.`),n.join(`
|
|
6
|
+
`);if(n.push(`${O("⚠")} No actionable updates found.`),e.failed.length>0){n.push(`
|
|
7
|
+
${O("Failed lookups:")}`);for(const o of e.failed)n.push(` ${o.file}: ${o.reason}`)}if(t.showIgnored&&e.ignored.length>0){n.push(`
|
|
8
|
+
${P("Ignored:")}`);for(const o of e.ignored)n.push(` ${P(o.name)} ${P(o.reason??"")}`)}return n.join(`
|
|
9
|
+
`)}n.push(`
|
|
10
|
+
${Le("Ecosystem updates")} — ${String(s)} reference${s===1?"":"s"} can be bumped:`);const r=e.updates.filter(o=>ge(o));if(r.length>0){n.push(`
|
|
11
|
+
${G(ut(`⚠ Breaking changes (${String(r.length)})`))}`),n.push(` ${P("Review release notes before applying — these cross a major-version boundary.")}`);for(const o of r)n.push(Ue(o)),n.push(...Be(o))}for(const o of Object.keys(e.perEcosystem)){const i=e.perEcosystem[o];if(i.updates.length!==0){n.push(`
|
|
12
|
+
${$s[o]} (${String(i.updates.length)})`);for(const a of i.updates)n.push(Ue(a)),n.push(...Be(a))}}if(t.showIgnored&&e.ignored.length>0){n.push(`
|
|
13
|
+
${P("Ignored:")}`);for(const o of e.ignored)n.push(` ${P(o.name)} ${P(o.reason??"")}`)}if(e.failed.length>0){n.push(`
|
|
14
|
+
${O("Failed lookups:")}`);for(const o of e.failed)n.push(` ${o.file}: ${o.reason}`)}return t.previewOnly&&n.push(`
|
|
15
|
+
${O("ℹ")} ${P("Not applied automatically — re-run with `--interactive` to choose which to apply, or `--yes` to apply all.")}`),n.join(`
|
|
16
|
+
`)},ws=e=>JSON.stringify({ecosystems:{failed:e.failed,ignored:e.ignored,perEcosystem:e.perEcosystem,scanned:e.scanned,updates:e.updates}},void 0,2),vs=()=>{const e=qe({input:process.stdin,output:process.stdout});return{ask:t=>new Promise(n=>{e.question(t,s=>{n(s.trim())})}),close:()=>{e.close()},write:t=>{process.stdout.write(`${t}
|
|
17
|
+
`)}}},bs=(e,t)=>e.split(",").map(n=>Number.parseInt(n.trim(),10)-1).filter(n=>Number.isInteger(n)&&n>=0&&n<t),Rs=async(e,t=vs())=>{if(e.length===0)return t.close(),[];t.write(""),t.write("Outdated ecosystem references:");for(const[s,r]of e.entries()){const o=r.currentVersion??r.currentRef,i=r.newVersion??r.newRef,a=ge(r)?" [BREAKING]":"";t.write(` ${String(s+1)}. [${r.ecosystem}] ${r.name}: ${o} → ${i} (${r.updateType})${a}`)}t.write("");const n=(await t.ask("Apply updates? [a]ll / [s]afe / [n]one / numbers: ")).toLowerCase();if(n==="a"||n==="all")return t.close(),e;if(n==="s"||n==="safe")return t.close(),e.filter(s=>!ge(s));if(n==="n"||n==="none"||n==="")return t.close(),[];if(/^[\d ,]+$/.test(n)){const s=bs(n,e.length);return t.close(),s.map(r=>e[r]).filter(r=>r!==void 0)}return t.close(),[]},tt=e=>{const t=e.trim();if(t==="")return;const n=/^(\d+(?:\.\d+)?)\s*([mhdw])?$/i.exec(t);if(!n)return;const s=Number.parseFloat(n[1]);if(!(!Number.isFinite(s)||s<0))switch((n[2]??"m").toLowerCase()){case"d":return s*60*24;case"h":return s*60;case"m":return s;case"w":return s*60*24*7;default:return}},xs=e=>{const t=e.trim();return/^\d+(?:\.\d+)?$/.test(t)?Number.parseFloat(t)*1440:tt(t)},Xs=e=>!Number.isFinite(e)||e<=0?"0m":e%1440===0?`${String(e/1440)}d`:e%60===0?`${String(e/60)}h`:`${String(e)}m`,ke=(e,t)=>{try{switch(t){case"bun":{const n=V(e,"bunfig.toml");if(U(n)){const s=yt(n),r=s?.install?.minimumReleaseAge;return{excludes:Array.isArray(s?.install?.minimumReleaseAgeExcludes)?s.install.minimumReleaseAgeExcludes:void 0,minutes:typeof r=="number"?Math.round(r/60):void 0}}break}case"npm":{const n=V(e,".npmrc");if(U(n)){const s=K(n),r=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(s);return{minutes:r?xs(r[1]):void 0}}break}case"pnpm":{const n=V(e,"pnpm-workspace.yaml");if(U(n)){const s=Re(n);return{excludes:Array.isArray(s?.minimumReleaseAgeExclude)?s.minimumReleaseAgeExclude:void 0,minutes:typeof s?.minimumReleaseAge=="number"?s.minimumReleaseAge:void 0}}break}case"yarn":{const n=V(e,".yarnrc.yml");if(U(n)){const s=Re(n),r=s?.npmMinimalAgeGate,o=Array.isArray(s?.npmPreapprovedPackages)?s.npmPreapprovedPackages:void 0;if(typeof r=="string")return{excludes:o,minutes:tt(r)};if(typeof r=="number")return{excludes:o,minutes:r}}break}}}catch{}return{}},As={bun:"minimumReleaseAgeExcludes",pnpm:"minimumReleaseAgeExclude",yarn:"npmPreapprovedPackages"},nt={bun:"bunfig.toml minimumReleaseAgeExcludes",npm:".npmrc",pnpm:"pnpm-workspace.yaml minimumReleaseAgeExclude",yarn:".yarnrc.yml npmPreapprovedPackages"},st=(e,t,n)=>{const s=ke(t,e);if(typeof s.minutes!="number"||s.minutes<=0)return{added:[],unsupported:!1};if(!(e in As))return{added:[],unsupported:!0};const r=s.excludes??[],o=[...new Set(n)].filter(i=>!r.includes(i));return o.length===0?{added:[],unsupported:!1}:(Wt(e,t,s.minutes,[...r,...o]),{added:o,unsupported:!1})},ot=(e,t,n)=>{n.added.length>0?e.info(`Added ${String(n.added.length)} package${n.added.length===1?"":"s"} to ${nt[t]??"the package manager config"} so --ignore-release-age versions install: ${n.added.join(", ")}`):n.unsupported&&e.warn(`${O("⚠")} npm has no per-package release-age exclude list, so vis can't exempt just the selected packages. Lower min-release-age in .npmrc or pass --min-release-age=0 to the install.`)},Ss=(e,t,n)=>{const s=e.latest?"latest":e.target??t.target??"latest";if(!["latest","minor","patch"].includes(s))throw new Error(`Invalid target "${s}". Use: latest, minor, or patch.`);const r=e.maxConcurrentRequests,o=typeof r=="number"&&r>0?r:t.maxConcurrentRequests,i=typeof e.releaseChannel=="string"?e.releaseChannel.toLowerCase():void 0;if(i!==void 0&&!["any","same","stable"].includes(i))throw new Error(`Invalid --release-channel "${String(e.releaseChannel)}". Use: any, same, or stable.`);const a=i??t.releaseChannel;return{exclude:[...q(e.exclude),...q(t.exclude)],ignore:q(t.ignore),include:[...q(e.include),...q(t.include),...n],includeLocked:e.includeLocked||t.includeLocked||!1,includePrerelease:e.prerelease||t.prerelease||!1,maxConcurrentRequests:o,minimumReleaseAge:t.minimumReleaseAge,minimumReleaseAgeExclude:t.minimumReleaseAgeExclude,packageMode:t.packageMode,releaseChannel:a,security:e.security===!1?!1:e.ai||(t.security??!0),target:s}},Ve=(e,t)=>{if(e.length!==0){t.info(`
|
|
18
|
+
${O("⚠")} ${String(e.length)} package${e.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const n of e)t.info(` ${n.packageName} ${n.currentRange} → ${n.newRange} (${n.updateType})`)}},_e=(e,t,n,s,r)=>{n==="json"?process.stdout.write(`${Ct({checkedCount:0,failed:t,filteredByTarget:[],ignored:[],outdated:e})}
|
|
19
|
+
`):n==="minimal"?process.stdout.write(`${Et(e)}
|
|
20
|
+
`):(Tt(e,s),s.info(Fe(e,r)))},Me=async(e,t,n,s,r,o,i)=>{const a=St(e,n,t,!0,{useEditorconfig:i}),d=t==="pnpm"?"pnpm-workspace.yaml":"package.json";if(r.info(`
|
|
21
|
+
Updated ${d}`),a&&r.info(`Backup saved to ${a}`),s.changelog){r.info(`
|
|
22
|
+
Fetching changelogs...`);const c=await He(n,void 0,o);for(const u of c){const f=u.releaseUrl??u.repoUrl??u.npmUrl;r.info(` ${u.packageName}: ${f}`)}}if(s["ignore-release-age"]===!0&&n.length>0&&ot(r,t,st(t,e,n.map(c=>c.packageName))),s.install??!0){const c=t,u=["install"];r.info(`Running ${c} ${u.join(" ")}...
|
|
23
|
+
`);try{const{code:f,output:g}=await ze(c,u,{cwd:e,env:process.env});f!==0?r.warn(`${c} ${u.join(" ")} failed. You may need to run it manually.`):s.peer!==!0&&Ge(g)&&r.info(Ke)}catch{r.warn(`${c} ${u.join(" ")} failed. You may need to run it manually.`)}}},me={applied:!1,canceled:!1,jsonEmitted:!1},Cs=async(e,t,n,s,r,o)=>{const i=n.update??{},a=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[R,j]of a)s[R]&&o.warn(`${O("⚠")} ${j}, ignoring.`);const d=s["ignore-release-age"]===!0,c=de("minReleaseAge")||d,{excludes:u,minutes:f}=c?{excludes:void 0,minutes:void 0}:ke(e,t),g=c?void 0:i.minimumReleaseAge??f,m=c?void 0:i.minimumReleaseAgeExclude??u;if(d?o.info(`${O("⚠")} --ignore-release-age: selecting the latest versions regardless of minimumReleaseAge.`):c&&(i.minimumReleaseAge!==void 0||f!==void 0)&&o.info("minimumReleaseAge gate disabled via MARSHALL_DISABLE_MIN_RELEASE_AGE."),!c&&i.minimumReleaseAge!==void 0&&f!==void 0&&i.minimumReleaseAge!==f){const R=t==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";o.warn(`${O("⚠")} minimumReleaseAge mismatch: vis config = ${String(i.minimumReleaseAge)} min, ${R} = ${String(f)} min. Consider keeping them in sync.`)}const h=kt(e),v=s["include-internal"],x=s.peer,$=wt(e,t,{depFields:i.depFields,dev:s.dev,includeInternal:v,peer:x,prod:s.prod});if($.size===0)return o.info("No catalogs found."),me;const A={...i,minimumReleaseAge:g,minimumReleaseAgeExclude:m},y=Ss(s,A,r);let p=0;for(const R of $.values())p+=R.size;const k=!!process.stdout.isTTY&&!ae;let l;const S=k?(R,j)=>{l?l.rerender(M.createElement(Se,{current:R,total:j})):(process.stdout.write(`
|
|
24
|
+
`),l=xe(M.createElement(Se,{current:R,total:j}),{interactive:!0,patchConsole:!1}))}:(R,j)=>{o.info(`Checking ${String(R)}/${String(j)} dependencies...`)};k||o.info(`Checking ${String(p)} catalog dependencies...
|
|
25
|
+
`);const w=new Set;de("socket")&&w.add("socket"),de("depsDev")&&w.add("deps-dev");const C=n.security?.policies?.score?.minimum,E=vt(n.security,{disabled:w,minimumScore:C}),{checkedCount:b,failed:T,filteredByTarget:N,ignored:_,outdated:D}=await bt($,y,h,S,e,E,n.security?.acceptedRisks);l&&(l.clear(),l.unmount());const te=v?{ignored:[],outdated:[]}:Rt(e,{depFields:i.depFields,dev:s.dev,exclude:y.exclude,ignore:y.ignore,include:y.include,packageMode:y.packageMode,peer:x,prod:s.prod,target:y.target});if(te.outdated.length>0){const R=new Set(D.map(j=>`${j.catalogName}|${j.packageName}`));for(const j of te.outdated)R.has(`${j.catalogName}|${j.packageName}`)||D.push(j)}if(te.ignored.length>0)for(const R of te.ignored)_.includes(R)||_.push(R);const we=b-D.length-T.length;if(T.length>0&&o.warn(`Failed to fetch: ${T.join(", ")}`),_.length>0&&o.info(`Skipped ${String(_.length)} ignored package${_.length===1?"":"s"}: ${_.join(", ")}`),!k&&b>D.length){const R=[...$.values()].reduce((X,ce)=>X+ce.size,0),j=R>b?` (${String(R)} catalog entries, ${String(R-b)} duplicates)`:"";o.info(`Checked ${String(b)} unique packages${j}: ${String(D.length)} outdated, ${String(we)} up-to-date${T.length>0?`, ${String(T.length)} failed`:""}${N.length>0?`, ${String(N.length)} skipped by target`:""}`)}if(D.length===0)return N.length>0?o.info(`All catalog dependencies are up to date within the current target.
|
|
26
|
+
${String(N.length)} package${N.length===1?" has":"s have"} newer versions available with --target latest:
|
|
27
|
+
${N.map(R=>` ${R.packageName} ${R.currentRange} → ${R.newRange} (${R.updateType})`).join(`
|
|
28
|
+
`)}`):o.info("All catalog dependencies are up to date."),me;const F=s.format??i.format??"table";let W;if(s.ai){const R=Dt(s.aiType??"impact");W=await Ot(D,o,n.ai,R)}const ne=!!s.dryRun;if(!ne&&r.length>0&&s.marshallCheck!==!1){const R=await Mt(r);if(R.length>0){const j=await Pt(R,{config:n?.security?.marshalls,workspaceRoot:e});if(!await qt(j))return process.exitCode=1,{applied:!1,canceled:!0,jsonEmitted:!1}}}if(k&&F==="table"){const R=new Ft(D,W??null);let j;if(s.changelog){o.info("Fetching changelogs...");const I=await He(D,void 0,h);j=new Map;for(const B of I){const z=B.releaseUrl??B.repoUrl??B.npmUrl;z&&j.set(B.packageName,z)}}const X=n.tui?.autoExit??!1,ce=X===!0?3:typeof X=="number"?X:0,ve=await xe(M.createElement(zt,{autoExitSeconds:ce,changelogUrls:j,checkedCount:b,filteredOutEntries:N,isDryRun:ne,store:R,totalCatalogEntries:p}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),le=process.stdout.columns||80;process.stdout.write(`
|
|
29
|
+
`);for(const I of D){const B=I.vulnerabilities?.length||I.socketReport&&I.socketReport.alerts.length>0,z=!!I.acceptedRisk,ue=B?z?"✓":"⚠":"✓",it=z?"gray":I.updateType==="major"?"red":I.updateType==="minor"?"yellow":"green",oe=I.socketReport?.score.overall,at=oe===void 0?"":` [${String(Math.round(oe*100))}%]`,be=oe===void 0?void 0:At(oe);process.stdout.write(`${pe(M.createElement(L,null," ",M.createElement(L,{color:it},ue),` ${I.packageName} ${I.currentRange} → ${I.newRange}`,M.createElement(L,{dimColor:!0},` ${I.updateType}`),be?M.createElement(L,{color:be},at):null),{columns:le})}
|
|
30
|
+
`)}if(process.stdout.write(`
|
|
31
|
+
`),o.info(Fe(D,C)),b>D.length){const I=[...$.values()].reduce((z,ue)=>z+ue.size,0),B=I>b?` (${String(I)} catalog entries, ${String(I-b)} duplicates)`:"";o.log(),o.info(`Checked ${String(b)} unique packages${B}: ${String(we)} up-to-date${T.length>0?`, ${String(T.length)} failed`:""}`)}if(N.length>0){process.stdout.write(`
|
|
32
|
+
`);const I=`${String(N.length)} package${N.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${pe(M.createElement(L,{color:"yellow"},` ${I}`),{columns:le})}
|
|
33
|
+
`);for(const B of N)process.stdout.write(`${pe(M.createElement(L,null," ",M.createElement(L,{dimColor:!0},B.packageName),` ${B.currentRange} → ${B.newRange}`,M.createElement(L,{dimColor:!0},` ${B.updateType}`)),{columns:le})}
|
|
34
|
+
`)}const se=Array.isArray(ve)?ve:[];if(se.length>0&&!ne){o.info(`
|
|
35
|
+
Applying ${String(se.length)} updates...
|
|
36
|
+
`);const I={...s,install:s.install??i.install};return await Me(e,t,se,I,o,h,n.editorconfig??!0),{applied:!0,canceled:!1,jsonEmitted:!1}}return{applied:!1,canceled:se.length===0,jsonEmitted:!1}}if(ne){if(F==="json"){const R={failed:T,filteredByTarget:N,ignored:_,outdated:D};W&&(R.aiAnalysis=W),process.stdout.write(`${JSON.stringify(R,void 0,2)}
|
|
37
|
+
`)}else o.info(`Would update ${String(D.length)} dependencies:
|
|
38
|
+
`),_e(D,T,F,o,C),W&&(o.info(""),o.info(Ae(W))),Ve(N,o);return{applied:!1,canceled:!1,jsonEmitted:F==="json"}}W&&F!=="json"&&(o.info(Ae(W)),o.info(""));let Y=D;if(s.interactive&&(Y=await xt(D),Y.length===0))return o.info("No updates selected."),{applied:!1,canceled:!0,jsonEmitted:!1};o.info(`Updating ${String(Y.length)} catalog dependencies...
|
|
39
|
+
`),_e(Y,[],F,o,C),Ve(N,o);const rt={...s,install:s.install??i.install};return await Me(e,t,Y,rt,o,h),{applied:!0,canceled:!1,jsonEmitted:F==="json"}},Es=async(e,t,n,s,r,o)=>{if(s["ignore-release-age"]===!0){const u=ke(e,t),f=typeof u.minutes=="number"&&u.minutes>0;if(f&&r.length>0){const g=r.map(m=>Je(m).name);ot(o,t,st(t,e,g))}else f&&o.warn(`${O("⚠")} --ignore-release-age without package names can't pre-exempt packages in pm-wrapper mode (vis doesn't know which will change). Pass explicit package names, use catalog mode, or lower the gate in ${nt[t]??"your package manager config"}.`)}const i={dev:s.dev,filters:q(s.filter),global:s.global,interactive:s.interactive,latest:s.latest||s.target==="latest",noOptional:s.optional===!1,noSave:s.save===!1,packages:r,prod:s.prod,recursive:s.recursive,workspaceRoot:s.workspaceRoot},{command:a,warnings:d}=tn(t,n,i);for(const u of d)o.warn(u);const c=`${a.bin} ${a.args.join(" ")}`.trim();if(s.dryRun)return o.info(`Would run: ${c}`),me;o.info(`Running: ${c}`);try{const{code:u,output:f}=await ze(a.bin,a.args,{cwd:e,env:process.env});if(u!==0)return o.error(`
|
|
40
|
+
${G("✖")} Update failed (exit code ${String(u)})`),o.error(` Command: ${c}`),o.error(` Directory: ${e}
|
|
41
|
+
`),process.exitCode=u,{applied:!1,canceled:!1,jsonEmitted:!1};s.peer!==!0&&Ge(f)&&o.info(Ke)}catch(u){const f=u.status??1;return o.error(`
|
|
42
|
+
${G("✖")} Update failed (exit code ${String(f)})`),o.error(` Command: ${c}`),o.error(` Directory: ${e}
|
|
43
|
+
`),process.exitCode=f,{applied:!1,canceled:!1,jsonEmitted:!1}}return{applied:!0,canceled:!1,jsonEmitted:!1}},Ts=async(e,t,n)=>{const s=e.latest===!0||e.target==="latest";if(t||!s||e.dryRun===!0||e.yes===!0||e.interactive===!0)return!0;if(!(process.stdout.isTTY&&!ae))return n.error(`${G("✖")} Refusing to run blanket --latest update in a non-interactive context.`),n.error(" Re-run with --yes to confirm, --dry-run to preview, or pass explicit package names."),process.exitCode=1,!1;const r=qe({input:process.stdin,output:process.stdout});try{const o=(await new Promise(i=>{r.question(`${O("⚠")} About to upgrade ALL dependencies to their latest versions. This may include breaking changes.
|
|
44
|
+
Continue? [y/N] `,i)})).trim().toLowerCase();return o==="y"||o==="yes"?!0:(n.info("Aborted."),!1)}finally{r.close()}},js=(e,t)=>{const n=new Set;e.actions===!1&&n.add("actions"),e.docker===!1&&n.add("docker"),e.gitlab===!1&&n.add("gitlab");const s=e.style??"sha";if(s!=="sha"&&s!=="preserve")throw new Error(`Invalid --style "${s}". Use: sha or preserve.`);const r=e.latest===!0?"latest":e.target??"latest";if(r!=="latest"&&r!=="minor"&&r!=="patch")throw new Error(`Invalid target "${r}". Use: latest, minor, or patch.`);const o=r,i=t.update??{};return{disabled:n,exclude:[...q(e.exclude),...q(i.exclude)],githubToken:e.actionsToken??void 0,gitlabToken:e.gitlabToken??void 0,include:q(e.include),includeBranches:e.includeBranches===!0,maxConcurrentRequests:typeof e.maxConcurrentRequests=="number"&&e.maxConcurrentRequests>0?e.maxConcurrentRequests:8,minAgeDays:typeof i.minimumReleaseAge=="number"&&i.minimumReleaseAge>0?i.minimumReleaseAge/1440:void 0,mode:o,respectDependabotConfig:!0,style:s}},Is=(e,t)=>e.dryRun===!0||process.exitCode!==void 0&&process.exitCode!==0||t.canceled?!1:e.yes===!0?!0:e.interactive===!0&&!!process.stdout.isTTY&&!ae,Ns=async(e,t,n,s,r)=>{const o=js(t,n);if(o.disabled.size===3)return;let i;try{i=await hs({options:o,workspaceRoot:e})}catch(m){s.warn(`${O("⚠")} Ecosystem update scan failed: ${m.message}`);return}if(i.scanned===0)return i;const a=t.format??"table",d=!!t.dryRun,c=Is(t,r);if(a==="json")r.jsonEmitted?s.warn(`${O("⚠")} ${String(i.updates.length)} ecosystem update${i.updates.length===1?"":"s"} available but not emitted in --format=json (catalog already wrote one JSON document). Rerun with --format=table or --no-catalog to see them.`):process.stdout.write(`${ws(i)}
|
|
45
|
+
`);else if(a!=="minimal"){const m=ks(i,{previewOnly:!c&&!d,showIgnored:t.interactive===!0});m&&s.info(m)}if(i.updates.length===0)return i;if(d)return a==="minimal"&&s.info(`
|
|
46
|
+
${O("ℹ")} ${String(i.updates.length)} ecosystem reference${i.updates.length===1?"":"s"} can be bumped — not applied (--dry-run). Re-run without --dry-run and with \`--interactive\` or \`--yes\` to apply.`),i;if(!c)return a==="minimal"&&s.info(`
|
|
47
|
+
${O("ℹ")} ${String(i.updates.length)} ecosystem reference${i.updates.length===1?"":"s"} can be bumped — not applied automatically. Re-run with \`--interactive\` to choose, or \`--yes\` to apply all (or \`--no-actions\` / \`--no-docker\` / \`--no-gitlab\` to silence by ecosystem).`),i;let u=i.updates;if(t.interactive===!0&&process.stdout.isTTY&&!ae&&(u=await Rs(i.updates),u.length===0))return s.info(`${O("ℹ")} No ecosystem updates selected.`),i;const{applied:f,skipped:g}=Nn(u);if(f.length>0&&s.info(`
|
|
48
|
+
${String(f.length)} ecosystem reference${f.length===1?"":"s"} updated.`),g.length>0){s.warn(`${O("⚠")} ${String(g.length)} ecosystem update${g.length===1?"":"s"} skipped:`);for(const m of g)s.warn(` ${m.update.name} (${m.update.file}:${String(m.update.line)}): ${m.reason}`)}return i},Ds=e=>{const t=e.style;if(t!==void 0&&t!=="sha"&&t!=="preserve")throw new Error(`Invalid --style "${t}". Use: sha or preserve.`);const n=e.target;if(n!==void 0&&n!=="latest"&&n!=="minor"&&n!=="patch")throw new Error(`Invalid --target "${n}". Use: latest, minor, or patch.`)},Zs=async({argument:e,logger:t,options:n,visConfig:s,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");Ds(n);let o=e;const i=r,{packageManager:a}=ft(i);if(n.typosquatCheck!==!1){if(o.length>0){const u=o.map(m=>Je(m)),f=s?.security?.typosquatAllowlist,g=await Lt(u.map(m=>m.name),f);if(!g.ok){process.exitCode=1;return}o=u.map((m,h)=>{const v=g.packages[h];return v!==m.name?m.versionSpec?`${v}@${m.versionSpec}`:v??"":o[h]??""})}else if(!await Ht(i,s?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!gt(i,a)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(mt(i,a))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(!await Ts(n,o.length>0,t))return;const d=n.catalog!==!1&&ht(i,a);let c;if(d)c=await Cs(i,a,s??{},n,o,t);else{const u=Bt(i,{backend:Vt(_t({logger:t,options:n,visConfig:s},i)),configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),f=u.name==="aube"?"":$t(u.name);c=await Es(i,u.name,f,n,o,t)}o.length===0&&await Ns(i,n,s??{},t,c)};export{st as addReleaseAgeExcludesForInstall,Zs as default,Xs as formatMinutesAsTimeString,xs as parseNpmReleaseAgeValue,tt as parseTimeStringToMinutes,ke as readPmNativeMinimumReleaseAge,Ts as requireBlanketUpdateConfirmation,Ns as runEcosystemUpdate,Is as shouldApplyEcosystem};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import{createRequire as mt}from"node:module";import{y as b,J as it,B as yt,A as at,m as O,f as B,k as kt}from"../packem_shared/index-BDmTbWX1.js";import{$ as vt,a4 as w,a5 as C,m as x,t as Tt,W as St}from"./bin.js";import ot from"./index.js";import{x as ct}from"tinyexec";import{o as It}from"../packem_shared/spinner-CV3WVJLv.js";import{C as dt,D as _,T as lt}from"../packem_shared/symbols-DPTlrJ3B.js";import{s as V,E as $,q as P,V as G,I as Et}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{withEnhancedPath as Mt}from"@visulima/task-runner";const wt=mt(import.meta.url),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,H=t=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[e,s]=A.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return A.getBuiltinModule(t)}return wt(t)},{readFileSync:xt,writeFileSync:bt,unlinkSync:$t}=H("node:fs"),{randomBytes:Ct}=H("node:crypto"),{availableParallelism:z}=H("node:os");class E extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class At extends E{}class v extends E{}class W extends E{}class R extends E{stderr;constructor(e,s,r){super(e,r),this.stderr=s}}class K extends E{}class I extends E{commandTitle;constructor(e,s,r){super(s,r),this.commandTitle=e}}const ut=t=>t.includes("/"),D=(t,e)=>e?t.toLowerCase():t,jt=(t,e,s,r={})=>{const n=ut(t),a=r.caseInsensitive===!0,c=D(t,a),i=[];for(const o of e){const l=n?b(s,o):it(o);ot(c,D(l,a))&&i.push(o)}return i},Rt=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(a=>{for(const c of e){const i=ut(c)?b(s,a):it(a),o=D(c,n);if(ot(o,D(i,n)))return!1}return!0})},L=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",N=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Nt=(t,e)=>{const s=b(t,e);return s===""||!s.startsWith("..")&&!at(s)},Ot=(t,e)=>{let s;for(const r of e)Nt(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},_t=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),a=(o,l,h,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],p=new Map;for(const f of h){const g=Ot(f,u)??t.cwd,y=p.get(g)??[];y.push(b(g,f)),p.set(g,y)}for(const f of[...p.keys()].sort()){const g=b(t.cwd,f)||".";d.push({command:o.command,cwd:f,files:p.get(f)??[],id:n(),source:"string",title:`${o.command} — ${g}`})}return}if(o.cwd!==void 0){const u=yt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:h,id:n(),source:"string",title:`${o.command} — ${b(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:n(),source:"string",title:o.command})},c=async(o,l,h,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:n(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,h,d);return}if(N(o)){a(o,l,h,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const p of u)if(typeof p=="string")d.push({command:p,files:l,id:n(),source:"function",title:p});else if(N(p))a(p,l,h,d);else if(L(p))d.push({files:l,id:n(),run:p.task,source:"custom",title:p.title});else throw new v("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(N(u)){a(u,l,h,d);return}if(L(u)){d.push({files:l,id:n(),run:u.task,source:"custom",title:u.title});return}throw new v("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(L(o)){d.push({files:l,id:n(),run:o.task,source:"custom",title:o.title});return}throw new v("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},i=[];for(const[o,l]of Object.entries(t.config)){const h=jt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(h.length===0)continue;const d=t.relative?h.map(p=>b(t.cwd,p)):h,u=[];await c(l,d,h,u),u.length!==0&&i.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${h.length} file${h.length===1?"":"s"}`})}return i},Dt=async t=>{if(t.config!==void 0)return t.config;throw new v(`No staged config provided. Add \`staged\` to your vis.config.ts:
|
|
2
|
+
|
|
3
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
staged: { "*.ts": "eslint --fix" },
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},Y=t=>{if(typeof t!="object"||t===null)throw new v("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new v("Staged config is empty — at least one glob pattern is required.");for(const[s,r]of e){if(!s||s.trim()==="")throw new v("Staged config keys must be non-empty glob patterns.");ht(s,r)}return t},ht=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new v(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new v(`Task array for "${t}" is empty.`);for(const s of e)ht(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new v(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(N(e)){if(e.command.trim()==="")throw new v(`Command task for "${t}" has an empty \`command\`.`);return}if(!Ft(e))throw new v(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Ft=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",J=2048,m=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ct("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const{stderr:a}=r,c=a.length>J?`${a.slice(0,J)}…`:a;throw new R(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,a)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},M=async(t,e)=>{const{stdout:s}=await m(t,e);return s.trim()},Pt=async t=>{const e=await m(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Gt=async t=>M(["rev-parse","--absolute-git-dir"],{cwd:t}),ft=async t=>M(["rev-parse","--show-toplevel"],{cwd:t}),Q=async t=>M(["write-tree"],{cwd:t}),Lt=async t=>{const e=await m(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},j={major:2,minor:32},Ht=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),r=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(r)?null:{major:s,minor:r}},qt=async t=>{const e=Ht(await M(["--version"],{cwd:t}));if(e!==null&&(e.major<j.major||e.major===j.major&&e.minor<j.minor))throw new R(`Git ${j.major}.${j.minor} or newer is required; found ${e.major}.${e.minor}.`)},Ut="ACMR",X=500,Bt=async t=>{const{stdout:e}=await m(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(n=>n.length>0),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(!a?.startsWith(":"))continue;const c=a.slice(1).split(" "),i=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&i!==void 0&&/^0+$/.test(i)&&l!==void 0&&r.push(l)}return r},Z=async t=>{const{stdout:e}=await m(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},Vt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},zt=async t=>{const e=t.diffFilter??Ut,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:r}=await m(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const a=t.workTree??await ft(t.cwd);return n.map(c=>at(c)?c:O(a,c))},Wt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let a=0;a<t.length;a+=X){const c=t.slice(a,a+X),{stdout:i}=await m(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});i.length>0&&s.push(i)}if(s.length===0)return null;const r=s.join(""),n=r.endsWith(`
|
|
10
|
+
`)?r:`${r}
|
|
11
|
+
`;return Buffer.from(n,"utf8")},Kt=async t=>{const{stdout:e}=await m(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(a===void 0||a.length<4)continue;const c=a.charAt(0),i=a.charAt(1),o=a.slice(3),l=c==="R"||c==="C"||i==="R"||i==="C";c!==" "&&c!=="?"&&i!==" "&&i!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await m(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await m(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Qt="vis_staged_automatic_backup",pt=()=>`${Qt}-${process.pid}-${Date.now()}-${Ct(3).toString("hex")}`,Xt=async t=>{const e=await M(["stash","create"],{cwd:t});return e.length===0?null:(await m(["stash","store","-m",pt(),e],{cwd:t}),e)},Zt=async t=>{const e=pt(),{exitCode:s,stdout:r}=await m(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const n=r.trim();return n.length>0&&/no local changes/i.test(n)?null:M(["rev-parse","stash@{0}"],{cwd:t})},q=async(t,e)=>{const{exitCode:s,stdout:r}=await m(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[a,c]=n.split(/\s+/,2);if(a===e&&c!==void 0)return c}return null},tt=async(t,e)=>{if(e===null)return;const s=await q(t,e);s!==null&&await m(["stash","drop","--quiet",s],{cwd:t})},te=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");const s=await q(t,e);if(s===null)throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await m(["reset","--hard","HEAD"],{cwd:t}),await m(["stash","apply","--index","--quiet",s],{cwd:t})},ee=async(t,e)=>{if(e===null)return;const s=await q(t,e);s!==null&&await m(["stash","pop","--quiet",s],{cwd:t})};class se{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Pt(this.cwd))throw new R(`Not a git repository: ${this.cwd}`);await qt(this.cwd),this.workTree=await ft(this.cwd),this.gitDir=await Gt(this.cwd),this.stagedFiles=await zt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Kt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await Bt(this.workTree),this.intentToAddPaths.length>0&&await Vt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Xt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await Zt(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await Q(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await Lt(this.workTree),this.preTaskUntracked=new Set(await Z(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(r=>b(this.workTree,r));if(await Jt(s,{cwd:this.workTree}),e){const r=(await Z(this.workTree)).filter(n=>!this.preTaskUntracked.has(n));if(r.length>0){const n=`${r.join("\0")}\0`;await m(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:n})}}if(this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await Q(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let s;try{await m(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof R?r.stderr:String(r)}try{await m([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof R&&r.stderr?r.stderr:String(r);throw new K(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
|
|
12
|
+
First attempt: ${s??"(no stderr)"}
|
|
13
|
+
Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await te(this.workTree,this.backupStashSha)}catch(e){throw new K("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await ee(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(r=>b(this.workTree,r))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(r=>e.has(r)):[];s.length!==0&&(this.patch=await Wt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=O(this.gitDir,e);return B(s)?{body:xt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=O(this.gitDir,e.name);try{e.existed&&e.body!==null?bt(s,e.body):B(s)&&$t(s)}catch{}}}}const re=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},et=t=>{if(t==="running")return w.jsx(It,{type:"dots"});const e=t==="failed"?dt:t==="skipped"?_:t==="success"?lt:_;return w.jsx(x,{color:re(t),children:e})},st=({state:t,tick:e,verbose:s})=>w.jsxs(C,{flexDirection:"column",children:[[...t.patterns.values()].map(r=>w.jsxs(C,{flexDirection:"column",children:[w.jsxs(C,{children:[et(r.status),w.jsxs(x,{children:[" ",r.title]})]}),[...r.commands.values()].map(n=>w.jsxs(C,{flexDirection:"column",marginLeft:2,children:[w.jsxs(C,{children:[et(n.status),w.jsxs(x,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?w.jsxs(x,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),s&&n.output?w.jsx(C,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((a,c)=>w.jsx(x,{color:"gray",children:a},`${n.id}-line-${c}`))}):null,n.status==="failed"&&n.error?w.jsx(C,{marginLeft:2,children:w.jsx(x,{color:"red",children:n.error.message})}):null]},n.id))]},r.id)),t.infoMessages.map((r,n)=>w.jsx(x,{color:"gray",children:r},`info-${n}`)),t.warnMessages.map((r,n)=>w.jsx(x,{color:"yellow",children:r},`warn-${n}`)),t.errorMessages.map(({message:r},n)=>w.jsx(x,{color:"red",children:r},`err-${n}`))]}),ne=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=vt(w.jsx(st,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),a=()=>{r+=1,n.rerender(w.jsx(st,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:i,error:o,output:l,patternId:h,status:d}){const u=s.patterns.get(h)?.commands.get(c);u&&(u.status=d,u.durationMs=i,u.output=l,u.error=o,a())},commandStart({commandId:c,patternId:i}){const o=s.patterns.get(i)?.commands.get(c);o&&(o.status="running",a())},error({error:c,message:i}){s.errorMessages.push({error:c,message:i}),a()},info({message:c}){s.infoMessages.push(c),a()},patternEnd({patternId:c,status:i}){const o=s.patterns.get(c);o&&(o.status=i,a())},patternStart({patternId:c}){const i=s.patterns.get(c);i&&(i.status="running",a())},start({patterns:c}){s.started=!0;for(const i of c){const o=new Map;for(const l of i.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(i.id,{commands:o,id:i.id,status:"pending",title:i.title})}a()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),a()}}},rt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,a=i=>{e||process.stderr.write(`${i}
|
|
14
|
+
`)},c=i=>{switch(i){case"failed":return G(dt);case"running":return P(">");case"skipped":return V(_);case"success":return Et(lt);default:return $(_)}};return{commandEnd({commandId:i,durationMs:o,error:l,output:h,status:d}){const u=n.get(i)??i,p=$(`(${o}ms)`);if(a(` ${c(d)} ${u} ${p}`),d==="failed"&&l&&a($(l.message)),(d==="failed"||s)&&h&&h.trim().length>0)for(const f of h.split(/\r?\n/))a(` ${$(f)}`)},commandStart({commandId:i}){if(!s)return;const o=n.get(i)??i;a(` ${$("…")} ${o}`)},error({error:i,message:o}){e?process.stderr.write(`${G(o)}
|
|
15
|
+
`):a(G(o)),i?.stack&&(s||!e)&&process.stderr.write(`${$(i.stack)}
|
|
16
|
+
`)},info({message:i}){a($(i))},patternEnd({patternId:i,status:o}){const l=r.get(i)??i;a(`${c(o)} ${l}`)},patternStart({patternId:i}){const o=r.get(i)??i;a(`${P(">")} ${o}`)},start({patterns:i}){if(i.length===0){a($("No staged files matched any pattern."));return}const o=new Set(i.flatMap(l=>l.files)).size;a(`${P(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${i.length} pattern${i.length===1?"":"s"}`);for(const l of i){r.set(l.id,l.title);for(const h of l.commands)n.set(h.id,h.title)}},stop(){},warn({message:i}){a(V(i))}}},ie=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return rt({quiet:t.quiet,verbose:t.verbose});try{return ne({verbose:t.verbose})}catch{return rt({quiet:t.quiet,verbose:t.verbose})}},ae=t=>{const e=[];let s="",r=!1,n=!1;for(let a=0;a<t.length;a+=1){const c=t[a];if(c===void 0)break;if(c==="\\"&&!r&&a+1<t.length){const i=t[a+1];if(i!==void 0){n&&i!=='"'&&i!=="\\"&&(s+=c),s+=i,a+=1;continue}}if(c==='"'&&!r){n=!n;continue}if(c==="'"&&!n){r=!r;continue}if(!r&&!n&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(r||n)throw new v(`Unterminated ${r?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},gt=process.platform==="win32"?28e3:131072,oe=(t,e,s)=>{const r=[];let n=[],a=e;const c=s<=0?gt:s;for(const i of t){const o=Buffer.byteLength(i)+1;n.length>0&&a+o>c&&(r.push(n),n=[],a=e),n.push(i),a+=o}return n.length>0&&r.push(n),r},ce=async(t,e,s)=>{const r=ae(t);if(r.length===0)throw new I(t,"Empty command for staged task.");const[n,...a]=r;if(n===void 0)throw new I(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+a.reduce((h,d)=>h+Buffer.byteLength(d)+1,0),i=oe(e,c,s.maxArgLength??gt),o=Date.now(),l=[];for(const h of i){if(s.signal?.aborted===!0)throw new I(t,"Task aborted by earlier failure.");const d=ct(n,[...a,...h],{nodeOptions:{cwd:s.cwd,env:de(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,p=[u.stdout,u.stderr].filter(g=>g.length>0).join(`
|
|
17
|
+
`);p.length>0&&l.push(p);const f=d.process?.signalCode??null;if(d.aborted||f!==null||u.exitCode===void 0){const g=d.aborted?"Task aborted by earlier failure.":f===null?p.trim()||"Task exited without a numeric status code.":`Task killed by signal ${f}.`;throw new I(t,g)}if(u.exitCode!==0)throw new I(t,p.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
|
|
18
|
+
`)}},de=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return Mt(r,e)},le=async(t,e,s)=>{const r=he(s.concurrent,t.length),n=[],a=new AbortController;let c=!1,i=0;const o=()=>{c||(c=!0,s.continueOnError||a.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=f=>{for(const g of f.commands)e.commandEnd({commandId:g.id,durationMs:0,patternId:f.id,status:"skipped"})},h=async f=>{if(c){l(f),e.patternEnd({patternId:f.id,status:"skipped"});return}e.patternStart({patternId:f.id});let g="success";for(const y of f.commands){if(c){e.commandEnd({commandId:y.id,durationMs:0,patternId:f.id,status:"skipped"}),g=g==="success"?"skipped":g;continue}e.commandStart({commandId:y.id,patternId:f.id});const T=await ue(y,s,a.signal),S=T.status==="failed"&&a.signal.aborted?{...T,status:"skipped"}:T;if(e.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:f.id,status:S.status}),S.status==="failed"){n.push(y.title),g="failed",o();break}if(S.status==="skipped"){g=g==="success"?"skipped":g;break}}e.patternEnd({patternId:f.id,status:g})},d=async()=>{for(;i<t.length;){const f=t[i];i+=1,f&&await h(f)}},u=[];for(let f=0;f<Math.min(r,t.length);f+=1)u.push(d());await Promise.all(u);const p=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!p}},ue=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await ce(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new I(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const a=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:a,output:a instanceof I?a.message:void 0,status:"failed"}}},he=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof z=="function"?z():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},fe=!0,pe=t=>{try{return!kt(t)}catch{return!1}},ge=t=>{try{const e=Tt(t);return e?St(t,e).map(s=>O(t,s)):[]}catch{return[]}},me=async(t={})=>{const e=t.cwd??process.cwd(),s=await ie(t),r=await Dt(t);typeof r!="function"&&Y(r);const n=new se({...t,cwd:e}),a=new AbortController;let c=!1;const i=d=>{if(c){process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),a.abort()};process.on("SIGINT",i),process.on("SIGTERM",i);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,h=!1;try{await n.prepare(),l=!0;for(const T of n.warnings)s.warn({message:T});if(n.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=pe(e),u=Rt(n.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&n.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const p=typeof r=="function"?Y(await r([...u])):r,f=await _t({caseInsensitive:d,config:p,cwd:e,files:u,relative:t.relative,workspacePackages:ge(e)});if(s.start({patterns:f}),f.length===0)return s.info({message:"No staged files matched any pattern."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:g,success:y}=await le(f,s,{concurrent:t.concurrent??fe,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:a.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:g,ranTasks:!0,success:y},y){if(t.diff===void 0&&(await n.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&n.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...g],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new At("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)s.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const T=n.recoveryHint();T&&s.warn({message:T})}return await n.restoreUnstagedChanges(),h=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),p=d instanceof Error?d:new Error(u);if(s.error({error:p,message:u}),d instanceof E)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),l)try{await n.cleanup(h)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},we="VIS_STAGED_CONCURRENT",nt=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},ye=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=k=>t[k]===void 0?void 0:!!t[k],n=k=>{const F=t[k];return typeof F=="string"&&F.length>0?F:void 0},a=r("allow-empty");a!==void 0&&(s.allowEmpty=a);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const i=r("continue-on-error");i!==void 0&&(s.continueOnError=i);const o=r("debug");o!==void 0&&(s.debug=o);const l=r("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const h=r("hide-partially-staged");h!==void 0&&(s.hidePartiallyStaged=h);const d=r("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=r("quiet");u!==void 0&&(s.quiet=u);const p=r("relative");p!==void 0&&(s.relative=p);const f=r("revert");f!==void 0&&(s.revert=f);const g=r("stash");g!==void 0&&(s.stash=g);const y=r("verbose");y!==void 0&&(s.verbose=y);const T=n("cwd");T!==void 0&&(s.cwd=T);const S=n("diff");S!==void 0&&(s.diff=S);const U=n("diff-filter");if(U!==void 0&&(s.diffFilter=U),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const k=process.env[we];k!==void 0&&(s.concurrent=nt(k.trim()))}else{const{concurrent:k}=t;s.concurrent=nt(typeof k=="string"?k:typeof k=="number"||typeof k=="boolean"?String(k):"")}return s},Ee=async({options:t,visConfig:e})=>{const s=(e??{}).staged;if(!s)throw new Error(`No "staged" config found in vis.config.ts. Add one:
|
|
19
|
+
|
|
20
|
+
// vis.config.ts
|
|
21
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
staged: { '*': 'vis check --fix' },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await me(ye(t,s))).success||(process.exitCode=1)};export{ye as buildRunOptions,Ee as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as Be}from"node:module";import{s as p,ae as U,a4 as e,a5 as s,m as r,aF as Ce,aE as ze,aG as Ge,aD as _e,aH as $e,aI as Ue,$ as We,d as Xe,r as Ve}from"./bin.js";import{w as Je}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{e as qe,m as le,f as Ye,v as Ke,H as Qe,a as Ze}from"../packem_shared/index-BDmTbWX1.js";import{F as et,a as tt}from"../packem_shared/tabs-BuTy5gPV.js";const Ne=Be(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Re=i=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[t,n]=Y.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Y.getBuiltinModule(i)}return Ne(i)},{writeFileSync:He}=Re("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(qe,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),W=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],ot=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ye(t))return null;const n=Ke(t),c=rt(n),l=c!==n;let o;try{o=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:o,hadComments:l}},nt=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");Ze(c),He(l,`${JSON.stringify(t,null,2)}
|
|
2
|
+
`,"utf8")},it={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},st=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of it[i])l.has(a.target)||c.push(a);const o=Object.keys(t);for(const{featureMatch:a,mounts:m}of st)if(o.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},N=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],K=i=>structuredClone(i);class ct{#o=new Set;#e;constructor(t,n,c=null){const l=t===null,o=t??{name:""},a=K(o);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:K(o),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#o.add(t),()=>{this.#o.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const t=(N.indexOf(this.#e.section)+1)%N.length;this.setSection(N[t])}previousSection(){const t=(N.indexOf(this.#e.section)-1+N.length)%N.length;this.setSection(N[t])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,W.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=W.find(c=>c.id===t);n&&this.#t(this.#r({...this.#e,config:K(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#r({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],o=l.indexOf(t);o===-1?l.push(t):l.splice(o,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",o={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:o},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:K(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=K(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#r(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#o)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},lt=/^[a-z]$/i,at=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},dt=(i,t)=>i.length===0||at(i)?!1:t.ctrl&&t.meta?!lt.test(i):!(t.ctrl||t.meta),ut=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,Se=-1,ht=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:Se,mt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ut,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:o,suggestions:a}){const[m,g]=p.useState(i),[f,j]=p.useState(i.length),x=p.useRef(m);x.current=m;const v=p.useRef(f);v.current=f;const b=p.useRef(c);b.current=c;const S=p.useRef(l);S.current=l;const D=se(m,a),R=p.useCallback((T,I)=>{const{current:E}=v,k=x.current;if(I.return){const w=se(k,a),C=w?k+w:k;w&&(g(C),j(C.length),b.current?.(C)),S.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(k,a);if(E===k.length&&w){const C=k+w;g(C),j(C.length),b.current?.(C);return}j(Math.min(k.length,E+1));return}const P=ht(T,I,E,k.length);if(P!==Se){j(P);return}const H=mt(T,I,k,E);if(H){const[w,C]=H;g(w),j(C),b.current?.(w);return}if(dt(T,I)){const w=k.slice(0,E)+T+k.slice(E);g(w),j(E+T.length),b.current?.(w)}},[a]);U(R,{isActive:!t});const L=n?"*".repeat(m.length):m,X=L.slice(0,f),V=L[f],Q=L.slice(f+1);return t?e.jsx(s,{children:e.jsx(r,{dimColor:!0,children:L||o||""})}):m.length===0&&o?e.jsxs(s,{children:[e.jsx(r,{dimColor:!0,inverse:!0,children:o[0]}),e.jsx(r,{dimColor:!0,children:o.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(r,{children:[X,e.jsx(r,{inverse:!0,children:V??" "}),Q]}),D?e.jsx(r,{dimColor:!0,children:D}):void 0]})}const Ee=["dockerComposeFile","service"],gt={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},ft={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},pt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,o=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),o&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(r,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const g=m===n,f=i[a]??"",j=Array.isArray(i[a])?i[a].join(", "):f;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:g,color:g?"cyan":"white",children:[g?"❯ ":" ",gt[a],":"]})}),e.jsx(s,{flexGrow:1,children:g&&t?e.jsx(he,{defaultValue:j,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(r,{color:j?"white":"gray",children:j||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(r,{dimColor:!0,children:ft[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},xt=Ee.length,jt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),o=Object.keys(c),a=l.length,m=l.length+1,g=m+o.length,f=t<=a,j=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(r,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),e.jsx(r,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,v)=>{const b=v===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(r,{bold:!0,children:x}),e.jsx(r,{dimColor:!0,children:" = "}),e.jsx(r,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(r,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:j?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:o.length>0?1:0,children:[e.jsx(r,{bold:!0,color:j?"cyan":"white",children:"remoteEnv"}),e.jsx(r,{dimColor:!0,children:" — set at runtime by the IDE"})]}),o.map((x,v)=>{const b=m+v===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(r,{bold:!0,children:x}),e.jsx(r,{dimColor:!0,children:" = "}),e.jsx(r,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:o.length>0?1:0,children:e.jsxs(r,{color:t===g?"cyan":"gray",inverse:t===g,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(r,{dimColor:!0,wrap:"truncate",children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(r,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},vt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const o=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,g=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),c&&e.jsxs(r,{dimColor:!0,children:["— filter:"," ",e.jsx(r,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((f,j)=>{const x=j===t,v=o.has(f.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:x?">":" "}),e.jsxs(r,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(r,{dimColor:!0,children:[" ","-",f.id]})]})})]},f.id)})})}),g&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(r,{dimColor:!0,children:"No extensions match the search."})})]})},bt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const o=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,g=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),c&&e.jsxs(r,{dimColor:!0,children:["— filter:"," ",e.jsx(r,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((f,j)=>{const x=j===t,v=o.has(f.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:x?">":" "}),e.jsxs(r,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(r,{dimColor:!0,children:[" ","-",f.description]})]})})]},f.id)})})}),g&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(r,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],wt={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},ye={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],kt={overrideCommand:"Override Command",privileged:"Privileged"},Ct=ae.length+te.length,St=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,o)=>{const a=o===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",wt[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:g=>{c({[l]:g})},placeholder:ye[l]}):e.jsx(r,{color:m?"white":"gray",children:m||ye[l]})})]},l)}),te.map((l,o)=>{const a=ae.length+o===n,m=i[l]??!1;return e.jsxs(s,{marginBottom:o<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",kt[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{color:m?"green":"gray",children:[m?"yes":"no",a&&e.jsx(r,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(r,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=Ct,ce=te,Te=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],Et={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},It={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Te.map((l,o)=>{const a=o===n,m=i[l],g=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",Et[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(r,{dimColor:!0,children:It[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:g,onChange:f=>{c(l,f)},placeholder:"e.g. npm install"}):e.jsx(r,{color:g?"green":"gray",children:g||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Dt=Te.length,be=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Pt=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:o,mountTarget:a,mountType:m,suggestedMounts:g})=>{const f=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[f.length," ","mounts"]}),n&&e.jsxs(r,{dimColor:!0,children:["— detected:"," ",e.jsx(r,{color:"white",children:n})]})]}),g.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(r,{dimColor:!0,children:[" ","— press"," ",e.jsx(r,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),g.map((j,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" + ",be(j)]})},`suggestion-${String(x)}`))]}),f.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:f.map((j,x)=>{const v=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:v?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:v,inverse:v,wrap:"truncate",children:[" ",be(j)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:c===f.length?"cyan":"gray",inverse:c===f.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(r,{color:o?"yellow":"gray",children:o||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(r,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(r,{children:[e.jsx(r,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(r,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(r,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(r,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(r,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!i&&g.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(r,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ft=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],o=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(r,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const g=m===c;return e.jsx(s,{children:e.jsxs(r,{color:g?"cyan":void 0,inverse:g,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(r,{color:o?"cyan":"gray",inverse:o,children:[" ",o&&i?e.jsxs(r,{children:["Enter port:"," ",e.jsx(r,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ",o?"type port number, Enter to confirm":"select"," ",e.jsx(r,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},At=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(r,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(r,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(r,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
|
|
3
|
+
`).map((o,a)=>e.jsx(r,{color:"green",children:o},`line-${String(a)}`))})]}),Ot=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,o]of i.forwardPorts.entries())typeof o=="number"&&(o<1||o>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(o)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},we=80,ke=15,Mt=120,De=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Lt=new Map(De.map(i=>[i.id,i.description])),Bt=(i,t,n,c)=>{switch(i){case"compose":return xt;case"environment":return vt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return Dt;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Nt=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=_e(),o=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[g,f]=p.useState(!1),[j,x]=p.useState(!1),[v,b]=p.useState(null),[S,D]=p.useState("editor"),[R,L]=p.useState(0),[X,V]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[k,P]=p.useState(""),[H,w]=p.useState(""),[C,z]=p.useState("key"),[re,Z]=p.useState(!1),[oe,G]=p.useState(""),[ne,_]=p.useState(""),[me,J]=p.useState("volume"),[A,$]=p.useState("source"),ie=p.useRef(null),B=p.useRef(null),M=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,M.current&&clearTimeout(M.current)}),[]);const ge=Bt(o.section,o.config,o.featureSearch,o.extensionSearch),q=Math.max(1,l-9);p.useEffect(()=>{o.section!=="features"&&o.section!=="extensions"||L(u=>o.fieldIndex>=u+q?o.fieldIndex-q+1:o.fieldIndex<u?o.fieldIndex:u)},[o.fieldIndex,o.section,q]),p.useEffect(()=>{L(0)},[o.section,o.featureSearch,o.extensionSearch]);const Pe=p.useCallback(()=>{const u=t.cleanConfig(),h=Ot(u);if(!h.valid){const y=h.errors[0];b(y?`Error: ${y.message}`:"Validation failed"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{ee.current&&b(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;b(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{ee.current&&b(null)},2e3)},[i,t]);U((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(o.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(o.templateIndex-1);else if(h.return){const d=W[o.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),U((u,h)=>{if(h.escape){V(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),V(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:X}),U((u,h)=>{if(h.escape){E(null),P(""),w(""),z("key");return}if(h.return){if(C==="key"&&k){z("value");return}if(C==="value"&&k){t.addEnvVar(I,k,H),E(null),P(""),w(""),z("key");return}}if(h.backspace){C==="key"?P(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?P(d=>d+u):w(d=>d+u))},{isActive:I!==null}),U((u,h)=>{if(h.escape){Z(!1),G(""),_(""),$("source");return}if(h.return){if(A==="source"&&oe){$("target");return}if(A==="target"&&ne){$("type");return}if(A==="type"){t.addMount({source:oe,target:ne,type:me}),Z(!1),G(""),_(""),$("source");return}}if(A==="type"){switch(u){case"1":{J("volume");break}case"2":{J("bind");break}case"3":{J("tmpfs");break}}return}if(h.backspace){A==="source"?G(d=>d.slice(0,-1)):A==="target"&&_(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(A==="source"?G(d=>d+u):A==="target"&&_(d=>d+u))},{isActive:re}),U((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!g){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),f(!0));return}if(j){if(h.escape){x(!1),o.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){o.section==="features"?t.setFeatureSearch(o.featureSearch.slice(0,-1)):t.setExtensionSearch(o.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){o.section==="features"?t.setFeatureSearch(o.featureSearch+u):t.setExtensionSearch(o.extensionSearch+u);return}return}if(o.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){o.isDirty?f(!0):n();return}if(u==="s"){Pe();return}if(h.tab){D(d=>d==="editor"?"preview":"editor");return}if(S==="preview"){if(h.downArrow||u==="j"){B.current?.scrollBy(1);return}if(h.upArrow||u==="k"){B.current?.scrollBy(-1);return}if(h.pageDown){B.current?.scrollBy(10);return}if(h.pageUp){B.current?.scrollBy(-10);return}if(h.home){B.current?.scrollToTop();return}if(h.end){B.current?.scrollToBottom();return}h.escape&&D("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(o.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(o.fieldIndex-1,0));return}if(h.return){switch(o.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(o.config.containerEnv??{}).length,y=d,O=d+1+Object.keys(o.config.remoteEnv??{}).length;o.fieldIndex===y?(E("container"),P(""),w(""),z("key")):o.fieldIndex===O&&(E("remote"),P(""),w(""),z("key"));break}case"mounts":{const d=o.config.mounts??[];o.fieldIndex===d.length&&(Z(!0),G(""),_(""),J("volume"),$("source"));break}case"ports":{const d=o.config.forwardPorts??[];o.fieldIndex===d.length&&(V(!0),T(""));break}}return}if(u===" "){switch(o.section){case"extensions":{const d=ue(o.extensionSearch)[o.fieldIndex];d&&t.toggleExtension(d.id);break}case"features":{const d=de(o.featureSearch)[o.fieldIndex];d&&t.toggleFeature(d.id);break}case"general":{const d=Ie-ce.length,y=o.fieldIndex-d;if(y>=0&&y<ce.length){const O=ce[y];t.updateConfig({[O]:!o.config[O]})}break}}return}if(u==="/"){(o.section==="features"||o.section==="extensions")&&x(!0);return}if(u==="A"&&o.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(o.section==="environment"){const d=Object.keys(o.config.containerEnv??{}).length,y=o.fieldIndex<=d?"container":"remote";E(y),P(""),w(""),z("key")}else o.section==="mounts"&&(Z(!0),G(""),_(""),J("volume"),$("source"));return}if(u==="d")switch(o.section){case"environment":{const d=Object.keys(o.config.containerEnv??{}),y=Object.keys(o.config.remoteEnv??{});if(o.fieldIndex<d.length)t.removeEnvVar("container",d[o.fieldIndex]),d.length===1||o.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const O=o.fieldIndex-d.length-1;O>=0&&O<y.length&&(t.removeEnvVar("remote",y[O]),y.length===1||O>=y.length-1&&t.setFieldIndex(o.fieldIndex-1))}break}case"mounts":{const d=o.config.mounts??[];if(o.fieldIndex<d.length){t.removeMount(o.fieldIndex);const y=d.length-1;o.fieldIndex>=y&&y>0&&t.setFieldIndex(y-1)}break}case"ports":{const d=o.config.forwardPorts??[];if(o.fieldIndex<d.length){t.removePort(o.fieldIndex);const y=d.length-1;o.fieldIndex>=y&&y>0&&t.setFieldIndex(y-1)}break}}}},{isActive:!o.showTemplateSelector&&!X&&I===null&&!re});const Fe=p.useMemo(()=>t.getJsonPreview(),[o.config]);if(c<we||l<ke)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",we,"x",ke]})});if(o.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Select a Template"})}),W.map((u,h)=>{const d=h===o.templateIndex;return e.jsx(s,{children:e.jsxs(r,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(r,{bold:d,children:u.name}),e.jsxs(r,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let F;switch(o.section){case"compose":{F=e.jsx(pt,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{F=e.jsxs(s,{flexDirection:"column",children:[e.jsx(jt,{config:o.config,fieldIndex:o.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(r,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(r,{children:["key=",e.jsx(r,{color:"yellow",children:k||"_"})," ","(Enter to set value)"]}):e.jsxs(r,{children:[k,"=",e.jsx(r,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{F=e.jsx(yt,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:R,searchText:o.extensionSearch,viewportHeight:q});break}case"features":{F=e.jsx(bt,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:R,searchText:o.featureSearch,viewportHeight:q});break}case"general":{F=e.jsx(St,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{F=e.jsx(Tt,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{F=e.jsx(Pt,{addingMount:re,config:o.config,detectedPm:o.detectedPm,fieldIndex:o.fieldIndex,mountPhase:A,mountSource:oe,mountTarget:ne,mountType:me,suggestedMounts:o.suggestedMounts});break}case"ports":{F=e.jsx(Ft,{addingPort:X,addPortValue:Q,config:o.config,fieldIndex:o.fieldIndex});break}default:F=e.jsx(r,{children:"Unknown section"})}const Ae=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]}),(o.section==="features"||o.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]}),(o.section==="features"||o.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"s"}),e.jsx(r,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[v&&e.jsxs(r,{color:v.startsWith("Error")?"red":"green",children:[v," "]}),o.isDirty&&e.jsx(r,{color:"yellow",children:"[modified]"}),!o.isDirty&&!v&&e.jsx(r,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs($e,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"?"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(r,{bold:!0,color:"white",children:"j/k"}),e.jsx(r,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Enter"}),e.jsx(r,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Esc"}),e.jsx(r,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"d"}),e.jsx(r,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"s"}),e.jsx(r,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:" Quit"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:" Toggle help"})]})]})]}),Me=e.jsx(At,{focused:S==="preview",hadComments:o.hadComments,jsonPreview:Fe,mode:o.mode,scrollRef:B}),fe=c>=Mt,Le=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[o.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(et,{defaultValue:o.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),D("editor")},showIndex:!1,children:De.map(({id:u,label:h})=>e.jsx(tt,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(r,{dimColor:!0,wrap:"truncate",children:Lt.get(o.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:S==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:F}),fe&&e.jsx(s,{flexShrink:0,width:Le,children:Me})]}),Ae,e.jsx(Ue,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Oe]})},Ut=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,o=t.output,a=!!process.stdout.isTTY&&!Ve;let m=null;try{m=Je(c).name}catch{}const g=ot(c);let f=g?.config??null;const j=g?.hadComments??!1;if(l&&!g){const S=W.find(D=>D.id===l);if(!S){const D=W.map(R=>R.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${D}`)}f=S.config}if(!a){f?i.info(JSON.stringify(f,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),v=new ct(f,j,m);l&&!g&&v.dismissTemplateSelector();let b=null;if(await We(Xe.createElement(Nt,{onSave:S=>{nt(c,S,o),b=S},store:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),b){const S=o??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${S}`)}};export{Ut as default};
|