@r_masseater/vite-plus-adopt 0.10.2 → 0.11.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/README.md +6 -13
- package/dist/attw.mjs +5 -11
- package/dist/attw.mjs.map +1 -1
- package/dist/cli.mjs +21 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/fsd.d.mts +1 -1
- package/dist/fsd.mjs +3 -5
- package/dist/fsd.mjs.map +1 -1
- package/dist/{index-HO_uRepr.d.mts → index-DyvYt7R0.d.mts} +11 -47
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -3
- package/dist/{vpa-B3VOYbg1.mjs → vpa-MRYbih3E.mjs} +168 -205
- package/dist/vpa-MRYbih3E.mjs.map +1 -0
- package/package.json +45 -44
- package/skills/configure-checks/SKILL.md +13 -18
- package/dist/output-BdvTIQ-k.mjs +0 -223
- package/dist/output-BdvTIQ-k.mjs.map +0 -1
- package/dist/postinstall.d.mts +0 -1
- package/dist/postinstall.mjs +0 -19
- package/dist/postinstall.mjs.map +0 -1
- package/dist/run-cli-BiPFbX9J.mjs +0 -24
- package/dist/run-cli-BiPFbX9J.mjs.map +0 -1
- package/dist/vpa-B3VOYbg1.mjs.map +0 -1
|
@@ -1,25 +1,51 @@
|
|
|
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-BdvTIQ-k.mjs";
|
|
2
1
|
import { n as toJson } from "./json-QtVKpodH.mjs";
|
|
3
2
|
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";
|
|
3
|
+
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
4
|
import { resolveConfigFromFile } from "vite-plus";
|
|
6
5
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
7
6
|
import format from "@commitlint/format";
|
|
8
7
|
import lint from "@commitlint/lint";
|
|
9
8
|
import load from "@commitlint/load";
|
|
10
9
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
11
|
-
import { lint as lint$1 } from "markdownlint/promise";
|
|
12
10
|
import { loadPackagesFromRawConfig } from "@textlint/config-loader";
|
|
13
11
|
import { TextlintKernelDescriptor } from "@textlint/kernel";
|
|
14
12
|
import { createLinter, loadLinterFormatter } from "textlint";
|
|
15
|
-
import {
|
|
13
|
+
import { loadBuiltinPlugins } from "textlint/lib/src/loader/TextlintrcLoader.js";
|
|
16
14
|
import { normalizeTextlintPresetSubRuleKey } from "@textlint/utils";
|
|
17
15
|
import { parse } from "yaml";
|
|
18
|
-
import {
|
|
16
|
+
import { Tar } from "effect/encoding";
|
|
17
|
+
import { format as format$1, makeDetector } from "@r_masseater/h56m";
|
|
19
18
|
import { minimatch } from "minimatch";
|
|
20
19
|
import { findWorkspaceProjectsNoCheck } from "@pnpm/workspace.projects-reader";
|
|
21
20
|
import { readWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-reader";
|
|
22
21
|
import { intersects, valid, validRange } from "semver";
|
|
22
|
+
// src/shared/lib/errors.ts
|
|
23
|
+
const taggedError = Schema.TaggedError;
|
|
24
|
+
var VpToolsError = class extends taggedError()("VpToolsError", {
|
|
25
|
+
kind: Schema.Literals([
|
|
26
|
+
"config-missing",
|
|
27
|
+
"tool-failed",
|
|
28
|
+
"checks-failed"
|
|
29
|
+
]),
|
|
30
|
+
message: Schema.String
|
|
31
|
+
}) {};
|
|
32
|
+
const configMissing = (message) => VpToolsError.make({
|
|
33
|
+
kind: "config-missing",
|
|
34
|
+
message
|
|
35
|
+
});
|
|
36
|
+
const checksFailed = (message) => VpToolsError.make({
|
|
37
|
+
kind: "checks-failed",
|
|
38
|
+
message
|
|
39
|
+
});
|
|
40
|
+
const toolFailed = (tool) => (cause) => VpToolsError.make({
|
|
41
|
+
kind: "tool-failed",
|
|
42
|
+
message: `${tool} failed: ${String(cause)}`
|
|
43
|
+
});
|
|
44
|
+
// src/shared/lib/attempt.ts
|
|
45
|
+
const attempt = (tool) => (run) => Effect.tryPromise({
|
|
46
|
+
try: run,
|
|
47
|
+
catch: toolFailed(tool)
|
|
48
|
+
});
|
|
23
49
|
// src/entities/vite-config/model/config.ts
|
|
24
50
|
const CONFIG_FILES = [
|
|
25
51
|
"vite.config.ts",
|
|
@@ -39,7 +65,7 @@ const requireSection = (key) => (config) => Effect.fromOption(Option.fromNullish
|
|
|
39
65
|
/** @internal */
|
|
40
66
|
const loadSection = Function.dual(2, (root, key) => loadViteConfig(root).pipe(Effect.flatMap(requireSection(key))));
|
|
41
67
|
// src/features/check-text/model/commitlint.ts
|
|
42
|
-
const DATA_FIRST_ARITY_3$
|
|
68
|
+
const DATA_FIRST_ARITY_3$2 = 3;
|
|
43
69
|
const COMMENT_CHAR = "#";
|
|
44
70
|
const parserOptionsOf = (loaded) => {
|
|
45
71
|
return {
|
|
@@ -54,7 +80,7 @@ const lintOptionsOf = (loaded) => ({
|
|
|
54
80
|
defaultIgnores: loaded.defaultIgnores ?? true
|
|
55
81
|
});
|
|
56
82
|
/** @internal */
|
|
57
|
-
const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$
|
|
83
|
+
const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$2, (config, root, messages) => Effect.gen(function* lintMessages() {
|
|
58
84
|
const loaded = yield* attempt("commitlint")(() => load(config, { cwd: root }));
|
|
59
85
|
const results = yield* Effect.forEach(messages, (message) => attempt("commitlint")(() => lint(message, loaded.rules, lintOptionsOf(loaded))), { concurrency: 1 });
|
|
60
86
|
return {
|
|
@@ -62,7 +88,7 @@ const lintCommitMessages = Function.dual(DATA_FIRST_ARITY_3$3, (config, root, me
|
|
|
62
88
|
output: format({ results }, { color: false })
|
|
63
89
|
};
|
|
64
90
|
}));
|
|
65
|
-
Function.dual(DATA_FIRST_ARITY_3$
|
|
91
|
+
Function.dual(DATA_FIRST_ARITY_3$2, (config, root, messageFile) => Effect.gen(function* read() {
|
|
66
92
|
const message = yield* (yield* FileSystem.FileSystem).readFileString(messageFile);
|
|
67
93
|
return yield* lintCommitMessages(config, root, [message]);
|
|
68
94
|
}));
|
|
@@ -72,9 +98,9 @@ const withSection = Function.dual(2, (key, run) => (context) => pipe(Option.from
|
|
|
72
98
|
onSome: (section) => Effect.asSome(run(section, context))
|
|
73
99
|
})));
|
|
74
100
|
// src/shared/lib/git.ts
|
|
75
|
-
const DATA_FIRST_ARITY$
|
|
101
|
+
const DATA_FIRST_ARITY$4 = 2;
|
|
76
102
|
/** @internal */
|
|
77
|
-
const listGitFiles = Function.dual(DATA_FIRST_ARITY$
|
|
103
|
+
const listGitFiles = Function.dual(DATA_FIRST_ARITY$4, (root, pathspecs) => Effect.gen(function* list() {
|
|
78
104
|
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
79
105
|
"-c",
|
|
80
106
|
"core.quotePath=false",
|
|
@@ -85,10 +111,10 @@ const listGitFiles = Function.dual(DATA_FIRST_ARITY$3, (root, pathspecs) => Effe
|
|
|
85
111
|
"--",
|
|
86
112
|
...pathspecs
|
|
87
113
|
], { cwd: root }));
|
|
88
|
-
return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
|
|
114
|
+
return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
|
|
89
115
|
}));
|
|
90
116
|
/** @internal */
|
|
91
|
-
const listCommitMessages = Function.dual(DATA_FIRST_ARITY$
|
|
117
|
+
const listCommitMessages = Function.dual(DATA_FIRST_ARITY$4, (root, range) => Effect.gen(function* messages() {
|
|
92
118
|
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
93
119
|
"log",
|
|
94
120
|
"-z",
|
|
@@ -97,39 +123,7 @@ const listCommitMessages = Function.dual(DATA_FIRST_ARITY$3, (root, range) => Ef
|
|
|
97
123
|
range,
|
|
98
124
|
"--"
|
|
99
125
|
], { cwd: root }));
|
|
100
|
-
return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
|
|
101
|
-
}));
|
|
102
|
-
// src/features/check-text/model/markdownlint.ts
|
|
103
|
-
const DATA_FIRST_ARITY_3$2 = 3;
|
|
104
|
-
const formatError = (file) => (error) => {
|
|
105
|
-
const detail = pipe([error.errorDetail, error.errorContext], Array.filter((part) => part !== null && part !== ""), Array.map((part) => ` [${part}]`), Array.join(""));
|
|
106
|
-
return `${file}:${error.lineNumber} ${Array.join(error.ruleNames, "/")} ${error.ruleDescription}${detail}`;
|
|
107
|
-
};
|
|
108
|
-
const optionsOf = (config, files) => ({
|
|
109
|
-
files: [...files],
|
|
110
|
-
...pipe(Option.fromNullishOr(config.config), Option.match({
|
|
111
|
-
onNone: () => ({}),
|
|
112
|
-
onSome: (rules) => ({ config: rules })
|
|
113
|
-
})),
|
|
114
|
-
...pipe(Option.fromNullishOr(config.customRules), Option.match({
|
|
115
|
-
onNone: () => ({}),
|
|
116
|
-
onSome: (rules) => ({ customRules: [...rules] })
|
|
117
|
-
}))
|
|
118
|
-
});
|
|
119
|
-
/** @internal */
|
|
120
|
-
const lintMarkdown = Function.dual(DATA_FIRST_ARITY_3$2, (config, root, files) => Effect.gen(function* markdown() {
|
|
121
|
-
const path = yield* Path.Path;
|
|
122
|
-
const absolute = pipe(files, Array.map((file) => path.join(root, file)));
|
|
123
|
-
const results = yield* attempt("markdownlint")(() => lint$1(optionsOf(config, absolute)));
|
|
124
|
-
const linesOf = ([file, errors]) => {
|
|
125
|
-
const format = formatError(path.relative(root, file));
|
|
126
|
-
return pipe(errors, Array.map(format));
|
|
127
|
-
};
|
|
128
|
-
const lines = pipe(Record.toEntries(results), Array.flatMap(linesOf));
|
|
129
|
-
return {
|
|
130
|
-
valid: Array.isArrayEmpty(lines),
|
|
131
|
-
output: Array.join(lines, "\n")
|
|
132
|
-
};
|
|
126
|
+
return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
|
|
133
127
|
}));
|
|
134
128
|
// src/features/check-text/model/textlint-presets.ts
|
|
135
129
|
const NO_OPTIONS = {};
|
|
@@ -161,10 +155,11 @@ const rawConfigOf = (config) => {
|
|
|
161
155
|
const DATA_FIRST_ARITY_3$1 = 3;
|
|
162
156
|
const descriptorOf = (loaded, root, config) => {
|
|
163
157
|
if (!loaded.ok) return Effect.fail(toolFailed("textlint")(loaded.error.message));
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
const { rules, filterRules, plugins } = loaded.config;
|
|
159
|
+
return Effect.map(attempt("textlint")(loadBuiltinPlugins), (builtIn) => new TextlintKernelDescriptor({
|
|
160
|
+
rules: [...rules, ...presetRulesOf(config)],
|
|
161
|
+
filterRules,
|
|
162
|
+
plugins: [...builtIn.plugin.toKernelPluginsFormat(), ...plugins],
|
|
168
163
|
configBaseDir: root
|
|
169
164
|
}));
|
|
170
165
|
};
|
|
@@ -195,7 +190,7 @@ const markdownFiles = (root, ignores = []) => listGitFiles(root, [MARKDOWN, ...p
|
|
|
195
190
|
const sourceFiles = (root, files) => listGitFiles(root, pipe(files, Array.map((glob) => `${GLOB_PATHSPEC}${glob}`)));
|
|
196
191
|
const mergeReports = (reports) => ({
|
|
197
192
|
valid: pipe(reports, Array.every((report) => report.valid)),
|
|
198
|
-
output: pipe(reports, Array.map((report) => report.output), Array.filter(String.isNonEmpty), Array.join("\n"))
|
|
193
|
+
output: pipe(reports, Array.map((report) => report.output), Array.filter(String$1.isNonEmpty), Array.join("\n"))
|
|
199
194
|
});
|
|
200
195
|
/** @internal */
|
|
201
196
|
const textlintCheck = withSection("textlint", (config, { root }) => {
|
|
@@ -208,9 +203,7 @@ const textlintCheck = withSection("textlint", (config, { root }) => {
|
|
|
208
203
|
return Effect.all([markdown, ...sources], { concurrency: 1 }).pipe(Effect.map(mergeReports));
|
|
209
204
|
});
|
|
210
205
|
/** @internal */
|
|
211
|
-
const
|
|
212
|
-
/** @internal */
|
|
213
|
-
const commitlintCheck = withSection("commitlint", (config, { root, base }) => listCommitMessages(root, `${base}..HEAD`).pipe(Effect.flatMap((messages) => lintCommitMessages(config, root, messages))));
|
|
206
|
+
const commitlintCheck = withSection("commitlint", (config, { root, range }) => listCommitMessages(root, range).pipe(Effect.flatMap((messages) => lintCommitMessages(config, root, messages))));
|
|
214
207
|
// src/shared/config/skills.ts
|
|
215
208
|
const Repository = Schema.String.check(Schema.isPattern(/^[\w-][\w.-]*\/[\w.-]+$/u));
|
|
216
209
|
const LocalDirectory = Schema.String.check(Schema.isPattern(/^\.\/[\w.-]+(?:\/[\w.-]+)*$/u));
|
|
@@ -246,6 +239,26 @@ const skillCacheDirectory = Effect.gen(function* skillCache() {
|
|
|
246
239
|
const base = yield* baseDirectory;
|
|
247
240
|
return path.join(base, ...SUBDIRECTORY);
|
|
248
241
|
});
|
|
242
|
+
// src/shared/lib/process.ts
|
|
243
|
+
const SUCCESS$1 = 0;
|
|
244
|
+
const stdinOf = (input) => pipe(Option.fromNullishOr(input), Option.match({
|
|
245
|
+
onNone: () => "ignore",
|
|
246
|
+
onSome: (text) => Stream.make(new TextEncoder().encode(text))
|
|
247
|
+
}));
|
|
248
|
+
/** @internal */
|
|
249
|
+
const runCaptured = ({ root, file, args, env = {}, input, output = "all" }) => Effect.gen(function* run() {
|
|
250
|
+
const handle = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).spawn(ChildProcess.make(file, args, {
|
|
251
|
+
cwd: root,
|
|
252
|
+
env,
|
|
253
|
+
extendEnv: true,
|
|
254
|
+
stdin: stdinOf(input)
|
|
255
|
+
}));
|
|
256
|
+
const [text, exitCode] = yield* Effect.all([handle[output].pipe(Stream.decodeText, Stream.mkString), handle.exitCode], { concurrency: "unbounded" });
|
|
257
|
+
return {
|
|
258
|
+
valid: exitCode === SUCCESS$1,
|
|
259
|
+
output: text
|
|
260
|
+
};
|
|
261
|
+
}).pipe(Effect.scoped);
|
|
249
262
|
// src/features/install-skills/model/link.ts
|
|
250
263
|
const KEEP = ".gitkeep";
|
|
251
264
|
const junction = (target, link) => runCaptured({
|
|
@@ -315,6 +328,17 @@ const linkSkills = (root) => (links) => Effect.gen(function* link() {
|
|
|
315
328
|
const next = yield* buildNext(agents, skills, links);
|
|
316
329
|
yield* swapIn(agents, skills, next);
|
|
317
330
|
});
|
|
331
|
+
// src/shared/lib/tar-gz.ts
|
|
332
|
+
const gunzipped = (data) => {
|
|
333
|
+
const compressed = new Blob([new Uint8Array(data)]).stream();
|
|
334
|
+
return attempt("gunzip")(() => new Response(compressed.pipeThrough(new DecompressionStream("gzip"))).arrayBuffer());
|
|
335
|
+
};
|
|
336
|
+
const untarred = (archive) => Stream.make(new Uint8Array(archive)).pipe(Stream.pipeThroughChannel(Tar.decode()), Stream.mapEffect(({ header, body }) => Effect.map(Stream.mkUint8Array(body), (bytes) => ({
|
|
337
|
+
header,
|
|
338
|
+
bytes
|
|
339
|
+
}))), Stream.runCollect, Effect.mapError(toolFailed("untar")));
|
|
340
|
+
/** @internal */
|
|
341
|
+
const readTarGz = (data) => Effect.flatMap(gunzipped(data), untarred);
|
|
318
342
|
const SKILL_FILE$1 = "SKILL.md";
|
|
319
343
|
const FRONTMATTER = /^---\r?\n(?<yaml>[\s\S]*?)\r?\n---/u;
|
|
320
344
|
const NEXT = 1;
|
|
@@ -325,9 +349,9 @@ const Frontmatter = Schema.Struct({ name: Schema.String });
|
|
|
325
349
|
const decodeFrontmatter = Schema.decodeUnknownOption(Frontmatter);
|
|
326
350
|
const parseYaml = Option.liftThrowable((yaml) => parse(yaml));
|
|
327
351
|
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));
|
|
328
|
-
const afterFirstSegment = (path) => pipe(path, String.indexOf("/"), Option.match({
|
|
352
|
+
const afterFirstSegment = (path) => pipe(path, String$1.indexOf("/"), Option.match({
|
|
329
353
|
onNone: () => path,
|
|
330
|
-
onSome: (at) => String.slice(at + NEXT)(path)
|
|
354
|
+
onSome: (at) => String$1.slice(at + NEXT)(path)
|
|
331
355
|
}));
|
|
332
356
|
const withoutTopDirectory = ({ header, bytes }) => ({
|
|
333
357
|
header: {
|
|
@@ -337,17 +361,17 @@ const withoutTopDirectory = ({ header, bytes }) => ({
|
|
|
337
361
|
bytes
|
|
338
362
|
});
|
|
339
363
|
/** @internal */
|
|
340
|
-
const isUnder = (directory) => (path) => directory === "" || String.startsWith(`${directory}/`)(path);
|
|
364
|
+
const isUnder = (directory) => (path) => directory === "" || String$1.startsWith(`${directory}/`)(path);
|
|
341
365
|
/** @internal */
|
|
342
366
|
const relativeTo = (directory) => (path) => {
|
|
343
367
|
if (directory === "") return path;
|
|
344
|
-
return String.slice(directory.length + NEXT)(path);
|
|
368
|
+
return String$1.slice(directory.length + NEXT)(path);
|
|
345
369
|
};
|
|
346
|
-
const parentOf = (path) => pipe(path, String.lastIndexOf("/"), Option.match({
|
|
370
|
+
const parentOf = (path) => pipe(path, String$1.lastIndexOf("/"), Option.match({
|
|
347
371
|
onNone: () => "",
|
|
348
|
-
onSome: (at) => String.slice(START, at)(path)
|
|
372
|
+
onSome: (at) => String$1.slice(START, at)(path)
|
|
349
373
|
}));
|
|
350
|
-
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);
|
|
374
|
+
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);
|
|
351
375
|
const isOutermost = (candidates) => ({ directory }) => !pipe(candidates, Array.some((other) => other.directory !== directory && isUnder(other.directory)(directory)));
|
|
352
376
|
const toFound = ({ directory, name }) => pipe(name, Option.map((found) => ({
|
|
353
377
|
name: found,
|
|
@@ -368,12 +392,16 @@ const skillsIn = ({ repository, source }) => (entries) => {
|
|
|
368
392
|
return Effect.succeed(found);
|
|
369
393
|
};
|
|
370
394
|
/** @internal */
|
|
371
|
-
const labelOf = ({ repository, source }) => `${repository}@${String.slice(START, SHORT_COMMIT)(source.commit)}`;
|
|
395
|
+
const labelOf = ({ repository, source }) => `${repository}@${String$1.slice(START, SHORT_COMMIT)(source.commit)}`;
|
|
396
|
+
const RETRY_DELAY = "1 second";
|
|
397
|
+
const RETRIES = 4;
|
|
372
398
|
const codeload = ({ repository, source }) => HttpClientRequest.get(`https://codeload.github.com/${repository}/tar.gz/${source.commit}`);
|
|
373
399
|
const api = ({ repository, source }) => (token) => HttpClientRequest.get(`https://api.github.com/repos/${repository}/tarball/${source.commit}`).pipe(HttpClientRequest.bearerToken(Redacted.value(token)));
|
|
374
400
|
const fetchBytes = (request) => Effect.gen(function* fetchArchive() {
|
|
375
|
-
const
|
|
376
|
-
|
|
401
|
+
const body = yield* (yield* (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk, HttpClient.retryTransient({
|
|
402
|
+
schedule: Schedule.exponential(RETRY_DELAY),
|
|
403
|
+
times: RETRIES
|
|
404
|
+
})).execute(request)).arrayBuffer;
|
|
377
405
|
return new Uint8Array(body);
|
|
378
406
|
});
|
|
379
407
|
const githubToken = Config.option(Config.Redacted("GITHUB_TOKEN")).pipe(Effect.orElseSucceed(Option.none));
|
|
@@ -403,9 +431,9 @@ const hasSkillFile = (base) => (name) => Effect.gen(function* checkSkillFile() {
|
|
|
403
431
|
/** @internal */
|
|
404
432
|
const resolveLocal = (root) => ({ directory, skills }) => Effect.gen(function* resolveLocalSource() {
|
|
405
433
|
const fs = yield* FileSystem.FileSystem;
|
|
406
|
-
const base = (yield* Path.Path).join(root, ...String.split("/")(directory));
|
|
434
|
+
const base = (yield* Path.Path).join(root, ...String$1.split("/")(directory));
|
|
407
435
|
const entries = yield* fs.readDirectory(base).pipe(Effect.mapError(() => checksFailed(`${directory} is not a folder`)));
|
|
408
|
-
const available = yield* pipe(Array.sort(entries, String.Order), Effect.filter(hasSkillFile(base)));
|
|
436
|
+
const available = yield* pipe(Array.sort(entries, String$1.Order), Effect.filter(hasSkillFile(base)));
|
|
409
437
|
return {
|
|
410
438
|
repository: directory,
|
|
411
439
|
names: yield* selectSkills({
|
|
@@ -448,7 +476,7 @@ const writeEntry = (staging, skill) => ({ header, bytes }) => Effect.gen(functio
|
|
|
448
476
|
const fs = yield* FileSystem.FileSystem;
|
|
449
477
|
const path = yield* Path.Path;
|
|
450
478
|
const relative = relativeTo(skill.directory)(header.path);
|
|
451
|
-
const file = path.join(staging, ...String.split("/")(relative));
|
|
479
|
+
const file = path.join(staging, ...String$1.split("/")(relative));
|
|
452
480
|
yield* fs.makeDirectory(path.dirname(file), { recursive: true });
|
|
453
481
|
yield* fs.writeFile(file, bytes);
|
|
454
482
|
yield* fs.chmod(file, modeOf(header.mode));
|
|
@@ -520,7 +548,7 @@ const fetchNames = (declared, directory) => Effect.gen(function* fromArchive() {
|
|
|
520
548
|
});
|
|
521
549
|
/** @internal */
|
|
522
550
|
const resolveSource = (cache) => (declared) => Effect.gen(function* resolve() {
|
|
523
|
-
const directory = (yield* Path.Path).join(cache, ...String.split("/")(declared.repository), declared.source.commit);
|
|
551
|
+
const directory = (yield* Path.Path).join(cache, ...String$1.split("/")(declared.repository), declared.source.commit);
|
|
524
552
|
const cached = yield* cachedNames(declared, directory);
|
|
525
553
|
const names = yield* Option.match(cached, {
|
|
526
554
|
onNone: () => fetchNames(declared, directory),
|
|
@@ -554,7 +582,7 @@ const linksOf = (resolved) => Effect.gen(function* collectLinks() {
|
|
|
554
582
|
})));
|
|
555
583
|
});
|
|
556
584
|
const resolveEntry = (root, cache) => ([key, source]) => {
|
|
557
|
-
const local = String.startsWith(LOCAL_PREFIX)(key);
|
|
585
|
+
const local = String$1.startsWith(LOCAL_PREFIX)(key);
|
|
558
586
|
if (isRemote(source)) {
|
|
559
587
|
if (local) return Effect.fail(checksFailed(`vite.config "skills": ${key} is a folder in this repository and takes no commit`));
|
|
560
588
|
return resolveSource(cache)({
|
|
@@ -580,37 +608,11 @@ const installSkills = (root) => Effect.gen(function* install() {
|
|
|
580
608
|
yield* linkSkills(root)(links);
|
|
581
609
|
return Option.some(links.length);
|
|
582
610
|
});
|
|
583
|
-
// src/features/scan-secrets/model/betterleaks.ts
|
|
584
|
-
const toBetterleaksToml = (config) => {
|
|
585
|
-
const { ignoredSecrets: _ignoredSecrets, ...rest } = config;
|
|
586
|
-
return stringify(rest);
|
|
587
|
-
};
|
|
588
|
-
const toIgnoreFile = (config) => pipe(config.ignoredSecrets ?? [], Array.map((digest) => `${digest}\n`), Array.join(""));
|
|
589
611
|
// src/features/scan-secrets/model/secret-checks.ts
|
|
590
|
-
const DATA_FIRST_ARITY$
|
|
591
|
-
const ignoreFileArgs = (config) => Effect.gen(function* ignoreFile() {
|
|
592
|
-
const digests = toIgnoreFile(config);
|
|
593
|
-
if (digests === "") return [];
|
|
594
|
-
const fs = yield* FileSystem.FileSystem;
|
|
595
|
-
const file = yield* fs.makeTempFileScoped({ prefix: "betterleaksignore-" });
|
|
596
|
-
yield* fs.writeFileString(file, digests);
|
|
597
|
-
return ["--ignore-file", file];
|
|
598
|
-
});
|
|
599
|
-
const scanSecrets = ({ config, root, args, input }) => Effect.gen(function* scan() {
|
|
600
|
-
const ignore = yield* ignoreFileArgs(config);
|
|
601
|
-
return yield* runVendored(BETTERLEAKS, {
|
|
602
|
-
root,
|
|
603
|
-
args: [
|
|
604
|
-
...args,
|
|
605
|
-
"--redact",
|
|
606
|
-
"--no-banner",
|
|
607
|
-
...ignore
|
|
608
|
-
],
|
|
609
|
-
env: { BETTERLEAKS_CONFIG_TOML: toBetterleaksToml(config) },
|
|
610
|
-
input
|
|
611
|
-
});
|
|
612
|
-
}).pipe(Effect.scoped);
|
|
612
|
+
const DATA_FIRST_ARITY$3 = 2;
|
|
613
613
|
const SUCCESS = 0;
|
|
614
|
+
const RANGE = "..";
|
|
615
|
+
const HEAD = "HEAD";
|
|
614
616
|
const lacksHistory = (root) => Effect.gen(function* history() {
|
|
615
617
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
616
618
|
const shallow = yield* spawner.string(ChildProcess.make("git", ["rev-parse", "--is-shallow-repository"], { cwd: root }));
|
|
@@ -619,69 +621,57 @@ const lacksHistory = (root) => Effect.gen(function* history() {
|
|
|
619
621
|
"--get",
|
|
620
622
|
"remote.origin.promisor"
|
|
621
623
|
], { cwd: root }));
|
|
622
|
-
return String.trim(shallow) === "true" || promisor === SUCCESS;
|
|
623
|
-
});
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
624
|
+
return String$1.trim(shallow) === "true" || promisor === SUCCESS;
|
|
625
|
+
});
|
|
626
|
+
const historyOf = (range) => pipe(String$1.split(range, RANGE), Array.match({
|
|
627
|
+
onEmpty: () => ({
|
|
628
|
+
type: "history",
|
|
629
|
+
head: HEAD
|
|
630
|
+
}),
|
|
631
|
+
onNonEmpty: ([base, ...rest]) => Array.match(rest, {
|
|
632
|
+
onEmpty: () => ({
|
|
633
|
+
type: "history",
|
|
634
|
+
head: range
|
|
635
|
+
}),
|
|
636
|
+
onNonEmpty: ([head]) => ({
|
|
637
|
+
type: "history",
|
|
638
|
+
bases: [base],
|
|
639
|
+
head
|
|
640
|
+
})
|
|
641
|
+
})
|
|
627
642
|
}));
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
archive,
|
|
638
|
-
"HEAD"
|
|
639
|
-
], { cwd: root })));
|
|
640
|
-
yield* succeeded("tar", spawner.exitCode(ChildProcess.make("tar", [
|
|
641
|
-
"-xf",
|
|
642
|
-
archive,
|
|
643
|
-
"-C",
|
|
644
|
-
directory
|
|
645
|
-
])));
|
|
646
|
-
yield* fs.remove(archive);
|
|
647
|
-
return yield* scanSecrets({
|
|
648
|
-
config,
|
|
643
|
+
const sourceOf = (partial, range) => Boolean$1.match(partial, {
|
|
644
|
+
onTrue: () => ({
|
|
645
|
+
type: "snapshot",
|
|
646
|
+
revision: HEAD
|
|
647
|
+
}),
|
|
648
|
+
onFalse: () => historyOf(range)
|
|
649
|
+
});
|
|
650
|
+
const scan = (config, root, source) => Effect.gen(function* scanSource() {
|
|
651
|
+
const found = yield* (yield* makeDetector(config)).scanGit({
|
|
649
652
|
root,
|
|
650
|
-
|
|
653
|
+
source
|
|
651
654
|
});
|
|
652
|
-
|
|
655
|
+
return {
|
|
656
|
+
valid: Array.isReadonlyArrayEmpty(found),
|
|
657
|
+
output: pipe(found, Array.map(format$1), Array.join("\n"))
|
|
658
|
+
};
|
|
659
|
+
}).pipe(Effect.mapError(toolFailed("h56m")));
|
|
653
660
|
/** @internal */
|
|
654
|
-
const
|
|
655
|
-
if (partial) return scanCommittedTree(config, root);
|
|
656
|
-
return scanSecrets({
|
|
657
|
-
config,
|
|
658
|
-
root,
|
|
659
|
-
args: [
|
|
660
|
-
"git",
|
|
661
|
-
".",
|
|
662
|
-
`--revision=${base}..HEAD`
|
|
663
|
-
]
|
|
664
|
-
});
|
|
665
|
-
})));
|
|
666
|
-
const STAGED_DIFF = [
|
|
667
|
-
"diff",
|
|
668
|
-
"--cached",
|
|
669
|
-
"--no-ext-diff",
|
|
670
|
-
"--no-textconv",
|
|
671
|
-
"--no-color",
|
|
672
|
-
"--src-prefix=a/",
|
|
673
|
-
"--dst-prefix=b/"
|
|
674
|
-
];
|
|
661
|
+
const h56mCheck = withSection("h56m", (config, { root, range }) => lacksHistory(root).pipe(Effect.flatMap((partial) => scan(config, root, sourceOf(partial, range)))));
|
|
675
662
|
/** @internal */
|
|
676
|
-
const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
args: ["stdin", "--git-diff"],
|
|
682
|
-
input: diff
|
|
683
|
-
});
|
|
663
|
+
const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$3, (config, root) => scan(config, root, { type: "staged" }));
|
|
664
|
+
/** @internal */
|
|
665
|
+
const writeTo = Function.dual(2, (sink, text) => Effect.gen(function* write() {
|
|
666
|
+
const stdio = yield* Stdio.Stdio;
|
|
667
|
+
yield* Stream.make(text).pipe(Stream.run(stdio[sink]()), Effect.orDie);
|
|
684
668
|
}));
|
|
669
|
+
/** @internal */
|
|
670
|
+
const finish = (report) => {
|
|
671
|
+
if (!report.valid) return Effect.fail(checksFailed(report.output));
|
|
672
|
+
if (report.output === "") return Effect.void;
|
|
673
|
+
return writeTo("stdout", `${report.output}\n`);
|
|
674
|
+
};
|
|
685
675
|
// src/shared/lib/workspace.ts
|
|
686
676
|
const DEPENDENCY_FIELDS = [
|
|
687
677
|
"dependencies",
|
|
@@ -691,8 +681,8 @@ const DEPENDENCY_FIELDS = [
|
|
|
691
681
|
];
|
|
692
682
|
const MANIFEST_FILE = "package.json";
|
|
693
683
|
const pnpm = attempt("pnpm");
|
|
694
|
-
const byFile = Order.mapInput(String.Order, ({ file }) => file);
|
|
695
|
-
const manifestIn = (directory) => pipe(Option.liftPredicate(directory, String.isNonEmpty), Option.map((own) => `${own}/${MANIFEST_FILE}`), Option.getOrElse(() => MANIFEST_FILE));
|
|
684
|
+
const byFile = Order.mapInput(String$1.Order, ({ file }) => file);
|
|
685
|
+
const manifestIn = (directory) => pipe(Option.liftPredicate(directory, String$1.isNonEmpty), Option.map((own) => `${own}/${MANIFEST_FILE}`), Option.getOrElse(() => MANIFEST_FILE));
|
|
696
686
|
const dependenciesIn = (file, declared) => pipe(DEPENDENCY_FIELDS, Array.flatMap((field) => {
|
|
697
687
|
const entries = Record.toEntries(Option.getOrElse(Option.fromUndefinedOr(declared[field]), () => ({})));
|
|
698
688
|
return pipe(entries, Array.map(([name, specifier]) => ({
|
|
@@ -761,7 +751,7 @@ const versionProblems = (rules, pinned) => {
|
|
|
761
751
|
};
|
|
762
752
|
const comparedDependencies = (rules, dependencies) => {
|
|
763
753
|
const isExact = inWorkspaces(exactGlobs(rules));
|
|
764
|
-
return pipe(dependencies, Array.filter(({ specifier }) => !String.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
|
|
754
|
+
return pipe(dependencies, Array.filter(({ specifier }) => !String$1.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
|
|
765
755
|
};
|
|
766
756
|
const checkDependencies = Function.dual(DATA_FIRST_ARITY$1, (rules, dependencies) => [
|
|
767
757
|
...bannedProblems(rules, dependencies),
|
|
@@ -784,7 +774,7 @@ const checkSlices = Function.dual(DATA_FIRST_ARITY_3, (config, root, targets) =>
|
|
|
784
774
|
}));
|
|
785
775
|
// src/features/check-repository/model/repository-checks.ts
|
|
786
776
|
const LAYER_FOLDER = /\/(?:app|pages|widgets|features|entities|shared)\//gu;
|
|
787
|
-
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)))))));
|
|
777
|
+
const layeredDirectories = (root, patterns) => listGitFiles(root, []).pipe(Effect.map((files) => pipe(files, Array.flatMap((file) => Array.map(Array.fromIterable(String$1.matchAll(LAYER_FOLDER)(file)), ({ index }) => String$1.takeLeft(file, index ?? file.length))), Array.dedupe, Array.filter((directory) => pipe(patterns, Array.some((pattern) => minimatch(directory, pattern)))))));
|
|
788
778
|
/** @internal */
|
|
789
779
|
const steigerCheck = withSection("steiger", (section, { root }) => layeredDirectories(root, section.paths).pipe(Effect.flatMap((targets) => checkSlices(section.rules, root, targets))));
|
|
790
780
|
/** @internal */
|
|
@@ -795,30 +785,6 @@ const dependenciesCheck = withSection("dependencyRules", (rules, { root }) => li
|
|
|
795
785
|
output: Array.join(problems, "\n")
|
|
796
786
|
};
|
|
797
787
|
})));
|
|
798
|
-
// src/features/check-workflows/model/workflow-checks.ts
|
|
799
|
-
const WORKFLOWS = ".github/workflows";
|
|
800
|
-
const onWorkflows = (binary, args) => ({ root }) => Effect.gen(function* workflows() {
|
|
801
|
-
const fs = yield* FileSystem.FileSystem;
|
|
802
|
-
const path = yield* Path.Path;
|
|
803
|
-
if (!(yield* fs.exists(path.join(root, WORKFLOWS)))) return Option.none();
|
|
804
|
-
const resolvedArgs = yield* args;
|
|
805
|
-
const ran = yield* runVendored(binary, {
|
|
806
|
-
root,
|
|
807
|
-
args: resolvedArgs
|
|
808
|
-
});
|
|
809
|
-
return Option.some(ran);
|
|
810
|
-
});
|
|
811
|
-
/** @internal */
|
|
812
|
-
const actionlintCheck = onWorkflows(ACTIONLINT, Effect.succeed([]));
|
|
813
|
-
const zizmorArgs = Effect.gen(function* zizmorArgs() {
|
|
814
|
-
const remote = yield* Config.option(Config.String("CLAUDE_CODE_REMOTE")).pipe(Effect.orDie);
|
|
815
|
-
return pipe(remote, Option.match({
|
|
816
|
-
onNone: () => [".github"],
|
|
817
|
-
onSome: () => ["--no-online-audits", ".github"]
|
|
818
|
-
}));
|
|
819
|
-
});
|
|
820
|
-
/** @internal */
|
|
821
|
-
const zizmorCheck = onWorkflows(ZIZMOR, zizmorArgs);
|
|
822
788
|
// src/features/run-fallow/model/fallow-check.ts
|
|
823
789
|
const QUIET = [
|
|
824
790
|
"--fail-on-issues",
|
|
@@ -903,21 +869,13 @@ const fallowCheck = withSection("fallow", (config, { root }) => runFallow(config
|
|
|
903
869
|
// src/app/checks.ts
|
|
904
870
|
const CHECKS = [
|
|
905
871
|
{
|
|
906
|
-
name: "
|
|
907
|
-
run:
|
|
872
|
+
name: "h56m",
|
|
873
|
+
run: h56mCheck
|
|
908
874
|
},
|
|
909
875
|
{
|
|
910
876
|
name: "commitlint",
|
|
911
877
|
run: commitlintCheck
|
|
912
878
|
},
|
|
913
|
-
{
|
|
914
|
-
name: "actionlint",
|
|
915
|
-
run: actionlintCheck
|
|
916
|
-
},
|
|
917
|
-
{
|
|
918
|
-
name: "zizmor",
|
|
919
|
-
run: zizmorCheck
|
|
920
|
-
},
|
|
921
879
|
{
|
|
922
880
|
name: "dependencies",
|
|
923
881
|
run: dependenciesCheck
|
|
@@ -930,18 +888,19 @@ const CHECKS = [
|
|
|
930
888
|
name: "textlint",
|
|
931
889
|
run: textlintCheck
|
|
932
890
|
},
|
|
933
|
-
{
|
|
934
|
-
name: "markdownlint",
|
|
935
|
-
run: markdownlintCheck
|
|
936
|
-
},
|
|
937
891
|
{
|
|
938
892
|
name: "fallow",
|
|
939
893
|
run: fallowCheck
|
|
940
894
|
}
|
|
941
895
|
];
|
|
942
896
|
// src/app/run-checks.ts
|
|
943
|
-
const
|
|
897
|
+
const DEFAULT_BRANCHES = [
|
|
898
|
+
"origin/HEAD",
|
|
899
|
+
"origin/main",
|
|
900
|
+
"origin/master"
|
|
901
|
+
];
|
|
944
902
|
const RESOLVED = 0;
|
|
903
|
+
const WHOLE_HISTORY = "HEAD";
|
|
945
904
|
const isCommit = (root, revision) => Effect.gen(function* verify() {
|
|
946
905
|
return (yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("git", [
|
|
947
906
|
"rev-parse",
|
|
@@ -950,10 +909,14 @@ const isCommit = (root, revision) => Effect.gen(function* verify() {
|
|
|
950
909
|
`${revision}^{commit}`
|
|
951
910
|
], { cwd: root }))) === RESOLVED;
|
|
952
911
|
}).pipe(Effect.orElseSucceed(() => false));
|
|
953
|
-
const
|
|
912
|
+
const resolveRange = (root) => Effect.gen(function* range() {
|
|
954
913
|
const configured = yield* Config.option(Config.String("VPA_BASE")).pipe(Effect.orDie);
|
|
955
|
-
|
|
956
|
-
|
|
914
|
+
const candidates = [...Option.toArray(configured), ...DEFAULT_BRANCHES];
|
|
915
|
+
const base = yield* Effect.findFirst(candidates, (revision) => isCommit(root, revision));
|
|
916
|
+
return Option.match(base, {
|
|
917
|
+
onNone: () => WHOLE_HISTORY,
|
|
918
|
+
onSome: (revision) => `${revision}..HEAD`
|
|
919
|
+
});
|
|
957
920
|
});
|
|
958
921
|
const describe = ({ name, report }) => {
|
|
959
922
|
if (report.valid) return `✓ ${name}`;
|
|
@@ -966,11 +929,11 @@ const runCheck = (context) => ({ name, run }) => run(context).pipe(Effect.map(Op
|
|
|
966
929
|
/** @internal */
|
|
967
930
|
const runAllChecks = (root) => Effect.gen(function* all() {
|
|
968
931
|
const config = yield* loadViteConfig(root);
|
|
969
|
-
const
|
|
932
|
+
const range = yield* resolveRange(root);
|
|
970
933
|
const outcomes = yield* pipe(CHECKS, Effect.forEach(runCheck({
|
|
971
934
|
root,
|
|
972
935
|
config,
|
|
973
|
-
|
|
936
|
+
range
|
|
974
937
|
}), { concurrency: "unbounded" }), Effect.map(Array.getSomes));
|
|
975
938
|
yield* writeTo("stdout", `${pipe(outcomes, Array.map(describe), Array.join("\n"))}\n`);
|
|
976
939
|
return yield* pipe(outcomes, Array.filter(({ report }) => !report.valid), Array.map(({ name }) => name), Array.match({
|
|
@@ -988,7 +951,7 @@ const USAGE = pipe([
|
|
|
988
951
|
" vpa --message <text> lint a message"
|
|
989
952
|
], Array.join("\n"));
|
|
990
953
|
const usage = Effect.fail(checksFailed(USAGE));
|
|
991
|
-
const stagedSecrets = (root) => loadSection(root, "
|
|
954
|
+
const stagedSecrets = (root) => loadSection(root, "h56m").pipe(Effect.flatMap((config) => scanStagedSecrets(config, root)), Effect.flatMap(finish));
|
|
992
955
|
const lintMessage = (toMessage) => (root, rest) => pipe(Array.head(rest), Option.match({
|
|
993
956
|
onNone: () => usage,
|
|
994
957
|
onSome: (argument) => Effect.gen(function* lintGiven() {
|
|
@@ -1018,6 +981,6 @@ const runVpa = Function.dual(DATA_FIRST_ARITY, (root, args) => pipe(args, Array.
|
|
|
1018
981
|
onSome: (hook) => hook(root, rest)
|
|
1019
982
|
}))
|
|
1020
983
|
})));
|
|
1021
|
-
export {
|
|
984
|
+
export { VpToolsError as i, writeTo as n, loadViteConfig as r, runVpa as t };
|
|
1022
985
|
|
|
1023
|
-
//# sourceMappingURL=vpa-
|
|
986
|
+
//# sourceMappingURL=vpa-MRYbih3E.mjs.map
|