@r_masseater/vite-plus-adopt 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.mjs ADDED
@@ -0,0 +1,553 @@
1
+ #!/usr/bin/env node
2
+ import { a as ZIZMOR, c as writeTo, i as BETTERLEAKS, n as locateBinary, o as runCli, r as ACTIONLINT, s as finish } from "./install-COdnLosP.mjs";
3
+ import { a as toolFailed, r as checksFailed, t as attempt } from "./attempt-B93fjWiJ.mjs";
4
+ import { n as loadViteConfig, t as loadSection } from "./config-BdAPwzCc.mjs";
5
+ import { n as toJson } from "./json-D-rhjlSM.mjs";
6
+ import { Array, Config, Effect, FileSystem, Function, Option, Path, Predicate, Record, Schema, Stdio, Stream, String, pipe } from "effect";
7
+ import format from "@commitlint/format";
8
+ import lint from "@commitlint/lint";
9
+ import load from "@commitlint/load";
10
+ import { ChildProcess, ChildProcessSpawner } from "effect/process";
11
+ import { minimatch } from "minimatch";
12
+ import { intersects, valid, validRange } from "semver";
13
+ import { linter, processConfiguration } from "steiger";
14
+ import { parse } from "yaml";
15
+ import { stringify } from "smol-toml";
16
+ import { lint as lint$1 } from "markdownlint/promise";
17
+ import { loadPackagesFromRawConfig } from "@textlint/config-loader";
18
+ import { TextlintKernelDescriptor } from "@textlint/kernel";
19
+ import { createLinter, loadLinterFormatter } from "textlint";
20
+ import { builtInPlugins } from "textlint/lib/src/loader/TextlintrcLoader.js";
21
+ // src/commitlint.ts
22
+ const DATA_FIRST_ARITY_3$3 = 3;
23
+ const COMMENT_CHAR = "#";
24
+ const parserOptionsOf = (loaded) => {
25
+ return {
26
+ ...pipe(Option.fromNullishOr(loaded.parserPreset), Option.map(({ parserOpts }) => parserOpts), Option.filter(Predicate.isObject), Option.getOrElse(() => ({}))),
27
+ commentChar: COMMENT_CHAR
28
+ };
29
+ };
30
+ const lintOptionsOf = (loaded) => ({
31
+ parserOpts: parserOptionsOf(loaded),
32
+ plugins: loaded.plugins,
33
+ ignores: loaded.ignores ?? [],
34
+ defaultIgnores: loaded.defaultIgnores ?? true
35
+ });
36
+ const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$3, (config, root, messages) => Effect.gen(function* lintMessages() {
37
+ const loaded = yield* attempt("commitlint")(() => load(config, { cwd: root }));
38
+ const results = yield* pipe(messages, Effect.forEach((message) => attempt("commitlint")(() => lint(message, loaded.rules, lintOptionsOf(loaded)))));
39
+ return {
40
+ valid: pipe(results, Array.every((result) => result.valid)),
41
+ output: format({ results }, { color: false })
42
+ };
43
+ }));
44
+ const lintCommitMessageFile = Function.dual(DATA_FIRST_ARITY_3$3, (config, root, messageFile) => Effect.gen(function* read() {
45
+ const message = yield* (yield* FileSystem.FileSystem).readFileString(messageFile);
46
+ return yield* lintCommitMessages(config, root, [message]);
47
+ }));
48
+ // src/process.ts
49
+ const SUCCESS = 0;
50
+ const stdinOf = (input) => pipe(Option.fromNullishOr(input), Option.match({
51
+ onNone: () => "ignore",
52
+ onSome: (text) => Stream.make(new TextEncoder().encode(text))
53
+ }));
54
+ const runCaptured = ({ root, file, args, env = {}, input, output = "all" }) => Effect.gen(function* run() {
55
+ const handle = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).spawn(ChildProcess.make(file, args, {
56
+ cwd: root,
57
+ env,
58
+ extendEnv: true,
59
+ stdin: stdinOf(input)
60
+ }));
61
+ const [text, exitCode] = yield* Effect.all([handle[output].pipe(Stream.decodeText, Stream.mkString), handle.exitCode], { concurrency: "unbounded" });
62
+ return {
63
+ valid: exitCode === SUCCESS,
64
+ output: text
65
+ };
66
+ }).pipe(Effect.scoped);
67
+ // src/section-check.ts
68
+ const withSection = Function.dual(2, (key, run) => (context) => pipe(Option.fromNullishOr(context.config[key]), Option.match({
69
+ onNone: () => Effect.succeedNone,
70
+ onSome: (section) => Effect.asSome(run(section, context))
71
+ })));
72
+ // src/fallow-check.ts
73
+ const QUIET = [
74
+ "--fail-on-issues",
75
+ "--quiet",
76
+ "--format",
77
+ "compact"
78
+ ];
79
+ const RUNS = [
80
+ [
81
+ "--skip",
82
+ "dupes",
83
+ ...QUIET
84
+ ],
85
+ [
86
+ "dead-code",
87
+ "--no-production",
88
+ ...QUIET
89
+ ],
90
+ ["dupes", ...QUIET],
91
+ [
92
+ "security",
93
+ "--fail-on-issues",
94
+ "--quiet"
95
+ ]
96
+ ];
97
+ const SMELLS = Schema.Array(Schema.Unknown).pipe(Schema.withDecodingDefaultKey(Effect.succeed([])));
98
+ const COMPONENT_SMELLS = Schema.Struct({
99
+ prop_drilling_chains: SMELLS,
100
+ thin_wrappers: SMELLS,
101
+ duplicate_prop_shapes: SMELLS
102
+ });
103
+ const decodeSmells = Schema.decodeUnknownEffect(Schema.fromJsonString(COMPONENT_SMELLS));
104
+ const componentSmells = (root, configFile) => runCaptured({
105
+ root,
106
+ file: "fallow",
107
+ args: [
108
+ "dead-code",
109
+ "--no-production",
110
+ "--quiet",
111
+ "--format",
112
+ "json",
113
+ "-c",
114
+ configFile
115
+ ],
116
+ output: "stdout"
117
+ }).pipe(Effect.flatMap((report) => decodeSmells(report.output)), Effect.map((smells) => {
118
+ const found = [
119
+ ...smells.prop_drilling_chains,
120
+ ...smells.thin_wrappers,
121
+ ...smells.duplicate_prop_shapes
122
+ ];
123
+ return {
124
+ valid: Array.isReadonlyArrayEmpty(found),
125
+ output: toJson(smells)
126
+ };
127
+ }));
128
+ const runFallow = (config, root) => Effect.gen(function* fallow() {
129
+ const fs = yield* FileSystem.FileSystem;
130
+ const path = yield* Path.Path;
131
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "vpa-fallow-" });
132
+ const configFile = path.join(directory, ".fallowrc.json");
133
+ const configText = yield* Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(config).pipe(Effect.orDie);
134
+ yield* fs.writeFileString(configFile, configText);
135
+ const reports = yield* pipe(RUNS, Effect.forEach((args) => runCaptured({
136
+ root,
137
+ file: "fallow",
138
+ args: [
139
+ ...args,
140
+ "-c",
141
+ configFile
142
+ ]
143
+ })));
144
+ const smells = yield* componentSmells(root, configFile);
145
+ const all = [...reports, smells];
146
+ return {
147
+ valid: pipe(all, Array.every((report) => report.valid)),
148
+ output: pipe(all, Array.filter((report) => !report.valid), Array.map((report) => report.output), Array.join("\n"))
149
+ };
150
+ }).pipe(Effect.scoped);
151
+ const fallowCheck = withSection("fallow", (config, { root }) => runFallow(config, root));
152
+ // src/dependency-rules.ts
153
+ const DATA_FIRST_ARITY$3 = 2;
154
+ const SINGLE = 1;
155
+ const bannedBy = (dependencies) => ([reason, globs]) => {
156
+ const isBanned = (name) => pipe(globs, Array.some((glob) => minimatch(name, glob)));
157
+ return pipe(dependencies, Array.filter((dependency) => isBanned(dependency.name)), Array.map((dependency) => `${dependency.manifest} ${dependency.field}.${dependency.name} is banned: ${reason}`));
158
+ };
159
+ const MANIFEST = "package.json";
160
+ const matchesAny = (globs) => (value) => pipe(globs, Array.some((glob) => minimatch(value, glob)));
161
+ const inWorkspace = (globs) => (dependency) => pipe(globs, Array.some((glob) => minimatch(dependency.manifest, `${glob}/${MANIFEST}`)));
162
+ const inFields = (fields) => (dependency) => pipe(Option.fromNullishOr(fields), Option.match({
163
+ onNone: () => true,
164
+ onSome: (names) => Array.contains(names, dependency.field)
165
+ }));
166
+ const allowedBy = (dependency) => ({ workspaces, dependencies, fields }) => inWorkspace(workspaces)(dependency) && matchesAny(dependencies)(dependency.name) && inFields(fields)(dependency);
167
+ const isAllowed = (rules) => (dependency) => pipe(Record.values(rules.allowed ?? {}), Array.some(allowedBy(dependency)));
168
+ const bannedProblems = (rules, dependencies) => {
169
+ const allowed = isAllowed(rules);
170
+ const checked = pipe(dependencies, Array.filter(Predicate.not(allowed)));
171
+ return pipe(Record.toEntries(rules.banned ?? {}), Array.flatMap(bannedBy(checked)));
172
+ };
173
+ const inWorkspaces = (globs) => (dependency) => dependency.field === "dependencies" && inWorkspace(globs)(dependency);
174
+ const exactGlobs = (rules) => pipe(Record.values(rules.exactDependencies ?? {}), Array.flatten);
175
+ const notExactBy = (dependencies) => ([reason, globs]) => pipe(dependencies, Array.filter(inWorkspaces(globs)), Array.filter((dependency) => valid(dependency.specifier) === null), Array.map((dependency) => `${dependency.manifest} dependencies.${dependency.name} must be an exact version: ${reason}`));
176
+ const exactProblems = (rules, dependencies) => pipe(Record.toEntries(rules.exactDependencies ?? {}), Array.flatMap(notExactBy(dependencies)));
177
+ const groupByName = (dependencies) => Record.values(Array.groupBy(dependencies, ({ name }) => name));
178
+ const describe$1 = (dependencies) => {
179
+ return `${pipe(Array.head(dependencies), Option.match({
180
+ onNone: () => "",
181
+ onSome: (dependency) => dependency.name
182
+ }))}: ${pipe(dependencies, Array.map((dependency) => `${dependency.manifest} ${dependency.field} ${dependency.specifier}`), Array.join(", "))}`;
183
+ };
184
+ const mismatchProblems = (dependencies) => pipe(groupByName(dependencies), Array.filter((group) => new Set(pipe(group, Array.map(({ specifier }) => specifier))).size > SINGLE), Array.map((group) => `different specifiers for ${describe$1(group)}`));
185
+ const isDisjoint = (ranges) => pipe(ranges, Array.some((left) => pipe(ranges, Array.some((right) => !intersects(left.specifier, right.specifier)))));
186
+ const disjointRangeProblems = (peers) => pipe(groupByName(peers), Array.map((group) => pipe(group, Array.filter(({ specifier }) => validRange(specifier) !== null))), Array.filter(isDisjoint), Array.map((ranges) => `peer ranges do not intersect for ${describe$1(ranges)}`));
187
+ const isPeer = ({ field }) => field === "peerDependencies";
188
+ const versionProblems = (rules, pinned) => {
189
+ if (rules.peerRanges !== "intersect") return mismatchProblems(pinned);
190
+ const others = pipe(pinned, Array.filter(Predicate.not(isPeer)));
191
+ const peers = pipe(pinned, Array.filter(isPeer));
192
+ return [...mismatchProblems(others), ...disjointRangeProblems(peers)];
193
+ };
194
+ const comparedDependencies = (rules, dependencies) => {
195
+ const isExact = inWorkspaces(exactGlobs(rules));
196
+ return pipe(dependencies, Array.filter(({ specifier }) => !String.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
197
+ };
198
+ const checkDependencies = Function.dual(DATA_FIRST_ARITY$3, (rules, dependencies) => [
199
+ ...bannedProblems(rules, dependencies),
200
+ ...exactProblems(rules, dependencies),
201
+ ...versionProblems(rules, comparedDependencies(rules, dependencies))
202
+ ]);
203
+ // src/git.ts
204
+ const DATA_FIRST_ARITY$2 = 2;
205
+ const listGitFiles = Function.dual(DATA_FIRST_ARITY$2, (root, pathspecs) => Effect.gen(function* list() {
206
+ const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
207
+ "-c",
208
+ "core.quotePath=false",
209
+ "ls-files",
210
+ "-co",
211
+ "--exclude-standard",
212
+ "-z",
213
+ "--",
214
+ ...pathspecs
215
+ ], { cwd: root }));
216
+ return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
217
+ }));
218
+ const listCommitMessages = Function.dual(DATA_FIRST_ARITY$2, (root, range) => Effect.gen(function* messages() {
219
+ const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
220
+ "log",
221
+ "-z",
222
+ "--first-parent",
223
+ "--format=%B",
224
+ range,
225
+ "--"
226
+ ], { cwd: root }));
227
+ return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
228
+ }));
229
+ // src/steiger.ts
230
+ const DATA_FIRST_ARITY_3$2 = 3;
231
+ const formatDiagnostic = (relative) => (diagnostic) => `${diagnostic.severity} ${relative(diagnostic.location.path)}: ${diagnostic.message} (${diagnostic.ruleName})`;
232
+ const reportOf = (diagnostics, relative) => ({
233
+ valid: pipe(diagnostics, Array.every((diagnostic) => diagnostic.severity !== "error")),
234
+ output: pipe(diagnostics, Array.map(formatDiagnostic(relative)), Array.join("\n"))
235
+ });
236
+ const checkSlices = Function.dual(DATA_FIRST_ARITY_3$2, (config, root, targets) => Effect.gen(function* check() {
237
+ const path = yield* Path.Path;
238
+ processConfiguration([...config], root);
239
+ const perTarget = yield* pipe(targets, Effect.forEach((target) => attempt("steiger")(() => linter.run(path.resolve(root, target)))));
240
+ return reportOf(Array.flatten(perTarget), (file) => path.relative(root, file));
241
+ }));
242
+ // src/workspace.ts
243
+ const DEPENDENCY_FIELDS = [
244
+ "dependencies",
245
+ "devDependencies",
246
+ "optionalDependencies",
247
+ "peerDependencies"
248
+ ];
249
+ const Manifest = Schema.Record(Schema.String, Schema.Unknown);
250
+ const decodeSpecifiers = Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.String));
251
+ const Workspace = Schema.Struct({ packages: Schema.optionalKey(Schema.Array(Schema.String)) });
252
+ const decodeManifest = Schema.decodeEffect(Schema.fromJsonString(Manifest));
253
+ const decodeWorkspace = Schema.decodeUnknownEffect(Workspace);
254
+ const NEGATION = "!";
255
+ const manifestPathspec = (pattern) => {
256
+ if (String.startsWith(NEGATION)(pattern)) return `:(glob,exclude)${String.slice(1)(pattern)}/package.json`;
257
+ return `:(glob)${pattern}/package.json`;
258
+ };
259
+ const listManifests = (root) => Effect.gen(function* list() {
260
+ const fs = yield* FileSystem.FileSystem;
261
+ const path = yield* Path.Path;
262
+ const text = yield* fs.readFileString(path.join(root, "pnpm-workspace.yaml"));
263
+ const raw = parse(text);
264
+ const workspace = yield* decodeWorkspace(raw);
265
+ const found = yield* listGitFiles(root, pipe(workspace.packages ?? [], Array.map(manifestPathspec)));
266
+ return ["package.json", ...Array.sort(found, String.Order)];
267
+ });
268
+ const dependenciesOf = (manifest) => (fields) => pipe(DEPENDENCY_FIELDS, Effect.forEach((field) => decodeSpecifiers(fields[field] ?? {}).pipe(Effect.map((specifiers) => pipe(Record.toEntries(specifiers), Array.map(([name, specifier]) => ({
269
+ manifest,
270
+ field,
271
+ name,
272
+ specifier
273
+ })))))), Effect.map(Array.flatten));
274
+ const listDependencies = (root) => Effect.gen(function* list() {
275
+ const fs = yield* FileSystem.FileSystem;
276
+ const path = yield* Path.Path;
277
+ const manifests = yield* listManifests(root);
278
+ const parsed = yield* pipe(manifests, Effect.forEach((manifest) => fs.readFileString(path.join(root, manifest)).pipe(Effect.flatMap(decodeManifest), Effect.flatMap(dependenciesOf(manifest)))));
279
+ return Array.flatten(parsed);
280
+ });
281
+ // src/repository-checks.ts
282
+ const ancestorsOf = (file) => pipe(String.split(file, "/"), Array.initNonEmpty, Array.scan("", (parent, segment) => Array.join(Array.filter([parent, segment], String.isNonEmpty), "/")), Array.filter(String.isNonEmpty));
283
+ const matchingDirectories = (root, patterns) => listGitFiles(root, []).pipe(Effect.map((files) => pipe(files, Array.flatMap(ancestorsOf), Array.dedupe, Array.filter((directory) => pipe(patterns, Array.some((pattern) => minimatch(directory, pattern)))))));
284
+ const steigerCheck = withSection("steiger", (section, { root }) => matchingDirectories(root, section.paths).pipe(Effect.flatMap((targets) => checkSlices(section.rules, root, targets))));
285
+ const dependenciesCheck = withSection("dependencyRules", (rules, { root }) => listDependencies(root).pipe(Effect.map((dependencies) => {
286
+ const problems = checkDependencies(rules, dependencies);
287
+ return {
288
+ valid: Array.isReadonlyArrayEmpty(problems),
289
+ output: Array.join(problems, "\n")
290
+ };
291
+ })));
292
+ // src/betterleaks.ts
293
+ const toBetterleaksToml = (config) => {
294
+ const { ignoredSecrets: _ignoredSecrets, ...rest } = config;
295
+ return stringify(rest);
296
+ };
297
+ const toIgnoreFile = (config) => pipe(config.ignoredSecrets ?? [], Array.map((digest) => `${digest}\n`), Array.join(""));
298
+ // src/vendored.ts
299
+ const runVendored = Function.dual(2, (binary, invocation) => locateBinary(binary).pipe(Effect.flatMap((file) => runCaptured({
300
+ ...invocation,
301
+ file
302
+ }))));
303
+ // src/secret-checks.ts
304
+ const DATA_FIRST_ARITY$1 = 2;
305
+ const ignoreFileArgs = (config) => Effect.gen(function* ignoreFile() {
306
+ const digests = toIgnoreFile(config);
307
+ if (digests === "") return [];
308
+ const fs = yield* FileSystem.FileSystem;
309
+ const file = yield* fs.makeTempFileScoped({ prefix: "betterleaksignore-" });
310
+ yield* fs.writeFileString(file, digests);
311
+ return ["--ignore-file", file];
312
+ });
313
+ const scanSecrets = ({ config, root, args, input }) => Effect.gen(function* scan() {
314
+ const ignore = yield* ignoreFileArgs(config);
315
+ return yield* runVendored(BETTERLEAKS, {
316
+ root,
317
+ args: [
318
+ ...args,
319
+ "--redact",
320
+ "--no-banner",
321
+ ...ignore
322
+ ],
323
+ env: { BETTERLEAKS_CONFIG_TOML: toBetterleaksToml(config) },
324
+ input
325
+ });
326
+ }).pipe(Effect.scoped);
327
+ const betterleaksCheck = withSection("betterleaks", (config, { root, base }) => scanSecrets({
328
+ config,
329
+ root,
330
+ args: [
331
+ "git",
332
+ ".",
333
+ `--revision=${base}..HEAD`
334
+ ]
335
+ }));
336
+ const STAGED_DIFF = [
337
+ "diff",
338
+ "--cached",
339
+ "--no-ext-diff",
340
+ "--no-textconv",
341
+ "--no-color",
342
+ "--src-prefix=a/",
343
+ "--dst-prefix=b/"
344
+ ];
345
+ const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$1, (config, root) => Effect.gen(function* staged() {
346
+ const diff = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", STAGED_DIFF, { cwd: root }));
347
+ return yield* scanSecrets({
348
+ config,
349
+ root,
350
+ args: ["stdin", "--git-diff"],
351
+ input: diff
352
+ });
353
+ }));
354
+ // src/markdownlint.ts
355
+ const DATA_FIRST_ARITY_3$1 = 3;
356
+ const formatError = (file) => (error) => {
357
+ const detail = pipe([error.errorDetail, error.errorContext], Array.filter((part) => part !== null && part !== ""), Array.map((part) => ` [${part}]`), Array.join(""));
358
+ return `${file}:${error.lineNumber} ${Array.join(error.ruleNames, "/")} ${error.ruleDescription}${detail}`;
359
+ };
360
+ const optionsOf = (config, files) => ({
361
+ files: [...files],
362
+ ...pipe(Option.fromNullishOr(config.config), Option.match({
363
+ onNone: () => ({}),
364
+ onSome: (rules) => ({ config: rules })
365
+ })),
366
+ ...pipe(Option.fromNullishOr(config.customRules), Option.match({
367
+ onNone: () => ({}),
368
+ onSome: (rules) => ({ customRules: [...rules] })
369
+ }))
370
+ });
371
+ const lintMarkdown = Function.dual(DATA_FIRST_ARITY_3$1, (config, root, files) => Effect.gen(function* markdown() {
372
+ const path = yield* Path.Path;
373
+ const absolute = pipe(files, Array.map((file) => path.join(root, file)));
374
+ const results = yield* attempt("markdownlint")(() => lint$1(optionsOf(config, absolute)));
375
+ const linesOf = ([file, errors]) => {
376
+ const format = formatError(path.relative(root, file));
377
+ return pipe(errors, Array.map(format));
378
+ };
379
+ const lines = pipe(Record.toEntries(results), Array.flatMap(linesOf));
380
+ return {
381
+ valid: Array.isArrayEmpty(lines),
382
+ output: Array.join(lines, "\n")
383
+ };
384
+ }));
385
+ // src/textlint.ts
386
+ const DATA_FIRST_ARITY_3 = 3;
387
+ const descriptorOf = (loaded, root) => {
388
+ if (!loaded.ok) return Effect.fail(toolFailed("textlint")(loaded.error.message));
389
+ return Effect.succeed(new TextlintKernelDescriptor({
390
+ rules: loaded.config.rules,
391
+ filterRules: loaded.config.filterRules,
392
+ plugins: [...builtInPlugins, ...loaded.config.plugins],
393
+ configBaseDir: root
394
+ }));
395
+ };
396
+ const lintTexts = Function.dual(DATA_FIRST_ARITY_3, (config, root, files) => Effect.gen(function* lint() {
397
+ const path = yield* Path.Path;
398
+ const { ignores: _ignores, ...rawConfig } = config;
399
+ const loaded = yield* attempt("textlint")(() => loadPackagesFromRawConfig({
400
+ rawConfig,
401
+ node_moduleDir: path.join(root, "node_modules")
402
+ }));
403
+ const descriptor = yield* descriptorOf(loaded, root);
404
+ const absolute = pipe(files, Array.map((file) => path.join(root, file)));
405
+ const results = yield* attempt("textlint")(() => createLinter({ descriptor }).lintFiles([...absolute]));
406
+ const formatter = yield* attempt("textlint")(() => loadLinterFormatter({
407
+ formatterName: "stylish",
408
+ color: false
409
+ }));
410
+ return {
411
+ valid: pipe(results, Array.every((result) => Array.isArrayEmpty(result.messages))),
412
+ output: formatter.format(results)
413
+ };
414
+ }));
415
+ // src/text-checks.ts
416
+ const MARKDOWN = "*.md";
417
+ const markdownFiles = (root, ignores = []) => listGitFiles(root, [MARKDOWN, ...pipe(ignores, Array.map((glob) => `:(glob,exclude)${glob}`))]);
418
+ const textlintCheck = withSection("textlint", (config, { root }) => markdownFiles(root, config.ignores).pipe(Effect.flatMap((files) => lintTexts(config, root, files))));
419
+ const markdownlintCheck = withSection("markdownlint", (config, { root }) => markdownFiles(root, config.ignores).pipe(Effect.flatMap((files) => lintMarkdown(config, root, files))));
420
+ const commitlintCheck = withSection("commitlint", (config, { root, base }) => listCommitMessages(root, `${base}..HEAD`).pipe(Effect.flatMap((messages) => lintCommitMessages(config, root, messages))));
421
+ // src/workflow-checks.ts
422
+ const WORKFLOWS = ".github/workflows";
423
+ const onWorkflows = (binary, args) => ({ root }) => Effect.gen(function* workflows() {
424
+ const fs = yield* FileSystem.FileSystem;
425
+ const path = yield* Path.Path;
426
+ if (!(yield* fs.exists(path.join(root, WORKFLOWS)))) return Option.none();
427
+ const resolvedArgs = yield* args;
428
+ const ran = yield* runVendored(binary, {
429
+ root,
430
+ args: resolvedArgs
431
+ });
432
+ return Option.some(ran);
433
+ });
434
+ const actionlintCheck = onWorkflows(ACTIONLINT, Effect.succeed([]));
435
+ const zizmorArgs = Effect.gen(function* zizmorArgs() {
436
+ const remote = yield* Config.option(Config.String("CLAUDE_CODE_REMOTE")).pipe(Effect.orDie);
437
+ return pipe(remote, Option.match({
438
+ onNone: () => [".github"],
439
+ onSome: () => ["--no-online-audits", ".github"]
440
+ }));
441
+ });
442
+ const zizmorCheck = onWorkflows(ZIZMOR, zizmorArgs);
443
+ // src/checks.ts
444
+ const CHECKS = [
445
+ {
446
+ name: "betterleaks",
447
+ run: betterleaksCheck
448
+ },
449
+ {
450
+ name: "commitlint",
451
+ run: commitlintCheck
452
+ },
453
+ {
454
+ name: "actionlint",
455
+ run: actionlintCheck
456
+ },
457
+ {
458
+ name: "zizmor",
459
+ run: zizmorCheck
460
+ },
461
+ {
462
+ name: "dependencies",
463
+ run: dependenciesCheck
464
+ },
465
+ {
466
+ name: "steiger",
467
+ run: steigerCheck
468
+ },
469
+ {
470
+ name: "textlint",
471
+ run: textlintCheck
472
+ },
473
+ {
474
+ name: "markdownlint",
475
+ run: markdownlintCheck
476
+ },
477
+ {
478
+ name: "fallow",
479
+ run: fallowCheck
480
+ }
481
+ ];
482
+ // src/run-checks.ts
483
+ const DEFAULT_BASE = "origin/main";
484
+ const RESOLVED = 0;
485
+ const isCommit = (root, revision) => Effect.gen(function* verify() {
486
+ return (yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("git", [
487
+ "rev-parse",
488
+ "-q",
489
+ "--verify",
490
+ `${revision}^{commit}`
491
+ ], { cwd: root }))) === RESOLVED;
492
+ }).pipe(Effect.orElseSucceed(() => false));
493
+ const resolveBase = (root) => Effect.gen(function* base() {
494
+ const configured = yield* Config.option(Config.String("VPA_BASE")).pipe(Effect.orDie);
495
+ if (Option.isSome(configured) && (yield* isCommit(root, configured.value))) return configured.value;
496
+ return DEFAULT_BASE;
497
+ });
498
+ const describe = ({ name, report }) => {
499
+ if (report.valid) return `✓ ${name}`;
500
+ return `✗ ${name}\n${report.output}`;
501
+ };
502
+ const runCheck = (context) => ({ name, run }) => run(context).pipe(Effect.map(Option.map((report) => ({
503
+ name,
504
+ report
505
+ }))));
506
+ const runAllChecks = (root) => Effect.gen(function* all() {
507
+ const config = yield* loadViteConfig(root);
508
+ const base = yield* resolveBase(root);
509
+ const outcomes = yield* pipe(CHECKS, Effect.forEach(runCheck({
510
+ root,
511
+ config,
512
+ base
513
+ }), { concurrency: "unbounded" }), Effect.map(Array.getSomes));
514
+ yield* writeTo("stdout", `${pipe(outcomes, Array.map(describe), Array.join("\n"))}\n`);
515
+ return yield* pipe(outcomes, Array.filter(({ report }) => !report.valid), Array.map(({ name }) => name), Array.match({
516
+ onEmpty: () => Effect.void,
517
+ onNonEmpty: (failed) => Effect.fail(checksFailed(`Failed: ${Array.join(failed, ", ")}`))
518
+ }));
519
+ });
520
+ // src/vpa.ts
521
+ const DATA_FIRST_ARITY = 2;
522
+ const USAGE = pipe([
523
+ "Usage: vpa run every check configured in vite.config.ts",
524
+ " vpa --staged scan the staged changes for secrets (pre-commit)",
525
+ " vpa --commit-msg <file> lint a commit message (commit-msg)"
526
+ ], Array.join("\n"));
527
+ const usage = Effect.fail(checksFailed(USAGE));
528
+ const stagedSecrets = (root) => loadSection(root, "betterleaks").pipe(Effect.flatMap((config) => scanStagedSecrets(config, root)), Effect.flatMap(finish));
529
+ const commitMessage = (root, rest) => pipe(Array.head(rest), Option.match({
530
+ onNone: () => usage,
531
+ onSome: (file) => loadSection(root, "commitlint").pipe(Effect.flatMap((config) => lintCommitMessageFile(config, root, file)), Effect.flatMap(finish))
532
+ }));
533
+ const HOOKS = {
534
+ "--staged": stagedSecrets,
535
+ "--commit-msg": commitMessage
536
+ };
537
+ const runVpa = Function.dual(DATA_FIRST_ARITY, (root, args) => pipe(args, Array.match({
538
+ onEmpty: () => runAllChecks(root),
539
+ onNonEmpty: ([flag, ...rest]) => pipe(Record.get(HOOKS, flag), Option.match({
540
+ onNone: () => usage,
541
+ onSome: (hook) => hook(root, rest)
542
+ }))
543
+ })));
544
+ // src/cli.ts
545
+ runCli(Effect.gen(function* main() {
546
+ const stdio = yield* Stdio.Stdio;
547
+ const path = yield* Path.Path;
548
+ const args = yield* stdio.args;
549
+ return yield* runVpa(path.resolve("."), args);
550
+ }));
551
+ export {};
552
+
553
+ //# sourceMappingURL=cli.mjs.map