@visulima/vis 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE.md +5760 -4562
- package/dashboard/dist/index.html +12 -12
- package/dist/bin.js +1 -1
- package/dist/binx.js +2 -2
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +6 -6
- package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -1
- package/dist/packem_chunks/agent-instructions.js +7 -7
- package/dist/packem_chunks/bloom-status.js +2 -2
- package/dist/packem_chunks/bloom-sync.js +2 -2
- package/dist/packem_chunks/cache-attestation.js +1 -1
- package/dist/packem_chunks/catalog-detector.js +1 -1
- package/dist/packem_chunks/catalog.js +87 -111
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +192 -217
- package/dist/packem_chunks/defineReleasePlugin.js +3 -3
- package/dist/packem_chunks/detect.js +8 -3
- package/dist/packem_chunks/devtools.js +1 -1
- package/dist/packem_chunks/discord.js +4 -4
- package/dist/packem_chunks/dispatch.js +4 -4
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/extra-files.js +3 -3
- package/dist/packem_chunks/fix.js +11 -11
- package/dist/packem_chunks/git.js +3 -3
- package/dist/packem_chunks/group-tags.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +5 -5
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +16 -16
- package/dist/packem_chunks/handler13.js +5 -5
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -2
- package/dist/packem_chunks/handler21.js +2 -2
- package/dist/packem_chunks/handler22.js +8 -8
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +5 -5
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +3 -3
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +2 -2
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler31.js +2 -2
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +2 -2
- package/dist/packem_chunks/handler34.js +3 -3
- package/dist/packem_chunks/handler35.js +5 -5
- package/dist/packem_chunks/handler36.js +1 -1
- package/dist/packem_chunks/handler37.js +2 -2
- package/dist/packem_chunks/handler38.js +6 -6
- package/dist/packem_chunks/handler39.js +8 -8
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler40.js +34 -34
- package/dist/packem_chunks/handler41.js +5 -5
- package/dist/packem_chunks/handler42.js +4 -4
- package/dist/packem_chunks/handler43.js +3 -3
- package/dist/packem_chunks/handler44.js +2 -2
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +3 -3
- package/dist/packem_chunks/handler49.js +1 -1
- package/dist/packem_chunks/handler5.js +6 -6
- package/dist/packem_chunks/handler50.js +6 -6
- package/dist/packem_chunks/handler51.js +13 -13
- package/dist/packem_chunks/handler52.js +3 -3
- package/dist/packem_chunks/handler53.js +5 -5
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler56.js +4 -4
- package/dist/packem_chunks/handler57.js +5 -5
- package/dist/packem_chunks/handler58.js +5 -5
- package/dist/packem_chunks/handler59.js +8 -8
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler60.js +3 -3
- package/dist/packem_chunks/handler61.js +21 -21
- package/dist/packem_chunks/handler62.js +12 -12
- package/dist/packem_chunks/handler63.js +3 -3
- package/dist/packem_chunks/handler64.js +5 -5
- package/dist/packem_chunks/handler65.js +8 -8
- package/dist/packem_chunks/handler66.js +2 -2
- package/dist/packem_chunks/handler67.js +25 -24
- package/dist/packem_chunks/handler68.js +153 -25
- package/dist/packem_chunks/handler69.js +10 -153
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +22 -10
- package/dist/packem_chunks/handler71.js +17 -17
- package/dist/packem_chunks/handler72.js +104 -104
- package/dist/packem_chunks/handler73.js +20 -20
- package/dist/packem_chunks/handler74.js +45 -45
- package/dist/packem_chunks/handler75.js +27 -3
- package/dist/packem_chunks/handler76.js +3 -27
- package/dist/packem_chunks/handler77.js +68 -68
- package/dist/packem_chunks/handler78.js +30 -30
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +9 -9
- package/dist/packem_chunks/heal.js +11 -11
- package/dist/packem_chunks/help-command.js +7 -63
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_chunks/index2.js +48 -804
- package/dist/packem_chunks/index3.js +3 -7
- package/dist/packem_chunks/index4.js +801 -134
- package/dist/packem_chunks/index5.js +7 -73
- package/dist/packem_chunks/index6.js +73 -0
- package/dist/packem_chunks/index7.js +135 -0
- package/dist/packem_chunks/interface.js +2 -2
- package/dist/packem_chunks/keys-refresh.js +4 -4
- package/dist/packem_chunks/lean.js +3 -3
- package/dist/packem_chunks/list.js +3 -3
- package/dist/packem_chunks/loader.js +4 -4
- package/dist/packem_chunks/loader2.js +1 -1
- package/dist/packem_chunks/orchestrator.js +27 -27
- package/dist/packem_chunks/pre-mode.js +2 -2
- package/dist/packem_chunks/print-config.js +1 -1
- package/dist/packem_chunks/prompts.js +7 -7
- package/dist/packem_chunks/prune.js +3 -3
- package/dist/packem_chunks/publish-guards.js +1 -1
- package/dist/packem_chunks/resolveFormatter.js +5 -5
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/security.js +1 -1
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/slack.js +2 -2
- package/dist/packem_chunks/snapshot.js +2 -2
- package/dist/packem_chunks/stage-publisher.js +1 -1
- package/dist/packem_chunks/staged-registry.js +2 -2
- package/dist/packem_chunks/state.js +3 -3
- package/dist/packem_chunks/status.js +2 -2
- package/dist/packem_chunks/success-walk.js +4 -4
- package/dist/packem_chunks/sync.js +2 -2
- package/dist/packem_chunks/sync2.js +2 -2
- package/dist/packem_chunks/tar.js +3 -3
- package/dist/packem_chunks/tripwire.js +2 -2
- package/dist/packem_chunks/ts-loader.js +5 -9
- package/dist/packem_chunks/verify-lockfile.js +2 -2
- package/dist/packem_chunks/version-resolver.js +2 -2
- package/dist/packem_chunks/webhook.js +1 -1
- package/dist/packem_chunks/workflow-templates.js +5 -5
- package/dist/packem_chunks/workspace.js +2 -2
- package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +1 -0
- package/dist/packem_shared/Table-DyORjLji-CC9cYgCG.js +11 -0
- package/dist/packem_shared/{VisReleaseError-DMGRBTNO.js → VisReleaseError-DZtgcKf8.js} +1 -1
- package/dist/packem_shared/_commonjsHelpers-DTfxOvZk.js +1 -0
- package/dist/packem_shared/advisories-DZd1uGqa.js +1 -0
- package/dist/packem_shared/affected-selection-CoRXp5H4.js +1 -0
- package/dist/packem_shared/affected-shas-Dd0P7fGD.js +1 -0
- package/dist/packem_shared/ai-analysis-DSQQDFU9.js +68 -0
- package/dist/packem_shared/ai-fix-6nXZbecQ.js +43 -0
- package/dist/packem_shared/augment-COAiXSIx.js +4 -0
- package/dist/packem_shared/bin-C2eYtJ_N.js +1 -0
- package/dist/packem_shared/build-scripts-pdVmqXRm.js +1 -0
- package/dist/packem_shared/clean-DRiLimTx.js +1 -0
- package/dist/packem_shared/command-runtime-CiLVo4ED.js +1 -0
- package/dist/packem_shared/{compile-cache-B_Vf_WxT.js → compile-cache-DoMHRsRZ.js} +1 -1
- package/dist/packem_shared/createAdapter-F7GidOzU.js +1 -0
- package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +1 -0
- package/dist/packem_shared/cyclonedx-B1vzerwP.js +4 -0
- package/dist/packem_shared/dependency-scan-DBH2Qo4I.js +1 -0
- package/dist/packem_shared/docker-Bex05Qcn.js +59 -0
- package/dist/packem_shared/failure-log-D92tM0ie.js +2 -0
- package/dist/packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js +4 -0
- package/dist/packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js +1 -0
- package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
- package/dist/packem_shared/glob-Cyk1H9ZL-ox19CSsT.js +1 -0
- package/dist/packem_shared/index-B4AjSxHU.js +1 -0
- package/dist/packem_shared/index-BisalDCf.js +39 -0
- package/dist/packem_shared/{index-BWl4DbMp.js → index-BjdW45xX.js} +1 -1
- package/dist/packem_shared/index-DHD8wb6Z.js +22 -0
- package/dist/packem_shared/index-DXPSWMbG.js +1 -0
- package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
- package/dist/packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js +1 -0
- package/dist/packem_shared/license-DvlYdo6T.js +1 -0
- package/dist/packem_shared/lifecycle-CfTZQHOG.js +2 -0
- package/dist/packem_shared/lockfile-35RFsJDs.js +1 -0
- package/dist/packem_shared/lockfile-DhHAaHN5.js +1 -0
- package/dist/packem_shared/main-BP-w-K-6.js +1 -0
- package/dist/packem_shared/manifests-BNSmpPF_.js +1 -0
- package/dist/packem_shared/min-release-age-ChzTC7_I.js +34 -0
- package/dist/packem_shared/missing-package-json-C0keIt78.js +1 -0
- package/dist/packem_shared/native-config-sync-BSzU4qUO.js +21 -0
- package/dist/packem_shared/osv-bloom-1JS__1or.js +2 -0
- package/dist/packem_shared/otelPlugin-D8LL2-4L.js +1 -0
- package/dist/packem_shared/package-version-Bb7KGF36.js +4 -0
- package/dist/packem_shared/packument-C55kVxcQ.js +1 -0
- package/dist/packem_shared/{peer-warnings-BXAzXqY3.js → peer-warnings-CmYSxvql.js} +1 -1
- package/dist/packem_shared/pm-runner-de-jCq8q.js +1 -0
- package/dist/packem_shared/project-name-filter-DYaIbrXa.js +7 -0
- package/dist/packem_shared/{prompt-BSAy8SMH.js → prompt-DMzaQEVa.js} +1 -1
- package/dist/packem_shared/provenance-CvfQEJPQ.js +1 -0
- package/dist/packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js +1 -0
- package/dist/packem_shared/registry-keys-DmBrAlhg.js +1 -0
- package/dist/packem_shared/resolve-explicit-DYaHAVDg.js +5 -0
- package/dist/packem_shared/resolve-runtime-C7NBCA1C.js +1 -0
- package/dist/packem_shared/run-file-jMngGQhs.js +1 -0
- package/dist/packem_shared/runtime-check-BklgEMkC.js +1 -0
- package/dist/packem_shared/s1ngularity-C8sva2SO.js +1 -0
- package/dist/packem_shared/scan-progress-aVHGZYWf.js +2 -0
- package/dist/packem_shared/selectors-B7lSFz7l.js +3 -0
- package/dist/packem_shared/signatures-oZ_2IneN.js +2 -0
- package/dist/packem_shared/{slug-DoueYuLo.js → slug-OBHcH7wV.js} +1 -1
- package/dist/packem_shared/spinner-CbJfWYwB.js +1 -0
- package/dist/packem_shared/sticky-comment-DjhyCIZt.js +1 -0
- package/dist/packem_shared/subtree-DtmcKAJK.js +2 -0
- package/dist/packem_shared/symbols-BXDZ_sKt.js +1 -0
- package/dist/packem_shared/tabs-BilwonkM.js +1 -0
- package/dist/packem_shared/target-merge-DCGow6Kw.js +4 -0
- package/dist/packem_shared/target-options-d_rIrLyq.js +1 -0
- package/dist/packem_shared/toolchain-DY11tPCw.js +5 -0
- package/dist/packem_shared/typosquats-Cdsnf6aN.js +1 -0
- package/dist/packem_shared/use-measured-height-BPQg2q_p.js +1 -0
- package/dist/packem_shared/utils-DQFHJn72.js +1 -0
- package/dist/packem_shared/verify-D8wYvB85.js +1 -0
- package/dist/packem_shared/vis-update-app-ngwL2mRv.js +1 -0
- package/dist/packem_shared/vis-user-error-CAu9wIbe.js +30 -0
- package/dist/packem_shared/watch-Dswvj6Zp.js +1 -0
- package/dist/packem_shared/watch-loop-COWvvSbR.js +11 -0
- package/dist/packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js +1 -0
- package/dist/release/core/changelog/index.d.ts +62 -2
- package/dist/release/core/package-managers/index.d.ts +25 -1
- package/dist/release/core/package-managers/index.js +1 -1
- package/dist/release/core/version-actions/index.d.ts +47 -2
- package/dist/release/core/version-actions/index.js +1 -1
- package/dist/release/index.d.ts +100 -1
- package/dist/release/index.js +1 -1
- package/dist/release/plugin-sdk.d.ts +16 -1
- package/dist/release/plugin-sdk.js +1 -1
- package/dist/release/presets.js +1 -1
- package/dist/release/types.js +1 -1
- package/dist/runtime/preload.js +1 -1
- package/index.js +26 -26
- package/package.json +14 -14
- package/dist/packem_chunks/detect2.js +0 -8
- package/dist/packem_chunks/registry.js +0 -48
- package/dist/packem_shared/ReleaseClient-BY4OZNCK.js +0 -1
- package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +0 -1
- package/dist/packem_shared/advisories-DsXRmIA5.js +0 -1
- package/dist/packem_shared/affected-selection-BE6VFCDV.js +0 -1
- package/dist/packem_shared/affected-shas-BKEu4RZc.js +0 -1
- package/dist/packem_shared/ai-analysis-DikAj6rX.js +0 -68
- package/dist/packem_shared/ai-fix-bfWo0cZX.js +0 -43
- package/dist/packem_shared/augment-BkJxi_GW.js +0 -4
- package/dist/packem_shared/bin-B-TytgzW.js +0 -1
- package/dist/packem_shared/build-scripts-DWypBQ--.js +0 -1
- package/dist/packem_shared/clean-DWjQl14S.js +0 -1
- package/dist/packem_shared/command-runtime-DQ7ZpLYL.js +0 -1
- package/dist/packem_shared/createAdapter-bU4DIP3F.js +0 -1
- package/dist/packem_shared/createVersionActions-BK43SNDH.js +0 -1
- package/dist/packem_shared/cyclonedx-DLBi65MV.js +0 -4
- package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +0 -1
- package/dist/packem_shared/docker-B4zAZCZG.js +0 -59
- package/dist/packem_shared/en-BDYMmM2_.js +0 -27
- package/dist/packem_shared/failure-log-DyhWPqno.js +0 -2
- package/dist/packem_shared/giget-CAxjpwew.js +0 -2
- package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +0 -1
- package/dist/packem_shared/index-BAe6e0XE.js +0 -1
- package/dist/packem_shared/index-BLtnel38.js +0 -35
- package/dist/packem_shared/index-CuKDxOCI.js +0 -1
- package/dist/packem_shared/index-tNFGWxc0.js +0 -39
- package/dist/packem_shared/index.server-CusjRLCh.js +0 -2
- package/dist/packem_shared/license-t5KnNX6v.js +0 -1
- package/dist/packem_shared/lifecycle-KY9umOg6.js +0 -2
- package/dist/packem_shared/lockfile-YAuZf1gh.js +0 -1
- package/dist/packem_shared/main-D_cam4hv.js +0 -1
- package/dist/packem_shared/manifests-BwTn_1ad.js +0 -1
- package/dist/packem_shared/min-release-age-6avfn81h.js +0 -34
- package/dist/packem_shared/missing-package-json-Cl0vdz6K.js +0 -1
- package/dist/packem_shared/native-config-sync-CHMCJx7H.js +0 -21
- package/dist/packem_shared/osv-bloom-DdqDnLCt.js +0 -2
- package/dist/packem_shared/otelPlugin-DmKDBaPo.js +0 -1
- package/dist/packem_shared/package-version-BNRJ3o9C.js +0 -4
- package/dist/packem_shared/packument-B9-WqReu.js +0 -1
- package/dist/packem_shared/pm-runner-DRybtzOV.js +0 -1
- package/dist/packem_shared/project-name-filter-Dw0fC6IO.js +0 -7
- package/dist/packem_shared/provenance-CLxuqCfL.js +0 -1
- package/dist/packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js +0 -1
- package/dist/packem_shared/registry-keys-cTN24144.js +0 -1
- package/dist/packem_shared/resolve-explicit-Uw6WQl9R.js +0 -5
- package/dist/packem_shared/resolve-runtime-DztanwkZ.js +0 -1
- package/dist/packem_shared/run-file-CaE5_xBY.js +0 -1
- package/dist/packem_shared/runtime-check-C32yE57I.js +0 -1
- package/dist/packem_shared/s1ngularity-BIYhg82u.js +0 -1
- package/dist/packem_shared/scan-progress-DWfY4zkp.js +0 -2
- package/dist/packem_shared/selectors-D2j4M9Ul.js +0 -3
- package/dist/packem_shared/signatures-C8iQ5fUq.js +0 -2
- package/dist/packem_shared/sticky-comment-D6_7-w8T.js +0 -1
- package/dist/packem_shared/subtree-DSm0QEoE.js +0 -2
- package/dist/packem_shared/symbols-DPTlrJ3B.js +0 -1
- package/dist/packem_shared/target-merge-DLxJTcxn.js +0 -11
- package/dist/packem_shared/target-options-3t4-2F-F.js +0 -1
- package/dist/packem_shared/toolchain-BPzbahcQ.js +0 -5
- package/dist/packem_shared/typosquats-BWrmhh36.js +0 -1
- package/dist/packem_shared/use-measured-height-BwAwGHjw.js +0 -1
- package/dist/packem_shared/utils-CRueU43T.js +0 -1
- package/dist/packem_shared/verify-CzUPT6Uk.js +0 -1
- package/dist/packem_shared/vis-update-app-D6Wq8ZHM.js +0 -1
- package/dist/packem_shared/vis-user-error-CfM4_ORo.js +0 -30
- package/dist/packem_shared/watch-D_oAxW_Z.js +0 -1
- package/dist/packem_shared/watch-loop-BrjblOz5.js +0 -11
|
@@ -1,804 +1,48 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# If the last parameter is complete (there is a space following it)
|
|
50
|
-
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
51
|
-
__${t}_debug "Adding extra empty parameter"
|
|
52
|
-
args_to_quote+=("")
|
|
53
|
-
fi
|
|
54
|
-
|
|
55
|
-
# Use Zsh's (q) flag to quote each argument safely for eval
|
|
56
|
-
local quoted_args=("\${(@q)args_to_quote}")
|
|
57
|
-
|
|
58
|
-
# Join the main command and the quoted arguments into a single string for eval
|
|
59
|
-
requestComp="${i} complete -- \${quoted_args[*]}"
|
|
60
|
-
|
|
61
|
-
__${t}_debug "About to call: eval \${requestComp}"
|
|
62
|
-
|
|
63
|
-
# Use eval to handle any environment variables and such
|
|
64
|
-
out=$(eval \${requestComp} 2>/dev/null)
|
|
65
|
-
__${t}_debug "completion output: \${out}"
|
|
66
|
-
|
|
67
|
-
# Extract the directive integer following a : from the last line
|
|
68
|
-
local lastLine
|
|
69
|
-
while IFS='
|
|
70
|
-
' read -r line; do
|
|
71
|
-
lastLine=\${line}
|
|
72
|
-
done < <(printf "%s
|
|
73
|
-
" "\${out[@]}")
|
|
74
|
-
__${t}_debug "last line: \${lastLine}"
|
|
75
|
-
|
|
76
|
-
if [ "\${lastLine[1]}" = : ]; then
|
|
77
|
-
directive=\${lastLine[2,-1]}
|
|
78
|
-
# Remove the directive including the : and the newline
|
|
79
|
-
local suffix
|
|
80
|
-
(( suffix=\${#lastLine}+2))
|
|
81
|
-
out=\${out[1,-$suffix]}
|
|
82
|
-
else
|
|
83
|
-
# There is no directive specified. Leave $out as is.
|
|
84
|
-
__${t}_debug "No directive found. Setting to default"
|
|
85
|
-
directive=0
|
|
86
|
-
fi
|
|
87
|
-
|
|
88
|
-
__${t}_debug "directive: \${directive}"
|
|
89
|
-
__${t}_debug "completions: \${out}"
|
|
90
|
-
__${t}_debug "flagPrefix: \${flagPrefix}"
|
|
91
|
-
|
|
92
|
-
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
93
|
-
__${t}_debug "Completion received error. Ignoring completions."
|
|
94
|
-
return
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
|
-
local activeHelpMarker="%"
|
|
98
|
-
local endIndex=\${#activeHelpMarker}
|
|
99
|
-
local startIndex=$((\${#activeHelpMarker}+1))
|
|
100
|
-
local hasActiveHelp=0
|
|
101
|
-
while IFS='
|
|
102
|
-
' read -r comp; do
|
|
103
|
-
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
104
|
-
if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
105
|
-
__${t}_debug "ActiveHelp found: $comp"
|
|
106
|
-
comp="\${comp[$startIndex,-1]}"
|
|
107
|
-
if [ -n "$comp" ]; then
|
|
108
|
-
compadd -x "\${comp}"
|
|
109
|
-
__${t}_debug "ActiveHelp will need delimiter"
|
|
110
|
-
hasActiveHelp=1
|
|
111
|
-
fi
|
|
112
|
-
continue
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -n "$comp" ]; then
|
|
116
|
-
# If requested, completions are returned with a description.
|
|
117
|
-
# The description is preceded by a TAB character.
|
|
118
|
-
# For zsh's _describe, we need to use a : instead of a TAB.
|
|
119
|
-
# We first need to escape any : as part of the completion itself.
|
|
120
|
-
comp=\${comp//:/\\:}
|
|
121
|
-
|
|
122
|
-
local tab="$(printf '\\t')"
|
|
123
|
-
comp=\${comp//$tab/:}
|
|
124
|
-
|
|
125
|
-
__${t}_debug "Adding completion: \${comp}"
|
|
126
|
-
completions+=\${comp}
|
|
127
|
-
lastComp=$comp
|
|
128
|
-
fi
|
|
129
|
-
done < <(printf "%s
|
|
130
|
-
" "\${out[@]}")
|
|
131
|
-
|
|
132
|
-
# Add a delimiter after the activeHelp statements, but only if:
|
|
133
|
-
# - there are completions following the activeHelp statements, or
|
|
134
|
-
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
135
|
-
if [ $hasActiveHelp -eq 1 ]; then
|
|
136
|
-
if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
137
|
-
__${t}_debug "Adding activeHelp delimiter"
|
|
138
|
-
compadd -x "--"
|
|
139
|
-
hasActiveHelp=0
|
|
140
|
-
fi
|
|
141
|
-
fi
|
|
142
|
-
|
|
143
|
-
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
144
|
-
__${t}_debug "Activating nospace."
|
|
145
|
-
noSpace="-S ''"
|
|
146
|
-
fi
|
|
147
|
-
|
|
148
|
-
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
149
|
-
__${t}_debug "Activating keep order."
|
|
150
|
-
keepOrder="-V"
|
|
151
|
-
fi
|
|
152
|
-
|
|
153
|
-
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
|
154
|
-
# File extension filtering
|
|
155
|
-
local filteringCmd
|
|
156
|
-
filteringCmd='_files'
|
|
157
|
-
for filter in \${completions[@]}; do
|
|
158
|
-
if [ \${filter[1]} != '*' ]; then
|
|
159
|
-
# zsh requires a glob pattern to do file filtering
|
|
160
|
-
filter="\\*.$filter"
|
|
161
|
-
fi
|
|
162
|
-
filteringCmd+=" -g $filter"
|
|
163
|
-
done
|
|
164
|
-
filteringCmd+=" \${flagPrefix}"
|
|
165
|
-
|
|
166
|
-
__${t}_debug "File filtering command: $filteringCmd"
|
|
167
|
-
_arguments '*:filename:'"$filteringCmd"
|
|
168
|
-
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
169
|
-
# File completion for directories only
|
|
170
|
-
local subdir
|
|
171
|
-
subdir="\${completions[1]}"
|
|
172
|
-
if [ -n "$subdir" ]; then
|
|
173
|
-
__${t}_debug "Listing directories in $subdir"
|
|
174
|
-
pushd "\${subdir}" >/dev/null 2>&1
|
|
175
|
-
else
|
|
176
|
-
__${t}_debug "Listing directories in ."
|
|
177
|
-
fi
|
|
178
|
-
|
|
179
|
-
local result
|
|
180
|
-
_arguments '*:dirname:_files -/'" \${flagPrefix}"
|
|
181
|
-
result=$?
|
|
182
|
-
if [ -n "$subdir" ]; then
|
|
183
|
-
popd >/dev/null 2>&1
|
|
184
|
-
fi
|
|
185
|
-
return $result
|
|
186
|
-
else
|
|
187
|
-
__${t}_debug "Calling _describe"
|
|
188
|
-
if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
|
|
189
|
-
__${t}_debug "_describe found some completions"
|
|
190
|
-
|
|
191
|
-
# Return the success of having called _describe
|
|
192
|
-
return 0
|
|
193
|
-
else
|
|
194
|
-
__${t}_debug "_describe did not find completions."
|
|
195
|
-
__${t}_debug "Checking if we should do file completion."
|
|
196
|
-
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
197
|
-
__${t}_debug "deactivating file completion"
|
|
198
|
-
|
|
199
|
-
# Return 0 to indicate completion is finished and prevent zsh from
|
|
200
|
-
# trying other completion algorithms (which could cause hanging).
|
|
201
|
-
# We use NoFileComp directive to explicitly disable file completion.
|
|
202
|
-
return 0
|
|
203
|
-
else
|
|
204
|
-
# Perform file completion
|
|
205
|
-
__${t}_debug "Activating file completion"
|
|
206
|
-
|
|
207
|
-
# We must return the result of this command, so it must be the
|
|
208
|
-
# last command, or else we must store its result to return it.
|
|
209
|
-
_arguments '*:filename:_files'" \${flagPrefix}"
|
|
210
|
-
fi
|
|
211
|
-
fi
|
|
212
|
-
fi
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
# don't run the completion function when being sourced or eval-ed
|
|
216
|
-
if [ "\${funcstack[1]}" = "_${t}" ]; then
|
|
217
|
-
_${t}
|
|
218
|
-
fi
|
|
219
|
-
`}function v(t,i){let e=t.replace(/[-:]/g,"_");return`# bash completion for ${t}
|
|
220
|
-
|
|
221
|
-
# Define shell completion directives
|
|
222
|
-
readonly ShellCompDirectiveError=${n.ShellCompDirectiveError}
|
|
223
|
-
readonly ShellCompDirectiveNoSpace=${n.ShellCompDirectiveNoSpace}
|
|
224
|
-
readonly ShellCompDirectiveNoFileComp=${n.ShellCompDirectiveNoFileComp}
|
|
225
|
-
readonly ShellCompDirectiveFilterFileExt=${n.ShellCompDirectiveFilterFileExt}
|
|
226
|
-
readonly ShellCompDirectiveFilterDirs=${n.ShellCompDirectiveFilterDirs}
|
|
227
|
-
readonly ShellCompDirectiveKeepOrder=${n.ShellCompDirectiveKeepOrder}
|
|
228
|
-
|
|
229
|
-
# Function to debug completion
|
|
230
|
-
__${e}_debug() {
|
|
231
|
-
if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
232
|
-
echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
|
|
233
|
-
fi
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
# Function to handle completions
|
|
237
|
-
__${e}_complete() {
|
|
238
|
-
local cur prev words cword
|
|
239
|
-
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
240
|
-
|
|
241
|
-
local requestComp out directive
|
|
242
|
-
|
|
243
|
-
# Build the command to get completions
|
|
244
|
-
requestComp="${i} complete -- \${words[@]:1}"
|
|
245
|
-
|
|
246
|
-
# Add an empty parameter if the last parameter is complete
|
|
247
|
-
if [[ -z "$cur" ]]; then
|
|
248
|
-
requestComp="$requestComp ''"
|
|
249
|
-
fi
|
|
250
|
-
|
|
251
|
-
# Get completions from the program
|
|
252
|
-
out=$(eval "$requestComp" 2>/dev/null)
|
|
253
|
-
|
|
254
|
-
# Extract directive if present
|
|
255
|
-
directive=0
|
|
256
|
-
if [[ "$out" == *:* ]]; then
|
|
257
|
-
directive=\${out##*:}
|
|
258
|
-
out=\${out%:*}
|
|
259
|
-
fi
|
|
260
|
-
|
|
261
|
-
# Process completions based on directive
|
|
262
|
-
if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
|
|
263
|
-
# Error, no completion
|
|
264
|
-
return
|
|
265
|
-
fi
|
|
266
|
-
|
|
267
|
-
# Apply directives
|
|
268
|
-
if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
|
|
269
|
-
compopt -o nospace
|
|
270
|
-
fi
|
|
271
|
-
if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
|
|
272
|
-
compopt -o nosort
|
|
273
|
-
fi
|
|
274
|
-
if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
|
|
275
|
-
compopt +o default
|
|
276
|
-
fi
|
|
277
|
-
|
|
278
|
-
# Handle file extension filtering
|
|
279
|
-
if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
|
|
280
|
-
local filter=""
|
|
281
|
-
for ext in $out; do
|
|
282
|
-
filter="$filter|$ext"
|
|
283
|
-
done
|
|
284
|
-
filter="\\.($filter)"
|
|
285
|
-
compopt -o filenames
|
|
286
|
-
COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
|
|
287
|
-
return
|
|
288
|
-
fi
|
|
289
|
-
|
|
290
|
-
# Handle directory filtering
|
|
291
|
-
if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
|
|
292
|
-
compopt -o dirnames
|
|
293
|
-
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
294
|
-
return
|
|
295
|
-
fi
|
|
296
|
-
|
|
297
|
-
# Process completions
|
|
298
|
-
local IFS=$'\\n'
|
|
299
|
-
local tab=$(printf '\\t')
|
|
300
|
-
|
|
301
|
-
# Parse completions with descriptions
|
|
302
|
-
local completions=()
|
|
303
|
-
while read -r comp; do
|
|
304
|
-
if [[ "$comp" == *$tab* ]]; then
|
|
305
|
-
# Split completion and description
|
|
306
|
-
local value=\${comp%%$tab*}
|
|
307
|
-
local desc=\${comp#*$tab}
|
|
308
|
-
completions+=("$value")
|
|
309
|
-
else
|
|
310
|
-
completions+=("$comp")
|
|
311
|
-
fi
|
|
312
|
-
done <<< "$out"
|
|
313
|
-
|
|
314
|
-
# Return completions
|
|
315
|
-
COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
# Register completion function
|
|
319
|
-
complete -F __${e}_complete ${t}
|
|
320
|
-
`}function C(t,i){let e=t.replace(/[-:]/g,"_"),o=n.ShellCompDirectiveError,l=n.ShellCompDirectiveNoSpace,r=n.ShellCompDirectiveNoFileComp,s=n.ShellCompDirectiveFilterFileExt,a=n.ShellCompDirectiveFilterDirs;return`# fish completion for ${t} -*- shell-script -*-
|
|
321
|
-
|
|
322
|
-
function __${e}_debug
|
|
323
|
-
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
324
|
-
if test -n "$file"
|
|
325
|
-
echo "$argv" >> $file
|
|
326
|
-
end
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
function __${e}_perform_completion
|
|
330
|
-
__${e}_debug "Starting __${e}_perform_completion"
|
|
331
|
-
|
|
332
|
-
# Extract all args except the last one
|
|
333
|
-
set -l args (commandline -opc)
|
|
334
|
-
# Extract the last arg and escape it in case it is a space or wildcard
|
|
335
|
-
set -l lastArg (string escape -- (commandline -ct))
|
|
336
|
-
|
|
337
|
-
__${e}_debug "args: $args"
|
|
338
|
-
__${e}_debug "last arg: $lastArg"
|
|
339
|
-
|
|
340
|
-
# Build the completion request command
|
|
341
|
-
set -l requestComp "${i} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
|
|
342
|
-
|
|
343
|
-
__${e}_debug "Calling $requestComp"
|
|
344
|
-
set -l results (eval $requestComp 2> /dev/null)
|
|
345
|
-
|
|
346
|
-
# Some programs may output extra empty lines after the directive.
|
|
347
|
-
# Let's ignore them or else it will break completion.
|
|
348
|
-
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
349
|
-
for line in $results[-1..1]
|
|
350
|
-
if test (string trim -- $line) = ""
|
|
351
|
-
# Found an empty line, remove it
|
|
352
|
-
set results $results[1..-2]
|
|
353
|
-
else
|
|
354
|
-
# Found non-empty line, we have our proper output
|
|
355
|
-
break
|
|
356
|
-
end
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
set -l comps $results[1..-2]
|
|
360
|
-
set -l directiveLine $results[-1]
|
|
361
|
-
|
|
362
|
-
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
|
|
363
|
-
# completions must be prefixed with the flag
|
|
364
|
-
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
|
|
365
|
-
|
|
366
|
-
__${e}_debug "Comps: $comps"
|
|
367
|
-
__${e}_debug "DirectiveLine: $directiveLine"
|
|
368
|
-
__${e}_debug "flagPrefix: $flagPrefix"
|
|
369
|
-
|
|
370
|
-
for comp in $comps
|
|
371
|
-
printf "%s%s\\n" "$flagPrefix" "$comp"
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
printf "%s\\n" "$directiveLine"
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
# This function limits calls to __${e}_perform_completion, by caching the result
|
|
378
|
-
function __${e}_perform_completion_once
|
|
379
|
-
__${e}_debug "Starting __${e}_perform_completion_once"
|
|
380
|
-
|
|
381
|
-
if test -n "$__${e}_perform_completion_once_result"
|
|
382
|
-
__${e}_debug "Seems like a valid result already exists, skipping __${e}_perform_completion"
|
|
383
|
-
return 0
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
set --global __${e}_perform_completion_once_result (__${e}_perform_completion)
|
|
387
|
-
if test -z "$__${e}_perform_completion_once_result"
|
|
388
|
-
__${e}_debug "No completions, probably due to a failure"
|
|
389
|
-
return 1
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
__${e}_debug "Performed completions and set __${e}_perform_completion_once_result"
|
|
393
|
-
return 0
|
|
394
|
-
end
|
|
395
|
-
|
|
396
|
-
# This function is used to clear the cached result after completions are run
|
|
397
|
-
function __${e}_clear_perform_completion_once_result
|
|
398
|
-
__${e}_debug ""
|
|
399
|
-
__${e}_debug "========= clearing previously set __${e}_perform_completion_once_result variable =========="
|
|
400
|
-
set --erase __${e}_perform_completion_once_result
|
|
401
|
-
__${e}_debug "Successfully erased the variable __${e}_perform_completion_once_result"
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
function __${e}_requires_order_preservation
|
|
405
|
-
__${e}_debug ""
|
|
406
|
-
__${e}_debug "========= checking if order preservation is required =========="
|
|
407
|
-
|
|
408
|
-
__${e}_perform_completion_once
|
|
409
|
-
if test -z "$__${e}_perform_completion_once_result"
|
|
410
|
-
__${e}_debug "Error determining if order preservation is required"
|
|
411
|
-
return 1
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
set -l directive (string sub --start 2 $__${e}_perform_completion_once_result[-1])
|
|
415
|
-
__${e}_debug "Directive is: $directive"
|
|
416
|
-
|
|
417
|
-
set -l shellCompDirectiveKeepOrder ${n.ShellCompDirectiveKeepOrder}
|
|
418
|
-
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
419
|
-
__${e}_debug "Keeporder is: $keeporder"
|
|
420
|
-
|
|
421
|
-
if test $keeporder -ne 0
|
|
422
|
-
__${e}_debug "This does require order preservation"
|
|
423
|
-
return 0
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
__${e}_debug "This doesn't require order preservation"
|
|
427
|
-
return 1
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
# This function does two things:
|
|
431
|
-
# - Obtain the completions and store them in the global __${e}_comp_results
|
|
432
|
-
# - Return false if file completion should be performed
|
|
433
|
-
function __${e}_prepare_completions
|
|
434
|
-
__${e}_debug ""
|
|
435
|
-
__${e}_debug "========= starting completion logic =========="
|
|
436
|
-
|
|
437
|
-
# Start fresh
|
|
438
|
-
set --erase __${e}_comp_results
|
|
439
|
-
|
|
440
|
-
__${e}_perform_completion_once
|
|
441
|
-
__${e}_debug "Completion results: $__${e}_perform_completion_once_result"
|
|
442
|
-
|
|
443
|
-
if test -z "$__${e}_perform_completion_once_result"
|
|
444
|
-
__${e}_debug "No completion, probably due to a failure"
|
|
445
|
-
# Might as well do file completion, in case it helps
|
|
446
|
-
return 1
|
|
447
|
-
end
|
|
448
|
-
|
|
449
|
-
set -l directive (string sub --start 2 $__${e}_perform_completion_once_result[-1])
|
|
450
|
-
set --global __${e}_comp_results $__${e}_perform_completion_once_result[1..-2]
|
|
451
|
-
|
|
452
|
-
__${e}_debug "Completions are: $__${e}_comp_results"
|
|
453
|
-
__${e}_debug "Directive is: $directive"
|
|
454
|
-
|
|
455
|
-
set -l shellCompDirectiveError ${o}
|
|
456
|
-
set -l shellCompDirectiveNoSpace ${l}
|
|
457
|
-
set -l shellCompDirectiveNoFileComp ${r}
|
|
458
|
-
set -l shellCompDirectiveFilterFileExt ${s}
|
|
459
|
-
set -l shellCompDirectiveFilterDirs ${a}
|
|
460
|
-
|
|
461
|
-
if test -z "$directive"
|
|
462
|
-
set directive 0
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
|
466
|
-
if test $compErr -eq 1
|
|
467
|
-
__${e}_debug "Received error directive: aborting."
|
|
468
|
-
# Might as well do file completion, in case it helps
|
|
469
|
-
return 1
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
|
473
|
-
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
|
474
|
-
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
|
475
|
-
__${e}_debug "File extension filtering or directory filtering not supported"
|
|
476
|
-
# Do full file completion instead
|
|
477
|
-
return 1
|
|
478
|
-
end
|
|
479
|
-
|
|
480
|
-
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
|
481
|
-
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
|
482
|
-
|
|
483
|
-
__${e}_debug "nospace: $nospace, nofiles: $nofiles"
|
|
484
|
-
|
|
485
|
-
# If we want to prevent a space, or if file completion is NOT disabled,
|
|
486
|
-
# we need to count the number of valid completions.
|
|
487
|
-
# To do so, we will filter on prefix as the completions we have received
|
|
488
|
-
# may not already be filtered so as to allow fish to match on different
|
|
489
|
-
# criteria than the prefix.
|
|
490
|
-
if test $nospace -ne 0; or test $nofiles -eq 0
|
|
491
|
-
set -l prefix (commandline -t | string escape --style=regex)
|
|
492
|
-
__${e}_debug "prefix: $prefix"
|
|
493
|
-
|
|
494
|
-
set -l completions (string match -r -- "^$prefix.*" $__${e}_comp_results)
|
|
495
|
-
set --global __${e}_comp_results $completions
|
|
496
|
-
__${e}_debug "Filtered completions are: $__${e}_comp_results"
|
|
497
|
-
|
|
498
|
-
# Important not to quote the variable for count to work
|
|
499
|
-
set -l numComps (count $__${e}_comp_results)
|
|
500
|
-
__${e}_debug "numComps: $numComps"
|
|
501
|
-
|
|
502
|
-
if test $numComps -eq 1; and test $nospace -ne 0
|
|
503
|
-
# We must first split on \\t to get rid of the descriptions to be
|
|
504
|
-
# able to check what the actual completion will be.
|
|
505
|
-
# We don't need descriptions anyway since there is only a single
|
|
506
|
-
# real completion which the shell will expand immediately.
|
|
507
|
-
set -l split (string split --max 1 "\\t" $__${e}_comp_results[1])
|
|
508
|
-
|
|
509
|
-
# Fish won't add a space if the completion ends with any
|
|
510
|
-
# of the following characters: @=/:.,
|
|
511
|
-
set -l lastChar (string sub -s -1 -- $split)
|
|
512
|
-
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
|
513
|
-
# In other cases, to support the "nospace" directive we trick the shell
|
|
514
|
-
# by outputting an extra, longer completion.
|
|
515
|
-
__${e}_debug "Adding second completion to perform nospace directive"
|
|
516
|
-
set --global __${e}_comp_results $split[1] $split[1].
|
|
517
|
-
__${e}_debug "Completions are now: $__${e}_comp_results"
|
|
518
|
-
end
|
|
519
|
-
end
|
|
520
|
-
|
|
521
|
-
if test $numComps -eq 0; and test $nofiles -eq 0
|
|
522
|
-
# To be consistent with bash and zsh, we only trigger file
|
|
523
|
-
# completion when there are no other completions
|
|
524
|
-
__${e}_debug "Requesting file completion"
|
|
525
|
-
return 1
|
|
526
|
-
end
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
return 0
|
|
530
|
-
end
|
|
531
|
-
|
|
532
|
-
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
|
|
533
|
-
# so we can properly delete any completions provided by another script.
|
|
534
|
-
# Only do this if the program can be found, or else fish may print some errors; besides,
|
|
535
|
-
# the existing completions will only be loaded if the program can be found.
|
|
536
|
-
if type -q "${t}"
|
|
537
|
-
# The space after the program name is essential to trigger completion for the program
|
|
538
|
-
# and not completion of the program name itself.
|
|
539
|
-
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
|
540
|
-
complete --do-complete "${t} " > /dev/null 2>&1
|
|
541
|
-
end
|
|
542
|
-
|
|
543
|
-
# Remove any pre-existing completions for the program since we will be handling all of them.
|
|
544
|
-
complete -c ${t} -e
|
|
545
|
-
|
|
546
|
-
# This will get called after the two calls below and clear the cached result
|
|
547
|
-
complete -c ${t} -n '__${e}_clear_perform_completion_once_result'
|
|
548
|
-
# The call to __${e}_prepare_completions will setup __${e}_comp_results
|
|
549
|
-
# which provides the program's completion choices.
|
|
550
|
-
# If this doesn't require order preservation, we don't use the -k flag
|
|
551
|
-
complete -c ${t} -n 'not __${e}_requires_order_preservation && __${e}_prepare_completions' -f -a '$__${e}_comp_results'
|
|
552
|
-
# Otherwise we use the -k flag
|
|
553
|
-
complete -k -c ${t} -n '__${e}_requires_order_preservation && __${e}_prepare_completions' -f -a '$__${e}_comp_results'
|
|
554
|
-
`}function b(t,i){let e=t.replace(/[-:]/g,"_");return`# powershell completion for ${t} -*- shell-script -*-
|
|
555
|
-
|
|
556
|
-
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
557
|
-
function __${t}_debug {
|
|
558
|
-
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
559
|
-
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
filter __${t}_escapeStringWithSpecialChars {
|
|
564
|
-
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
[scriptblock]$__${e}CompleterBlock = {
|
|
568
|
-
param(
|
|
569
|
-
$WordToComplete,
|
|
570
|
-
$CommandAst,
|
|
571
|
-
$CursorPosition
|
|
572
|
-
)
|
|
573
|
-
|
|
574
|
-
# Get the current command line and convert into a string
|
|
575
|
-
$Command = $CommandAst.CommandElements
|
|
576
|
-
$Command = "$Command"
|
|
577
|
-
|
|
578
|
-
__${t}_debug ""
|
|
579
|
-
__${t}_debug "========= starting completion logic =========="
|
|
580
|
-
__${t}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
581
|
-
|
|
582
|
-
# The user could have moved the cursor backwards on the command-line.
|
|
583
|
-
# We need to trigger completion from the $CursorPosition location, so we need
|
|
584
|
-
# to truncate the command-line ($Command) up to the $CursorPosition location.
|
|
585
|
-
# Make sure the $Command is longer then the $CursorPosition before we truncate.
|
|
586
|
-
# This happens because the $Command does not include the last space.
|
|
587
|
-
if ($Command.Length -gt $CursorPosition) {
|
|
588
|
-
$Command = $Command.Substring(0, $CursorPosition)
|
|
589
|
-
}
|
|
590
|
-
__${t}_debug "Truncated command: $Command"
|
|
591
|
-
|
|
592
|
-
$ShellCompDirectiveError=${n.ShellCompDirectiveError}
|
|
593
|
-
$ShellCompDirectiveNoSpace=${n.ShellCompDirectiveNoSpace}
|
|
594
|
-
$ShellCompDirectiveNoFileComp=${n.ShellCompDirectiveNoFileComp}
|
|
595
|
-
$ShellCompDirectiveFilterFileExt=${n.ShellCompDirectiveFilterFileExt}
|
|
596
|
-
$ShellCompDirectiveFilterDirs=${n.ShellCompDirectiveFilterDirs}
|
|
597
|
-
$ShellCompDirectiveKeepOrder=${n.ShellCompDirectiveKeepOrder}
|
|
598
|
-
|
|
599
|
-
# Prepare the command to request completions for the program.
|
|
600
|
-
# Split the command at the first space to separate the program and arguments.
|
|
601
|
-
$Program, $Arguments = $Command.Split(" ", 2)
|
|
602
|
-
|
|
603
|
-
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
604
|
-
__${t}_debug "QuotedArgs: $QuotedArgs"
|
|
605
|
-
|
|
606
|
-
$RequestComp = "& ${i} complete '--' $QuotedArgs"
|
|
607
|
-
__${t}_debug "RequestComp: $RequestComp"
|
|
608
|
-
|
|
609
|
-
# we cannot use $WordToComplete because it
|
|
610
|
-
# has the wrong values if the cursor was moved
|
|
611
|
-
# so use the last argument
|
|
612
|
-
if ($WordToComplete -ne "" ) {
|
|
613
|
-
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
614
|
-
}
|
|
615
|
-
__${t}_debug "New WordToComplete: $WordToComplete"
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
# Check for flag with equal sign
|
|
619
|
-
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
620
|
-
if ( $IsEqualFlag ) {
|
|
621
|
-
__${t}_debug "Completing equal sign flag"
|
|
622
|
-
# Remove the flag part
|
|
623
|
-
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
624
|
-
}
|
|
625
|
-
$HasTrailingEmptyArg = $QuotedArgs -match "(^| )''$"
|
|
626
|
-
__${t}_debug "HasTrailingEmptyArg: $HasTrailingEmptyArg"
|
|
627
|
-
|
|
628
|
-
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag ) -And ( -Not $HasTrailingEmptyArg )) {
|
|
629
|
-
# If the last parameter is complete (there is a space following it)
|
|
630
|
-
# We add an extra empty parameter so we can indicate this to the go method.
|
|
631
|
-
__${t}_debug "Adding extra empty parameter"
|
|
632
|
-
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
633
|
-
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
634
|
-
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
635
|
-
($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
|
|
636
|
-
(($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
|
|
637
|
-
$PSNativeCommandArgumentPassing -eq 'Legacy')) {
|
|
638
|
-
$RequestComp="$RequestComp" + ' \`"\`"'
|
|
639
|
-
} else {
|
|
640
|
-
$RequestComp = "$RequestComp" + ' ""'
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
__${t}_debug "Calling $RequestComp"
|
|
645
|
-
# First disable ActiveHelp which is not supported for Powershell
|
|
646
|
-
$env:ActiveHelp = 0
|
|
647
|
-
|
|
648
|
-
# call the command store the output in $out and redirect stderr and stdout to null
|
|
649
|
-
# $Out is an array contains each line per element
|
|
650
|
-
Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
|
|
651
|
-
|
|
652
|
-
# get directive from last line
|
|
653
|
-
[int]$Directive = $Out[-1].TrimStart(':')
|
|
654
|
-
if ($Directive -eq "") {
|
|
655
|
-
# There is no directive specified
|
|
656
|
-
$Directive = 0
|
|
657
|
-
}
|
|
658
|
-
__${t}_debug "The completion directive is: $Directive"
|
|
659
|
-
|
|
660
|
-
# remove directive (last element) from out
|
|
661
|
-
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
662
|
-
__${t}_debug "The completions are: $Out"
|
|
663
|
-
|
|
664
|
-
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
665
|
-
# Error code. No completion.
|
|
666
|
-
__${t}_debug "Received error from custom completion go code"
|
|
667
|
-
return
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
$Longest = 0
|
|
671
|
-
[Array]$Values = $Out | ForEach-Object {
|
|
672
|
-
# Split the output in name and description
|
|
673
|
-
$Name, $Description = $_.Split("\`t", 2)
|
|
674
|
-
__${t}_debug "Name: $Name Description: $Description"
|
|
675
|
-
|
|
676
|
-
# Look for the longest completion so that we can format things nicely
|
|
677
|
-
if ($Longest -lt $Name.Length) {
|
|
678
|
-
$Longest = $Name.Length
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
# Set the description to a one space string if there is none set.
|
|
682
|
-
# This is needed because the CompletionResult does not accept an empty string as argument
|
|
683
|
-
if (-Not $Description) {
|
|
684
|
-
$Description = " "
|
|
685
|
-
}
|
|
686
|
-
@{ Name = "$Name"; Description = "$Description" }
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
$Space = " "
|
|
691
|
-
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
692
|
-
# remove the space here
|
|
693
|
-
__${t}_debug "ShellCompDirectiveNoSpace is called"
|
|
694
|
-
$Space = ""
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
698
|
-
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
699
|
-
__${t}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
700
|
-
|
|
701
|
-
# return here to prevent the completion of the extensions
|
|
702
|
-
return
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
$Values = $Values | Where-Object {
|
|
706
|
-
# filter the result
|
|
707
|
-
$_.Name -like "$WordToComplete*"
|
|
708
|
-
|
|
709
|
-
# Join the flag back if we have an equal sign flag
|
|
710
|
-
if ( $IsEqualFlag ) {
|
|
711
|
-
__${t}_debug "Join the equal sign flag back to the completion value"
|
|
712
|
-
$_.Name = $Flag + "=" + $_.Name
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
# we sort the values in ascending order by name if keep order isn't passed
|
|
717
|
-
if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
|
|
718
|
-
$Values = $Values | Sort-Object -Property Name
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
722
|
-
__${t}_debug "ShellCompDirectiveNoFileComp is called"
|
|
723
|
-
|
|
724
|
-
if ($Values.Length -eq 0) {
|
|
725
|
-
# Just print an empty string here so the
|
|
726
|
-
# shell does not start to complete paths.
|
|
727
|
-
# We cannot use CompletionResult here because
|
|
728
|
-
# it does not accept an empty string as argument.
|
|
729
|
-
""
|
|
730
|
-
return
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
# Get the current mode
|
|
735
|
-
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
736
|
-
__${t}_debug "Mode: $Mode"
|
|
737
|
-
|
|
738
|
-
$Values | ForEach-Object {
|
|
739
|
-
|
|
740
|
-
# store temporary because switch will overwrite $_
|
|
741
|
-
$comp = $_
|
|
742
|
-
|
|
743
|
-
# PowerShell supports three different completion modes
|
|
744
|
-
# - TabCompleteNext (default windows style - on each key press the next option is displayed)
|
|
745
|
-
# - Complete (works like bash)
|
|
746
|
-
# - MenuComplete (works like zsh)
|
|
747
|
-
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
|
|
748
|
-
|
|
749
|
-
# CompletionResult Arguments:
|
|
750
|
-
# 1) CompletionText text to be used as the auto completion result
|
|
751
|
-
# 2) ListItemText text to be displayed in the suggestion list
|
|
752
|
-
# 3) ResultType type of completion result
|
|
753
|
-
# 4) ToolTip text for the tooltip with details about the object
|
|
754
|
-
|
|
755
|
-
switch ($Mode) {
|
|
756
|
-
|
|
757
|
-
# bash like
|
|
758
|
-
"Complete" {
|
|
759
|
-
|
|
760
|
-
if ($Values.Length -eq 1) {
|
|
761
|
-
__${t}_debug "Only one completion left"
|
|
762
|
-
|
|
763
|
-
# insert space after value
|
|
764
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${t}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
765
|
-
|
|
766
|
-
} else {
|
|
767
|
-
# Add the proper number of spaces to align the descriptions
|
|
768
|
-
while($comp.Name.Length -lt $Longest) {
|
|
769
|
-
$comp.Name = $comp.Name + " "
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
# Check for empty description and only add parentheses if needed
|
|
773
|
-
if ($($comp.Description) -eq " " ) {
|
|
774
|
-
$Description = ""
|
|
775
|
-
} else {
|
|
776
|
-
$Description = " ($($comp.Description))"
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
# zsh like
|
|
784
|
-
"MenuComplete" {
|
|
785
|
-
# insert space after value
|
|
786
|
-
# MenuComplete will automatically show the ToolTip of
|
|
787
|
-
# the highlighted value at the bottom of the suggestions.
|
|
788
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${t}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
# TabCompleteNext and in case we get something unknown
|
|
792
|
-
Default {
|
|
793
|
-
# Like MenuComplete but we don't want to add a space here because
|
|
794
|
-
# the user need to press space anyway to get the completion.
|
|
795
|
-
# Description will not be shown because that's not possible with TabCompleteNext
|
|
796
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${t}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
Register-ArgumentCompleter -CommandName '${t}' -ScriptBlock $__${e}CompleterBlock
|
|
804
|
-
`}const n={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,ShellCompDirectiveDefault:0};var w=class{name;variadic;command;handler;constructor(t,i,e,o=!1){this.command=t,this.name=i,this.handler=e,this.variadic=o}},D=class{value;description;command;handler;alias;isBoolean;constructor(t,i,e,o,l,r){this.command=t,this.value=i,this.description=e,this.handler=o,this.alias=l,this.isBoolean=r}},m=class{value;description;options=new Map;arguments=new Map;parent;constructor(t,i){this.value=t,this.description=i}option(t,i,e,o){let l,r,s;typeof e=="function"?(l=e,r=o,s=!1):typeof e=="string"?(l=void 0,r=e,s=!0):(l=void 0,r=void 0,s=!0);let a=new D(this,t,i,l,r,s);return this.options.set(t,a),this}argument(t,i,e=!1){let o=new w(this,t,i,e);return this.arguments.set(t,o),this}},S=class extends m{commands=new Map;completions=[];directive=n.ShellCompDirectiveDefault;constructor(){super("","")}command(t,i){let e=new m(t,i);return this.commands.set(t,e),e}stripOptions(t){let i=[],e=0;for(;e<t.length;){let o=t[e];if(o.startsWith("-")){e++;let l=!1,r=this.findOption(this,o);if(r)l=r.isBoolean??!1;else for(let[,s]of this.commands){let a=this.findOption(s,o);if(a){l=a.isBoolean??!1;break}}!l&&e<t.length&&!t[e].startsWith("-")&&e++}else i.push(o),e++}return i}matchCommand(t){t=this.stripOptions(t);let i=[],e=[],o=null;for(let l=0;l<t.length;l++){let r=t[l];i.push(r);let s=this.commands.get(i.join(" "));if(s)o=s;else{e=t.slice(l,t.length);break}}return[o||this,e]}shouldCompleteFlags(t,i){if(i.startsWith("-"))return!0;if(t?.startsWith("-")){let e=this.findOption(this,t);if(!e){for(let[,o]of this.commands)if(e=this.findOption(o,t),e)break}return!(e&&e.isBoolean)}return!1}shouldCompleteCommands(t){return!t.startsWith("-")}handleFlagCompletion(t,i,e,o){let l;if(e.includes("=")){let[r]=e.split("=");l=r}else if(o?.startsWith("-")){let r=this.findOption(t,o);r&&!r.isBoolean&&(l=o)}if(l){let r=this.findOption(t,l);if(r?.handler){let s=[];r.handler.call(r,(a,c)=>s.push({value:a,description:c}),t.options),this.completions=s}return}if(e.startsWith("-")){let r=e.startsWith("-")&&!e.startsWith("--"),s=e.replace(/^-+/,"");for(let[a,c]of t.options)r&&c.alias&&`-${c.alias}`.startsWith(e)?this.completions.push({value:`-${c.alias}`,description:c.description}):!r&&a.startsWith(s)&&this.completions.push({value:`--${a}`,description:c.description})}}findOption(t,i){let e=t.options.get(i);if(e||(e=t.options.get(i.replace(/^-+/,"")),e))return e;for(let[o,l]of t.options)if(l.alias&&`-${l.alias}`===i)return l}handleCommandCompletion(t,i){let e=this.stripOptions(t);for(let[o,l]of this.commands){if(o==="")continue;let r=o.split(" ");r.slice(0,e.length).every((s,a)=>s===e[a])&&r[e.length]?.startsWith(i)&&this.completions.push({value:r[e.length],description:l.description})}}handlePositionalCompletion(t,i){let e=this.stripOptions(i),o=t.value.split(" ").length,l=Math.max(0,e.length-o),r=Array.from(t.arguments.entries());if(r.length>0){let s;if(l<r.length){let[a,c]=r[l];s=c}else{let a=r[r.length-1][1];a.variadic&&(s=a)}if(s&&s.handler&&typeof s.handler=="function"){let a=[];s.handler.call(s,(c,d)=>a.push({value:c,description:d}),t.options),this.completions.push(...a)}}}complete(t){this.directive=n.ShellCompDirectiveNoFileComp;let i=new Set;this.completions.filter(e=>i.has(e.value)?!1:(i.add(e.value),!0)).filter(e=>{if(t.includes("=")){let[,o]=t.split("=");return e.value.startsWith(o)}return e.value.startsWith(t)}).forEach(e=>console.log(`${e.value} ${e.description??""}`)),console.log(`:${this.directive}`)}parse(t){this.completions=[];let i=t[t.length-1]==="";i&&t.pop();let e=t[t.length-1]||"",o=t.slice(0,-1);i&&(e!==""&&o.push(e),e="");let[l]=this.matchCommand(o),r=o[o.length-1];this.shouldCompleteFlags(r,e)?this.handleFlagCompletion(l,o,e,r):(this.shouldCompleteCommands(e)&&this.handleCommandCompletion(o,e),l&&l.arguments.size>0&&this.handlePositionalCompletion(l,o)),this.complete(e)}setup(t,i,e){switch(f(e==="zsh"||e==="bash"||e==="fish"||e==="powershell","Unsupported shell"),e){case"zsh":{let o=g(t,i);console.log(o);break}case"bash":{let o=v(t,i);console.log(o);break}case"fish":{let o=C(t,i);console.log(o);break}case"powershell":{let o=b(t,i);console.log(o);break}}}};const y=new S;export{w as Argument,m as Command,D as Option,S as RootCommand,n as ShellCompDirective,y as default};
|
|
1
|
+
import{createRequire as _e}from"node:module";import{VersionActions as _}from"../packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js";import{VisReleaseError as u}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{L as Me}from"../packem_shared/index-BisalDCf.js";import{resolveCleanStripList as De}from"./DEFAULT_CLEAN_KEEP.js";import{assertValidPackageName as F,resolveCustomCommands as W,interpolateCommand as H}from"./security.js";let Ne;const Ee=s=>(Ne??=_e(import.meta.url))(s),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=s=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[e,r]=V.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return V.getBuiltinModule(s)}return Ee(s)},{readFile:A,writeFile:j,rm:Ve,readdir:Oe}=O("node:fs/promises"),{dirname:G,join:f}=O("node:path"),{fileURLToPath:je}=O("node:url"),{mkdtempSync:B,writeFileSync:Re}=O("node:fs"),{tmpdir:J}=O("node:os"),Le=["dependencies","devDependencies","peerDependencies","optionalDependencies"],fe=(s,e)=>{if(s.startsWith("catalog:")||s==="*"||s==="workspace:*"||s==="workspace:^"||s==="workspace:~")return s;if(s.startsWith("workspace:")){const n=s.slice(10);return`workspace:${U(n)}${e}`}if(s.startsWith("npm:")){const n=s.lastIndexOf("@");if(n<=4)return s;const a=s.slice(4,n),t=s.slice(n+1),i=U(t);return`npm:${a}@${i}${e}`}return`${U(s)}${e}`},Te=/^([\^~=]|>=?|<=?)/,U=s=>{const e=Te.exec(s);return e?e[1]??"^":"^"},Gs=async(s,e,r={})=>{const n=r.serializeManifest??Je,a=r.changelogPath??He,t=r.renderChangelogEntry??Ke,i=new Map(s.releases.map(l=>[l.name,l.newVersion])),o=await Promise.all(s.releases.map(async l=>{const m=e.getPackage(l.name);if(!m)return;const b=Fe(m.manifest,l.newVersion,i),w=r.readManifest?.(m.manifestPath),k=a(m);return{changelogEntry:await t(l),changelogPath:k,manifestWrite:{content:n(b,w),path:m.manifestPath}}})),c=[],p=new Map;for(const l of o){if(!l)continue;c.push(l.manifestWrite);const m=p.get(l.changelogPath);m?m.push(l.changelogEntry):p.set(l.changelogPath,[l.changelogEntry])}for(const[l,m]of p){const b=m.join(`
|
|
2
|
+
|
|
3
|
+
`),w=r.readChangelog?.(l);c.push({content:Be(b,w),path:l})}return{deletions:s.consumedChangeFiles.map(l=>l.path),writes:c}},Fe=(s,e,r)=>{const n={...s,version:e};for(const a of Le){const t=s[a];if(!t||typeof t!="object")continue;const i={...t};let o=!1;for(const[c,p]of Object.entries(t)){const l=r.get(c);if(l===void 0)continue;const m=fe(p,l);m!==p&&(i[c]=m,o=!0)}o&&(n[a]=i)}return n},Ue=/^# .+/,Ge=/^## /m,Be=(s,e)=>{const r=s.trim();if(!e||e.trim()==="")return`# Changelog
|
|
4
|
+
|
|
5
|
+
${r}
|
|
6
|
+
`;const n=e.split(/\r?\n/);if(n[0]&&Ue.test(n[0])){let a=1;for(;a<n.length&&!(n[a]??"").startsWith("## ");)a+=1;const t=n.slice(0,a),i=n.slice(a);return t.length>0&&t[t.length-1]!==""&&t.push(""),[...t,r,"",...i].join(`
|
|
7
|
+
`).replaceAll(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`)}return Ge.test(e)?`${r}
|
|
10
|
+
|
|
11
|
+
${e.trimStart()}`:`${r}
|
|
12
|
+
|
|
13
|
+
${e.trimStart()}`},Je=(s,e)=>{const r=We(e);return`${JSON.stringify(s,null,r)}
|
|
14
|
+
`},We=s=>{if(!s)return 4;const e=/\n(\s+)"/.exec(s);if(!e)return 4;const r=(e[1]??"").length;return r===2||r===4?r:4},He=s=>`${s.dir}/CHANGELOG.md`,Ke=s=>{const e=new Date().toISOString().slice(0,10),r=[`## ${s.newVersion}`,`<sub>${e}</sub>`,""];if(s.isCascadeBump||s.isGroupBump)for(const n of s.sources)r.push(`- Version bump from ${n.name}@${n.newVersion}`);else if(s.isDependencyBump&&s.changeFiles.length===0)for(const n of s.sources)n.newVersion===""?r.push(`- Removed dependency ${n.name}`):r.push(`- Updated dependency ${n.name}@${n.newVersion}`);else for(const n of s.changeFiles)for(const a of n.body.split(/\r?\n/)){if(a.trim()===""){r.push("");continue}r.push(a.startsWith("-")||a.startsWith("*")?a:`- ${a}`)}return r.join(`
|
|
15
|
+
`)},qe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],X={default:{},named:{}},Ye=s=>{if(!s)return X;let e;try{e=Me(s,{strict:!0})}catch(a){throw new u({cause:a,code:"CONFIG_INVALID",message:`Failed to parse pnpm-workspace.yaml: ${a.message}`})}if(typeof e!="object"||e===null||Array.isArray(e))return X;const r=e,n={default:{},named:{}};if(typeof r.catalog=="object"&&r.catalog!==null&&!Array.isArray(r.catalog))for(const[a,t]of Object.entries(r.catalog))typeof t=="string"&&(n.default[a]=t);if(typeof r.catalogs=="object"&&r.catalogs!==null&&!Array.isArray(r.catalogs))for(const[a,t]of Object.entries(r.catalogs)){if(typeof t!="object"||t===null||Array.isArray(t))continue;const i={};for(const[o,c]of Object.entries(t))typeof c=="string"&&(i[o]=c);n.named[a]=i}return n},we=(s,e,r)=>{if(!s.startsWith("catalog:"))return s;const n=s.slice(8),a=n===""?r.default:r.named[n];if(a)return a[e]},z=(s,e)=>{const r={...s};for(const n of qe){const a=s[n];if(!a||typeof a!="object")continue;const t={...a};for(const[i,o]of Object.entries(a)){if(!o.startsWith("catalog:"))continue;const c=we(o,i,e);if(c===void 0)throw new u({code:"CONFIG_INVALID",message:`Cannot resolve "${o}" for dependency "${i}" in package "${s.name}". Add it to pnpm-workspace.yaml's "catalog" or "catalogs" block.`,packageName:s.name});t[i]=c}r[n]=t}return r},Bs=Object.defineProperty({__proto__:null,parseCatalogs:Ye,resolveCatalogRef:we,rewriteCatalogRefs:z},Symbol.toStringTag,{value:"Module"}),ze="ACTIONS_ID_TOKEN_REQUEST_URL",Q=s=>{const e=!!s.env[ze],r=!!s.env[s.staticTokenVar],n=s.workspaceConfig?.publish?.preferStaticToken===!0;return e&&!(n&&r)?"oidc":r?"token":"missing"};let R;const Qe="https://github.com/visulima/visulima",Xe=async()=>{try{let e=G(je(import.meta.url));for(let r=0;r<6;r+=1){const n=f(e,"package.json");try{const t=await A(n,"utf8"),i=JSON.parse(t);if(i.name==="@visulima/vis"&&typeof i.version=="string")return i.version}catch{}const a=G(e);if(a===e)break;e=a}}catch{}return"unknown"},Ze=async()=>(R!==void 0||(R=`vis-release/${await Xe()} (+${Qe})`),R),Z=new Map,xe=async s=>{const e=Z.get(s);if(e!==void 0)return e;try{const r=await import("./index7.js").then(a=>a.i),n=new r.ProxyAgent(s);return Z.set(s,n),n}catch{return}},es=s=>s===301||s===302||s===303||s===307||s===308,ss=(s,e)=>{try{const r=new URL(s),n=new URL(e);return r.host===n.host&&r.protocol===n.protocol}catch{return!1}},N=async(s,e={})=>{const r=e.maxRedirects??2,a={"User-Agent":await Ze(),...e.headers};e.headers?.["User-Agent"]&&(a["User-Agent"]=e.headers["User-Agent"]);let t=s,i=0;const o=e.httpProxy?await xe(e.httpProxy):void 0;for(;;){let c;try{const m=e.fetchImpl??globalThis.fetch,b={headers:a,method:e.method??"GET",redirect:"manual"};o&&(b.dispatcher=o),c=await m(t,b)}catch{return{json:async()=>{},ok:!1,status:0,text:async()=>""}}if(!es(c.status))return{json:async()=>{try{return await c.json()}catch{return}},ok:c.ok,status:c.status,text:async()=>{try{return await c.text()}catch{return""}}};const p=c.headers.get("location")??c.headers.get("Location");if(!p||i>=r)return{json:async()=>{},ok:!1,status:0,text:async()=>""};let l;try{l=new URL(p,t).toString()}catch{return{json:async()=>{},ok:!1,status:0,text:async()=>""}}if(!ss(s,l))return{json:async()=>{},ok:!1,status:0,text:async()=>""};t=l,i+=1}},rs="https://crates.io/api/v1/crates",ns="Cargo.toml",x=async s=>{let e;try{e=await A(s,"utf8")}catch(o){throw new u({cause:o,code:"CONFIG_INVALID",file:s,message:`Failed to read Cargo.toml at ${s}: ${o.message}`})}const{parse:r}=await import("./index6.js");let n;try{n=r(e)}catch(o){throw new u({cause:o,code:"CONFIG_INVALID",file:s,message:`Failed to parse Cargo.toml at ${s}: ${o.message}`})}if(!n.package)throw new u({code:"CONFIG_INVALID",file:s,hint:"CargoVersionActions only supports publishable crates with a [package] table. For workspace roots, point per-package config at the member crate directory.",message:`Cargo.toml at ${s} has no [package] table.`});const{name:a}=n.package;if(typeof a!="string"||a.length===0)throw new u({code:"CONFIG_INVALID",file:s,message:`Cargo.toml at ${s} is missing [package].name.`});const t=n.package.version;let i;if(typeof t=="string"?i=t:t&&typeof t=="object"&&t.workspace===!0&&(i=n.workspace?.package?.version),typeof i!="string"||i.length===0)throw new u({code:"CONFIG_INVALID",file:s,hint:"Set [package].version explicitly, or — for workspace-inherited versions — ensure the root Cargo.toml carries [workspace.package].version and point per-package config at it.",message:`Cargo.toml at ${s} has no resolvable [package].version.`});return{name:a,version:i}},ee=async(s,e)=>{const r=`${rs}/${encodeURIComponent(s)}`;try{const n=await N(r,{headers:{Accept:"application/json"},httpProxy:e});if(n.status===404||!n.ok)return;const a=await n.json();return a?.crate?.max_stable_version??a?.crate?.max_version??void 0}catch{return}},as=(s,e)=>Q({env:s,staticTokenVar:"CARGO_REGISTRY_TOKEN",workspaceConfig:e})==="oidc",ts=async(s,e)=>{const r=await s.run("cargo",["package","--list","--allow-dirty"],{cwd:e,silent:!0});return r.exitCode!==0?[]:r.stdout.split(/\r?\n/).map(n=>n.trim()).filter(n=>n.length>0)};class is extends _{id="cargo";async readPublishedVersion(e){const r=K(e.pkg);try{const{name:n}=await x(r);return await ee(n)}catch{return}}async publish(e){if(e.dryRun)return{output:`[dry-run / cargo] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const r=K(e.pkg,e.perPackageConfig),n=os(e.pkg,e.perPackageConfig),{name:a,version:t}=await x(r);if(t!==e.release.newVersion)throw new u({code:"CONFIG_INVALID",file:r,hint:`Confirm the cargo() preset's crateDir points at the directory containing this Cargo.toml. Expected ${e.release.newVersion} on disk after the extra-files bump.`,message:`Cargo.toml version (${t}) does not match planned release version (${e.release.newVersion}) for ${e.pkg.name}.`,packageName:e.pkg.name});if(await ee(a,e.workspaceConfig?.httpProxy)===e.release.newVersion)return{alreadyPublished:!0,output:`[cargo] ${a}@${e.release.newVersion} already on crates.io`,published:!1};const o=as(process.env,e.workspaceConfig);if(!o&&!process.env.CARGO_REGISTRY_TOKEN)throw new u({code:"AUTH_MISSING",hint:"Set CARGO_REGISTRY_TOKEN, or run from a GH-Actions job with `permissions: id-token: write` for OIDC trusted publishing.",message:`Cannot publish ${a}@${e.release.newVersion}: neither CARGO_REGISTRY_TOKEN nor OIDC trusted publishing is available.`,packageName:e.pkg.name});const c=e.workspaceConfig?.publish?.guards;if(c?.packSecretScan){const m=await ts(e.pm.runner,n);if(m.length>0){const{runPackSecretScan:b}=await import("./publish-guards.js"),w=typeof c.packSecretScan=="object"?c.packSecretScan.ignore:void 0,k=await b({files:m,ignore:w,pkgDir:n});if(!k.passed){const{redactTokens:C}=await import("./security.js"),E=k.findings.map(v=>` • [packSecretScan] ${C(v.message)}${v.hint?`
|
|
16
|
+
→ ${C(v.hint)}`:""}`).join(`
|
|
17
|
+
`);throw new u({code:"PUBLISH_FAILED",message:`Pre-publish secret scan failed for ${a}@${e.release.newVersion}:
|
|
18
|
+
${E}`,packageName:e.pkg.name})}}}const p=["publish","--allow-dirty"];e.registry&&e.registry!=="https://crates.io"&&p.push("--registry",e.registry);const l=await e.pm.runner.run("cargo",p,{cwd:n,silent:!1});if(l.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:"Inspect the cargo output above. Common causes: missing CARGO_REGISTRY_TOKEN, OIDC permission misconfigured, version already published, crates.io rate limit. Re-runs are safe — the published-version probe short-circuits subsequent runs.",message:`cargo publish failed for ${a}@${e.release.newVersion}: exit ${l.exitCode}. stderr: ${l.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});return{output:`[cargo] published ${a}@${e.release.newVersion}${o?" (trusted publishing)":""}`,published:!0}}}const K=(s,e)=>{const r=e?.cargoTomlPath??ns;return f(s.dir,r)},os=(s,e)=>G(K(s,e)),cs=["linux/amd64","linux/arm64"],ls=s=>{const e=s.indexOf("/");if(e===-1)return{registry:"docker.io",repository:`library/${s}`};const r=s.slice(0,e),n=s.slice(e+1);return r==="localhost"||r.includes(".")||r.includes(":")?{registry:r,repository:n}:n.includes("/")?{registry:"docker.io",repository:s}:{registry:"docker.io",repository:`${r}/${n}`}},se=(s,e)=>{const{registry:r,repository:n}=ls(s);return`https://${r==="docker.io"?"registry-1.docker.io":r}/v2/${n}/manifests/${encodeURIComponent(e)}`},ke=s=>{const e=s??{};return{buildContext:e.buildContext,containerBuildArgs:e.containerBuildArgs,containerImage:e.containerImage,containerPlatforms:e.containerPlatforms,containerSigning:e.containerSigning,containerSkipLatest:e.containerSkipLatest}},ps=(s,e)=>{const r=ke(s);if(typeof r.containerImage!="string"||r.containerImage.length===0)throw new u({code:"CONFIG_INVALID",hint:["Container packages must declare `containerImage` in their per-pkg release config:","",' release.packages["<pkg>"] = container({',' image: "ghcr.io/scope/foo",',' platforms: ["linux/amd64", "linux/arm64"],',' signing: "cosign", // optional'," })","",'Or set `versionActions: "container"` + `containerImage` directly.'].join(`
|
|
19
|
+
`),message:`containerImage is required for versionActions: "container" on ${e}`,packageName:e});return{buildContext:r.buildContext,containerBuildArgs:r.containerBuildArgs,containerImage:r.containerImage,containerPlatforms:r.containerPlatforms,containerSigning:r.containerSigning,containerSkipLatest:r.containerSkipLatest}};class us extends _{id="container";async readPublishedVersion(e){const r=ke(e.perPackageConfig);if(!r.containerImage)return;const n=e.pkg.version,a=se(r.containerImage,n);try{return(await N(a,{headers:{Accept:["application/vnd.oci.image.manifest.v1+json","application/vnd.oci.image.index.v1+json","application/vnd.docker.distribution.manifest.v2+json","application/vnd.docker.distribution.manifest.list.v2+json"].join(",")},httpProxy:e.workspaceConfig?.httpProxy,method:"HEAD"})).status===200?n:void 0}catch{return}}async publish(e){const r=ps(e.perPackageConfig,e.pkg.name);if(e.dryRun){const{command:t}=re(e,r);return{output:`[dry-run / container] would run: ${t.join(" ")}`,published:!0}}try{const t=se(r.containerImage,e.release.newVersion);if((await N(t,{httpProxy:e.workspaceConfig?.httpProxy,method:"HEAD"})).status===200)return{alreadyPublished:!0,output:`[container] ${r.containerImage}:${e.release.newVersion} already published`,published:!1}}catch{}const{command:n}=re(e,r),a=await e.pm.runner.run(n[0],n.slice(1),{cwd:e.pkg.dir,silent:!1});if(a.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:["docker buildx build failed. Common causes:"," • Not authenticated to the registry — run `docker login <registry>` first."," For ECR: `aws ecr get-login-password --region <r> | docker login --username AWS --password-stdin <account>.dkr.ecr.<r>.amazonaws.com`"," For GCR/GAR: `gcloud auth configure-docker <region>-docker.pkg.dev`"," For GHCR: `echo $GITHUB_TOKEN | docker login ghcr.io -u <user> --password-stdin`"," • Buildx not installed / configured — `docker buildx create --use` (one-time setup)."," • Multi-arch build needs QEMU registered — `docker run --privileged --rm tonistiigi/binfmt --install all`."].join(`
|
|
20
|
+
`),message:`docker buildx failed for ${e.pkg.name}@${e.release.newVersion}: exit ${a.exitCode}. stderr: ${a.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});if(r.containerSigning==="cosign"){const t=`${r.containerImage}:${e.release.newVersion}`,i=await e.pm.runner.run("cosign",["sign","--yes",t],{cwd:e.pkg.dir,silent:!1});if(i.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:"cosign signing failed. For keyless cosign, ensure COSIGN_EXPERIMENTAL=1 (cosign <2.0) and the CI runner has the OIDC token (`id-token: write` permission on GH Actions).",message:`cosign sign failed for ${t}: exit ${i.exitCode}. stderr: ${i.stderr.trim().slice(0,500)}`,packageName:e.pkg.name})}return{output:`[container] published ${r.containerImage}:${e.release.newVersion}${r.containerSkipLatest?"":" + :latest"}${r.containerSigning==="cosign"?" (signed via cosign)":""}`,published:!0}}}const re=(s,e)=>{if(!e.containerImage)throw new Error("buildBuildxCommand requires config.containerImage");const r=(e.containerPlatforms??cs).join(","),n=`${e.containerImage}:${s.release.newVersion}`,a=`${e.containerImage}:latest`,t=e.buildContext??".",i=["docker","buildx","build","--platform",r,"-t",n];e.containerSkipLatest||i.push("-t",a);for(const[o,c]of Object.entries(e.containerBuildArgs??{}))i.push("--build-arg",`${o}=${c}`);return i.push("--label",`org.opencontainers.image.version=${s.release.newVersion}`),i.push("--label",`org.opencontainers.image.title=${s.pkg.name}`),i.push("--push",t),{command:i}},ds="https://jsr.io",ms=/^@[a-z0-9-]+\/[a-z0-9-]+$/i,ne=async s=>{let e;try{e=await A(s,"utf8")}catch(n){throw new u({cause:n,code:"CONFIG_INVALID",file:s,message:`Failed to read JSR manifest at ${s}: ${n.message}`})}let r;try{r=JSON.parse(e)}catch(n){throw new u({cause:n,code:"CONFIG_INVALID",file:s,message:`Failed to parse JSR manifest at ${s}: ${n.message}`})}if(typeof r.name!="string"||r.name.length===0)throw new u({code:"CONFIG_INVALID",file:s,hint:"JSR manifests must declare a `name` field with the `@scope/name` form.",message:`JSR manifest at ${s} is missing the \`name\` field.`});if(!ms.test(r.name))throw new u({code:"CONFIG_INVALID",file:s,hint:"JSR requires every package to publish under `@scope/name`. Add the `@scope/` prefix and lowercase the name (a-z, 0-9, hyphen).",message:`JSR manifest at ${s} declares an invalid \`name\`: "${r.name}". JSR requires the @scope/name form.`});if(typeof r.version!="string"||r.version.length===0)throw new u({code:"CONFIG_INVALID",file:s,hint:"Add a `version` literal to the JSR manifest, or wire the `jsr()` preset so vis bumps it for you.",message:`JSR manifest at ${s} is missing the \`version\` field.`});return{name:r.name,version:r.version}},ae=async(s,e)=>{const r=`${ds}/${s}/meta.json`;try{const n=await N(r,{headers:{Accept:"application/json"},httpProxy:e});if(n.status===404||!n.ok)return;const a=await n.json();return typeof a?.latest=="string"?a.latest:void 0}catch{return}},gs=(s,e)=>Q({env:s,staticTokenVar:"JSR_API_KEY",workspaceConfig:e})==="oidc",te=(s,e)=>{const r=e?.jsrConfigPath??"jsr.json";return f(s.dir,r)};class hs extends _{id="jsr";async readPublishedVersion(e){const r=te(e.pkg,e.perPackageConfig);try{const{name:n}=await ne(r);return await ae(n,e.workspaceConfig?.httpProxy)}catch{return}}async publish(e){if(e.dryRun)return{output:`[dry-run / jsr] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const r=te(e.pkg,e.perPackageConfig),{name:n,version:a}=await ne(r);if(a!==e.release.newVersion)throw new u({code:"CONFIG_INVALID",file:r,hint:`Confirm the jsr() preset's manifestPath points at the JSR config file the extra-files rule rewrites. Expected ${e.release.newVersion} on disk after the bump.`,message:`JSR manifest version (${a}) does not match planned release version (${e.release.newVersion}) for ${e.pkg.name}.`,packageName:e.pkg.name});if(await ae(n,e.workspaceConfig?.httpProxy)===e.release.newVersion)return{alreadyPublished:!0,output:`[jsr] ${n}@${e.release.newVersion} already on jsr.io`,published:!1};const i=gs(process.env,e.workspaceConfig);if(!i&&!process.env.JSR_API_KEY)throw new u({code:"AUTH_MISSING",hint:"Set JSR_API_KEY for static-token auth, or run from a GH-Actions job with `permissions: id-token: write` so ACTIONS_ID_TOKEN_REQUEST_URL is exposed for OIDC trusted publishing.",message:`Cannot publish ${n}@${e.release.newVersion}: neither JSR_API_KEY nor OIDC trusted publishing is available.`,packageName:e.pkg.name});const o=["jsr","publish","--allow-dirty"],c=e.perPackageConfig?.jsrConfigPath;c!==void 0&&c!=="jsr.json"&&o.push("--config",c);for(const l of e.perPackageConfig?.jsrPublishArgs??[])o.push(l);const p=await e.pm.runner.run("npx",o,{cwd:e.pkg.dir,silent:!1});if(p.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:"Inspect the jsr CLI output above. Common causes: invalid JSR_API_KEY, OIDC permission misconfigured, version already published, slow-mode rate limit. Re-runs are safe — the published-version probe short-circuits subsequent runs.",message:`jsr publish failed for ${n}@${e.release.newVersion}: exit ${p.exitCode}. stderr: ${p.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});return{output:`[jsr] published ${n}@${e.release.newVersion}${i?" (trusted publishing)":""}`,published:!0}}}const fs=/<!--[\s\S]*?-->/g,ws=/<project\b[^>]*>([\s\S]*)/i,ie=/<version>\s*([^<]+?)\s*<\/version>/i,oe=/<groupId>\s*([^<]+?)\s*<\/groupId>/i,ce=/<artifactId>\s*([^<]+?)\s*<\/artifactId>/i,ks=/<modules\b[^>]*>[\s\S]*?<module\b/i,le=s=>{const e=s.replaceAll(fs,""),n=ws.exec(e)?.[1]??e,a=n.replaceAll(/<parent\b[\s\S]*?<\/parent>/gi,"").replaceAll(/<dependencyManagement\b[\s\S]*?<\/dependencyManagement>/gi,"").replaceAll(/<dependencies\b[\s\S]*?<\/dependencies>/gi,"").replaceAll(/<build\b[\s\S]*?<\/build>/gi,"").replaceAll(/<profiles\b[\s\S]*?<\/profiles>/gi,"").replaceAll(/<pluginRepositories\b[\s\S]*?<\/pluginRepositories>/gi,"").replaceAll(/<repositories\b[\s\S]*?<\/repositories>/gi,""),t=ie.exec(a)??ie.exec(n),i=oe.exec(a)??oe.exec(n),o=ce.exec(a)??ce.exec(n),c=ks.test(n);return{artifactId:o?.[1],groupId:i?.[1],hasModules:c,version:t?.[1]}},bs=s=>{const e=/<latest>\s*([^<]+?)\s*<\/latest>/i.exec(s);if(e?.[1])return e[1];const r=/<versions>([\s\S]*?)<\/versions>/i.exec(s);return r?[...r[1].matchAll(/<version>\s*([^<]+?)\s*<\/version>/gi)].map(a=>a[1]).at(-1):void 0},ys=(s,e)=>{const r=s.split(".").map(a=>encodeURIComponent(a)).join("/"),n=encodeURIComponent(e);return`https://repo1.maven.org/maven2/${r}/${n}/maven-metadata.xml`},vs=["Native Maven publishing isn't implemented yet. Drop to the generic shell path:","",' release.packages["<your-pkg>"] = {',' ...pomXml({ pomDir: "jvm/sdk" }),',' versionActions: "shell",',' publishCommand: "mvn -B -ntp deploy",',' checkPublished: "",'," }","","Configure either `central-publishing-maven-plugin` (recommended for","Sonatype Central Portal) or `nexus-staging-maven-plugin` (legacy OSSRH)","in your pom.xml, plus credentials in ~/.m2/settings.xml.","","Maven Central does not (yet) support OIDC trusted publishing —","static credentials are required. See docs/guides/release-maven.mdx","for the full setup walkthrough."].join(`
|
|
21
|
+
`);class $s extends _{id="maven";warnedMultiModule=new WeakSet;warnIfMultiModule(e,r){!r.hasModules||this.warnedMultiModule.has(e)||(this.warnedMultiModule.add(e),process.stderr.write(`[vis release] ⚠ ${e.name} (${r.groupId??"?"}:${r.artifactId??"?"}) is a multi-module Maven project (<modules> present). vis treats it as a single artifact for version-read + already-published checks. For proper reactor handling, use \`versionActions: "shell"\` with \`mvn -B -ntp deploy\`.
|
|
22
|
+
`))}async readPublishedVersion(e){const r=e.perPackageConfig??{},n=f(e.pkg.dir,r.pomPath??"pom.xml");let a;try{a=await A(n,"utf8")}catch{return}const t=le(a);if(this.warnIfMultiModule(e.pkg,t),!t.groupId||!t.artifactId||r.mavenMetadataUrl==="")return;const i=r.mavenMetadataUrl??ys(t.groupId,t.artifactId);try{const o=await N(i,{headers:{Accept:"text/xml,application/xml;q=0.9,*/*;q=0.8"},httpProxy:e.workspaceConfig?.httpProxy});if(o.status===404||!o.ok)return;const c=await o.text();return bs(c)}catch{return}}async publish(e){const r=e.perPackageConfig??{},n=f(e.pkg.dir,r.pomPath??"pom.xml");let a;try{const o=await A(n,"utf8");a=le(o)}catch{a=void 0}const t=a?.groupId&&a?.artifactId?`${a.groupId}:${a.artifactId}`:e.pkg.name;if(e.dryRun)return{output:`[dry-run / maven] would publish ${e.pkg.name}@${e.release.newVersion} (${t}) (native publish not yet implemented — would use shell path)`,published:!0};const i=`Failing artifact: ${t}
|
|
23
|
+
Pom: ${n}
|
|
24
|
+
|
|
25
|
+
${vs}`;throw new u({code:"CONFIG_INVALID",hint:i,message:`Native Maven publishing is not implemented for ${e.pkg.name}@${e.release.newVersion} (${t}). Use \`versionActions: "shell"\` with \`mvn deploy\` until the Sonatype Central Portal client lands.`,packageName:e.pkg.name})}}const be=(s,e)=>{if(e===!1)return{...s};const r=new Set(De(e)),n={name:s.name,version:s.version};for(const[a,t]of Object.entries(s))r.has(a)||(n[a]=t);return n},ye="https://registry.npmjs.org/",Is="npm:registry.npmjs.org",pe=async s=>{const e=f(s,"npm");try{return(await Oe(e,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name)}catch{return[]}},Cs=async s=>{const e=s.ACTIONS_ID_TOKEN_REQUEST_URL,r=s.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!e||!r)return;const n=`${e}${e.includes("?")?"&":"?"}audience=${encodeURIComponent(Is)}`,a=await fetch(n,{headers:{Authorization:`Bearer ${r}`}});if(!a.ok)return;const t=await a.json().catch(()=>({}));return typeof t.value=="string"?t.value:void 0},Ps=async(s,e)=>{const r=await fetch(`${ye}-/npm/v1/oidc/token/exchange/package/${encodeURIComponent(s)}`,{headers:{Authorization:`Bearer ${e}`},method:"POST"});if(!r.ok)return;const n=await r.json().catch(()=>({}));return typeof n.token=="string"?n.token:void 0},ue=async(s,e,r)=>{if(e){const a=await Ps(s,e);if(a)return{source:"oidc",token:a}}const n=r.NPM_TOKEN;if(n)return{source:"NPM_TOKEN",token:n};throw new u({code:"AUTH_MISSING",message:`Cannot publish ${s}: OIDC exchange did not succeed and NPM_TOKEN is not set.`,packageName:s})},de=(s,e)=>{Re(s,`//registry.npmjs.org/:_authToken=${e}
|
|
26
|
+
registry=${ye}
|
|
27
|
+
`)};class Ss extends _{id="native-addon";async readPublishedVersion(e){try{F(e.pkg.name);const{execFileSync:r}=await import("node:child_process");return r("npm",["view",e.pkg.name,"version"],{stdio:["ignore","pipe","ignore"]}).toString().trim()||void 0}catch{return}}async publish(e){if(e.dryRun){const c=await pe(e.pkg.dir);return{output:`[dry-run] would publish ${e.pkg.name}@${e.release.newVersion} + ${c.length} platform package(s)`,published:!0}}const r=await pe(e.pkg.dir);if(r.length===0){const{NpmVersionActions:c}=await Promise.resolve().then(()=>Es);return new c().publish(e)}const{env:n}=process,a=await Cs(n),t=e.release.newVersion,i=new Map,o=[];try{await Promise.all(r.map(async g=>{const d=f(e.pkg.dir,"npm",g,"package.json"),h=await A(d,"utf8");i.set(d,h);const $=JSON.parse(h);$.version=t,await j(d,`${JSON.stringify($,null,4)}
|
|
28
|
+
`)}));const{execFileSync:c}=await import("node:child_process"),p=await Promise.all(r.map(async g=>{const d=f(e.pkg.dir,"npm",g),h=f(d,"package.json"),$=await A(h,"utf8"),y=JSON.parse($);F(y.name);const S=await ue(y.name,a,n),I=B(f(J(),"vis-release-napi-"));o.push(I);const P=f(I,".npmrc");return de(P,S.token),{manifest:y,npmrcPath:P,platform:g,platformDir:d}})),l=e.workspaceConfig?.publish?.guards;if(l&&Object.values(l).some(g=>g!==void 0&&g!==!1&&g!=="off")){const{runPublishGuards:g}=await import("./publish-guards.js");for(const{manifest:d,platformDir:h}of p){const $=c("npm",["pack","--dry-run","--json"],{cwd:h,stdio:["ignore","pipe","ignore"]}).toString();let y=[];try{y=JSON.parse($)[0]?.files?.map(P=>P.path)??[]}catch{}const S=await g({config:l,manifest:d,packFiles:y,pkgDir:h,runner:e.pm.runner,sourceManifest:d});if(S.blockers.length>0){const I=S.blockers.flatMap(P=>P.findings.map(T=>` • [${P.gate}] ${T.message}${T.hint?`
|
|
29
|
+
→ ${T.hint}`:""}`)).join(`
|
|
30
|
+
`);throw new u({code:"PUBLISH_FAILED",message:`Pre-publish guards failed for ${d.name}@${t} (platform package):
|
|
31
|
+
${I}`,packageName:d.name})}}}const m=e.tag??"latest",b=(g,d)=>{const h=["publish",g,"--tag",m,"--access","public","--userconfig",d];return e.provenance&&h.push("--provenance"),h};for(const{manifest:g,npmrcPath:d,platformDir:h}of p)try{c("npm",b(h,d),{env:{...n,NPM_CONFIG_USERCONFIG:d},stdio:"inherit"})}catch($){const y=$.message;if(!y.includes("EPUBLISHCONFLICT")&&!y.includes("cannot publish over"))throw new u({cause:$,code:"PUBLISH_FAILED",message:`Failed to publish platform package ${g.name}@${t}: ${y}`,packageName:g.name})}const w=e.versionedManifestByName.get(e.pkg.name)??e.pkg.manifest,k={...w},C={...w.optionalDependencies};for(const{manifest:g}of p)Object.hasOwn(C,g.name)&&(C[g.name]=t);k.optionalDependencies=C;const E=z(k,e.catalogs),v=be(E,e.cleanPackageJsonConfig),L=await A(e.pkg.manifestPath,"utf8");try{await j(e.pkg.manifestPath,`${JSON.stringify(v,null,4)}
|
|
32
|
+
`),F(e.pkg.name);const g=await ue(e.pkg.name,a,n),d=B(f(J(),"vis-release-napi-parent-"));o.push(d);const h=f(d,".npmrc");de(h,g.token);const $=c("npm",["pack","--pack-destination",d,"--json"],{cwd:e.pkg.dir,env:n,stdio:["ignore","pipe","ignore"]}).toString();let y;try{const I=JSON.parse($);I[0]?.filename&&(y=f(d,I[0].filename))}catch{}const S=["publish",y??e.pkg.dir,"--tag",m,"--access","public","--userconfig",h];if(e.provenance&&S.push("--provenance"),c("npm",S,{env:{...n,NPM_CONFIG_USERCONFIG:h},stdio:"inherit"}),y){const{hashTarball:I}=await import("./publish-guards.js");return{published:!0,tarball:await I(y)}}return{published:!0}}finally{await j(e.pkg.manifestPath,L)}}finally{for(const[c,p]of i)try{await j(c,p)}catch{}for(const c of o)try{await Ve(c,{force:!0,recursive:!0})}catch{}}}}const As=async(s,e)=>{const{extractPackFilesFromRaw:r}=await import("./publish-guards.js"),n=r(e.raw);if(n!==void 0)return n;const a=await s.pm.runner.run("npm",["pack","--dry-run","--json"],{cwd:s.pkg.dir,silent:!0});if(a.exitCode!==0)return[];try{return r(JSON.parse(a.stdout))??[]}catch{return[]}},me=1800*1e3,ge=15*1e3,he=s=>{if(s===!0)return{enabled:!0,pollIntervalMs:ge,timeoutMs:me};if(s&&typeof s=="object"){const e=s;return{enabled:!0,pollIntervalMs:e.pollIntervalMs??ge,timeoutMs:e.timeoutMs??me}}return{enabled:!1,pollIntervalMs:0,timeoutMs:0}};class ve extends _{id="npm";async readPublishedVersion(e){try{const r=await e.pm.runner.run("npm",["view",e.pkg.name,"version","--silent"],{cwd:e.pkg.dir,silent:!0});return r.exitCode!==0?void 0:r.stdout.trim()||void 0}catch{return}}async publish(e){if(e.dryRun)return{output:`[dry-run] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};if(e.resumeStageId){const p=he(e.workspaceConfig?.publish?.stage);if(!p.enabled)throw new u({code:"CONFIG_INVALID",message:`Cannot resume stage ${e.resumeStageId} for ${e.pkg.name}@${e.release.newVersion}: publish.stage is now disabled. Resolve the stage manually via \`vis release stage approve|reject ${e.resumeStageId}\`.`,packageName:e.pkg.name});return this.resumeStagedPublish(e,p)}const r=e.perPackageConfig&&e.workspaceConfig?W(e.pkg.name,e.perPackageConfig,e.workspaceConfig):{};if(r.buildCommand){const p=H(r.buildCommand,{name:e.pkg.name,version:e.release.newVersion}),l=await e.pm.runner.run(process.platform==="win32"?"cmd":"sh",process.platform==="win32"?["/c",p]:["-c",p],{cwd:e.pkg.dir,silent:!1});if(l.exitCode!==0)throw new Error(`buildCommand failed for ${e.pkg.name}: exit ${l.exitCode}`)}const n=e.versionedManifestByName.get(e.pkg.name)??e.pkg.manifest,a=Ns(n,e.versionedManifestByName),t=z(a,e.catalogs),i=be(t,e.cleanPackageJsonConfig),o=await import("node:fs/promises"),c=await o.readFile(e.pkg.manifestPath,"utf8");try{if(await o.writeFile(e.pkg.manifestPath,`${JSON.stringify(i,null,4)}
|
|
33
|
+
`),r.publishCommand){const l={name:e.pkg.name,version:e.release.newVersion},m=Array.isArray(r.publishCommand)?r.publishCommand:[r.publishCommand];for(const b of m){const w=H(b,l),k=await e.pm.runner.run(process.platform==="win32"?"cmd":"sh",process.platform==="win32"?["/c",w]:["-c",w],{cwd:e.pkg.dir,silent:!1});if(k.exitCode!==0)throw new Error(`publishCommand failed for ${e.pkg.name}: exit ${k.exitCode}`)}return{output:`[custom] published ${e.pkg.name}@${e.release.newVersion}`,published:!0}}const p=B(f(J(),"vis-release-pack-"));try{const l=await e.pm.pack({cwd:e.pkg.dir,destination:p}),m=e.workspaceConfig?.publish?.guards;if(m&&Object.values(m).some(d=>d!==void 0&&d!==!1&&d!=="off")){const{runPublishGuards:d}=await import("./publish-guards.js"),h=await As(e,l),$=await d({config:m,manifest:i,packFiles:h,pkgDir:e.pkg.dir,runner:e.pm.runner,sourceManifest:e.pkg.manifest});if($.blockers.length>0){const{redactTokens:y}=await import("./security.js"),S=$.blockers.flatMap(I=>I.findings.map(P=>` • [${I.gate}] ${y(P.message)}${P.hint?`
|
|
34
|
+
→ ${y(P.hint)}`:""}`)).join(`
|
|
35
|
+
`);throw new u({code:"PUBLISH_FAILED",message:`Pre-publish guards failed for ${e.pkg.name}@${e.release.newVersion}:
|
|
36
|
+
${S}`,packageName:e.pkg.name})}}const{hashTarball:b}=await import("./publish-guards.js"),w=await b(l.tarball);if((e.workspaceConfig?.publish?.publishStrategy??"npm-publish-tarball")==="native"){const d=e.pm.id;return e.provenance&&d==="bun"&&process.stderr.write(`[vis release] ⚠ publishStrategy "native": bun has no --provenance/OIDC support; ${e.pkg.name}@${e.release.newVersion} publishes without provenance.
|
|
37
|
+
`),e.otp&&d==="yarn"&&process.stderr.write(`[vis release] ⚠ publishStrategy "native": \`yarn npm publish\` ignores --otp; configure 2FA via .yarnrc.yml for ${e.pkg.name}.
|
|
38
|
+
`),{...await e.pm.publishNative({access:"public",cwd:e.pkg.dir,otp:e.otp,provenance:e.provenance,registry:e.registry,tag:e.tag}),tarball:w}}const k=he(e.workspaceConfig?.publish?.stage);if(k.enabled){const{refuseRestrictedOidc:d}=await import("./stage-publisher.js"),h=e.pkg.manifest.publishConfig?.access;d(h)}const C=await e.pm.publish({access:"public",otp:e.otp,provenance:e.provenance,registry:e.registry,stage:k.enabled,tag:e.tag,tarball:l.tarball});if(!k.enabled||!C.stageId)return{...C,tarball:w};const{waitForStageDecision:E}=await import("./stage-publisher.js"),{stageId:v}=C,L=Date.now();process.stderr.write(`[vis release] ⏳ ${e.pkg.name}@${e.release.newVersion} staged (id ${v}). Waiting up to ${Math.round(k.timeoutMs/6e4)}m for a maintainer to approve via npmjs.com or \`npm stage approve ${v}\`...
|
|
39
|
+
`);const g=await E({cwd:e.pkg.dir,onProgress:d=>{d>0&&d%3e5<k.pollIntervalMs&&process.stderr.write(`[vis release] still waiting for ${e.pkg.name} stage decision (${Math.round(d/6e4)}m elapsed)...
|
|
40
|
+
`)},packageName:e.pkg.name,pollIntervalMs:k.pollIntervalMs,runner:e.pm.runner,stageId:v,timeoutMs:k.timeoutMs,version:e.release.newVersion});return g==="approved"?(process.stderr.write(`[vis release] ✓ ${e.pkg.name}@${e.release.newVersion} approved + promoted (${Math.round((Date.now()-L)/1e3)}s).
|
|
41
|
+
`),{...C,stageId:void 0,tarball:w}):g==="rejected"?(process.stdout.write(`::warning::Stage rejected for ${e.pkg.name}@${e.release.newVersion} (id ${v}). Re-stage by re-running the release once the review feedback is addressed.
|
|
42
|
+
`),{alreadyPublished:!1,output:`stage-rejected: ${v}`,published:!1,stageId:v}):(process.stdout.write(`::warning::Stage timeout for ${e.pkg.name}@${e.release.newVersion} (id ${v}) after ${Math.round(k.timeoutMs/6e4)}m. Re-run \`vis release publish\` once a maintainer can approve, or run \`vis release stage approve ${v}\` manually.
|
|
43
|
+
`),{alreadyPublished:!1,output:`stage-timeout: ${v}`,published:!1,stageId:v})}finally{await o.rm(p,{force:!0,recursive:!0})}}finally{await o.writeFile(e.pkg.manifestPath,c)}}async resumeStagedPublish(e,r){const n=e.resumeStageId,a=Date.now();process.stderr.write(`[vis release] ↻ Resuming wait on staged ${e.pkg.name}@${e.release.newVersion} (id ${n}) — tarball already uploaded; not re-publishing.
|
|
44
|
+
`);const{waitForStageDecision:t}=await import("./stage-publisher.js"),i=await t({cwd:e.pkg.dir,onProgress:o=>{o>0&&o%3e5<r.pollIntervalMs&&process.stderr.write(`[vis release] still waiting for ${e.pkg.name} stage decision (resume, ${Math.round(o/6e4)}m elapsed)...
|
|
45
|
+
`)},packageName:e.pkg.name,pollIntervalMs:r.pollIntervalMs,runner:e.pm.runner,stageId:n,timeoutMs:r.timeoutMs,version:e.release.newVersion});return i==="approved"?(process.stderr.write(`[vis release] ✓ ${e.pkg.name}@${e.release.newVersion} approved + promoted on resume (${Math.round((Date.now()-a)/1e3)}s).
|
|
46
|
+
`),{output:`[resumed] published ${e.pkg.name}@${e.release.newVersion}`,published:!0}):i==="rejected"?(process.stdout.write(`::warning::Stage rejected on resume for ${e.pkg.name}@${e.release.newVersion} (id ${n}).
|
|
47
|
+
`),{alreadyPublished:!1,output:`stage-rejected: ${n}`,published:!1,stageId:n}):(process.stdout.write(`::warning::Stage timeout on resume for ${e.pkg.name}@${e.release.newVersion} (id ${n}) after ${Math.round(r.timeoutMs/6e4)}m.
|
|
48
|
+
`),{alreadyPublished:!1,output:`stage-timeout: ${n}`,published:!1,stageId:n})}}const _s=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Ns=(s,e)=>{const r={...s};for(const n of _s){const a=s[n];if(!a||typeof a!="object")continue;const t={...a};for(const[i,o]of Object.entries(a)){if(!o.startsWith("workspace:"))continue;const c=e.get(i);c&&(t[i]=fe(o.slice(10)==="*"?"*":o,c.version),t[i].startsWith("workspace:")&&(t[i]=t[i].slice(10)))}r[n]=t}return r},Es=Object.defineProperty({__proto__:null,NpmVersionActions:ve},Symbol.toStringTag,{value:"Module"});class Vs extends _{id="private";async readPublishedVersion(e){}async publish(e){return{output:`[private] skipped publish for ${e.pkg.name}@${e.release.newVersion}`,published:!1}}}const $e=s=>`https://pypi.org/pypi/${encodeURIComponent(s.toLowerCase())}/json`,Os=(s,e)=>e?.uvLockPath?f(s.dir,e.uvLockPath):f(s.dir,"uv.lock"),js=async(s,e)=>{let r;try{r=await D(s)}catch{return"no-root-pyproject"}if(r===void 0)return"no-root-pyproject";const n=r.tool?.uv?.workspace?.members;if(!Array.isArray(n)||n.length===0)return"no-workspace";const a=e.replace(/^\.\//,"").replaceAll("\\","/");for(const t of n){if(typeof t!="string")continue;const i=t.replace(/^\.\//,"").replaceAll("\\","/");if(i===a)return"member";if(i.endsWith("/*")){const o=i.slice(0,-2);if(a.startsWith(`${o}/`)&&!a.slice(o.length+1).includes("/"))return"member"}if(i.endsWith("/**")){const o=i.slice(0,-3);if(a===o||a.startsWith(`${o}/`))return"member"}}return"missing"},D=async s=>{const e=f(s,"pyproject.toml");let r;try{r=await A(e,"utf8")}catch(a){const{code:t}=a;if(t==="ENOENT")return;throw new u({cause:a,code:"BUMP_FILE_INVALID",file:e,message:`Failed to read ${e}: ${a.message}`})}const{parse:n}=await import("./index6.js");try{return n(r)}catch(a){throw new u({cause:a,code:"BUMP_FILE_INVALID",file:e,message:`Failed to parse ${e}: ${a.message}`})}},Ie=async(s,e)=>{try{return(await s.run("uv",["--version"],{cwd:e,silent:!0})).exitCode===0}catch{return!1}},Ce=s=>{const e=s?.["build-system"]?.["build-backend"];return e?e.startsWith("hatchling")?"hatch":e.startsWith("poetry.core")||e.startsWith("poetry_core")?"poetry":e.startsWith("pdm.backend")||e.startsWith("pdm_backend")?"pdm":e.startsWith("setuptools")?"setuptools":e.startsWith("uv_build")||e.startsWith("uv.build")?"uv":"unknown":"unknown"},Pe=(s,e)=>s==="uv"||s==="unknown"&&e?{backend:s,buildCommand:{args:["build"],binary:"uv"},hasUv:e,publishCommand:{args:["publish"],binary:"uv"}}:{backend:s,buildCommand:{args:["-m","build"],binary:"python"},hasUv:e,publishCommand:{args:["upload","dist/*"],binary:"twine"}},Se=(s,e)=>Q({env:s,staticTokenVar:"TWINE_PASSWORD",workspaceConfig:e}),q=async(s,e)=>{try{const r=await N($e(s),{headers:{Accept:"application/json"},httpProxy:e});return r.status===404||!r.ok?void 0:(await r.json())?.info?.version}catch{return}},Y=(s,e)=>e?.pythonProjectDir?f(s.dir,e.pythonProjectDir):s.dir;class Ae extends _{id="python";async readPublishedVersion(e){const r=Y(e.pkg,e.perPackageConfig),a=(await D(r).catch(()=>{}))?.project?.name??e.pkg.name.replace(/^@[^/]+\//,"");return q(a)}async publish(e){if(e.dryRun)return{output:`[dry-run / python] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const r=e.perPackageConfig??{},n=Y(e.pkg,r),a=await D(n);if(a?.project?.dynamic?.includes("version"))throw new u({code:"CONFIG_INVALID",file:f(n,"pyproject.toml"),hint:"Dynamic versioning isn't supported by PythonVersionActions yet; use versionActions: 'shell' with your build backend's version-bump tool (e.g. `hatch version` or `poetry version` for non-vcs setups).",message:`${e.pkg.name}: pyproject.toml declares dynamic = ["version", ...]; PythonVersionActions requires a static [project] version.`,packageName:e.pkg.name});if(a?.project?.version&&a.project.version!==e.release.newVersion)throw new u({code:"BUMP_FILE_INVALID",file:f(n,"pyproject.toml"),hint:`Ensure the pyproject() preset is wired up for this package so the version literal in [project] is bumped before publish. Expected ${e.release.newVersion}, found ${a.project.version}.`,message:`${e.pkg.name}: pyproject.toml version ${a.project.version} differs from planned ${e.release.newVersion}.`,packageName:e.pkg.name});const t=a?.project?.name??e.pkg.name.replace(/^@[^/]+\//,"");if(await q(t,e.workspaceConfig?.httpProxy)===e.release.newVersion)return{alreadyPublished:!0,output:`[python] ${t}@${e.release.newVersion} already on PyPI`,published:!1};const o=await Ie(e.pm.runner,e.pkg.dir),c=Ce(a),p=Pe(c,o),l=Se(process.env,e.workspaceConfig);if(l==="missing")throw new u({code:"AUTH_MISSING",hint:["Set TWINE_PASSWORD to a PyPI API token (`TWINE_USERNAME=__token__` is injected automatically), OR","configure trusted publishing on PyPI and grant the workflow `permissions: id-token: write` so ACTIONS_ID_TOKEN_REQUEST_URL is exposed.","See https://docs.pypi.org/trusted-publishers/"].join(" "),message:`${e.pkg.name}: no PyPI credentials detected (neither TWINE_PASSWORD nor OIDC trusted-publishing env).`,packageName:e.pkg.name});const m=await e.pm.runner.run(p.buildCommand.binary,p.buildCommand.args,{cwd:n,silent:!1});if(m.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:`Inspect the ${p.buildCommand.binary} ${p.buildCommand.args.join(" ")} output above. Common causes: missing ${p.backend==="uv"?"uv":"build/setuptools/wheel"} dependency, broken pyproject.toml, source files missing from \`include\`.`,message:`${e.pkg.name}: build failed (${p.buildCommand.binary} ${p.buildCommand.args.join(" ")}): exit ${m.exitCode}. stderr: ${m.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});const b={...process.env};l==="token"&&!b.TWINE_USERNAME&&(b.TWINE_USERNAME="__token__");const w=await e.pm.runner.run(p.publishCommand.binary,p.publishCommand.args,{cwd:n,env:b,silent:!1});if(w.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:`Inspect the ${p.publishCommand.binary} output above. Common causes: invalid API token, version already published (this should have been caught by readPublishedVersion — file a vis bug), 2FA required without a token.`,message:`${e.pkg.name}: publish failed (${p.publishCommand.binary} ${p.publishCommand.args.join(" ")}): exit ${w.exitCode}. stderr: ${w.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});return{output:`[python/${p.backend}${p.hasUv?"+uv":""}] published ${t}@${e.release.newVersion}`,published:!0}}}const Js=Object.defineProperty({__proto__:null,PYPI_PROJECT_URL:$e,PythonVersionActions:Ae,checkUvWorkspaceMembership:js,detectAuthMode:Se,detectBackend:Ce,detectUv:Ie,fetchPyPiVersion:q,readPyProject:D,resolveBuildEnv:Pe,resolveProjectDir:Y,resolveUvLockPath:Os},Symbol.toStringTag,{value:"Module"}),M=async(s,e,r,n)=>{const a=H(r,n),t=process.platform==="win32",i=t?"cmd":"sh",o=t?["/c",a]:["-c",a];return s.run(i,o,{cwd:e,silent:!1})};class Rs extends _{id="shell";async readPublishedVersion(e){const r=e.perPackageConfig??{},{workspaceConfig:n}=e;if(!n)return;const a=W(e.pkg.name,r,n);if(!a.checkPublished)return;const t=await M(e.pm.runner,e.pkg.dir,a.checkPublished,{name:e.pkg.name,version:e.pkg.version});if(t.exitCode!==0)return;const i=t.stdout.trim();return/\b\d+\.\d+\.\d+(?:[-+][\w.+-]+)?\b/.exec(i)?.[0]}async publish(e){if(e.dryRun)return{output:`[dry-run / shell] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const{workspaceConfig:r}=e,n=e.perPackageConfig??{};if(!r)throw new u({code:"CONFIG_INVALID",message:`Shell publish actions for ${e.pkg.name} require a workspace config (release.allowCustomCommands gate).`,packageName:e.pkg.name});const a=W(e.pkg.name,n,r);if(!a.publishCommand)throw new u({code:"CONFIG_INVALID",hint:`Set release.allowCustomCommands (workspace-wide boolean or an allow-list including "${e.pkg.name}") and configure release.packages["${e.pkg.name}"].publishCommand.`,message:`Shell publish actions for ${e.pkg.name} require a publishCommand AND the trust gate to permit it.`,packageName:e.pkg.name});const t={name:e.pkg.name,registry:e.registry,tag:e.tag,version:e.release.newVersion};if(a.checkPublished){const o=await M(e.pm.runner,e.pkg.dir,a.checkPublished,t);if(o.exitCode===0&&/\b\d+\.\d+\.\d+(?:[-+][\w.+-]+)?\b/.exec(o.stdout.trim())?.[0]===e.release.newVersion)return{alreadyPublished:!0,output:`[shell] ${e.pkg.name}@${e.release.newVersion} already on the registry`,published:!1}}if(a.buildCommand){const o=await M(e.pm.runner,e.pkg.dir,a.buildCommand,t);if(o.exitCode!==0)throw new u({code:"PUBLISH_FAILED",message:`buildCommand failed for ${e.pkg.name}: exit ${o.exitCode}. stderr: ${o.stderr.trim().slice(0,500)}`,packageName:e.pkg.name})}const i=Array.isArray(a.publishCommand)?a.publishCommand:[a.publishCommand];for(const o of i){const c=await M(e.pm.runner,e.pkg.dir,o,t);if(c.exitCode!==0)throw new u({code:"PUBLISH_FAILED",hint:"Inspect the publishCommand output above. Common causes: missing auth token, registry unreachable, version already published (re-run safe — `checkPublished` short-circuits subsequent runs).",message:`publishCommand failed for ${e.pkg.name}@${e.release.newVersion}: exit ${c.exitCode}. stderr: ${c.stderr.trim().slice(0,500)}`,packageName:e.pkg.name})}return{output:`[shell] published ${e.pkg.name}@${e.release.newVersion}`,published:!0}}}const Ws=s=>{switch(s){case"cargo":return new is;case"container":return new us;case"jsr":return new hs;case"maven":return new $s;case"native-addon":return new Ss;case"private":return new Vs;case"python":return new Ae;case"shell":return new Rs;default:return new ve}};export{fe as a,Ws as b,be as c,Be as d,Gs as e,Bs as f,Js as g,Ye as p,z as r};
|