@r_masseater/msch 0.124.0 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +373 -262
- 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 +2 -1
- package/skills/msch-repository-config/SKILL.md +11 -8
- package/dist/config.mjs.map +0 -1
- package/dist/repository-text-DfTSvaqo.mjs +0 -322
- package/dist/repository-text-DfTSvaqo.mjs.map +0 -1
package/dist/config.d.mts
CHANGED
|
@@ -51,5 +51,17 @@ export interface RepositoryOptions {
|
|
|
51
51
|
};
|
|
52
52
|
readonly gitHooks?: GitHooksSection;
|
|
53
53
|
}
|
|
54
|
+
export declare const COMMIT_LINT: {
|
|
55
|
+
extends: string[];
|
|
56
|
+
};
|
|
57
|
+
export declare const STAGED: {
|
|
58
|
+
"*": string;
|
|
59
|
+
};
|
|
60
|
+
export declare const FORMAT: {
|
|
61
|
+
ignorePatterns: string[];
|
|
62
|
+
sortImports: boolean;
|
|
63
|
+
sortTailwindcss: boolean;
|
|
64
|
+
sortPackageJson: boolean;
|
|
65
|
+
};
|
|
54
66
|
export declare const repositoryConfig: (options: RepositoryOptions) => UserConfig;
|
|
55
67
|
export {};
|
package/dist/config.mjs
CHANGED
|
@@ -1,518 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Array, Effect, Layer, ManagedRuntime, Option, Record, String, pipe } from "effect";
|
|
3
|
-
import { f as requiredStack, g as decisionTestRules, 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 { _ as patternOf, d as tasksOf, f as existsAt, g as namedWorkspaces, h as staticPrefix, i as textlintOf, l as gitHooksOf, m as isIgnored, o as GIT_HOOKS, p as isDirectoryAt, r as secretsOf } from "./repository-text-DfTSvaqo.mjs";
|
|
9
|
-
import { RUNTIME_SECTIONS } from "@r_masseater/masseater-utils/kestrion";
|
|
10
|
-
// src/features/guard-workflows/model/yaml.ts
|
|
11
|
-
const rootOf = ({ source }) => Option.fromNullishOr(source.yaml);
|
|
12
|
-
const stringOf = (node) => pipe(node, Option.filter(({ kind }) => kind === "scalar"), Option.map(({ value, line, column }) => ({
|
|
13
|
-
text: value,
|
|
14
|
-
line,
|
|
15
|
-
column
|
|
16
|
-
})));
|
|
17
|
-
const childOf = (key) => (node) => pipe(node, Option.flatMap(valueAt(key)));
|
|
18
|
-
const keyNodeOf = (key) => (node) => pipe(node, Option.flatMap((mapping) => pipe(pairsOf(mapping), Array.findFirst((pair) => pair.key.value === key), Option.map((pair) => pair.key))));
|
|
19
|
-
const itemsOf = (node) => pipe(node, Option.filter(({ kind }) => kind === "sequence"), Option.map(({ children }) => children), Option.getOrElse(() => []));
|
|
20
|
-
const entriesOf = (node) => pipe(node, Option.map(pairsOf), Option.getOrElse(() => []), Array.map((pair) => [pair.key.value, pair.value]));
|
|
21
|
-
const scalarsIn = (node) => {
|
|
22
|
-
if (node.kind === "scalar") return [{
|
|
23
|
-
text: node.value,
|
|
24
|
-
line: node.line,
|
|
25
|
-
column: node.column
|
|
26
|
-
}];
|
|
27
|
-
return pipe(node.children, Array.flatMap((child) => scalarsIn(child)));
|
|
28
|
-
};
|
|
29
|
-
const ownValuesNamed = (name, node) => {
|
|
30
|
-
if (node.kind !== "mapping") return [];
|
|
31
|
-
return pipe(pairsOf(node), Array.filter((pair) => pair.key.value === name), Array.map((pair) => pair.value));
|
|
32
|
-
};
|
|
33
|
-
const valuesNamed = (name) => (node) => [...ownValuesNamed(name, node), ...pipe(node.children, Array.flatMap(valuesNamed(name)))];
|
|
34
|
-
const descend = (...keys) => (node) => {
|
|
35
|
-
let found = node;
|
|
36
|
-
for (const key of keys) found = pipe(found, childOf(key));
|
|
37
|
-
return found;
|
|
38
|
-
};
|
|
39
|
-
// src/features/guard-workflows/model/publish-trigger.ts
|
|
40
|
-
const PUBLISH = /\bmsch\s+publish\s+(?:plan|npm|release)\b/u;
|
|
41
|
-
const MANUAL = "workflow_dispatch";
|
|
42
|
-
const TRIGGER_KEY = "on";
|
|
43
|
-
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`.";
|
|
44
|
-
const triggersOf = (node) => {
|
|
45
|
-
if (node.kind === "scalar") return [node.value];
|
|
46
|
-
if (node.kind === "sequence") return pipe(node.children, Array.map(({ value }) => value));
|
|
47
|
-
return keysOf(node);
|
|
48
|
-
};
|
|
49
|
-
/** @internal */
|
|
50
|
-
const publishTrigger = workflowRule({
|
|
51
|
-
description: "Reports msch publish steps in a workflow that something other than workflow_dispatch starts",
|
|
52
|
-
visitor: (fail, context) => {
|
|
53
|
-
const publishing = [];
|
|
54
|
-
return {
|
|
55
|
-
...NOOP,
|
|
56
|
-
step: (step) => {
|
|
57
|
-
if (pipe(runOf(step), Option.flatMap(({ run }) => Option.fromNullishOr(run)), Option.exists(({ value }) => PUBLISH.test(value)))) publishing.push(MANUAL);
|
|
58
|
-
},
|
|
59
|
-
workflowPost: () => {
|
|
60
|
-
const root = rootOf(context);
|
|
61
|
-
const triggers = pipe(childOf(TRIGGER_KEY)(root), Option.map(triggersOf), Option.getOrElse(() => []));
|
|
62
|
-
const manualOnly = pipe(triggers, Array.every((trigger) => trigger === MANUAL));
|
|
63
|
-
if (Array.isReadonlyArrayNonEmpty(publishing) && !manualOnly) for (const key of pipe(root, keyNodeOf(TRIGGER_KEY), Option.toArray)) fail(key, MESSAGE$5);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
// src/features/guard-workflows/model/release-please.ts
|
|
69
|
-
const RELEASE_PLEASE = /^googleapis\/release-please-action(?:@|$)/u;
|
|
70
|
-
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.";
|
|
71
|
-
/** @internal */
|
|
72
|
-
const releasePlease = workflowRule({
|
|
73
|
-
description: "Reports the release-please action, because releases here are manual",
|
|
74
|
-
visitor: (fail) => ({
|
|
75
|
-
...NOOP,
|
|
76
|
-
step: (step) => {
|
|
77
|
-
const uses = pipe(actionOf(step), Option.flatMap(({ uses: text }) => Option.fromNullishOr(text)), Option.filter(({ value }) => RELEASE_PLEASE.test(value)), Option.toArray);
|
|
78
|
-
for (const found of uses) fail(found, MESSAGE$4);
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
});
|
|
82
|
-
// src/features/guard-workflows/model/workflow-commit.ts
|
|
83
|
-
const GIT_WRITE = /\bgit\s+(?:-{1,2}\S+\s+(?:\S+\s+)?)*(?:commit|push)\b/u;
|
|
84
|
-
const COMMIT_ACTION = /^[^@/]+\/[^@]*(?:commit|push)[^@]*(?:@|$)/iu;
|
|
85
|
-
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.";
|
|
86
|
-
/** @internal */
|
|
87
|
-
const workflowCommit = workflowRule({
|
|
88
|
-
description: "Reports git commit, git push and commit actions in a workflow",
|
|
89
|
-
visitor: (fail) => ({
|
|
90
|
-
...NOOP,
|
|
91
|
-
step: (step) => {
|
|
92
|
-
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)))));
|
|
93
|
-
const commits = pipe(actionOf(step), Option.flatMap(({ uses }) => Option.fromNullishOr(uses)), Option.filter(({ value }) => COMMIT_ACTION.test(value)));
|
|
94
|
-
for (const found of Option.toArray(Option.orElse(writes, () => commits))) fail(found, MESSAGE$3);
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
});
|
|
98
|
-
// src/features/guard-workflows/model/repository-services.ts
|
|
99
|
-
const runtime = ManagedRuntime.make(Layer.provide(nodeRepositoryFiles, nodeServicesLayer));
|
|
100
|
-
/** @internal */
|
|
101
|
-
const inRepository = (effect) => Effect.promise(() => runtime.runPromise(effect));
|
|
102
|
-
// src/features/guard-workflows/model/workflow-references.ts
|
|
103
|
-
const ROOT = ".";
|
|
104
|
-
const LOCAL = "./";
|
|
105
|
-
const NEGATION = "!";
|
|
106
|
-
const SEPARATOR$2 = "/";
|
|
107
|
-
const LINE = "\n";
|
|
108
|
-
const UNRESOLVED_MARKERS = [
|
|
109
|
-
"${{",
|
|
110
|
-
"$",
|
|
111
|
-
"{"
|
|
112
|
-
];
|
|
113
|
-
const ABSOLUTE_MARKERS = ["/", "~"];
|
|
114
|
-
const FILE_INPUT_SUFFIX = "-file";
|
|
115
|
-
const DEPENDENCY_PATH_INPUT = "cache-dependency-path";
|
|
116
|
-
const FILTER_KEYS$1 = ["paths", "paths-ignore"];
|
|
117
|
-
const HASH_FILES = /hashFiles\((?<arguments>[^)]*)\)/gu;
|
|
118
|
-
const QUOTED$1 = /'(?<path>[^']*)'/gu;
|
|
119
|
-
const SCRIPT = /^[\w.@/-]+\.(?:ts|mts|cts|sh)$/u;
|
|
120
|
-
const TOKEN_SEPARATOR = /[\s;&|()<>"'`=]+/u;
|
|
121
|
-
const ACTION_DEFINITIONS = ["action.yml", "action.yaml"];
|
|
122
|
-
const containsAny = (markers) => (path) => pipe(markers, Array.some((marker) => String.includes(marker)(path)));
|
|
123
|
-
const startsWithAny = (markers) => (path) => pipe(markers, Array.some((marker) => String.startsWith(marker)(path)));
|
|
124
|
-
const isLiteralPath = (path) => String.isNonEmpty(path) && !containsAny(UNRESOLVED_MARKERS)(path) && !startsWithAny(ABSOLUTE_MARKERS)(path);
|
|
125
|
-
const withoutLocal = (path) => {
|
|
126
|
-
if (String.startsWith(LOCAL)(path)) return String.slice(2)(path);
|
|
127
|
-
return path;
|
|
128
|
-
};
|
|
129
|
-
const joinPath = (base, path) => {
|
|
130
|
-
const relative = withoutLocal(String.trim(path));
|
|
131
|
-
if (base === ROOT) return relative;
|
|
132
|
-
return `${base}${SEPARATOR$2}${relative}`;
|
|
133
|
-
};
|
|
134
|
-
const reference = (kind, field, base = ROOT) => ({ text, line, column }) => {
|
|
135
|
-
const path = String.trim(text);
|
|
136
|
-
if (!isLiteralPath(path) || !isLiteralPath(base)) return [];
|
|
137
|
-
return [{
|
|
138
|
-
kind,
|
|
139
|
-
field,
|
|
140
|
-
path: joinPath(base, path),
|
|
141
|
-
text,
|
|
142
|
-
line,
|
|
143
|
-
column
|
|
144
|
-
}];
|
|
145
|
-
};
|
|
146
|
-
const isPositive = ({ text }) => !String.startsWith(NEGATION)(String.trim(text));
|
|
147
|
-
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)));
|
|
148
|
-
const filtersOf = ([event, filters]) => pipe(FILTER_KEYS$1, Array.flatMap((key) => globsIn(`on.${event}.${key}`, pipe(filters, Option.some, childOf(key)))));
|
|
149
|
-
const workingDirectoryOf = (owner) => pipe(owner, descend("defaults", "run", "working-directory"), stringOf);
|
|
150
|
-
const directoryOf = (found, base) => pipe(found, Option.map(({ text }) => joinPath(ROOT, text)), Option.getOrElse(() => base));
|
|
151
|
-
const located = (kind, field, base = ROOT) => (found) => pipe(found, Option.toArray, Array.flatMap(reference(kind, field, base)));
|
|
152
|
-
const localUses = (node) => pipe(node, childOf("uses"), stringOf, Option.filter(({ text }) => String.startsWith(LOCAL)(text)));
|
|
153
|
-
const scriptsIn = (field, base) => ({ text, line, column }) => pipe(String.split(text, TOKEN_SEPARATOR), Array.filter((token) => SCRIPT.test(token)), Array.dedupe, Array.flatMap((token) => pipe({
|
|
154
|
-
text: token,
|
|
155
|
-
line,
|
|
156
|
-
column
|
|
157
|
-
}, reference("script", field, base))));
|
|
158
|
-
const isFileInput = ([key]) => String.endsWith(FILE_INPUT_SUFFIX)(key) || key === DEPENDENCY_PATH_INPUT;
|
|
159
|
-
const linesOf = ({ text, line, column }) => pipe(String.split(text, LINE), Array.map((each) => ({
|
|
160
|
-
text: each,
|
|
161
|
-
line,
|
|
162
|
-
column
|
|
163
|
-
})));
|
|
164
|
-
const fileInputOf = (field) => ([key, value]) => pipe(value, Option.some, stringOf, Option.toArray, Array.flatMap(linesOf), Array.flatMap(reference("glob", `${field}.with.${key}`)));
|
|
165
|
-
const fileInputsIn = (field, step) => pipe(step, Option.some, childOf("with"), entriesOf, Array.filter(isFileInput), Array.flatMap(fileInputOf(field)));
|
|
166
|
-
const scriptReferencesOf = (field, directory, step) => pipe(step, Option.some, childOf("run"), stringOf, Option.toArray, Array.flatMap(scriptsIn(`${field}.run`, directory)));
|
|
167
|
-
const stepReferences = (job, base) => (step, index) => {
|
|
168
|
-
const field = `jobs.${job}.steps[${index}]`;
|
|
169
|
-
const own = pipe(step, Option.some, childOf("working-directory"), stringOf);
|
|
170
|
-
const directory = directoryOf(own, base);
|
|
171
|
-
return [
|
|
172
|
-
...pipe(step, Option.some, localUses, located("action", `${field}.uses`)),
|
|
173
|
-
...pipe(own, located("directory", `${field}.working-directory`)),
|
|
174
|
-
...scriptReferencesOf(field, directory, step),
|
|
175
|
-
...fileInputsIn(field, step)
|
|
176
|
-
];
|
|
177
|
-
};
|
|
178
|
-
const jobReferences = (base) => ([job, node]) => {
|
|
179
|
-
const own = pipe(node, Option.some, workingDirectoryOf);
|
|
180
|
-
const steps = pipe(node, Option.some, childOf("steps"), itemsOf);
|
|
181
|
-
const directory = directoryOf(own, base);
|
|
182
|
-
return [
|
|
183
|
-
...pipe(node, Option.some, localUses, located("file", `jobs.${job}.uses`)),
|
|
184
|
-
...pipe(own, located("directory", `jobs.${job}.defaults.run.working-directory`)),
|
|
185
|
-
...pipe(steps, Array.flatMap(stepReferences(job, directory)))
|
|
186
|
-
];
|
|
187
|
-
};
|
|
188
|
-
const groupsOf = (pattern, group) => ({ text, line, column }) => pipe(Array.fromIterable(String.matchAll(pattern)(text)), Array.flatMap((match) => pipe(Option.fromNullishOr(match.groups), Option.flatMap((groups) => Option.fromNullishOr(groups[group])), Option.toArray)), Array.map((value) => ({
|
|
189
|
-
text: value,
|
|
190
|
-
line,
|
|
191
|
-
column
|
|
192
|
-
})));
|
|
193
|
-
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")));
|
|
194
|
-
const jobsOf = (root) => pipe(root, Option.some, childOf("jobs"), entriesOf);
|
|
195
|
-
/** @internal */
|
|
196
|
-
const workflowReferences = (root) => {
|
|
197
|
-
const workflowDefault = pipe(root, Option.some, workingDirectoryOf);
|
|
198
|
-
const base = directoryOf(workflowDefault, ROOT);
|
|
199
|
-
return [
|
|
200
|
-
...pipe(root, Option.some, childOf("on"), entriesOf, Array.flatMap(filtersOf)),
|
|
201
|
-
...pipe(workflowDefault, located("directory", "defaults.run.working-directory")),
|
|
202
|
-
...pipe(jobsOf(root), Array.flatMap(jobReferences(base))),
|
|
203
|
-
...hashFilesIn(root)
|
|
204
|
-
];
|
|
205
|
-
};
|
|
206
|
-
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));
|
|
207
|
-
/** @internal */
|
|
208
|
-
const producedPaths = (root) => pipe(jobsOf(root), Array.flatMap(([, job]) => pipe(job, Option.some, childOf("steps"), itemsOf)), Array.flatMap(outputPathsOf));
|
|
209
|
-
// src/features/guard-workflows/model/workflow-package.ts
|
|
210
|
-
const WORKFLOW = /(?:^|\/)\.github\/workflows\/(?<name>[^/]+)\.ya?ml$/u;
|
|
211
|
-
const ACTION = /(?:^|\/)\.github\/actions\/(?<name>[^/]+)\/action\.ya?ml$/u;
|
|
212
|
-
const PACKAGE_FILTER = /(?:^|\s)(?:--filter|-F)(?:\s+|=)(?<quote>["']?)(?<value>[^\s"'$][^\s"']*)\k<quote>/gu;
|
|
213
|
-
const SEPARATOR$1 = "/";
|
|
214
|
-
const WORD_SEPARATORS = /[-_]/gu;
|
|
215
|
-
const SPACE = " ";
|
|
216
|
-
const FIRST_LINE = {
|
|
217
|
-
text: "",
|
|
218
|
-
line: 1,
|
|
219
|
-
column: 1
|
|
220
|
-
};
|
|
221
|
-
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.`;
|
|
222
|
-
const matching = (workspaces, text) => pipe(workspaces, Array.findFirst(({ names }) => Array.isReadonlyArrayNonEmpty(names) && Option.isSome(String.match(patternOf(names))(text))), Option.map(({ directory }) => directory));
|
|
223
|
-
const named = (workspaces, text) => Option.orElse(matching(workspaces, text), () => matching(workspaces, String.replaceAll(WORD_SEPARATORS, SPACE)(text)));
|
|
224
|
-
const containing = (workspaces, path) => pipe(workspaces, Array.findFirst(({ directory }) => path === directory || String.startsWith(`${directory}${SEPARATOR$1}`)(path)), Option.map(({ directory }) => directory));
|
|
225
|
-
const filtersIn = (scalars) => pipe(scalars, Array.flatMap(({ text, line, column }) => pipe(Array.fromIterable(String.matchAll(PACKAGE_FILTER)(text)), Array.flatMap((match) => pipe(Option.fromNullishOr(match.groups), Option.flatMap((groups) => Option.fromNullishOr(groups["value"])), Option.toArray)), Array.map((value) => ({
|
|
226
|
-
text: value,
|
|
227
|
-
line,
|
|
228
|
-
column
|
|
229
|
-
})))));
|
|
230
|
-
const findingFor = (what, found, directory) => pipe(directory, Option.map((workspace) => ({
|
|
231
|
-
line: found.line,
|
|
232
|
-
column: found.column,
|
|
233
|
-
message: packageMessage(what, workspace)
|
|
234
|
-
})), Option.toArray);
|
|
235
|
-
const namesIn = (stem, root) => [
|
|
236
|
-
{
|
|
237
|
-
...FIRST_LINE,
|
|
238
|
-
text: stem
|
|
239
|
-
},
|
|
240
|
-
...pipe(root, childOf("name"), stringOf, Option.toArray),
|
|
241
|
-
...pipe(root, childOf("jobs"), Option.map((jobs) => pipe(pairsOf(jobs), Array.map(({ key }) => ({
|
|
242
|
-
text: key.value,
|
|
243
|
-
line: key.line,
|
|
244
|
-
column: key.column
|
|
245
|
-
})))), Option.getOrElse(() => []))
|
|
246
|
-
];
|
|
247
|
-
const workflowFindings = (workspaces, stem, root) => {
|
|
248
|
-
const fromNames = pipe(namesIn(stem, Option.some(root)), Array.flatMap((found) => findingFor(`"${found.text}"`, found, named(workspaces, found.text))));
|
|
249
|
-
const referenced = pipe(workflowReferences(root), Array.filter(({ field }) => !String.startsWith("on.")(field)), Array.flatMap((found) => findingFor(found.field, found, containing(workspaces, found.path))));
|
|
250
|
-
const filtered = pipe(filtersIn(scalarsIn(root)), Array.flatMap((found) => findingFor(`--filter ${found.text}`, found, matching(workspaces, found.text))));
|
|
251
|
-
return [
|
|
252
|
-
...fromNames,
|
|
253
|
-
...referenced,
|
|
254
|
-
...filtered
|
|
255
|
-
];
|
|
256
|
-
};
|
|
257
|
-
const workflowPackage = defineRule({
|
|
258
|
-
meta: {
|
|
259
|
-
description: "Reports workflows, jobs, actions and paths that are made for one workspace",
|
|
260
|
-
kinds: ["workflow", "action"]
|
|
261
|
-
},
|
|
262
|
-
check: ({ filename, project, source, report }) => Effect.gen(function* checkPackages() {
|
|
263
|
-
const workspaces = yield* namedWorkspaces(project.root);
|
|
264
|
-
const asWorkflow = groupOf("name")(WORKFLOW.exec(filename));
|
|
265
|
-
const asAction = groupOf("name")(ACTION.exec(filename));
|
|
266
|
-
const found = [...pipe(asAction, Option.flatMap((name) => named(workspaces, name)), Option.map((directory) => ({
|
|
267
|
-
...FIRST_LINE,
|
|
268
|
-
message: packageMessage(`The action ${Option.getOrElse(asAction, () => "")}`, directory)
|
|
269
|
-
})), Option.toArray), ...pipe(Option.all([asWorkflow, Option.fromNullishOr(source.yaml)]), Option.map(([stem, root]) => workflowFindings(workspaces, stem, root)), Option.getOrElse(() => []))];
|
|
270
|
-
for (const each of found) report(each);
|
|
271
|
-
}).pipe(inRepository)
|
|
272
|
-
});
|
|
273
|
-
// src/features/guard-workflows/model/workflow-path-filter.ts
|
|
274
|
-
const FILTER_KEYS = ["paths", "paths-ignore"];
|
|
275
|
-
const PATHS_FILTER_ACTION = /(?:^|\/)paths-filter@/u;
|
|
276
|
-
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.";
|
|
277
|
-
/** @internal */
|
|
278
|
-
const workflowPathFilter = defineRule({
|
|
279
|
-
meta: {
|
|
280
|
-
description: "Reports paths and paths-ignore triggers and the paths-filter action",
|
|
281
|
-
kinds: ["workflow"]
|
|
282
|
-
},
|
|
283
|
-
check: (context) => {
|
|
284
|
-
const root = rootOf(context);
|
|
285
|
-
const triggers = pipe(root, childOf("on"), entriesOf, Array.flatMap(([, trigger]) => pipe(FILTER_KEYS, Array.flatMap((key) => pipe(Option.some(trigger), keyNodeOf(key), Option.toArray)))));
|
|
286
|
-
const actions = pipe(Option.toArray(root), Array.flatMap((node) => scalarsIn(node)), Array.filter(({ text }) => PATHS_FILTER_ACTION.test(text)));
|
|
287
|
-
for (const found of [...triggers, ...actions]) context.report({
|
|
288
|
-
line: found.line,
|
|
289
|
-
column: found.column,
|
|
290
|
-
message: MESSAGE$2
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
// src/features/guard-workflows/model/workflow-path.ts
|
|
295
|
-
const SEPARATOR = "/";
|
|
296
|
-
const EXPECTED = {
|
|
297
|
-
action: "a directory with action.yml",
|
|
298
|
-
directory: "a directory",
|
|
299
|
-
file: "a file",
|
|
300
|
-
glob: "a pattern that matches a tracked file",
|
|
301
|
-
script: "a file"
|
|
302
|
-
};
|
|
303
|
-
const matchesAny = Effect.fn("matchesAny")(function* matchesAny(root, pathspecs) {
|
|
304
|
-
const matched = yield* (yield* RepositoryFiles).matchingFiles(root, pathspecs);
|
|
305
|
-
return Array.isReadonlyArrayNonEmpty(matched);
|
|
306
|
-
});
|
|
307
|
-
const matchesGlob = (root, path) => matchesAny(root, [`:(glob)${path}`]);
|
|
308
|
-
const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
|
|
309
|
-
const found = yield* Effect.forEach(ACTION_DEFINITIONS, (name) => existsAt(root, `${path}${SEPARATOR}${name}`), { concurrency: 1 });
|
|
310
|
-
return pipe(found, Array.some(Boolean));
|
|
311
|
-
});
|
|
312
|
-
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR))}`;
|
|
313
|
-
const findsScript = Effect.fn("findsScript")(function* findsScript(root, path) {
|
|
314
|
-
if (yield* existsAt(root, path)) return true;
|
|
315
|
-
const segments = String.split(path, SEPARATOR);
|
|
316
|
-
return yield* matchesAny(root, Array.makeBy(segments.length, suffixAt(segments)));
|
|
317
|
-
});
|
|
318
|
-
const RESOLVERS = {
|
|
319
|
-
action: hasAction,
|
|
320
|
-
directory: isDirectoryAt,
|
|
321
|
-
file: existsAt,
|
|
322
|
-
glob: matchesGlob,
|
|
323
|
-
script: findsScript
|
|
324
|
-
};
|
|
325
|
-
const overlaps = (path) => (produced) => produced === path || String.startsWith(`${path}${SEPARATOR}`)(produced) || String.startsWith(`${produced}${SEPARATOR}`)(path);
|
|
326
|
-
const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, found) {
|
|
327
|
-
const prefix = staticPrefix(found.path);
|
|
328
|
-
if (pipe(produced, Array.some(overlaps(prefix)))) return false;
|
|
329
|
-
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
330
|
-
return !(yield* isIgnored(root, found.path));
|
|
331
|
-
});
|
|
332
|
-
const workflowPath = defineRule({
|
|
333
|
-
meta: {
|
|
334
|
-
description: "Reports a path that a workflow names and the repository does not have",
|
|
335
|
-
kinds: ["workflow"]
|
|
336
|
-
},
|
|
337
|
-
check: ({ project, source, report }) => Effect.gen(function* checkPaths() {
|
|
338
|
-
for (const yaml of Option.toArray(Option.fromNullishOr(source.yaml))) {
|
|
339
|
-
const produced = producedPaths(yaml);
|
|
340
|
-
const missing = yield* Effect.filter(workflowReferences(yaml), (found) => isMissing(project.root, produced, found));
|
|
341
|
-
for (const found of missing) report({
|
|
342
|
-
line: found.line,
|
|
343
|
-
column: found.column,
|
|
344
|
-
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.`
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}).pipe(inRepository)
|
|
348
|
-
});
|
|
349
|
-
// src/features/guard-workflows/model/workflow-queue.ts
|
|
350
|
-
const CONCURRENCY_KEY = "concurrency";
|
|
351
|
-
const QUEUE_KEY = "queue";
|
|
352
|
-
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.";
|
|
353
|
-
/** @internal */
|
|
354
|
-
const workflowQueue = defineRule({
|
|
355
|
-
meta: {
|
|
356
|
-
description: "Reports queue on a concurrency group, because a queued group holds back the newest commit",
|
|
357
|
-
kinds: ["workflow"]
|
|
358
|
-
},
|
|
359
|
-
check: (context) => {
|
|
360
|
-
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)));
|
|
361
|
-
for (const key of keys) context.report({
|
|
362
|
-
line: key.line,
|
|
363
|
-
column: key.column,
|
|
364
|
-
message: MESSAGE$1
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
// src/features/guard-workflows/model/workflow-script.ts
|
|
369
|
-
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
370
|
-
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
371
|
-
const COMMENT = "#";
|
|
372
|
-
const ONE_COMMAND = 1;
|
|
373
|
-
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.";
|
|
374
|
-
const isCommand = (line) => String.isNonEmpty(line) && !String.startsWith(COMMENT)(line);
|
|
375
|
-
const chainsCommands = (line) => COMMAND_CHAIN.test(String.replaceAll(QUOTED, "")(line));
|
|
376
|
-
const runsMoreThanOneCommand = (text) => {
|
|
377
|
-
const lines = pipe(String.split("\n")(text), Array.map(String.trim), Array.filter(isCommand));
|
|
378
|
-
return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
|
|
379
|
-
};
|
|
380
|
-
/** @internal */
|
|
381
|
-
const workflowScript = workflowRule({
|
|
382
|
-
description: "Reports a run step with more than one command, because the logic belongs in a task",
|
|
383
|
-
visitor: (fail) => ({
|
|
384
|
-
...NOOP,
|
|
385
|
-
step: (step) => {
|
|
386
|
-
const runs = pipe(runOf(step), Option.flatMap(({ run }) => Option.fromNullishOr(run)), Option.filter(({ value }) => runsMoreThanOneCommand(value)), Option.toArray);
|
|
387
|
-
for (const found of runs) fail(found, MESSAGE);
|
|
388
|
-
}
|
|
389
|
-
})
|
|
390
|
-
});
|
|
391
|
-
// src/features/guard-workflows/model/policy.ts
|
|
392
|
-
const NAME = "msch";
|
|
393
|
-
const plugin = definePlugin({ rules: {
|
|
394
|
-
"publish-trigger": publishTrigger,
|
|
395
|
-
"release-please": releasePlease,
|
|
396
|
-
"workflow-commit": workflowCommit,
|
|
397
|
-
"workflow-package": workflowPackage,
|
|
398
|
-
"workflow-path": workflowPath,
|
|
399
|
-
"workflow-path-filter": workflowPathFilter,
|
|
400
|
-
"workflow-queue": workflowQueue,
|
|
401
|
-
"workflow-script": workflowScript
|
|
402
|
-
} });
|
|
403
|
-
/** @internal */
|
|
404
|
-
const workflowPolicy = () => ({
|
|
405
|
-
plugins: Record.singleton(NAME, plugin),
|
|
406
|
-
rules: pipe(Record.keys(plugin.rules), Array.map((rule) => [`${NAME}/${rule}`, "error"]), Record.fromEntries)
|
|
407
|
-
});
|
|
408
|
-
// src/features/guard-workflows/model/fu4-config.ts
|
|
409
|
-
/** @internal */
|
|
410
|
-
const fu4Of = () => ({ extends: [recommended(), workflowPolicy()] });
|
|
411
|
-
// src/app/repository-dependencies.ts
|
|
412
|
-
const allowedIn = (allowances, fields) => pipe(allowances, Record.map(({ workspaces, dependencies }) => ({
|
|
413
|
-
workspaces,
|
|
414
|
-
dependencies,
|
|
415
|
-
fields: [...fields]
|
|
416
|
-
})));
|
|
417
|
-
const PLUGIN_DEPENDENCIES = "Claude Code installs a plugin's dependencies from its own package.json and lockfile, where only exact registry versions install";
|
|
418
|
-
const dependencyRulesOf = (workspace) => ({
|
|
419
|
-
allowed: {
|
|
420
|
-
...allowedIn(workspace.devDependencies, ["devDependencies"]),
|
|
421
|
-
...allowedIn(workspace.dependencies, RUNTIME_SECTIONS)
|
|
422
|
-
},
|
|
423
|
-
banned: requiredStack,
|
|
424
|
-
exactDependencies: { [PLUGIN_DEPENDENCIES]: workspace.plugins },
|
|
425
|
-
peerRanges: "intersect"
|
|
426
|
-
});
|
|
427
|
-
// src/app/repository-config.ts
|
|
428
|
-
const cacheOf = (remoteCache) => pipe(Option.fromNullishOr(remoteCache), Option.match({
|
|
429
|
-
onNone: () => true,
|
|
430
|
-
onSome: (url) => ({
|
|
431
|
-
scripts: true,
|
|
432
|
-
tasks: true,
|
|
433
|
-
remote: { url }
|
|
434
|
-
})
|
|
435
|
-
}));
|
|
436
|
-
const COMMIT_CONVENTION = fileURLToPath(import.meta.resolve("@commitlint/config-conventional"));
|
|
437
|
-
const added = ({ files, excludeFiles, rules }) => pipe(Option.fromUndefinedOr(excludeFiles), Option.match({
|
|
438
|
-
onNone: () => ({
|
|
439
|
-
files: [...files],
|
|
440
|
-
rules: { ...rules }
|
|
441
|
-
}),
|
|
442
|
-
onSome: (excluded) => ({
|
|
443
|
-
files: [...files],
|
|
444
|
-
excludeFiles: [...excluded],
|
|
445
|
-
rules: { ...rules }
|
|
446
|
-
})
|
|
447
|
-
}));
|
|
448
|
-
const lintOf = ({ workspace, overrides = [] }) => ({
|
|
449
|
-
...lint$1,
|
|
450
|
-
ignorePatterns: exempt,
|
|
451
|
-
overrides: [
|
|
452
|
-
...lint$1.overrides,
|
|
453
|
-
{
|
|
454
|
-
files: [...workspace.lint.shadcnUi],
|
|
455
|
-
rules: { "react/jsx-props-no-spreading": "off" }
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
files: [
|
|
459
|
-
...workspace.lint.publicEntries,
|
|
460
|
-
...workspace.lint.deployEntries,
|
|
461
|
-
...workspace.lint.siteEntries
|
|
462
|
-
],
|
|
463
|
-
rules: { "import/no-default-export": "off" }
|
|
464
|
-
},
|
|
465
|
-
...pipe(overrides, Array.map(added)),
|
|
466
|
-
...workspace.lint.overrides,
|
|
467
|
-
{
|
|
468
|
-
files: ["**/*.test.ts"],
|
|
469
|
-
rules: decisionTestRules
|
|
470
|
-
}
|
|
471
|
-
]
|
|
472
|
-
});
|
|
473
|
-
const repositoryConfig = (options) => {
|
|
474
|
-
const { workspace, textlint = {}, markdown = {}, run = {}, usage, cargo, gitHooks } = options;
|
|
475
|
-
return {
|
|
476
|
-
commitlint: { extends: [COMMIT_CONVENTION] },
|
|
477
|
-
dependencyRules: dependencyRulesOf(workspace),
|
|
478
|
-
h56m: secretsOf(),
|
|
479
|
-
wism: structureOf({
|
|
480
|
-
members: workspace.members,
|
|
481
|
-
ignorePatterns: exempt
|
|
482
|
-
}),
|
|
483
|
-
textlint: textlintOf({
|
|
484
|
-
...textlint,
|
|
485
|
-
articles: workspace.articles
|
|
486
|
-
}),
|
|
487
|
-
y8: markdownOf({
|
|
488
|
-
...markdown,
|
|
489
|
-
indexSkill: workspace.indexSkill
|
|
490
|
-
}),
|
|
491
|
-
fu4: fu4Of(),
|
|
492
|
-
test: {
|
|
493
|
-
projects: [...workspace.testProjects],
|
|
494
|
-
passWithNoTests: true
|
|
495
|
-
},
|
|
496
|
-
staged: { "*": "vp fmt --no-error-on-unmatched-pattern" },
|
|
497
|
-
gitHooks: gitHooksOf(gitHooks),
|
|
498
|
-
fmt: {
|
|
499
|
-
ignorePatterns: exempt,
|
|
500
|
-
sortImports: true,
|
|
501
|
-
sortTailwindcss: true,
|
|
502
|
-
sortPackageJson: true
|
|
503
|
-
},
|
|
504
|
-
lint: lintOf(options),
|
|
505
|
-
run: {
|
|
506
|
-
cache: cacheOf(run.remoteCache),
|
|
507
|
-
tasks: tasksOf({
|
|
508
|
-
workspace,
|
|
509
|
-
commands: run.tasks ?? {},
|
|
510
|
-
usage: Option.fromUndefinedOr(usage),
|
|
511
|
-
cargo: Option.map(Option.fromUndefinedOr(cargo), ({ inputs }) => inputs)
|
|
512
|
-
})
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
};
|
|
516
|
-
export { GIT_HOOKS, PLUGIN_DEPENDENCIES, repositoryConfig, secretsOf };
|
|
517
|
-
|
|
518
|
-
//# sourceMappingURL=config.mjs.map
|
|
1
|
+
export { t as COMMIT_LINT, n as FORMAT, l as GIT_HOOKS, p as PLUGIN_DEPENDENCIES, r as STAGED, i as repositoryConfig, s as secretsOf } from "./repository-config-8JN86BZA.mjs";
|