@visulima/vis 3.0.6 → 4.0.1
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 +39 -0
- package/LICENSE.md +0 -116
- package/README.md +3 -2
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +24 -4
- package/dist/packem_chunks/CONFIG_FILES.js +6 -5
- package/dist/packem_chunks/catalog.js +32 -32
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +153 -152
- package/dist/packem_chunks/handler12.js +25 -10
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler67.js +28 -25
- package/dist/packem_chunks/handler68.js +25 -153
- package/dist/packem_chunks/handler69.js +153 -10
- package/dist/packem_chunks/handler70.js +10 -22
- package/dist/packem_chunks/handler71.js +21 -22
- package/dist/packem_chunks/handler72.js +23 -322
- package/dist/packem_chunks/handler73.js +273 -659
- package/dist/packem_chunks/handler74.js +708 -48
- package/dist/packem_chunks/handler75.js +48 -27
- package/dist/packem_chunks/handler76.js +27 -3
- package/dist/packem_chunks/handler77.js +3 -189
- package/dist/packem_chunks/handler78.js +188 -39
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_shared/{affected-selection-BXSwA6UK.js → affected-selection-DLrq50Mz.js} +1 -1
- package/dist/packem_shared/{bin-DX0e6Is-.js → bin-As0Wq5ZN.js} +1 -1
- package/dist/packem_shared/{index-Cit0JVOK.js → index-CcVv0V1y.js} +1 -1
- package/dist/packem_shared/lockfile-DVFySxTS.js +1 -0
- package/dist/packem_shared/{package-version-DwvcnvER.js → package-version-BFsJ8iyZ.js} +1 -1
- package/dist/packem_shared/{project-name-filter-DENHWAF3.js → project-name-filter-DdXd3P3a.js} +1 -1
- package/dist/packem_shared/vis-user-error-DJvfOpBX.js +31 -0
- package/index.js +26 -26
- package/package.json +12 -12
- package/schemas/project.schema.json +2 -2
- package/schemas/vis-config.schema.json +8 -9
- package/skills/vis/SKILL.md +1 -1
- package/dist/packem_shared/lockfile-35RFsJDs.js +0 -1
- package/dist/packem_shared/vis-user-error-Bp_JAmry.js +0 -30
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`),
|
|
1
|
+
import{createRequire as A}from"node:module";import{e as m,a as O}from"../packem_shared/index-DHD8wb6Z.js";import{findVisConfigFile as F,DEFAULT_MIN_RELEASE_AGE_MINUTES as h}from"./CONFIG_FILES.js";import{p as e,e as q}from"./cli-main.js";import{d as G}from"../packem_shared/pm-runner-d93_73O6.js";import{s as K}from"../packem_shared/build-scripts-pdVmqXRm.js";import{y as S}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{s as T}from"../packem_shared/native-config-sync-BSzU4qUO.js";import{s as R}from"../packem_shared/min-release-age-ChzTC7_I.js";let M;const N=n=>(M??=A(import.meta.url))(n),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=n=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(n)}return N(n)},{execFileSync:D}=x("node:child_process"),{createInterface:I}=x("node:readline"),U=n=>{const s=[];return S(m(n,"turbo.json"))&&s.push("turborepo"),S(m(n,"nx.json"))&&s.push("nx"),S(m(n,".moon"))&&s.push("moon"),s},B=(n,s)=>new Promise(t=>{n.question(s,i=>{t(i.trim())})}),d=async(n,s,t=!0)=>{const o=await B(n,`${s} ${t?"[Y/n]":"[y/N]"} `);return o===""?t:o.toLowerCase()==="y"||o.toLowerCase()==="yes"},w=(n,s)=>{const t=[],i=Object.entries(s.allowBuilds).filter(([,c])=>c).map(([c])=>` "${c}": true,`).join(`
|
|
2
|
+
`),a=[` installScripts: {
|
|
3
3
|
allow: ${i?`{
|
|
4
4
|
${i}
|
|
5
5
|
}`:"{}"},
|
|
6
|
-
},`];s.minimumReleaseAge!==void 0&&
|
|
6
|
+
},`];s.minimumReleaseAge!==void 0&&a.push(` firstSeen: {
|
|
7
7
|
minutes: ${String(s.minimumReleaseAge)},
|
|
8
8
|
},`);let l=` policies: {
|
|
9
|
-
${
|
|
9
|
+
${a.join(`
|
|
10
10
|
`)}
|
|
11
11
|
},`;return s.enableSocket&&(l+=`
|
|
12
12
|
socket: { enabled: true },`),s.enableDepsDev&&(l+=`
|
|
13
|
-
depsDev: { enabled: true },`),
|
|
13
|
+
depsDev: { enabled: true },`),t.push(` // Workspace-wide task defaults. Keys are target names, matched
|
|
14
|
+
// exactly against your package.json scripts. Everything here is
|
|
15
|
+
// optional — vis runs your scripts without any of it.
|
|
16
|
+
//
|
|
17
|
+
// tasks: {
|
|
18
|
+
// build: {
|
|
19
|
+
// // Build the packages this one depends on first.
|
|
20
|
+
// dependsOn: ["^build"],
|
|
21
|
+
// outputs: ["{projectRoot}/dist/**"],
|
|
22
|
+
// },
|
|
23
|
+
// test: {
|
|
24
|
+
// dependsOn: ["build"],
|
|
25
|
+
// },
|
|
26
|
+
// },
|
|
27
|
+
//
|
|
28
|
+
// Docs: https://visulima.com/docs/packages/vis/configuration`),t.push(` security: {
|
|
14
29
|
${l}
|
|
15
|
-
},`),s.staged&&
|
|
30
|
+
},`),s.staged&&t.push(` staged: {
|
|
16
31
|
"*": ["vis lint --staged --fix", "vis fmt --staged"],
|
|
17
32
|
},`),`import { defineConfig } from "@visulima/vis/config";
|
|
18
33
|
|
|
19
34
|
export default defineConfig({
|
|
20
|
-
${
|
|
35
|
+
${t.join(`
|
|
21
36
|
|
|
22
37
|
`)}
|
|
23
38
|
});
|
|
24
|
-
`},L=async(
|
|
39
|
+
`},L=async(n,s,t)=>{const i=I({input:process.stdin,output:process.stdout});e.info(`
|
|
25
40
|
vis init — interactive setup
|
|
26
|
-
`);const o=await d(i," Enable Socket.dev security scanning?");o&&(e.success(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||e.notice(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),e.info("");const
|
|
27
|
-
`);for(const
|
|
41
|
+
`);const o=await d(i," Enable Socket.dev security scanning?");o&&(e.success(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||e.notice(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),e.info("");const a=await d(i," Enable Google deps.dev (OpenSSF Scorecard + GHSA advisories)?");a&&e.success(" deps.dev enabled — Scorecard signals and advisories merged into the security report."),e.info("");const l=await d(i," Scan for packages with build scripts?"),c={};if(l){e.info(" Scanning node_modules...");const f=K(n,{});if(f.length>0){e.info(` Found ${String(f.length)} package${f.length===1?"":"s"} with build scripts:
|
|
42
|
+
`);for(const r of f){const y=await d(i,` Allow ${r}?`,!1),u=r.split(" (")[0]??r;c[u]=y,y&&e.success(` ✓ ${u} approved`)}}else e.info(" No packages with build scripts found.")}e.info("");const C=await d(i," Enforce a minimum release age (block freshly-published versions)?");let p;if(C){const f=await B(i,` Minimum age in minutes (default ${String(h)} = 2 days): `),r=f===""?h:Number.parseInt(f,10);p=Number.isFinite(r)&&r>0?r:h,e.success(` minimumReleaseAge: ${String(p)} minutes`)}e.info("");const $=await d(i," Set up pre-commit hooks (lint-staged)?",!1);let b=!1;(s.name==="pnpm"||s.name==="yarn"||s.name==="npm"||s.name==="bun")&&(e.info(""),b=await d(i,` Sync security settings to ${s.name} config?`));const v=U(n);if(v.length>0&&(e.info(""),e.info(` Detected existing tools: ${v.join(", ")}`),await d(i,` Run \`vis migrate\` for ${v.join(", ")}?`,!1))){i.close();const[r,...y]=s.name==="pnpm"?["pnpm","exec"]:s.name==="yarn"?["yarn","exec"]:s.name==="bun"?["bunx"]:["npx"];for(const u of v){e.info(` Migrating from ${u}...`);try{D(r,[...y,"vis","migrate",u],{cwd:n,stdio:"inherit"})}catch{e.warn(` Migration from ${u} had issues — run \`vis migrate ${u}\` manually.`)}}if(S(t))e.success(`Migrated config written to ${t}`);else{const u=w(s.name,{allowBuilds:c,enableDepsDev:a,enableSocket:o,minimumReleaseAge:p,staged:$});j(t,u),e.success(`Created ${t}`)}e.notice(" Run 'vis doctor' to see your project's full health status.");return}i.close(),e.info("");const E=w(s.name,{allowBuilds:c,enableDepsDev:a,enableSocket:o,minimumReleaseAge:p,staged:$});if(j(t,E),e.success(`Created ${t}`),b){const f=Object.fromEntries(Object.entries(c).filter(([,r])=>r));for(const r of T(s.name,n,f))e.success(` ${r}`);for(const r of R(s.name,n,p))e.success(` ${r}`)}e.info(""),e.info(" Setup complete. Your config:");const k=[o&&"Socket.dev",a&&"deps.dev"].filter(Boolean);e.info(` Security: ${k.length>0?`${k.join(" + ")} enabled`:"defaults only"}`),e.info(` Build scripts: ${Object.values(c).filter(Boolean).length} approved`),e.info(` Min age: ${p===void 0?"not enforced":`${String(p)} minutes`}`),e.info(` Git hooks: ${$?"lint-staged configured":"not configured"}`),e.info(` PM sync: ${b?"done":"skipped"}`),e.info(""),e.notice(" Run 'vis doctor' to see your project's full health status."),e.info("")},V=(n,s,t,i)=>{const o=w(s.name,{allowBuilds:{},enableDepsDev:!1,enableSocket:!1,minimumReleaseAge:h,staged:!1});if(j(i,o),e.success(`Created ${i}`),e.info(" Secure defaults are applied automatically by defineConfig()."),t.syncNative){for(const a of T(s.name,n,{}))e.success(` ${a}`);for(const a of R(s.name,n,h))e.success(` ${a}`)}e.info(""),e.notice("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},_=(n,s,t)=>{const i=m(n,".."),o=m(s,"node_modules","@visulima","vis","schemas",t),a=O(i,o),l=a===""?`./${t}`:a.split(/[/\\]/u).join("/");return l.startsWith(".")?l:`./${l}`},Y=(n,s)=>{const t=_(m(n,"project.json"),s,"project.schema.json"),i=_(m(n,"vis.config.ts"),s,"vis-config.schema.json");e.info(""),e.info("Paste these into your config files to get editor IntelliSense:"),e.info(""),e.info(` project.json → "$schema": "${t}"`),e.info(` vis.config.ts → see ${i} (vis.config.ts is TypeScript; use the import path directly)`),e.info(""),e.notice("For nested project.json files, the `..` depth changes — run `vis migrate nx` to auto-rewrite all of them.")},te=async({options:n,workspaceRoot:s})=>{const t=s??process.cwd();if(n.schema){Y(t,t);return}const i=G(t),o=F(t);if(o&&!n.force){e.warn(`Config already exists: ${o}`),e.notice("Use --force to overwrite, or edit the existing file.");return}const a=o??m(t,"vis.config.ts");!!process.stdin.isTTY&&n.interactive!==!1?await L(t,i,a):V(t,i,n,a);const c=q(t);c.added.length>0&&e.success(`Added to .gitignore: ${c.added.join(", ")}`)};export{_ as buildSchemaRefForTesting,te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-
|
|
1
|
+
import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-DdXd3P3a.js";import{r as S,f as E,a as G}from"../packem_shared/selectors-B7lSFz7l.js";const T=(l,s,t)=>{const a=[],e=new Set,n=(r,u)=>{if(e.has(r))return;e.add(r);const m=s[r]??[];for(const d of m)n(d,u+1);const o=t[r],h=" ".repeat(u);a.push(`${h}${r}${o?.cache===!1?" (no-cache)":""}`)};for(const r of l)n(r,0);return a},x=(l,s,t)=>({roots:l,tasks:Object.fromEntries(Object.entries(t).map(([a,e])=>[a,{cache:e.cache,dependsOn:s[a]??[],outputs:e.outputs,parallelism:e.parallelism,projectRoot:e.projectRoot,target:e.target}]))}),C=async({argument:l,logger:s,options:t,process:a,visConfig:e,workspaceRoot:n})=>{const r=l[0];if(!r)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!n)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:u,packageJsons:m,workspace:o}=b(n,e),h=O(n,o,m),d=await S(r,o,a.cwd,n),{target:f}=d;let i=d.projects;t.projects!==void 0&&(i=P(i,String(t.projects),Object.keys(o.projects))),t.query&&(i=E(i,o,t.query)),i=G(i,o,t.tag);const k=i.filter(p=>o.projects[p]?.targets?.[f]!==void 0);if(k.length===0){s.info(`No projects have a "${f}" target.`);return}const y=k.map(p=>{const g=o.projects[p],j=g.targets?.[f],v={project:p,target:f};return{cache:j?.cache,id:`${p}:${f}`,outputs:j?.outputs??[],overrides:{command:j?.command},parallelism:j?.parallelism,projectRoot:g.root,target:v}}),c=$(y,{projectGraph:h,targetDefaults:u.tasks,workspace:o});if(t.json){s.info(JSON.stringify(x(c.roots,c.dependencies,c.tasks),null,2));return}const w=T(c.roots,c.dependencies,c.tasks);s.info(`Execution plan (${Object.keys(c.tasks).length} task(s), ${c.roots.length} root(s)):`),s.info("");for(const p of w)s.info(p)};export{C as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-
|
|
1
|
+
import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-BFsJ8iyZ.js";let a;const f=t=>(a??=u(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return f(t)},{execSync:l,spawnSync:p}=d("node:child_process"),y=async({argument:t,logger:e,options:s})=>{const o=t?.[0];e.info("info: checking for updates...");const i=m();let n;try{const c=l("npm view @visulima/vis version",{encoding:"utf8"}).trim();n=o??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===n&&!s.force){e.info(`
|
|
2
2
|
✓ Already up to date (${i})`);return}if(s.check){i===n?e.info(`✓ Already up to date (${i})`):e.info(`info: found @visulima/vis@${n} (current: ${i})`);return}if(e.info(`info: found @visulima/vis@${n} (current: ${i})`),e.info("info: installing..."),p("npm",["install","-g",`@visulima/vis@${n}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
|
|
3
3
|
✓ Updated @visulima/vis from ${i} → ${n}`)};export{y as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as
|
|
1
|
+
import{d as h,b as j}from"./catalog.js";import{V as n}from"../packem_shared/vis-user-error-DJvfOpBX.js";import{s as k}from"../packem_shared/affected-selection-DLrq50Mz.js";import{f as P,a as y}from"../packem_shared/selectors-B7lSFz7l.js";const b=(r,e)=>{if(r.length>0)return[...r];const s=e.indexOf("affected",2);return s===-1?[]:e.slice(s+1)},G=async({argument:r,options:e,process:s,rawArgv:u,runtime:g,visConfig:d,workspaceRoot:f})=>{if(!r[0])throw new n("Missing target. Usage: vis affected <target>");if(!f)throw new n("Could not determine workspace root. Run this command inside a monorepo.");if(e.sparseCheckout){const o=f,{packageJsons:p,workspace:t}=h(o,d),l=j(o,t,p),w=await k({base:e.base,downstream:e.downstream,head:e.head,uncommitted:e.uncommitted,upstream:e.upstream},{projectGraph:l,projects:t.projects,workspaceRoot:o},{defaultBase:d?.defaultBase});let c=P(w.affectedProjects,t,e.query);c=y(c,t,e.tag);const i=[...new Set(c.map(m=>t.projects[m]?.root??m))].sort();process.stdout.write(i.length>0?`${i.join(`
|
|
2
2
|
`)}
|
|
3
|
-
`:"");return}const a=
|
|
3
|
+
`:"");return}const a=b(u??[],s?.argv??[]);if(a.length===0)throw new n("Missing target. Usage: vis affected <target>");await g.runCommand("run",{argv:a.includes("--affected")?a:[...a,"--affected"]})};export{G as default,b as forwardedArgv};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I}from"../packem_shared/index-DHD8wb6Z.js";import{d as
|
|
1
|
+
import{a as I}from"../packem_shared/index-DHD8wb6Z.js";import{d as O}from"./catalog.js";import{f as D,a as x}from"../packem_shared/selectors-B7lSFz7l.js";import E from"./index.js";import{w as J}from"./cli-main.js";const S=(e,t)=>{for(const l of t)if(E(l,e))return!0;return!1},q=(e,t={})=>{const{depTypes:l,excludePatterns:f,externalOnly:h,includePatterns:m,internalOnly:g}=t;if(g&&h)return[];const d=l&&l.length>0?new Set(l):void 0,k=m&&m.length>0?m:void 0,w=f&&f.length>0?f:void 0,N=[];for(const y of e)g&&!y.isInternal||h&&y.isInternal||d&&!d.has(y.depType)||k&&(!y.packageName||!S(y.packageName,k))||w&&y.packageName&&S(y.packageName,w)||N.push(y);return N},C=new Set(["json","ndjson","table"]),M=e=>{if(e===void 0)return"table";const t=e.toLowerCase();if(!C.has(t))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return t},P=(e,t)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:I(t,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),$=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),A=e=>{if(!e||e.length===0)return;const t=[],l=[];for(const f of e)for(const h of f.split(",")){const m=h.trim();m&&($.has(m)?t.push(m):l.push(m))}if(l.length>0)throw new Error(`Unknown --dep-type value(s): ${l.join(", ")}. Valid: ${[...$].join(", ")}`);return t.length>0?t:void 0},V=async({logger:e,options:t,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root.");const h=M(t.json&&t.format===void 0?"json":t.format);if(t.deps){if(t.internalOnly&&t.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const p=A(t.depType),c=J(f);let r=q(c,{depTypes:p,excludePatterns:t.exclude,externalOnly:t.externalOnly,includePatterns:t.include,internalOnly:t.internalOnly});if(t.query||t.tag&&t.tag.length>0){const{workspace:n}=O(f,l),i=D(Object.keys(n.projects),n,t.query),T=new Set(x(i,n,t.tag));r=r.filter(v=>v.packageName!==void 0&&T.has(v.packageName))}const u=[...r].sort((n,i)=>{const T=`${n.packageName??n.packageDir} ${n.depType} ${n.depName}`,v=`${i.packageName??i.packageDir} ${i.depType} ${i.depName}`;return T.localeCompare(v)});if(h==="ndjson"){for(const n of u)e.info(JSON.stringify(P(n,f)));return}if(h==="json"){const n=u.map(i=>P(i,f));e.info(JSON.stringify(n,null,t.pretty?2:void 0));return}if(u.length===0){e.info("No matching dep-instances.");return}const o=["Package","Block","Dep","Specifier","Internal","Path"],a=u.map(n=>[n.packageName??n.packageDir,n.depType,n.depName,n.specifier,n.isInternal?"yes":"no",I(f,n.packageJsonPath)]),s=o.map((n,i)=>Math.max(n.length,...a.map(T=>(T[i]??"").length))),j=(n,i)=>n.padEnd(i);e.info(o.map((n,i)=>j(n,s[i])).join(" ")),e.info(s.map(n=>"─".repeat(n)).join("──"));for(const n of a)e.info(n.map((i,T)=>j(i,s[T])).join(" "));e.info(""),e.info(`${String(u.length)} dep-instance(s)`);return}if(h==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:m,workspace:g}=O(f,l);let d=Object.keys(g.projects).sort();if(t.query&&(d=D(d,g,t.query)),d=x(d,g,t.tag),d.length===0){e.info("No projects found.");return}const k=t.inferred,w=t.targets||k;if(h==="json"){const p=d.map(c=>{const r=g.projects[c],u=m.get(c)??{},o=Object.entries(r.targets??{}).map(([a])=>{const s=u[a],j=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...j?{inferred:!0}:{},name:a,type:s?.type}}).filter(a=>!k||a.inferred===!0);return{language:r.language,layer:r.layer,name:c,root:r.root,stack:r.stack,tags:r.tags??[],targets:o,type:r.projectType??"library"}});e.info(JSON.stringify(p,null,2));return}const N=(p,c)=>{const r=p.map((o,a)=>{let s=0;for(const j of c)s=Math.max(s,(j[a]??"").length);return Math.max(o.length,s)}),u=(o,a)=>o.padEnd(a);e.info(p.map((o,a)=>u(o,r[a])).join(" ")),e.info(r.map(o=>"─".repeat(o)).join("──"));for(const o of c)e.info(o.map((a,s)=>u(a,r[s])).join(" "))};if(w){const p=[];for(const c of d){const r=g.projects[c],u=m.get(c)??{};for(const o of Object.keys(r.targets??{}).sort()){const a=u[o],s=a?.inferred===!0;if(k&&!s)continue;const j=r.targets?.[o],n=j?.cache===!1?"no":j?.cache===!0?"yes":"default";p.push([c,o,a?.type??"—",n,s?"yes":"no",a?.description??"—"])}}if(p.length===0){e.info(k?"No inferred targets found.":"No targets found.");return}N(["Project","Target","Type","Cache","Inferred","Description"],p),e.info(""),e.info(`${String(p.length)} target(s) across ${String(d.length)} project(s)`);return}const y=["Project","Type","Layer","Tags","Targets"],b=d.map(p=>{const c=g.projects[p],r=Object.keys(c.targets??{});return[p,c.projectType??"library",c.layer??"—",(c.tags??[]).join(", ")||"—",r.length>4?`${r.slice(0,4).join(", ")}… (${String(r.length)})`:r.join(", ")||"—"]});N(y,b),e.info(""),e.info(`${String(d.length)} project(s)`)};export{V as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-BAjDJSEu.js";import{e as h,v as U}from"../packem_shared/index-DHD8wb6Z.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-
|
|
1
|
+
import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-BAjDJSEu.js";import{e as h,v as U}from"../packem_shared/index-DHD8wb6Z.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-DVFySxTS.js";import{p as z,s as X}from"../packem_shared/docker-Bex05Qcn.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
|
|
2
2
|
`)},$="v2.14.0",D=`https://github.com/hadolint/hadolint/releases/download/${$}`,ie={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ae=e=>ie[e],ce=(e=process.platform,t=process.arch)=>{const n=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(n===void 0)return;const r=t==="arm64"?"arm64":t==="x64"?"x86_64":void 0;if(n==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${n}-${r}`},L=e=>h(B(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",t=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const n of t)if(n!==""&&I(h(n,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",E=async e=>{const t=await fetch(e,{redirect:"follow"});if(!t.ok)throw new Error(`download failed (${String(t.status)} ${t.statusText}) for ${e}`);return Buffer.from(await t.arrayBuffer())},ue=async e=>{const t=L(e),n=ae(e),r=await E(`${D}/${e}`),o=Z("sha256").update(r).digest("hex");if(n===void 0){const s=await E(`${D}/${e}.sha256`),i=de(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==o)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${o}). Refusing to use the download.`)}else if(n.toLowerCase()!==o)throw new Error(`hadolint checksum mismatch (expected ${n.toLowerCase()}, got ${o}). Refusing to use the download.`);return oe(h(B(),"hadolint",$)),ee(t,r),process.platform!=="win32"&&te(t,493),t},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),t=await new Promise(n=>{e.question(` Download hadolint ${v($)} now? ${m("[y/N]")} `,r=>{n(r.trim().toLowerCase())})});return e.close(),t==="y"||t==="yes"},pe=async e=>{const{autoInstall:t=!1,log:n}=e,r=le();if(r!==void 0)return r;const o=ce();if(o===void 0){n(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=L(o);if(I(s))return s;if(!t){if(!(!!process.stdin.isTTY&&!ne)){n(`hadolint is not installed. Re-run with ${g("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(n(`${g("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){n(`Skipped. Install it yourself or re-run with ${g("--install")}.`);return}}n(`Downloading hadolint ${$} (${o})…`);try{const i=await ue(o);return n(`Installed hadolint to ${m(i)}`),i}catch(i){n(`Failed to download hadolint: ${i.message}`);return}},_=async(e,t,n)=>{if(t.length===0)return[];const r=["--format","json","--no-fail",...n!==void 0&&n!==""?["--config",n]:[],...t],o=await new Promise((i,l)=>{const a=Q(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(o.trim()==="")return[];let s;try{s=JSON.parse(o)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},C=(e,t,n)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||n.test(e)))return e.replace(/\binstall\b/u,`install ${t}`)},k={DL3014:e=>C(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>C(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},T=new Set(Object.keys(k)),me=(e,t)=>{const n=e.includes(`\r
|
|
3
3
|
`)?`\r
|
|
4
4
|
`:`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as q,b as J,p as f,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{V as ae}from"../packem_shared/vis-user-error-
|
|
1
|
+
import{a as q,b as J,p as f,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{V as ae}from"../packem_shared/vis-user-error-DJvfOpBX.js";import{d as ne}from"../packem_shared/pm-runner-d93_73O6.js";import{s as oe}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-DNeU8RBQ.js";const we=async({argument:$,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(q(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
|
|
2
2
|
Settings that would sync to pnpm-workspace.yaml:`);for(const S of r)f.success(` ${S}`)}else f.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(f.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),f.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!$?.length)return}const{packageManager:N}=G(d),U=H(d),i=o?.update??{},h=K(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const k=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(k))throw new Error(`Invalid target "${k}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(i.exclude)],ignore:m(i.ignore),include:[...m(e.include),...m(i.include),...$],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:k};let x=0;for(const t of h.values())x+=t.size;const w=!!process.stdout.isTTY&&!ee;let l;const I=w?(t,r)=>{l?l.rerender(c.createElement(j,{current:t,total:r})):l=O(c.createElement(j,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};w||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
|
|
3
3
|
`);const g=new Set;T("socket")&&g.add("socket"),T("depsDev")&&g.add("deps-dev");const v=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:g,minimumScore:v}),{failed:E,outdated:n}=await W(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),E.length>0&&s.warn(`Failed to fetch: ${E.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const R=e.format??i.format??"table",V=te(e.aiType??"impact"),u=e.ai?await se(n,s,o?.ai,V):void 0;if(w&&R==="table"){const t=new ce(n,u??null),r=o?.tui?.autoExit??!1,S=r===!0?3:typeof r=="number"?r:0;await O(c.createElement(ie,{autoExitSeconds:S,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const B=process.stdout.columns||80;process.stdout.write(`
|
|
4
4
|
`);for(const a of n){const Y=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,z=Y?b?"✓":"⚠":"✓",F=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,L=p===void 0?"":` [${String(Math.round(p*100))}%]`,A=p===void 0?void 0:oe(p);process.stdout.write(`${X(c.createElement(y,null," ",c.createElement(y,{color:F},z),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),A?c.createElement(y,{color:A},L):null),{columns:B})}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`)
|
|
3
|
-
`:`
|
|
4
|
-
|
|
5
|
-
`)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`)
|
|
9
|
-
`);le(n,h,{overwrite:!0}),r.push(n);continue}const p=S(n),f=p.workspaces;Array.isArray(f)?p.workspaces=f.filter(m=>typeof m!="string"||!i.has(m)):f&&Array.isArray(f.packages)&&(f.packages=f.packages.filter(m=>typeof m!="string"||!i.has(m))),j(n,p,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},xe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Je=(e,a={})=>{const s=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const o=I(e,n,"package.json"),i=F(o);if(!i)continue;const c=typeof i.name=="string"?i.name:void 0;for(const p of xe){if(s.has(p))continue;const f=i[p];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:p,packageDir:n,packageJsonPath:o,packageName:c})}}return r},Se=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.keys(p).length===0&&Reflect.deleteProperty(i,c.depType)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Ie=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Me=(e,a={})=>{const s=new Set(a.depTypes??Ie),t=new Set(a.ignoreDeps),r=new Map;for(const o of e)o.packageDir!=="."||!s.has(o.depType)||r.set(o.depName,{depType:o.depType,specifier:o.specifier});if(r.size===0)return[];const n=[];for(const o of e){if(o.packageDir==="."||!s.has(o.depType)||t.has(o.depName))continue;const i=r.get(o.depName);i&&n.push({childSpecifier:o.specifier,depName:o.depName,depType:o.depType,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},We=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:s}]},je=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),o=n.dependencies;if(typeof o!="object"||o===null)continue;const i=o;n.devDependencies??={};const c=n.devDependencies;for(const p of r.depNames){const f=i[p];typeof f=="string"&&(p in c||(c[p]=f),Reflect.deleteProperty(i,p))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ae=/^[a-z][\w-]*@\S+$/i,Ee=(e,a,s={})=>{if(!a)return[];const t=I(e,"package.json"),r=F(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&Ae.test(n)?[]:[{packageJsonPath:t,suggested:s.suggested}]},Re=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ce=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);return t?t.private===!0?[]:[{packageJsonPath:s,rawValue:t.private}]:[]},Ve=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let o=n;if("private"in n)n.private=!0;else{const{name:i,version:c,...p}=n,f={};i!==void 0&&(f.name=i),c!==void 0&&(f.version=c),f.private=!0;for(const[m,h]of Object.entries(p))f[m]=h;o=f}j(r.packageJsonPath,o,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},_e=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Fe=new Set(["dependencies","devDependencies","peerDependencies"]),Oe=(e,a)=>{for(const s of e)if(s.members?.includes(a)||s.prefixes?.some(t=>a.startsWith(t)))return s},Be=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),He=(e,a={})=>{const s=new Set(a.ignoreFamilies),t=new Map;for(const i of _e)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Fe.has(i.depType)||Be(i.specifier))continue;const c=Oe(r,i.depName);if(!c||s.has(c.id))continue;const p=n.get(c.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};p?p.push(f):n.set(c.id,[f])}const o=[];for(const[i,c]of n){const p=[...new Set(c.map(m=>m.specifier))];if(p.length<2)continue;const f=t.get(i);f&&o.push({family:i,familyLabel:f.label??i,members:c,specifiers:p})}return o},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const s=new Set(a.ignoreDeps),t=new Map,r=o=>{const i=t.get(o);if(i!==void 0)return i;try{const p=S(o).private===!0;return t.set(o,p),p}catch{return t.set(o,!1),!1}},n=[];for(const o of e)o.depType==="dependencies"&&ze(o.depName)&&(s.has(o.depName)||r(o.packageJsonPath)&&n.push({childSpecifier:o.specifier,depName:o.depName,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName}));return n},Ke=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n),c=i.dependencies;if(typeof c!="object"||c===null)continue;const p=c;i.devDependencies??={};const f=i.devDependencies;for(const m of o){const h=p[m.depName];typeof h=="string"&&(m.depName in f||(f[m.depName]=h),Reflect.deleteProperty(p,m.depName))}Object.keys(p).length===0&&Reflect.deleteProperty(i,"dependencies"),j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ge=(e,a={})=>{const s=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:s,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ue=(e,a,s,t)=>{const r=a.split(".");let n=e;for(let c=0;c<r.length-1;c+=1){const p=r[c],f=n[p];(typeof f!="object"||f===null)&&(n[p]={}),n=n[p]}const o=r.at(-1);let i=n[o];(typeof i!="object"||i===null)&&(i={},n[o]=i),i[s]=t},Ye=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o)if(c.depType.includes("."))Ue(i,c.depType,c.depName,c.fix);else{const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Xe=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Ze=e=>e.startsWith("workspace:"),et=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},tt=(e,a)=>{if(e.get("default")?.has(a))return"default";const s=[...e.keys()].filter(t=>t!=="default").sort();for(const t of s)if(e.get(t)?.has(a))return t},st=e=>e==="default"?"catalog:":`catalog:${e}`,ot=(e,a)=>{const s=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of s){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const o=L(t.specifier);if(!o){t=r;continue}const i=K(o,n),c=K(n,o);(a==="highest"&&i||a==="lowest"&&c)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},nt=(e,a={})=>{const s=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Xe.has(i.depType)||Ze(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),o=new Map;for(const i of n){const c=o.get(i.depName);c?c.push(i):o.set(i.depName,[i])}for(const[i,c]of o){const p=a.pinned?.get(i);if(p!==void 0){for(const u of c)u.specifier!==p&&r.push({canonicalSource:"cli:--pin",depName:i,depType:u.depType,fix:p,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier});continue}if(s==="catalog"){const{catalogs:u}=a;if(!u)continue;const k=tt(u,i);if(!k)continue;const J=st(k);for(const P of c)et(P.specifier)!==k&&r.push({canonicalSource:`catalog:${k}`,depName:i,depType:P.depType,fix:J,packageDir:P.packageDir,packageJsonPath:P.packageJsonPath,packageName:P.packageName,specifier:P.specifier});continue}const f=c.filter(u=>!Qe(u.specifier));if(f.length<2||new Set(f.map(u=>u.specifier)).size<=1)continue;const h=ot(f,s);if(!h)continue;const d=h.canonical.specifier;for(const u of f)u.specifier!==d&&r.push({canonicalSource:h.canonicalSource,depName:i,depType:u.depType,fix:d,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier})}return r},at=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},it=e=>{if(_(I(e,"pnpm-workspace.yaml")))return!0;const a=I(e,"package.json");if(!_(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},A=(e,a)=>{const s=new Map;for(const t of e){const r=a(t),n=s.get(r);n?n.push(t):s.set(r,[t])}return s},rt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-protocol: no violations"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i){const f=s?x("→"):b("→");t.info(` ${g(p.depType)} ${p.depName}: ${D(p.specifier)} ${f} ${v(p.fix)}`)}}s||t.info(g(" Run with --fix to rewrite specifiers in place."))},ct=(e,a,s)=>{if(e.length===0){s.info(v("✓ redefine-root: no violations"));return}s.info(b(w(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r)s.info(` ${g(o.depType)} ${o.depName}: ${D(o.childSpecifier)} ${g(`(root ${o.rootDepType}: ${o.rootSpecifier})`)}`)}s.info(g(" Remove these from child package.json files — root pin will resolve."))},pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-versions: no drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.depName)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)} ${g(f.depType)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align drifting specifiers."))},ft=(e,a,s)=>{if(e.length===0){s.info(v("✓ banned-deps: no violations"));return}s.info(D(w(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r){const i=o.replacement?` ${g("→")} ${v(o.replacement)}`:"";s.info(` ${g(o.depType)} ${D(o.depName)}${i}`),s.info(` ${g(o.reason)}`)}}},lt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ catalog-proposals: nothing worth promoting"));return}const r=s?"Added":"Would add",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const o of e)t.info(` ${w(o.depName)}: ${v(o.specifier)} ${g(`(${String(o.instanceCount)} packages agree)`)}`);if(!s){const o=be(a,e);if(o){t.info(""),t.info(g("Proposed pnpm-workspace.yaml changes:"));for(const i of o.split(`
|
|
10
|
-
`)
|
|
11
|
-
`)}
|
|
12
|
-
`)}
|
|
13
|
-
|
|
14
|
-
`)}
|
|
15
|
-
|
|
16
|
-
`);for(const s of
|
|
17
|
-
`)
|
|
18
|
-
`)
|
|
19
|
-
|
|
20
|
-
`)}
|
|
21
|
-
`);
|
|
22
|
-
`);
|
|
23
|
-
`)}
|
|
24
|
-
`)}},
|
|
25
|
-
`)}
|
|
1
|
+
import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-BAjDJSEu.js";import{v as T,a as G,U as I,z as Se,e as M}from"../packem_shared/index-DHD8wb6Z.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Te,scanGitHistory as Re}from"@visulima/secret-scanner";import{a4 as Ae,a5 as Q,p as y}from"./cli-main.js";import{I as je,W as Ne}from"../packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
|
|
2
|
+
`),this.#d=0}#$(){if(this.#d>0&&this.#s.isTTY){for(let t=1;t<this.#d;t+=1)this.#s.write("\x1B[1A\x1B[2K");this.#s.write("\r\x1B[K")}this.#d=0}#S(t){this.#f=t,this.#n?this.#n.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#$(),this.#s.write(`${t}
|
|
3
|
+
`))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,R=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=R(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,R(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(R(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(R(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,R(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(R(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!T(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
|
|
4
|
+
`),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
|
|
5
|
+
`).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
|
|
6
|
+
`).trimEnd()},mt=(e,t)=>{if(!T(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},yt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,we=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:T(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:yt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},V=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),wt=e=>V(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>T(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=V(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return V(r).map(i=>T(i)?i:M(e,i))}return s.map(r=>T(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
|
|
7
|
+
|
|
8
|
+
`);for(const s of n){const r=t?L(s.id):s.id,i=s.tags.length>0?` ${t?$(`[${s.tags.join(", ")}]`):`[${s.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
|
|
9
|
+
${s.description}
|
|
10
|
+
`),s.keywords.length>0){const c=`keywords: ${s.keywords.slice(0,6).join(", ")}${s.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?$(c):c}
|
|
11
|
+
`)}process.stdout.write(`
|
|
12
|
+
`)}},bt=async(e,t)=>{const n=await Te(e);if(n.length===0){process.stdout.write(t?`${$("No non-HTTP validators required by the current ruleset.")}
|
|
13
|
+
`:`No non-HTTP validators required by the current ruleset.
|
|
14
|
+
`);return}process.stdout.write(`${String(n.length)} non-HTTP validator type(s) referenced by the current ruleset:
|
|
15
|
+
|
|
16
|
+
`);for(const s of n){const r=t?L(s.displayName):s.displayName,i=`(${s.type}, ${String(s.ruleCount)} rule${s.ruleCount===1?"":"s"})`;process.stdout.write(`${r} ${t?$(i):i}
|
|
17
|
+
`),process.stdout.write(` ${s.summary}
|
|
18
|
+
`);const c=s.packageName?`install: npm add ${s.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?$(c):c}
|
|
19
|
+
|
|
20
|
+
`)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${J(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
|
|
21
|
+
`)},Et=async(e,t,n)=>{if(e.staged){if(!_(n))throw new Error("--staged requires a git working tree, and none was detected.");return{files:wt(n)}}if(e.since){if(!_(n))throw new Error("--since requires a git working tree, and none was detected.");return{files:ie(n,e.since)}}if(e.affected){if(!_(n))return y.warn("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(r=>I(n,r)):[n]};const s=process.env.VIS_BASE??"HEAD~1";return{files:ie(n,s)}}return{paths:t&&t.length>0?t.map(s=>I(n,s)):[n]}},It=(e,t,n,s,r,i,c)=>{switch(t){case"json":{const o=e.map(a=>A(a,n));process.stdout.write(`${JSON.stringify(o,null,2)}
|
|
22
|
+
`);break}case"sarif":{process.stdout.write(`${we(e,r,n,i)}
|
|
23
|
+
`);break}default:process.stdout.write(`${pt(e,n,s,{redact:c})}
|
|
24
|
+
`)}},Tt=async(e,t,n,s,r)=>{if(e.staged||e.since||e.affected)throw new Error("--history scans commit history and can't be combined with --staged / --since / --affected (those scan the working tree).");if(!_(t))throw new Error("--history requires a git working tree, and none was detected.");const i=$e(e.format),c=!e.quiet&&i==="text",o=Y({verbose:c});o.start("scanning git history for secrets");let a;try{a=await Re({...n,cwd:t,maxCommits:e.maxCommits,range:e.historyRange}),o.succeed()}catch(u){throw o.failed(),new Error(`git-history secret scan failed: ${u instanceof Error?u.message:String(u)}`,{cause:u})}const l=n.redact===!0,f=l?ge(a,["match","secret"]):a;switch(i){case"json":{process.stdout.write(`${JSON.stringify(f.map(u=>A(u,t)),null,2)}
|
|
25
|
+
`);break}case"sarif":{const u=await K(n).catch(()=>[]);process.stdout.write(`${we(f,r,t,u)}
|
|
26
|
+
`);break}default:process.stdout.write(`${gt(f,s,{redact:l})}
|
|
27
|
+
`)}if(a.length>0){e.quiet||(y.warn(`${String(a.length)} potential secret(s) found across git history`),y.notice("Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.")),process.exitCode=1;return}e.quiet||y.success("No secrets detected in git history.")},Bt=async({argument:e,options:t,visConfig:n,workspaceRoot:s})=>{const r=t,i=e,c=s??process.cwd(),o=!r.quiet&&process.stdout.isTTY,a=n?.secrets,l=kt(r,a,c),f="0.0.0-alpha";if(r.listRules){await xt(l,o);return}if(r.listValidators){await bt(l,o);return}if(r.init){await vt(c,l,r.dryRun??!1);return}if(r.history){await Tt(r,c,l,o,f);return}const u=await Et(r,i??[],c);if(u.files?.length===0){r.quiet||y.success("No files to scan.");return}const h=!r.quiet&&!["json","sarif"].includes(r.format??"text"),g=Y({verbose:h});g.start("scanning for secrets");let p;try{p=u.files===void 0?await le(u.paths??[c],l):await Ee(u.files,l),g.succeed()}catch(w){throw g.failed(),new Error(`secret scan failed: ${w instanceof Error?w.message:String(w)}`,{cause:w})}if(r.verbose){const w=await Ie(l);if(w.length>0){y.warn(`${String(w.length)} rule(s) skipped due to invalid regex. First few:`);for(const O of w.slice(0,5))process.stderr.write(` - ${O.ruleId}: ${O.reason}
|
|
28
|
+
`)}}const m=typeof l.baseline=="string"?l.baseline:M(c,F),C=!r.quiet&&X(m);if(r.updateBaseline){const w=ye(p,m,c,{replace:r.replaceBaseline});y.success(`Baseline updated: ${G(c,m)||m} now contains ${String(w)} entries.`);return}const b=$e(r.format),d=b==="sarif"?await K(l).catch(()=>[]):[],S=l.redact===!0,v=S?ge(p,["match","secret"]):p;if(It(v,b,c,o,f,d,S),b==="text"&&C&&St(ut(p,m,c)),p.length>0){r.quiet||(y.warn(`${String(p.length)} potential secret(s) found`),y.notice("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1;return}r.quiet||y.success("No secrets detected.")};export{Bt as default,kt as resolveScanOptions};
|