@r_masseater/msch 0.125.0 → 0.126.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/dist/cli.mjs +118 -59
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +12 -0
- package/dist/config.mjs +1 -518
- package/dist/repository-config-8JN86BZA.mjs +834 -0
- package/dist/repository-config-8JN86BZA.mjs.map +1 -0
- package/package.json +1 -1
- package/skills/msch-repository-config/SKILL.md +3 -1
- package/dist/config.mjs.map +0 -1
- package/dist/repository-text-DfTSvaqo.mjs +0 -322
- package/dist/repository-text-DfTSvaqo.mjs.map +0 -1
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { Array, Effect, Layer, ManagedRuntime, Option, Record, String as String$1, pipe } from "effect";
|
|
3
|
+
import { a as textlintFilters, f as requiredStack, g as decisionTestRules, i as zennMarkdown, o as textlintPresets, p as lint$1, r as markdownOf, s as structureOf, x as exempt } from "./define-lint-preset-D3jb88wH.mjs";
|
|
4
|
+
import { recommended } from "@r_masseater/fu4/presets";
|
|
5
|
+
import { definePlugin, defineRule } from "@r_masseater/fu4";
|
|
6
|
+
import { NOOP, actionOf, keysOf, pairsOf, runOf, valueAt, workflowRule } from "@r_masseater/fu4/rules";
|
|
7
|
+
import { a as nodeServicesLayer, i as nodeRepositoryFiles, r as RepositoryFiles, s as groupOf } from "./repository-files-C_GzAnYp.mjs";
|
|
8
|
+
import { c as TASK_NAMES, i as workspaceProjects } from "./workspace-projects-eapoa0az.mjs";
|
|
9
|
+
import { RUNTIME_SECTIONS } from "@r_masseater/masseater-utils/kestrion";
|
|
10
|
+
import { i as USAGE_SPOOL } from "./config-B3SYjao5.mjs";
|
|
11
|
+
import { betterleaks } from "@r_masseater/h56m/presets";
|
|
12
|
+
// src/entities/workspace/model/workspace-names.ts
|
|
13
|
+
const ALTERNATIVE = "|";
|
|
14
|
+
const SCOPE = /^@[^/]+\//u;
|
|
15
|
+
const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
|
|
16
|
+
/** @internal */
|
|
17
|
+
const patternOf = (names) => {
|
|
18
|
+
const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
|
|
19
|
+
return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
|
|
20
|
+
};
|
|
21
|
+
const namedIn = (basename) => ({ directory, packageName }) => {
|
|
22
|
+
const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
|
|
23
|
+
return {
|
|
24
|
+
directory,
|
|
25
|
+
names: pipe([
|
|
26
|
+
Option.some(directory),
|
|
27
|
+
Option.some(basename(directory)),
|
|
28
|
+
packageName,
|
|
29
|
+
unscoped
|
|
30
|
+
], Array.getSomes, Array.dedupe),
|
|
31
|
+
packageName
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** @internal */
|
|
35
|
+
const namedWorkspaces = Effect.fn("namedWorkspaces")(function* namedWorkspaces(root) {
|
|
36
|
+
const files = yield* RepositoryFiles;
|
|
37
|
+
const projects = yield* workspaceProjects(root);
|
|
38
|
+
return pipe(projects, Array.map(namedIn((directory) => files.basename(directory))));
|
|
39
|
+
});
|
|
40
|
+
// src/shared/lib/path-existence.ts
|
|
41
|
+
const WILDCARD = /[*?[]/u;
|
|
42
|
+
const SEPARATOR$3 = "/";
|
|
43
|
+
const FIRST = 0;
|
|
44
|
+
/** @internal */
|
|
45
|
+
const existsAt = Effect.fn("existsAt")(function* existsAt(root, path) {
|
|
46
|
+
const files = yield* RepositoryFiles;
|
|
47
|
+
return yield* files.exists(files.join(root, path));
|
|
48
|
+
});
|
|
49
|
+
/** @internal */
|
|
50
|
+
const isDirectoryAt = Effect.fn("isDirectoryAt")(function* isDirectoryAt(root, path) {
|
|
51
|
+
const files = yield* RepositoryFiles;
|
|
52
|
+
const directory = yield* files.isDirectory(files.join(root, path));
|
|
53
|
+
return Option.getOrElse(directory, () => false);
|
|
54
|
+
});
|
|
55
|
+
/** @internal */
|
|
56
|
+
const staticPrefix = (path) => {
|
|
57
|
+
const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD));
|
|
58
|
+
if (String$1.endsWith(SEPARATOR$3)(prefix)) return String$1.slice(FIRST, -1)(prefix);
|
|
59
|
+
return prefix;
|
|
60
|
+
};
|
|
61
|
+
/** @internal */
|
|
62
|
+
const isIgnored = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
63
|
+
const prefix = staticPrefix(path);
|
|
64
|
+
if (String$1.isEmpty(prefix)) return false;
|
|
65
|
+
const ignored = yield* (yield* RepositoryFiles).ignoredPaths(root, [prefix, `${prefix}${SEPARATOR$3}`]);
|
|
66
|
+
return Array.isReadonlyArrayNonEmpty(ignored);
|
|
67
|
+
});
|
|
68
|
+
// src/features/guard-workflows/model/yaml.ts
|
|
69
|
+
const rootOf = ({ source }) => Option.fromNullishOr(source.yaml);
|
|
70
|
+
const stringOf = (node) => pipe(node, Option.filter(({ kind }) => kind === "scalar"), Option.map(({ value, line, column }) => ({
|
|
71
|
+
text: value,
|
|
72
|
+
line,
|
|
73
|
+
column
|
|
74
|
+
})));
|
|
75
|
+
const childOf = (key) => (node) => pipe(node, Option.flatMap(valueAt(key)));
|
|
76
|
+
const keyNodeOf = (key) => (node) => pipe(node, Option.flatMap((mapping) => pipe(pairsOf(mapping), Array.findFirst((pair) => pair.key.value === key), Option.map((pair) => pair.key))));
|
|
77
|
+
const itemsOf = (node) => pipe(node, Option.filter(({ kind }) => kind === "sequence"), Option.map(({ children }) => children), Option.getOrElse(() => []));
|
|
78
|
+
const entriesOf = (node) => pipe(node, Option.map(pairsOf), Option.getOrElse(() => []), Array.map((pair) => [pair.key.value, pair.value]));
|
|
79
|
+
const scalarsIn = (node) => {
|
|
80
|
+
if (node.kind === "scalar") return [{
|
|
81
|
+
text: node.value,
|
|
82
|
+
line: node.line,
|
|
83
|
+
column: node.column
|
|
84
|
+
}];
|
|
85
|
+
return pipe(node.children, Array.flatMap((child) => scalarsIn(child)));
|
|
86
|
+
};
|
|
87
|
+
const ownValuesNamed = (name, node) => {
|
|
88
|
+
if (node.kind !== "mapping") return [];
|
|
89
|
+
return pipe(pairsOf(node), Array.filter((pair) => pair.key.value === name), Array.map((pair) => pair.value));
|
|
90
|
+
};
|
|
91
|
+
const valuesNamed = (name) => (node) => [...ownValuesNamed(name, node), ...pipe(node.children, Array.flatMap(valuesNamed(name)))];
|
|
92
|
+
const descend = (...keys) => (node) => {
|
|
93
|
+
let found = node;
|
|
94
|
+
for (const key of keys) found = pipe(found, childOf(key));
|
|
95
|
+
return found;
|
|
96
|
+
};
|
|
97
|
+
// src/features/guard-workflows/model/publish-trigger.ts
|
|
98
|
+
const PUBLISH = /\bmsch\s+publish\s+(?:plan|npm|release)\b/u;
|
|
99
|
+
const MANUAL = "workflow_dispatch";
|
|
100
|
+
const TRIGGER_KEY = "on";
|
|
101
|
+
const MESSAGE$5 = "publishes with `msch publish plan`, `npm` or `release` from a trigger other than `workflow_dispatch`. Keep those steps in a workflow that only `workflow_dispatch` starts, and start it on a push to main with `msch publish dispatch`.";
|
|
102
|
+
const triggersOf = (node) => {
|
|
103
|
+
if (node.kind === "scalar") return [node.value];
|
|
104
|
+
if (node.kind === "sequence") return pipe(node.children, Array.map(({ value }) => value));
|
|
105
|
+
return keysOf(node);
|
|
106
|
+
};
|
|
107
|
+
/** @internal */
|
|
108
|
+
const publishTrigger = workflowRule({
|
|
109
|
+
description: "Reports msch publish steps in a workflow that something other than workflow_dispatch starts",
|
|
110
|
+
visitor: (fail, context) => {
|
|
111
|
+
const publishing = [];
|
|
112
|
+
return {
|
|
113
|
+
...NOOP,
|
|
114
|
+
step: (step) => {
|
|
115
|
+
if (pipe(runOf(step), Option.flatMap(({ run }) => Option.fromNullishOr(run)), Option.exists(({ value }) => PUBLISH.test(value)))) publishing.push(MANUAL);
|
|
116
|
+
},
|
|
117
|
+
workflowPost: () => {
|
|
118
|
+
const root = rootOf(context);
|
|
119
|
+
const triggers = pipe(childOf(TRIGGER_KEY)(root), Option.map(triggersOf), Option.getOrElse(() => []));
|
|
120
|
+
const manualOnly = pipe(triggers, Array.every((trigger) => trigger === MANUAL));
|
|
121
|
+
if (Array.isReadonlyArrayNonEmpty(publishing) && !manualOnly) for (const key of pipe(root, keyNodeOf(TRIGGER_KEY), Option.toArray)) fail(key, MESSAGE$5);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// src/features/guard-workflows/model/release-please.ts
|
|
127
|
+
const RELEASE_PLEASE = /^googleapis\/release-please-action(?:@|$)/u;
|
|
128
|
+
const MESSAGE$4 = "releases with release-please. Releases are manual: bump the version in a PR, then run the publish workflow, which runs `msch publish` for the workspace.";
|
|
129
|
+
/** @internal */
|
|
130
|
+
const releasePlease = workflowRule({
|
|
131
|
+
description: "Reports the release-please action, because releases here are manual",
|
|
132
|
+
visitor: (fail) => ({
|
|
133
|
+
...NOOP,
|
|
134
|
+
step: (step) => {
|
|
135
|
+
const uses = pipe(actionOf(step), Option.flatMap(({ uses: text }) => Option.fromNullishOr(text)), Option.filter(({ value }) => RELEASE_PLEASE.test(value)), Option.toArray);
|
|
136
|
+
for (const found of uses) fail(found, MESSAGE$4);
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
// src/features/guard-workflows/model/workflow-commit.ts
|
|
141
|
+
const GIT_WRITE = /\bgit\s+(?:-{1,2}\S+\s+(?:\S+\s+)?)*(?:commit|push)\b/u;
|
|
142
|
+
const COMMIT_ACTION = /^[^@/]+\/[^@]*(?:commit|push)[^@]*(?:@|$)/iu;
|
|
143
|
+
const MESSAGE$3 = "commits or pushes from a workflow. A bot commit leaves generated files out of review and races the next push. Regenerate the files in a commit hook (for example `.vite-hooks/pre-commit`) so they land in the author's commit, and let CI only check that they are current.";
|
|
144
|
+
/** @internal */
|
|
145
|
+
const workflowCommit = workflowRule({
|
|
146
|
+
description: "Reports git commit, git push and commit actions in a workflow",
|
|
147
|
+
visitor: (fail) => ({
|
|
148
|
+
...NOOP,
|
|
149
|
+
step: (step) => {
|
|
150
|
+
const writes = pipe(runOf(step), Option.flatMap((exec) => Option.zipRight(Option.filter(Option.fromNullishOr(exec.run), ({ value }) => GIT_WRITE.test(value)), Option.orElse(Option.fromNullishOr(exec.runPosition), () => Option.fromNullishOr(exec.run)))));
|
|
151
|
+
const commits = pipe(actionOf(step), Option.flatMap(({ uses }) => Option.fromNullishOr(uses)), Option.filter(({ value }) => COMMIT_ACTION.test(value)));
|
|
152
|
+
for (const found of Option.toArray(Option.orElse(writes, () => commits))) fail(found, MESSAGE$3);
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
// src/features/guard-workflows/model/repository-services.ts
|
|
157
|
+
const runtime = ManagedRuntime.make(Layer.provide(nodeRepositoryFiles, nodeServicesLayer));
|
|
158
|
+
/** @internal */
|
|
159
|
+
const inRepository = (effect) => Effect.promise(() => runtime.runPromise(effect));
|
|
160
|
+
// src/features/guard-workflows/model/workflow-references.ts
|
|
161
|
+
const ROOT = ".";
|
|
162
|
+
const LOCAL = "./";
|
|
163
|
+
const NEGATION = "!";
|
|
164
|
+
const SEPARATOR$2 = "/";
|
|
165
|
+
const LINE = "\n";
|
|
166
|
+
const UNRESOLVED_MARKERS = [
|
|
167
|
+
"${{",
|
|
168
|
+
"$",
|
|
169
|
+
"{"
|
|
170
|
+
];
|
|
171
|
+
const ABSOLUTE_MARKERS = ["/", "~"];
|
|
172
|
+
const FILE_INPUT_SUFFIX = "-file";
|
|
173
|
+
const DEPENDENCY_PATH_INPUT = "cache-dependency-path";
|
|
174
|
+
const FILTER_KEYS$1 = ["paths", "paths-ignore"];
|
|
175
|
+
const HASH_FILES = /hashFiles\((?<arguments>[^)]*)\)/gu;
|
|
176
|
+
const QUOTED$1 = /'(?<path>[^']*)'/gu;
|
|
177
|
+
const SCRIPT = /^[\w.@/-]+\.(?:ts|mts|cts|sh)$/u;
|
|
178
|
+
const TOKEN_SEPARATOR = /[\s;&|()<>"'`=]+/u;
|
|
179
|
+
const ACTION_DEFINITIONS = ["action.yml", "action.yaml"];
|
|
180
|
+
const containsAny = (markers) => (path) => pipe(markers, Array.some((marker) => String$1.includes(marker)(path)));
|
|
181
|
+
const startsWithAny = (markers) => (path) => pipe(markers, Array.some((marker) => String$1.startsWith(marker)(path)));
|
|
182
|
+
const isLiteralPath = (path) => String$1.isNonEmpty(path) && !containsAny(UNRESOLVED_MARKERS)(path) && !startsWithAny(ABSOLUTE_MARKERS)(path);
|
|
183
|
+
const withoutLocal = (path) => {
|
|
184
|
+
if (String$1.startsWith(LOCAL)(path)) return String$1.slice(2)(path);
|
|
185
|
+
return path;
|
|
186
|
+
};
|
|
187
|
+
const joinPath = (base, path) => {
|
|
188
|
+
const relative = withoutLocal(String$1.trim(path));
|
|
189
|
+
if (base === ROOT) return relative;
|
|
190
|
+
return `${base}${SEPARATOR$2}${relative}`;
|
|
191
|
+
};
|
|
192
|
+
const reference = (kind, field, base = ROOT) => ({ text, line, column }) => {
|
|
193
|
+
const path = String$1.trim(text);
|
|
194
|
+
if (!isLiteralPath(path) || !isLiteralPath(base)) return [];
|
|
195
|
+
return [{
|
|
196
|
+
kind,
|
|
197
|
+
field,
|
|
198
|
+
path: joinPath(base, path),
|
|
199
|
+
text,
|
|
200
|
+
line,
|
|
201
|
+
column
|
|
202
|
+
}];
|
|
203
|
+
};
|
|
204
|
+
const isPositive = ({ text }) => !String$1.startsWith(NEGATION)(String$1.trim(text));
|
|
205
|
+
const globsIn = (field, node) => pipe(itemsOf(node), Array.flatMap((item) => pipe(item, Option.some, stringOf, Option.toArray)), Array.filter(isPositive), Array.flatMap(reference("glob", field)));
|
|
206
|
+
const filtersOf$1 = ([event, filters]) => pipe(FILTER_KEYS$1, Array.flatMap((key) => globsIn(`on.${event}.${key}`, pipe(filters, Option.some, childOf(key)))));
|
|
207
|
+
const workingDirectoryOf = (owner) => pipe(owner, descend("defaults", "run", "working-directory"), stringOf);
|
|
208
|
+
const directoryOf = (found, base) => pipe(found, Option.map(({ text }) => joinPath(ROOT, text)), Option.getOrElse(() => base));
|
|
209
|
+
const located = (kind, field, base = ROOT) => (found) => pipe(found, Option.toArray, Array.flatMap(reference(kind, field, base)));
|
|
210
|
+
const localUses = (node) => pipe(node, childOf("uses"), stringOf, Option.filter(({ text }) => String$1.startsWith(LOCAL)(text)));
|
|
211
|
+
const scriptsIn = (field, base) => ({ text, line, column }) => pipe(String$1.split(text, TOKEN_SEPARATOR), Array.filter((token) => SCRIPT.test(token)), Array.dedupe, Array.flatMap((token) => pipe({
|
|
212
|
+
text: token,
|
|
213
|
+
line,
|
|
214
|
+
column
|
|
215
|
+
}, reference("script", field, base))));
|
|
216
|
+
const isFileInput = ([key]) => String$1.endsWith(FILE_INPUT_SUFFIX)(key) || key === DEPENDENCY_PATH_INPUT;
|
|
217
|
+
const linesOf = ({ text, line, column }) => pipe(String$1.split(text, LINE), Array.map((each) => ({
|
|
218
|
+
text: each,
|
|
219
|
+
line,
|
|
220
|
+
column
|
|
221
|
+
})));
|
|
222
|
+
const fileInputOf = (field) => ([key, value]) => pipe(value, Option.some, stringOf, Option.toArray, Array.flatMap(linesOf), Array.flatMap(reference("glob", `${field}.with.${key}`)));
|
|
223
|
+
const fileInputsIn = (field, step) => pipe(step, Option.some, childOf("with"), entriesOf, Array.filter(isFileInput), Array.flatMap(fileInputOf(field)));
|
|
224
|
+
const scriptReferencesOf = (field, directory, step) => pipe(step, Option.some, childOf("run"), stringOf, Option.toArray, Array.flatMap(scriptsIn(`${field}.run`, directory)));
|
|
225
|
+
const stepReferences = (job, base) => (step, index) => {
|
|
226
|
+
const field = `jobs.${job}.steps[${index}]`;
|
|
227
|
+
const own = pipe(step, Option.some, childOf("working-directory"), stringOf);
|
|
228
|
+
const directory = directoryOf(own, base);
|
|
229
|
+
return [
|
|
230
|
+
...pipe(step, Option.some, localUses, located("action", `${field}.uses`)),
|
|
231
|
+
...pipe(own, located("directory", `${field}.working-directory`)),
|
|
232
|
+
...scriptReferencesOf(field, directory, step),
|
|
233
|
+
...fileInputsIn(field, step)
|
|
234
|
+
];
|
|
235
|
+
};
|
|
236
|
+
const jobReferences = (base) => ([job, node]) => {
|
|
237
|
+
const own = pipe(node, Option.some, workingDirectoryOf);
|
|
238
|
+
const steps = pipe(node, Option.some, childOf("steps"), itemsOf);
|
|
239
|
+
const directory = directoryOf(own, base);
|
|
240
|
+
return [
|
|
241
|
+
...pipe(node, Option.some, localUses, located("file", `jobs.${job}.uses`)),
|
|
242
|
+
...pipe(own, located("directory", `jobs.${job}.defaults.run.working-directory`)),
|
|
243
|
+
...pipe(steps, Array.flatMap(stepReferences(job, directory)))
|
|
244
|
+
];
|
|
245
|
+
};
|
|
246
|
+
const groupsOf = (pattern, group) => ({ text, line, column }) => pipe(Array.fromIterable(String$1.matchAll(pattern)(text)), Array.flatMap((match) => pipe(Option.fromNullishOr(match.groups), Option.flatMap((groups) => Option.fromNullishOr(groups[group])), Option.toArray)), Array.map((value) => ({
|
|
247
|
+
text: value,
|
|
248
|
+
line,
|
|
249
|
+
column
|
|
250
|
+
})));
|
|
251
|
+
const hashFilesIn = (root) => pipe(scalarsIn(root), Array.flatMap(groupsOf(HASH_FILES, "arguments")), Array.flatMap(groupsOf(QUOTED$1, "path")), Array.filter(isPositive), Array.flatMap(reference("glob", "hashFiles")));
|
|
252
|
+
const jobsOf = (root) => pipe(root, Option.some, childOf("jobs"), entriesOf);
|
|
253
|
+
/** @internal */
|
|
254
|
+
const workflowReferences = (root) => {
|
|
255
|
+
const workflowDefault = pipe(root, Option.some, workingDirectoryOf);
|
|
256
|
+
const base = directoryOf(workflowDefault, ROOT);
|
|
257
|
+
return [
|
|
258
|
+
...pipe(root, Option.some, childOf("on"), entriesOf, Array.flatMap(filtersOf$1)),
|
|
259
|
+
...pipe(workflowDefault, located("directory", "defaults.run.working-directory")),
|
|
260
|
+
...pipe(jobsOf(root), Array.flatMap(jobReferences(base))),
|
|
261
|
+
...hashFilesIn(root)
|
|
262
|
+
];
|
|
263
|
+
};
|
|
264
|
+
const outputPathsOf = (step) => pipe(step, Option.some, descend("with", "path"), stringOf, Option.toArray, Array.flatMap(linesOf), Array.map(({ text }) => joinPath(ROOT, text)), Array.filter(isLiteralPath));
|
|
265
|
+
/** @internal */
|
|
266
|
+
const producedPaths = (root) => pipe(jobsOf(root), Array.flatMap(([, job]) => pipe(job, Option.some, childOf("steps"), itemsOf)), Array.flatMap(outputPathsOf));
|
|
267
|
+
// src/features/guard-workflows/model/workflow-package.ts
|
|
268
|
+
const WORKFLOW = /(?:^|\/)\.github\/workflows\/(?<name>[^/]+)\.ya?ml$/u;
|
|
269
|
+
const ACTION = /(?:^|\/)\.github\/actions\/(?<name>[^/]+)\/action\.ya?ml$/u;
|
|
270
|
+
const PACKAGE_FILTER = /(?:^|\s)(?:--filter|-F)(?:\s+|=)(?<quote>["']?)(?<value>[^\s"'$][^\s"']*)\k<quote>/gu;
|
|
271
|
+
const SEPARATOR$1 = "/";
|
|
272
|
+
const WORD_SEPARATORS = /[-_]/gu;
|
|
273
|
+
const SPACE = " ";
|
|
274
|
+
const FIRST_LINE = {
|
|
275
|
+
text: "",
|
|
276
|
+
line: 1,
|
|
277
|
+
column: 1
|
|
278
|
+
};
|
|
279
|
+
const packageMessage = (what, directory) => `${what} names the workspace ${directory}. A workflow or job made for one package does not scale: give the package a vp task and let the generic pipeline (verify, deploy, release, daily, task) find it.`;
|
|
280
|
+
const matching = (workspaces, text) => pipe(workspaces, Array.findFirst(({ names }) => Array.isReadonlyArrayNonEmpty(names) && Option.isSome(String$1.match(patternOf(names))(text))), Option.map(({ directory }) => directory));
|
|
281
|
+
const named = (workspaces, text) => Option.orElse(matching(workspaces, text), () => matching(workspaces, String$1.replaceAll(WORD_SEPARATORS, SPACE)(text)));
|
|
282
|
+
const containing = (workspaces, path) => pipe(workspaces, Array.findFirst(({ directory }) => path === directory || String$1.startsWith(`${directory}${SEPARATOR$1}`)(path)), Option.map(({ directory }) => directory));
|
|
283
|
+
const filtersIn = (scalars) => pipe(scalars, Array.flatMap(({ text, line, column }) => pipe(Array.fromIterable(String$1.matchAll(PACKAGE_FILTER)(text)), Array.flatMap((match) => pipe(Option.fromNullishOr(match.groups), Option.flatMap((groups) => Option.fromNullishOr(groups["value"])), Option.toArray)), Array.map((value) => ({
|
|
284
|
+
text: value,
|
|
285
|
+
line,
|
|
286
|
+
column
|
|
287
|
+
})))));
|
|
288
|
+
const findingFor = (what, found, directory) => pipe(directory, Option.map((workspace) => ({
|
|
289
|
+
line: found.line,
|
|
290
|
+
column: found.column,
|
|
291
|
+
message: packageMessage(what, workspace)
|
|
292
|
+
})), Option.toArray);
|
|
293
|
+
const namesIn = (stem, root) => [
|
|
294
|
+
{
|
|
295
|
+
...FIRST_LINE,
|
|
296
|
+
text: stem
|
|
297
|
+
},
|
|
298
|
+
...pipe(root, childOf("name"), stringOf, Option.toArray),
|
|
299
|
+
...pipe(root, childOf("jobs"), Option.map((jobs) => pipe(pairsOf(jobs), Array.map(({ key }) => ({
|
|
300
|
+
text: key.value,
|
|
301
|
+
line: key.line,
|
|
302
|
+
column: key.column
|
|
303
|
+
})))), Option.getOrElse(() => []))
|
|
304
|
+
];
|
|
305
|
+
const workflowFindings = (workspaces, stem, root) => {
|
|
306
|
+
const fromNames = pipe(namesIn(stem, Option.some(root)), Array.flatMap((found) => findingFor(`"${found.text}"`, found, named(workspaces, found.text))));
|
|
307
|
+
const referenced = pipe(workflowReferences(root), Array.filter(({ field }) => !String$1.startsWith("on.")(field)), Array.flatMap((found) => findingFor(found.field, found, containing(workspaces, found.path))));
|
|
308
|
+
const filtered = pipe(filtersIn(scalarsIn(root)), Array.flatMap((found) => findingFor(`--filter ${found.text}`, found, matching(workspaces, found.text))));
|
|
309
|
+
return [
|
|
310
|
+
...fromNames,
|
|
311
|
+
...referenced,
|
|
312
|
+
...filtered
|
|
313
|
+
];
|
|
314
|
+
};
|
|
315
|
+
const workflowPackage = defineRule({
|
|
316
|
+
meta: {
|
|
317
|
+
description: "Reports workflows, jobs, actions and paths that are made for one workspace",
|
|
318
|
+
kinds: ["workflow", "action"]
|
|
319
|
+
},
|
|
320
|
+
check: ({ filename, project, source, report }) => Effect.gen(function* checkPackages() {
|
|
321
|
+
const workspaces = yield* namedWorkspaces(project.root);
|
|
322
|
+
const asWorkflow = groupOf("name")(WORKFLOW.exec(filename));
|
|
323
|
+
const asAction = groupOf("name")(ACTION.exec(filename));
|
|
324
|
+
const found = [...pipe(asAction, Option.flatMap((name) => named(workspaces, name)), Option.map((directory) => ({
|
|
325
|
+
...FIRST_LINE,
|
|
326
|
+
message: packageMessage(`The action ${Option.getOrElse(asAction, () => "")}`, directory)
|
|
327
|
+
})), Option.toArray), ...pipe(Option.all([asWorkflow, Option.fromNullishOr(source.yaml)]), Option.map(([stem, root]) => workflowFindings(workspaces, stem, root)), Option.getOrElse(() => []))];
|
|
328
|
+
for (const each of found) report(each);
|
|
329
|
+
}).pipe(inRepository)
|
|
330
|
+
});
|
|
331
|
+
// src/features/guard-workflows/model/workflow-path-filter.ts
|
|
332
|
+
const FILTER_KEYS = ["paths", "paths-ignore"];
|
|
333
|
+
const PATHS_FILTER_ACTION = /(?:^|\/)paths-filter@/u;
|
|
334
|
+
const MESSAGE$2 = "A workflow that reacts to changes under listed paths needs a new entry for every package and drifts from the packages it is meant to cover. Run the generic pipeline on every push and let it decide from the workspace what changed.";
|
|
335
|
+
/** @internal */
|
|
336
|
+
const workflowPathFilter = defineRule({
|
|
337
|
+
meta: {
|
|
338
|
+
description: "Reports paths and paths-ignore triggers and the paths-filter action",
|
|
339
|
+
kinds: ["workflow"]
|
|
340
|
+
},
|
|
341
|
+
check: (context) => {
|
|
342
|
+
const root = rootOf(context);
|
|
343
|
+
const triggers = pipe(root, childOf("on"), entriesOf, Array.flatMap(([, trigger]) => pipe(FILTER_KEYS, Array.flatMap((key) => pipe(Option.some(trigger), keyNodeOf(key), Option.toArray)))));
|
|
344
|
+
const actions = pipe(Option.toArray(root), Array.flatMap((node) => scalarsIn(node)), Array.filter(({ text }) => PATHS_FILTER_ACTION.test(text)));
|
|
345
|
+
for (const found of [...triggers, ...actions]) context.report({
|
|
346
|
+
line: found.line,
|
|
347
|
+
column: found.column,
|
|
348
|
+
message: MESSAGE$2
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
// src/features/guard-workflows/model/workflow-path.ts
|
|
353
|
+
const SEPARATOR = "/";
|
|
354
|
+
const EXPECTED = {
|
|
355
|
+
action: "a directory with action.yml",
|
|
356
|
+
directory: "a directory",
|
|
357
|
+
file: "a file",
|
|
358
|
+
glob: "a pattern that matches a tracked file",
|
|
359
|
+
script: "a file"
|
|
360
|
+
};
|
|
361
|
+
const matchesAny = Effect.fn("matchesAny")(function* matchesAny(root, pathspecs) {
|
|
362
|
+
const matched = yield* (yield* RepositoryFiles).matchingFiles(root, pathspecs);
|
|
363
|
+
return Array.isReadonlyArrayNonEmpty(matched);
|
|
364
|
+
});
|
|
365
|
+
const matchesGlob = (root, path) => matchesAny(root, [`:(glob)${path}`]);
|
|
366
|
+
const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
|
|
367
|
+
const found = yield* Effect.forEach(ACTION_DEFINITIONS, (name) => existsAt(root, `${path}${SEPARATOR}${name}`), { concurrency: 1 });
|
|
368
|
+
return pipe(found, Array.some(Boolean));
|
|
369
|
+
});
|
|
370
|
+
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR))}`;
|
|
371
|
+
const RESOLVERS = {
|
|
372
|
+
action: hasAction,
|
|
373
|
+
directory: isDirectoryAt,
|
|
374
|
+
file: existsAt,
|
|
375
|
+
glob: matchesGlob,
|
|
376
|
+
script: Effect.fn("findsScript")(function* findsScript(root, path) {
|
|
377
|
+
if (yield* existsAt(root, path)) return true;
|
|
378
|
+
const segments = String$1.split(path, SEPARATOR);
|
|
379
|
+
return yield* matchesAny(root, Array.makeBy(segments.length, suffixAt(segments)));
|
|
380
|
+
})
|
|
381
|
+
};
|
|
382
|
+
const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR}`)(produced) || String$1.startsWith(`${produced}${SEPARATOR}`)(path);
|
|
383
|
+
const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, found) {
|
|
384
|
+
const prefix = staticPrefix(found.path);
|
|
385
|
+
if (pipe(produced, Array.some(overlaps(prefix)))) return false;
|
|
386
|
+
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
387
|
+
return !(yield* isIgnored(root, found.path));
|
|
388
|
+
});
|
|
389
|
+
const workflowPath = defineRule({
|
|
390
|
+
meta: {
|
|
391
|
+
description: "Reports a path that a workflow names and the repository does not have",
|
|
392
|
+
kinds: ["workflow"]
|
|
393
|
+
},
|
|
394
|
+
check: ({ project, source, report }) => Effect.gen(function* checkPaths() {
|
|
395
|
+
for (const yaml of Option.toArray(Option.fromNullishOr(source.yaml))) {
|
|
396
|
+
const produced = producedPaths(yaml);
|
|
397
|
+
const missing = yield* Effect.filter(workflowReferences(yaml), (found) => isMissing(project.root, produced, found));
|
|
398
|
+
for (const found of missing) report({
|
|
399
|
+
line: found.line,
|
|
400
|
+
column: found.column,
|
|
401
|
+
message: `${found.field} names ${found.path}, which is not ${EXPECTED[found.kind]} in this repository. Point it at a path that exists or remove it.`
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}).pipe(inRepository)
|
|
405
|
+
});
|
|
406
|
+
// src/features/guard-workflows/model/workflow-queue.ts
|
|
407
|
+
const CONCURRENCY_KEY = "concurrency";
|
|
408
|
+
const QUEUE_KEY = "queue";
|
|
409
|
+
const MESSAGE$1 = "queues runs with `queue`. A queued group runs every old push one by one, so a long run holds back the newest commit for hours. Drop `queue`: a job that later pushes redo gets `cancel-in-progress: true`, and a deploy or release job keeps the default, which lets the running one finish and replaces the waiting one with the newest run.";
|
|
410
|
+
/** @internal */
|
|
411
|
+
const workflowQueue = defineRule({
|
|
412
|
+
meta: {
|
|
413
|
+
description: "Reports queue on a concurrency group, because a queued group holds back the newest commit",
|
|
414
|
+
kinds: ["workflow"]
|
|
415
|
+
},
|
|
416
|
+
check: (context) => {
|
|
417
|
+
const keys = pipe(rootOf(context), Option.toArray, Array.flatMap((root) => valuesNamed(CONCURRENCY_KEY)(root)), Array.filter((group) => Array.contains(keysOf(group), QUEUE_KEY)), Array.flatMap((group) => pipe(Option.some(group), keyNodeOf(QUEUE_KEY), Option.toArray)));
|
|
418
|
+
for (const key of keys) context.report({
|
|
419
|
+
line: key.line,
|
|
420
|
+
column: key.column,
|
|
421
|
+
message: MESSAGE$1
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
// src/features/guard-workflows/model/workflow-script.ts
|
|
426
|
+
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
427
|
+
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
428
|
+
const COMMENT = "#";
|
|
429
|
+
const ONE_COMMAND = 1;
|
|
430
|
+
const MESSAGE = "runs more than one command. Keep a step to one command, `vp run <task>` or `vp exec <bin>`, and put the logic in a Vite+ task in TypeScript.";
|
|
431
|
+
const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
|
|
432
|
+
const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED, "")(line));
|
|
433
|
+
const runsMoreThanOneCommand = (text) => {
|
|
434
|
+
const lines = pipe(String$1.split("\n")(text), Array.map(String$1.trim), Array.filter(isCommand));
|
|
435
|
+
return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
|
|
436
|
+
};
|
|
437
|
+
/** @internal */
|
|
438
|
+
const workflowScript = workflowRule({
|
|
439
|
+
description: "Reports a run step with more than one command, because the logic belongs in a task",
|
|
440
|
+
visitor: (fail) => ({
|
|
441
|
+
...NOOP,
|
|
442
|
+
step: (step) => {
|
|
443
|
+
const runs = pipe(runOf(step), Option.flatMap(({ run }) => Option.fromNullishOr(run)), Option.filter(({ value }) => runsMoreThanOneCommand(value)), Option.toArray);
|
|
444
|
+
for (const found of runs) fail(found, MESSAGE);
|
|
445
|
+
}
|
|
446
|
+
})
|
|
447
|
+
});
|
|
448
|
+
// src/features/guard-workflows/model/policy.ts
|
|
449
|
+
const NAME = "msch";
|
|
450
|
+
const plugin = definePlugin({ rules: {
|
|
451
|
+
"publish-trigger": publishTrigger,
|
|
452
|
+
"release-please": releasePlease,
|
|
453
|
+
"workflow-commit": workflowCommit,
|
|
454
|
+
"workflow-package": workflowPackage,
|
|
455
|
+
"workflow-path": workflowPath,
|
|
456
|
+
"workflow-path-filter": workflowPathFilter,
|
|
457
|
+
"workflow-queue": workflowQueue,
|
|
458
|
+
"workflow-script": workflowScript
|
|
459
|
+
} });
|
|
460
|
+
/** @internal */
|
|
461
|
+
const workflowPolicy = () => ({
|
|
462
|
+
plugins: Record.singleton(NAME, plugin),
|
|
463
|
+
rules: pipe(Record.keys(plugin.rules), Array.map((rule) => [`${NAME}/${rule}`, "error"]), Record.fromEntries)
|
|
464
|
+
});
|
|
465
|
+
// src/features/guard-workflows/model/fu4-config.ts
|
|
466
|
+
/** @internal */
|
|
467
|
+
const fu4Of = () => ({ extends: [recommended(), workflowPolicy()] });
|
|
468
|
+
// src/app/repository-dependencies.ts
|
|
469
|
+
const allowedIn = (allowances, fields) => pipe(allowances, Record.map(({ workspaces, dependencies }) => ({
|
|
470
|
+
workspaces,
|
|
471
|
+
dependencies,
|
|
472
|
+
fields: [...fields]
|
|
473
|
+
})));
|
|
474
|
+
const PLUGIN_DEPENDENCIES = "Claude Code installs a plugin's dependencies from its own package.json and lockfile, where only exact registry versions install";
|
|
475
|
+
const dependencyRulesOf = (workspace) => ({
|
|
476
|
+
allowed: {
|
|
477
|
+
...allowedIn(workspace.devDependencies, ["devDependencies"]),
|
|
478
|
+
...allowedIn(workspace.dependencies, RUNTIME_SECTIONS)
|
|
479
|
+
},
|
|
480
|
+
banned: requiredStack,
|
|
481
|
+
exactDependencies: { [PLUGIN_DEPENDENCIES]: workspace.plugins },
|
|
482
|
+
peerRanges: "intersect"
|
|
483
|
+
});
|
|
484
|
+
// src/app/repository-tasks.ts
|
|
485
|
+
const NOT_INPUTS = [
|
|
486
|
+
"!node_modules/.pnpm-store",
|
|
487
|
+
"!node_modules/.pnpm-store/**",
|
|
488
|
+
"!node_modules/.tmp",
|
|
489
|
+
"!node_modules/.tmp/**",
|
|
490
|
+
"!target/**",
|
|
491
|
+
"!node_modules/.vitest-cache/**",
|
|
492
|
+
"!node_modules/.cache/**"
|
|
493
|
+
];
|
|
494
|
+
const UNTRACKED_ENV = [
|
|
495
|
+
"CLOUDFLARE_ACCOUNT_ID",
|
|
496
|
+
"CLOUDFLARE_AI_GATEWAY_ID",
|
|
497
|
+
"CLOUDFLARE_API_TOKEN",
|
|
498
|
+
"CLAUDECODE",
|
|
499
|
+
"CLAUDE_CODE_REMOTE",
|
|
500
|
+
"GITHUB_ACTIONS",
|
|
501
|
+
"HTTPS_PROXY",
|
|
502
|
+
"https_proxy",
|
|
503
|
+
"NO_PROXY",
|
|
504
|
+
"no_proxy",
|
|
505
|
+
"SSL_CERT_FILE",
|
|
506
|
+
"NODE_EXTRA_CA_CERTS"
|
|
507
|
+
];
|
|
508
|
+
const FALLOW = pipe([
|
|
509
|
+
"--skip dupes --fail-on-issues --quiet --format compact",
|
|
510
|
+
"dead-code --no-production --fail-on-issues --quiet --format compact",
|
|
511
|
+
"dead-code --no-production --quiet --format json | jq -n 'input | {prop_drilling_chains, thin_wrappers, duplicate_prop_shapes} | with_entries(select(.value | length > 0)) | if length > 0 then halt_error else empty end'",
|
|
512
|
+
"dupes --fail-on-issues --quiet --format compact",
|
|
513
|
+
"security --fail-on-issues --quiet"
|
|
514
|
+
], Array.map((args) => `FALLOW_TYPE_AWARE_BACKEND=tsrs fallow ${args}`));
|
|
515
|
+
const CHECK = `TSRS_LINT_RUN_EXTERNAL_CODE=1 msch changed --batch-sources ${String(1e3)} -- vp check --deny-warnings --continue-on-error --no-error-on-unmatched-pattern`;
|
|
516
|
+
const COMPAT = "msch changed -- msch publish compat-changed";
|
|
517
|
+
const AUDIT = Array.join([
|
|
518
|
+
"copy=\"$(mktemp -d)\"",
|
|
519
|
+
`trap 'rm -rf "$copy"' EXIT`,
|
|
520
|
+
`for file in ${Array.join([
|
|
521
|
+
"package.json",
|
|
522
|
+
"pnpm-workspace.yaml",
|
|
523
|
+
"pnpm-lock.yaml",
|
|
524
|
+
".npmrc"
|
|
525
|
+
], " ")}; do if [ -f "$file" ]; then cp "$file" "$copy/"; fi; done`,
|
|
526
|
+
"(cd \"$copy\" && vp pm audit --fix >/dev/null) || exit",
|
|
527
|
+
`added="$(diff pnpm-workspace.yaml "$copy/pnpm-workspace.yaml" | sed -n 's/^> \\(.*\\)$/\\1 # exit: unused/p')"`,
|
|
528
|
+
"if [ -z \"$added\" ]; then exit 0; fi",
|
|
529
|
+
`printf '%s\\n' "vp pm audit --fix found vulnerable versions. First update them within their ranges with vp update -r --no-save <package>... -- --depth Infinity. For each one still reported by vp pm audit, add its line to overrides in pnpm-workspace.yaml and run vp install:" "$added" >&2`,
|
|
530
|
+
"exit 1"
|
|
531
|
+
], "; ");
|
|
532
|
+
const BROKER_TOKEN = `GH_TOKEN="\${GITHUB_APP_TOKEN:-$GH_TOKEN}"`;
|
|
533
|
+
const DAILY = `msch exits; ${BROKER_TOKEN} msch upstream; ${BROKER_TOKEN} msch callers; ${BROKER_TOKEN} msch refs; refs=$?; msch agents "\${RUNNER_TEMP:-\${TMPDIR:-/tmp}}/msch-agents" && exit "$refs"`;
|
|
534
|
+
const TEST = "msch changed -- vp test run --passWithNoTests";
|
|
535
|
+
const CARGO = "cargo fmt --all --check && cargo clippy --workspace --all-targets --locked -- -D warnings";
|
|
536
|
+
const cargoTasks = (cargo) => Option.match(cargo, {
|
|
537
|
+
onNone: () => ({}),
|
|
538
|
+
onSome: (inputs) => ({ cargo: {
|
|
539
|
+
command: CARGO,
|
|
540
|
+
cache: {
|
|
541
|
+
input: [...inputs],
|
|
542
|
+
output: [],
|
|
543
|
+
untrackedEnv: UNTRACKED_ENV
|
|
544
|
+
}
|
|
545
|
+
} })
|
|
546
|
+
});
|
|
547
|
+
const MSCH_VERIFY_COMMANDS = {
|
|
548
|
+
fallow: FALLOW,
|
|
549
|
+
check: CHECK,
|
|
550
|
+
msch: "msch",
|
|
551
|
+
audit: AUDIT,
|
|
552
|
+
published: "msch published",
|
|
553
|
+
compat: COMPAT
|
|
554
|
+
};
|
|
555
|
+
const MSCH_TASK_COMMANDS = {
|
|
556
|
+
...MSCH_VERIFY_COMMANDS,
|
|
557
|
+
test: TEST
|
|
558
|
+
};
|
|
559
|
+
const CI_TASKS = [TASK_NAMES.verify, TASK_NAMES.test];
|
|
560
|
+
const USAGE_TASK = "usage";
|
|
561
|
+
const METERED_TASKS = ["check", "msch"];
|
|
562
|
+
const meteredCommand = (command) => `USAGE_METER_SPOOL="$PWD/${USAGE_SPOOL}" ${command}`;
|
|
563
|
+
const usageCommandOf = ({ endpoint, apiKeyEnv }) => pipe(Option.fromUndefinedOr(apiKeyEnv), Option.match({
|
|
564
|
+
onNone: () => `msch usage --endpoint ${endpoint}`,
|
|
565
|
+
onSome: (name) => `msch usage --endpoint ${endpoint} --api-key-env ${name}`
|
|
566
|
+
}));
|
|
567
|
+
const commandOf = (usage) => (command) => Option.match(usage, {
|
|
568
|
+
onNone: () => command,
|
|
569
|
+
onSome: () => meteredCommand(command)
|
|
570
|
+
});
|
|
571
|
+
const usageTasks = (usage) => Option.match(usage, {
|
|
572
|
+
onNone: () => ({}),
|
|
573
|
+
onSome: (options) => ({ [USAGE_TASK]: {
|
|
574
|
+
command: usageCommandOf(options),
|
|
575
|
+
dependsOn: [...METERED_TASKS],
|
|
576
|
+
cache: false
|
|
577
|
+
} })
|
|
578
|
+
});
|
|
579
|
+
const tasksOf = ({ workspace, commands, usage, cargo }) => {
|
|
580
|
+
const inputs = [
|
|
581
|
+
{ auto: true },
|
|
582
|
+
...workspace.ignoredDirectories,
|
|
583
|
+
...NOT_INPUTS
|
|
584
|
+
];
|
|
585
|
+
const run = commandOf(usage);
|
|
586
|
+
const checks = {
|
|
587
|
+
...commands,
|
|
588
|
+
fallow: {
|
|
589
|
+
command: FALLOW,
|
|
590
|
+
cache: {
|
|
591
|
+
input: [
|
|
592
|
+
...inputs,
|
|
593
|
+
"!.fallow/**",
|
|
594
|
+
"!**/dist/**",
|
|
595
|
+
"!**/.fallow-verified"
|
|
596
|
+
],
|
|
597
|
+
output: []
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
check: {
|
|
601
|
+
command: run(CHECK),
|
|
602
|
+
cache: {
|
|
603
|
+
input: inputs,
|
|
604
|
+
untrackedEnv: UNTRACKED_ENV
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
msch: {
|
|
608
|
+
command: run(MSCH_VERIFY_COMMANDS.msch),
|
|
609
|
+
dependsOn: ["check", ...workspace.tasks.native],
|
|
610
|
+
cache: false
|
|
611
|
+
},
|
|
612
|
+
audit: {
|
|
613
|
+
command: AUDIT,
|
|
614
|
+
cache: false
|
|
615
|
+
},
|
|
616
|
+
published: {
|
|
617
|
+
command: MSCH_TASK_COMMANDS.published,
|
|
618
|
+
cache: false
|
|
619
|
+
},
|
|
620
|
+
compat: {
|
|
621
|
+
command: COMPAT,
|
|
622
|
+
dependsOn: ["msch", "fallow"],
|
|
623
|
+
cache: false
|
|
624
|
+
},
|
|
625
|
+
...cargoTasks(cargo),
|
|
626
|
+
...usageTasks(usage)
|
|
627
|
+
};
|
|
628
|
+
return {
|
|
629
|
+
...checks,
|
|
630
|
+
test: {
|
|
631
|
+
command: TEST,
|
|
632
|
+
dependsOn: ["check", ...workspace.tasks.native],
|
|
633
|
+
cache: { input: [...inputs, "!**/.cache/**"] }
|
|
634
|
+
},
|
|
635
|
+
daily: {
|
|
636
|
+
command: DAILY,
|
|
637
|
+
dependsOn: [...workspace.tasks.native],
|
|
638
|
+
cache: false
|
|
639
|
+
},
|
|
640
|
+
verify: {
|
|
641
|
+
command: [],
|
|
642
|
+
dependsOn: [...workspace.tasks.verify, ...Record.keys(checks)]
|
|
643
|
+
},
|
|
644
|
+
ci: {
|
|
645
|
+
command: [],
|
|
646
|
+
dependsOn: [...CI_TASKS, ...workspace.tasks.test]
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
const REINSTALL = "vp install";
|
|
651
|
+
const GIT_HOOKS = {
|
|
652
|
+
"pre-commit": ["vp staged", "vp exec msch --staged"],
|
|
653
|
+
"commit-msg": ["vp exec msch --commit-msg \"$1\""],
|
|
654
|
+
"pre-push": ["vp exec msch --pre-push", "vp run verify"],
|
|
655
|
+
"post-checkout": [`[ "$3" = 0 ] || ${REINSTALL}`],
|
|
656
|
+
"post-merge": [REINSTALL],
|
|
657
|
+
"post-rewrite": [REINSTALL]
|
|
658
|
+
};
|
|
659
|
+
const gitHooksOf = (hooks = {}) => ({
|
|
660
|
+
...GIT_HOOKS,
|
|
661
|
+
...hooks
|
|
662
|
+
});
|
|
663
|
+
// src/app/repository-text.ts
|
|
664
|
+
const TEXT_IGNORES = [
|
|
665
|
+
"AGENTS.md",
|
|
666
|
+
"CLAUDE.md",
|
|
667
|
+
".agents/skills/**",
|
|
668
|
+
"CHANGELOG.md",
|
|
669
|
+
...exempt
|
|
670
|
+
];
|
|
671
|
+
const ZENN_MARKDOWN = "zenn-markdown";
|
|
672
|
+
const QUOTATION = String.raw`/「(?:[^「」]|「[^「」]*」)*」|『(?:[^『』]|『[^『』]*』)*』/`;
|
|
673
|
+
const ELLIPSIS = "…";
|
|
674
|
+
const filtersOf = (properNouns) => ({
|
|
675
|
+
comments: true,
|
|
676
|
+
"node-types": { nodeTypes: ["BlockQuote"] },
|
|
677
|
+
allowlist: { allow: [QUOTATION, ...properNouns] }
|
|
678
|
+
});
|
|
679
|
+
const SENTENCE_LENGTH = 120;
|
|
680
|
+
const KANJI_RUN = 6;
|
|
681
|
+
const PUBLIC_LINES = [
|
|
682
|
+
String.raw`\bCF_BEACON_TOKEN = "[0-9a-f]{32}"`,
|
|
683
|
+
String.raw`\b\w*DISCORD_\w*ID = "[0-9]{17,20}"`,
|
|
684
|
+
String.raw`untrusted comment: minisign public key: [0-9A-F]{16}`
|
|
685
|
+
];
|
|
686
|
+
const EXEMPT_PATHS = [String.raw`(?:^|/)(?:fixtures|upstream|hooks/vendor)/`];
|
|
687
|
+
const builtRules = (style) => ({
|
|
688
|
+
"@textlint-ja/preset-ai-writing": true,
|
|
689
|
+
"@r_masseater/preset-ja": true,
|
|
690
|
+
"preset-ja-technical-writing": {
|
|
691
|
+
"sentence-length": { max: SENTENCE_LENGTH },
|
|
692
|
+
"ja-no-mixed-period": { allowPeriodMarks: [":"] },
|
|
693
|
+
"no-mix-dearu-desumasu": {
|
|
694
|
+
preferInBody: style,
|
|
695
|
+
preferInList: style
|
|
696
|
+
},
|
|
697
|
+
"max-kanji-continuous-len": { max: KANJI_RUN },
|
|
698
|
+
"ja-no-successive-word": { allow: [ELLIPSIS] }
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
const builtTextRuleNames = Record.keys(builtRules("である"));
|
|
702
|
+
const textlintOf = ({ properNouns = [], rules = {}, sources = [], articles }) => {
|
|
703
|
+
const textRules = {
|
|
704
|
+
...rules,
|
|
705
|
+
...builtRules("である")
|
|
706
|
+
};
|
|
707
|
+
const filters = filtersOf(properNouns);
|
|
708
|
+
const articleSources = Array.filter([{
|
|
709
|
+
files: [...articles],
|
|
710
|
+
plugins: { [ZENN_MARKDOWN]: true },
|
|
711
|
+
rules: {
|
|
712
|
+
...rules,
|
|
713
|
+
...builtRules("ですます")
|
|
714
|
+
},
|
|
715
|
+
filters
|
|
716
|
+
}], () => Array.isReadonlyArrayNonEmpty(articles));
|
|
717
|
+
return {
|
|
718
|
+
ignores: [...TEXT_IGNORES, ...articles],
|
|
719
|
+
presets: textlintPresets,
|
|
720
|
+
filterModules: textlintFilters,
|
|
721
|
+
pluginModules: { [ZENN_MARKDOWN]: zennMarkdown },
|
|
722
|
+
reportUnusedDirectives: true,
|
|
723
|
+
sources: pipe(sources, Array.map(({ files, plugins }) => ({
|
|
724
|
+
files: [...files],
|
|
725
|
+
plugins: { ...plugins },
|
|
726
|
+
rules: textRules,
|
|
727
|
+
filters
|
|
728
|
+
})), Array.appendAll(articleSources)),
|
|
729
|
+
filters,
|
|
730
|
+
rules: textRules
|
|
731
|
+
};
|
|
732
|
+
};
|
|
733
|
+
const anyOf = (subject) => (patterns) => {
|
|
734
|
+
if (Array.isReadonlyArrayEmpty(patterns)) return [];
|
|
735
|
+
return [`matchesAny(${subject}, [${pipe(patterns, Array.map((pattern) => `\`${pattern}\``), Array.join(", "))}])`];
|
|
736
|
+
};
|
|
737
|
+
const secretsOf = () => ({
|
|
738
|
+
extend: { path: betterleaks },
|
|
739
|
+
filter: pipe([...anyOf("finding.line")(PUBLIC_LINES), ...anyOf(`attributes["path"]`)(EXEMPT_PATHS)], Array.join(" || "))
|
|
740
|
+
});
|
|
741
|
+
// src/app/repository-config.ts
|
|
742
|
+
const cacheOf = (remoteCache) => pipe(Option.fromNullishOr(remoteCache), Option.match({
|
|
743
|
+
onNone: () => true,
|
|
744
|
+
onSome: (url) => ({
|
|
745
|
+
scripts: true,
|
|
746
|
+
tasks: true,
|
|
747
|
+
remote: { url }
|
|
748
|
+
})
|
|
749
|
+
}));
|
|
750
|
+
const COMMIT_LINT = { extends: [fileURLToPath(import.meta.resolve("@commitlint/config-conventional"))] };
|
|
751
|
+
const STAGED = { "*": "vp fmt --no-error-on-unmatched-pattern" };
|
|
752
|
+
const FORMAT = {
|
|
753
|
+
ignorePatterns: exempt,
|
|
754
|
+
sortImports: true,
|
|
755
|
+
sortTailwindcss: true,
|
|
756
|
+
sortPackageJson: true
|
|
757
|
+
};
|
|
758
|
+
const added = ({ files, excludeFiles, rules }) => pipe(Option.fromUndefinedOr(excludeFiles), Option.match({
|
|
759
|
+
onNone: () => ({
|
|
760
|
+
files: [...files],
|
|
761
|
+
rules: { ...rules }
|
|
762
|
+
}),
|
|
763
|
+
onSome: (excluded) => ({
|
|
764
|
+
files: [...files],
|
|
765
|
+
excludeFiles: [...excluded],
|
|
766
|
+
rules: { ...rules }
|
|
767
|
+
})
|
|
768
|
+
}));
|
|
769
|
+
const lintOf = ({ workspace, overrides = [] }) => ({
|
|
770
|
+
...lint$1,
|
|
771
|
+
ignorePatterns: exempt,
|
|
772
|
+
overrides: [
|
|
773
|
+
...lint$1.overrides,
|
|
774
|
+
{
|
|
775
|
+
files: [...workspace.lint.shadcnUi],
|
|
776
|
+
rules: { "react/jsx-props-no-spreading": "off" }
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
files: [
|
|
780
|
+
...workspace.lint.publicEntries,
|
|
781
|
+
...workspace.lint.deployEntries,
|
|
782
|
+
...workspace.lint.siteEntries
|
|
783
|
+
],
|
|
784
|
+
rules: { "import/no-default-export": "off" }
|
|
785
|
+
},
|
|
786
|
+
...pipe(overrides, Array.map(added)),
|
|
787
|
+
...workspace.lint.overrides,
|
|
788
|
+
{
|
|
789
|
+
files: ["**/*.test.ts"],
|
|
790
|
+
rules: decisionTestRules
|
|
791
|
+
}
|
|
792
|
+
]
|
|
793
|
+
});
|
|
794
|
+
const repositoryConfig = (options) => {
|
|
795
|
+
const { workspace, textlint = {}, markdown = {}, run = {}, usage, cargo, gitHooks } = options;
|
|
796
|
+
return {
|
|
797
|
+
commitlint: COMMIT_LINT,
|
|
798
|
+
dependencyRules: dependencyRulesOf(workspace),
|
|
799
|
+
h56m: secretsOf(),
|
|
800
|
+
wism: structureOf({
|
|
801
|
+
members: workspace.members,
|
|
802
|
+
ignorePatterns: exempt
|
|
803
|
+
}),
|
|
804
|
+
textlint: textlintOf({
|
|
805
|
+
...textlint,
|
|
806
|
+
articles: workspace.articles
|
|
807
|
+
}),
|
|
808
|
+
y8: markdownOf({
|
|
809
|
+
...markdown,
|
|
810
|
+
indexSkill: workspace.indexSkill
|
|
811
|
+
}),
|
|
812
|
+
fu4: fu4Of(),
|
|
813
|
+
test: {
|
|
814
|
+
projects: [...workspace.testProjects],
|
|
815
|
+
passWithNoTests: true
|
|
816
|
+
},
|
|
817
|
+
staged: STAGED,
|
|
818
|
+
gitHooks: gitHooksOf(gitHooks),
|
|
819
|
+
fmt: FORMAT,
|
|
820
|
+
lint: lintOf(options),
|
|
821
|
+
run: {
|
|
822
|
+
cache: cacheOf(run.remoteCache),
|
|
823
|
+
tasks: tasksOf({
|
|
824
|
+
workspace,
|
|
825
|
+
commands: run.tasks ?? {},
|
|
826
|
+
usage: Option.fromUndefinedOr(usage),
|
|
827
|
+
cargo: Option.map(Option.fromUndefinedOr(cargo), ({ inputs }) => inputs)
|
|
828
|
+
})
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
};
|
|
832
|
+
export { namedWorkspaces as _, TEXT_IGNORES as a, CI_TASKS as c, MSCH_VERIFY_COMMANDS as d, meteredCommand as f, isIgnored as g, existsAt as h, repositoryConfig as i, GIT_HOOKS as l, fu4Of as m, FORMAT as n, builtTextRuleNames as o, PLUGIN_DEPENDENCIES as p, STAGED as r, secretsOf as s, COMMIT_LINT as t, MSCH_TASK_COMMANDS as u, patternOf as v };
|
|
833
|
+
|
|
834
|
+
//# sourceMappingURL=repository-config-8JN86BZA.mjs.map
|