@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,75 @@
|
|
|
1
|
+
import{createRequire as N}from"node:module";const R=N(import.meta.url),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[n,a]=j.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return j.getBuiltinModule(e)}return R(e)},{mkdir:J,readFile:$,writeFile:w,readdir:S,access:M,rm:O}=A("node:fs/promises"),{join:l,relative:v,dirname:P}=A("node:path"),k=async e=>{try{return await M(e),!0}catch{return!1}},_=async e=>await k(l(e,".changeset"))?"changesets":await k(l(e,".bumpy"))?"bumpy":await(async()=>{for(const a of[".releaserc.json",".releaserc.cjs",".releaserc.js"])if(await k(l(e,a)))return!0;const n=[l(e,"packages"),l(e,"apps")];for(;n.length>0;){const a=n.shift();let t;try{t=await S(a,{withFileTypes:!0})}catch{continue}for(const s of t)if(s.isDirectory()){if(s.name==="node_modules"||s.name.startsWith("."))continue;n.push(l(a,s.name))}else if(s.name===".releaserc.json"||s.name===".releaserc.cjs"||s.name===".releaserc.js")return!0;if(n.length>200)break}return!1})()?"semantic-release":"fresh",C=async e=>{const n=[];for(const s of[".releaserc.json",".releaserc.cjs",".releaserc.js"]){const f=l(e,s);await k(f)&&n.push(f)}const a=[l(e,"packages"),l(e,"apps")];let t=0;for(;a.length>0&&t<5e3;){const s=a.shift();t+=1;let f;try{f=await S(s,{withFileTypes:!0})}catch{continue}for(const i of f){const r=l(s,i.name);if(i.isDirectory()){if(i.name==="node_modules"||i.name.startsWith("."))continue;a.push(r)}else(i.name===".releaserc.json"||i.name===".releaserc.cjs"||i.name===".releaserc.js")&&n.push(r)}}return n},F=async e=>{if(!e.endsWith(".json"))return{path:e};try{const n=await $(e,"utf8"),a=JSON.parse(n);return{branches:a.branches,extends:typeof a.extends=="string"?a.extends:void 0,path:e,plugins:Array.isArray(a.plugins)?a.plugins:void 0}}catch{return}},B=e=>Array.isArray(e)?e.map(n=>{if(typeof n=="string")return{name:n};if(typeof n=="object"&&n!==null&&typeof n.name=="string"){const a=n;return{channel:a.channel,name:a.name,prerelease:a.prerelease}}}).filter(n=>n!==void 0):[],T=e=>{const n={};for(const a of e){const t={tag:"latest"};typeof a.prerelease=="string"?(t.prerelease=a.prerelease,t.tag=a.prerelease,t.mode="auto-publish"):a.prerelease===!0?(t.prerelease=a.name,t.tag=a.name,t.mode="auto-publish"):(t.tag=a.channel??(a.name==="main"||a.name==="master"?"latest":a.name),t.mode="version-pr"),n[a.name]=t}return n},z=async({logger:e,options:n,workspaceRoot:a})=>{const t=a??process.cwd(),s=n.dryRun===!0;let f=n.apply===!0;s&&f&&(e.warn("--apply is ignored because --dry-run is set (dry-run takes precedence)."),f=!1);let i;n.fromSemanticRelease?i="semantic-release":n.fromChangesets?i="changesets":n.fromBumpy?i="bumpy":n.fresh?i="fresh":i=await _(t),e.info(`Detected source: ${i}`),e.info("");const r=l(t,".vis","release"),c=".vis/release/.state.json",g=".vis/release/.lock",u=l(t,".gitignore");if(s)e.info(`[dry-run] would create directory: ${r}`),e.info(`[dry-run] would append to .gitignore:
|
|
2
|
+
${c}
|
|
3
|
+
${g}`);else{await J(r,{recursive:!0}),e.info(`Created ${v(t,r)}/`);try{const p=await $(u,"utf8"),h=[];p.includes(c)||h.push(c),p.includes(g)||h.push(g),h.length>0&&(await w(u,`${p.replace(/\n*$/,`
|
|
4
|
+
`)}
|
|
5
|
+
# vis release subsystem
|
|
6
|
+
${h.join(`
|
|
7
|
+
`)}
|
|
8
|
+
`),e.info("Updated .gitignore."))}catch{await w(u,`# vis release subsystem
|
|
9
|
+
${c}
|
|
10
|
+
${g}
|
|
11
|
+
`),e.info("Created .gitignore.")}}const o=".vis/release/**",d=l(t,".secretlintignore");if(s)e.info(`[dry-run] would add to .secretlintignore:
|
|
12
|
+
${o}`);else try{const p=await $(d,"utf8");p.includes(o)||(await w(d,`${p.replace(/\n*$/,`
|
|
13
|
+
`)}
|
|
14
|
+
# vis release change files (author handles false-positive secretlint)
|
|
15
|
+
${o}
|
|
16
|
+
`),e.info("Updated .secretlintignore."))}catch{await w(d,`# vis release change files (author handles false-positive secretlint)
|
|
17
|
+
${o}
|
|
18
|
+
`),e.info("Created .secretlintignore.")}switch(i){case"bumpy":{await U(t,s,e);break}case"changesets":{await E(t,s,e);break}case"semantic-release":{await D(t,s,f,e);break}default:V(e)}await q(t,s,n.yes===!0,e),await G(t,s,n,e),e.info(""),e.info("Next steps:"),e.info(" 1. Add the `release: { ... }` block above to your vis.config.ts"),e.info(" 2. Author your first change file: vis release add"),e.info(" 3. Preview the plan: vis release status"),e.info(" 4. Apply: vis release version --dry-run")},D=async(e,n,a,t)=>{const s=await C(e);if(t.info(`Found ${s.length} .releaserc file(s).`),s.length===0)return;let f=[],i=0;for(const o of s){const d=await F(o);d&&(d.branches&&(f=[...f,...B(d.branches)]),d.plugins?.some(p=>typeof p=="string"&&p.includes("native-addons"))&&(i+=1),d.plugins?.some(p=>Array.isArray(p)&&typeof p[0]=="string"&&p[0].includes("native-addons"))&&(i+=1))}const r=new Set,c=f.filter(o=>r.has(o.name)?!1:(r.add(o.name),!0)),g=c.length>0?T(c):{alpha:{mode:"auto-publish",prerelease:"alpha",tag:"alpha"},main:{mode:"version-pr",tag:"latest"}};t.info(""),t.info("Suggested vis.config.ts release block (paste into your existing config):"),t.info("");const u=` release: {
|
|
19
|
+
baseBranch: "main",
|
|
20
|
+
defaultManaged: false, // flip to true after Phase 6
|
|
21
|
+
channels: {
|
|
22
|
+
${Object.entries(g).map(([o,d])=>` ${JSON.stringify(o)}: ${JSON.stringify(d)},`).join(`
|
|
23
|
+
`)}
|
|
24
|
+
},
|
|
25
|
+
publish: {
|
|
26
|
+
packManager: "auto",
|
|
27
|
+
publishStrategy: "npm-publish-tarball",
|
|
28
|
+
publishArgs: ["--provenance"],
|
|
29
|
+
protocolResolution: "pack",
|
|
30
|
+
catalogResolution: "auto",
|
|
31
|
+
cleanPackageJson: true,
|
|
32
|
+
},
|
|
33
|
+
gitUser: { name: "release-bot", email: "release-bot@example.com" },
|
|
34
|
+
},`;if(t.info(u),t.info(""),i>0&&(t.info(`Found ${i} package(s) using a NAPI native-addons plugin.`),t.info("These will auto-detect via the `napi` field in package.json — no config needed."),t.info("")),t.info("Migration is per-package opt-in (RFC §17.1). For each package you want to migrate:"),t.info(' 1. Add to its package.json: "vis-release": { "managed": true }'),t.info(" 2. Backfill any missing git tags so already-published detection works."),t.info(" 3. Add to multi-semantic-release's --ignore-packages list in your release workflow."),t.info(""),!a){t.info("Existing .releaserc.json files are kept in place during transition (deleted in Phase 6)."),t.info("Re-run with `--apply` to perform the writes automatically.");return}t.info(""),t.info("Applying migration writes (--apply set)…"),await I(e,s,u,t),t.info(""),t.info("Migration writes complete. Follow-up steps you still need to do manually:"),t.info(" - Update your CI workflow: remove `multi-semantic-release` step, add `vis release ci/release` step (see `.github/workflows/vis-release.yml` example in the vis package)"),t.info(" - Run `pnpm install` to drop semantic-release deps once you remove them from root package.json"),t.info(" - Run `vis release doctor` to verify the migration")},I=async(e,n,a,t)=>{const s=l(e,"vis.config.ts"),f=await $(s,"utf8").catch(()=>{});if(f===void 0){const i=`import { defineConfig } from "@visulima/vis/config";
|
|
35
|
+
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
${a}
|
|
38
|
+
});
|
|
39
|
+
`;await w(s,i),t.info(` wrote ${v(e,s)}`)}else if(/\brelease\s*:/.test(f))t.warn(` skipped ${v(e,s)} — already has a \`release\` key; merge the suggested block manually.`);else{const i=W(f,a);i===void 0?t.warn(` skipped ${v(e,s)} — could not locate \`defineConfig({\` or \`export default {\` to inject into; merge the suggested block manually.`):(await w(s,i),t.info(` updated ${v(e,s)} (injected release block)`))}for(const i of n){const r=P(i),c=l(r,"package.json");if(!await k(c))continue;const g=await $(c,"utf8");let u;try{u=JSON.parse(g)}catch{t.warn(` skipped ${v(e,c)} — invalid JSON.`);continue}const o=u["vis-release"];if(o!==null&&typeof o=="object"&&o.managed===!0)continue;const d=o!==null&&typeof o=="object"?{...o,managed:!0}:{managed:!0};u["vis-release"]=d,await w(c,`${JSON.stringify(u,void 0,4)}
|
|
40
|
+
`),t.info(` updated ${v(e,c)} (added vis-release.managed = true)`)}for(const i of n)await O(i,{force:!0}),t.info(` deleted ${v(e,i)}`)},W=(e,n)=>{const a=/defineConfig\s*\(\s*\{/.exec(e);if(a!==null){const s=a.index+a[0].length;return`${e.slice(0,s)}
|
|
41
|
+
${n}
|
|
42
|
+
${e.slice(s)}`}const t=/export\s+default\s+\{/.exec(e);if(t!==null){const s=t.index+t[0].length;return`${e.slice(0,s)}
|
|
43
|
+
${n}
|
|
44
|
+
${e.slice(s)}`}},E=async(e,n,a)=>{const t=l(e,".changeset"),s=l(t,"config.json"),f=l(t,"pre.json");if(await k(f)){a.error("Pre-release mode is active in changesets (.changeset/pre.json exists)."),a.error("Run `changeset pre exit && changeset version` to consume pending changes, then re-run `vis release init`."),process.exitCode=1;return}let i={};try{i=JSON.parse(await $(s,"utf8"))}catch{a.warn(".changeset/config.json missing or unreadable; using defaults.")}const r={access:i.access==="restricted"?"restricted":"public",baseBranch:typeof i.baseBranch=="string"?i.baseBranch:"main",defaultManaged:!0,fixed:Array.isArray(i.fixed)?i.fixed:[],ignore:Array.isArray(i.ignore)?i.ignore:[],linked:Array.isArray(i.linked)?i.linked:[],privatePackages:i.privatePackages??{tag:!1,version:!1},updateInternalDependencies:i.updateInternalDependencies??"out-of-range"},c=i.changelog,g=typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:void 0;let u;c===!1?u="false":g?.includes("@changesets/changelog-github")?u='"github"':(g?.includes("@changesets/cli"),u='"default"');const o=[];let d=0;try{const p=await S(t);for(const h of p)!h.endsWith(".md")||h==="README.md"||o.push(h)}catch{}if(o.length>0){const p=l(e,".vis","release");let h=0;for(const b of o){const m=l(t,b),y=l(p,b);if(n){a.info(`[dry-run] would copy ${m} → ${y}`);continue}if(await k(y)){a.info(`Skipping existing ${v(e,y)}.`),h+=1;continue}const x=await $(m,"utf8");await w(y,x),d+=1}h>0&&a.info(`Skipped ${h} file(s) that already exist in .vis/release/.`)}a.info(`Found ${o.length} pending .changeset/*.md file(s); ${d>0?`copied ${d} to .vis/release/`:"(dry-run — would copy)"}.`),a.info(""),a.info("Suggested vis.config.ts release block:"),a.info(""),a.info(` release: {
|
|
45
|
+
baseBranch: ${JSON.stringify(r.baseBranch)},
|
|
46
|
+
access: ${JSON.stringify(r.access)},
|
|
47
|
+
defaultManaged: ${r.defaultManaged},
|
|
48
|
+
updateInternalDependencies: ${JSON.stringify(r.updateInternalDependencies)},
|
|
49
|
+
fixed: ${JSON.stringify(r.fixed)},
|
|
50
|
+
linked: ${JSON.stringify(r.linked)},
|
|
51
|
+
ignore: ${JSON.stringify(r.ignore)},
|
|
52
|
+
privatePackages: ${JSON.stringify(r.privatePackages)},
|
|
53
|
+
changelog: ${u},
|
|
54
|
+
publish: {
|
|
55
|
+
packManager: "auto",
|
|
56
|
+
publishStrategy: "npm-publish-tarball",
|
|
57
|
+
cleanPackageJson: true,
|
|
58
|
+
},
|
|
59
|
+
},`),a.info(""),a.info("After confirming the config, you can delete `.changeset/` (or run `vis release init --remove-changesets`).")},U=async(e,n,a)=>{const t=l(e,".bumpy"),s=l(t,"_config.json");let f={};try{f=JSON.parse(await $(s,"utf8"))}catch{a.warn(".bumpy/_config.json missing or unreadable; using defaults.")}const i=JSON.stringify(f,null,4).split(`
|
|
60
|
+
`).map(g=>` ${g}`).join(`
|
|
61
|
+
`),r=[];let c=0;try{const g=await S(t);for(const u of g)!u.endsWith(".md")||u==="README.md"||r.push(u)}catch{}if(r.length>0){const g=l(e,".vis","release");let u=0;for(const o of r){const d=l(t,o),p=l(g,o);if(n){a.info(`[dry-run] would copy ${d} → ${p}`);continue}if(await k(p)){a.info(`Skipping existing ${v(e,p)}.`),u+=1;continue}const h=await $(d,"utf8");await w(p,h),c+=1}u>0&&a.info(`Skipped ${u} file(s) that already exist in .vis/release/.`)}a.info(`Found ${r.length} pending .bumpy/*.md file(s); ${c>0?`copied ${c} to .vis/release/`:"(dry-run)"}.`),a.info(""),a.info("Suggested vis.config.ts release block (bumpy config translates 1:1):"),a.info(""),a.info(` release: ${i.trimStart()},`),a.info(""),a.info("After confirming, delete `.bumpy/`.")},q=async(e,n,a,t)=>{const s=l(e,".husky","pre-commit");if(!await k(s))return;const f=await $(s,"utf8").catch(()=>"");if(f.includes("vis release check"))return;const i="vis release check --hook pre-commit --no-fail";if(!await(async()=>{if(!process.stdout.isTTY||process.env.CI==="true")return!1;if(a)return!0;try{const{confirmPrompt:c}=await import("./prompts.js");return await c(`Wire \`${i}\` into your .husky/pre-commit hook?`,!0)}catch{return!1}})()){t.info(""),t.info("Optional: add this line to .husky/pre-commit:"),t.info(` ${i}`);return}if(n){t.info(`[dry-run] would append \`${i}\` to .husky/pre-commit`);return}const r=`${f.replace(/\n*$/,`
|
|
62
|
+
`)}${i}
|
|
63
|
+
`;await w(s,r),t.info("Wired vis release check into .husky/pre-commit.")},G=async(e,n,a,t)=>{const s=a.workflows===!0,f=a.yes===!0;if(!s&&(!process.stdout.isTTY||process.env.CI==="true"))return;if(!(s||f||await(async()=>{try{const{confirmPrompt:m}=await import("./prompts.js");return await m("Generate CI workflow files for the active provider?",!0)}catch{return!1}})())){t.info(""),t.info("Skipped workflow generation. Re-run with `vis release init --workflows` later.");return}const{detectRemoteProvider:i}=await import("./detect2.js"),{generateWorkflowFiles:r}=await import("./workflow-templates.js"),{detectPackageManager:c}=await import("../packem_shared/createAdapter-bU4DIP3F.js"),{createShellRunner:g}=await import("./shell-runner.js"),u=g(),o=await i(e,u,void 0),d=await c(e,u),p=a.packageManager??d;let h={};try{const{loadVisConfig:m}=await import("../packem_shared/CONFIG_FILES-BfaR0jKT.js"),y=await m(e);y.release&&(h=y.release)}catch{}const b=r(h,{packageManager:p,provider:o});t.info(""),t.info(`Generating ${b.length} workflow file(s) for ${o}:`);for(const m of b){const y=l(e,m.path);if(await k(y)){t.warn(` ${m.path} — already exists, skipping`);continue}if(n){t.info(` ${m.path} — [dry-run] would write ${m.content.length} bytes`);continue}const x=await import("node:path");await J(x.dirname(y),{recursive:!0}),await w(y,m.content),t.info(` ${m.path} — wrote ${m.content.length} bytes`)}},V=e=>{e.info(""),e.info("Suggested vis.config.ts release block:"),e.info(""),e.info(` release: {
|
|
64
|
+
baseBranch: "main",
|
|
65
|
+
defaultManaged: true,
|
|
66
|
+
channels: {
|
|
67
|
+
main: { tag: "latest", mode: "version-pr" },
|
|
68
|
+
},
|
|
69
|
+
publish: {
|
|
70
|
+
packManager: "auto",
|
|
71
|
+
publishStrategy: "npm-publish-tarball",
|
|
72
|
+
publishArgs: ["--provenance"],
|
|
73
|
+
cleanPackageJson: true,
|
|
74
|
+
},
|
|
75
|
+
},`)};export{z as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{b as d}from"./orchestrator.js";const k=async({logger:c,options:o,workspaceRoot:p})=>{const l=p??process.cwd(),t=await d({channel:o.channel,cwd:l,firstRelease:o.firstRelease===!0,skipRegistryLookup:!0}),{printConfigIfRequested:f}=await import("./print-config.js");if(f(o,t,c))return;const s=o.package,i=s?t.plan.releases.filter(e=>e.name===s):t.plan.releases;if(i.length===0){if(s!==void 0&&s!==""){const e=new Set(t.plan.releases.map(a=>a.name)).has(s),r=t.packages.some(a=>a.name===s);let n;if(e)n=`release plan unexpectedly empty for "${s}"`;else if(r)n=`package "${s}" is in the workspace but has no pending release (no change file targets it).`;else{const a=t.packages.slice(0,5).map(u=>u.name).join(", "),m=a?` Known workspace packages: ${a}${t.packages.length>5?", …":""}.`:"";n=`package "${s}" is not in this workspace.${m}`}c.error(`--package filter matched no releases: ${n}`),o.json&&process.stdout.write(`${JSON.stringify({error:n},null,2)}
|
|
2
|
+
`),process.exitCode=1;return}o.json&&process.stdout.write(`{}
|
|
3
|
+
`);return}if(o.json){const e={};for(const r of i)e[r.name]={from:r.oldVersion,to:r.newVersion};process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
4
|
+
`);return}const g=[...i].sort((e,r)=>e.name.localeCompare(r.name));for(const e of g)process.stdout.write(`${e.name} ${e.oldVersion} -> ${e.newVersion}
|
|
5
|
+
`)};export{k as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{createRequire as k}from"node:module";import{b as N}from"./orchestrator.js";import{createShellRunner as v}from"./shell-runner.js";const b=k(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,r]=g.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return g.getBuiltinModule(e)}return b(e)},{resolve:A}=$("node:path"),x=["test"],C=e=>e===void 0||e===""?"test":x.includes(e)?e:void 0,w=e=>e==null?[]:Array.isArray(e)?e:[e],S=async(e,o)=>{const r=v();let i,n;try{const{createRemoteClient:u,detectRemoteProvider:l}=await import("./detect2.js"),c=await l(o,r,void 0);i=await u(c,{}).detectRepoSlug(o,r)}catch{}try{n=JSON.parse(await e.readFile(`${o}/package.json`,"utf8")).name}catch{}const p=n?`${n.startsWith("@")?n:`@${n}`}/example`:"@scope/example",s=i?`https://github.com/${i}/releases/tag/v1.0.0`:"https://github.com/example/example/releases/tag/v1.0.0";return{channel:"latest",completedAt:new Date().toISOString(),...n===void 0?{}:{monorepoName:n},published:[{name:p,tag:"latest",url:s,version:"1.0.0"}],...i===void 0?{}:{repo:i},skipped:[]}},j=(e,o)=>o?o.includes(":")?e===o:e===o||e.startsWith(`${o}:`):!0,_=async e=>{const o=[],r=[];if(!e)return{channels:o,pluginFailures:r};const{SlackNotificationChannel:i}=await import("./slack.js");for(const s of w(e.slack))o.push(new i(s));const{DiscordNotificationChannel:n}=await import("./discord.js");for(const s of w(e.discord))o.push(new n(s));const{WebhookNotificationChannel:p}=await import("./webhook.js");for(const s of w(e.webhook))o.push(new p(s));if(e.plugins&&e.plugins.length>0){const{pathToFileURL:s}=await import("node:url"),{dynamicEsmImport:u}=await import("./dynamic-import.js");for(const l of e.plugins){const[c,h]=Array.isArray(l)?l:[l,void 0],m=c;try{const d=c.startsWith(".")?s(`${process.cwd()}/${c}`).href:c,f=await u(d),t=f.default??f;let a;typeof t=="function"?a=t(h):t&&typeof t=="object"&&typeof t.send=="function"&&(a=t),a&&typeof a=="object"&&typeof a.send=="function"?o.push(a):r.push({error:"did not export a NotificationChannel (object with .send) or a factory returning one",id:m})}catch(d){r.push({error:d.message,id:m})}}}return{channels:o,pluginFailures:r}},R=async(e,o)=>{try{return await e.send(o),{id:e.id,ok:!0}}catch(r){const i=r instanceof Error?r.message:String(r),{redactTokens:n}=await import("./security.js");return{error:n(i),id:e.id,ok:!1}}},F=async(e,o)=>{const r=A(process.cwd(),o),i=await e.readFile(r,"utf8"),n=JSON.parse(i);return{channel:n.channel,completedAt:n.completedAt??new Date().toISOString(),...n.monorepoName===void 0?{}:{monorepoName:n.monorepoName},published:Array.isArray(n.published)?n.published:[],...n.repo===void 0?{}:{repo:n.repo},skipped:Array.isArray(n.skipped)?n.skipped:[]}},D=async({fs:e,logger:o,options:r,workspaceRoot:i})=>{const n=i??process.cwd();if(C(r.action)===void 0){o.error(`Unknown action "${r.action}". Expected: test.`),process.exitCode=1;return}let p;try{p=await N({cwd:n,skipRegistryLookup:!0})}catch(t){o.error(`Failed to load release context: ${t instanceof Error?t.message:String(t)}`),process.exitCode=1;return}const s=p.config.notifications;if(!(s&&(s.slack&&(!Array.isArray(s.slack)||s.slack.length>0)||s.discord&&(!Array.isArray(s.discord)||s.discord.length>0)||s.webhook&&(!Array.isArray(s.webhook)||s.webhook.length>0)||s.plugins&&s.plugins.length>0))){const t={channels:[],hint:"No notifications configured. Add `release.notifications.{slack,discord,webhook,plugins}` to vis.config.ts.",ok:!0};r.json?process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
2
|
+
`):o.info(t.hint);return}let u;try{u=r.customContext?await F(e,r.customContext):await S(e,n)}catch(t){o.error(`Could not load NotificationContext: ${t.message}`),process.exitCode=1;return}const{channels:l,pluginFailures:c}=await _(s),h=r.channel,m=l.filter(t=>j(t.id,h));if(m.length===0&&c.length===0){const t=h?`No channels matched filter "${h}". Configured ids: ${l.map(a=>a.id).join(", ")||"(none)"}.`:"No channels could be materialised from the configured notifications block.";r.json?process.stdout.write(`${JSON.stringify({channels:[],hint:t,ok:!1},null,2)}
|
|
3
|
+
`):o.error(t),process.exitCode=1;return}const d=[...await Promise.all(m.map(t=>R(t,u))),...c.map(t=>({error:`plugin load failed: ${t.error}`,id:t.id,ok:!1}))],f=d.filter(t=>!t.ok);if(r.json)process.stdout.write(`${JSON.stringify({channels:d,ok:f.length===0},null,2)}
|
|
4
|
+
`);else{for(const y of d)y.ok?o.info(` ${y.id} OK`):o.error(` ${y.id} FAIL — ${y.error??"unknown error"}`);const t=d.length,a=t-f.length;o.info(""),o.info(`Dispatched ${a}/${t} channel${t===1?"":"s"}.`)}f.length>0&&(process.exitCode=1)};export{D as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as y}from"node:module";import{DEFAULT_CHANGES_DIR as j}from"./DEFAULT_CLEAN_KEEP.js";import{b as C,f as T}from"./orchestrator.js";import{a as x}from"../packem_shared/slug-DoueYuLo.js";import B from"./handler44.js";const k=y(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[t,o]=l.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return l.getBuiltinModule(e)}return k(e)},{join:h}=_("node:path"),f=["none","patch","minor","major"],g=(e,t)=>{const o=f.indexOf(e)+t;return f[Math.min(Math.max(o,0),f.length-1)]??e},v=e=>e.chosen!==e.release.type,R=(e,t)=>{const o=[];e.isCascadeBump&&o.push("cascade"),e.isGroupBump&&o.push("group"),e.isDependencyBump&&!e.isCascadeBump&&o.push("dep-bump");const r=o.length>0?` [${o.join(", ")}]`:"";return`${e.name}: ${e.oldVersion} → ${e.newVersion} (${t})${r}`},q=async e=>{const{selectPrompt:t}=await import("./prompts.js");process.stdout.write(`
|
|
2
|
+
${R(e,e.type)}
|
|
3
|
+
`);const o=await t("Action?",[{label:"accept (keep as-is)",value:"accept"},{label:"promote (bump up one level)",value:"promote"},{label:"demote (bump down one level)",value:"demote"},{label:"set explicitly (major | minor | patch | none)",value:"set"},{label:"skip this package",value:"skip"}]);return o==="promote"?g(e.type,1):o==="demote"?g(e.type,-1):o==="skip"?"none":o==="set"?t("Set bump level to?",[{label:"major",value:"major"},{label:"minor",value:"minor"},{label:"patch",value:"patch"},{label:"none (skip)",value:"none"}]):e.type},D=async e=>{const t=[];for(const o of e)t.push({chosen:await q(o),release:o});return t},N=async(e,t,o,r,c)=>{const i={};for(const s of r)s.chosen!=="none"&&(i[s.release.name]=s.chosen);const n=h(t,o,`${x("plan")}.md`),u={bumps:i};return await e.mkdir(h(t,o),{recursive:!0}),await e.writeFile(n,T(u,c)),n},S=async e=>{const{fs:t,logger:o,options:r,workspaceRoot:c}=e,i=c??process.cwd();if(!process.stdout.isTTY){o.error("--interactive requires a TTY. Drop the flag to get JSON output."),process.exitCode=1;return}const n=await C({channel:r.channel,cwd:i,skipRegistryLookup:!0}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(r,n,o))return;const{releases:s}=n.plan;if(s.length===0){o.info("No pending releases.");return}n.channel&&o.info(`Channel: ${n.channel.tag}${n.channel.prerelease?` (preid: ${n.channel.prerelease})`:""} | mode: ${n.channel.mode}`),o.info(`Walking through ${s.length} pending release(s). Press Ctrl-C to abort.`);const p=await D(s),m=p.filter(a=>v(a)).length,w=p.filter(a=>a.chosen==="none").length;o.info(""),o.info("Summary:");for(const a of p){const d=v(a)?` (was ${a.release.type})`:"";o.info(` ${a.release.name}: ${a.chosen}${d}`)}if(o.info(""),o.info(`${m} overridden, ${w} skipped, ${p.length-m} accepted as-is.`),r.write){if(m===0){o.info("Nothing to write — every package was accepted as-is.");return}const{textPrompt:a}=await import("./prompts.js"),d=await a("Changelog body for the override change file:","Operator-driven plan adjustment via `vis release plan -i`."),b=n.config.changesDir??j,$=await N(t,i,b,p,d);o.info(`Wrote ${$}`)}},L=async e=>{if(e.options.interactive){await S(e);return}await B({...e,options:{...e.options,bump:void 0,json:!0}})};export{L as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as m}from"./orchestrator.js";const u=a=>a==="major"||a==="minor"||a==="patch"||a==="none",d=async({logger:a,options:i,workspaceRoot:p})=>{const l=p??process.cwd();let r;try{r=await m({channel:i.channel,cwd:l,skipRegistryLookup:!0})}catch(e){a.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:c}=await import("./print-config.js");if(c(i,r,a))return;let{releases:o}=r.plan;if(i.bump){const e=i.bump.split(",").map(n=>n.trim()).filter(u);e.length>0&&(o=o.filter(n=>e.includes(n.type)))}if(i.filter){const e=(await import("./index.js")).default;o=o.filter(n=>e(i.filter,n.name))}if(i.json){const e={branch:r.branch,channel:r.channel,consumedChangeFiles:r.plan.consumedChangeFiles.map(n=>n.path),releases:o.map(n=>({isCascadeBump:n.isCascadeBump,isDependencyBump:n.isDependencyBump,isGroupBump:n.isGroupBump,name:n.name,newVersion:n.newVersion,oldVersion:n.oldVersion,reasons:n.reasons,type:n.type})),warnings:r.plan.warnings};process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
2
|
+
`),o.length===0&&(process.exitCode=1);return}if(o.length===0){if(a.info("No pending releases."),r.plan.warnings.length>0){a.warn(`${r.plan.warnings.length} warning(s):`);for(const e of r.plan.warnings)a.warn(` - ${e}`)}process.exitCode=1;return}r.channel&&a.info(`Channel: ${r.channel.tag}${r.channel.prerelease?` (preid: ${r.channel.prerelease})`:""} | mode: ${r.channel.mode}`),a.info(`${o.length} package(s) pending release:`),a.info("");const t={major:[],minor:[],none:[],patch:[]};for(const e of o)t[e.type].push(e);for(const e of["major","minor","patch"])if(t[e].length!==0){a.info(` ${e.toUpperCase()}:`);for(const n of t[e]){const s=[];n.isCascadeBump&&s.push("cascade"),n.isGroupBump&&s.push("group"),n.isDependencyBump&&!n.isCascadeBump&&s.push("dep-bump");const f=s.length>0?` [${s.join(", ")}]`:"";a.info(` ${n.name}: ${n.oldVersion} → ${n.newVersion}${f}`)}}if(r.plan.warnings.length>0){a.info(""),a.warn(`${r.plan.warnings.length} warning(s):`);for(const e of r.plan.warnings)a.warn(` - ${e}`)}};export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_CHANGES_DIR as l}from"./DEFAULT_CLEAN_KEEP.js";import{stageAndCommitFile as g}from"./git.js";import{b as d}from"./orchestrator.js";import{readPreMode as m,buildEnterFile as w,writePreMode as u,preModeFilePath as $}from"./pre-mode.js";import{createShellRunner as h}from"./shell-runner.js";import{VisReleaseError as x}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const v=["enter","exit","status"],k=t=>t===void 0||t===""?"status":v.includes(t)?t:void 0,C=async(t,i,r)=>{const e=i.tag?.[0];if(!e){r.error("`pre enter` requires a tag, e.g.: vis release pre enter alpha"),process.exitCode=1;return}const o=await d({cwd:t,skipRegistryLookup:!0}),s=o.config.changesDir??l,p=await m(t,s);if(p){r.error(`Already in pre-mode (tag "${p.tag}", mode "${p.mode}"). Run \`vis release pre exit\` first if you want to switch tags.`),process.exitCode=1;return}const a=w(e,o.packages.map(c=>({name:c.name,version:c.version}))),n=await u(t,s,a);if(r.info(`Entered pre-mode with tag "${e}". ${Object.keys(a.initialVersions).length} package version(s) snapshot.`),i.commit===!1)r.info(`Run \`git add ${n} && git commit -m 'chore(release): enter pre-mode (${e}) [skip ci]'\` so CI sees the state.`);else{const c=h();try{await g({cwd:t,runner:c},n,`chore(release): enter pre-mode (${e}) [skip ci]`,{author:o.config.gitUser,push:i.push!==!1,sign:o.config.gitSignCommits===!0}),r.info(`Committed ${n}${i.push===!1?"":" + pushed"}.`)}catch(f){r.warn(`Could not commit ${n}: ${f.message}`)}}},y=async(t,i,r)=>{const e=await d({cwd:t,skipRegistryLookup:!0}),o=e.config.changesDir??l,s=await m(t,o);if(!s){r.error("Not in pre-mode. Nothing to exit."),process.exitCode=1;return}if(s.mode==="exit-pending"){r.info("Pre-mode already in `exit-pending` state. Run `vis release version` to consolidate.");return}if(e.channel?.prerelease!==void 0)throw new x({code:"CONFIG_INVALID",hint:`Switch to a non-prerelease branch (one whose channel has no \`prerelease\` set) before running \`vis release pre exit\`, or stay in pre-mode by skipping the exit. Current channel "${e.channel.tag}" pins prerelease "${e.channel.prerelease}".`,message:`Refusing to exit pre-mode: the active channel "${e.channel.tag}" has its own prerelease identifier "${e.channel.prerelease}". Exiting would create an unrecoverable state — the next \`vis release version\` would still produce a prerelease via the channel, but the cleanup would delete pre.json making retry impossible.`});const p={...s,mode:"exit-pending"},a=await u(t,o,p);if(r.info("Pre-mode flagged for exit. The next `vis release version` will consolidate the prereleases and delete pre.json."),i.commit!==!1){const n=h();try{await g({cwd:t,runner:n},a,`chore(release): exit pre-mode (was ${s.tag}) [skip ci]`,{author:e.config.gitUser,push:i.push!==!1,sign:e.config.gitSignCommits===!0}),r.info(`Committed ${a}${i.push===!1?"":" + pushed"}.`)}catch(c){r.warn(`Could not commit ${a}: ${c.message}`)}}},b=async(t,i)=>{const r=(await d({cwd:t,skipRegistryLookup:!0})).config.changesDir??l,e=await m(t,r);if(!e){i.info("Pre-mode: off.");return}i.info(`Pre-mode: ${e.mode==="pre"?"ACTIVE":"EXIT-PENDING"} (tag "${e.tag}", entered ${e.enteredAt})`),i.info(` → ${$(t,r)}`),i.info(` → ${Object.keys(e.initialVersions).length} package version(s) snapshot at enter time.`)},N=async({logger:t,options:i,workspaceRoot:r})=>{const e=r??process.cwd(),o=k(i.action);if(o===void 0){t.error(`Unknown action "${i.action}". Expected one of: enter, exit, status.`),process.exitCode=1;return}if(o==="enter"){await C(e,i,t);return}if(o==="exit"){await y(e,i,t);return}await b(e,t)};export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u,p as $}from"./orchestrator.js";import{VisReleaseError as m}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const x=async({logger:s,options:r,workspaceRoot:l})=>{const p=l??process.cwd(),o=r.dryRun===!0;let n;try{n=await u({channel:r.channel,cwd:p,firstRelease:r.firstRelease===!0,projects:r.filter?r.filter.split(",").map(e=>e.trim()).filter(Boolean):void 0})}catch(e){s.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:h}=await import("./print-config.js");if(h(r,n,s))return;if(r.checkOnly===!0){if(s.info(`Preflight: ${n.plan.releases.length} pending publish(es)${n.channel?` to dist-tag "${n.channel.tag}"`:""}.`),n.plan.warnings.length>0)for(const e of n.plan.warnings)s.warn(` - ${e}`);process.exitCode=n.plan.releases.length===0?1:0;return}if(n.plan.releases.length===0){s.info("No pending releases — nothing to publish.");return}const i=r.tag??n.channel?.tag;i||s.warn("No --tag provided and no channel matched the current branch. Defaulting to dist-tag 'latest'. Set channels in vis.config.ts to control this."),s.info(`${o?"[dry-run] would publish":"Publishing"} ${n.plan.releases.length} package(s) to dist-tag "${i??"latest"}"${o?"":"..."}`);let t;try{t=await $(n,{dryRun:o,noPush:r.noPush===!0,otp:r.otp,resume:r.resume===!0,tag:i})}catch(e){if(e instanceof m&&e.code==="STAGE_PENDING"){s.error(e.message),e.hint&&(s.info(""),s.info(`Next steps: ${e.hint}`)),process.exitCode=1;return}s.error(`Publish failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}s.info("");for(const e of t.published)s.info(` [published] ${e.name}@${e.version}`);for(const e of t.skipped)e.reason.startsWith("stage-")?s.warn(` [stage] ${e.name} (${e.reason} — re-run \`vis release publish\` once approved)`):s.info(` [skipped] ${e.name} (${e.reason})`);for(const e of t.failed)s.error(` [failed] ${e.name}: ${e.reason}`);s.info(""),s.info(`Published: ${t.published.length} | Skipped: ${t.skipped.length} | Failed: ${t.failed.length}`),t.tags.length>0&&s.info(`Tags created: ${t.tags.length}${t.tagsPushed?" (pushed)":" (NOT pushed — re-run with --resume to retry)"}`),t.failed.length===0?process.exitCode=0:t.published.length===0&&t.skipped.length===0?process.exitCode=3:process.exitCode=2;const a=t.failed.filter(e=>/\bEOTP\b|one[- ]time password|otp/i.test(e.reason));if(a.length>0){s.info(""),s.warn("Publish failed because the registry required a 2FA OTP. Rerun with:");const e=a.map(g=>g.name).join(","),d=r.channel?` --channel=${r.channel}`:"",c=r.tag?` --tag=${r.tag}`:"",f=` --filter='${e}'`;s.info(` vis release publish --otp=REPLACE_WITH_NEW_OTP --resume${c}${d}${f}`)}};export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as p}from"./orchestrator.js";import{runSnapshot as f}from"./snapshot.js";const u=async({logger:r,options:i,workspaceRoot:n})=>{const a=n??process.cwd();if(!i.tag){r.error("--tag is required."),process.exitCode=1;return}const o=i.dryRun===!0,s=await p({cwd:a}),{printConfigIfRequested:d}=await import("./print-config.js");if(d(i,s,r))return;let e;try{e=await f({context:s,dryRun:o,filter:i.filter,registry:i.registry,tag:i.tag})}catch(t){r.error(`Snapshot failed: ${t.message}`),process.exitCode=1;return}r.info(`${o?"[dry-run] would snapshot":"Snapshotting"} at version ${e.snapshotVersion} → tag "${e.tag}"`);for(const t of e.published)r.info(` ${o?"[dry-run] ":"[published]"} ${t.name}@${t.version}`);for(const t of e.skipped)r.info(` [skipped] ${t.name} (${t.reason})`);for(const t of e.failed)r.error(` [failed] ${t.name}: ${t.reason}`);r.info(""),r.info(`Published: ${e.published.length} | Skipped: ${e.skipped.length} | Failed: ${e.failed.length}`),process.exitCode=e.failed.length>0?2:0};export{u as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{DEFAULT_CHANGES_DIR as u}from"./DEFAULT_CLEAN_KEEP.js";import{b as m}from"./orchestrator.js";import{createShellRunner as $}from"./shell-runner.js";import{readStagedRegistry as v,removePendingStages as y,writeStagedRegistry as C}from"./staged-registry.js";import{acquireLock as x,releaseLock as S}from"./state.js";const j=["approve","list","reject"],k=t=>t===void 0||t===""?"list":j.includes(t)?t:void 0,A=async(t,r,o,s)=>{const i=["stage","list","--json"],d=o.stageIds?.[0],n=o.filter??d;n&&i.push(n);const p=await t.run("npm",i,{cwd:r,silent:!0}),c=await m({cwd:r}),a=await v(r,c.config.changesDir??u),f=n?{pending:a.pending.filter(e=>e.name===n)}:a;let g=[];if(p.exitCode===0&&p.stdout.trim())try{g=JSON.parse(p.stdout)}catch{process.stdout.write(`${p.stdout}
|
|
2
|
+
`)}if(o.json){process.stdout.write(`${JSON.stringify({npm:g,registry:f.pending},null,2)}
|
|
3
|
+
`);return}if(g.length===0&&f.pending.length===0){s.info("No staged versions awaiting approval.");return}const h=new Set(g.map(e=>e.id).filter(Boolean)),l=new Set(f.pending.map(e=>e.id));for(const e of g){const w=l.has(e.id??"")?"":" [npm-only]";s.info(` ${e.id??"<no-id>"} ${e.package??"?"}@${e.version??"?"} → ${e.tag??"latest"}${w}`)}for(const e of f.pending)h.has(e.id)||s.info(` ${e.id} ${e.name}@${e.version} → ${e.tag??"latest"} [registry-only, ${e.reason}]`)},b=async(t,r,o)=>{if(r.all){const i=await m({cwd:t}),d=await v(t,i.config.changesDir??u);if(d.pending.length===0){o.error("No pending stages in .vis/release/staged.json. Approve manually with explicit ids, or rerun `vis release publish` with publish.stage: true.");return}return d.pending.map(n=>n.id)}const s=r.stageIds??[];if(s.length===0){o.error("Pass stage ids positionally, or use --all to approve every pending stage in .vis/release/staged.json.");return}return s},E=async(t,r,o,s,i)=>{const d=t==="approve"?await b(o,s,i):s.stageIds;if(!d||d.length===0){t==="reject"&&i.error("Pass stage ids positionally to reject."),process.exitCode=1;return}const n=[],p=[];for(const c of d){const a=await r.run("npm",["stage",t,c],{cwd:o,silent:!1});a.exitCode===0?n.push(c):p.push({id:c,reason:a.stderr.trim()||`exit ${a.exitCode}`})}if(i.info(""),n.length>0){i.info(`${t==="approve"?"Approved":"Rejected"} ${n.length} stage(s).`);let c=[];try{const a=await m({cwd:o}),f=a.config.changesDir??u,g=await v(o,f);if(t==="reject"){const l=new Set(n);c=g.pending.filter(e=>l.has(e.id)).map(e=>({name:e.name,version:e.version}))}const h=y(g,n);if(h!==g){const l=await C(o,f,h);if(l.changed&&s.commit!==!1){const{stageAndCommitFile:e}=await import("./git.js"),w=l.removed?"chore(release): clear pending stage registry [skip ci]":`chore(release): ${t} ${n.length} stage${n.length===1?"":"s"} [skip ci]`;await e({cwd:o,runner:r},l.path,w,{author:a.config.gitUser,push:s.push!==!1,sign:a.config.gitSignCommits===!0}),i.info(`Updated ${l.path} and committed${s.push===!1?"":" + pushed"}.`)}else l.changed&&i.info(`Updated ${l.path}. Commit + push it so the next release wave sees the resolved state.`)}}catch(a){i.warn(`Could not update staged registry: ${a.message}`)}if(c.length>0){i.info(""),i.info("Orphan CHANGELOG sections to review:");for(const a of c)i.info(` Edit CHANGELOG.md for ${a.name} to remove the orphan ${a.version} section before the next wave`);i.info("(Workspace CHANGELOG.md is unaffected — its wave entry is written from the publish phase against actually-published versions.)")}}if(p.length>0){for(const c of p)i.error(` ${c.id}: ${c.reason}`);process.exitCode=1}},R=async({logger:t,options:r,workspaceRoot:o})=>{const s=o??process.cwd(),i=k(r.action);if(i===void 0){t.error(`Unknown action "${r.action}". Expected one of: list, approve, reject.`),process.exitCode=1;return}const d=$();if(i==="list"){await A(d,s,r,t);return}let n,p=!1;if(r.commit!==!1)try{n=(await m({cwd:s})).config.changesDir??u,await x(s,n),p=!0}catch(c){t.error(`Could not acquire release lock: ${c.message}`),process.exitCode=1;return}try{await E(i,d,s,r,t)}finally{p&&n&&await S(s,n)}};export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as f,a as c}from"./orchestrator.js";import{VisReleaseError as d}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const p=async({logger:e,options:t,workspaceRoot:l})=>{const a=l??process.cwd(),r=t.dryRun===!0,o=await f({channel:t.channel,cwd:a,firstRelease:t.firstRelease===!0,projects:t.filter?t.filter.split(",").map(n=>n.trim()).filter(Boolean):void 0}),{printConfigIfRequested:s}=await import("./print-config.js");if(s(t,o,e))return;if(t.checkOnly===!0){if(e.info(`Preflight: ${o.plan.releases.length} pending release(s)${o.channel?` on channel "${o.channel.tag}"`:""}.`),o.plan.warnings.length>0)for(const n of o.plan.warnings)e.warn(` - ${n}`);process.exitCode=o.plan.releases.length===0?1:0;return}if(o.plan.releases.length===0){e.info("No pending releases — nothing to version."),process.exitCode=0;return}o.channel&&e.info(`Channel: ${o.channel.tag}${o.channel.prerelease?` (preid: ${o.channel.prerelease})`:""}`),e.info(`${r?"[dry-run] would version":"Versioning"} ${o.plan.releases.length} package(s)...`);for(const n of o.plan.releases)e.info(` ${n.name}: ${n.oldVersion} → ${n.newVersion}`);let i;try{i=await c(o,{commit:t.commit===!0,dryRun:r})}catch(n){if(n instanceof d&&n.code==="STAGE_PENDING"){e.error(n.message),n.hint&&(e.info(""),e.info(`Next steps: ${n.hint}`)),process.exitCode=1;return}throw n}if(r){e.info(""),e.info(`[dry-run] would write ${i.changedFiles.length} file(s):`);for(const n of i.changedFiles)e.info(` ${n}`);if(i.deletedFiles.length>0){e.info(`[dry-run] would delete ${i.deletedFiles.length} change file(s):`);for(const n of i.deletedFiles)e.info(` ${n}`)}e.info(""),e.info("Dry run complete. No changes made.")}else e.info(""),e.info(`Wrote ${i.changedFiles.length} file(s); deleted ${i.deletedFiles.length} consumed change file(s).`),i.commitSha?e.info(`Committed as ${i.commitSha.slice(0,7)}.`):t.commit&&e.warn("--commit was requested but no commit was made (likely no changes to commit).");if(o.plan.warnings.length>0){e.info(""),e.warn(`${o.plan.warnings.length} warning(s):`);for(const n of o.plan.warnings)e.warn(` - ${n}`)}};export{p as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{createRequire as A}from"node:module";import{w as G,k as H,p,P as J,j as V,R as W,l as S,c as K,V as Z,$ as T,d as a,h as Q,m as g,H as M,o as X,G as ee,r as te,B as oe,F as m}from"./bin.js";import"../packem_shared/index-BDmTbWX1.js";import"../packem_shared/public-api-WqUCiyIe.js";import{K as se,Z as re,W as ne}from"../packem_shared/ai-analysis-BUeX2J2H.js";import{w as ie}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-k3fDxech.js";const de=A(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const $e=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=ie(d);if(G(i??{},t.name),e.sync&&t.name==="pnpm"){const s=H(i??{});if(s.length>0){p.info(`
|
|
2
|
+
Settings that would sync to pnpm-workspace.yaml:`);for(const b of s)p.success(` ${b}`)}else p.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(p.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),p.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!E?.length)return}const{packageManager:U}=J(d),B=V(d),c=i?.update??{},y=W(d,U,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const h=e.target??c.target??"latest";if(!["latest","minor","patch"].includes(h))throw new Error(`Invalid target "${h}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(c.exclude)],ignore:m(c.ignore),include:[...m(e.include),...m(c.include),...E],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:h};let j=0;for(const t of y.values())j+=t.size;const $=!!process.stdout.isTTY&&!te;let l;const F=$?(t,s)=>{l?l.rerender(a.createElement(N,{current:t,total:s})):l=T(a.createElement(N,{current:t,total:s}),{interactive:!0,patchConsole:!1})}:(t,s)=>{o.info(`Checking ${String(t)}/${String(s)} dependencies...`)};$||o.info(`Checking ${String(j)} catalog dependencies against npm registry...
|
|
3
|
+
`);const w=new Set;S("socket")&&w.add("socket"),S("depsDev")&&w.add("deps-dev");const v=i?.security?.policies?.score?.minimum,I=K(i?.security,{disabled:w,minimumScore:v}),{failed:k,outdated:n}=await Z(y,D,B,F,d,I,i?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),k.length>0&&o.warn(`Failed to fetch: ${k.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const R=e.format??c.format??"table",P=se(e.aiType??"impact"),u=e.ai?await re(n,o,i?.ai,P):void 0;if($&&R==="table"){const t=new ae(n,u??null),s=i?.tui?.autoExit??!1,b=s===!0?3:typeof s=="number"?s:0;await T(a.createElement(ce,{autoExitSeconds:b,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
|
|
4
|
+
`);for(const r of n){const z=r.vulnerabilities?.length||r.socketReport&&r.socketReport.alerts.length>0,_=!!r.acceptedRisk,L=z?_?"✓":"⚠":"✓",O=_?"gray":r.updateType==="major"?"red":r.updateType==="minor"?"yellow":"green",f=r.socketReport?.score.overall,Y=f===void 0?"":` [${String(Math.round(f*100))}%]`,x=f===void 0?void 0:oe(f);process.stdout.write(`${Q(a.createElement(g,null," ",a.createElement(g,{color:O},L),` ${r.packageName} ${r.currentRange} → ${r.newRange}`,a.createElement(g,{dimColor:!0},` ${r.updateType}`),x?a.createElement(g,{color:x},Y):null),{columns:q})}
|
|
5
|
+
`)}process.stdout.write(`
|
|
6
|
+
`),o.info(M(n,v))}else if(R==="json"){const t={failed:k,outdated:n};u&&(t.aiAnalysis=u),process.stdout.write(`${JSON.stringify(t,void 0,2)}
|
|
7
|
+
`)}else R==="minimal"?process.stdout.write(`${X(n)}
|
|
8
|
+
`):(ee(n,o),o.info(M(n,v)),u&&(o.info(""),o.info(ne(u))));e.exitCode&&n.length>0&&(process.exitCode=1)};export{$e as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createRequire as $}from"node:module";import{N as y,R as l,S as d,h as b}from"../packem_shared/ai-analysis-BUeX2J2H.js";import{h as x,d as w,e as _}from"./bin.js";import{j as S,E as p,q as j,I as E,s as I}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";const C=$(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const u={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},N=e=>{if(typeof e!="function")return String(e);const{name:t}=e;return t==="Boolean"?"boolean":t==="Number"?"number":t==="String"?"string":t??"unknown"},R=e=>{const t=[...e.commandPath??[],e.name].join(" "),i=(e.examples??[]).map(([o,r])=>({command:o??"",description:r??""})),n=(e.options??[]).map(o=>({defaultValue:o.defaultValue,description:o.description,name:o.name,type:N(o.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:i,name:e.name,options:n,path:t}},f=(e,t=u)=>({command:t.command,description:t.description,subcommands:e.map(i=>R(i))}),P=(e,t=u)=>`${JSON.stringify(f(e,t),void 0,2)}
|
|
2
|
+
`,T=(e,t=u)=>{const i=f(e,t),n=[S(`vis ${i.command} — ${i.description}`),"",p("Subcommands:")];for(const o of i.subcommands){const r=o.argument?` ${j(`<${o.argument.name}>`)}`:"";if(n.push(""),n.push(` ${E(`vis ${o.path}`)}${r}`),o.description&&n.push(` ${o.description}`),o.options.length>0){const s=o.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");n.push(p(` options: ${s}`))}if(o.examples.length>0){n.push(p(" examples:"));for(const s of o.examples){const c=s.description?p(` — ${s.description}`):"";n.push(` ${I(s.command)}${c}`)}}}return n.push(""),n.push(p(`Run \`vis ${i.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),n.push(p(`Run \`vis ${i.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${n.join(`
|
|
3
|
+
`)}
|
|
4
|
+
`},h=async()=>{const{default:e}=await import("./bin.js").then(t=>t.bw);return e.filter(t=>t.name!=="ai")},O=async()=>{const e=await h();process.stderr.write(T(e))},B=async()=>{const e=await h();process.stdout.write(P(e))},F=async({logger:e,visConfig:t})=>{const i=t?.ai,n=l(i);if(!n){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${n.name}...`);try{const o=await b(n,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${n.name} responded: ${o.stdout.trim().slice(0,200)}`)}catch(o){const r=o instanceof Error?o.message:String(o);e.error(`Provider ${n.name} failed: ${r}`),process.exitCode=1}},V=({logger:e,options:t,visConfig:i})=>{const n=t.format??"table",o=i?.ai,r=y(),s=l(o);if(n==="json"){const a=r.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:d[m.name]??0,selected:m.name===s?.name,version:m.version}));process.stdout.write(`${JSON.stringify(a,void 0,2)}
|
|
5
|
+
`);return}const c=r.map(a=>({method:a.detectionMethod??"-",path:a.path??"-",priority:String(d[a.name]??0),provider:a.name,selected:a.name===s?.name?">>>":"",status:a.available?"available":"not found",version:a.version??"-"})),g=process.stdout.columns||80,v=x(w.createElement(_,{data:c}),{columns:g});e.info(v),s?e.info(`
|
|
6
|
+
Selected provider: ${s.name} (priority ${String(d[s.name]??0)})`):e.info(`
|
|
7
|
+
No AI provider available. Install one of the supported AI CLI tools.`)},k=async e=>{const{aiFix:t}=await import("./fix.js");await t(e)};export{B as aiDiscoverHelpExecute,k as aiFixExecute,V as aiProvidersExecute,O as aiRootExecute,F as aiTestExecute};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import{createRequire as N}from"node:module";import{f as D,v as O,T as w}from"../packem_shared/index-BDmTbWX1.js";import{b as V}from"./config.js";import{p as e}from"./bin.js";import{w as q}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{W as A}from"../packem_shared/build-scripts-CCCi8U66.js";import{O as F}from"../packem_shared/native-config-sync-BEkJW7g3.js";const R=N(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=l=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(l)}return R(l)},{spawnSync:T}=C("node:child_process"),M=/(defineConfig\s*\(\s*\{)/,W=/(export\s+default\s+\{)/,v=(l,t)=>`${t}${JSON.stringify(l)}: true,`,B=(l,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=V(l);if(!s)return{added:[],skipped:t,status:"no-config"};if(!D(s))return{added:[],skipped:t,status:"no-config"};const i=O(s),h=i.search(/installScripts\s*:\s*\{/);let a=null,r=0;if(h!==-1){const c=i.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(c);d?.index!==void 0&&(a=d,r=h+d.index)}if(a){const c=a[2]??"",d=new Set;for(const g of c.matchAll(/["']([^"']+)["']\s*:/g))d.add(g[1]);for(const g of c.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))d.add(g[1]);const u=[],k=[];for(const g of t)d.has(g)?k.push(g):u.push(g);if(u.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const x=/\n([ \t]+)\S/.exec(c)?.[1]??" ",_=`
|
|
2
|
+
${u.map(g=>v(g,x)).join(`
|
|
3
|
+
`)}`,y=c.replace(/\s+$/,""),S=c.slice(y.length),j=`${y}${y.endsWith(",")||y===""?"":","}${_}${S.length>0?S:`
|
|
4
|
+
`}`,P=`${i.slice(0,r)}${a[1]}${j}${a[3]}${i.slice(r+a[0].length)}`;return w(s,P),{added:u,configPath:s,skipped:k,status:"updated"}}const n=/(installScripts\s*:\s*\{)/;if(n.test(i)){const c=`
|
|
5
|
+
allow: {
|
|
6
|
+
${t.map(u=>v(u," ")).join(`
|
|
7
|
+
`)}
|
|
8
|
+
},`,d=i.replace(n,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const o=/(policies\s*:\s*\{)/;if(o.test(i)){const c=`
|
|
9
|
+
installScripts: {
|
|
10
|
+
allow: {
|
|
11
|
+
${t.map(u=>v(u," ")).join(`
|
|
12
|
+
`)}
|
|
13
|
+
},
|
|
14
|
+
},`,d=i.replace(o,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const f=/(security\s*:\s*\{)/;if(f.test(i)){const c=`
|
|
15
|
+
policies: {
|
|
16
|
+
installScripts: {
|
|
17
|
+
allow: {
|
|
18
|
+
${t.map(u=>v(u," ")).join(`
|
|
19
|
+
`)}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},`,d=i.replace(f,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const p=M.exec(i)??W.exec(i);if(!p)return{added:[],configPath:s,skipped:t,status:"missing-anchor"};const m=`
|
|
23
|
+
security: {
|
|
24
|
+
policies: {
|
|
25
|
+
installScripts: {
|
|
26
|
+
allow: {
|
|
27
|
+
${t.map(c=>v(c," ")).join(`
|
|
28
|
+
`)}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},`,b=`${i.slice(0,p.index+p[0].length)}${m}${i.slice(p.index+p[0].length)}`;return w(s,b),{added:t,configPath:s,skipped:[],status:"updated"}},L=async({options:l,visConfig:t,workspaceRoot:s})=>{const i=s??process.cwd(),h=q(i);if(h.name==="pnpm"&&!l.scan){e.info("Delegating to pnpm approve-builds...");const a=["approve-builds"];l.all&&a.push("--all");const r=T("pnpm",a,{cwd:i,stdio:"inherit"});if(r.error)throw new Error(`Failed to run pnpm approve-builds: ${r.error.message}`);if(r.status!==0&&r.status!==null&&(e.error(`pnpm approve-builds exited with code ${r.status}`),process.exitCode=r.status),!l.syncNative){e.notice(""),e.notice("Tip: vis.config.ts security.policies.installScripts.allow may now be out of sync with pnpm-workspace.yaml."),e.notice("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const a=t?.security?.policies?.installScripts?.allow??{},r=t?.security?.pinVersions===!0,n=A(i,a,{pinVersions:r});if(n.unapproved.length===0)e.success("No unapproved build scripts found."),l.write&&(e.info(""),e.info("Nothing to write — there are no unapproved build scripts."));else{e.warn(`Found ${n.unapproved.length} package${n.unapproved.length===1?"":"s"} with unapproved build scripts:
|
|
33
|
+
`);for(const o of n.unapproved)e.info(` ${o.name} (${o.hooks.join(", ")})`);e.notice(""),e.notice("To approve these packages, add them to vis.config.ts:"),e.notice(""),e.notice(" security: {"),e.notice(" policies: {"),e.notice(" installScripts: {"),e.notice(" allow: {");for(const o of n.unapproved){const f=r&&o.version?`${o.name}@${o.version}`:o.name;e.notice(` "${f}": true,`)}if(e.notice(" },"),e.notice(" },"),e.notice(" },"),e.notice(" },"),h.name==="pnpm"&&(e.notice(""),e.notice("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly.")),l.write){const o=t?.security?.pinVersions===!0,f=n.unapproved.map(m=>o&&m.version?`${m.name}@${m.version}`:m.name),p=B(i,f);switch(e.info(""),p.status){case"missing-anchor":{e.warn(`Could not locate 'defineConfig({' or 'export default {' in ${String(p.configPath)} — please add entries manually.`);break}case"no-config":{e.warn("No vis.config.ts found. Run 'vis init' first, then re-run with --write.");break}case"noop":{e.info(`All ${String(f.length)} entr${f.length===1?"y":"ies"} were already present in vis.config.ts security.policies.installScripts.allow.`);break}default:e.success(`Wrote ${String(p.added.length)} entr${p.added.length===1?"y":"ies"} to ${String(p.configPath)}.`),p.skipped.length>0&&e.info(`Skipped ${String(p.skipped.length)} already-present entr${p.skipped.length===1?"y":"ies"}.`)}}}if(n.excess.length>0){e.notice(""),e.warn(`Stale installScripts.allow entries — ${String(n.excess.length)} pattern${n.excess.length===1?"":"s"} no longer match any installed package:`);for(const o of n.excess)e.info(` ${o}`);e.notice("Consider removing these entries from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){e.notice(""),e.warn(`Version drift — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} pinned to an outdated version:`);for(const{from:o,to:f}of n.versionDrift)e.info(` ${o} → ${f}`);e.notice("Rename the keys in vis.config.ts security.policies.installScripts.allow to migrate.")}}if(l.syncNative){const a=t?.security?.policies?.installScripts?.allow??{};if(Object.keys(a).length===0)e.warn("No security.policies.installScripts.allow configured in vis.config.ts. Nothing to sync.");else{const r=F(h.name,i,a);e.info("");for(const n of r)e.success(n)}}};export{L as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as B}from"node:module";import{getAffectedProjects as F}from"@visulima/task-runner";import{b as H,O as T}from"./bin.js";const C=B(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return C(e)},{execFile:D}=A("node:child_process"),{promisify:q}=A("node:util"),P=q(D),G=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],N=["[vis deploy]","[nx deploy]"],U=["vis","nx"],J=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],V=/^[\w./~^@{}][\w.\-/~^@{}]*$/,z=(e=process.env)=>{for(const t of J){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},_=e=>{if(!V.test(e))throw new Error(`Invalid git ref: "${e}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},L=async(e,t)=>{try{return await P("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},W=async e=>{try{const{stdout:t}=await P("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},O=(e,t,r)=>U.some(c=>e.includes(`[${c} ${t} ${r}]`)),Z=(e,t)=>G.some(r=>e.includes(r))||O(e,"skip",t),K=(e,t)=>N.some(r=>e.includes(r))||O(e,"deploy",t),f=(e,t,r,c)=>({action:"build",message:r,project:e,reason:t,...c}),b=(e,t,r,c)=>({action:"skip",message:r,project:e,reason:t,...c}),Q=e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,X=(e,t)=>e.action==="skip"||t?0:1,E=new Set(["deep","direct","none"]),re=async({argument:e,logger:t,options:r,visConfig:c,workspaceRoot:l})=>{const o=e[0]??"",k=!!r.json,R=!!r.verbose,I=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),p=s=>{R&&!k&&t.info(`❱ ${s}`)},n=s=>{k?process.stdout.write(`${JSON.stringify(s)}
|
|
2
|
+
`):t.info(Q(s)),process.exit(X(s,I))};if(!o)return n(f("","missing-project-argument","Missing project argument. Usage: vis ci ignore <project>"));if(!l)return n(f(o,"workspace-error","Could not determine workspace root — building defensively"));const m=await W(l),$=m.trim().split(`
|
|
3
|
+
`)[0]??"";if(p(`commit: ${$}`),m&&K(m,o))return n(f(o,"commit-force-deploy",`Force-deploy keyword in commit: "${$}"`));if(m&&Z(m,o))return n(b(o,"commit-skip",`Skip keyword in commit: "${$}"`));let h,v;try{({packageJsons:v,workspace:h}=H(l,c))}catch(s){const a=s instanceof Error?s.message:String(s);return n(f(o,"workspace-error",`Workspace discovery failed (${a}) — building defensively`))}if(!Object.hasOwn(h.projects,o))return n(f(o,"project-unknown",`Project "${o}" not found in workspace — building defensively`));try{const s=r.base?.trim(),a=z();let i=s||a||"HEAD~1";const u=r.head?.trim()||"HEAD";_(i),_(u),p(`resolved base ref: ${i} (source: ${s?"flag":a?"ci-env":"default"})`);const S=L(l,i),x=T(l,h,v);await S||(p(`base ref ${i} not reachable — falling back to HEAD~1`),i="HEAD~1"),p(`comparing ${i}...${u}`);const w=r.downstream??"deep",y=r.upstream??"none";if(!E.has(w))throw new Error(`Invalid --downstream value: "${w}". Must be "none", "direct", or "deep".`);if(!E.has(y))throw new Error(`Invalid --upstream value: "${y}". Must be "none", "direct", or "deep".`);const M={base:i,downstream:w,head:u,projectGraph:x,projects:h.projects,upstream:y,workspaceRoot:l},d=await F(M);p(`changed files: ${d.changedFiles.length}`),p(`affected projects: ${d.affectedProjects.join(", ")||"(none)"}`);const j={base:i,head:u};return d.changedFiles.length===0?n(b(o,"no-changes",`No files changed between ${i}...${u}`,{...j,affectedProjects:[]})):d.affectedProjects.includes(o)?n(f(o,"project-affected",`Build ${o}: affected by ${d.changedFiles.length} changed file(s)`,{...j,affectedProjects:d.affectedProjects})):n(b(o,"project-not-affected",`Skip ${o}: not affected by changes between ${i}...${u}`,{...j,affectedProjects:d.affectedProjects}))}catch(s){const a=s instanceof Error?s.message:String(s);return t.error(`Affected detection failed: ${a}`),n(f(o,"workspace-error",`Affected detection failed (${a}) — building defensively`))}};export{re as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{E as u}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as p}from"../packem_shared/index-BDmTbWX1.js";const f={docker:".dockerignore",npm:".npmignore",slug:".slugignore",vercel:".vercelignore"},m=[".git",".gitattributes",".gitignore",".editorconfig",".vscode/",".idea/",".DS_Store","*.md","LICENSE*","LICENCE*","CHANGELOG*","CONTRIBUTING*","AUTHORS*","docs/","doc/","examples/","example/",".github/",".gitlab-ci.yml",".circleci/","appveyor.yml",".eslintrc*","eslint.config.*",".prettierrc*","prettier.config.*","*.log","npm-debug.log*","*.d.ts","*.map","*.flow","tsconfig*.json","__tests__/","__mocks__/","test/","tests/","*.test.*","*.spec.*","coverage/",".nyc_output/"],w={docker:["node_modules",".vis/","Dockerfile*",".dockerignore"],npm:[],slug:["node_modules"],vercel:["node_modules",".vercel/"]},$=e=>{const r=new Set,n=[];for(const t of[...m,...w[e]])r.has(t)||(r.add(t),n.push(t));return n},h=e=>e.trim(),_="# Added by vis ignore",v=(e,r)=>{const n=new Set;for(const o of e.split(/\r?\n/u)){const c=h(o);c!==""&&!c.startsWith("#")&&n.add(c)}const t=[];for(const o of r)n.has(o)||(n.add(o),t.push(o));if(t.length===0)return{added:t,content:e};const s=e.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`,d=[_,...t].join(s);if(e.trim()==="")return{added:t,content:`${d}${s}`};const i=e.endsWith(`
|
|
5
|
+
`)?s:`${s}${s}`;return{added:t,content:`${e}${i}${d}${s}`}},E=e=>e==="docker"||e==="npm"||e==="slug"||e==="vercel",k=async(e,r)=>{try{return await e.readFile(r,"utf8")}catch{return""}},N=async({fs:e,logger:r,options:n,process:t,workspaceRoot:s})=>{const d=s??t.cwd,i=n.target??"docker";if(!E(i))throw new Error(`Invalid --target "${i}". Expected one of: docker, vercel, npm, slug.`);const o=f[i],c=p(d,o),g=await k(e,c),{added:a,content:l}=v(g,$(i));if(n.json){process.stdout.write(`${JSON.stringify({added:a,file:o,target:i},null,2)}
|
|
6
|
+
`);return}if(n.write){if(a.length===0){r.info(`${o} is already up to date (no new patterns).`);return}await e.writeFile(c,l),r.info(`Added ${a.length} pattern(s) to ${o}.`);return}process.stdout.write(l.endsWith(`
|
|
7
|
+
`)?l:`${l}
|
|
8
|
+
`),r.info(u(`(${a.length} new pattern(s); re-run with --write to save ${o})`))};export{N as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{E as d}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as g,f as y,v as k,T as w,O as l}from"../packem_shared/index-BDmTbWX1.js";import{a as h,b as x,f as b}from"../packem_shared/subtree-C7bZuiSQ.js";import{o as u}from"../packem_shared/utils-Cxree603.js";import{t as A,W as R}from"./bin.js";import{a as $}from"./config.js";const j=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,E=/^(\s*)-\s/,q=(c,i)=>{const r=c.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`,e=c.split(/\r?\n/),o=e.findIndex(t=>v.test(t));if(o===-1)return;let s=" ";for(let t=o+1;t<e.length;t++){const a=E.exec(e[t]);if(a){s=a[1];break}if(e[t].trim().length>0)break}return e.splice(o+1,0,`${s}- "${i}"`),e.join(r)},I=(c,i,r)=>{const e=g(c,"package.json");let o;try{o=$(e)}catch{return!1}const{workspaces:s}=o;return Array.isArray(s)?s.includes(i)?!1:(r||l(e,{...o,workspaces:[...s,i]},{detectIndent:!0}),!0):s&&typeof s=="object"&&Array.isArray(s.packages)?s.packages.includes(i)?!1:(r||l(e,{...o,workspaces:{...s,packages:[...s.packages,i]}},{detectIndent:!0}),!0):!1},P=({dryRun:c=!1,prefix:i,workspaceRoot:r})=>{const e=u(i),o=A(r);if(!o)return{status:"no-config"};if(R(r,o).some(s=>u(s)===e))return{status:"already-covered"};for(const s of j){const t=g(r,s);if(!y(t))continue;const a=q(k(t),e);if(a!==void 0)return c||w(t,a),{entry:e,file:s,status:"added"}}return I(r,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},H=async({argument:c,fs:i,logger:r,options:e,process:o,workspaceRoot:s})=>{const t=c[0];if(!t)throw new Error("Missing <source>. Pass a git repository URL or local path to import.");if(!e.prefix)throw new Error("Missing --prefix <dir>. Pass the target directory in the monorepo (e.g. packages/tooling/foo).");const a=s??o.cwd,n=u(e.prefix),f=e.ref??"HEAD";if(h(a),await(async p=>{try{return await i.access(p),!0}catch{return!1}})(g(a,n)))throw new Error(`Target "${n}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const p=e.squash?" --squash":"",m=e.message?` -m "${e.message}"`:"";r.info("Dry run — no changes will be made. Planned steps:"),r.info(` git subtree add --prefix=${n}${p}${m} ${t} ${f}`),e.noRegister||r.info(` register ${n} into the workspace config (skipped if already covered by an existing glob)`);return}if(x(a),r.info(`Importing ${d(t)}@${f} → ${n} ...`),b({cwd:a,message:e.message,prefix:n,ref:f,repo:t,squash:e.squash}),r.info(`✓ Imported ${t} into ${n} (history preserved).`),e.noRegister)r.info(d(`Skipped workspace registration (--no-register). Add ${n} to your workspace config manually.`));else{const p=P({prefix:n,workspaceRoot:a});p.status==="already-covered"?r.info(`✓ ${n} is already covered by an existing workspace glob.`):p.status==="added"?r.info(`✓ Registered ${p.entry} in ${p.file}.`):r.warn(`Could not auto-register ${n}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}r.info(d("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{H as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as x}from"../packem_shared/index-BDmTbWX1.js";import{af as I,b as T}from"./bin.js";import{f as $}from"../packem_shared/selectors-GCJIe342.js";import E from"./index.js";const b=(e,n)=>{for(const l of n)if(E(l,e))return!0;return!1},J=(e,n={})=>{const{depTypes:l,excludePatterns:f,externalOnly:y,includePatterns:d,internalOnly:j}=n;if(j&&y)return[];const u=l&&l.length>0?new Set(l):void 0,N=d&&d.length>0?d:void 0,O=f&&f.length>0?f:void 0,w=[];for(const m of e)j&&!m.isInternal||y&&m.isInternal||u&&!u.has(m.depType)||N&&(!m.packageName||!b(m.packageName,N))||O&&m.packageName&&b(m.packageName,O)||w.push(m);return w},C=new Set(["json","ndjson","table"]),q=e=>{if(e===void 0)return"table";const n=e.toLowerCase();if(!C.has(n))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return n},v=(e,n)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:x(n,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),S=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),L=e=>{if(!e||e.length===0)return;const n=[],l=[];for(const f of e)for(const y of f.split(",")){const d=y.trim();d&&(S.has(d)?n.push(d):l.push(d))}if(l.length>0)throw new Error(`Unknown --dep-type value(s): ${l.join(", ")}. Valid: ${[...S].join(", ")}`);return n.length>0?n:void 0},U=async({logger:e,options:n,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root.");const y=q(n.format);if(n.deps===!0){if(n.internalOnly&&n.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const c=L(n.depType),i=I(f);let r=J(i,{depTypes:c,excludePatterns:n.exclude,externalOnly:n.externalOnly,includePatterns:n.include,internalOnly:n.internalOnly});if(n.query){const{workspace:t}=T(f,l),p=new Set($(Object.keys(t.projects),t,n.query));r=r.filter(k=>k.packageName!==void 0&&p.has(k.packageName))}const g=[...r].sort((t,p)=>{const k=`${t.packageName??t.packageDir} ${t.depType} ${t.depName}`,D=`${p.packageName??p.packageDir} ${p.depType} ${p.depName}`;return k.localeCompare(D)});if(y==="ndjson"){for(const t of g)e.info(JSON.stringify(v(t,f)));return}if(y==="json"){const t=g.map(p=>v(p,f));e.info(JSON.stringify(t,null,n.pretty===!0?2:void 0));return}if(g.length===0){e.info("No matching dep-instances.");return}const a=["Package","Block","Dep","Specifier","Internal","Path"],o=g.map(t=>[t.packageName??t.packageDir,t.depType,t.depName,t.specifier,t.isInternal?"yes":"no",x(f,t.packageJsonPath)]),s=a.map((t,p)=>Math.max(t.length,...o.map(k=>(k[p]??"").length))),h=(t,p)=>t.padEnd(p);e.info(a.map((t,p)=>h(t,s[p])).join(" ")),e.info(s.map(t=>"─".repeat(t)).join("──"));for(const t of o)e.info(t.map((p,k)=>h(p,s[k])).join(" "));e.info(""),e.info(`${String(g.length)} dep-instance(s)`);return}if(y==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:d,workspace:j}=T(f,l);let u=Object.keys(j.projects).sort();if(n.query&&(u=$(u,j,n.query)),u.length===0){e.info("No projects found.");return}const N=n.inferred===!0,O=n.targets===!0||N;if(y==="json"){const c=u.map(i=>{const r=j.projects[i],g=d.get(i)??{},a=Object.entries(r.targets??{}).map(([o])=>{const s=g[o],h=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...h?{inferred:!0}:{},name:o,type:s?.type}}).filter(o=>!N||o.inferred===!0);return{language:r.language,layer:r.layer,name:i,root:r.root,stack:r.stack,tags:r.tags??[],targets:a,type:r.projectType??"library"}});e.info(JSON.stringify(c,null,2));return}const w=(c,i)=>{const r=c.map((a,o)=>{let s=0;for(const h of i)s=Math.max(s,(h[o]??"").length);return Math.max(a.length,s)}),g=(a,o)=>a.padEnd(o);e.info(c.map((a,o)=>g(a,r[o])).join(" ")),e.info(r.map(a=>"─".repeat(a)).join("──"));for(const a of i)e.info(a.map((o,s)=>g(o,r[s])).join(" "))};if(O){const c=[];for(const i of u){const r=j.projects[i],g=d.get(i)??{};for(const a of Object.keys(r.targets??{}).sort()){const o=g[a],s=o?.inferred===!0;if(N&&!s)continue;const h=r.targets?.[a],t=h?.cache===!1?"no":h?.cache===!0?"yes":"default";c.push([i,a,o?.type??"—",t,s?"yes":"no",o?.description??"—"])}}if(c.length===0){e.info(N?"No inferred targets found.":"No targets found.");return}w(["Project","Target","Type","Cache","Inferred","Description"],c),e.info(""),e.info(`${String(c.length)} target(s) across ${String(u.length)} project(s)`);return}const m=["Project","Type","Layer","Tags","Targets"],P=u.map(c=>{const i=j.projects[c],r=Object.keys(i.targets??{});return[c,i.projectType??"library",i.layer??"—",(i.tags??[]).join(", ")||"—",r.length>4?`${r.slice(0,4).join(", ")}… (${String(r.length)})`:r.join(", ")||"—"]});w(m,P),e.info(""),e.info(`${String(u.length)} project(s)`)};export{U as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{DEFAULT_CHANGES_DIR as R}from"./DEFAULT_CLEAN_KEEP.js";import{b as k,r as S,a as C,p as x}from"./orchestrator.js";import{hasUncommittedChanges as F,getCurrentBranch as N,pushBranch as P,stageAndCommit as A}from"./git.js";import{createShellRunner as I}from"./shell-runner.js";import{stateFilePath as j}from"./state.js";import{d as D}from"../packem_shared/sticky-comment-D6_7-w8T.js";import{VisReleaseError as y}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const V="<!-- vis:user-content -->",M="<!-- /vis:user-content -->",U=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,q=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,E=r=>`${V}${r}${M}`,L=(r,e)=>{const s=[],o=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let n=o.exec(r);for(;n!==null;)s.push({end:n.index+n[0].length,start:n.index}),n=o.exec(r);if(s.length===0)return{body:r,remaining:e};let i=0;const t=[],u=Math.min(s.length,e.length);for(let l=0;l<u;l+=1){const d=s[l],a=e[l];t.push(r.slice(i,d.start)),t.push(a),i=d.end}return t.push(r.slice(i)),{body:t.join(""),remaining:e.slice(u)}},O=(r,e)=>{if(r===void 0||r==="")return e;const s=r.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),o=(s.match(/<!-- vis:user-content -->/g)??[]).length,n=(s.match(/<!-- \/vis:user-content -->/g)??[]).length;if(o!==n)throw new y({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${o} opens, ${n} closes). Refusing to merge to prevent silent edit loss.`});if(q.test(s))throw new y({code:"CONFIG_INVALID",hint:"Flatten the nesting in the PR body and re-run.",message:"Nested <!-- vis:user-content --> markers are not allowed in PR body. The merger refuses to operate to prevent silent edit loss."});const i=[];for(const a of r.matchAll(U)){const p=a[1]??"";p.trim()!==""&&i.push(E(p))}if(i.length===0)return e;const{body:t,remaining:u}=L(e,i);if(u.length===0)return t;const l=t.replace(/\s+$/u,""),d=u.join(`
|
|
2
|
+
|
|
3
|
+
`);return`${l}
|
|
4
|
+
|
|
5
|
+
${d}
|
|
6
|
+
`},_=async(r,e,s)=>{try{return await r.access(j(e,s)),!0}catch{return!1}},B=async(r,e,s,o,n,i,t)=>{const u=await r.run("gh",["pr","list","--head",o,"--state","open","--json","number"],{cwd:s,silent:!0});if(u.exitCode===0&&u.stdout.trim()!==""&&u.stdout.trim()!=="[]")try{const a=JSON.parse(u.stdout);if(a[0]){let p=i,w=!1;try{const m=await r.run("gh",["pr","view",String(a[0].number),"--json","body","-q",".body"],{cwd:s,silent:!0});if(m.exitCode===0)try{p=O(m.stdout.replace(/\n$/,""),i)}catch($){w=!0,e.warn(`Skipping PR body update for #${a[0].number} — protected-content blocks are unbalanced, refusing to overwrite operator content. Please clean up markers manually. Cause: ${$.message}`)}}catch(m){e.warn(`Could not read existing body of PR #${a[0].number} for protected-edit merge: ${m.message}. Proceeding with the unmerged body.`)}const v=w?["pr","edit",String(a[0].number),"--title",n]:["pr","edit",String(a[0].number),"--title",n,"--body",p],b=await r.run("gh",v,{cwd:s,silent:!0});if(b.exitCode!==0)throw new Error(`gh pr edit #${a[0].number} failed: ${b.stderr.trim()}`);return{existing:!0,number:a[0].number}}}catch{}const l=await r.run("gh",["pr","create","--head",o,"--base",t,"--title",n,"--body",i],{cwd:s,silent:!0});if(l.exitCode!==0)return;const d=/\/pull\/(\d+)/.exec(l.stdout);return d?{existing:!1,number:Number.parseInt(d[1]??"0",10)}:void 0},G=async(r,e,s,o)=>{const n=o.labels??["autorelease: pending"];n.length>0&&await r.run("gh",["pr","edit",String(s),...n.flatMap(i=>["--add-label",i])],{cwd:e,silent:!0}),o.reviewers&&o.reviewers.length>0&&await r.run("gh",["pr","edit",String(s),"--add-reviewer",o.reviewers.join(",")],{cwd:e,silent:!0}),o.assignees&&o.assignees.length>0&&await r.run("gh",["pr","edit",String(s),"--add-assignee",o.assignees.join(",")],{cwd:e,silent:!0})},X=async({fs:r,logger:e,options:s,workspaceRoot:o})=>{const n=o??process.cwd(),i=I(),t=await k({channel:s.channel,cwd:n}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(s,t,e))return;const l=s.autoPublish===!0?"auto-publish":t.channel?.mode??"auto-publish";if(await F({cwd:n,runner:i})){e.warn("Working tree has uncommitted changes. CI mode requires a clean tree."),process.exitCode=1;return}const{files:d}=await S({changesDir:t.config.changesDir,cwd:n});if(l==="auto-publish"){if(d.length===0){e.info("No pending change files. Nothing to release.");return}e.info(`Auto-publish mode — versioning + publishing ${t.plan.releases.length} package(s).`),await C(t,{commit:!0});const c=await x(t,{resume:!0,tag:t.channel?.tag}),h=await N({cwd:n,runner:i});if(h)try{await P({cwd:n,runner:i},h)}catch(f){e.error(`Failed to push branch: ${f.message}`)}e.info(`Published: ${c.published.length} | Skipped: ${c.skipped.length} | Failed: ${c.failed.length}`),process.exitCode=c.failed.length>0?2:0;return}if(d.length===0){const c=t.config.changesDir??R,h=await _(r,n,c);h?e.info("No pending change files but `.state.json` is present — resuming the prior wave's publish."):e.info("No pending change files — assuming this push is a merged release PR. Publishing.");const f=await x(t,{resume:h,tag:t.channel?.tag});e.info(`Published: ${f.published.length} | Skipped: ${f.skipped.length} | Failed: ${f.failed.length}`),process.exitCode=f.failed.length>0?2:0;return}e.info(`Version-PR mode — maintaining release PR for ${t.plan.releases.length} package(s).`);const a=s.branch??t.config.versionPr?.branch??"vis-release/version-packages",p=t.config.versionPr?.title??"🚀 Versioned release";if(!await D(i,n)){e.error("Could not detect repository slug via gh CLI. Cannot maintain version PR."),process.exitCode=1;return}const w=await i.run("git",["switch","-C",a],{cwd:n,silent:!0});if(w.exitCode!==0){e.error(`Could not switch to ${a}: ${w.stderr}`),process.exitCode=1;return}const v=await C(t,{commit:!1}),b=[...v.changedFiles,...v.deletedFiles];if(b.length===0){e.warn("Apply produced no file changes. Aborting version PR.");return}await A({cwd:n,runner:i},b,t.config.gitUser?`release(${t.channel?.tag??"main"}): version packages [skip ci]`:"release: version packages [skip ci]",{author:t.config.gitUser});try{await P({cwd:n,runner:i},a,{force:!0})}catch(c){e.error(`Could not push ${a}: ${c.message}`),process.exitCode=1;return}const m=t.branch??t.config.baseBranch??"main",$=`${t.config.versionPr?.preamble??""}
|
|
7
|
+
|
|
8
|
+
## Pending releases
|
|
9
|
+
|
|
10
|
+
${t.plan.releases.map(c=>`- \`${c.name}\`: ${c.oldVersion} → **${c.newVersion}**`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
`,g=await B(i,e,n,a,p,$,m);if(g){if(e.info(`${g.existing?"Updated":"Opened"} version PR #${g.number}.`),await G(i,n,g.number,{assignees:g.existing?void 0:t.config.versionPr?.assignees,labels:t.config.versionPr?.labels,reviewers:g.existing?void 0:t.config.versionPr?.reviewers}),t.config.versionPr?.autoMerge&&!g.existing){const c=t.config.versionPr.autoMergeMethod??"squash",h=await i.run("gh",["pr","merge",String(g.number),"--auto",`--${c}`],{cwd:n,silent:!0});h.exitCode===0?e.info(`Auto-merge enabled (${c}).`):e.warn(`Could not enable auto-merge on PR #${g.number}: ${h.stderr.trim()||`exit ${h.exitCode}`}`)}}else e.error("Failed to create / update version PR."),process.exitCode=1};export{X as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createRequire as F}from"node:module";import{DEFAULT_CHANGES_DIR as N}from"./DEFAULT_CLEAN_KEEP.js";import{b as O,f as V}from"./orchestrator.js";import{CommitParser as G}from"conventional-commits-parser";import{createShellRunner as U}from"./shell-runner.js";import{r as K}from"../packem_shared/slug-DoueYuLo.js";import{maxBump as Y}from"../release/types.js";const W=F(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=f=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[n,p]=E.versions.node.split(".").map(Number);if(n>22||n===22&&p>=3||n===20&&p>=16)return E.getBuiltinModule(f)}return W(f)},{join:B,relative:z}=q("node:path"),T={build:"patch",chore:"patch",ci:"patch",docs:"patch",feat:"minor",fix:"patch",perf:"patch",refactor:"patch",style:"patch",test:"patch"},J=new G,Q=/^Revert\s+"(.+)"\s*$/,X=/This reverts commit\s+([0-9a-f]{7,40})/i,Z=/^(?:[\p{Emoji_Presentation}\p{Extended_Pictographic}]|:\w+:)\s+/u,ee=(f,n)=>{const p=f.replace(Z,""),h=J.parse(`${p}
|
|
2
|
+
|
|
3
|
+
${n}`);return{breaking:h.notes.some(i=>/BREAKING/i.test(i.title)),scope:h.scope??void 0,type:h.type??void 0}},te=(f,n,p)=>{let h,i=!1;if(p.type==="revert"){i=!0;const m=f.indexOf(":");m!==-1&&(h=f.slice(m+1).trim())}else{const m=Q.exec(f.trim());m&&(i=!0,h=m[1]?.trim())}let u;const d=X.exec(n);return d&&(u=d[1]?.toLowerCase()),{isRevert:i,targetSha:u,targetSubject:h}},oe=(f,n=new Set,p)=>{const h=f.map(e=>{const o=ee(e.subject,e.body),{isRevert:t,targetSha:s,targetSubject:a}=te(e.subject,e.body,o);return{...e,cancelled:!1,parsed:o,revert:t,revertSubject:a,revertTargetSha:s}}),i=h.toReversed(),u=12,d=new Map;for(const e of i)if(d.set(e.hash,e),e.hash.length>=7){const o=Math.min(e.hash.length-1,u);for(let t=7;t<=o;t+=1){const s=e.hash.slice(0,t);if(d.has(s)){const a=d.get(s);a!==null&&a!==e&&d.set(s,null)}else d.set(s,e)}}const m=(e,o)=>{if(e.revertTargetSha){const t=e.revertTargetSha.toLowerCase();let s=d.get(t)??void 0;if(s||(s=i.find(a=>a.hash.startsWith(t))),s&&s!==e)return s}if(e.revertSubject)for(let t=o.length-1;t>=0;t-=1){const s=o[t];if(s.subject===e.revertSubject)return s}},v=64,C=e=>{let o=e;for(let t=0;t<v;t+=1){if(!o.revert)return o;const s=o.cancelledBy;let a;if(s&&(a=d.get(s)??void 0,a||(a=d.get(s.slice(0,7))??void 0)),!a||a===o)return o;o=a}},j=[],b=[];for(const e of i){if(e.revert){const o=m(e,b);if(o){if(n.has(o.hash)){b.push(e);continue}const t=C(o);if(t===void 0){j.push(`Revert chain at ${e.hash} exceeded depth limit (${v}) — skipping cancellation`),b.push(e);continue}if(n.has(t.hash)){b.push(e);continue}t.cancelled=!t.cancelled,t.cancelledBy=t.cancelled?e.hash:void 0,e.cancelled=!0,e.cancelledBy=o.hash}}b.push(e)}const w=h.filter(e=>!e.cancelled&&!e.revert&&!e.subject?.startsWith("Merge ")),R=w.filter(e=>!e.parsed.type);if(w.length>0&&R.length/w.length>.5){const e=p??"<from>..HEAD";j.push(`${R.length}/${w.length} commits in ${e} have no conventional-commits prefix. Consider enabling commit-message linting.`)}return{commits:h,warnings:j}},fe=async({fs:f,logger:n,options:p,workspaceRoot:h})=>{const i=h??process.cwd(),u=await O({cwd:i,skipRegistryLookup:!0}),{printConfigIfRequested:d}=await import("./print-config.js");if(d(p,u,n))return;const m=U();let v=p.from;if(!v){const r=u.config.baseBranch??"main",c=await m.run("git",["merge-base",`origin/${r}`,"HEAD"],{cwd:i,silent:!0});if(c.exitCode===0&&c.stdout.trim())v=c.stdout.trim();else{const l=await m.run("git",["merge-base",r,"HEAD"],{cwd:i,silent:!0});v=l.exitCode===0?l.stdout.trim():"HEAD~10"}}const C=new Map;for(const r of u.packages){const c=(r.dir.startsWith(i)?r.dir.slice(i.length):r.dir).replaceAll("\\","/").replace(/^\/+/,"");C.set(c,r.name)}const j=r=>{for(const[c,l]of C)if(r.startsWith(`${c}/`)||r===`${c}/package.json`)return l},b=Math.random().toString(16).slice(2,10),w=`@@VIS_RELEASE_COMMIT_${b}@@`,R=`@@VIS_RELEASE_FILES_${b}@@`,e=await m.run("git",["log",`${v}..HEAD`,`--pretty=format:${w}%n%H%n%s%n%b%n${R}`,"--name-only"],{cwd:i,silent:!0});if(e.exitCode!==0){n.error(`git log failed: ${e.stderr}`),process.exitCode=1;return}const o=new Map,t=[],s=[],a=e.stdout.split(w).map(r=>r.trim()).filter(Boolean);for(const r of a){const[c,l=""]=r.split(R).toReversed(),S=l.split(`
|
|
4
|
+
`),_=S[0]?.trim()??"",y=S[1]?.trim()??"",g=S.slice(2).join(`
|
|
5
|
+
`).trim(),$=(c??"").split(`
|
|
6
|
+
`).map(P=>P.trim()).filter(Boolean);_&&s.push({body:g,files:$,hash:_,subject:y})}const{commits:M,warnings:D}=oe(s,void 0,`${v}..HEAD`);for(const r of D)n.warn(r);for(const{cancelled:r,files:c,parsed:l,subject:S}of M){if(r)continue;let _="patch";l.breaking?_="major":l.type&&T[l.type]&&(_=T[l.type]??"patch");const y=new Set;if(l.scope)for(const g of u.packages)(g.name===l.scope||g.name.endsWith(`/${l.scope}`))&&y.add(g.name);if(y.size===0)for(const g of c){const $=j(g);$&&y.add($)}for(const g of y){const $=o.get(g);o.set(g,$?Y($,_):_)}y.size>0&&t.push(`- ${S}`)}if(o.size===0){n.info("No commits affected workspace packages — nothing to generate.");return}const H={bumps:Object.fromEntries(o)},I=t.length>0?t.join(`
|
|
7
|
+
`):"Auto-generated change file.",A=V(H,I);if(p.dryRun){n.info("[dry-run] would write:"),n.info(A);return}const x=u.config.changesDir??N,L=(p.name??K()).replaceAll(/[^a-z0-9-]/gi,"-"),k=B(i,x,`${L}.md`);await f.mkdir(B(i,x),{recursive:!0}),await f.writeFile(k,A),n.info(`Created ${z(i,k)}`);for(const[r,c]of o)n.info(` ${r}: ${c}`)};export{fe as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{createRequire as B}from"node:module";import{u as W,ai as M,aj as F,ak as P,al as p,am as z,an as G,ao as L,ap as Y,aq as Z,ar as H,as as K,at as Q,au as U,av as X,aw as tt,ax as V,ay as ot}from"./bin.js";import{f as k,m as f,v as j,T as O,I as nt,J as it}from"../packem_shared/index-BDmTbWX1.js";import"../packem_shared/public-api-WqUCiyIe.js";import{Z as rt}from"./config.js";import{v as ut}from"../packem_shared/verify-6WCmFmy8.js";const J=B(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[o,s]=$.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return $.getBuiltinModule(t)}return J(t)},{readdirSync:et,statSync:st}=I("node:fs"),{stdin:T,stdout:at}=$,{createInterface:ct}=I("node:readline/promises"),w="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),pt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,m=t=>{if(!Array.isArray(t))return[];const o=[];for(const s of t)typeof s=="string"?o.push(s):s&&typeof s=="object"&&o.push(pt(s));return R(o)},y=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,ft=(t,o)=>{const s=t.trim();if(o==="moon"){if(s.startsWith("^:"))return h(void 0,s.slice(2),!0);if(s.startsWith("~:"))return h(void 0,s.slice(2),!1);if(s.includes(":")){const[n,e]=s.split(":");return h(n,e??"",!1)}return s}if(s.startsWith("^"))return h(void 0,s.slice(1),!0);if(s.includes("#")){const[n,e]=s.split("#");return h(n,e??"",!1)}return s},C=(t,o)=>{if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n=="string"){s.push(ft(n,o));continue}if(!n||typeof n!="object")continue;const e=n,{target:i}=e;if(!i)continue;if(e.dependencies===!0){s.push(h(void 0,i,!0));continue}if(e.projects===void 0){s.push(h(void 0,i,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const c of r)s.push(c==="^"?h(void 0,i,!0):h(c,i,!1))}return R(s)},E=t=>{if(k(t))try{return JSON.parse(j(t))}catch{return}},gt=t=>{const o=new Map,s=E(f(t,"turbo.json"));if(!s)return o;const n=s.tasks??s.pipeline??{};for(const[i,r]of Object.entries(n)){const c=i.includes("#")?i:`*#${i}`,a=y(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=m(r.inputs),a.outputs=m(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=y(w);return e.inputs=m(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},dt=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),S=(t,o,s=8)=>{const n=[],e=(i,r)=>{if(r>s)return;let c;try{c=et(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||dt.has(a))continue;const u=f(i,a);try{st(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},N=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},lt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=y(i);N(r,e),o.set(i,r)}for(const n of S(t,"project.json")){const e=E(n);if(!(!e?.name||!e.targets))for(const[i,r]of Object.entries(e.targets)){const c=`${e.name}#${i}`,a=y(c);N(a,r),o.set(c,a)}}return o},_=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(k(t))try{return W(t)}catch{return}},vt=t=>{const o=new Map,s=f(t,".moon"),n=[f(s,"tasks.yml"),f(s,"tasks.yaml")];for(const e of n){const i=A(e);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=y(a);_(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=y(w);r.inputs=m(i.implicitInputs),o.set(w,r)}}}for(const e of[...S(t,"moon.yml"),...S(t,"moon.yaml")]){const i=A(e);if(!i?.tasks)continue;const r=e.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,v=y(u);_(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.env=R([...o.env??[],...o.passThroughEnv??[],...o.options?.passThroughEnv??[]]),t.cache=o.cache===!1?!1:typeof o.cache=="boolean"?o.cache:void 0},ht=async t=>{const o=new Map,s=await rt(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=y(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=y(w);return e.inputs=m(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},yt=(t,o)=>{switch(o){case"moon":return vt(t);case"nx":return lt(t);default:return gt(t)}},kt=t=>{const o=[];return k(f(t,"turbo.json"))&&o.push("turbo"),k(f(t,"nx.json"))&&o.push("nx"),(k(f(t,".moon","tasks.yml"))||k(f(t,".moon","tasks.yaml")))&&o.push("moon"),o.length===1?o[0]:void 0},x=(t,o,s,n,e)=>{const i=n.filter(a=>!e.includes(a)),r=e.filter(a=>!n.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${c.join("; ")}`,node:o,severity:i.length>0?"error":"warning"})},wt=(t,o,s)=>{const n=[],e=R([...t.keys(),...o.keys()]);for(const i of e){const r=t.get(i),c=o.get(i);if(r&&!c){const a=s==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==w;n.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){n.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target — not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(x(n,i,"dependsOn",r.dependsOn,c.dependsOn),x(n,i,"inputs",r.inputs,c.inputs),x(n,i,"outputs",r.outputs,c.outputs),x(n,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&n.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return n.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:n,source:s,sourceNodeCount:t.size,visNodeCount:o.size}},Rt=new Set(["json","ndjson","table"]),$t=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),bt=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify($t(t),void 0,2)}
|
|
2
|
+
`);return}if(o==="ndjson"){for(const n of t.findings)process.stdout.write(`${JSON.stringify(n)}
|
|
3
|
+
`);return}if(s.info(`Migration equivalence: ${t.source} → vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const n of t.findings){const e=` [${n.severity}] ${n.node} (${n.axis}) — ${n.detail}`;n.severity==="error"?s.warn(e):s.info(e)}},xt=(t,o)=>t.findings.some(s=>o==="warning"?!0:s.severity==="error")?1:0,D=async t=>{if(!T.isTTY)return!0;const o=ct({input:T,output:at});try{const s=(await o.question(`${t} [Y/n] `)).trim().toLowerCase();return s===""||s==="y"||s==="yes"}finally{o.close()}},Ct=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],jt=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Et=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),St=(t,o)=>{let s=t;const n=[];for(const e of o){const i=Et(e.previous);i.test(s)&&(i.lastIndex=0,s=s.replace(i,(r,c,a,u)=>`${c}${a}${e.next}${a}${u}`),n.push(e))}return{applied:n,output:s}},q=(t,o)=>St(t,o),Mt=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Ot=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),Tt=t=>{for(const o of Mt){const s=f(t,o);if(k(s))return s}},Nt=t=>{const o=[];try{for(const s of nt(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Ot.has(it(s.path))&&o.push(s.path)}catch{}return o},_t=(t,o,s,n)=>{const e=Tt(t);if(e){const r=j(e),{applied:c,output:a}=q(r,Ct);if(c.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(o.dryRun)s.info(`── ${e} (preview) ──`),s.info(a),s.info("── end preview ──"),s.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{M(e,n),O(e,a),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)n.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),n.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=o.taskConfigPaths??Nt(t);for(const r of i){if(!k(r))continue;const c=j(r),a=q(c,jt);if(a.applied.length!==0)if(o.dryRun)s.info(`── ${r} (preview) ──`),s.info(a.output),s.info("── end preview ──"),s.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{M(r,n),O(r,a.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)n.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},g=t=>{const o=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:ot(o),report:V(),root:o,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},d=async(t,o,s)=>{if(o.yes||o.dryRun)return!0;const n=await D(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return n||s.info("Aborted."),n},l=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
|
|
4
|
+
`)},At=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("deps",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating dependencies and scripts ──"),z(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},qt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("lint-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating lint-staged ──"),G(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},It=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nano-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nano-staged ──"),L(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Vt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("turborepo",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating turborepo ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Dt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nx",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nx ──");const i=!!o.aggressive;Z(e.root,{aggressive:i,dryRun:e.dryRun,force:i||!!o.force,rewriteSyncGenerators:i||!!o.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Bt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("moon",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating moon ──"),H(e.root,{copyTemplates:!!o.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Jt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("gitleaks",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating gitleaks ──"),K(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Wt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("kingfisher",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating Kingfisher ──"),Q(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Ft=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("secretlint",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating secretlint ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Pt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("syncpack",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating syncpack ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},zt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("sherif",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating sherif ──"),tt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Gt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("self",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating vis.config.ts to current schema ──"),_t(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Lt=({logger:t,workspaceRoot:o})=>{const s=o??process.cwd();ut(s,t).length>0&&(process.exitCode=1)},Yt=async({logger:t,options:o,workspaceRoot:s})=>{const n=s??process.cwd(),e=o.format??"table";if(!Rt.has(e)){t.warn(`Invalid --format: ${String(o.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=o.failOn==="warning"?"warning":"error";let r;if(o.from){if(o.from!=="turbo"&&o.from!=="nx"&&o.from!=="moon"){t.warn(`Invalid --from: ${o.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=o.from}else if(r=kt(n),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=yt(n,r);if(c.size===0){t.warn(`No ${r} task graph found at ${n} — nothing to verify.`),process.exitCode=1;return}const a=await ht(n);if(a.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=wt(c,a,r);bt(u,e,t),process.exitCode=xt(u,i)},Zt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const e=n??process.cwd(),i=F(e,s??{}),r=P(i);if(r.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!o.dryRun;t.info(`Detected ${String(r.length)} migration(s):`);for(const v of r)t.info(` • ${v.title} — ${v.description}`);if(t.info(""),!o.yes&&!c&&!await D("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
|
|
5
|
+
`);const a=V(),u=[];for(const v of r)try{if(t.info(`── Applying ${v.title} ──`),c)for(const b of v.probe(i))t.info(b);else v.apply(i,a,t);t.info("")}catch(b){u.push({error:b,id:v.id}),t.warn(`Failed to apply ${v.title}: ${b.message}`)}p(a,t),u.length>0&&(t.warn(""),t.warn(`${String(u.length)} migration(s) failed — see messages above.`),process.exitCode=1)},oo=At,eo=qt,so=It,no=Vt,io=Dt,ro=Bt,ao=Jt,co=Wt,uo=Ft,po=Pt,fo=zt,go=Gt,lo=Lt,vo=Yt,mo=Zt;export{mo as migrateAllExecute,oo as migrateDepsExecute,ao as migrateGitleaksExecute,co as migrateKingfisherExecute,eo as migrateLintStagedExecute,ro as migrateMoonExecute,so as migrateNanoStagedExecute,io as migrateNxExecute,uo as migrateSecretlintExecute,go as migrateSelfExecute,fo as migrateSherifExecute,po as migrateSyncpackExecute,no as migrateTurborepoExecute,lo as migrateVerifyExecute,vo as migrateVerifyGraphExecute};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{createRequire as K}from"node:module";import{j as b,E as m,q as k,I as N,V as U,s as P}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as h,a as J,A,f as W}from"../packem_shared/index-BDmTbWX1.js";import{r as z,g as I,b as T,O as G}from"./bin.js";import{d as X}from"../packem_shared/lockfile-C8Q1_4KK.js";import{p as Q,s as Z}from"../packem_shared/docker-BMLrNtWm.js";const Y=K(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,t]=g.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return g.getBuiltinModule(e)}return Y(e)},{createInterface:_}=y("node:readline"),{spawn:ee}=y("node:child_process"),{createHash:oe}=y("node:crypto"),{existsSync:L,writeFileSync:te,chmodSync:ne}=y("node:fs"),D={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},re=e=>{const{focus:o,manager:t,nodeVersion:r}=e,n=D[t]??D.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${o?` --focus=${o}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...n.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",n.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",n.build(o),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
|
|
2
|
+
`)},$="v2.14.0",S=`https://github.com/hadolint/hadolint/releases/download/${$}`,se={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ie=e=>se[e],ae=(e=process.platform,o=process.arch)=>{const t=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(t===void 0)return;const r=o==="arm64"?"arm64":o==="x64"?"x86_64":void 0;if(t==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${t}-${r}`},H=e=>h(I(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),ce=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",o=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const t of o)if(t!==""&&L(h(t,e)))return e},le=e=>e.trim().split(/\s+/u)[0]??"",C=async e=>{const o=await fetch(e,{redirect:"follow"});if(!o.ok)throw new Error(`download failed (${String(o.status)} ${o.statusText}) for ${e}`);return Buffer.from(await o.arrayBuffer())},de=async e=>{const o=H(e),t=ie(e),r=await C(`${S}/${e}`),n=oe("sha256").update(r).digest("hex");if(t===void 0){const s=await C(`${S}/${e}.sha256`),i=le(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==n)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${n}). Refusing to use the download.`)}else if(t.toLowerCase()!==n)throw new Error(`hadolint checksum mismatch (expected ${t.toLowerCase()}, got ${n}). Refusing to use the download.`);return J(h(I(),"hadolint",$)),te(o,r),process.platform!=="win32"&&ne(o,493),o},ue=async()=>{const e=_({input:process.stdin,output:process.stderr}),o=await new Promise(t=>{e.question(` Download hadolint ${k($)} now? ${m("[y/N]")} `,r=>{t(r.trim().toLowerCase())})});return e.close(),o==="y"||o==="yes"},fe=async e=>{const{autoInstall:o=!1,log:t}=e,r=ce();if(r!==void 0)return r;const n=ae();if(n===void 0){t(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=H(n);if(L(s))return s;if(!o){if(!(process.stdin.isTTY&&!z)){t(`hadolint is not installed. Re-run with ${b("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(t(`${b("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await ue()){t(`Skipped. Install it yourself or re-run with ${b("--install")}.`);return}}t(`Downloading hadolint ${$} (${n})…`);try{const i=await de(n);return t(`Installed hadolint to ${m(i)}`),i}catch(i){t(`Failed to download hadolint: ${i.message}`);return}},O=async(e,o,t)=>{if(o.length===0)return[];const r=["--format","json","--no-fail",...t!==void 0&&t!==""?["--config",t]:[],...o],n=await new Promise((i,l)=>{const a=ee(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(n.trim()==="")return[];let s;try{s=JSON.parse(n)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},E=(e,o,t)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||t.test(e)))return e.replace(/\binstall\b/u,`install ${o}`)},R={DL3014:e=>E(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>E(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},M=new Set(Object.keys(R)),pe=(e,o)=>{const t=e.includes(`\r
|
|
3
|
+
`)?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`,r=e.split(/\r?\n/u),n=new Set;let s=0;const i=new Map;for(const l of o){if(!R[l.code])continue;const a=i.get(l.line)??[];a.push(l),i.set(l.line,a)}for(const[l,a]of i){const d=l-1;if(!(d<0||d>=r.length))for(const u of a){const c=R[u.code],f=c?.(r[d]??"");f!==void 0&&f!==r[d]&&(r[d]=f,n.add(u.code),s+=1)}}return{content:s>0?r.join(t):e,fixedCodes:[...n],fixedCount:s}},j={error:0,info:2,style:3,warning:1},me=(e,o)=>{switch(e){case"error":return U(o);case"info":return k(o);case"warning":return P(o);default:return m(o)}},he=(e,o)=>(e.length>0?e:["Dockerfile"]).map(t=>A(t)?t:h(o,t)).filter(t=>W(t)),we=(e,o)=>{const t=[...e].sort((n,s)=>n.file.localeCompare(s.file)||n.line-s.line||n.column-s.column||j[n.level]-j[s.level]);let r="";for(const n of t){n.file!==r&&(r=n.file,o.info(`
|
|
6
|
+
${b(r)}`));const s=m(`${String(n.line)}:${String(n.column)}`),i=me(n.level,n.level.padEnd(7)),l=M.has(n.code)?m(" (fixable)"):"";o.info(` ${s} ${i} ${k(n.code)} ${n.message}${l}`)}},ge=e=>{const o={error:0,info:0,style:0,warning:0};for(const t of e)o[t.level]+=1;return o},be=async e=>{const{autoInstall:o,configPath:t,cwd:r,files:n,fix:s,fs:i,json:l,logger:a}=e,d=he(n,r);if(d.length===0)return a.error(`No Dockerfile found${n.length>0?` at: ${n.join(", ")}`:` in ${r}`}. Pass a path: vis docker lint <path>`),1;const u=await fe({autoInstall:o,log:p=>{a.info(p)}});if(u===void 0)return 0;let c=await O(u,d,t),f=0;if(s&&c.length>0){for(const p of d){const F=c.filter(V=>V.file===p),q=await i.readFile(p,"utf8"),x=pe(q,F);x.fixedCount>0&&(await i.writeFile(p,x.content),f+=x.fixedCount)}f>0&&(c=await O(u,d,t))}if(l)return process.stdout.write(`${JSON.stringify({findings:c,fixed:f},null,2)}
|
|
7
|
+
`),c.some(p=>p.level==="error")?1:0;if(s&&f>0&&a.info(N(`✔ Auto-fixed ${String(f)} issue${f===1?"":"s"}.`)),c.length===0)return a.info(N("✔ No Dockerfile issues found.")),0;we(c,a);const w=ge(c),v=c.filter(p=>M.has(p.code)).length;return a.info(`
|
|
8
|
+
${b(String(c.length))} issue${c.length===1?"":"s"}: ${U(`${String(w.error)} error`)}, ${P(`${String(w.warning)} warning`)}, ${k(`${String(w.info)} info`)}, ${m(`${String(w.style)} style`)}`),!s&&v>0&&a.info(m(`Run 'vis docker lint --fix' to auto-fix ${String(v)} of them.`)),w.error>0?1:0},B=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},Se=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{packageJsons:s,workspace:i}=T(n,t),l=G(n,i,s),a=(o.focus??"").split(",").map(c=>c.trim()).filter(Boolean);if(a.length===0)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const d=h(n,o.out??".vis/docker"),{projects:u}=Z({focus:a,includeSources:!!o.includeSources,log:c=>{e.info(c)},outDir:d,projectGraph:l,pruneLockfile:o.pruneLockfile!==!1,workspace:i,workspaceRoot:n});e.info(`Scaffolded ${u.length} project(s) into ${d}`),e.info(`Focus closure: ${u.toSorted().join(", ")}`)},Ce=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{workspace:s}=T(n,t),i=h(n,o.context??".vis/docker"),{removed:l}=Q({contextRoot:i,workspace:s,workspaceRoot:n});e.info(`Pruned ${l.length} unfocused project(s)`),l.length>0&&e.debug?.(l.join(`
|
|
9
|
+
`))},Oe=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=await be({autoInstall:!!r.install,configPath:r.config,cwd:s??n.cwd,files:e.filter(Boolean),fix:!!r.fix,fs:o,json:!!r.json,logger:t});i!==0&&(process.exitCode=i)},$e=async(e,o)=>{try{return await e.access(o),!0}catch{return!1}},ye=async e=>{const o=_({input:process.stdin,output:process.stderr}),t=await new Promise(r=>{o.question(` ${e} already exists. Overwrite? ${m("[y/N]")} `,n=>{r(n.trim().toLowerCase())})});return o.close(),t==="y"||t==="yes"},Ee=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=s??n.cwd,l=e[0]??"Dockerfile",a=A(l)?l:h(i,l),d=X(i)?.manager??"npm",u=(r.focus??"").split(",").map(f=>f.trim()).find(Boolean),c=re({focus:u,manager:d,nodeVersion:r.node??"22"});if(r.dryRun){process.stdout.write(c.endsWith(`
|
|
10
|
+
`)?c:`${c}
|
|
11
|
+
`);return}if(await $e(o,a)&&!r.force){if(!process.stdin.isTTY){t.error(`${a} already exists. Re-run with --force to overwrite.`),process.exitCode=1;return}if(!await ye(a)){t.info("Aborted — existing Dockerfile left untouched.");return}}await o.writeFile(a,c),t.info(`Created ${a} (package manager: ${d}).`),t.info(m(`Next: vis docker scaffold${u?` --focus=${u}`:""} --include-sources, then DOCKER_BUILDKIT=1 docker build .`))};export{Ee as initExecute,Oe as lintExecute,Ce as pruneExecute,Se as scaffoldExecute};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as g}from"../packem_shared/affected-shas-cVnX8-zs.js";import{r as m}from"../packem_shared/toolchain-pR7AJ-tB.js";const w=async({argument:d,logger:t,options:o,runtime:r,visConfig:s,workspaceRoot:e})=>{const l=d[0];if(!l)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const f=l.split(",").map(a=>a.trim()).filter(Boolean);if(f.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!e)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=g({defaultBase:s?.defaultBase,workspaceRoot:e}),p=o.base??i.base,c=o.head??i.head;!o.base&&!o.head&&t.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),o.skipToolchain||t.info("▸ Toolchain pre-flight"),await m(e,s?.toolchain,{error:a=>{t.error(a)},info:a=>{t.info(a)},warn:a=>{t.warn(a)}},!!o.skipToolchain),o.install===!1?t.info("▸ Skipping install (--no-install)"):(t.info("▸ Installing dependencies"),await r.runCommand("install",{argv:["--ci","--frozen-lockfile"]}));for(const a of f){t.info(`▸ Running affected ${a} (base=${p}, head=${c})`);const n=[a,`--base=${p}`,`--head=${c}`,`--upstream=${String(o.upstream??"none")}`,`--downstream=${String(o.downstream??"deep")}`];o.parallel!==void 0&&n.push(`--parallel=${String(o.parallel)}`),o.partition&&n.push(`--partition=${String(o.partition)}`),o.query&&n.push(`--query=${String(o.query)}`),await r.runCommand("affected",{argv:n})}t.info("▸ CI pipeline complete")};export{w as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as G}from"node:module";import{I as F,q as L,j as N,E as O}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{y as P}from"../packem_shared/index-BDmTbWX1.js";import{aJ as h,aK as U}from"./bin.js";import{d as A,f as C,r as D,a as Q,b as X,s as Y,c as Z,e as ee,g as te,h as se,i as ie,j as re,k as ne,l as oe,m as ae,n as de,o as ce,p as fe,q as le,t as pe}from"../packem_shared/watch-loop-DWkvv2tK.js";const H=G(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[e,s]=k.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return k.getBuiltinModule(t)}return H(t)},{createHash:q}=I("node:crypto"),ue=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),_=(t,e)=>ue(e)?e:`${t}/${e}`,ge={argsCheck:(t,e)=>T(t,e,"check"),argsFix:(t,e)=>T(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.dprint.packageNames[0]),i=C(t,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const i of t.stdout.split(/\r?\n/)){const r=i.trim();!r||r.startsWith("[")||r.startsWith("Checked ")||r.startsWith("Error:")||s.push({adapter:"dprint",file:_(e.root,r),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(t,e,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},me={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(t,e,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(t,e)=>{const s=["oxfmt",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.oxfmt.packageNames[0]),i=C(t,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const i of t.stdout.split(/\r?\n/)){const r=i.trim();!r||r.startsWith("[")||s.push({adapter:"oxfmt",file:_(e.root,r),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},B=(t,e,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},he={argsCheck:(t,e)=>K(t,e,"check"),argsFix:(t,e)=>K(t,e,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(t,e)=>{const s=["prettier",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.prettier.packageNames[0]),i=C(t,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const i of t.stdout.split(/\r?\n/)){const r=i.trim();r&&(r.startsWith("[")||s.push({adapter:"prettier",file:_(e.root,r),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},K=(t,e,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return e.quiet&&i.push("--log-level","warn"),e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},xe=[me,de,ge,he,ce,fe],Ce=async({logger:t,options:e,visConfig:s,workspaceRoot:i})=>{const r=i??process.cwd(),u=s?.fmt,w=D(xe,u?.order),E=Q(r,w),x=X(E,w,"fmt").filter(({adapter:l})=>u?.adapters?.[l.id]?.enabled!==!1);if(x.length===0){t.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff, deno-fmt).");return}const $=l=>{const o=u?.adapters?.[l]?.extraArgs;return o&&o.length>0?[...o]:void 0},j={quiet:e.quiet??!1},R=ke(e),y=e.check?"check":"fix";let d;if(e.staged){if(d=Y(r),d===void 0)t.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(d.length===0){t.info(F("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(d=Z(r,e.since),d===void 0)t.warn(`vis fmt: could not resolve --since ${e.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(d.length===0){t.info(F(`✓ fmt: no files changed since ${e.since}`));return}}const J=U(r,void 0,void 0,!0),v=e.format??"human";v==="human"&&e.output!==void 0&&t.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async l=>{const o=R.length>0?R:l,g=[];if(o){const n=te(o,x,u?.extensionOverrides);for(const{adapter:a,presence:c}of x){const f=n.get(a.id);if(!f||f.length===0)continue;const W=$(a.id),V={adapter:a,files:f,presence:c};W&&(V.options={...j,extraArgs:W}),g.push(V)}}else for(const{adapter:n,presence:a}of x){const c=$(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...j,extraArgs:c}),g.push(f)}if(g.length===0)return;const z=await se(g,j,y,{cacheRoot:J}),b=g.map((n,a)=>{const c=z[a],f=n.adapter.parse(c,n.presence);return{adapter:n.adapter,durationMs:c.durationMs,exitCode:c.exitCode,findings:f}}),p=ie(b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:re({cwd:r,target:e.output});try{switch(v){case"github":{m.write(ae({runs:b.map(n=>({findings:n.findings})),workspaceRoot:r}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:y,runs:p.runs},null,2)}
|
|
2
|
+
`);break}case"junit":{m.write(oe({runs:b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:r}));break}case"minimal":{ye(p.findings,r,m);break}case"sarif":{m.write(ne({runs:b.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:g.find(a=>a.adapter.id===n.adapter.id)?.presence})),workspaceRoot:r}));break}default:we(p.findings,r,y,t)}}finally{m?.close()}const S=y==="fix"?p.hadProcessFailure?1:0:pe({...p,maxSeverity:p.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const l=[...new Set(x.flatMap(({adapter:o})=>o.extensions))];await ee({extensions:l,initialFiles:d,label:"fmt",log:o=>{t.info(o)},runCycle:M,workspaceRoot:r});return}await M(d)},ke=t=>{const e=t;return[...e._??e.args??[]]},we=(t,e,s,i)=>{if(t.length===0){i.info(F(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const r=le(t),u=s==="fix"?L(N("Formatted:")):N("Would change:");i.info(u);for(const w of r.keys())i.info(` ${O("·")} ${P(e,w)}`);s==="check"&&(i.info(""),i.info(O(`Run \`vis fmt\` to apply changes (${String(r.size)} file${r.size===1?"":"s"}).`)))},ye=(t,e,s)=>{for(const i of t)s.write(`${i.adapter} ${P(e,i.file)}
|
|
3
|
+
`)};export{Ce as default};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{createRequire as te}from"node:module";import{E as f,j as g,q as y}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as T,f as R,I as V,H as G,y as K,a as L,A as P,o as se,T as oe,B as ne}from"../packem_shared/index-BDmTbWX1.js";import{f as pe}from"../packem_shared/giget-DHY1sQZC.js";import{p as l}from"./bin.js";const re=te(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=t=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[e,r]=N.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return N.getBuiltinModule(t)}return re(t)},{fileURLToPath:ie}=j("node:url"),{createInterface:ae}=j("node:readline"),{mkdtempSync:ce,rmSync:le}=j("node:fs"),{tmpdir:fe}=j("node:os"),{spawnSync:ue}=j("node:child_process"),J=[".ts",".mts",".cts",".js",".mjs",".cjs"],de="template.yml",me=[".d",".test",".spec",".config",".bench",".stories"],he=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of J)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(he.some(r=>t.endsWith(r))||!J.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!me.some(r=>e.endsWith(r))},H=(t,e)=>{const r=[];if(!R(t))return r;for(const s of V(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ge(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!R(t))return r;for(const s of V(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=T(s.path,de);R(n)&&r.push({load:()=>ye(s.path,s.name),name:s.name,path:s.path,source:e})}return r},we=()=>{try{const t=ie(import.meta.url),e=T(G(t),"..","..","templates");return R(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...H(T(s,".vis","templates"),"native"),...x(T(s,".vis","templates"),"moon"),...x(T(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...H(o,"config"));const i=we();i&&n.push(...x(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},ge=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ye=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index2.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),ve=async(t,e,r)=>{const s=await q(t,` ${e} ${f(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},be=async(t,e,r,s)=>{process.stderr.write(` ${e}
|
|
2
|
+
`);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=i===s?f(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
3
|
+
`)}for(;;){const n=await q(t,`
|
|
4
|
+
${f(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${f("Invalid choice. Try again.")}
|
|
5
|
+
`)}},Te=async(t,e,r,s)=>{process.stderr.write(` ${e} ${f("(comma-separated numbers)")}
|
|
6
|
+
`);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=s.includes(i)?f(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
7
|
+
`)}for(;;){const n=await q(t,`
|
|
8
|
+
${f("Enter choices:")} `);if(n===""&&s.length>0)return s;const i=n.split(",").map(a=>Number.parseInt(a.trim(),10)).filter(a=>Number.isInteger(a)&&a>=1&&a<=r.length);if(i.length>0)return i.map(a=>r[a-1]);process.stderr.write(` ${f("Invalid choice. Try again.")}
|
|
9
|
+
`)}},Se=t=>` ${f(`${t}:`)} `,Ee=(t,e)=>e.prompt??t,Ne=t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),U=(t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},W=(t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},Re=async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?ae({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of Ne(n)){if(Object.hasOwn(s,o)){const w=U(c,s[o]??"");W(o,c,w),i[o]=w;continue}if(e||!r||c.internal){if(c.default!==void 0){W(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const $=Ee(o,c);let m;if(c.type==="boolean")m=await ve(a,$,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const w=Array.isArray(c.default)?c.default:[];m=await Te(a,$,c.values,w)}else{const w=typeof c.default=="string"?c.default:void 0;m=await be(a,$,c.values,w)}else{const w=c.default===void 0?"":` (${String(c.default)})`,v=await q(a,Se(`${$}${w}`));if(v===""&&c.default!==void 0)m=c.default;else if(v===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=U(c,v)}W(o,c,m),i[o]=m}return i}finally{a?.close()}},je=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],ke=t=>je.some(e=>t.startsWith(e)),_e=async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??ce(T(fe(),"vis-generate-")),n=()=>{if(r)try{le(s,{force:!0,recursive:!0})}catch{}};l.info(`Downloading ${t}…`);try{const i=await pe(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},Q=(t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...Q(n,i))}return r},Oe=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,xe=(t,e)=>{if(P(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=T(t,e),s=K(t,r);if(s===".."||s.startsWith(`..${se}`)||P(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},Ie=(t,e)=>{L(G(t)),oe(t,e)},qe=(t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=ue(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},De=t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},Be=async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:K(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?Q(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=xe(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${g(y("Plan"))} ${f("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${f("write")} ${o.file.path} ${f(`(${Oe(c)})`)}
|
|
10
|
+
`)}}else{L(e.destination);let o=0,c=0;for(const $ of a){const{file:m,meta:w,target:v}=$,D=R(v),b=e.force||w.force===!0;if(D&&!b){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ie(v,m.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=De(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map($=>Promise.resolve(qe($,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
|
|
11
|
+
`),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${f("•")} ${o}
|
|
12
|
+
`)}},We=async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},Pe=(t,e)=>{const r={default:e.default,name:t,order:e.order,prompt:e.prompt,required:e.required,type:e.type};return e.type==="enum"&&(r.multiple=e.multiple,r.values=e.values),r},Ae=async t=>{const e=await t.load(),r=Object.entries(e.options??{}).sort(([s,n],[i,a])=>{const o=n.order??0,c=a.order??0;return o===c?s.localeCompare(i):o-c}).map(([s,n])=>Pe(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},Ce=t=>{if(t.length===0){l.info("No templates found."),l.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}l.info("Available templates:");for(const e of t){const r=f(`(${e.source})`);process.stderr.write(` ${g(y(e.name))} ${r}
|
|
13
|
+
`)}},Me=t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const n=s.indexOf("=");if(n===-1){const o=s.slice(2);o.startsWith("no-")?e[o.slice(3)]="false":e[o]="true";continue}const i=s.slice(2,n),a=s.slice(n+1);e[i]=a}return{overrides:e,remaining:r}},Fe=async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${g(y("vis generate"))} ${f("— pick a template")}
|
|
14
|
+
|
|
15
|
+
`);for(const[s,n]of t.entries()){const i=g(y(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${f(`(${n.source})`)}
|
|
16
|
+
`)}return new Promise((s,n)=>{r.question(`
|
|
17
|
+
${f(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},Le=async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const u=I({extraDirectories:o?.templates??[],onWarning:p=>{l.warn(p)},workspaceRoot:a});if(e.json){const p=await Promise.all(u.map(d=>We(d)));process.stdout.write(`${JSON.stringify(p,null,2)}
|
|
18
|
+
`);return}Ce(u);return}if(e.describe){const u=c[0];if(!u)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const p=I({extraDirectories:o?.templates??[],onWarning:h=>{l.warn(h)},workspaceRoot:a}).find(h=>h.name===u);if(!p)throw new Error(`Template "${u}" not found. Run \`vis generate --list\` to see available templates.`);const d=await Ae(p);if(e.json){process.stdout.write(`${JSON.stringify(d,null,2)}
|
|
19
|
+
`);return}if(l.info(`Template: ${g(y(d.name))} ${f(`(${d.source})`)}`),d.description&&l.info(d.description),d.destination&&l.info(`Destination: ${f(d.destination)}`),d.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const h of d.variables){const O=[h.type];h.required&&O.push("required"),h.default!==void 0&&O.push(`default=${JSON.stringify(h.default)}`),h.values&&O.push(`values=${h.values.join("|")}`),process.stderr.write(` ${g(y(h.name))} ${f(`(${O.join(", ")})`)}
|
|
20
|
+
`)}}return}let $=[...r??[]];if($.length===0){const u=process.argv.slice(2),p=u.indexOf("--");p!==-1&&($=u.slice(p+1))}const m=c.indexOf("--"),w=m===-1?[]:c.slice(m+1),v=m===-1?c:c.slice(0,m),{overrides:D}=Me([...w,...$]);let b,k,_;const E=v[0];let B;if(E&&ke(E)){const u=await _e(E,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});B=u.cleanup;try{const p=I({extraDirectories:[u.directory],workspaceRoot:a}).find(d=>d.path.startsWith(u.directory));if(!p)throw new Error(`Downloaded template at ${u.directory} contains no template.yml or *.ts entrypoint.`);b=await p.load(),k=p.name,_=b.destination}catch(p){throw B(),p}}else{const u=I({extraDirectories:o?.templates??[],onWarning:h=>{l.warn(h)},workspaceRoot:a});if(u.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let p;if(E)p=E;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");p=await Fe(u)}const d=u.find(h=>h.name===p);if(!d)throw new Error(`Template "${p}" not found. Run 'vis generate --list' to see available templates.`);b=await d.load(),k=d.name,_=b.destination}const A=e.to,C=!!e.dryRun,X=!!e.force,M=!!e.defaults,z=!!e.skipScripts,Z=e.interactive!==!1&&!!process.stdin.isTTY&&!M;let S;A?S=A:_?S=_:S=".";const F=P(S)?S:ne(i,S);l.info(`Template: ${g(y(k))}`),l.info(`Target: ${f(F)}`),process.stderr.write(`
|
|
21
|
+
`);const ee=await Re({defaults:M,interactive:Z,overrides:D,variables:b.options??{}});try{await Be(b,{cwd:i,destination:F,dryRun:C,force:X,options:ee,skipScripts:z,workspaceRoot:a}),C||(process.stderr.write(`
|
|
22
|
+
`),l.success(`Template '${k}' applied.`))}finally{B?.()}};export{Le as default};
|