@visulima/vis 1.0.0-alpha.9 → 1.0.0
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 +1844 -3
- package/LICENSE.md +13515 -10
- package/README.md +215 -39
- package/bin/resolve-binary.mjs +85 -0
- package/bin/vis.mjs +76 -0
- package/dashboard/dist/index.html +152 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +1 -2
- package/dist/binx.js +3 -0
- package/dist/config/index.d.ts +3276 -0
- package/dist/config/index.js +1 -0
- package/dist/generate/index.d.ts +1 -1
- package/dist/generate/index.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +8 -0
- package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -0
- package/dist/packem_chunks/agent-instructions.js +11 -0
- package/dist/packem_chunks/bloom-status.js +2 -0
- package/dist/packem_chunks/bloom-sync.js +2 -0
- package/dist/packem_chunks/cache-attestation.js +1 -0
- package/dist/packem_chunks/catalog-detector.js +1 -0
- package/dist/packem_chunks/catalog.js +114 -0
- package/dist/packem_chunks/cli-exec.js +1 -0
- package/dist/packem_chunks/cli-main.js +268 -0
- package/dist/packem_chunks/defineReleasePlugin.js +3 -0
- package/dist/packem_chunks/detect.js +3 -0
- package/dist/packem_chunks/detect2.js +8 -0
- package/dist/packem_chunks/devtools.js +4 -0
- package/dist/packem_chunks/discord.js +4 -0
- package/dist/packem_chunks/dispatch.js +4 -0
- package/dist/packem_chunks/doctor-probe.js +2 -0
- package/dist/packem_chunks/dynamic-import.js +1 -0
- package/dist/packem_chunks/extra-files.js +3 -0
- package/dist/packem_chunks/fix.js +11 -0
- package/dist/packem_chunks/git.js +3 -0
- package/dist/packem_chunks/group-tags.js +1 -0
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +5 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +26 -152
- package/dist/packem_chunks/handler13.js +5 -1
- package/dist/packem_chunks/handler14.js +1 -3
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -2
- package/dist/packem_chunks/handler17.js +1 -7
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -19
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -428
- package/dist/packem_chunks/handler21.js +2 -22
- package/dist/packem_chunks/handler22.js +14 -3
- package/dist/packem_chunks/handler23.js +1 -5
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -20
- package/dist/packem_chunks/handler26.js +5 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +3 -1
- package/dist/packem_chunks/handler29.js +1 -2
- package/dist/packem_chunks/handler3.js +4 -2
- package/dist/packem_chunks/handler30.js +1 -22
- package/dist/packem_chunks/handler31.js +2 -1
- package/dist/packem_chunks/handler32.js +2 -1
- package/dist/packem_chunks/handler33.js +2 -37
- package/dist/packem_chunks/handler34.js +3 -3
- package/dist/packem_chunks/handler35.js +6 -23
- package/dist/packem_chunks/handler36.js +1 -5
- package/dist/packem_chunks/handler37.js +36 -21
- package/dist/packem_chunks/handler38.js +8 -1
- package/dist/packem_chunks/handler39.js +9 -2
- package/dist/packem_chunks/handler4.js +4 -5
- package/dist/packem_chunks/handler40.js +75 -1
- package/dist/packem_chunks/handler41.js +5 -5
- package/dist/packem_chunks/handler42.js +4 -1
- package/dist/packem_chunks/handler43.js +3 -24
- package/dist/packem_chunks/handler44.js +2 -3
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -0
- package/dist/packem_chunks/handler47.js +1 -0
- package/dist/packem_chunks/handler48.js +3 -0
- package/dist/packem_chunks/handler49.js +1 -0
- package/dist/packem_chunks/handler5.js +6 -4
- package/dist/packem_chunks/handler50.js +7 -0
- package/dist/packem_chunks/handler51.js +33 -0
- package/dist/packem_chunks/handler52.js +3 -0
- package/dist/packem_chunks/handler53.js +8 -0
- package/dist/packem_chunks/handler54.js +4 -0
- package/dist/packem_chunks/handler55.js +1 -0
- package/dist/packem_chunks/handler56.js +12 -0
- package/dist/packem_chunks/handler57.js +11 -0
- package/dist/packem_chunks/handler58.js +5 -0
- package/dist/packem_chunks/handler59.js +11 -0
- package/dist/packem_chunks/handler6.js +8 -2
- package/dist/packem_chunks/handler60.js +3 -0
- package/dist/packem_chunks/handler61.js +22 -0
- package/dist/packem_chunks/handler62.js +61 -0
- package/dist/packem_chunks/handler63.js +3 -0
- package/dist/packem_chunks/handler64.js +6 -0
- package/dist/packem_chunks/handler65.js +9 -0
- package/dist/packem_chunks/handler66.js +2 -0
- package/dist/packem_chunks/handler67.js +24 -0
- package/dist/packem_chunks/handler68.js +25 -0
- package/dist/packem_chunks/handler69.js +153 -0
- package/dist/packem_chunks/handler7.js +1 -24
- package/dist/packem_chunks/handler70.js +10 -0
- package/dist/packem_chunks/handler71.js +23 -0
- package/dist/packem_chunks/handler72.js +322 -0
- package/dist/packem_chunks/handler73.js +708 -0
- package/dist/packem_chunks/handler74.js +48 -0
- package/dist/packem_chunks/handler75.js +27 -0
- package/dist/packem_chunks/handler76.js +3 -0
- package/dist/packem_chunks/handler77.js +190 -0
- package/dist/packem_chunks/handler78.js +38 -0
- package/dist/packem_chunks/handler8.js +1 -6
- package/dist/packem_chunks/handler9.js +1 -8
- package/dist/packem_chunks/heal-accept.js +10 -0
- package/dist/packem_chunks/heal.js +14 -0
- package/dist/packem_chunks/help-command.js +31 -0
- package/dist/packem_chunks/index.js +1 -7
- package/dist/packem_chunks/index2.js +802 -0
- package/dist/packem_chunks/index3.js +7 -0
- package/dist/packem_chunks/index4.js +135 -0
- package/dist/packem_chunks/index5.js +74 -0
- package/dist/packem_chunks/interface.js +2 -0
- package/dist/packem_chunks/keys-refresh.js +4 -0
- package/dist/packem_chunks/lean.js +4 -0
- package/dist/packem_chunks/list.js +3 -0
- package/dist/packem_chunks/loader.js +4 -1
- package/dist/packem_chunks/loader2.js +1 -0
- package/dist/packem_chunks/orchestrator.js +42 -0
- package/dist/packem_chunks/pre-mode.js +2 -0
- package/dist/packem_chunks/print-config.js +2 -0
- package/dist/packem_chunks/prompts.js +7 -0
- package/dist/packem_chunks/prune.js +3 -0
- package/dist/packem_chunks/publish-guards.js +1 -0
- package/dist/packem_chunks/registry.js +48 -0
- package/dist/packem_chunks/resolveFormatter.js +9 -0
- package/dist/packem_chunks/run.js +1 -0
- package/dist/packem_chunks/security.js +1 -0
- package/dist/packem_chunks/shell-runner.js +1 -0
- package/dist/packem_chunks/slack.js +2 -0
- package/dist/packem_chunks/snapshot.js +2 -0
- package/dist/packem_chunks/stage-publisher.js +1 -0
- package/dist/packem_chunks/staged-registry.js +2 -0
- package/dist/packem_chunks/state.js +3 -0
- package/dist/packem_chunks/status.js +2 -0
- package/dist/packem_chunks/success-walk.js +8 -0
- package/dist/packem_chunks/sync.js +2 -0
- package/dist/packem_chunks/sync2.js +2 -0
- package/dist/packem_chunks/tar.js +3 -0
- package/dist/packem_chunks/tripwire.js +2 -0
- package/dist/packem_chunks/ts-loader.js +22 -0
- package/dist/packem_chunks/verify-lockfile.js +2 -0
- package/dist/packem_chunks/version-resolver.js +2 -0
- package/dist/packem_chunks/webhook.js +1 -0
- package/dist/packem_chunks/workflow-templates.js +167 -0
- package/dist/packem_chunks/workspace.js +2 -0
- package/dist/packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js +1 -0
- package/dist/packem_shared/MultiSpinner-B9U0-aE3-B-gIXhFk.js +3 -0
- package/dist/packem_shared/ReleaseClient-BY4OZNCK.js +1 -0
- package/dist/packem_shared/Table-CcVkyULl-DLWu6XHL.js +34 -0
- package/dist/packem_shared/VisReleaseError-DMGRBTNO.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +1 -0
- package/dist/packem_shared/advisories-B76fBVL-.js +1 -0
- package/dist/packem_shared/affected-shas-CCxG4tvm.js +1 -0
- package/dist/packem_shared/ai-analysis-BpVdn20h.js +68 -0
- package/dist/packem_shared/ai-fix-CeGzAT9m.js +43 -0
- package/dist/packem_shared/anolilab-text-CAM_E6uK.js +13 -0
- package/dist/packem_shared/api.d-BPftyU9r.d.ts +27 -0
- package/dist/packem_shared/augment-DaSS2Lgs.js +4 -0
- package/dist/packem_shared/bin-BlGVEhl8.js +1 -0
- package/dist/packem_shared/build-scripts-q__dKE2y.js +1 -0
- package/dist/packem_shared/command-runtime-3FTGuUsK.js +1 -0
- package/dist/packem_shared/compile-cache-B_Vf_WxT.js +3 -0
- package/dist/packem_shared/createAdapter-bU4DIP3F.js +1 -0
- package/dist/packem_shared/createVersionActions-BK43SNDH.js +1 -0
- package/dist/packem_shared/cyclonedx-CmrYQ0vx.js +4 -0
- package/dist/packem_shared/defineFormatter-D5dCp6Kv.js +1 -0
- package/dist/packem_shared/definePlugin-DoUcoYSy.js +1 -0
- package/dist/packem_shared/dependency-scan-DpOFiZuI.js +1 -0
- package/dist/packem_shared/docker-BYqiD711.js +59 -0
- package/dist/packem_shared/env-DdQRnEIy.js +27 -0
- package/dist/packem_shared/failure-log-CKMhqLWr.js +2 -0
- package/dist/packem_shared/giget-DVTFJlbR.js +2 -0
- package/dist/packem_shared/glob-fqg4KepW-1S3z30c8.js +1 -0
- package/dist/packem_shared/index-B0EsgdzO.js +1 -0
- package/dist/packem_shared/index-CE6MsgcV.js +22 -0
- package/dist/packem_shared/index-Cg0IHaFI.js +1 -0
- package/dist/packem_shared/index-Cg71MisW.js +1 -0
- package/dist/packem_shared/index-DjTWo3sH.js +1 -0
- package/dist/packem_shared/index-jJNulo5i.js +28 -0
- package/dist/packem_shared/index.server-J83sowC4.js +2 -0
- package/dist/packem_shared/interface.d-B7VK2rcH.d.ts +148 -0
- package/dist/packem_shared/interface.d-Cezzifoh.d.ts +106 -0
- package/dist/packem_shared/license-t5KnNX6v.js +1 -0
- package/dist/packem_shared/lifecycle-aDTZ8dW1.js +2 -0
- package/dist/packem_shared/lockfile-C1qCKGH6.js +1 -0
- package/dist/packem_shared/main-B3juSU5z.js +1 -0
- package/dist/packem_shared/manifests-DSBr3-dw.js +1 -0
- package/dist/packem_shared/min-release-age-C71MO72F.js +34 -0
- package/dist/packem_shared/missing-package-json-CTF71tE5.js +1 -0
- package/dist/packem_shared/native-config-sync-D-z2Uwqu.js +21 -0
- package/dist/packem_shared/osv-bloom-DMhXP184.js +2 -0
- package/dist/packem_shared/otelPlugin-DmKDBaPo.js +1 -0
- package/dist/packem_shared/packument-aGzYwXKn.js +1 -0
- package/dist/packem_shared/peer-warnings-BXAzXqY3.js +1 -0
- package/dist/packem_shared/plugins.d-ND23R9I3.d.ts +4 -0
- package/dist/packem_shared/pm-runner-CQcraCcu.js +1 -0
- package/dist/packem_shared/prompt-DjXHVgYU.js +1 -0
- package/dist/packem_shared/provenance-S7y0BRAt.js +1 -0
- package/dist/packem_shared/public-api-WqUCiyIe.js +131 -0
- package/dist/packem_shared/readJsonSync-DuMMeB3s-ihoybKvs.js +1 -0
- package/dist/packem_shared/registry-keys-CRnXATt2.js +1 -0
- package/dist/packem_shared/resolve-explicit-CJGazevw.js +5 -0
- package/dist/packem_shared/resolve-runtime-QRaQucfL.js +1 -0
- package/dist/packem_shared/run-file-DD7Ne23Z.js +1 -0
- package/dist/packem_shared/runtime-check-qnrPTlma.js +1 -0
- package/dist/packem_shared/runtime-process-Dmz0vCJy-DUwTvH1J.js +1 -0
- package/dist/packem_shared/s1ngularity-BLj4Jy8z.js +1 -0
- package/dist/packem_shared/scan-progress-BDcl7Kty.js +2 -0
- package/dist/packem_shared/selectors-D4iCvITE.js +3 -0
- package/dist/packem_shared/signatures-DoNG2hEr.js +2 -0
- package/dist/packem_shared/slug-DoueYuLo.js +1 -0
- package/dist/packem_shared/spinner-DuJJvFTl.js +1 -0
- package/dist/packem_shared/sticky-comment-D6_7-w8T.js +1 -0
- package/dist/packem_shared/subtree-C7bZuiSQ.js +2 -0
- package/dist/packem_shared/symbols-DPTlrJ3B.js +1 -0
- package/dist/packem_shared/tabs-CgxCvjCY.js +1 -0
- package/dist/packem_shared/target-merge-Dg25Izl5.js +11 -0
- package/dist/packem_shared/target-options-CR0OuYJr.js +1 -0
- package/dist/packem_shared/toolchain-Zb3VzZb4.js +5 -0
- package/dist/packem_shared/typosquats-C12CP_2G.js +1 -0
- package/dist/packem_shared/use-measured-height-CjS7Tks7.js +1 -0
- package/dist/packem_shared/utils-CRueU43T.js +1 -0
- package/dist/packem_shared/verify-DStfg3nb.js +1 -0
- package/dist/packem_shared/vis-update-app-BlocL713.js +1 -0
- package/dist/packem_shared/watch-BXNI7dC6.js +1 -0
- package/dist/packem_shared/watch-loop-BZudYfcl.js +11 -0
- package/dist/release/core/changelog/index.d.ts +5 -0
- package/dist/release/core/changelog/index.js +1 -0
- package/dist/release/core/package-managers/index.d.ts +6 -0
- package/dist/release/core/package-managers/index.js +1 -0
- package/dist/release/core/version-actions/index.d.ts +14 -0
- package/dist/release/core/version-actions/index.js +1 -0
- package/dist/release/index.d.ts +233 -0
- package/dist/release/index.js +1 -0
- package/dist/release/plugin-sdk.d.ts +128 -0
- package/dist/release/plugin-sdk.js +1 -0
- package/dist/release/presets.d.ts +225 -0
- package/dist/release/presets.js +1 -0
- package/dist/release/types.d.ts +1493 -0
- package/dist/release/types.js +1 -0
- package/dist/runtime/preload.d.ts +1 -0
- package/dist/runtime/preload.js +1 -0
- package/index.d.ts +450 -0
- package/index.js +80 -57
- package/package.json +87 -44
- package/schemas/project.schema.json +872 -225
- package/schemas/vis-config.schema.json +6309 -264
- package/schemas/vis-release-config.schema.json +1423 -0
- package/skills/vis/SKILL.md +96 -0
- package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
- package/templates/buildkite-ci/template.yml +20 -0
- package/dist/config.d.ts +0 -1087
- package/dist/config.js +0 -1
- package/dist/packem_shared/VisUpdateApp-BBx3idMI.js +0 -1
- package/dist/packem_shared/ai-analysis-DDqXRFxY.js +0 -67
- package/dist/packem_shared/bin-BaZZ32BK.js +0 -93
- package/dist/packem_shared/cache-directory-DL8hfXeG.js +0 -1
- package/dist/packem_shared/catalog-CuSpuB_R.js +0 -12
- package/dist/packem_shared/dependency-scan-BoLG2Fez.js +0 -1
- package/dist/packem_shared/docker-BcfqH4Av.js +0 -2
- package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
- package/dist/packem_shared/otelPlugin-DxyvBcXO.js +0 -1
- package/dist/packem_shared/runtime-check-CGHal8SO.js +0 -1
- package/dist/packem_shared/selectors-CfH9ZY08.js +0 -3
- package/dist/packem_shared/symbols-CIMw60-G.js +0 -1
- package/dist/packem_shared/toolchain-C3ZG0o_X.js +0 -5
- package/dist/packem_shared/typosquats-Bpq4zcWL.js +0 -1
- package/dist/packem_shared/utils-DrNg0XTR.js +0 -1
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`);
|
|
3
|
-
${r}`:r:n={command:r,id:"(custom)"}}return n&&t.push(n),t},"parseStageScript"),ke=P((e,t)=>{const s=l(e,t),n=[],r=new Set(z);if(y(s))for(const o of q(s)){if(o.startsWith(".")||o==="_"||!r.has(o))continue;const i=l(s,o);if(!C(i).isFile())continue;const a=A(i),u=me(a);n.push({blocks:u,rawLineCount:a.split(`
|
|
4
|
-
`).length,stage:o})}return n.sort((o,i)=>o.stage.localeCompare(i.stage)),{hooksDirectory:t,stages:n}},"listHooks"),ye=P(e=>{const t=[];if(e.stages.length===0)return t.push(`No hooks installed in ${e.hooksDirectory}/.`),t;t.push(`Hooks in ${e.hooksDirectory}/:`);for(const s of e.stages)if(t.push("",`${s.stage} (${s.rawLineCount} lines)`),s.blocks.length===0)t.push(" (empty)");else for(const n of s.blocks){const r=n.name?`${n.id} — ${n.name}`:n.id;t.push(` - ${r}`);const o=n.command.split(`
|
|
5
|
-
`).find(i=>i.trim()!=="");if(o){const i=o.length>120?`${o.slice(0,117)}...`:o;t.push(` ${i}`)}}return t},"formatListResult"),be=P((e,t)=>{const s=ke(j(),e);for(const n of ye(s))t.info(n)},"runList"),E="prek-runner.mjs",xe={css:["css","scss","sass","less"],dockerfile:["dockerfile"],html:["htm","html"],javascript:["cjs","js","jsx","mjs"],json:["json"],jsx:["jsx","tsx"],makefile:["mk","makefile"],markdown:["markdown","md","mdown","mdx"],python:["py","pyi","pyw"],python3:["py","pyi","pyw"],ruby:["rb"],rust:["rs"],shell:["bash","sh","zsh"],sql:["sql"],svg:["svg"],systemd:["service","socket","timer"],toml:["toml"],tsx:["tsx"],typescript:["cts","mts","ts","tsx"],xml:["xml"],yaml:["yaml","yml"]},we=["binary","directory","executable","non-executable","symlink","text"],ve={bash:["bash","shell"],node:["javascript"],nodejs:["javascript"],perl:["perl"],python:["python"],python3:["python","python3"],ruby:["ruby"],sh:["shell"],zsh:["shell","zsh"]},$e=["check-json","check-merge-conflict","end-of-file-fixer","mixed-line-ending","trailing-whitespace"],Ee=[...Object.keys(xe),...Object.values(ve).flat(),...we],Se=["#!/usr/bin/env node","// Auto-generated by `vis hook migrate`. Do not edit by hand.","// Replicates the subset of prek / pre-commit framework semantics that a vis","// hook script needs: staged-file discovery, regex + type filters, chunked","// argv dispatch, and a handful of built-in hook implementations.","","import { spawnSync } from 'node:child_process';","import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';","import { basename, extname, join } from 'node:path';","import process from 'node:process';","","const TYPES_EXTENSION_MAP = {"," css: ['css', 'scss', 'sass', 'less'],"," dockerfile: ['dockerfile'],"," html: ['htm', 'html'],"," javascript: ['cjs', 'js', 'jsx', 'mjs'],"," json: ['json'],"," jsx: ['jsx', 'tsx'],"," makefile: ['mk', 'makefile'],"," markdown: ['markdown', 'md', 'mdown', 'mdx'],"," python: ['py', 'pyi', 'pyw'],"," python3: ['py', 'pyi', 'pyw'],"," ruby: ['rb'],"," rust: ['rs'],"," shell: ['bash', 'sh', 'zsh'],"," sql: ['sql'],"," svg: ['svg'],"," systemd: ['service', 'socket', 'timer'],"," toml: ['toml'],"," tsx: ['tsx'],"," typescript: ['cts', 'mts', 'ts', 'tsx'],"," xml: ['xml'],"," yaml: ['yaml', 'yml'],","};","","const FILENAME_TYPE_MAP = {"," dockerfile: 'dockerfile',"," makefile: 'makefile',"," 'gnumakefile': 'makefile',","};","","const SHEBANG_INTERPRETER_MAP = {"," bash: ['bash', 'shell'],"," node: ['javascript'],"," nodejs: ['javascript'],"," perl: ['perl'],"," python: ['python'],"," python3: ['python', 'python3'],"," ruby: ['ruby'],"," sh: ['shell'],"," zsh: ['shell', 'zsh'],","};","","const BUILTINS = {"," 'check-json': runCheckJson,"," 'check-merge-conflict': runCheckMergeConflict,"," 'end-of-file-fixer': runEndOfFileFixer,"," 'mixed-line-ending': runMixedLineEnding,"," 'trailing-whitespace': runTrailingWhitespace,","};","","const parseArgs = (argv) => {"," const flags = {"," allFiles: process.env.VIS_HOOK_ALL_FILES === '1',"," alwaysRun: false,"," builtin: null,"," exclude: null,"," excludeTypes: [],"," files: null,"," fromRef: process.env.VIS_HOOK_FROM_REF || null,"," passFilenames: true,"," toRef: process.env.VIS_HOOK_TO_REF || null,"," types: [],"," typesOr: [],"," };"," const rest = [];"," let seenDoubleDash = false;",""," for (let i = 0; i < argv.length; i += 1) {"," const arg = argv[i];",""," if (seenDoubleDash) {"," rest.push(arg);"," continue;"," }",""," switch (arg) {"," case '--':"," seenDoubleDash = true;"," break;"," case '--all-files':"," flags.allFiles = true;"," break;"," case '--always-run':"," flags.alwaysRun = true;"," break;"," case '--builtin':"," i += 1;"," flags.builtin = argv[i];"," break;"," case '--exclude':"," i += 1;"," flags.exclude = argv[i];"," break;"," case '--from-ref':"," i += 1;"," flags.fromRef = argv[i];"," break;"," case '--to-ref':"," i += 1;"," flags.toRef = argv[i];"," break;"," case '--exclude-types':"," i += 1;"," flags.excludeTypes = (argv[i] || '').split(',').filter(Boolean);"," break;"," case '--files':"," i += 1;"," flags.files = argv[i];"," break;"," case '--no-pass-filenames':"," flags.passFilenames = false;"," break;"," case '--types':"," i += 1;"," flags.types = (argv[i] || '').split(',').filter(Boolean);"," break;"," case '--types-or':"," i += 1;"," flags.typesOr = (argv[i] || '').split(',').filter(Boolean);"," break;"," default:"," process.stderr.write('prek-runner: unknown flag ' + arg + '\\n');"," process.exit(2);"," }"," }",""," return { flags, rest };","};","","const gitListFiles = (args, errorHint) => {"," const result = spawnSync('git', args, { encoding: 'buffer' });"," if (result.status !== 0) {"," process.stderr.write('prek-runner: git ' + errorHint + ' failed\\n');"," process.stderr.write(result.stderr ? result.stderr.toString() : '');"," process.exit(result.status === null ? 1 : result.status);"," }"," const raw = result.stdout.toString('utf8');"," if (raw.length === 0) { return []; }"," return raw.split('\\0').filter(function (f) { return f.length > 0; });","};","","const discoverFiles = (flags) => {"," if (flags.allFiles) {"," return gitListFiles(['ls-files', '-z'], 'ls-files');"," }"," if (flags.fromRef && flags.toRef) {"," return gitListFiles("," ['diff', '--name-only', '--diff-filter=ACM', '-z', flags.fromRef, flags.toRef],"," 'diff --from-ref/--to-ref'"," );"," }"," return gitListFiles(['diff', '--cached', '--name-only', '--diff-filter=ACM', '-z'], 'diff --cached');","};","","const buildRegex = (pattern) => {"," try {"," return new RegExp(pattern);"," } catch (error) {"," process.stderr.write('prek-runner: invalid regex ' + JSON.stringify(pattern) + ': ' + error.message + '\\n');"," process.exit(2);"," }","};","","const readShebang = (file) => {"," try {"," const fd = readFileSync(file, { encoding: null });"," if (fd.length < 2 || fd[0] !== 0x23 || fd[1] !== 0x21) { return null; }"," const nl = fd.indexOf(0x0a);"," const end = nl === -1 ? Math.min(fd.length, 256) : Math.min(nl, 256);"," return fd.slice(2, end).toString('utf8').trim();"," } catch (error) {"," return null;"," }","};","","const interpreterFromShebang = (shebang) => {"," if (!shebang) { return null; }"," const parts = shebang.split(/\\s+/).filter(Boolean);"," if (parts.length === 0) { return null; }"," const first = parts[0];"," let candidate = basename(first);"," if (candidate === 'env' && parts.length > 1) {"," candidate = basename(parts[1].split('=')[0] || parts[1]);"," }"," return candidate.toLowerCase();","};","","const fileMetadataTags = (file) => {"," const tags = new Set();"," let info;"," try { info = statSync(file, { throwIfNoEntry: false }); } catch (error) { info = null; }"," if (!info) { return tags; }"," if (info.isSymbolicLink()) { tags.add('symlink'); }"," if (info.isDirectory()) { tags.add('directory'); }"," if (info.isFile()) {"," if ((info.mode & 0o111) !== 0) { tags.add('executable'); } else { tags.add('non-executable'); }"," }"," return tags;","};","","const isBinaryFile = (file) => {"," try {"," const buf = readFileSync(file);"," const slice = buf.subarray(0, Math.min(buf.length, 8192));"," for (let i = 0; i < slice.length; i += 1) {"," if (slice[i] === 0) { return true; }"," }"," return false;"," } catch (error) {"," return false;"," }","};","","const typesForFile = (file) => {"," const tags = new Set();"," const baseName = basename(file).toLowerCase();"," const ext = extname(file).slice(1).toLowerCase();",""," if (baseName in FILENAME_TYPE_MAP) {"," tags.add(FILENAME_TYPE_MAP[baseName]);"," }",""," for (const [type, extensions] of Object.entries(TYPES_EXTENSION_MAP)) {"," if (extensions.includes(ext) || extensions.includes(baseName)) {"," tags.add(type);"," }"," }",""," const metaTags = fileMetadataTags(file);"," for (const tag of metaTags) { tags.add(tag); }",""," if (tags.size === 0 || tags.has('executable') || tags.has('shell')) {"," const interpreter = interpreterFromShebang(readShebang(file));"," if (interpreter) {"," const interpreterTags = SHEBANG_INTERPRETER_MAP[interpreter];"," if (interpreterTags) {"," for (const tag of interpreterTags) { tags.add(tag); }"," }"," }"," }",""," if (!tags.has('symlink') && !tags.has('directory')) {"," tags.add(isBinaryFile(file) ? 'binary' : 'text');"," }",""," return tags;","};","","const applyFilters = (files, flags) => {"," let filtered = files;",""," if (flags.files) {"," const rx = buildRegex(flags.files);"," filtered = filtered.filter(function (f) { return rx.test(f); });"," }",""," if (flags.exclude) {"," const rx = buildRegex(flags.exclude);"," filtered = filtered.filter(function (f) { return !rx.test(f); });"," }",""," if (flags.types.length > 0) {"," filtered = filtered.filter(function (f) {"," const tags = typesForFile(f);"," return flags.types.every(function (t) { return tags.has(t); });"," });"," }",""," if (flags.typesOr.length > 0) {"," filtered = filtered.filter(function (f) {"," const tags = typesForFile(f);"," return flags.typesOr.some(function (t) { return tags.has(t); });"," });"," }",""," if (flags.excludeTypes.length > 0) {"," filtered = filtered.filter(function (f) {"," const tags = typesForFile(f);"," return !flags.excludeTypes.some(function (t) { return tags.has(t); });"," });"," }",""," return filtered;","};","","// Conservative per-call argv budget. POSIX guarantees 4 KiB, Linux gives ~2 MiB","// in practice. 32 KiB keeps us well clear of Windows' 32767-char limit too.","const ARG_BUDGET = 32 * 1024;","","const chunkFiles = (files) => {"," const chunks = [];"," let current = [];"," let size = 0;",""," for (const file of files) {"," const cost = Buffer.byteLength(file, 'utf8') + 8;",""," if (size + cost > ARG_BUDGET && current.length > 0) {"," chunks.push(current);"," current = [];"," size = 0;"," }",""," current.push(file);"," size += cost;"," }",""," if (current.length > 0) {"," chunks.push(current);"," }",""," return chunks;","};","","const runCommand = (cmd, files, passFilenames) => {"," if (!cmd || cmd.length === 0) {"," process.stderr.write('prek-runner: no command specified after --\\n');"," return 2;"," }",""," const bin = cmd[0];"," const baseArgs = cmd.slice(1);",""," if (!passFilenames) {"," const result = spawnSync(bin, baseArgs, { stdio: 'inherit' });"," return result.status === null ? 1 : result.status;"," }",""," let rc = 0;"," const chunks = files.length === 0 ? [[]] : chunkFiles(files);",""," for (const chunk of chunks) {"," const result = spawnSync(bin, baseArgs.concat(chunk), { stdio: 'inherit' });"," rc = rc | (result.status === null ? 1 : result.status);"," }",""," return rc;","};","","// ─── Built-in hook implementations ──────────────────────────────────","// Each receives the already-filtered file list and returns an exit code.","","function runTrailingWhitespace(files) {"," // Mirrors pre-commit/pre-commit-hooks/trailing_whitespace_fixer.py:"," // strip trailing whitespace from each line, preserve original endings,"," // preserve markdown hard-break trailing two-spaces on non-blank lines."," const WS = new Set([0x20, 0x09, 0x0b, 0x0c, 0x0d]); // SP, TAB, VT, FF, CR"," const MD_RE = /\\.(md|markdown|mdown|mdx)$/i;"," let rc = 0;",""," for (const file of files) {"," const isMarkdown = MD_RE.test(file);"," const buf = readFileSync(file);"," const out = [];"," let i = 0;",""," while (i <= buf.length) {"," let end = i;",""," while (end < buf.length && buf[end] !== 0x0a) {"," end += 1;"," }",""," const hadLf = end < buf.length && buf[end] === 0x0a;"," let contentEnd = end;"," let hadCr = false;",""," if (hadLf && end > i && buf[end - 1] === 0x0d) {"," hadCr = true;"," contentEnd = end - 1;"," }",""," const content = buf.subarray(i, contentEnd);"," let stripEnd = content.length;",""," while (stripEnd > 0 && WS.has(content[stripEnd - 1])) {"," stripEnd -= 1;"," }",""," const nonWhitespace = content.some(function (b) { return !WS.has(b); });",""," if (isMarkdown && content.length >= 2 && content[content.length - 1] === 0x20 && content[content.length - 2] === 0x20 && nonWhitespace) {"," stripEnd = Math.min(stripEnd + 2, content.length);"," }",""," out.push(content.subarray(0, stripEnd));",""," if (hadCr) {"," out.push(Buffer.from([0x0d]));"," }",""," if (hadLf) {"," out.push(Buffer.from([0x0a]));"," }",""," if (!hadLf) {"," break;"," }",""," i = end + 1;"," }",""," const next = Buffer.concat(out);",""," if (!next.equals(buf)) {"," writeFileSync(file, next);"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," }"," }",""," return rc;","}","","function runEndOfFileFixer(files) {"," // Mirrors pre-commit/pre-commit-hooks/end_of_file_fixer.py: collapse"," // trailing \\n / \\r\\n / \\r runs to a single newline; add a newline if"," // missing; leave empty files alone."," let rc = 0;",""," for (const file of files) {"," const buf = readFileSync(file);",""," if (buf.length === 0) {"," continue;"," }",""," let end = buf.length;"," const last = buf[end - 1];",""," if (last !== 0x0a && last !== 0x0d) {"," writeFileSync(file, Buffer.concat([buf, Buffer.from([0x0a])]));"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," continue;"," }",""," while (end > 0 && (buf[end - 1] === 0x0a || buf[end - 1] === 0x0d)) {"," end -= 1;"," }",""," if (end === 0) {"," writeFileSync(file, Buffer.alloc(0));"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," continue;"," }",""," const trailing = buf.subarray(end);"," let keep;",""," if (trailing[0] === 0x0d && trailing[1] === 0x0a) {"," keep = Buffer.from([0x0d, 0x0a]);"," } else if (trailing[0] === 0x0d) {"," keep = Buffer.from([0x0d]);"," } else {"," keep = Buffer.from([0x0a]);"," }",""," if (trailing.equals(keep)) {"," continue;"," }",""," writeFileSync(file, Buffer.concat([buf.subarray(0, end), keep]));"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," }",""," return rc;","}","","function isInMerge() {"," // Mirrors pre-commit/pre-commit-hooks/check_merge_conflict.py:is_in_merge."," const gitDirResult = spawnSync('git', ['rev-parse', '--git-dir'], { encoding: 'utf8' });"," if (gitDirResult.status !== 0) { return false; }"," const gitDir = gitDirResult.stdout.trim();"," if (!existsSync(join(gitDir, 'MERGE_MSG'))) { return false; }"," return existsSync(join(gitDir, 'MERGE_HEAD'))"," || existsSync(join(gitDir, 'rebase-apply'))"," || existsSync(join(gitDir, 'rebase-merge'));","}","","function runCheckMergeConflict(files, args) {"," // Mirrors pre-commit/pre-commit-hooks/check_merge_conflict.py: only"," // scans for conflict markers when git is mid-merge/rebase, unless the"," // caller passes --assume-in-merge. Skipping the guard means every"," // legit `<<<<<<<` in docs would fail the hook."," const assumeInMerge = Array.isArray(args) && args.includes('--assume-in-merge');"," if (!assumeInMerge && !isInMerge()) { return 0; }",""," const PATTERNS = ['<<<<<<< ', '======= ', '=======\\r\\n', '=======\\n', '>>>>>>> '];"," let rc = 0;",""," for (const file of files) {"," const content = readFileSync(file, 'utf8');"," const lines = content.split('\\n');",""," for (let i = 0; i < lines.length; i += 1) {"," const line = lines[i] + (i < lines.length - 1 ? '\\n' : '');",""," for (const pattern of PATTERNS) {"," if (line.startsWith(pattern)) {"," process.stdout.write(file + ':' + (i + 1) + ': Merge conflict string ' + JSON.stringify(pattern.trim()) + ' found\\n');"," rc = 1;"," }"," }"," }"," }",""," return rc;","}","","function runCheckJson(files) {"," // Mirrors pre-commit/pre-commit-hooks/check_json.py: parse each file"," // and additionally reject duplicate keys."," let rc = 0;",""," for (const file of files) {"," const content = readFileSync(file, 'utf8');",""," try {"," JSON.parse(content);"," detectDuplicateJsonKeys(content, file);"," } catch (error) {"," process.stdout.write(file + ': Failed to json decode (' + error.message + ')\\n');"," rc = 1;"," }"," }",""," return rc;","}","","function detectDuplicateJsonKeys(source, file) {"," // Minimal tokeniser that walks the already-valid JSON source and throws"," // with a message compatible with the Python hook when a duplicate key"," // appears at any object level."," let i = 0;"," const length = source.length;",""," const skipWs = function () {"," while (i < length && /\\s/.test(source[i])) {"," i += 1;"," }"," };",""," const parseString = function () {",` if (source[i] !== '"') {`," throw new Error('expected string at ' + i);"," }"," i += 1;"," let start = i;",` while (i < length && source[i] !== '"') {`," if (source[i] === '\\\\') {"," i += 2;"," } else {"," i += 1;"," }"," }"," const raw = source.slice(start, i);"," i += 1;",` return JSON.parse('"' + raw + '"');`," };",""," const parseValue = function () {"," skipWs();"," const ch = source[i];"," if (ch === '{') { parseObject(); }"," else if (ch === '[') { parseArray(); }",` else if (ch === '"') { parseString(); }`," else {"," while (i < length && ',}]'.indexOf(source[i]) === -1 && !/\\s/.test(source[i])) {"," i += 1;"," }"," }"," };",""," const parseArray = function () {"," i += 1;"," skipWs();"," if (source[i] === ']') { i += 1; return; }"," while (i < length) {"," parseValue();"," skipWs();"," if (source[i] === ',') { i += 1; skipWs(); }"," else if (source[i] === ']') { i += 1; return; }"," }"," };",""," const parseObject = function () {"," i += 1;"," skipWs();"," const seen = new Set();"," if (source[i] === '}') { i += 1; return; }"," while (i < length) {"," skipWs();"," const key = parseString();"," if (seen.has(key)) {"," throw new Error('Duplicate key: ' + key);"," }"," seen.add(key);"," skipWs();"," if (source[i] !== ':') {"," throw new Error('expected colon at ' + i);"," }"," i += 1;"," parseValue();"," skipWs();"," if (source[i] === ',') { i += 1; skipWs(); }"," else if (source[i] === '}') { i += 1; return; }"," }"," };",""," skipWs();"," parseValue();","}","","function runMixedLineEnding(files, args) {"," // Mirrors pre-commit/pre-commit-hooks/mixed_line_ending.py."," const ENDING = { cr: Buffer.from([0x0d]), crlf: Buffer.from([0x0d, 0x0a]), lf: Buffer.from([0x0a]) };"," let fixArg = 'auto';",""," for (let idx = 0; idx < args.length; idx += 1) {"," const a = args[idx];"," if (a === '-f' || a === '--fix') {"," idx += 1;"," fixArg = args[idx];"," } else if (a.indexOf('--fix=') === 0) {"," fixArg = a.slice('--fix='.length);"," }"," }",""," let rc = 0;",""," for (const file of files) {"," const buf = readFileSync(file);"," const counts = { cr: 0, crlf: 0, lf: 0 };"," const lines = [];"," let start = 0;",""," for (let i = 0; i < buf.length; i += 1) {"," const b = buf[i];",""," if (b === 0x0d && buf[i + 1] === 0x0a) {"," lines.push({ content: buf.subarray(start, i), ending: 'crlf' });"," counts.crlf += 1;"," i += 1;"," start = i + 1;"," } else if (b === 0x0d) {"," lines.push({ content: buf.subarray(start, i), ending: 'cr' });"," counts.cr += 1;"," start = i + 1;"," } else if (b === 0x0a) {"," lines.push({ content: buf.subarray(start, i), ending: 'lf' });"," counts.lf += 1;"," start = i + 1;"," }"," }",""," if (start < buf.length) {"," lines.push({ content: buf.subarray(start), ending: null });"," }",""," const distinct = Object.values(counts).filter(function (c) { return c > 0; }).length;"," const mixed = distinct > 1;",""," if (fixArg === 'no') {"," if (mixed) {"," process.stdout.write(file + ': mixed line endings\\n');"," rc = 1;"," }"," continue;"," }",""," let target;",""," if (fixArg === 'auto') {"," if (!mixed) { continue; }"," let max = -1;"," for (const key of ['cr', 'crlf', 'lf']) {"," if (counts[key] >= max) {"," max = counts[key];"," target = key;"," }"," }"," } else if (!(fixArg in ENDING)) {"," process.stderr.write('prek-runner: invalid --fix value ' + fixArg + '\\n');"," return 2;"," } else {"," target = fixArg;"," const other = Object.entries(counts).some(function (entry) { return entry[0] !== target && entry[1] > 0; });"," if (!other) { continue; }"," }",""," const ending = ENDING[target];"," const chunks = [];",""," for (const line of lines) {"," chunks.push(line.content);"," if (line.ending !== null) {"," chunks.push(ending);"," }"," }",""," writeFileSync(file, Buffer.concat(chunks));"," process.stdout.write(file + ': fixed mixed line endings\\n');"," rc = 1;"," }",""," return rc;","}","","// ─── Entry point ────────────────────────────────────────────────────","","const parsed = parseArgs(process.argv.slice(2));","const candidateFiles = discoverFiles(parsed.flags);","const filtered = applyFilters(candidateFiles, parsed.flags);","","if (filtered.length === 0 && !parsed.flags.alwaysRun) {"," process.exit(0);","}","","let code;","","if (parsed.flags.builtin) {"," const impl = BUILTINS[parsed.flags.builtin];"," if (!impl) {"," process.stderr.write('prek-runner: unknown builtin ' + parsed.flags.builtin + '\\n');"," process.exit(2);"," }"," code = impl(filtered, parsed.rest);","} else {"," code = runCommand(parsed.rest, filtered, parsed.flags.passFilenames);","}","","process.exit(code);",""],_e=Se.join(`
|
|
6
|
-
`);var Re=Object.defineProperty,d=$((e,t)=>Re(e,"name",{value:t,configurable:!0}),"a$1");const Fe=new Map([["pre-commit/pre-commit-hooks#check-json","check-json"],["pre-commit/pre-commit-hooks#check-merge-conflict","check-merge-conflict"],["pre-commit/pre-commit-hooks#end-of-file-fixer","end-of-file-fixer"],["pre-commit/pre-commit-hooks#mixed-line-ending","mixed-line-ending"],["pre-commit/pre-commit-hooks#trailing-whitespace","trailing-whitespace"]]),je=/[<>=!~]=/,Ae=/github\.com[/:]([^/\s]+\/[^/\s.]+)/i,X=`node "$(dirname "$0")/.builtins/${E}"`,Me="# Generated by `vis hook migrate` from prek",v=d(e=>`'${e.replaceAll("'",String.raw`'\''`)}'`,"shellQuote"),B=d(e=>{for(const t of ae)if(y(l(e,t)))return t},"detectPrekConfig"),Oe=d(e=>le[e]??e,"mapPrekStage"),Ie=d(e=>Ae.exec(e)?.[1]??e,"normalizeRepoKey"),De=d(e=>{if(je.test(e))return;if(e.startsWith("@")){const n=e.indexOf("@",1);if(n===-1)return{name:e,version:"latest"};const r=e.slice(n+1).trim();return{name:e.slice(0,n),version:r||"latest"}}const t=e.indexOf("@");if(t===-1)return{name:e,version:"latest"};const s=e.slice(t+1).trim();return{name:e.slice(0,t),version:s||"latest"}},"parseAdditionalDep"),Ne=new Set(Ee),Pe=d(e=>{const t=[];for(const s of[e.types,e.types_or,e.exclude_types])for(const n of s??[])Ne.has(n)||t.push(n);return t},"unknownTypes"),Te=d((e,t)=>(e.stages&&e.stages.length>0?e.stages:t??["pre-commit"]).map(s=>Oe(s)),"resolveStages"),Ce=d(e=>{const t=[];return e.files&&t.push("--files",v(e.files)),e.exclude&&t.push("--exclude",v(e.exclude)),e.types&&e.types.length>0&&t.push("--types",v(e.types.join(","))),e.types_or&&e.types_or.length>0&&t.push("--types-or",v(e.types_or.join(","))),e.exclude_types&&e.exclude_types.length>0&&t.push("--exclude-types",v(e.exclude_types.join(","))),e.always_run&&t.push("--always-run"),e.pass_filenames===!1&&t.push("--no-pass-filenames"),t},"buildRunnerFilterFlags"),H=d((e,t)=>{const s=[X,...Ce(e)];if(t)return s.push("--builtin",t),Array.isArray(e.args)&&e.args.length>0&&s.push("--",...e.args.map(n=>v(n))),s.join(" ");if(s.push("--",e.entry??""),Array.isArray(e.args))for(const n of e.args)s.push(v(n));return s.join(" ")},"buildRunnerInvocation"),We=d((e,t,s)=>{if(e.language==="fail"){const n=e.entry??e.name??e.id??"hook failed";return`echo ${v(n)}; exit 1`}if(s)return H(e,s);if(ce.has(t)){const n=[];if(e.entry&&n.push(e.entry),Array.isArray(e.args))for(const r of e.args)n.push(v(r));return(e.pass_filenames??!0)&&!e.always_run&&n.push('"$@"'),n.join(" ")}return H(e)},"buildHookCommand"),Le=d((e,t,s,n)=>{if(Array.isArray(e.additional_dependencies))for(const r of e.additional_dependencies){const o=De(r);if(!o){n.push(`"${t}": additional_dependency "${r}" uses a pip-style pin and cannot be added to package.json — install manually.`);continue}s.push({hookId:t,name:o.name,raw:r,version:o.version})}},"collectAdditionalDeps"),Be=d(e=>{const t=new Map,s=[],n=[],r=[],o=[];let i=!1;(e.files||e.exclude)&&n.push("top-level files/exclude filter dropped — apply it per hook if needed");for(const u of e.repos??[]){const c=u.repo??"<unknown>",b=c==="local",k=b?void 0:Ie(c);for(const h of u.hooks??[]){const g=h.id??"<unknown>";let M;if(b){const p=h.language??"system";if(!fe.has(p)){s.push({hookId:g,reason:`language "${p}" needs an isolated toolchain — run via prek or reimplement as a system command`,repo:c});continue}if(p!=="fail"&&!h.entry){s.push({hookId:g,reason:"missing `entry`",repo:c});continue}}else if(k&&(M=Fe.get(`${k}#${g}`)),!M){s.push({hookId:g,reason:`remote repo "${c}"@${u.rev??"?"} has no bundled equivalent — run via prek or replace with a system command`,repo:c});continue}Le(h,g,o,r);const O=Pe(h);O.length>0&&n.push(`hook "${g}": unsupported types ${O.join(", ")} — those entries are ignored by the runner`);const I=Te(h,e.default_stages);for(const p of I){if(p==="manual")continue;if(!ue.has(p)){s.push({hookId:g,reason:`unsupported stage "${p}"`,repo:c});continue}let w=We(h,p,M);w.startsWith(X)&&(i=!0),h.verbose&&(w=`(set -x; ${w})`);const D=`${`# ${g}${h.name?`: ${h.name}`:""}`}
|
|
7
|
-
${w}`,f=t.get(p);f?f.push(D):t.set(p,[D])}}}const a=new Map;for(const[u,c]of t){const b=["#!/usr/bin/env sh",Me];e.fail_fast&&b.push("set -e"),b.push("",c.join(`
|
|
8
|
-
|
|
9
|
-
`),""),a.set(u,b.join(`
|
|
10
|
-
`))}return{additionalDeps:o,droppedFilters:n,manualSteps:r,scripts:a,skippedHooks:s,usesRunner:i}},"convertPrekConfig"),He=d(e=>{const t=pe(e);if(t&&typeof t=="object")return t},"parsePrekConfig"),Ve=d(e=>{if(e.endsWith(".toml")){const s=de(e);return s&&typeof s=="object"?s:void 0}const t=A(e);return He(t)},"loadPrekConfig"),qe=d((e,t)=>{const s=l(e,"package.json"),n=[],r=[];if(!y(s)||t.length===0)return{added:n,skipped:r};const o=A(s),i=JSON.parse(o),a=i.devDependencies??{},u=i.dependencies??{};for(const k of t){if(k.name in a||k.name in u){r.push(k.name);continue}a[k.name]=k.version,n.push(k.name)}if(n.length===0)return{added:n,skipped:r};i.devDependencies=a;const c=/^(\s+)"/m.exec(o),b=c?c[1]:" ";return S(s,`${JSON.stringify(i,void 0,b)}
|
|
11
|
-
`,"utf8"),{added:n,skipped:r}},"mergeAdditionalDependencies"),Ge=d((e,t)=>{const s=l(e,t,".builtins");G(s),S(l(s,E),_e,{mode:493}),S(l(s,"README.md"),["# Vis prek runner","","Auto-generated by `vis hook migrate` from a prek/pre-commit config.","This directory is owned by the migrator — do not edit by hand.","",`Supported built-in hooks: ${$e.join(", ")}`,""].join(`
|
|
12
|
-
`),"utf8")},"writeRunnerAssets"),ze=d((e,t)=>{x("prek",["--version"],{cwd:e,encoding:"utf8"}).status===0?x("prek",["uninstall"],{cwd:e,encoding:"utf8"}).status===0?t.info("Detached prek via `prek uninstall`."):t.info("`prek uninstall` did not exit cleanly — continuing. You may need to run it manually."):t.info("prek binary not found on PATH — skipping `prek uninstall`. Run it manually if prek is installed elsewhere.")},"detachPrek"),Q=d((e,t,s,n={})=>{const r=B(e),o=n.dryRun===!0;if(!r)return{isError:!0,message:"No prek configuration found (.pre-commit-config.yaml, .pre-commit-config.yml, or prek.toml)"};s.info(`Found prek config at ${r}`);const i=l(e,r),a=A(i),u=Ve(i);if(!u)return{isError:!0,message:`Could not parse ${r}`};const{additionalDeps:c,droppedFilters:b,manualSteps:k,scripts:h,skippedHooks:g,usesRunner:M}=Be(u);if(h.size===0&&g.length===0)return{isError:!0,message:`${r} has no hooks to migrate`};if(!o){const f=x("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(f.status===0){const T=f.stdout?.toString().trim();T&&(T.includes(".prek")||T.includes("prek-hooks"))&&x("git",["config","--local","--unset","core.hooksPath"],{cwd:e})}const _=K(t);if(_.isError)return _;_.message&&s.info(_.message)}const O=l(e,t);o||G(O),M&&(o?s.info(` (would write) ${t}/.builtins/${E}`):(Ge(e,t),s.info(` Wrote ${t}/.builtins/${E}`)));let I=0;for(const[f,_]of h)o?s.info(` (would write) ${t}/${f} (${_.split(`
|
|
13
|
-
`).length} lines)`):(S(l(O,f),_,{mode:493}),s.info(` Wrote ${t}/${f}`)),I+=1;const{added:p,skipped:w}=o?{added:c.map(f=>f.name),skipped:[]}:qe(e,c);if(p.length>0){const f=o?"would add":"Added";s.info(`${f} ${p.length} package${p.length===1?"":"s"} to devDependencies: ${p.join(", ")}`),o||s.info("Run your package manager's install (e.g. `pnpm install`) to pick up the new devDependencies.")}w.length>0&&s.info(`Skipped ${w.length} already-declared package${w.length===1?"":"s"}: ${w.join(", ")}`),o||ze(e,s);const D=`${i}.bak`;if(o?s.info(` (would remove) ${r} and back it up to ${r}.bak`):(y(D)||S(D,a,"utf8"),ne(i),s.info(`Removed ${r} (backup at ${r}.bak)`)),g.length>0){s.warn(`Skipped ${g.length} hook${g.length===1?"":"s"} that cannot run without prek:`);for(const f of g)s.warn(` - ${f.repo}::${f.hookId} — ${f.reason}`)}if(b.length>0){s.warn("Partial filter translations:");for(const f of b)s.warn(` - ${f}`)}if(k.length>0){s.warn("Manual follow-up required:");for(const f of k)s.warn(` - ${f}`)}return{isError:!1,message:`${o?"would migrate":"Migration complete:"} ${I} stage script${I===1?"":"s"} ${o?"into":"written to"} ${t}/`}},"migrateFromPrek");var Ke=Object.defineProperty,Z=$((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"a");const Je="pre-commit",Ue=Z((e,t,s,n)=>{const r=s.stage??Je,o=l(e,t,r);if(!y(o))throw new Error(`No script found at ${t}/${r}. Install or migrate hooks first.`);if(s.lastCommit&&(s.fromRef||s.toRef))throw new Error("--last-commit cannot be combined with --from-ref or --to-ref");const i=s.lastCommit?"HEAD~1":s.fromRef,a=s.lastCommit?"HEAD":s.toRef;if(i&&!a)throw new Error("--from-ref requires --to-ref");if(a&&!i)throw new Error("--to-ref requires --from-ref");const u={...process.env};s.allFiles&&(u.VIS_HOOK_ALL_FILES="1"),i&&(u.VIS_HOOK_FROM_REF=i),a&&(u.VIS_HOOK_TO_REF=a),n.info(`Running ${t}/${r}${s.allFiles?" (--all-files)":""}${i?` (${i}..${a})`:""}`);const c=x("sh",["-e",o],{cwd:e,env:u,stdio:"inherit"});if(c.error)throw c.error;return c.status??1},"runHookStage"),Ye=Z((e,t,s)=>{const n=Ue(j(),e,t,s);if(n!==0)throw new Error(`Hook stage exited with code ${n}`)},"runRun");var Xe=Object.defineProperty,Qe=$((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"e");const Ze=Qe((e=J)=>{if(x("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:t,stderr:s}=x("git",["config","--local","--unset","core.hooksPath"]);if(t==null)return{isError:!0,message:"git command not found"};if(t&&t!==5)return{isError:!0,message:String(s)};const n=l(e,"_");return y(n)&&re(n,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var et=Object.defineProperty,N=$((e,t)=>et(e,"name",{value:t,configurable:!0}),"u");const tt=new Set(z),st=N(e=>{const t=x("sh",["-n",e],{encoding:"utf8"});if(t.status===null)return`failed to run "sh -n" (${t.error?.message??"unknown error"})`;if(t.status!==0)return t.stderr.trim()||`sh -n exited with ${t.status}`},"runSyntaxCheck"),nt=N(e=>{const t=x("node",["--check",e],{encoding:"utf8"});if(t.status===null)return`failed to run "node --check" (${t.error?.message??"unknown error"})`;if(t.status!==0)return t.stderr.trim()||`node --check exited with ${t.status}`},"runNodeCheck"),rt=N((e,t)=>{const s=[],n=l(e,t),r=x("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(r.status===0){const i=r.stdout.trim(),a=`${t}/_`;i&&i!==a&&s.push({kind:"warning",message:`core.hooksPath is "${i}" — expected "${a}". Re-run \`vis hook install\` to fix.`})}else s.push({kind:"warning",message:"core.hooksPath is not set — run `vis hook install`."});if(y(l(n,"_"))||s.push({kind:"error",message:`Dispatcher directory ${t}/_ is missing. Run \`vis hook install\`.`}),!y(n))return s.push({kind:"error",message:`Hooks directory ${t}/ is missing.`}),{issues:s,ok:!1};let o=!1;for(const i of q(n)){if(i.startsWith(".")||i==="_")continue;if(!tt.has(i)){s.push({kind:"warning",message:`Unknown hook "${i}" — not a standard git hook.`,path:l(t,i)});continue}const a=l(n,i);if(!C(a).isFile())continue;const u=C(a).mode&511;(u&64)===0&&s.push({kind:"warning",message:`Script is not owner-executable (mode ${u.toString(8)}).`,path:l(t,i)});const c=st(a);c&&s.push({kind:"error",message:`Shell syntax error: ${c}`,path:l(t,i)}),A(a).includes(`/.builtins/${E}`)&&(o=!0)}if(o){const i=l(n,".builtins",E);if(y(i)){const a=nt(i);a&&s.push({kind:"error",message:`prek-runner.mjs has a syntax error: ${a}`,path:l(t,".builtins",E)})}else s.push({kind:"error",message:`Hook scripts reference ${t}/.builtins/${E} but the file is missing. Re-run \`vis hook migrate\`.`})}return{issues:s,ok:!s.some(i=>i.kind==="error")}},"validateHooks"),it=N((e,t)=>{if(e.issues.length===0)return[`Hook directory ${t}/ looks good.`];const s=[];for(const n of e.issues){const r=n.kind==="error"?"ERROR":"WARN ",o=n.path?` (${n.path})`:"";s.push(`${r} ${n.message}${o}`)}return s.push("",e.ok?"No errors — warnings only.":`${e.issues.filter(n=>n.kind==="error").length} error(s).`),s},"formatValidationResult"),ot=N((e,t)=>{const s=rt(j(),e),n=it(s,e);for(const r of n)r.startsWith("ERROR")||r.startsWith("WARN")?t.warn(r):t.info(r);if(!s.ok)throw new Error("Hook validation failed")},"runValidate");var at=Object.defineProperty,m=$((e,t)=>at(e,"name",{value:t,configurable:!0}),"i");const R=m(e=>e.hooksDir??J,"resolveHooksDirectory"),V=m(e=>new Promise(t=>{const s=oe({input:process.stdin,output:process.stdout});s.question(`${e} (y/N) `,n=>{s.close();const r=n.trim().toLowerCase();t(r==="y"||r==="yes")})}),"confirmPrompt"),lt=m(async(e,t)=>{const s=j(),n=U(s),r=B(s);if(n&&r)throw new Error(`Found both husky (${n}/) and prek (${r}). Remove or migrate one before running \`vis hook install\`.`);if(n){if(t.info(`Existing husky installation found at ${n}/`),await V("Would you like to migrate your husky hooks to vis?")){const i=Y(s,e,t);if(i.isError)throw new Error(i.message);i.message&&t.info(i.message);return}t.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}if(r){if(t.info(`Existing prek configuration found at ${r}`),await V("Would you like to migrate your prek hooks to vis?")){const i=Q(s,e,t);if(i.isError)throw new Error(i.message);i.message&&t.info(i.message);return}t.info("Aborting install. Remove the prek config first or run 'vis hook migrate' to migrate.");return}t.info(`Installing git hooks in ${e}/...`);const o=K(e);if(o.message){if(o.isError)throw new Error(o.message);t.info(o.message);return}y(l(s,e,"pre-commit"))||S(l(s,e,"pre-commit"),`#!/usr/bin/env sh
|
|
14
|
-
`,{mode:493}),t.info("Git hooks installed successfully.")},"executeInstall"),ct=m((e,t,s)=>{const n=j(),r=U(n),o=B(n);if(r&&o)throw new Error(`Found both husky (${r}/) and prek (${o}). Migrate one at a time — rename or remove one before retrying.`);if(!r&&!o)throw new Error("No husky (.husky/) or prek (.pre-commit-config.yaml / prek.toml) configuration found to migrate.");t&&s.info("(dry-run) no files will be written");const i=r?Y(n,e,s,{dryRun:t}):Q(n,e,s,{dryRun:t});if(i.isError)throw new Error(i.message);i.message&&s.info(i.message)},"executeMigrate"),W="# vis:secrets-hook",ft=`#!/usr/bin/env sh
|
|
15
|
-
${W}
|
|
16
|
-
# Scan staged files for secrets before each commit. Remove this block or the whole file to disable.
|
|
17
|
-
pnpm exec vis secrets --staged --quiet || exit 1
|
|
18
|
-
`,ut=m((e,t,s)=>{if(e!=="secrets")throw new Error(`Unknown hook add target "${String(e)}". Currently supported: "secrets".`);const n=j(),r=l(n,t,"pre-commit");if(!y(l(n,t)))throw new Error(`Hooks directory ${t}/ does not exist. Run \`vis hook install\` first.`);if(y(r)){const o=A(r);if(o.includes(W)){s.info(`Secrets hook already present in ${r}.`);return}if(/\bvis secrets\b/.test(o)){s.warn(`Found a \`vis secrets\` invocation in ${r} without the managed marker — leaving it untouched.`);return}const i=`${o.trimEnd()}
|
|
19
|
-
|
|
20
|
-
${W}
|
|
21
|
-
pnpm exec vis secrets --staged --quiet || exit 1
|
|
22
|
-
`;S(r,i),ie(r,493),s.info(`Appended secrets scan to ${r}.`);return}S(r,ft,{mode:493}),s.info(`Created ${r} with a secrets-scan pre-commit check.`)},"executeAdd"),dt=m((e,t)=>{t.info("Removing git hooks...");const s=Ze(e);if(s.message){if(s.isError)throw new Error(s.message);t.info(s.message);return}t.info("Git hooks removed successfully.")},"executeUninstall"),pt=m(async({logger:e,options:t})=>{await lt(R(t),e)},"hookInstallImpl"),gt=m(({logger:e,options:t})=>{dt(R(t),e)},"hookUninstallImpl"),ht=m(({logger:e,options:t})=>{ct(R(t),!!t.dryRun,e)},"hookMigrateImpl"),mt=m(({logger:e,options:t})=>{be(R(t),e)},"hookListImpl"),kt=m(({logger:e,options:t})=>{ot(R(t),e)},"hookValidateImpl"),yt=m(({argument:e,logger:t,options:s})=>{Ye(R(s),{allFiles:!!s.allFiles,fromRef:s.fromRef,lastCommit:!!s.lastCommit,stage:e[0],toRef:s.toRef},t)},"hookRunImpl"),bt=m(({argument:e,logger:t,options:s})=>{ut(e[0],R(s),t)},"hookAddImpl"),Rt=pt,Ft=gt,jt=ht,At=mt,Mt=kt,Ot=yt,It=bt;export{It as hookAddExecute,Rt as hookInstallExecute,At as hookListExecute,jt as hookMigrateExecute,Ot as hookRunExecute,Ft as hookUninstallExecute,Mt as hookValidateExecute};
|
|
1
|
+
import{createRequire as M}from"node:module";import{b as _}from"../packem_shared/index-CE6MsgcV.js";import{C as N,b as I}from"./catalog.js";import{p as c,f as A}from"./cli-main.js";import{p as H,i as E,r as v,s as R,a as C,S as U,b as D,c as P,d as z,e as G}from"../packem_shared/lifecycle-aDTZ8dW1.js";import{r as L,l as q}from"../packem_shared/target-options-CR0OuYJr.js";const j=M(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=s=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,r]=w.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return w.getBuiltinModule(s)}return j(s)},{open:S,stat:k,watch:T}=F("node:fs/promises"),$=async s=>{const e=s?.plugins;if(!e||e.length===0)return;const r=z();return await G(r,e),{callHook:async(d,...o)=>{try{await r.callHook(d,...o)}catch(t){const n=t instanceof Error?t.message:String(t);c.warn(`Plugin error in ${d}: ${n}`)}}}},B=s=>{const e=s.trim(),r=e.lastIndexOf(":");if(!(r<=0||r===e.length-1))return{project:e.slice(0,r),target:e.slice(r+1)}},b=async(s,e,r)=>{const d=B(r);if(!d){c.error(`Invalid target id "${r}". Expected "<project>:<target>", e.g. "@my/api:db".`);return}const o=await N(s),{projectOptions:t,workspace:n}=I(s,e,o),i=n.projects[d.project],a=t.get(d.project)?.[d.target];if(!i||!a){c.error(`Target "${r}" not found in this workspace.`);return}const p=a.options?.service;if(!p){c.error(`Target "${r}" is not a service. Add an \`options.service\` block to make it eligible for \`vis service\`.`);return}if(!a.command){c.error(`Target "${r}" has no command — services must be runnable.`);return}const u=L(s,i.root,a.options?.runFromWorkspaceRoot===!0),f=a.options?.envFile?q(u,a.options.envFile):{};return{command:a.command,cwd:u,env:{...f,...p.env},service:p,target:a,targetId:r}},m=s=>{if(!s)throw new Error("Could not determine workspace root. Run `vis service` inside a workspace.");return s},te=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service start <project>:<target>"),process.exitCode=1;return}const n=await b(o,r,t);if(!n){process.exitCode=1;return}try{const{entry:i}=await C({command:n.command,config:n.service,cwd:n.cwd,env:n.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await(await $(r))?.callHook("service:start",i),c.success(`Started ${t} (pid ${String(i.pid)})`),c.info(` log: ${i.logFile}`)}catch(i){const a=i instanceof Error?i.message:String(i);i instanceof U?c.error(`Readiness probe failed for ${t}: ${a}`):c.error(`Failed to start ${t}: ${a}`),process.exitCode=1}},y=async({graceMs:s,hookSink:e,id:r,workspaceRoot:d})=>{const o=await v(d,r),{stopped:t}=await R({graceMs:s,id:r,workspaceRoot:d});return t?(o&&await e?.callHook("service:stop",o),c.success(`Stopped ${r}`),!0):(c.info(`No running service registered for ${r}`),!1)},re=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),{graceMs:t}=e,n=s[0]?.trim(),i=await $(r);if(e.all===!0){if(n){c.error("Cannot combine --all with a target id. Use one or the other."),process.exitCode=1;return}const a=await P(o);if(a.length===0){c.info("No running services registered for this workspace.");return}for(const p of a)await y({graceMs:t,hookSink:i,id:p.id,workspaceRoot:o});return}if(!n){c.error("Missing target id. Usage: vis service stop <project>:<target> | --all"),process.exitCode=1;return}await y({graceMs:t,hookSink:i,id:n,workspaceRoot:o})||(process.exitCode=1)},O=s=>{const e=s.config.readiness?.tcp.port??s.config.port;return e===void 0?"—":String(e)},x=new Set(["json","table"]),oe=async({logger:s,options:e,workspaceRoot:r})=>{const d=m(r),o=e.format??"table";if(!x.has(o)){c.error(`Invalid --format "${o}". Expected one of: ${[...x].sort().join(", ")}.`),process.exitCode=1;return}const{surviving:t}=await H(d);if(o==="json"){const l=Date.now();process.stdout.write(`${JSON.stringify(t.map(g=>{const h=Date.parse(g.startedAt);return{ageMs:Number.isFinite(h)?l-h:null,alive:E(g.pid),command:g.command,cwd:g.cwd,env:g.env,id:g.id,logFile:g.logFile,pid:g.pid,port:g.config.readiness?.tcp.port??g.config.port??null,startedAt:g.startedAt,visVersion:g.visVersion}}),void 0,2)}
|
|
2
|
+
`);return}if(t.length===0){c.info("No running services registered for this workspace.");return}const n=Date.now(),i=t.map(l=>{const g=Date.parse(l.startedAt);return{age:Number.isFinite(g)?A(g,n):"?",id:l.id,log:l.logFile,pid:String(l.pid),port:O(l)}}),a=Math.max(2,...i.map(l=>l.id.length)),p=Math.max(3,...i.map(l=>l.pid.length)),u=Math.max(4,...i.map(l=>l.port.length)),f=Math.max(3,...i.map(l=>l.age.length));s.info(` ${"id".padEnd(a)} ${"pid".padEnd(p)} ${"port".padEnd(u)} ${"age".padEnd(f)} log`),s.info(` ${"-".repeat(a)} ${"-".repeat(p)} ${"-".repeat(u)} ${"-".repeat(f)} ---`);for(const l of i)s.info(` ${l.id.padEnd(a)} ${l.pid.padEnd(p)} ${l.port.padEnd(u)} ${l.age.padEnd(f)} ${l.log}`)},se=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service status <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!E(t.pid)){c.error(`Service ${o} is not running (pid ${String(t.pid)} is dead). Run \`vis service start ${o}\` to recover.`),process.exitCode=1;return}try{await D(t.config,{timeoutMs:e.timeout}),c.success(`${o} healthy (pid ${String(t.pid)})`)}catch(n){const i=n instanceof Error?n.message:String(n);c.error(`${o} probe failed: ${i}`),process.exitCode=1}},ie=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service restart <project>:<target>"),process.exitCode=1;return}const n=await $(r),i=await v(o,t);(await R({graceMs:e.graceMs,id:t,workspaceRoot:o})).stopped&&i&&await n?.callHook("service:stop",i);const a=await b(o,r,t);if(!a){process.exitCode=1;return}try{const{entry:p}=await C({command:a.command,config:a.service,cwd:a.cwd,env:a.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await n?.callHook("service:start",p),c.success(`Restarted ${t} (pid ${String(p.pid)})`)}catch(p){const u=p instanceof Error?p.message:String(p);c.error(`Failed to restart ${t}: ${u}`),process.exitCode=1}},V=200,W=1024*1024,J=async s=>{let e=0;try{e=(await k(s)).size}catch{e=0}const r=new AbortController;let d=!1;const o=()=>{d=!0,r.abort()},t=()=>{r.abort()};process.on("SIGINT",o),process.on("SIGTERM",t);let n=!1;const i=async()=>{if(!n){n=!0;try{const a=await k(s).catch(()=>{});if(!a||(a.size<e&&(e=0),a.size===e))return;const p=a.size-e,u=Math.min(p,W),f=await S(s,"r");try{const l=Buffer.alloc(u);await f.read(l,0,u,e),process.stdout.write(l),e+=u}finally{await f.close().catch(()=>{})}}finally{n=!1}}};try{const a=(async()=>{try{const p=T(s,{signal:r.signal});for(;!(await p.next()).done;)await i()}catch{}})();for(;!r.signal.aborted;)await i(),await new Promise(p=>{const u=setTimeout(p,V);r.signal.addEventListener("abort",()=>{clearTimeout(u),p()},{once:!0})});await a.catch(()=>{}),await i().catch(()=>{})}finally{process.off("SIGINT",o),process.off("SIGTERM",t)}d&&(process.exitCode=130)},ae=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service logs <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!await _(t.logFile)){c.warn(`Log file is missing for ${o}: ${t.logFile}`),process.exitCode=1;return}if(e.follow===!0){await J(t.logFile);return}const n=await S(t.logFile,"r");try{const i=n.createReadStream();await new Promise((a,p)=>{i.on("end",a),i.on("error",p),i.pipe(process.stdout,{end:!1})})}finally{await n.close().catch(()=>{})}};export{oe as serviceListExecute,ae as serviceLogsExecute,ie as serviceRestartExecute,te as serviceStartExecute,se as serviceStatusExecute,re as serviceStopExecute};
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import{createRequire as f}from"node:module";import{H as d,m as l}from"../packem_shared/index-CE6MsgcV.js";const v=f(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=s=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,o]=a.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return a.getBuiltinModule(s)}return v(s)},{chmodSync:$}=h("node:fs"),{createRequire:g}=h("node:module"),m=["npm","npx","pnpm","pnpx","yarn","yarnpkg"],r=process.platform==="win32",u=s=>l(s.process.cwd,".vis","shims"),_=()=>{const{report:s}=process;if(typeof s?.getReport!="function")return!1;const e=s.getReport();return Array.isArray(e.sharedObjects)?e.sharedObjects.some(o=>o.includes("libc.musl-")||o.includes("ld-musl-")):!e.header?.glibcVersionRuntime},x={"darwin:arm64":"darwin-arm64","darwin:x64":"darwin-x64","win32:arm64":"win32-arm64-msvc","win32:x64":"win32-x64-msvc"},w=()=>{const{arch:s,platform:e}=process;return e==="linux"?s==="arm64"||s==="x64"?`linux-${s}-${_()?"musl":"gnu"}`:void 0:x[`${e}:${s}`]},y=async(s,e)=>{const o=async p=>s.fs.stat(p).then(()=>!0).catch(()=>!1),t=process.env.VIS_NATIVE_BIN;if(t!==void 0&&t!==""&&await o(t))return t;const i=r?"vis-native-cli.exe":"vis-native-cli",n=l(e,i);if(await o(n))return n;const c=w();if(c!==void 0)try{return g(import.meta.url).resolve(`@visulima/vis-binding-${c}/${i}`)}catch{return}},P=(s,e,o,t)=>r?o===void 0?`@echo off\r
|
|
2
|
+
"${s}" "${e}" __pm-shim ${t} %*\r
|
|
3
|
+
`:`@echo off\r
|
|
4
|
+
if exist "${o}" (\r
|
|
5
|
+
"${o}" __pm-shim ${t} %*\r
|
|
6
|
+
exit /b %errorlevel%\r
|
|
7
|
+
)\r
|
|
8
|
+
"${s}" "${e}" __pm-shim ${t} %*\r
|
|
9
|
+
`:o===void 0?`#!/bin/sh
|
|
10
|
+
exec "${s}" "${e}" __pm-shim ${t} "$@"
|
|
11
|
+
`:`#!/bin/sh
|
|
12
|
+
[ -x "${o}" ] && exec "${o}" __pm-shim ${t} "$@"
|
|
13
|
+
exec "${s}" "${e}" __pm-shim ${t} "$@"
|
|
14
|
+
`,b=async s=>{const e=process.argv[1];if(e===void 0){s.console.error("vis shim install: could not resolve the vis entry path."),s.process.exit(1);return}const o=process.execPath,t=u(s),i=await y(s,d(d(e)));await s.fs.mkdir(t,{recursive:!0});for(const n of m){const c=l(t,r?`${n}.cmd`:n);await s.fs.writeFile(c,P(o,e,i,n)),r||$(c,493)}s.console.log(`Installed ${String(m.length)} PM shims in ${t}`),s.console.log(""),s.console.log("Add the shim dir to PATH (project-local) to activate the PM guard, e.g. in .envrc:"),s.console.log(` export PATH="${t}:$PATH"`),s.console.log("Remove with `vis shim uninstall`.")},R=async s=>{const e=u(s);await s.fs.rm(e,{force:!0,recursive:!0}),s.console.log(`Removed ${e}.`),s.console.log("If you added it to PATH (e.g. .envrc), remove that line too.")},H=async s=>{const e=u(s);if(!await s.fs.stat(e).then(i=>i.isDirectory()).catch(()=>!1)){s.console.log("PM shims: not installed. Run `vis shim install`.");return}const o=[];for(const i of m){const n=l(e,r?`${i}.cmd`:i);await s.fs.stat(n).then(()=>!0).catch(()=>!1)||o.push(i)}const t=(s.process.env.PATH??"").split(r?";":":").includes(e);s.console.log(`PM shims: installed in ${e}`),o.length>0&&s.console.log(`WARNING: ${String(o.length)} shim(s) missing (${o.join(", ")}). Re-run \`vis shim install\`.`),s.console.log(t?"PATH: active (shim dir is on PATH).":"PATH: NOT on PATH — the guard is inactive until you add it.")};export{b as shimInstallExecute,H as shimStatusExecute,R as shimUninstallExecute};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`),n=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));n.length!==l.length&&(j(o,n.join(`
|
|
3
|
-
`)),i.push(o))}catch{e.warn(`warning: could not clean ${o}`)}return i},"cleanShellProfiles"),F=m(async({logger:e,options:i})=>{if(!u(f)){e.info("vis is not installed (no ~/.vis directory found).");return}e.info("This will remove:"),e.info(` ${f}/`);const o=h.filter(n=>u(n)&&p(n).includes(".vis"));for(const n of o)e.info(` Lines in ${n}`);if(!i.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const n=w({input:process.stdin,output:process.stdout}),t=await new Promise(v=>{n.question(`
|
|
4
|
-
Type "uninstall" to confirm: `,v)});if(n.close(),t.trim()!=="uninstall"){e.info("Aborted.");return}}const l=T(e);for(const n of l)e.info(`Cleaned ${n}`);try{b(f,{force:!0,recursive:!0}),e.info(`
|
|
5
|
-
✓ Removed ${f}`)}catch(n){throw new Error(`Failed to remove ${f}: ${n instanceof Error?n.message:String(n)}`)}e.info("✓ vis has been uninstalled.")},"execute");export{F as default};
|
|
1
|
+
import{E as w}from"../packem_shared/index.server-J83sowC4.js";import{A as b,m as y}from"../packem_shared/index-CE6MsgcV.js";import{b as C}from"./catalog.js";import{a as R,b as j,s as E,i as x,c as B,p as D,d as P,r as N,e as A}from"../packem_shared/subtree-C7bZuiSQ.js";import{d as M,a as v}from"../packem_shared/utils-CRueU43T.js";const S=async(p,m,r)=>{const o=m[p];if(o?.root)return{pkgName:p,relativeDir:v(o.root)};const i=v(p);if(i.length>0&&await r(i))return{pkgName:i.split("/").pop()??i,relativeDir:i}},U=async({argument:p,fs:m,logger:r,options:o,process:i,visConfig:g,workspaceRoot:k})=>{const f=p[0];if(!f)throw new Error("Missing <package>. Pass a project name or a workspace-relative path.");if(!o.dryRun&&!o.output)throw new Error("Missing --output <dir>. Pass the destination directory for the new repo (or use --dry-run).");const t=k??i.cwd;R(t);const{workspace:h}=C(t,g),l=async a=>{try{return await m.access(a),!0}catch{return!1}},$=await S(f,h.projects,a=>l(y(t,a,"package.json")));if(!$){const a=Object.keys(h.projects).sort().join(", ");throw new Error(`Unknown package "${f}". Known projects: ${a||"(none)"}.`)}const{pkgName:d,relativeDir:n}=$,s=o.branch??g?.defaultBase??"main",u=`vis/split/${M(n.replaceAll("/","-"))}`,c=o.output?b(o.output)?o.output:y(t,o.output):void 0;if(o.dryRun){r.info("Dry run — no changes will be made. Planned git commands:"),r.info(` git subtree split --prefix=${n}${o.annotate?` --annotate=(${d}) `:""} -b ${u}`),c&&(r.info(` git -C ${c} init -b ${s}`),r.info(` git -C ${c} pull ${t} ${u}`)),o.remote&&r.info(` git -C ${c??"<output>"} remote add origin ${o.remote}`),o.push&&r.info(` git -C ${c??"<output>"} push -u origin ${s}`),o.remove&&r.info(` git rm -r ${n} && git commit (in ${t})`);return}const e=c;if(await l(e)){if((await m.readdir(e)).length>0&&!o.force)throw new Error(`${e} is not empty. Re-run with --force to use it anyway.`)}else await m.mkdir(e,{recursive:!0});o.remove&&j(t),r.info(`Splitting ${w(n)} → ${e} ...`);try{E({annotate:o.annotate?`(${d}) `:void 0,branch:u,cwd:t,prefix:n}),x({branch:s,source:t,sourceBranch:u,target:e}),o.remote?(B("origin",o.remote,e),o.push&&D("origin",s,e)):o.push&&r.warn("--push ignored: no --remote provided.");const a=P(s,e);r.info(`✓ Extracted ${d} with ${a} commit(s) to ${e}`),o.remove&&(N(n,`chore(${d}): split out to standalone repo`,t),r.info(`✓ Removed ${n} from the monorepo (committed).`)),o.remote||r.info(w(`Next: cd ${e} && git remote add origin <url> && git push -u origin ${s}`))}finally{try{A(u,t)}catch{}}};export{U as default,S as resolvePackageDirectory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{E as C,I as a,s as j,V as S}from"../packem_shared/index.server-J83sowC4.js";import{f as R,m as V}from"../packem_shared/index-CE6MsgcV.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{b as x,O as F}from"./catalog.js";import{b as I}from"./cli-main.js";import{c as T}from"../packem_shared/runtime-check-qnrPTlma.js";import{d as z}from"../packem_shared/env-DdQRnEIy.js";import{a as D}from"../packem_shared/readJsonSync-DuMMeB3s-ihoybKvs.js";const e=c=>c?a("✓"):S("✗"),P=async({fs:c,logger:t,options:O,visConfig:y,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const{config:h,packageJsons:w,workspace:f}=x(s,y),b=F(s,f,w),$=Object.keys(f.projects).length,k=new Set(Object.values(f.projects).flatMap(g=>Object.keys(g.targets??{}))).size,n=T(s);let o=0;h.constraints&&(o=v(b,h.constraints).length);const i=I(s,{minRuns:2});let r;const l=z(s);if(R(l)){const g=(await c.readdir(l)).filter(p=>p.endsWith(".json")).sort();let m=0,d=0;for(const p of g.slice(-20))try{const u=D(V(l,p));u.stats&&(m+=u.stats.total??0,d+=u.stats.cached??0)}catch{continue}m>0&&(r=`${(d/m*100).toFixed(0)}%`)}if(O.json){t.info(JSON.stringify({cacheHitRate:r??null,constraintViolations:o,flakyTasks:i.length,projects:$,runtimeIssues:n.length,targets:k},null,2));return}t.info(""),t.info(` ${C("VIS STATUS")}`),t.info(""),t.info(` ${e(!0)} ${String($)} projects · ${String(k)} unique targets`),t.info(` ${e(n.length===0)} Runtime: ${n.length===0?a("OK"):j(`${String(n.length)} issue(s)`)}`),t.info(` ${e(o===0)} Constraints: ${o===0?a("OK"):S(`${String(o)} violation(s)`)}`),t.info(` ${e(i.length===0)} Flaky tasks: ${i.length===0?a("none"):j(String(i.length))}`),r&&t.info(` ${e(!0)} Cache hit rate: ${r} (last 20 runs)`),t.info("")};export{P as default};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`);let i=` allowBuilds: ${s?`{
|
|
3
|
-
${s}
|
|
4
|
-
}`:"{}"},`;return e.enableSocket&&(i+=`
|
|
5
|
-
socket: { enabled: true },`),o.push(` security: {
|
|
6
|
-
${i}
|
|
7
|
-
},`),e.staged&&o.push(` staged: {
|
|
8
|
-
"*.{ts,tsx}": "eslint --fix",
|
|
9
|
-
"*.{ts,tsx,js,jsx,json,md}": "prettier --write",
|
|
10
|
-
},`),`import { defineConfig } from "@visulima/vis/config";
|
|
11
|
-
|
|
12
|
-
export default defineConfig({
|
|
13
|
-
${o.join(`
|
|
14
|
-
|
|
15
|
-
`)}
|
|
16
|
-
});
|
|
17
|
-
`},"generateConfigContent"),A=f(async(t,e,o)=>{const s=N({input:process.stdin,output:process.stdout});n(`
|
|
18
|
-
vis init — interactive setup
|
|
19
|
-
`);const i=await p(s," Enable Socket.dev security scanning?");i&&(l(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||g(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),n("");const a=await p(s," Scan for packages with build scripts?"),u={};if(a){n(" Scanning node_modules...");const c=R(t,{});if(c.length>0){n(` Found ${String(c.length)} package${c.length===1?"":"s"} with build scripts:
|
|
20
|
-
`);for(const r of c){const d=await p(s,` Allow ${r}?`,!1),k=r.split(" (")[0]??r;u[k]=d,d&&l(` ✓ ${k} approved`)}}else n(" No packages with build scripts found.")}n("");const $=await p(s," Set up pre-commit hooks (lint-staged)?",!1);let b=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(n(""),b=await p(s,` Sync security settings to ${e.name} config?`));const y=K(t);if(y.length>0&&(n(""),n(` Detected existing tools: ${y.join(", ")}`),await p(s,` Run \`vis migrate\` for ${y.join(", ")}?`,!1))){s.close();const c=e.name==="pnpm"?"pnpm exec":e.name==="yarn"?"yarn exec":e.name==="bun"?"bunx":"npx";for(const r of y){n(` Migrating from ${r}...`);try{E(`${c} vis migrate ${r}`,{cwd:t,stdio:"inherit"})}catch{_(` Migration from ${r} had issues — run \`vis migrate ${r}\` manually.`)}}if(h(o))l(`Migrated config written to ${o}`);else{const r=j(e.name,{allowBuilds:u,enableSocket:i,staged:$});S(o,r),l(`Created ${o}`)}g(" Run 'vis doctor' to see your project's full health status.");return}s.close(),n("");const B=j(e.name,{allowBuilds:u,enableSocket:i,staged:$});if(S(o,B),l(`Created ${o}`),b){const c=Object.fromEntries(Object.entries(u).filter(([,d])=>d)),r=C(e.name,t,c);for(const d of r)l(` ${d}`)}n(""),n(" Setup complete. Your config:"),n(` Security: ${i?"Socket.dev enabled":"defaults only"}`),n(` Build scripts: ${Object.values(u).filter(Boolean).length} approved`),n(` Git hooks: ${$?"lint-staged configured":"not configured"}`),n(` PM sync: ${b?"done":"skipped"}`),n(""),g(" Run 'vis doctor' to see your project's full health status."),n("")},"runInteractiveInit"),F=f((t,e,o,s)=>{const i=j(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if(S(s,i),l(`Created ${s}`),n(" Secure defaults applied automatically by defineConfig()."),o.syncNative){const a=C(e.name,t,{});for(const u of a)l(` ${u}`)}n(""),g("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),H=f(async({options:t,workspaceRoot:e})=>{const o=e??process.cwd(),s=P(o),i=M(o);if(i&&!t.force){_(`Config already exists: ${i}`),g("Use --force to overwrite, or edit the existing file.");return}const a=i??v(o,"vis.config.ts");process.stdin.isTTY&&t.interactive!==!1&&!t.noInteractive?await A(o,s,a):F(o,s,t,a)},"execute");export{H as default};
|
|
1
|
+
import{createTaskGraph as j}from"@visulima/task-runner";import{b as m,O as b}from"./catalog.js";const y=(a,e)=>{const r=new Map;for(const[i,t]of Object.entries(a.dependencies))for(const c of t){const f=r.get(c)??[];f.push(i),r.set(c,f)}if(!a.tasks[e])return;const s=new Set([e]),o=[{node:e,path:[e]}];for(;o.length>0;){const i=o.shift();if(a.roots.includes(i.node))return i.path;for(const t of r.get(i.node)??[])s.has(t)||(s.add(t),o.push({node:t,path:[t,...i.path]}))}return[e]},E=(a,e)=>{const r=[];for(const[s,o]of Object.entries(a.dependencies))o.includes(e)&&r.push(s);return r.sort()},T=async({argument:a,logger:e,visConfig:r,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const o=a[0];if(!o)throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");if(!o.includes(":"))throw new Error(`Invalid task ID "${o}" — expected format "project:target".`);const{packageJsons:i,workspace:t}=m(s,r),c=b(s,t,i),[f,l]=o.split(":",2),u=t.projects[f];if(!u)throw new Error(`Unknown project "${f}".`);if(!u.targets?.[l])throw new Error(`Project "${f}" has no target "${l}".`);const $=Object.entries(t.projects).flatMap(([n,k])=>Object.keys(k.targets??{}).map(h=>({id:`${n}:${h}`,outputs:[],overrides:{},target:{project:n,target:h}}))),p=j($,{projectGraph:c,workspace:t});if(!p.tasks[o])throw new Error(`Task "${o}" is not reachable in the graph.`);const d=y(p,o),g=E(p,o);if(e.info(""),e.info(`Why ${o}?`),e.info(""),d&&d.length>1){e.info("Shortest path from a root to this task:");for(const[n,k]of d.entries()){const h=n===0?" ":`${" ".repeat(n+1)}└─ `;e.info(`${h}${k}`)}e.info("")}else e.info(" This task is itself a root — nothing upstream depends on it."),e.info("");if(g.length>0){e.info(`Directly depended on by ${g.length} task(s):`);for(const n of g)e.info(` - ${n}`);e.info("")}const w=p.dependencies[o]??[];if(w.length>0){e.info(`This task depends on ${w.length} task(s):`);for(const n of[...w].sort())e.info(` - ${n}`);e.info("")}};export{T as default};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{createRequire as M}from"node:module";import{E as d,I as F,V as I,s as U}from"../packem_shared/index.server-J83sowC4.js";import{m as A}from"../packem_shared/index-CE6MsgcV.js";import{p as t}from"./cli-main.js";import{p as N,g as C,S as w,w as b,b as S,a as W,f as k,c as E,d as B,u as y,e as q,h as H}from"../packem_shared/toolchain-Zb3VzZb4.js";const _=M(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,i]=$.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return $.getBuiltinModule(e)}return _(e)},{spawnSync:P}=T("node:child_process"),x=["aube","bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],O=e=>x.includes(e),v=e=>e?F("✓"):I("✗"),j=U("⚠"),V=e=>{if(e.installed){const n=e.version?` v${e.version}`:"",i=e.configFiles.length>0?` (${e.configFiles.join(", ")})`:"";return`${v(!0)} ${e.name}${n}${i}`}return`${j} ${e.name} — referenced by ${e.configFiles.join(", ")} but not installed`},D=e=>{if(e.matches)return"";const{manager:n}=e;return n.name==="none"?d("→ (no manager)"):n.name==="self-activate"?"":n.installed?d(`→ ${n.name}`):d(`→ ${n.name} (missing)`)},G=e=>e.matches?v(!0):e.actual?j:v(!1),J=e=>{if(t.info(""),t.info(d("── Toolchain ───────────────────────")),e.detected.length===0)t.info(` ${v(!1)} No version manager detected`),t.notice(` Install one of: ${w.join(", ")}`);else for(const n of e.detected)t.info(` ${V(n)}`);if(t.info(""),e.tools.length===0){t.info(` ${d("No tool pins found — add engines.node, .nvmrc, or a manager config file.")}`);return}t.info(d("── Tools ───────────────────────────"));for(const n of e.tools){const i=`${n.expected.tool} ${n.expected.version}`,a=n.actual?`actual ${n.actual}`:"not installed",c=n.matches?"":d(` [${n.expected.source}]`),o=D(n),g=o===""?"":` ${o}`;t.info(` ${G(n)} ${i} — ${a}${c}${g}`),n.manager.note&&t.notice(` ${n.manager.note}`)}},K=(e,n,i)=>{const a=C(e,n);if(i.json){process.stdout.write(`${JSON.stringify({detected:a.detected.map(o=>({binPath:o.binPath??null,configFiles:o.configFiles,installed:o.installed,name:o.name,version:o.version??null})),tools:a.tools.map(o=>({actual:o.actual??null,expected:o.expected.version,manager:o.manager.name,managerInstalled:o.manager.installed,matches:o.matches,note:o.manager.note??null,source:o.expected.source,tool:o.expected.tool}))},void 0,2)}
|
|
2
|
+
`);return}J(a);const c=a.tools.filter(o=>!o.matches);c.length>0&&(t.info(""),t.notice(" Run `vis toolchain install` to install pinned versions.")),i.exitCode&&c.length>0&&(process.exitCode=1)},L=e=>{const n=new Map;for(const i of e){const a=n.get(i.manager.name);a?a.push(i):n.set(i.manager.name,[i])}return n},R=(e,n,i)=>P(e,n,{cwd:i,stdio:"inherit"}).status??1,z=(e,n,i)=>{const a=C(e,n),c=a.tools.filter(u=>!u.matches);if(c.length===0){t.success("Everything already matches — nothing to install.");return}const o=c.some(u=>u.manager.name!=="self-activate"&&u.manager.name!=="none");if(a.detected.length===0&&o){t.error(`No version manager detected. Install one of: ${w.join(", ")}.`),process.exitCode=1;return}const g=L(c);let l=!1,r=0;for(const[u,f]of g){if(u==="self-activate"){for(const{expected:s}of f){if(s.source==="packageManager")t.info(`${d("$")} (${s.tool} will self-activate from packageManager on next invocation)`);else if(t.info(`${d("$")} Writing packageManager=${s.tool}@${s.version}`),i.dryRun)l=!0;else try{b(e,s),l=!0}catch(h){t.error(h.message),r=1}t.notice(` ${s.tool} ${s.version} — no install needed`)}continue}if(u==="none"){for(const{expected:s}of f)t.warn(`Cannot install ${s.tool} ${s.version} — no manager can handle it.`);r=1;continue}if(!a.detected.find(s=>s.name===u)?.installed){t.error(`${u} is referenced but not on PATH — install it first, then rerun \`vis toolchain install\`.`),r=1;continue}const m=f.map(s=>S(u,s.expected)).filter(Boolean);for(const s of m){if(!s)continue;if(s.bin==="nvm"&&s.args.length===0){t.error("nvm is a shell function — run `nvm install` in your shell, then rerun `vis toolchain install`."),s.hint&&t.notice(` ${s.hint}`),r=1;continue}if(t.info(`${d("$")} ${s.bin} ${s.args.join(" ")}`),s.hint&&t.notice(` ${s.hint}`),i.dryRun){l=!0;continue}const h=R(s.bin,s.args,e);if(l=!0,h!==0){r=h;break}}}if(r!==0){process.exitCode=r;return}l&&t.success("Toolchain installed.")},Q=async(e,n,i,a,c)=>{if(!a)throw new Error("Usage: vis toolchain use <tool>@<version> (e.g. vis toolchain use node@22.13.0)");const o=W(a);if(!o)throw new Error(`Could not parse "${a}". Expected "<tool>@<version>" where <tool> is one of ${x.join(", ")}.`);const g=k(n),l=E(o,g,i);if(l.name==="none"){t.error(`No manager can pin ${o.tool}. Install one of: ${w.join(", ")}.`),process.exitCode=1;return}if(!l.installed){t.error(`The best manager for ${o.tool} (${l.name}) is not on PATH. ${l.note??""}`),process.exitCode=1;return}const r=B(l.name,o);if(!r){t.error(`${l.name} cannot pin ${o.tool}. Use a different manager, or set \`toolchain.tools.${o.tool}\` in vis.config.ts.`),process.exitCode=1;return}if(l.name==="self-activate"){if(t.info(`${d("→")} Writing packageManager field to package.json...`),c.dryRun){t.notice(` Would set packageManager: "${o.tool}@${o.version}"`);return}try{const f=b(n,o);if(!f){t.error(`Refusing to pin non-package-manager tool ${o.tool} via the packageManager field.`),process.exitCode=1;return}if(t.success(`Set packageManager: "${f}" — ${o.tool} will activate this version on next invocation.`),c.engines!==!1){const m=y(n,o);m&&t.success(`Updated package.json engines.${o.tool} → ${m}.`)}}catch(f){t.error(f.message),process.exitCode=1}return}if(r.args.length===0&&l.name==="nvm"&&o.tool==="node"){const f=A(n,".nvmrc");if(t.info(`${d("→")} Writing ${f}...`),c.dryRun){t.notice(` Would write ${o.version} to .nvmrc`);return}try{await e.writeFile(f,`${o.version}
|
|
3
|
+
`)}catch(m){t.error(`Failed to write .nvmrc: ${m.message}`),process.exitCode=1;return}t.success(`Wrote ${o.version} to .nvmrc.`),t.notice(" nvm is a shell function — run `nvm use` to activate it in this shell.");return}if(r.args.length===0){t.error(`${l.name} cannot pin ${o.tool} from a subprocess. ${r.configChange?.hint??""}`),r.configChange&&t.notice(` Edit ${r.configChange.file} by hand and rerun \`vis toolchain status\` to verify.`),process.exitCode=1;return}if(t.info(`${d("$")} ${r.bin} ${r.args.join(" ")}`),r.configChange&&t.notice(` Will update ${r.configChange.file} — ${r.configChange.hint}`),c.dryRun)return;const u=R(r.bin,r.args,n);if(u!==0){process.exitCode=u;return}if(t.success(`Pinned ${o.tool} to ${o.version}.`),c.engines!==!1)try{const f=y(n,o);f&&t.success(`Updated package.json engines.${o.tool} → ${f}.`)}catch(f){t.warn(`Could not update engines.${o.tool}: ${f.message}`)}},X=(e,n,i)=>{if(!i)throw new Error("Usage: vis toolchain which <tool> (e.g. vis toolchain which node)");const a=i.toLowerCase();if(!O(a))throw new Error(`Unknown tool "${i}". Known: ${x.join(", ")}.`);const c=k(e),o=E({source:"vis.config.ts",tool:a,version:"*"},c,n),g=o.installed&&o.name!=="self-activate"&&o.name!=="none"?c.find(r=>r.name===o.name):void 0,l=g?q(g,a):H(a);if(!l){t.error(`${i} not found in PATH${g?` or via ${g.name}`:""}.`),process.exitCode=1;return}process.stdout.write(`${l}
|
|
4
|
+
`)},Y=(e,n)=>{const i=N(e,n);process.stdout.write(`${i.name}
|
|
5
|
+
`)},p=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},ie=async({options:e,visConfig:n,workspaceRoot:i})=>{K(p(i),n?.toolchain,e)},se=async({visConfig:e,workspaceRoot:n})=>{Y(p(n),e?.toolchain)},ae=async({options:e,visConfig:n,workspaceRoot:i})=>{z(p(i),n?.toolchain,e)},re=async({argument:e,fs:n,options:i,visConfig:a,workspaceRoot:c})=>{await Q(n,p(c),a?.toolchain,e[0],i)},ce=async({argument:e,visConfig:n,workspaceRoot:i})=>{X(p(i),n?.toolchain,e[0])};export{se as detectExecute,ae as installExecute,ie as statusExecute,re as useExecute,ce as whichExecute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{h as p,$ as f}from"../packem_shared/pm-runner-CQcraCcu.js";import{r as g,a as d}from"../packem_shared/command-runtime-3FTGuUsK.js";import{c as k}from"../packem_shared/utils-CRueU43T.js";const w=async({argument:r,logger:n,options:s,rawUnknown:c,visConfig:o,workspaceRoot:i})=>{const t=k(r,c),e=i??process.cwd(),l=g({logger:n,options:s,visConfig:o},e),m=p(e,{backend:d(l),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),a=f(m,t,s.recursive||!1,e,n);a!==0&&(process.exitCode=a)};export{w as default};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{createRequire as u}from"node:module";import{c as p}from"../packem_shared/index-jJNulo5i.js";const f=u(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,a=s=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,i]=r.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return r.getBuiltinModule(s)}return f(s)},{execSync:d,spawnSync:l}=a("node:child_process"),v=async({argument:s,logger:e,options:i})=>{const t=s?.[0];e.info("info: checking for updates...");const n=p.version;let o;try{const c=d("npm view @visulima/vis version",{encoding:"utf8"}).trim();o=t??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(n===o&&!i.force){e.info(`
|
|
2
|
+
✓ Already up to date (${n})`);return}if(i.check){n===o?e.info(`✓ Already up to date (${n})`):e.info(`info: found @visulima/vis@${o} (current: ${n})`);return}if(e.info(`info: found @visulima/vis@${o} (current: ${n})`),e.info("info: installing..."),l("npm",["install","-g",`@visulima/vis@${o}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
|
|
3
|
+
✓ Updated @visulima/vis from ${n} → ${o}`)};export{v as default};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`)},"announceDryRun"),V=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("deps",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating dependencies and scripts ──"),C(t.root,t.packageManager,t.config,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateDepsExecuteImpl"),W=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("lint-staged",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating lint-staged ──"),j(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateLintStagedExecuteImpl"),Y=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("nano-staged",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating nano-staged ──"),E(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateNanoStagedExecuteImpl"),H=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("turborepo",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating turborepo ──"),$(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateTurborepoExecuteImpl"),X=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("nx",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating nx ──"),M(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateNxExecuteImpl"),z=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("moon",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating moon ──"),S(t.root,{copyTemplates:!!o.copyTemplates,dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateMoonExecuteImpl"),U=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("gitleaks",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating gitleaks ──"),_(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateGitleaksExecuteImpl"),Z=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("kingfisher",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating Kingfisher ──"),I(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateKingfisherExecuteImpl"),ee=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("secretlint",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating secretlint ──"),T(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateSecretlintExecuteImpl"),te=n(({logger:e,workspaceRoot:o})=>{const r=o??process.cwd();J(r,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),ae=V,ce=W,ge=Y,pe=H,le=X,ue=z,fe=U,de=Z,me=ee,ye=te;export{ae as migrateDepsExecute,fe as migrateGitleaksExecute,de as migrateKingfisherExecute,ce as migrateLintStagedExecute,ue as migrateMoonExecute,ge as migrateNanoStagedExecute,le as migrateNxExecute,me as migrateSecretlintExecute,pe as migrateTurborepoExecute,ye as migrateVerifyExecute};
|
|
1
|
+
import{h as d,P as g}from"../packem_shared/pm-runner-CQcraCcu.js";import{r as m,a as k}from"../packem_shared/command-runtime-3FTGuUsK.js";import{c as v,i as h}from"../packem_shared/utils-CRueU43T.js";const C=async({argument:l,logger:n,options:o,process:i,rawUnknown:t,visConfig:a,workspaceRoot:c})=>{const r=v(l,t);if(r.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const e=c??i.cwd,p=m({logger:n,options:o,visConfig:a},e),f=d(e,{backend:k(p),configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),s=g(f,{depth:o.depth===void 0?void 0:Number(o.depth),dev:o.dev||!1,filter:h(o.filter),global:o.global||!1,json:o.json||!1,long:o.long||!1,noOptional:o.optional===!1,packages:r,parseable:o.parseable||!1,prod:o.prod||!1,recursive:o.recursive||!1},e,n);s!==0&&s!==1&&(process.exitCode=s)};export{C as default};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
`)
|
|
1
|
+
import{getAffectedProjects as $}from"@visulima/task-runner";import{b as E,O as F}from"./catalog.js";import{r as b}from"../packem_shared/affected-shas-CCxG4tvm.js";import{f as k}from"../packem_shared/selectors-D4iCvITE.js";const T=async({argument:w,logger:s,options:e,runtime:j,visConfig:u,workspaceRoot:h})=>{const l=w[0];if(!l)throw new Error("Missing target. Usage: vis affected <target>");if(!h)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=h,{packageJsons:v,workspace:i}=E(a,u),y=F(a,i,v),g=new Set(["deep","direct","none"]),p=e.downstream??"deep",d=e.upstream??"none";if(!g.has(p))throw new Error(`Invalid --downstream value: "${p}". Must be "none", "direct", or "deep".`);if(!g.has(d))throw new Error(`Invalid --upstream value: "${d}". Must be "none", "direct", or "deep".`);let{base:c}=e,{head:f}=e;if(!c||!f){const o=b({defaultBase:u?.defaultBase,workspaceRoot:a});c=c??o.base,f=f??o.head,s.info(`▸ Resolved affected refs from ${o.provider} (${o.notes.join("; ")})`)}const S={base:c,downstream:p,head:f,projectGraph:y,projects:i.projects,upstream:d,workspaceRoot:a},n=await $(S);if(n.changedFiles.length===0){s.info("No files changed. Nothing to run.");return}if(n.affectedProjects.length===0){s.info("No projects affected by the changes.");return}let{affectedProjects:t}=n;if(e.query&&(t=k(t,i,e.query),t.length===0)){s.info(`Query "${String(e.query)}" matched no affected projects.`);return}if(e.sparseCheckout){const o=[...new Set(t.map(m=>i.projects[m]?.root??m))].sort();process.stdout.write(`${o.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`);return}s.info(`Affected projects: ${t.join(", ")}`),n.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=n.changedFiles.join(`
|
|
4
|
+
`));const r=[l,`--projects=${t.join(",")}`];e.parallel!==void 0&&r.push(`--parallel=${String(e.parallel)}`),e.cache||r.push("--no-cache"),e.dryRun&&r.push("--dry-run"),e.partition&&r.push(`--partition=${String(e.partition)}`),e.reverse&&r.push("--reverse"),typeof e.runnerTags=="string"&&e.runnerTags!==""&&r.push(`--runner-tags=${e.runnerTags}`);try{await j.runCommand("run",{argv:r})}finally{delete process.env.VIS_AFFECTED_FILES}};export{T as default};
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
${Object.entries(e).map(([o,s])=>` '${o}': '${s}'`).join(`
|
|
3
|
-
`)}
|
|
4
|
-
`;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,a):`${n.trimEnd()}
|
|
5
|
-
|
|
6
|
-
${a}`,F(t,n)},"writePnpmWorkspaceOverrides"),Ye=N((r,e,t,n)=>{const a=M(r),o=Xe(a);if(n==="pnpm"){const s=e.pnpm??{};if(s.overrides=t,e.pnpm)e.pnpm=s,F(r,`${JSON.stringify(e,null,o)}
|
|
7
|
-
`);else{const m=Object.keys(e),p=Z(m,"pnpm"),u=Object.entries(e);u.splice(p,0,["pnpm",s]),F(r,`${JSON.stringify(Object.fromEntries(u),null,o)}
|
|
8
|
-
`)}}else{const s=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[s])e[s]=t,F(r,`${JSON.stringify(e,null,o)}
|
|
9
|
-
`);else{const m=Object.keys(e),p=Z(m,s),u=Object.entries(e);u.splice(p,0,[s,t]),F(r,`${JSON.stringify(Object.fromEntries(u),null,o)}
|
|
10
|
-
`)}}},"writePkgJsonOverrides"),He=N((r,e,t,n)=>{const a=M(e),o=JSON.parse(a),{overrides:s,source:m}=Ve(r,o,n),p=[],u=[],x=new Set;if(n.name==="npm")for(const g of["dependencies","devDependencies"]){const w=o[g];if(w)for(const y of Object.keys(w))x.add(y)}for(const g of t){const w=s[g.original];if(typeof w=="object")continue;let y=g.spec;n.name==="npm"&&x.has(g.original)&&(y=`$${g.original}`),w!==y&&(w?u.push(g.original):p.push(g.original),s[g.original]=y)}if(p.length===0&&u.length===0)return{added:p,updated:u};const S=Object.fromEntries(Object.entries(s).sort(([g],[w])=>g.localeCompare(w)));return m==="pnpm-workspace.yaml"?We(r,S):Ye(e,o,S,n.name),{added:p,updated:u}},"applyOverrides"),Ue=N((r,e)=>{const t={bun:["bun.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of t[e]??[]){const a=A(r,n);try{return M(a)}catch{continue}}return""},"readLockfileText"),Ke=N((r,e,t)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(t){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);default:return!1}},"lockfileContainsPackage");var Ze=Object.defineProperty,_=T((r,e)=>Ze(r,"name",{value:e,configurable:!0}),"s");const Qe=_((r,e,t)=>{let n=r;if(e!=="all"&&(n=n.filter(a=>a.category===e)),t){const a=t.toLowerCase();n=n.filter(o=>o.packageName.toLowerCase().includes(a))}return n},"filterEntries");class er{static{T(this,"c")}static{_(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=_(()=>this.#e,"getSnapshot");subscribe=_(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=_(()=>Qe(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(e,t.length-1)),this.#r()}toggleCheck(e){const t=new Set(this.#e.checkedEntries);t.has(e)?t.delete(e):t.add(e),this.#e.checkedEntries=t,this.#r()}toggleAll(){const e=this.getFilteredEntries(),t=new Set(this.#e.checkedEntries);if(e.every(n=>t.has(n.packageName)))for(const n of e)t.delete(n.packageName);else for(const n of e)t.add(n.packageName);this.#e.checkedEntries=t,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,t){this.#e.applyProgress={current:e,total:t},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ne={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},rr={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},tr={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var nr=Object.defineProperty,or=T((r,e)=>nr(r,"name",{value:e,configurable:!0}),"a");const ir=or(({entry:r,focused:e,scrollRef:t})=>{const n=e?"white":"gray";if(!r)return i(d,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:i(c,{dimColor:!0,children:"No entry selected"})});const a=ne[r.category]??"gray";return f(d,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i(d,{flexShrink:0,paddingTop:1,paddingX:2,children:i(c,{bold:!0,color:"white",children:r.packageName})}),f(ve,{flexGrow:1,flexShrink:1,paddingX:2,ref:t,scrollbar:!0,scrollbarColor:"gray",children:[i(c,{}),f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Category:"})}),i(c,{bold:!0,color:a,children:r.category})]}),f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Replace with:"})}),i(c,{children:r.replacement})]}),r.overrideSpec&&f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Override:"})}),i(c,{color:"cyan",children:r.overrideSpec})]}),f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Codemod:"})}),i(c,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"white",children:"DESCRIPTION"}),i(d,{marginTop:1,paddingLeft:2,children:i(c,{children:tr[r.category]??""})})]}),r.category==="native"&&f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"green",children:"ACTION"}),i(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?f(K,{children:[f(c,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),i(c,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):f(K,{children:[f(c,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),i(c,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"cyan",children:"ACTION"}),f(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(c,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),i(c,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"white",children:"LINKS"}),i(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:f(c,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]})})]})]})]})},"OptimizeDetailPanel");var cr=Object.defineProperty,oe=T((r,e)=>cr(r,"name",{value:e,configurable:!0}),"b$1");const sr=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],ar=oe(({checked:r,entry:e,isSelected:t})=>{const n=ne[e.category]??"white",a=rr[e.category]??e.category,o=r?"☑":"☐",s=e.hasCodemod?"⚙":" ";return f(d,{flexShrink:0,height:1,children:[i(c,{children:t?">":" "}),f(c,{color:r?"white":"gray",children:[" ",o," "]}),i(c,{bold:!0,color:n,children:`[${a}]`.padEnd(9)}),f(c,{children:[" ",s," "]}),i(d,{flexGrow:1,children:i(c,{bold:t,inverse:t,wrap:"truncate",children:e.packageName})}),i(c,{dimColor:!0,children:" → "}),i(c,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),lr=oe(({checkedEntries:r,entries:e,filterActive:t,filterText:n,filterType:a,focused:o,isDryRun:s,scrollOffset:m,selectedIndex:p,totalEntries:u,viewportHeight:x})=>{const S=o?"white":"gray";let g=0,w=0,y=0,O=0;for(const j of e)switch(j.category){case"micro-utility":{y++;break}case"native":{g++;break}case"preferred":{w++;break}case"socket":{O++;break}}const h=[];g>0&&h.push(`${g} native`),w>0&&h.push(`${w} preferred`),y>0&&h.push(`${y} micro`),O>0&&h.push(`${O} socket`);const b=h.length>0?` (${h.join(", ")})`:"",C=r.size,D=[];for(const[j,$]of e.entries())D.push(i(ar,{checked:r.has($.packageName),entry:$,isSelected:j===p},$.packageName));const I=e.length,l=I>x&&x>0;return f(d,{borderColor:S,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(d,{flexShrink:0,gap:1,paddingX:1,children:[i(c,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),f(c,{wrap:"truncate",children:[u," ","optimizations",b]}),!s&&C>0&&f(c,{dimColor:!0,children:[" ","—",C," ","selected"]})]}),i(d,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:sr.map(j=>{const $=a===j.key;return f(d,{children:[i(c,{dimColor:!$,children:"["}),i(c,{bold:$,color:$?"cyan":"gray",children:j.shortcut}),i(c,{dimColor:!$,children:"]"}),f(c,{color:$?"white":"gray",children:[" ",j.label]})]},j.key)})}),t&&f(d,{flexShrink:0,paddingX:1,children:[i(c,{bold:!0,color:"white",children:"/ "}),i(c,{children:n}),i(c,{inverse:!0,children:" "})]}),f(d,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[i(d,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:i(d,{flexDirection:"column",marginTop:-m,children:D})}),l&&i(d,{flexShrink:0,marginLeft:1,marginRight:1,children:i(we,{contentHeight:I,placement:"inset",scrollOffset:m,style:"block",viewportHeight:x})})]})]})},"OptimizeListPanel");var dr=Object.defineProperty,pr=T((r,e)=>dr(r,"name",{value:e,configurable:!0}),"S");const fr=100,Q=10,ee={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},hr=pr(({isDryRun:r,store:e})=>{const{exit:t}=be(),{columns:n,rows:a}=$e(),o=Ie(e.subscribe,e.getSnapshot),s=Re(null),[m,p]=U(0),[u,x]=U(!1),S=e.getFilteredEntries(),g=S[o.selectedIndex]??null,w=n>=fr,y=Math.max(0,a-5),O=Fe(h=>{t(h)},[t]);return Se((h,b)=>{if(u){h==="y"||h==="Y"?O():x(!1);return}if(o.filterActive){b.escape?(e.setFilterActive(!1),e.setFilterText("")):b.return?e.setFilterActive(!1):b.backspace||b.delete?e.setFilterText(o.filterText.slice(0,-1)):h&&!b.ctrl&&!b.meta&&e.setFilterText(o.filterText+h);return}if(h==="q"){!r&&o.checkedEntries.size>0?x(!0):O();return}if(h==="/"){e.setFilterActive(!0);return}if(ee[h]){e.setFilter(ee[h]);return}if(b.tab){e.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list")if(b.upArrow||h==="k"){const C=Math.max(0,o.selectedIndex-1);e.select(C),C<m&&p(C)}else if(b.downArrow||h==="j"){const C=Math.min(S.length-1,o.selectedIndex+1);e.select(C),C>=m+y&&p(C-y+1)}else h===" "?g&&e.toggleCheck(g.packageName):h==="a"?e.toggleAll():b.return&&!r&&o.checkedEntries.size>0&&O(e.getCheckedEntries());else o.focusedPanel==="detail"&&(b.upArrow||h==="k"?s.current?.scrollBy(-1):(b.downArrow||h==="j")&&s.current?.scrollBy(1))},{isActive:o.phase==="browsing"}),a<Q?i(d,{alignItems:"center",justifyContent:"center",children:f(c,{color:"yellow",children:["Terminal too small. Resize to at least",Q," ","rows."]})}):f(d,{flexDirection:"column",height:a,width:n,children:[f(d,{flexDirection:w?"row":"column",flexGrow:1,children:[i(d,{flexBasis:w?"50%":void 0,flexGrow:1,children:i(lr,{checkedEntries:o.checkedEntries,entries:S,filterActive:o.filterActive,filterText:o.filterText,filterType:o.filterType,focused:o.focusedPanel==="list",isDryRun:r,scrollOffset:m,selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:y})}),i(d,{flexBasis:w?"50%":void 0,flexGrow:1,children:i(ir,{entry:g,focused:o.focusedPanel==="detail",scrollRef:s})})]}),i(d,{flexShrink:0,paddingX:1,children:f(c,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),i(Ce,{autoExitSeconds:3,onCancel:T(()=>{x(!1)},"onCancel"),visible:u})]})},"VisOptimizeApp");var mr=Object.defineProperty,P=T((r,e)=>mr(r,"name",{value:e,configurable:!0}),"f");const V=P((r,e)=>{const t=new Set;try{const n=re(r),a=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const o of a)if(o)for(const s of Object.keys(o))t.add(s)}catch{}return t},"collectDepsFromPkgJson"),ie=P(r=>{const e=Oe(r);if(e)return W(r,e);const t=A(r,"package.json");if(!X(t))return[];try{const n=re(t),a=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return a?W(r,a):[]}catch{return[]}},"discoverWorkspacePackages"),ce=P(r=>{const e=[],t=P((n,a)=>{for(const[,o]of Object.entries(n.mappings)){if(!r.has(o.moduleName))continue;const s=[];for(const m of o.replacements){const p=n.replacements[m];p&&s.push(p.description??p.id)}e.push({category:a,hasCodemod:!1,overrideSpec:void 0,packageName:o.moduleName,replacement:s.join(", ")||o.replacements.join(", ")})}},"scanManifest");return t(Pe,"native"),t(Ae,"preferred"),t(Te,"micro-utility"),e},"buildE18eEntries"),se=P((r,e,t,n)=>{const a=ge("npm")??[],o=[];for(const[,s]of a){if(s.deprecated)continue;const m=r.has(s.package),p=e?Ke(e,s.package,t.name):!1;if(!m&&!p)continue;const u=te(s.version)?.major;if(u===void 0)continue;const x=n?`npm:${s.name}@${s.version}`:`npm:${s.name}@^${String(u)}`;o.push({category:"socket",hasCodemod:!1,overrideSpec:x,packageName:s.package,replacement:s.name})}return o},"buildSocketEntries");let G;const ae=P(async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},"loadCodemods"),le=P(async r=>{try{const e=await ae();for(const t of r)t.category!=="socket"&&e[t.packageName]&&(t.hasCodemod=!0)}catch{}},"markCodemodAvailability"),de=P(async(r,e)=>{let t=0;try{const n=(await ae())[e];if(!n)return{filesChanged:0,packageName:e};const a=n({}),o=await ur(r);for(const s of o){const m=M(s);if(m.includes(e))try{const p=await a.transform({file:{filename:s,source:m}});p!==m&&(ue(s,p,"utf8"),t++)}catch(p){process.stderr.write(`warn: codemod transform failed for ${s}: ${p instanceof Error?p.message:String(p)}
|
|
11
|
-
`)}}}catch{}return{filesChanged:t,packageName:e}},"runCodemod"),ur=P(async r=>ye("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),gr=P(async({logger:r,options:e,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=je(t),a=!!e.dryRun,o=!!e.prod,s=!!e.pin;v(`Detected ${n.name} v${n.version}.`);const m=V(A(t,"package.json"),o),p=ie(t),u=new Set(m);for(const l of p){const j=V(A(ke(t,l),"package.json"),o);for(const $ of j)u.add($)}p.length>0&&v(`Scanned ${String(p.length)} workspace package${p.length===1?"":"s"}.`),v(`Scanning dependencies...
|
|
12
|
-
`);const x=Ue(t,n.name),S=ce(u),g=se(u,x,n,s),w=new Set(S.map(l=>l.packageName)),y=g.filter(l=>!w.has(l.packageName)),O=[...S,...y];if(await le(O),O.length===0){v("No optimizations found for your dependencies.");return}const h=!!process.stdout.isTTY&&!Ee,b=e.format==="json"||!!e.json;if(h&&!a&&!b){const l=new er(O),j=await xe(De.createElement(hr,{isDryRun:!1,store:l}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),$=Array.isArray(j)?j:[];if($.length===0){v("No optimizations selected.");return}const z=$.filter(k=>k.category!=="socket"&&k.hasCodemod),L=$.filter(k=>k.category!=="socket"&&!k.hasCodemod),B=$.filter(k=>k.category==="socket");if(z.length>0){v(`
|
|
13
|
-
Running ${String(z.length)} codemod${z.length===1?"":"s"}...
|
|
14
|
-
`);for(const k of z){const E=await de(t,k.packageName);E.filesChanged>0?q(` ${k.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`):v(` ${k.packageName}: no files changed`)}}if(L.length>0){Y(`
|
|
15
|
-
${String(L.length)} selected replacement${L.length===1?"":"s"} require manual migration (no codemod available):`);for(const k of L)v(` ${k.packageName} → ${k.replacement}`);H(" Replace usage in your source code, then remove from dependencies.")}if(B.length>0){const k=B.filter(J=>J.overrideSpec).map(J=>({original:J.packageName,spec:J.overrideSpec})),E=He(t,A(t,"package.json"),k,n);E.added.length>0&&q(`
|
|
16
|
-
Added ${String(E.added.length)} override${E.added.length===1?"":"s"}.`),E.updated.length>0&&q(`Updated ${String(E.updated.length)} override${E.updated.length===1?"":"s"}.`)}if(B.length>0&&!e.noInstall){v(`
|
|
17
|
-
Running ${n.name} install to update lockfile...`);const k=Ne(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},t,r);k!==0&&Y(`${n.name} install exited with code ${String(k)}. Run it manually.`)}v(""),q("Optimization complete.");return}if(b){process.stdout.write(`${JSON.stringify({e18e:S.map(l=>({category:l.category,hasCodemod:l.hasCodemod,packageName:l.packageName,replacement:l.replacement})),packageManager:n.name,socket:y.map(l=>({overrideSpec:l.overrideSpec,packageName:l.packageName,replacement:l.replacement})),total:O.length,workspaces:p.length},void 0,2)}
|
|
18
|
-
`);return}const C=S.filter(l=>l.category==="native"),D=S.filter(l=>l.category==="preferred"),I=S.filter(l=>l.category==="micro-utility");if(C.length>0){v(`Native replacements (${String(C.length)}):`);for(const l of C)v(` ${l.hasCodemod?"⚙":" "} ${l.packageName} → ${l.replacement}`)}if(D.length>0){v(`
|
|
19
|
-
Preferred alternatives (${String(D.length)}):`);for(const l of D)v(` ${l.hasCodemod?"⚙":" "} ${l.packageName} → ${l.replacement}`)}if(I.length>0){v(`
|
|
20
|
-
Micro-utilities (${String(I.length)}):`);for(const l of I)v(` ${l.hasCodemod?"⚙":" "} ${l.packageName} → ${l.replacement}`)}if(y.length>0){v(`
|
|
21
|
-
Socket.dev overrides (${String(y.length)}):`);for(const l of y)v(` ${l.packageName} → ${l.overrideSpec}`)}v(`
|
|
22
|
-
Total: ${String(O.length)} optimizations available (⚙ = codemod available).`),a&&H("Run without --dry-run for interactive selection.")},"execute"),Pr=Object.defineProperty({__proto__:null,buildE18eEntries:ce,buildSocketEntries:se,collectDepsFromPkgJson:V,default:gr,discoverWorkspacePackages:ie,markCodemodAvailability:le,runCodemod:de},Symbol.toStringTag,{value:"Module"});export{Ue as A,ie as B,He as F,ce as I,se as J,de as L,le as _,Pr as h,V as x};
|
|
1
|
+
import{A as d,B as w}from"../packem_shared/index-CE6MsgcV.js";import{r as v}from"../packem_shared/command-runtime-3FTGuUsK.js";import{r as u}from"../packem_shared/run-file-DD7Ne23Z.js";const R=async({argument:s,logger:i,options:n,rawUnknown:t,visConfig:a,workspaceRoot:f})=>{const m=s??[],[o,...p]=m;if(o===void 0)throw new Error("No file specified. Usage: vis x <file> [args...]");const r=process.cwd(),c=d(o)?o:w(r,o),g=[...p,...t??[]],{runtime:l}=v({logger:i,options:n,visConfig:a},f??r),e=await u(c,g,l,r);e!==0&&(process.exitCode=e)};export{R as default};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{createRequire as R}from"node:module";import{DEFAULT_CHANGES_DIR as C}from"./DEFAULT_CLEAN_KEEP.js";import{b as E,f as B}from"./orchestrator.js";import{r as T}from"../packem_shared/slug-DoueYuLo.js";import{VisReleaseError as w}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const S=R(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[o,n]=u.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return u.getBuiltinModule(e)}return S(e)},{mkdir:V,writeFile:O}=$("node:fs/promises"),{resolve:b,sep:k,join:P}=$("node:path");let y;const W=e=>{y=e},_=async()=>y||(await import("./shell-runner.js")).createShellRunner(),v=e=>!e||!/^[\dv]/i.test(e)?!1:/^[\d.+\-a-z]+$/i.test(e),D=e=>{const o=e.trim(),n=/^(?:[a-z]+(?:\([^)]+\))?:\s+)?[Bb]ump\s+(?<dep>\S+)\s+from\s+(?<fromVersion>\S+)\s+to\s+(?<toVersion>\S+)(?:\s+in\s+\S+)?$/.exec(o);if(n?.groups){const t=n.groups.toVersion;return v(t)?{dep:n.groups.dep,fromVersion:n.groups.fromVersion,toVersion:t}:void 0}const s=/^(?:[a-z]+(?:\([^)]+\))?:\s+)?[Uu]pdate\s+(?:dependency|module)\s+(?<dep>\S+)\s+to\s+(?<toVersion>\S+)(?:\s+\S.*)?$/.exec(o);if(s?.groups){const t=s.groups.toVersion;return v(t)?{dep:s.groups.dep,fromVersion:"",toVersion:t}:void 0}},A=async e=>{const o=process.env.PR_NUMBER;if(o&&/^\d+$/.test(o))return Number.parseInt(o,10);const n=process.env.GITHUB_REF;if(n){const s=/^refs\/pull\/(\d+)\//.exec(n);if(s)return Number.parseInt(s[1],10)}try{const s=await(await _()).run("gh",["pr","view","--json","number"],{cwd:e,silent:!0});if(s.exitCode===0){const t=JSON.parse(s.stdout.trim());if(typeof t.number=="number")return t.number}}catch{}},L=async(e,o)=>{try{const n=await(await _()).run("gh",["pr","view",String(o),"--json","title,body,author"],{cwd:e,silent:!0});return n.exitCode!==0?void 0:JSON.parse(n.stdout.trim())}catch{return}},U=(e,o)=>{const n=[];for(const s of o){const{manifest:t}=s;(Object.hasOwn(t.dependencies??{},e)||Object.hasOwn(t.devDependencies??{},e)||Object.hasOwn(t.peerDependencies??{},e)||Object.hasOwn(t.optionalDependencies??{},e))&&n.push(s.name)}return n},F=e=>{const o={};for(const n of e.split(",")){const s=n.trim();if(!s)continue;const t=s.lastIndexOf(":");if(t<1)throw new w({code:"BUMP_FILE_INVALID",message:`Invalid --packages entry: ${JSON.stringify(s)}. Expected "package:level".`});const i=s.slice(0,t).trim(),r=s.slice(t+1).trim();if(r!=="major"&&r!=="minor"&&r!=="patch"&&r!=="none")throw new w({code:"BUMP_FILE_INVALID",message:`Invalid bump level: ${JSON.stringify(r)}. Expected major|minor|patch|none.`});o[i]=r}return o},M=async e=>{const{multiSelectPrompt:o,selectPrompt:n,textPrompt:s}=await import("./prompts.js"),t=await o("Which packages to bump?",e.map(p=>({label:p,value:p}))),i={};for(const p of t){const f=await n(`Bump level for ${p}?`,[{label:"patch — bug fixes only",value:"patch"},{label:"minor — new feature, backward-compatible",value:"minor"},{label:"major — breaking change",value:"major"},{label:"none — acknowledged, no direct bump",value:"none"}]);i[p]=f}const r=await s("Changelog entry (markdown):","");return{bumps:i,message:r}},Y=async({logger:e,options:o,workspaceRoot:n})=>{const s=n??process.cwd(),t=await E({cwd:s,skipRegistryLookup:!0});let i={},r=o.message??"";if(o.fromBotPr){const c=await A(s);if(c===void 0){e.error("No PR found. Set PR_NUMBER, run inside a GitHub Actions PR workflow, or check `gh pr view` works on this branch."),process.exitCode=1;return}const a=await L(s,c);if(!a||typeof a.title!="string"){e.error(`Could not fetch PR #${c} via \`gh pr view\`. Ensure gh is on PATH and authenticated.`),process.exitCode=1;return}const d=D(a.title);if(!d){e.info(`PR #${c} title is not a recognised Dependabot / Renovate pattern; skipping.`),e.info(`Title: ${a.title}`),process.exitCode=0;return}const h=U(d.dep,t.packages),N=d.fromVersion?`from ${d.fromVersion} to ${d.toVersion}`:`to ${d.toVersion}`;if(r=r||`Updated ${d.dep} ${N}`,h.length===0){const g=t.packages[0]?.name;if(!g){e.error("Workspace has no packages — cannot author an acknowledging change file."),process.exitCode=1;return}i={[g]:"none"},r=`${r} (no workspace package depends on ${d.dep})`}else for(const g of h)i[g]="patch"}else if(o.empty)i={},r=r||"Empty change file (no release).";else if(o.packages){i=F(o.packages);const c=new Set(t.packages.map(a=>a.name));for(const a of Object.keys(i))if(!c.has(a))throw new w({code:"BUMP_FILE_INVALID",message:`Unknown workspace package in --packages: ${JSON.stringify(a)}.`,packageName:a})}else{if(!process.stdout.isTTY){e.error("--packages is required when stdin is not a TTY."),e.error("Example: vis release add --packages '@scope/cerebro:minor' --message 'Add X'"),process.exitCode=1;return}const c=await M(t.packages.map(a=>a.name));i=c.bumps,r=r||c.message}if(Object.keys(i).length===0){e.error("No bumps specified."),process.exitCode=1;return}const p=t.config.changesDir??C,f=(o.name??T()).replaceAll(/[^a-z0-9-]/gi,"-"),l=b(s),x=l.endsWith(k)?l:`${l}${k}`,m=b(s,p);if(m!==l&&!m.startsWith(x))throw new w({code:"CONFIG_INVALID",message:`changesDir resolves outside the workspace: ${m} (workspace: ${l}).`});const j=P(m,`${f}.md`),I=B({bumps:i},r);await V(m,{recursive:!0}),await O(j,I,{flag:"wx"}),e.info(`Created ${p}/${f}.md`),e.info("");for(const[c,a]of Object.entries(i))e.info(` ${c}: ${a}`);r&&(e.info(""),e.info(` Body: ${r.split(`
|
|
2
|
+
`)[0]?.slice(0,80)??""}`))};export{W as __setBotPrRunnerForTests,Y as default,D as parseBotPrTitle};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{releaseChangelog as l}from"../packem_shared/ReleaseClient-BY4OZNCK.js";const c=async({logger:o,options:t,workspaceRoot:r})=>{const s=r??process.cwd(),i=t.filter?t.filter.split(",").map(e=>e.trim()).filter(Boolean):void 0,n=await l({channel:t.channel,cwd:s,projects:i});if(t.json){process.stdout.write(`${JSON.stringify(n,null,2)}
|
|
2
|
+
`),n.projectChangelogs.length===0&&(process.exitCode=1);return}if(n.projectChangelogs.length===0){o.info("No pending releases — no changelog entries to render."),process.exitCode=1;return}for(const e of n.projectChangelogs)o.info(`# ${e.package} → ${e.file}`),o.info(""),o.info(e.content),o.info("")};export{c as default};
|