@r_masseater/vite-plus-adopt 0.11.0 → 0.12.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.
@@ -1,7 +1,5 @@
1
- import { a as ACTIONLINT, c as readTarGz, f as checksFailed, l as runCaptured, m as toolFailed, n as writeTo, o as BETTERLEAKS, p as configMissing, r as runVendored, s as ZIZMOR, t as finish, u as attempt } from "./output-CeQIa6e5.mjs";
2
1
  import { n as toJson } from "./json-QtVKpodH.mjs";
3
- import { n as processConfiguration, t as linter } from "./steiger-CbusAzht.mjs";
4
- import { Array, Config, Context, Effect, Exit, FileSystem, Function, Layer, Option, Order, Path, Predicate, Record, Redacted, Schema, String, pipe } from "effect";
2
+ import { Array, Boolean as Boolean$1, Config, Context, Effect, Exit, FileSystem, Function, Layer, Option, Order, Path, Predicate, Record, Redacted, Schedule, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
5
3
  import { resolveConfigFromFile } from "vite-plus";
6
4
  import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
7
5
  import format from "@commitlint/format";
@@ -11,14 +9,42 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
11
9
  import { loadPackagesFromRawConfig } from "@textlint/config-loader";
12
10
  import { TextlintKernelDescriptor } from "@textlint/kernel";
13
11
  import { createLinter, loadLinterFormatter } from "textlint";
14
- import { builtInPlugins } from "textlint/lib/src/loader/TextlintrcLoader.js";
12
+ import { loadBuiltinPlugins } from "textlint/lib/src/loader/TextlintrcLoader.js";
15
13
  import { normalizeTextlintPresetSubRuleKey } from "@textlint/utils";
16
14
  import { parse } from "yaml";
17
- import { stringify } from "smol-toml";
18
- import { minimatch } from "minimatch";
15
+ import { Tar } from "effect/encoding";
16
+ import { format as format$1, makeDetector } from "@r_masseater/h56m";
19
17
  import { findWorkspaceProjectsNoCheck } from "@pnpm/workspace.projects-reader";
20
18
  import { readWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-reader";
19
+ import { minimatch } from "minimatch";
21
20
  import { intersects, valid, validRange } from "semver";
21
+ // src/shared/lib/errors.ts
22
+ const taggedError = Schema.TaggedError;
23
+ var VpToolsError = class extends taggedError()("VpToolsError", {
24
+ kind: Schema.Literals([
25
+ "config-missing",
26
+ "tool-failed",
27
+ "checks-failed"
28
+ ]),
29
+ message: Schema.String
30
+ }) {};
31
+ const configMissing = (message) => VpToolsError.make({
32
+ kind: "config-missing",
33
+ message
34
+ });
35
+ const checksFailed = (message) => VpToolsError.make({
36
+ kind: "checks-failed",
37
+ message
38
+ });
39
+ const toolFailed = (tool) => (cause) => VpToolsError.make({
40
+ kind: "tool-failed",
41
+ message: `${tool} failed: ${String(cause)}`
42
+ });
43
+ // src/shared/lib/attempt.ts
44
+ const attempt = (tool) => (run) => Effect.tryPromise({
45
+ try: run,
46
+ catch: toolFailed(tool)
47
+ });
22
48
  // src/entities/vite-config/model/config.ts
23
49
  const CONFIG_FILES = [
24
50
  "vite.config.ts",
@@ -38,7 +64,7 @@ const requireSection = (key) => (config) => Effect.fromOption(Option.fromNullish
38
64
  /** @internal */
39
65
  const loadSection = Function.dual(2, (root, key) => loadViteConfig(root).pipe(Effect.flatMap(requireSection(key))));
40
66
  // src/features/check-text/model/commitlint.ts
41
- const DATA_FIRST_ARITY_3$2 = 3;
67
+ const DATA_FIRST_ARITY_3$1 = 3;
42
68
  const COMMENT_CHAR = "#";
43
69
  const parserOptionsOf = (loaded) => {
44
70
  return {
@@ -53,7 +79,7 @@ const lintOptionsOf = (loaded) => ({
53
79
  defaultIgnores: loaded.defaultIgnores ?? true
54
80
  });
55
81
  /** @internal */
56
- const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$2, (config, root, messages) => Effect.gen(function* lintMessages() {
82
+ const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$1, (config, root, messages) => Effect.gen(function* lintMessages() {
57
83
  const loaded = yield* attempt("commitlint")(() => load(config, { cwd: root }));
58
84
  const results = yield* Effect.forEach(messages, (message) => attempt("commitlint")(() => lint(message, loaded.rules, lintOptionsOf(loaded))), { concurrency: 1 });
59
85
  return {
@@ -61,7 +87,7 @@ const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$2, (config, root, me
61
87
  output: format({ results }, { color: false })
62
88
  };
63
89
  }));
64
- Function.dual(DATA_FIRST_ARITY_3$2, (config, root, messageFile) => Effect.gen(function* read() {
90
+ Function.dual(DATA_FIRST_ARITY_3$1, (config, root, messageFile) => Effect.gen(function* read() {
65
91
  const message = yield* (yield* FileSystem.FileSystem).readFileString(messageFile);
66
92
  return yield* lintCommitMessages(config, root, [message]);
67
93
  }));
@@ -71,9 +97,9 @@ const withSection = Function.dual(2, (key, run) => (context) => pipe(Option.from
71
97
  onSome: (section) => Effect.asSome(run(section, context))
72
98
  })));
73
99
  // src/shared/lib/git.ts
74
- const DATA_FIRST_ARITY$3 = 2;
100
+ const DATA_FIRST_ARITY$4 = 2;
75
101
  /** @internal */
76
- const listGitFiles = Function.dual(DATA_FIRST_ARITY$3, (root, pathspecs) => Effect.gen(function* list() {
102
+ const listGitFiles = Function.dual(DATA_FIRST_ARITY$4, (root, pathspecs) => Effect.gen(function* list() {
77
103
  const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
78
104
  "-c",
79
105
  "core.quotePath=false",
@@ -84,10 +110,10 @@ const listGitFiles = Function.dual(DATA_FIRST_ARITY$3, (root, pathspecs) => Effe
84
110
  "--",
85
111
  ...pathspecs
86
112
  ], { cwd: root }));
87
- return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
113
+ return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
88
114
  }));
89
115
  /** @internal */
90
- const listCommitMessages = Function.dual(DATA_FIRST_ARITY$3, (root, range) => Effect.gen(function* messages() {
116
+ const listCommitMessages = Function.dual(DATA_FIRST_ARITY$4, (root, range) => Effect.gen(function* messages() {
91
117
  const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
92
118
  "log",
93
119
  "-z",
@@ -96,7 +122,7 @@ const listCommitMessages = Function.dual(DATA_FIRST_ARITY$3, (root, range) => Ef
96
122
  range,
97
123
  "--"
98
124
  ], { cwd: root }));
99
- return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
125
+ return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
100
126
  }));
101
127
  // src/features/check-text/model/textlint-presets.ts
102
128
  const NO_OPTIONS = {};
@@ -125,18 +151,19 @@ const rawConfigOf = (config) => {
125
151
  };
126
152
  };
127
153
  // src/features/check-text/model/textlint.ts
128
- const DATA_FIRST_ARITY_3$1 = 3;
154
+ const DATA_FIRST_ARITY_3 = 3;
129
155
  const descriptorOf = (loaded, root, config) => {
130
156
  if (!loaded.ok) return Effect.fail(toolFailed("textlint")(loaded.error.message));
131
- return Effect.succeed(new TextlintKernelDescriptor({
132
- rules: [...loaded.config.rules, ...presetRulesOf(config)],
133
- filterRules: loaded.config.filterRules,
134
- plugins: [...builtInPlugins, ...loaded.config.plugins],
157
+ const { rules, filterRules, plugins } = loaded.config;
158
+ return Effect.map(attempt("textlint")(loadBuiltinPlugins), (builtIn) => new TextlintKernelDescriptor({
159
+ rules: [...rules, ...presetRulesOf(config)],
160
+ filterRules,
161
+ plugins: [...builtIn.plugin.toKernelPluginsFormat(), ...plugins],
135
162
  configBaseDir: root
136
163
  }));
137
164
  };
138
165
  /** @internal */
139
- const lintTexts = Function.dual(DATA_FIRST_ARITY_3$1, (config, root, files) => Effect.gen(function* lint() {
166
+ const lintTexts = Function.dual(DATA_FIRST_ARITY_3, (config, root, files) => Effect.gen(function* lint() {
140
167
  const path = yield* Path.Path;
141
168
  yield* attempt("textlint")(() => import("vite-plus/register"));
142
169
  const loaded = yield* attempt("textlint")(() => loadPackagesFromRawConfig({
@@ -162,7 +189,7 @@ const markdownFiles = (root, ignores = []) => listGitFiles(root, [MARKDOWN, ...p
162
189
  const sourceFiles = (root, files) => listGitFiles(root, pipe(files, Array.map((glob) => `${GLOB_PATHSPEC}${glob}`)));
163
190
  const mergeReports = (reports) => ({
164
191
  valid: pipe(reports, Array.every((report) => report.valid)),
165
- output: pipe(reports, Array.map((report) => report.output), Array.filter(String.isNonEmpty), Array.join("\n"))
192
+ output: pipe(reports, Array.map((report) => report.output), Array.filter(String$1.isNonEmpty), Array.join("\n"))
166
193
  });
167
194
  /** @internal */
168
195
  const textlintCheck = withSection("textlint", (config, { root }) => {
@@ -211,6 +238,26 @@ const skillCacheDirectory = Effect.gen(function* skillCache() {
211
238
  const base = yield* baseDirectory;
212
239
  return path.join(base, ...SUBDIRECTORY);
213
240
  });
241
+ // src/shared/lib/process.ts
242
+ const SUCCESS$1 = 0;
243
+ const stdinOf = (input) => pipe(Option.fromNullishOr(input), Option.match({
244
+ onNone: () => "ignore",
245
+ onSome: (text) => Stream.make(new TextEncoder().encode(text))
246
+ }));
247
+ /** @internal */
248
+ const runCaptured = ({ root, file, args, env = {}, input, output = "all" }) => Effect.gen(function* run() {
249
+ const handle = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).spawn(ChildProcess.make(file, args, {
250
+ cwd: root,
251
+ env,
252
+ extendEnv: true,
253
+ stdin: stdinOf(input)
254
+ }));
255
+ const [text, exitCode] = yield* Effect.all([handle[output].pipe(Stream.decodeText, Stream.mkString), handle.exitCode], { concurrency: "unbounded" });
256
+ return {
257
+ valid: exitCode === SUCCESS$1,
258
+ output: text
259
+ };
260
+ }).pipe(Effect.scoped);
214
261
  // src/features/install-skills/model/link.ts
215
262
  const KEEP = ".gitkeep";
216
263
  const junction = (target, link) => runCaptured({
@@ -280,6 +327,17 @@ const linkSkills = (root) => (links) => Effect.gen(function* link() {
280
327
  const next = yield* buildNext(agents, skills, links);
281
328
  yield* swapIn(agents, skills, next);
282
329
  });
330
+ // src/shared/lib/tar-gz.ts
331
+ const gunzipped = (data) => {
332
+ const compressed = new Blob([new Uint8Array(data)]).stream();
333
+ return attempt("gunzip")(() => new Response(compressed.pipeThrough(new DecompressionStream("gzip"))).arrayBuffer());
334
+ };
335
+ const untarred = (archive) => Stream.make(new Uint8Array(archive)).pipe(Stream.pipeThroughChannel(Tar.decode()), Stream.mapEffect(({ header, body }) => Effect.map(Stream.mkUint8Array(body), (bytes) => ({
336
+ header,
337
+ bytes
338
+ }))), Stream.runCollect, Effect.mapError(toolFailed("untar")));
339
+ /** @internal */
340
+ const readTarGz = (data) => Effect.flatMap(gunzipped(data), untarred);
283
341
  const SKILL_FILE$1 = "SKILL.md";
284
342
  const FRONTMATTER = /^---\r?\n(?<yaml>[\s\S]*?)\r?\n---/u;
285
343
  const NEXT = 1;
@@ -290,9 +348,9 @@ const Frontmatter = Schema.Struct({ name: Schema.String });
290
348
  const decodeFrontmatter = Schema.decodeUnknownOption(Frontmatter);
291
349
  const parseYaml = Option.liftThrowable((yaml) => parse(yaml));
292
350
  const nameOf = (markdown) => pipe(Option.fromNullishOr(FRONTMATTER.exec(markdown)), Option.flatMap((found) => Option.fromNullishOr(found.groups)), Option.flatMap((groups) => Record.get(groups, "yaml")), Option.flatMap(parseYaml), Option.flatMap(decodeFrontmatter), Option.map(({ name }) => name));
293
- const afterFirstSegment = (path) => pipe(path, String.indexOf("/"), Option.match({
351
+ const afterFirstSegment = (path) => pipe(path, String$1.indexOf("/"), Option.match({
294
352
  onNone: () => path,
295
- onSome: (at) => String.slice(at + NEXT)(path)
353
+ onSome: (at) => String$1.slice(at + NEXT)(path)
296
354
  }));
297
355
  const withoutTopDirectory = ({ header, bytes }) => ({
298
356
  header: {
@@ -302,17 +360,17 @@ const withoutTopDirectory = ({ header, bytes }) => ({
302
360
  bytes
303
361
  });
304
362
  /** @internal */
305
- const isUnder = (directory) => (path) => directory === "" || String.startsWith(`${directory}/`)(path);
363
+ const isUnder = (directory) => (path) => directory === "" || String$1.startsWith(`${directory}/`)(path);
306
364
  /** @internal */
307
365
  const relativeTo = (directory) => (path) => {
308
366
  if (directory === "") return path;
309
- return String.slice(directory.length + NEXT)(path);
367
+ return String$1.slice(directory.length + NEXT)(path);
310
368
  };
311
- const parentOf = (path) => pipe(path, String.lastIndexOf("/"), Option.match({
369
+ const parentOf = (path) => pipe(path, String$1.lastIndexOf("/"), Option.match({
312
370
  onNone: () => "",
313
- onSome: (at) => String.slice(START, at)(path)
371
+ onSome: (at) => String$1.slice(START, at)(path)
314
372
  }));
315
- const isSkillFile = (root) => (entry) => entry.header.type === "File" && (entry.header.path === SKILL_FILE$1 || String.endsWith(`/${SKILL_FILE$1}`)(entry.header.path)) && isUnder(root)(entry.header.path);
373
+ const isSkillFile = (root) => (entry) => entry.header.type === "File" && (entry.header.path === SKILL_FILE$1 || String$1.endsWith(`/${SKILL_FILE$1}`)(entry.header.path)) && isUnder(root)(entry.header.path);
316
374
  const isOutermost = (candidates) => ({ directory }) => !pipe(candidates, Array.some((other) => other.directory !== directory && isUnder(other.directory)(directory)));
317
375
  const toFound = ({ directory, name }) => pipe(name, Option.map((found) => ({
318
376
  name: found,
@@ -333,12 +391,16 @@ const skillsIn = ({ repository, source }) => (entries) => {
333
391
  return Effect.succeed(found);
334
392
  };
335
393
  /** @internal */
336
- const labelOf = ({ repository, source }) => `${repository}@${String.slice(START, SHORT_COMMIT)(source.commit)}`;
394
+ const labelOf = ({ repository, source }) => `${repository}@${String$1.slice(START, SHORT_COMMIT)(source.commit)}`;
395
+ const RETRY_DELAY = "1 second";
396
+ const RETRIES = 4;
337
397
  const codeload = ({ repository, source }) => HttpClientRequest.get(`https://codeload.github.com/${repository}/tar.gz/${source.commit}`);
338
398
  const api = ({ repository, source }) => (token) => HttpClientRequest.get(`https://api.github.com/repos/${repository}/tarball/${source.commit}`).pipe(HttpClientRequest.bearerToken(Redacted.value(token)));
339
399
  const fetchBytes = (request) => Effect.gen(function* fetchArchive() {
340
- const httpClient = yield* HttpClient.HttpClient;
341
- const body = yield* (yield* HttpClient.filterStatusOk(httpClient).execute(request)).arrayBuffer;
400
+ const body = yield* (yield* (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk, HttpClient.retryTransient({
401
+ schedule: Schedule.exponential(RETRY_DELAY),
402
+ times: RETRIES
403
+ })).execute(request)).arrayBuffer;
342
404
  return new Uint8Array(body);
343
405
  });
344
406
  const githubToken = Config.option(Config.Redacted("GITHUB_TOKEN")).pipe(Effect.orElseSucceed(Option.none));
@@ -368,9 +430,9 @@ const hasSkillFile = (base) => (name) => Effect.gen(function* checkSkillFile() {
368
430
  /** @internal */
369
431
  const resolveLocal = (root) => ({ directory, skills }) => Effect.gen(function* resolveLocalSource() {
370
432
  const fs = yield* FileSystem.FileSystem;
371
- const base = (yield* Path.Path).join(root, ...String.split("/")(directory));
433
+ const base = (yield* Path.Path).join(root, ...String$1.split("/")(directory));
372
434
  const entries = yield* fs.readDirectory(base).pipe(Effect.mapError(() => checksFailed(`${directory} is not a folder`)));
373
- const available = yield* pipe(Array.sort(entries, String.Order), Effect.filter(hasSkillFile(base)));
435
+ const available = yield* pipe(Array.sort(entries, String$1.Order), Effect.filter(hasSkillFile(base)));
374
436
  return {
375
437
  repository: directory,
376
438
  names: yield* selectSkills({
@@ -413,7 +475,7 @@ const writeEntry = (staging, skill) => ({ header, bytes }) => Effect.gen(functio
413
475
  const fs = yield* FileSystem.FileSystem;
414
476
  const path = yield* Path.Path;
415
477
  const relative = relativeTo(skill.directory)(header.path);
416
- const file = path.join(staging, ...String.split("/")(relative));
478
+ const file = path.join(staging, ...String$1.split("/")(relative));
417
479
  yield* fs.makeDirectory(path.dirname(file), { recursive: true });
418
480
  yield* fs.writeFile(file, bytes);
419
481
  yield* fs.chmod(file, modeOf(header.mode));
@@ -485,7 +547,7 @@ const fetchNames = (declared, directory) => Effect.gen(function* fromArchive() {
485
547
  });
486
548
  /** @internal */
487
549
  const resolveSource = (cache) => (declared) => Effect.gen(function* resolve() {
488
- const directory = (yield* Path.Path).join(cache, ...String.split("/")(declared.repository), declared.source.commit);
550
+ const directory = (yield* Path.Path).join(cache, ...String$1.split("/")(declared.repository), declared.source.commit);
489
551
  const cached = yield* cachedNames(declared, directory);
490
552
  const names = yield* Option.match(cached, {
491
553
  onNone: () => fetchNames(declared, directory),
@@ -519,7 +581,7 @@ const linksOf = (resolved) => Effect.gen(function* collectLinks() {
519
581
  })));
520
582
  });
521
583
  const resolveEntry = (root, cache) => ([key, source]) => {
522
- const local = String.startsWith(LOCAL_PREFIX)(key);
584
+ const local = String$1.startsWith(LOCAL_PREFIX)(key);
523
585
  if (isRemote(source)) {
524
586
  if (local) return Effect.fail(checksFailed(`vite.config "skills": ${key} is a folder in this repository and takes no commit`));
525
587
  return resolveSource(cache)({
@@ -545,37 +607,11 @@ const installSkills = (root) => Effect.gen(function* install() {
545
607
  yield* linkSkills(root)(links);
546
608
  return Option.some(links.length);
547
609
  });
548
- // src/features/scan-secrets/model/betterleaks.ts
549
- const toBetterleaksToml = (config) => {
550
- const { ignoredSecrets: _ignoredSecrets, ...rest } = config;
551
- return stringify(rest);
552
- };
553
- const toIgnoreFile = (config) => pipe(config.ignoredSecrets ?? [], Array.map((digest) => `${digest}\n`), Array.join(""));
554
610
  // src/features/scan-secrets/model/secret-checks.ts
555
- const DATA_FIRST_ARITY$2 = 2;
556
- const ignoreFileArgs = (config) => Effect.gen(function* ignoreFile() {
557
- const digests = toIgnoreFile(config);
558
- if (digests === "") return [];
559
- const fs = yield* FileSystem.FileSystem;
560
- const file = yield* fs.makeTempFileScoped({ prefix: "betterleaksignore-" });
561
- yield* fs.writeFileString(file, digests);
562
- return ["--ignore-file", file];
563
- });
564
- const scanSecrets = ({ config, root, args, input }) => Effect.gen(function* scan() {
565
- const ignore = yield* ignoreFileArgs(config);
566
- return yield* runVendored(BETTERLEAKS, {
567
- root,
568
- args: [
569
- ...args,
570
- "--redact",
571
- "--no-banner",
572
- ...ignore
573
- ],
574
- env: { BETTERLEAKS_CONFIG_TOML: toBetterleaksToml(config) },
575
- input
576
- });
577
- }).pipe(Effect.scoped);
611
+ const DATA_FIRST_ARITY$3 = 2;
578
612
  const SUCCESS = 0;
613
+ const RANGE = "..";
614
+ const HEAD = "HEAD";
579
615
  const lacksHistory = (root) => Effect.gen(function* history() {
580
616
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
581
617
  const shallow = yield* spawner.string(ChildProcess.make("git", ["rev-parse", "--is-shallow-repository"], { cwd: root }));
@@ -584,69 +620,57 @@ const lacksHistory = (root) => Effect.gen(function* history() {
584
620
  "--get",
585
621
  "remote.origin.promisor"
586
622
  ], { cwd: root }));
587
- return String.trim(shallow) === "true" || promisor === SUCCESS;
588
- });
589
- const succeeded = (tool, run) => run.pipe(Effect.flatMap((code) => {
590
- if (code === SUCCESS) return Effect.void;
591
- return Effect.fail(toolFailed(tool)(`exit code ${code}`));
623
+ return String$1.trim(shallow) === "true" || promisor === SUCCESS;
624
+ });
625
+ const historyOf = (range) => pipe(String$1.split(range, RANGE), Array.match({
626
+ onEmpty: () => ({
627
+ type: "history",
628
+ head: HEAD
629
+ }),
630
+ onNonEmpty: ([base, ...rest]) => Array.match(rest, {
631
+ onEmpty: () => ({
632
+ type: "history",
633
+ head: range
634
+ }),
635
+ onNonEmpty: ([head]) => ({
636
+ type: "history",
637
+ bases: [base],
638
+ head
639
+ })
640
+ })
592
641
  }));
593
- const scanCommittedTree = (config, root) => Effect.gen(function* tree() {
594
- const fs = yield* FileSystem.FileSystem;
595
- const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
596
- const directory = yield* fs.makeTempDirectoryScoped({ prefix: "vpa-betterleaks-" });
597
- const archive = `${directory}.tar`;
598
- yield* succeeded("git archive", spawner.exitCode(ChildProcess.make("git", [
599
- "archive",
600
- "--format=tar",
601
- "-o",
602
- archive,
603
- "HEAD"
604
- ], { cwd: root })));
605
- yield* succeeded("tar", spawner.exitCode(ChildProcess.make("tar", [
606
- "-xf",
607
- archive,
608
- "-C",
609
- directory
610
- ])));
611
- yield* fs.remove(archive);
612
- return yield* scanSecrets({
613
- config,
642
+ const sourceOf = (partial, range) => Boolean$1.match(partial, {
643
+ onTrue: () => ({
644
+ type: "snapshot",
645
+ revision: HEAD
646
+ }),
647
+ onFalse: () => historyOf(range)
648
+ });
649
+ const scan = (config, root, source) => Effect.gen(function* scanSource() {
650
+ const found = yield* (yield* makeDetector(config)).scanGit({
614
651
  root,
615
- args: [directory]
652
+ source
616
653
  });
617
- }).pipe(Effect.scoped);
654
+ return {
655
+ valid: Array.isReadonlyArrayEmpty(found),
656
+ output: pipe(found, Array.map(format$1), Array.join("\n"))
657
+ };
658
+ }).pipe(Effect.mapError(toolFailed("h56m")));
618
659
  /** @internal */
619
- const betterleaksCheck = withSection("betterleaks", (config, { root, range }) => lacksHistory(root).pipe(Effect.flatMap((partial) => {
620
- if (partial) return scanCommittedTree(config, root);
621
- return scanSecrets({
622
- config,
623
- root,
624
- args: [
625
- "git",
626
- ".",
627
- `--revision=${range}`
628
- ]
629
- });
630
- })));
631
- const STAGED_DIFF = [
632
- "diff",
633
- "--cached",
634
- "--no-ext-diff",
635
- "--no-textconv",
636
- "--no-color",
637
- "--src-prefix=a/",
638
- "--dst-prefix=b/"
639
- ];
660
+ const h56mCheck = withSection("h56m", (config, { root, range }) => lacksHistory(root).pipe(Effect.flatMap((partial) => scan(config, root, sourceOf(partial, range)))));
640
661
  /** @internal */
641
- const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$2, (config, root) => Effect.gen(function* staged() {
642
- const diff = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", STAGED_DIFF, { cwd: root }));
643
- return yield* scanSecrets({
644
- config,
645
- root,
646
- args: ["stdin", "--git-diff"],
647
- input: diff
648
- });
662
+ const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$3, (config, root) => scan(config, root, { type: "staged" }));
663
+ /** @internal */
664
+ const writeTo = Function.dual(2, (sink, text) => Effect.gen(function* write() {
665
+ const stdio = yield* Stdio.Stdio;
666
+ yield* Stream.make(text).pipe(Stream.run(stdio[sink]()), Effect.orDie);
649
667
  }));
668
+ /** @internal */
669
+ const finish = (report) => {
670
+ if (!report.valid) return Effect.fail(checksFailed(report.output));
671
+ if (report.output === "") return Effect.void;
672
+ return writeTo("stdout", `${report.output}\n`);
673
+ };
650
674
  // src/shared/lib/workspace.ts
651
675
  const DEPENDENCY_FIELDS = [
652
676
  "dependencies",
@@ -656,8 +680,8 @@ const DEPENDENCY_FIELDS = [
656
680
  ];
657
681
  const MANIFEST_FILE = "package.json";
658
682
  const pnpm = attempt("pnpm");
659
- const byFile = Order.mapInput(String.Order, ({ file }) => file);
660
- const manifestIn = (directory) => pipe(Option.liftPredicate(directory, String.isNonEmpty), Option.map((own) => `${own}/${MANIFEST_FILE}`), Option.getOrElse(() => MANIFEST_FILE));
683
+ const byFile = Order.mapInput(String$1.Order, ({ file }) => file);
684
+ const manifestIn = (directory) => pipe(Option.liftPredicate(directory, String$1.isNonEmpty), Option.map((own) => `${own}/${MANIFEST_FILE}`), Option.getOrElse(() => MANIFEST_FILE));
661
685
  const dependenciesIn = (file, declared) => pipe(DEPENDENCY_FIELDS, Array.flatMap((field) => {
662
686
  const entries = Record.toEntries(Option.getOrElse(Option.fromUndefinedOr(declared[field]), () => ({})));
663
687
  return pipe(entries, Array.map(([name, specifier]) => ({
@@ -726,32 +750,14 @@ const versionProblems = (rules, pinned) => {
726
750
  };
727
751
  const comparedDependencies = (rules, dependencies) => {
728
752
  const isExact = inWorkspaces(exactGlobs(rules));
729
- return pipe(dependencies, Array.filter(({ specifier }) => !String.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
753
+ return pipe(dependencies, Array.filter(({ specifier }) => !String$1.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
730
754
  };
731
755
  const checkDependencies = Function.dual(DATA_FIRST_ARITY$1, (rules, dependencies) => [
732
756
  ...bannedProblems(rules, dependencies),
733
757
  ...exactProblems(rules, dependencies),
734
758
  ...versionProblems(rules, comparedDependencies(rules, dependencies))
735
759
  ]);
736
- // src/features/check-repository/model/steiger.ts
737
- const DATA_FIRST_ARITY_3 = 3;
738
- const formatDiagnostic = (relative) => (diagnostic) => `${diagnostic.severity} ${relative(diagnostic.location.path)}: ${diagnostic.message} (${diagnostic.ruleName})`;
739
- const reportOf = (diagnostics, relative) => ({
740
- valid: pipe(diagnostics, Array.every((diagnostic) => diagnostic.severity !== "error")),
741
- output: pipe(diagnostics, Array.map(formatDiagnostic(relative)), Array.join("\n"))
742
- });
743
- /** @internal */
744
- const checkSlices = Function.dual(DATA_FIRST_ARITY_3, (config, root, targets) => Effect.gen(function* check() {
745
- const path = yield* Path.Path;
746
- processConfiguration([...config], root);
747
- const perTarget = yield* Effect.forEach(targets, (target) => attempt("steiger")(() => linter.run(path.resolve(root, target))), { concurrency: 1 });
748
- return reportOf(Array.flatten(perTarget), (file) => path.relative(root, file));
749
- }));
750
760
  // src/features/check-repository/model/repository-checks.ts
751
- const LAYER_FOLDER = /\/(?:app|pages|widgets|features|entities|shared)\//gu;
752
- const layeredDirectories = (root, patterns) => listGitFiles(root, []).pipe(Effect.map((files) => pipe(files, Array.flatMap((file) => Array.map(Array.fromIterable(String.matchAll(LAYER_FOLDER)(file)), ({ index }) => String.takeLeft(file, index ?? file.length))), Array.dedupe, Array.filter((directory) => pipe(patterns, Array.some((pattern) => minimatch(directory, pattern)))))));
753
- /** @internal */
754
- const steigerCheck = withSection("steiger", (section, { root }) => layeredDirectories(root, section.paths).pipe(Effect.flatMap((targets) => checkSlices(section.rules, root, targets))));
755
761
  /** @internal */
756
762
  const dependenciesCheck = withSection("dependencyRules", (rules, { root }) => listDependencies(root).pipe(Effect.map((dependencies) => {
757
763
  const problems = checkDependencies(rules, dependencies);
@@ -760,30 +766,6 @@ const dependenciesCheck = withSection("dependencyRules", (rules, { root }) => li
760
766
  output: Array.join(problems, "\n")
761
767
  };
762
768
  })));
763
- // src/features/check-workflows/model/workflow-checks.ts
764
- const WORKFLOWS = ".github/workflows";
765
- const onWorkflows = (binary, args) => ({ root }) => Effect.gen(function* workflows() {
766
- const fs = yield* FileSystem.FileSystem;
767
- const path = yield* Path.Path;
768
- if (!(yield* fs.exists(path.join(root, WORKFLOWS)))) return Option.none();
769
- const resolvedArgs = yield* args;
770
- const ran = yield* runVendored(binary, {
771
- root,
772
- args: resolvedArgs
773
- });
774
- return Option.some(ran);
775
- });
776
- /** @internal */
777
- const actionlintCheck = onWorkflows(ACTIONLINT, Effect.succeed([]));
778
- const zizmorArgs = Effect.gen(function* zizmorArgs() {
779
- const remote = yield* Config.option(Config.String("CLAUDE_CODE_REMOTE")).pipe(Effect.orDie);
780
- return pipe(remote, Option.match({
781
- onNone: () => [".github"],
782
- onSome: () => ["--no-online-audits", ".github"]
783
- }));
784
- });
785
- /** @internal */
786
- const zizmorCheck = onWorkflows(ZIZMOR, zizmorArgs);
787
769
  // src/features/run-fallow/model/fallow-check.ts
788
770
  const QUIET = [
789
771
  "--fail-on-issues",
@@ -868,29 +850,17 @@ const fallowCheck = withSection("fallow", (config, { root }) => runFallow(config
868
850
  // src/app/checks.ts
869
851
  const CHECKS = [
870
852
  {
871
- name: "betterleaks",
872
- run: betterleaksCheck
853
+ name: "h56m",
854
+ run: h56mCheck
873
855
  },
874
856
  {
875
857
  name: "commitlint",
876
858
  run: commitlintCheck
877
859
  },
878
- {
879
- name: "actionlint",
880
- run: actionlintCheck
881
- },
882
- {
883
- name: "zizmor",
884
- run: zizmorCheck
885
- },
886
860
  {
887
861
  name: "dependencies",
888
862
  run: dependenciesCheck
889
863
  },
890
- {
891
- name: "steiger",
892
- run: steigerCheck
893
- },
894
864
  {
895
865
  name: "textlint",
896
866
  run: textlintCheck
@@ -958,7 +928,7 @@ const USAGE = pipe([
958
928
  " vpa --message <text> lint a message"
959
929
  ], Array.join("\n"));
960
930
  const usage = Effect.fail(checksFailed(USAGE));
961
- const stagedSecrets = (root) => loadSection(root, "betterleaks").pipe(Effect.flatMap((config) => scanStagedSecrets(config, root)), Effect.flatMap(finish));
931
+ const stagedSecrets = (root) => loadSection(root, "h56m").pipe(Effect.flatMap((config) => scanStagedSecrets(config, root)), Effect.flatMap(finish));
962
932
  const lintMessage = (toMessage) => (root, rest) => pipe(Array.head(rest), Option.match({
963
933
  onNone: () => usage,
964
934
  onSome: (argument) => Effect.gen(function* lintGiven() {
@@ -988,6 +958,6 @@ const runVpa = Function.dual(DATA_FIRST_ARITY, (root, args) => pipe(args, Array.
988
958
  onSome: (hook) => hook(root, rest)
989
959
  }))
990
960
  })));
991
- export { loadViteConfig as n, runVpa as t };
961
+ export { VpToolsError as i, writeTo as n, loadViteConfig as r, runVpa as t };
992
962
 
993
- //# sourceMappingURL=vpa--jth0aBQ.mjs.map
963
+ //# sourceMappingURL=vpa-CvCOW4oL.mjs.map