@visulima/vis 1.0.0-alpha.11 → 1.0.0-alpha.13

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.
Files changed (116) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/LICENSE.md +559 -186
  3. package/README.md +18 -0
  4. package/dist/bin.js +1 -9
  5. package/dist/config/index.d.ts +477 -556
  6. package/dist/config/index.js +1 -2
  7. package/dist/generate/index.js +1 -3
  8. package/dist/packem_chunks/applyDefaults.js +2 -336
  9. package/dist/packem_chunks/bin.js +234 -9552
  10. package/dist/packem_chunks/doctor-probe.js +2 -112
  11. package/dist/packem_chunks/fix.js +11 -234
  12. package/dist/packem_chunks/handler.js +1 -99
  13. package/dist/packem_chunks/handler10.js +2 -53
  14. package/dist/packem_chunks/handler11.js +1 -32
  15. package/dist/packem_chunks/handler12.js +5 -100
  16. package/dist/packem_chunks/handler13.js +1 -25
  17. package/dist/packem_chunks/handler14.js +18 -916
  18. package/dist/packem_chunks/handler15.js +15 -201
  19. package/dist/packem_chunks/handler16.js +1 -124
  20. package/dist/packem_chunks/handler17.js +1 -13
  21. package/dist/packem_chunks/handler18.js +1 -106
  22. package/dist/packem_chunks/handler19.js +1 -19
  23. package/dist/packem_chunks/handler2.js +2 -75
  24. package/dist/packem_chunks/handler20.js +5 -29
  25. package/dist/packem_chunks/handler21.js +1 -222
  26. package/dist/packem_chunks/handler22.js +1 -237
  27. package/dist/packem_chunks/handler23.js +5 -101
  28. package/dist/packem_chunks/handler24.js +1 -110
  29. package/dist/packem_chunks/handler25.js +3 -402
  30. package/dist/packem_chunks/handler26.js +1 -13
  31. package/dist/packem_chunks/handler27.js +1 -63
  32. package/dist/packem_chunks/handler28.js +7 -34
  33. package/dist/packem_chunks/handler29.js +21 -456
  34. package/dist/packem_chunks/handler3.js +4 -95
  35. package/dist/packem_chunks/handler30.js +3 -170
  36. package/dist/packem_chunks/handler31.js +1 -530
  37. package/dist/packem_chunks/handler32.js +2 -214
  38. package/dist/packem_chunks/handler33.js +25 -119
  39. package/dist/packem_chunks/handler34.js +2 -630
  40. package/dist/packem_chunks/handler35.js +3 -283
  41. package/dist/packem_chunks/handler36.js +22 -542
  42. package/dist/packem_chunks/handler37.js +410 -744
  43. package/dist/packem_chunks/handler38.js +22 -989
  44. package/dist/packem_chunks/handler39.js +22 -574
  45. package/dist/packem_chunks/handler4.js +2 -90
  46. package/dist/packem_chunks/handler40.js +22 -1685
  47. package/dist/packem_chunks/handler41.js +6 -1088
  48. package/dist/packem_chunks/handler42.js +5 -797
  49. package/dist/packem_chunks/handler43.js +10 -2658
  50. package/dist/packem_chunks/handler44.js +51 -3784
  51. package/dist/packem_chunks/handler45.js +25 -2574
  52. package/dist/packem_chunks/handler46.js +3 -3769
  53. package/dist/packem_chunks/handler47.js +21 -1485
  54. package/dist/packem_chunks/handler48.js +42 -0
  55. package/dist/packem_chunks/handler5.js +8 -174
  56. package/dist/packem_chunks/handler6.js +1 -95
  57. package/dist/packem_chunks/handler7.js +1 -115
  58. package/dist/packem_chunks/handler8.js +1 -12
  59. package/dist/packem_chunks/handler9.js +1 -29
  60. package/dist/packem_chunks/heal-accept.js +10 -522
  61. package/dist/packem_chunks/heal.js +14 -673
  62. package/dist/packem_chunks/index.js +7 -873
  63. package/dist/packem_chunks/loader.js +1 -23
  64. package/dist/packem_chunks/tar.js +3 -0
  65. package/dist/packem_shared/ai-analysis-hm8d2W7z.js +67 -0
  66. package/dist/packem_shared/ai-cache-DoiF80AR.js +1 -0
  67. package/dist/packem_shared/ai-fix-nn4zOE95.js +43 -0
  68. package/dist/packem_shared/cache-directory-CwHlJhgx.js +1 -0
  69. package/dist/packem_shared/dependency-scan-COr5n63B.js +2 -0
  70. package/dist/packem_shared/docker-D6OGr5_S.js +2 -0
  71. package/dist/packem_shared/failure-log-iUVLf6ts.js +2 -0
  72. package/dist/packem_shared/flakiness-D9wf0t56.js +1 -0
  73. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  74. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  75. package/dist/packem_shared/otel-DxDUPJJH.js +6 -0
  76. package/dist/packem_shared/otelPlugin-CQq6poq8.js +1 -0
  77. package/dist/packem_shared/registry-CkubDdiY.js +2 -0
  78. package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +1 -0
  79. package/dist/packem_shared/runtime-check-BXZ43CBW.js +1 -0
  80. package/dist/packem_shared/selectors-BylODRiM.js +3 -0
  81. package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
  82. package/dist/packem_shared/toolchain-BgBOUHII.js +5 -0
  83. package/dist/packem_shared/typosquats-CcZl99B1.js +1 -0
  84. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +1 -0
  85. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  86. package/dist/packem_shared/verify-Baj5mFJ7.js +1 -0
  87. package/dist/packem_shared/vis-update-app-D1jl0UZZ.js +1 -0
  88. package/dist/packem_shared/xxh3-DrAUNq4n.js +1 -0
  89. package/index.js +556 -727
  90. package/package.json +19 -29
  91. package/schemas/project.schema.json +739 -297
  92. package/schemas/vis-config.schema.json +3365 -384
  93. package/templates/buildkite-ci/template.yml +20 -20
  94. package/dist/packem_shared/VisUpdateApp-D-Yz_wvg.js +0 -1316
  95. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  96. package/dist/packem_shared/ai-analysis-CHeB1joD.js +0 -367
  97. package/dist/packem_shared/ai-cache-Be_jexe4.js +0 -142
  98. package/dist/packem_shared/ai-fix-B9iQVcD2.js +0 -379
  99. package/dist/packem_shared/cache-directory-2qvs4goY.js +0 -98
  100. package/dist/packem_shared/catalog-BJTtyi-O.js +0 -1371
  101. package/dist/packem_shared/dependency-scan-A0KSklpG.js +0 -188
  102. package/dist/packem_shared/docker-2iZzc280.js +0 -181
  103. package/dist/packem_shared/failure-log-Cz3Z4SKL.js +0 -100
  104. package/dist/packem_shared/flakiness-goTxXuCX.js +0 -180
  105. package/dist/packem_shared/otel-DCvqCTz_.js +0 -158
  106. package/dist/packem_shared/otelPlugin-DFaLDvJf.js +0 -3
  107. package/dist/packem_shared/registry-CbqXI0rc.js +0 -272
  108. package/dist/packem_shared/run-summary-utils-PVMl4aIh.js +0 -130
  109. package/dist/packem_shared/runtime-check-Cobi3p6l.js +0 -127
  110. package/dist/packem_shared/selectors-SM69TfqC.js +0 -194
  111. package/dist/packem_shared/symbols-Ta7g2nU-.js +0 -14
  112. package/dist/packem_shared/toolchain-BdZd9eBi.js +0 -975
  113. package/dist/packem_shared/typosquats-C-bCh3PX.js +0 -1210
  114. package/dist/packem_shared/use-measured-height-CNP0vT4M.js +0 -20
  115. package/dist/packem_shared/utils-CthVdBPS.js +0 -40
  116. package/dist/packem_shared/xxh3-Ck8mXNg1.js +0 -239
@@ -1,283 +1,3 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- import { L as migrateDeps, M as printSummary, N as migrateLintStaged, O as migrateNanoStaged, P as migrateTurborepo, Q as migrateNx, R as migrateMoon, T as migrateGitleaks, U as migrateKingfisher, V as migrateSecretlint, W as createMigrationReport, X as detectPackageManager } from './bin.js';
21
- const {
22
- stdin,
23
- stdout
24
- } = __cjs_getProcess;
25
- const {
26
- createInterface
27
- } = __cjs_getBuiltinModule("node:readline/promises");
28
- import { isAccessibleSync, readFileSync } from '@visulima/fs';
29
- import { join } from '@visulima/path';
30
-
31
- const confirm = async (question) => {
32
- if (!stdin.isTTY) {
33
- return true;
34
- }
35
- const rl = createInterface({ input: stdin, output: stdout });
36
- try {
37
- const answer = (await rl.question(`${question} [Y/n] `)).trim().toLowerCase();
38
- if (answer === "" || answer === "y" || answer === "yes") {
39
- return true;
40
- }
41
- return false;
42
- } finally {
43
- rl.close();
44
- }
45
- };
46
-
47
- const HOOK_CANDIDATES = [".husky/pre-commit", ".vis-hooks/pre-commit", ".git/hooks/pre-commit"];
48
- const SECRETLINT_CONFIG_FILES = [
49
- ".secretlintrc",
50
- ".secretlintrc.json",
51
- ".secretlintrc.js",
52
- ".secretlintrc.mjs",
53
- ".secretlintrc.cjs",
54
- ".secretlintrc.yml",
55
- ".secretlintrc.yaml"
56
- ];
57
- const scanPackageJson = (root) => {
58
- const packageJsonPath = join(root, "package.json");
59
- if (!isAccessibleSync(packageJsonPath)) {
60
- return [];
61
- }
62
- let pkg;
63
- try {
64
- pkg = JSON.parse(readFileSync(packageJsonPath));
65
- } catch {
66
- return [];
67
- }
68
- const issues = [];
69
- if (pkg.scripts) {
70
- for (const [name, value] of Object.entries(pkg.scripts)) {
71
- if (typeof value !== "string") {
72
- continue;
73
- }
74
- if (/\bgitleaks\b/.test(value)) {
75
- issues.push({ detail: `Script "${name}" still invokes gitleaks: ${value}`, kind: "script", location: "package.json" });
76
- }
77
- if (/\bsecretlint\b/.test(value)) {
78
- issues.push({ detail: `Script "${name}" still invokes secretlint: ${value}`, kind: "script", location: "package.json" });
79
- }
80
- }
81
- }
82
- if (pkg.devDependencies) {
83
- for (const dep of Object.keys(pkg.devDependencies)) {
84
- if (dep === "gitleaks" || dep === "@gitleaks/cli") {
85
- issues.push({ detail: `devDependency \`${dep}\` is still installed`, kind: "devDep", location: "package.json" });
86
- }
87
- if (dep === "secretlint" || dep.startsWith("@secretlint/")) {
88
- issues.push({ detail: `devDependency \`${dep}\` is still installed`, kind: "devDep", location: "package.json" });
89
- }
90
- }
91
- }
92
- return issues;
93
- };
94
- const scanHooks = (root) => {
95
- const issues = [];
96
- for (const rel of HOOK_CANDIDATES) {
97
- const abs = join(root, rel);
98
- if (!isAccessibleSync(abs)) {
99
- continue;
100
- }
101
- const content = readFileSync(abs);
102
- if (/\bgitleaks\b/.test(content)) {
103
- issues.push({ detail: "gitleaks invocation still present in hook", kind: "hook", location: rel });
104
- }
105
- if (/\bsecretlint\b/.test(content)) {
106
- issues.push({ detail: "secretlint invocation still present in hook", kind: "hook", location: rel });
107
- }
108
- }
109
- return issues;
110
- };
111
- const scanConfigs = (root) => {
112
- const issues = [];
113
- for (const name of SECRETLINT_CONFIG_FILES) {
114
- if (isAccessibleSync(join(root, name))) {
115
- issues.push({ detail: "secretlint config should be removed after migration", kind: "config", location: name });
116
- }
117
- }
118
- return issues;
119
- };
120
- const verifyMigration = (root, logger) => {
121
- const issues = [...scanPackageJson(root), ...scanHooks(root), ...scanConfigs(root)];
122
- if (issues.length === 0) {
123
- logger.info("✓ No unmigrated gitleaks/secretlint references found.");
124
- return [];
125
- }
126
- logger.warn(`Found ${String(issues.length)} unmigrated reference(s):`);
127
- for (const issue of issues) {
128
- logger.warn(` [${issue.kind}] ${issue.location} — ${issue.detail}`);
129
- }
130
- return issues;
131
- };
132
-
133
- const buildContext = (toolbox) => {
134
- const root = toolbox.workspaceRoot ?? process.cwd();
135
- return {
136
- config: toolbox.visConfig ?? {},
137
- dryRun: Boolean(toolbox.options.dryRun),
138
- logger: toolbox.logger,
139
- packageManager: detectPackageManager(root),
140
- report: createMigrationReport(),
141
- root
142
- };
143
- };
144
- const maybeConfirm = async (name, options, logger) => {
145
- if (options.yes || options.dryRun) {
146
- return true;
147
- }
148
- const confirmed = await confirm(`This will edit files, scripts, and hooks for "${name}". Backups (.bak) will be created. Continue?`);
149
- if (!confirmed) {
150
- logger.info("Aborted.");
151
- }
152
- return confirmed;
153
- };
154
- const announceDryRun = (ctx) => {
155
- if (ctx.dryRun) {
156
- ctx.logger.info("Running in dry-run mode — no changes will be made.\n");
157
- }
158
- };
159
- const migrateDepsExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
160
- if (!await maybeConfirm("deps", options, logger)) {
161
- return;
162
- }
163
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
164
- announceDryRun(ctx);
165
- logger.info("── Migrating dependencies and scripts ──");
166
- migrateDeps(
167
- ctx.root,
168
- ctx.packageManager,
169
- ctx.config,
170
- { dryRun: ctx.dryRun },
171
- logger,
172
- ctx.report
173
- );
174
- logger.info("");
175
- printSummary(ctx.report, logger);
176
- };
177
- const migrateLintStagedExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
178
- if (!await maybeConfirm("lint-staged", options, logger)) {
179
- return;
180
- }
181
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
182
- announceDryRun(ctx);
183
- logger.info("── Migrating lint-staged ──");
184
- migrateLintStaged(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
185
- logger.info("");
186
- printSummary(ctx.report, logger);
187
- };
188
- const migrateNanoStagedExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
189
- if (!await maybeConfirm("nano-staged", options, logger)) {
190
- return;
191
- }
192
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
193
- announceDryRun(ctx);
194
- logger.info("── Migrating nano-staged ──");
195
- migrateNanoStaged(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
196
- logger.info("");
197
- printSummary(ctx.report, logger);
198
- };
199
- const migrateTurborepoExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
200
- if (!await maybeConfirm("turborepo", options, logger)) {
201
- return;
202
- }
203
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
204
- announceDryRun(ctx);
205
- logger.info("── Migrating turborepo ──");
206
- migrateTurborepo(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
207
- logger.info("");
208
- printSummary(ctx.report, logger);
209
- };
210
- const migrateNxExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
211
- if (!await maybeConfirm("nx", options, logger)) {
212
- return;
213
- }
214
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
215
- announceDryRun(ctx);
216
- logger.info("── Migrating nx ──");
217
- migrateNx(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
218
- logger.info("");
219
- printSummary(ctx.report, logger);
220
- };
221
- const migrateMoonExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
222
- if (!await maybeConfirm("moon", options, logger)) {
223
- return;
224
- }
225
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
226
- announceDryRun(ctx);
227
- logger.info("── Migrating moon ──");
228
- migrateMoon(ctx.root, { copyTemplates: Boolean(options.copyTemplates), dryRun: ctx.dryRun }, logger, ctx.report);
229
- logger.info("");
230
- printSummary(ctx.report, logger);
231
- };
232
- const migrateGitleaksExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
233
- if (!await maybeConfirm("gitleaks", options, logger)) {
234
- return;
235
- }
236
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
237
- announceDryRun(ctx);
238
- logger.info("── Migrating gitleaks ──");
239
- migrateGitleaks(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
240
- logger.info("");
241
- printSummary(ctx.report, logger);
242
- };
243
- const migrateKingfisherExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
244
- if (!await maybeConfirm("kingfisher", options, logger)) {
245
- return;
246
- }
247
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
248
- announceDryRun(ctx);
249
- logger.info("── Migrating Kingfisher ──");
250
- migrateKingfisher(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
251
- logger.info("");
252
- printSummary(ctx.report, logger);
253
- };
254
- const migrateSecretlintExecuteImpl = async ({ logger, options, visConfig, workspaceRoot }) => {
255
- if (!await maybeConfirm("secretlint", options, logger)) {
256
- return;
257
- }
258
- const ctx = buildContext({ logger, options, visConfig, workspaceRoot });
259
- announceDryRun(ctx);
260
- logger.info("── Migrating secretlint ──");
261
- migrateSecretlint(ctx.root, { dryRun: ctx.dryRun }, logger, ctx.report);
262
- logger.info("");
263
- printSummary(ctx.report, logger);
264
- };
265
- const migrateVerifyExecuteImpl = ({ logger, workspaceRoot }) => {
266
- const root = workspaceRoot ?? process.cwd();
267
- const issues = verifyMigration(root, logger);
268
- if (issues.length > 0) {
269
- process.exitCode = 1;
270
- }
271
- };
272
- const migrateDepsExecute = migrateDepsExecuteImpl;
273
- const migrateLintStagedExecute = migrateLintStagedExecuteImpl;
274
- const migrateNanoStagedExecute = migrateNanoStagedExecuteImpl;
275
- const migrateTurborepoExecute = migrateTurborepoExecuteImpl;
276
- const migrateNxExecute = migrateNxExecuteImpl;
277
- const migrateMoonExecute = migrateMoonExecuteImpl;
278
- const migrateGitleaksExecute = migrateGitleaksExecuteImpl;
279
- const migrateKingfisherExecute = migrateKingfisherExecuteImpl;
280
- const migrateSecretlintExecute = migrateSecretlintExecuteImpl;
281
- const migrateVerifyExecute = migrateVerifyExecuteImpl;
282
-
283
- export { migrateDepsExecute, migrateGitleaksExecute, migrateKingfisherExecute, migrateLintStagedExecute, migrateMoonExecute, migrateNanoStagedExecute, migrateNxExecute, migrateSecretlintExecute, migrateTurborepoExecute, migrateVerifyExecute };
1
+ var R=Object.defineProperty;var k=(e,o)=>R(e,"name",{value:o,configurable:!0});import{createRequire as A}from"node:module";import{writeFileSync as T,writeJsonSync as I}from"@visulima/fs";import{join as w,relative as L}from"@visulima/path";import{o as M}from"../packem_shared/index-DH-5hsrC.js";import{k as U,ak as O,al as W,z as B}from"./bin.js";const x=A(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=k(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[o,t]=y.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return y.getBuiltinModule(e)}return x(e)},"__cjs_getBuiltinModule"),{readFileSync:q}=D("node:fs");var K=Object.defineProperty,C=k((e,o)=>K(e,"name",{value:o,configurable:!0}),"i");const z=C((e,o)=>{const t=o.replace(/^\.?\//,"");return t===""||t==="."?`/${e}/`:e===""||e==="."?`/${t}`:`/${e}/${t}`},"toWorkspacePath"),G=C((e,o)=>{const t=[];for(const[r,n]of Object.entries(o?.globalPaths??{}))t.push({owners:n,path:r});for(const[r,n]of Object.entries(e.projects)){const i=n.owners??[];for(const a of i)t.push({channel:a.channel,owners:a.owners,path:z(n.root??r,a.path),projectId:r})}return(o?.orderBy??"file-source")==="project-id"?t.sort((r,n)=>(r.projectId??"").localeCompare(n.projectId??"")||r.path.localeCompare(n.path)):t.sort((r,n)=>r.path.localeCompare(n.path)),t},"buildCodeownersLines"),V=["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.","# Update each project's project.json `owners` field and re-run the command.",""],Y=C((e,o="github")=>{const t=[...V];for(const r of e){const n=r.owners.join(" "),i=r.channel?` # notify: ${r.channel}`:"";t.push(`${r.path} ${n}${i}`)}return t.push(""),t.join(`
2
+ `)},"renderCodeowners");var H=Object.defineProperty,u=k((e,o)=>H(e,"name",{value:o,configurable:!0}),"s");const Q=["author","bugs","homepage","license","repository","engines"],E=u(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),b=u((e,o)=>{if(e===o)return!0;if(typeof e!=typeof o||e===null||o===null)return!1;if(Array.isArray(e)){if(!Array.isArray(o)||e.length!==o.length)return!1;for(const[t,r]of e.entries())if(!b(r,o[t]))return!1;return!0}if(typeof e=="object"&&typeof o=="object"){const t=Object.keys(e),r=Object.keys(o);if(t.length!==r.length)return!1;for(const n of t)if(!b(e[n],o[n]))return!1;return!0}return!1},"deepEqual"),N=u(e=>e===void 0?e:structuredClone(e),"cloneJson"),X=u((e,o,t)=>{if(e==="repository"&&E(o)&&E(t)){const r={};for(const[n,i]of Object.entries(o))n!=="directory"&&(r[n]=N(i));return typeof t.directory=="string"&&(r.directory=t.directory),r}return N(o)},"buildTargetValue"),Z=u((e,o,t)=>{const r=[];for(const n of t.fields){if(!Object.hasOwn(e,n))continue;const i=e[n],a=o[n],c=X(n,i,a);b(c,a)||r.push({after:c,before:a,field:n,packageJsonPath:""})}return r},"computeFieldChanges"),ee=u((e,o)=>{for(const t of o)e[t.field]=t.after},"applyFieldChanges");var oe=Object.defineProperty,m=k((e,o)=>oe(e,"name",{value:o,configurable:!0}),"p");const _=["codeowners","package-json-fields"],te=m(e=>{const o=new Set,t=[];for(const r of e??[])for(const n of r.split(",")){const i=n.trim();i.length===0||o.has(i)||(o.add(i),t.push(i))}return t.length>0?t:[...Q]},"parseFieldsOption"),re=m((e,o)=>o.some(t=>M(t,e)),"matchesAnyGlob"),ne=m(({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const{workspace:n}=U(r,t),i=G(n,t?.codeowners);if(i.length===0){e.info("No `owners` entries found in any project. Nothing to sync.");return}const a=Y(i,t?.codeowners?.provider??"github"),c=o.out?w(r,o.out):w(r,"CODEOWNERS");if(o.check){let g="";try{g=q(c,"utf8")}catch(d){if(d.code!=="ENOENT")throw d}if(g.trim()!==a.trim()){e.error(`${c} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${c} is up to date.`);return}T(c,a),e.info(`Wrote ${i.length} entries to ${c}`)},"runCodeowners"),se=m(({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=r,i=t?.editorconfig??!0,a=O(w(n,"package.json"));if(!a){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const c=te(o.fields),g=o.ignorePackageName??[],d=o.check===!0,F=(o.format??"human").toLowerCase(),v=o.quiet===!0,S=W(n).filter(s=>s!=="."),p=[];let j=0;for(const s of S){const l=w(n,s,"package.json"),h=O(l);if(!h)continue;const $=typeof h.name=="string"?h.name:void 0;if($!==void 0&&g.length>0&&re($,g))continue;j+=1;const P=Z(a,h,{fields:c});P.length!==0&&p.push({filePath:l,packageJsonPath:L(n,l),packageName:$,pkg:h,pkgChanges:P})}if(!d)for(const s of p)ee(s.pkg,s.pkgChanges),I(s.filePath,s.pkg,{indent:B(s.filePath,{useEditorconfig:i}),overwrite:!0});const f=p.flatMap(s=>s.pkgChanges.map(l=>({after:l.after,before:l.before,field:l.field,packageJsonPath:s.packageJsonPath,packageName:s.packageName}))),J={changes:f,fields:c,kind:"package-json-fields",mode:d?"check":"write",totalChanges:f.length,totalPackages:j};if(F==="json")process.stdout.write(`${JSON.stringify(J,null,4)}
3
+ `);else if(f.length===0)e.info(`All ${j} package${j===1?"":"s"} in sync (fields: ${c.join(", ")}).`);else if(d){if(!v)for(const s of f)e.error(`${s.packageJsonPath}: ${s.field} drifts from root`);e.error(`Found ${f.length} field drift${f.length===1?"":"s"} across ${p.length} package${p.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!v)for(const s of p)e.info(`${s.packageJsonPath}: synced ${s.pkgChanges.map(l=>l.field).join(", ")}`);e.info(`Synced ${f.length} field${f.length===1?"":"s"} across ${p.length} package${p.length===1?"":"s"}.`)}d&&f.length>0&&(process.exitCode=1)},"runPackageJsonFields"),de=m(async e=>{const o=e.argument[0];if(!o)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${_.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(o==="codeowners"){ne(e);return}if(o==="package-json-fields"){se(e);return}throw new Error(`Unknown sync kind: "${o}". Known kinds: ${_.join(", ")}.`)},"execute");export{de as default};