@r_masseater/msch 0.47.0 → 0.48.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/README.md +1 -0
- package/dist/changed.mjs +1 -1
- package/dist/check-upstream-exits-BJNhgkLI.mjs +499 -0
- package/dist/check-upstream-exits-BJNhgkLI.mjs.map +1 -0
- package/dist/cli-contract-D7btWrEu.mjs +5 -0
- package/dist/cli-contract-D7btWrEu.mjs.map +1 -0
- package/dist/cli.mjs +260 -284
- package/dist/cli.mjs.map +1 -1
- package/dist/{comment-directives-5-f_qs1E.mjs → comment-directives-CRAU6yNZ.mjs} +2 -1
- package/dist/comment-directives-CRAU6yNZ.mjs.map +1 -0
- package/dist/config.mjs +5 -1
- package/dist/config.mjs.map +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-CxzPzVuB.mjs → define-lint-preset-BhT4RpHs.mjs} +2 -2
- package/dist/{define-lint-preset-CxzPzVuB.mjs.map → define-lint-preset-BhT4RpHs.mjs.map} +1 -1
- package/dist/exits.d.mts +1 -0
- package/dist/exits.mjs +58 -0
- package/dist/exits.mjs.map +1 -0
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +2 -1
- package/dist/oxlint.mjs.map +1 -1
- package/dist/{cli-contract-BY7vwgKc.mjs → problem-u-p6QglA.mjs} +2 -4
- package/dist/problem-u-p6QglA.mjs.map +1 -0
- package/dist/publish.mjs +1 -1
- package/dist/{runtime-GbrDfB8K.mjs → runtime-BmlYnI7T.mjs} +2 -2
- package/dist/{runtime-GbrDfB8K.mjs.map → runtime-BmlYnI7T.mjs.map} +1 -1
- package/package.json +5 -4
- package/skills/msch-checks/SKILL.md +9 -0
- package/dist/cli-contract-BY7vwgKc.mjs.map +0 -1
- package/dist/comment-directives-5-f_qs1E.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ The package has these entry points.
|
|
|
22
22
|
| -------------------------------------- | ------------------------------------------------------------- |
|
|
23
23
|
| `msch` (bin) | Runs every check against the repository |
|
|
24
24
|
| `msch-changed` (bin) | Runs a command on the workspaces that changed since it passed |
|
|
25
|
+
| `msch-exits` (bin) | Reports upstream deviations whose exit condition is met |
|
|
25
26
|
| `msch-publish` (bin) | Plans and publishes a workspace to npm and GitHub Releases |
|
|
26
27
|
| `@r_masseater/msch/config` | `repositoryConfig`, which builds the root `vite.config.ts` |
|
|
27
28
|
| `@r_masseater/msch/workspace-settings` | `workspaceSettings`, which loads the settings of a workspace |
|
package/dist/changed.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as ProblemsFound, t as runCli } from "./runtime-
|
|
2
|
+
import { n as ProblemsFound, t as runCli } from "./runtime-BmlYnI7T.mjs";
|
|
3
3
|
import { a as installedPackages, i as recordsIn, r as keepOnly, s as workspaceClosure } from "./project-DeQcAglt.mjs";
|
|
4
4
|
import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-aXwrITdF.mjs";
|
|
5
5
|
import { v as workspaceDirectories } from "./dependencies-v59cxwTD.mjs";
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import { a as groupOf, n as RepositoryFiles } from "./repository-files-aXwrITdF.mjs";
|
|
2
|
+
import { Array, Config, Effect, HashMap, HashSet, Match, Option, Record, Schema, String as String$1, pipe } from "effect";
|
|
3
|
+
import { Parser, parseDocument } from "yaml";
|
|
4
|
+
import semver from "semver";
|
|
5
|
+
import { parseTOML } from "toml-eslint-parser";
|
|
6
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
7
|
+
// src/shared/lib/text-position.ts
|
|
8
|
+
const START$1 = 0;
|
|
9
|
+
const FIRST_COLUMN = 1;
|
|
10
|
+
const positionOf = (source) => (index) => {
|
|
11
|
+
const before = pipe(source, String$1.slice(START$1, index), String$1.split("\n"));
|
|
12
|
+
return {
|
|
13
|
+
line: before.length,
|
|
14
|
+
column: pipe(Array.last(before), Option.match({
|
|
15
|
+
onNone: () => FIRST_COLUMN,
|
|
16
|
+
onSome: (last) => last.length + FIRST_COLUMN
|
|
17
|
+
}))
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
// src/shared/lib/scanned-files.ts
|
|
21
|
+
const SCANNED_FILE = /(?:\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\/)(?:(?:Dockerfile|Containerfile)[^/]*|Makefile|justfile|\.tool-versions|[^./][^./]*))$/u;
|
|
22
|
+
const LOCKFILE = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
|
|
23
|
+
const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
|
|
24
|
+
const READ_CONCURRENCY = 64;
|
|
25
|
+
const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE.test(name);
|
|
26
|
+
const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
|
|
27
|
+
/** @internal */
|
|
28
|
+
const listedFiles = Effect.fn("listedFiles")(function* listedFiles(root) {
|
|
29
|
+
const files = yield* RepositoryFiles;
|
|
30
|
+
const names = yield* files.ownedFiles(root);
|
|
31
|
+
return pipe(names, Array.map((name) => ({
|
|
32
|
+
name,
|
|
33
|
+
file: files.join(root, name)
|
|
34
|
+
})));
|
|
35
|
+
});
|
|
36
|
+
/** @internal */
|
|
37
|
+
const presentFiles = Effect.fn("presentFiles")(function* presentFiles(listed) {
|
|
38
|
+
const files = yield* RepositoryFiles;
|
|
39
|
+
return yield* pipe(listed, Effect.filter(({ file }) => files.exists(file)));
|
|
40
|
+
});
|
|
41
|
+
/** @internal */
|
|
42
|
+
const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
|
|
43
|
+
const files = yield* RepositoryFiles;
|
|
44
|
+
const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
|
|
45
|
+
onNone: () => [],
|
|
46
|
+
onSome: (source) => problemsIn(entry, source)
|
|
47
|
+
}))), { concurrency: READ_CONCURRENCY });
|
|
48
|
+
return Array.flatten(found);
|
|
49
|
+
});
|
|
50
|
+
// src/shared/lib/config-comments.ts
|
|
51
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
52
|
+
const childrenOf = (value) => {
|
|
53
|
+
if (Array.isArray(value)) return value;
|
|
54
|
+
if (isRecord(value)) return Record.values(value);
|
|
55
|
+
return [];
|
|
56
|
+
};
|
|
57
|
+
const collectNodes = (isItem) => (value) => {
|
|
58
|
+
if (isItem(value)) return [value];
|
|
59
|
+
return pipe(childrenOf(value), Array.flatMap(collectNodes(isItem)));
|
|
60
|
+
};
|
|
61
|
+
const isYamlComment = (value) => isRecord(value) && value["type"] === "comment" && typeof value["offset"] === "number" && typeof value["source"] === "string";
|
|
62
|
+
const yamlSourceComments = (source) => pipe(Array.fromIterable(new Parser().parse(source)), Array.flatMap(collectNodes(isYamlComment)), Array.map((token) => ({
|
|
63
|
+
index: token.offset,
|
|
64
|
+
text: token.source
|
|
65
|
+
})));
|
|
66
|
+
const tomlSourceComments = (source) => pipe(parseTOML(source).comments, Array.map(({ range: [start, end] }) => ({
|
|
67
|
+
index: start,
|
|
68
|
+
text: String$1.slice(start, end)(source)
|
|
69
|
+
})));
|
|
70
|
+
// src/features/check-upstream-exits/model/deviation-entries.ts
|
|
71
|
+
const WORKSPACE_SECTIONS = [
|
|
72
|
+
"overrides",
|
|
73
|
+
"patchedDependencies",
|
|
74
|
+
"packageExtensions"
|
|
75
|
+
];
|
|
76
|
+
const CARGO_PATCH = "patch";
|
|
77
|
+
const KEY_SEPARATOR = ".";
|
|
78
|
+
const PATCH_SOURCE_DEPTH = 2;
|
|
79
|
+
const NONE = {
|
|
80
|
+
entries: [],
|
|
81
|
+
comments: []
|
|
82
|
+
};
|
|
83
|
+
const KeyValue = Schema.Union([Schema.String, Schema.Finite]);
|
|
84
|
+
const Positions = Schema.Array(Schema.Finite);
|
|
85
|
+
const YamlKey = Schema.Struct({
|
|
86
|
+
value: KeyValue,
|
|
87
|
+
range: Positions
|
|
88
|
+
});
|
|
89
|
+
const YamlMap = Schema.Struct({ items: Schema.Array(Schema.Struct({ key: YamlKey })) });
|
|
90
|
+
const KeyPart = Schema.Union([Schema.Struct({
|
|
91
|
+
type: Schema.Literal("TOMLBare"),
|
|
92
|
+
name: Schema.String
|
|
93
|
+
}), Schema.Struct({
|
|
94
|
+
type: Schema.Literal("TOMLQuoted"),
|
|
95
|
+
value: Schema.String
|
|
96
|
+
})]);
|
|
97
|
+
const Located = {
|
|
98
|
+
range: Schema.Array(Schema.Finite),
|
|
99
|
+
loc: Schema.Struct({ start: Schema.Struct({ line: Schema.Finite }) })
|
|
100
|
+
};
|
|
101
|
+
const TomlKeyValue = Schema.Struct({
|
|
102
|
+
...Located,
|
|
103
|
+
type: Schema.Literal("TOMLKeyValue"),
|
|
104
|
+
key: Schema.Struct({ keys: Schema.Array(KeyPart) })
|
|
105
|
+
});
|
|
106
|
+
const TomlTable = Schema.Struct({
|
|
107
|
+
...Located,
|
|
108
|
+
type: Schema.Literal("TOMLTable"),
|
|
109
|
+
resolvedKey: Schema.Array(Schema.Union([Schema.String, Schema.Finite])),
|
|
110
|
+
body: Schema.Array(TomlKeyValue)
|
|
111
|
+
});
|
|
112
|
+
const TomlNode = Schema.Union([TomlTable, TomlKeyValue]);
|
|
113
|
+
const TomlTop = Schema.Array(Schema.Struct({ body: Schema.Array(TomlNode) }));
|
|
114
|
+
const decodeYamlMap = Schema.decodeUnknownOption(YamlMap);
|
|
115
|
+
const decodeTomlTop = Schema.decodeUnknownOption(TomlTop);
|
|
116
|
+
const FIRST = 0;
|
|
117
|
+
const lineComments = (source, comments) => pipe(comments, Array.map((comment) => ({
|
|
118
|
+
...comment,
|
|
119
|
+
line: positionOf(source)(comment.index).line
|
|
120
|
+
})));
|
|
121
|
+
const startOf = (range) => Option.getOrElse(Array.get(range, FIRST), () => FIRST);
|
|
122
|
+
const sectionEntries = (source, sectionNode) => (section) => pipe(decodeYamlMap(sectionNode(section)), Option.match({
|
|
123
|
+
onNone: () => [],
|
|
124
|
+
onSome: ({ items }) => pipe(items, Array.map(({ key }) => {
|
|
125
|
+
const index = startOf(key.range);
|
|
126
|
+
return {
|
|
127
|
+
section,
|
|
128
|
+
key: String(key.value),
|
|
129
|
+
index,
|
|
130
|
+
line: positionOf(source)(index).line
|
|
131
|
+
};
|
|
132
|
+
}))
|
|
133
|
+
}));
|
|
134
|
+
const workspaceDeviations = (source) => {
|
|
135
|
+
const document = parseDocument(source);
|
|
136
|
+
if (Array.isReadonlyArrayNonEmpty(document.errors)) return NONE;
|
|
137
|
+
const sectionNode = (section) => document.get(section, true);
|
|
138
|
+
return {
|
|
139
|
+
entries: pipe(WORKSPACE_SECTIONS, Array.flatMap(sectionEntries(source, sectionNode))),
|
|
140
|
+
comments: lineComments(source, yamlSourceComments(source))
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const partName = (part) => {
|
|
144
|
+
if (part.type === "TOMLBare") return part.name;
|
|
145
|
+
return part.value;
|
|
146
|
+
};
|
|
147
|
+
const patchEntries = (table) => {
|
|
148
|
+
const tableKey = pipe(table.resolvedKey, Array.map(String));
|
|
149
|
+
if (!Option.exists(Array.get(tableKey, FIRST), (part) => part === CARGO_PATCH)) return [];
|
|
150
|
+
if (tableKey.length > PATCH_SOURCE_DEPTH) return [{
|
|
151
|
+
section: CARGO_PATCH,
|
|
152
|
+
key: Array.join(tableKey, KEY_SEPARATOR),
|
|
153
|
+
index: startOf(table.range),
|
|
154
|
+
line: table.loc.start.line
|
|
155
|
+
}];
|
|
156
|
+
return pipe(table.body, Array.map((value) => ({
|
|
157
|
+
section: CARGO_PATCH,
|
|
158
|
+
key: Array.join([...tableKey, ...pipe(value.key.keys, Array.map(partName))], KEY_SEPARATOR),
|
|
159
|
+
index: startOf(value.range),
|
|
160
|
+
line: value.loc.start.line
|
|
161
|
+
})));
|
|
162
|
+
};
|
|
163
|
+
const isTable = (node) => node.type === "TOMLTable";
|
|
164
|
+
const cargoDeviations = (source) => pipe(Option.liftThrowable(() => parseTOML(source).body)(), Option.flatMap(decodeTomlTop), Option.match({
|
|
165
|
+
onNone: () => NONE,
|
|
166
|
+
onSome: (tops) => ({
|
|
167
|
+
entries: pipe(tops, Array.flatMap(({ body }) => body), Array.filter(isTable), Array.flatMap(patchEntries)),
|
|
168
|
+
comments: lineComments(source, tomlSourceComments(source))
|
|
169
|
+
})
|
|
170
|
+
}));
|
|
171
|
+
const commentsByLine = (comments) => HashMap.fromIterable(pipe(comments, Array.map((comment) => [comment.line, comment])));
|
|
172
|
+
// src/features/check-upstream-exits/model/exit-condition.ts
|
|
173
|
+
const ALTERNATIVE = " || ";
|
|
174
|
+
const UNUSED = "unused";
|
|
175
|
+
const ANY_RANGE = "*";
|
|
176
|
+
const EXIT_COMMENT = /^#?\s*exit:\s*(?<condition>.*?)\s*$/u;
|
|
177
|
+
const PACKAGE = String.raw`(?:@[^\s/@]+\/)?[^\s@]+`;
|
|
178
|
+
const REGISTRY_CONDITION = new RegExp(String.raw`^(?<registry>npm|crate):(?<name>${PACKAGE})(?:@(?<range>.+)| (?<relation>drops|allows|requires) (?<dependency>${PACKAGE})(?:@(?<dependencyRange>.+))?)$`, "u");
|
|
179
|
+
const GITHUB_CONDITION = /^github:(?<owner>[\w.-]+)\/(?<repo>[\w.-]+)#(?<number>[1-9]\d*)$/u;
|
|
180
|
+
const GRAMMAR = "`unused`, `npm:<package>@<range>`, `npm:<package> drops <dependency>`, `npm:<package> allows <dependency>@<range>`, `npm:<package> requires <dependency>@<range>` (the same forms with `crate:`), or `github:<owner>/<repo>#<number>`, joined with ` || `";
|
|
181
|
+
const isRegistry = (value) => value === "npm" || value === "crate";
|
|
182
|
+
const isRelation = (value) => value === "drops" || value === "allows" || value === "requires";
|
|
183
|
+
const validRange = (range) => Option.liftPredicate(range, (candidate) => semver.validRange(candidate) !== null);
|
|
184
|
+
const declared = (subject, found) => {
|
|
185
|
+
const relation = Option.filter(groupOf("relation")(found), isRelation);
|
|
186
|
+
const dependency = groupOf("dependency")(found);
|
|
187
|
+
const range = groupOf("dependencyRange")(found);
|
|
188
|
+
if (Option.isNone(relation) || Option.isNone(dependency)) return Option.none();
|
|
189
|
+
const base = {
|
|
190
|
+
kind: "declares",
|
|
191
|
+
...subject,
|
|
192
|
+
relation: relation.value,
|
|
193
|
+
dependency: dependency.value
|
|
194
|
+
};
|
|
195
|
+
if (relation.value === "drops") return Option.match(range, {
|
|
196
|
+
onNone: () => Option.some({
|
|
197
|
+
...base,
|
|
198
|
+
range: ANY_RANGE
|
|
199
|
+
}),
|
|
200
|
+
onSome: () => Option.none()
|
|
201
|
+
});
|
|
202
|
+
return pipe(range, Option.flatMap(validRange), Option.map((valid) => ({
|
|
203
|
+
...base,
|
|
204
|
+
range: valid
|
|
205
|
+
})));
|
|
206
|
+
};
|
|
207
|
+
const registryCondition = (text) => {
|
|
208
|
+
const found = REGISTRY_CONDITION.exec(text);
|
|
209
|
+
if (found === null) return Option.none();
|
|
210
|
+
const subject = Option.all({
|
|
211
|
+
registry: Option.filter(groupOf("registry")(found), isRegistry),
|
|
212
|
+
name: groupOf("name")(found)
|
|
213
|
+
});
|
|
214
|
+
const range = groupOf("range")(found);
|
|
215
|
+
const conditionOf = (resolved) => Option.match(range, {
|
|
216
|
+
onNone: () => declared(resolved, found),
|
|
217
|
+
onSome: (published) => Option.map(validRange(published), (valid) => ({
|
|
218
|
+
kind: "published",
|
|
219
|
+
...resolved,
|
|
220
|
+
range: valid
|
|
221
|
+
}))
|
|
222
|
+
});
|
|
223
|
+
return pipe(subject, Option.flatMap(conditionOf));
|
|
224
|
+
};
|
|
225
|
+
const githubCondition = (text) => {
|
|
226
|
+
const found = GITHUB_CONDITION.exec(text);
|
|
227
|
+
const issueNumber = pipe(groupOf("number")(found), Option.map(Number));
|
|
228
|
+
return pipe(Option.all({
|
|
229
|
+
owner: groupOf("owner")(found),
|
|
230
|
+
repo: groupOf("repo")(found),
|
|
231
|
+
number: issueNumber
|
|
232
|
+
}), Option.map((issue) => ({
|
|
233
|
+
kind: "closed",
|
|
234
|
+
...issue
|
|
235
|
+
})));
|
|
236
|
+
};
|
|
237
|
+
const alternativeOf = (text) => {
|
|
238
|
+
if (text === UNUSED) return Option.some({ kind: "unused" });
|
|
239
|
+
return Option.orElse(registryCondition(text), () => githubCondition(text));
|
|
240
|
+
};
|
|
241
|
+
const parseCondition = (text) => pipe(String$1.split(text, ALTERNATIVE), Array.map((alternative) => alternativeOf(String$1.trim(alternative))), Option.all);
|
|
242
|
+
const exitTextOf = (comment) => groupOf("condition")(EXIT_COMMENT.exec(String$1.trim(comment)));
|
|
243
|
+
const describeDeclares = (condition) => {
|
|
244
|
+
const subject = `${condition.registry}:${condition.name} ${condition.relation} ${condition.dependency}`;
|
|
245
|
+
if (condition.relation === "drops") return subject;
|
|
246
|
+
return `${subject}@${condition.range}`;
|
|
247
|
+
};
|
|
248
|
+
const describeCondition = (condition) => Match.value(condition).pipe(Match.discriminatorsExhaustive("kind")({
|
|
249
|
+
unused: () => UNUSED,
|
|
250
|
+
published: ({ registry, name, range }) => `${registry}:${name}@${range}`,
|
|
251
|
+
declares: describeDeclares,
|
|
252
|
+
closed: ({ owner, repo, number }) => `github:${owner}/${repo}#${String(number)}`
|
|
253
|
+
}));
|
|
254
|
+
const isUnused = (condition) => condition.kind === "unused";
|
|
255
|
+
// src/features/check-upstream-exits/model/met-exits.ts
|
|
256
|
+
const NPM = "https://registry.npmjs.org/";
|
|
257
|
+
const CRATES = "https://crates.io/api/v1/crates/";
|
|
258
|
+
const GITHUB = "https://api.github.com/repos/";
|
|
259
|
+
const USER_AGENT = "msch-exits (https://github.com/masseater/masseater.dev/tree/main/libs/msch)";
|
|
260
|
+
const LOOKUP_CONCURRENCY = 4;
|
|
261
|
+
const RANGE_OPTIONS = { includePrerelease: true };
|
|
262
|
+
const DECLARING_SECTIONS = [
|
|
263
|
+
"optionalDependencies",
|
|
264
|
+
"peerDependencies",
|
|
265
|
+
"dependencies"
|
|
266
|
+
];
|
|
267
|
+
const Dependencies = Schema.Record(Schema.String, Schema.String);
|
|
268
|
+
const NpmVersion = Schema.Record(Schema.String, Schema.Unknown);
|
|
269
|
+
const decodeDependencies = Schema.decodeUnknownOption(Dependencies);
|
|
270
|
+
const NpmPackument = Schema.Struct({
|
|
271
|
+
"dist-tags": Schema.Struct({ latest: Schema.String }),
|
|
272
|
+
versions: Schema.Record(Schema.String, NpmVersion)
|
|
273
|
+
});
|
|
274
|
+
const Crate = Schema.Struct({
|
|
275
|
+
crate: Schema.Struct({
|
|
276
|
+
max_stable_version: Schema.NullOr(Schema.String),
|
|
277
|
+
newest_version: Schema.String
|
|
278
|
+
}),
|
|
279
|
+
versions: Schema.Array(Schema.Struct({
|
|
280
|
+
num: Schema.String,
|
|
281
|
+
yanked: Schema.Boolean
|
|
282
|
+
}))
|
|
283
|
+
});
|
|
284
|
+
const CrateDependencies = Schema.Struct({ dependencies: Schema.Array(Schema.Struct({
|
|
285
|
+
crate_id: Schema.String,
|
|
286
|
+
req: Schema.String
|
|
287
|
+
})) });
|
|
288
|
+
const Issue = Schema.Struct({ state: Schema.String });
|
|
289
|
+
const requestOf = ({ url, token }) => {
|
|
290
|
+
const request = HttpClientRequest.get(url).pipe(HttpClientRequest.setHeader("user-agent", USER_AGENT), HttpClientRequest.acceptJson);
|
|
291
|
+
return Option.match(token, {
|
|
292
|
+
onNone: () => request,
|
|
293
|
+
onSome: (value) => HttpClientRequest.bearerToken(value)(request)
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
const fetched = (lookup) => HttpClient.HttpClient.pipe(Effect.flatMap((client) => HttpClient.filterStatusOk(client).execute(requestOf(lookup))));
|
|
297
|
+
const publicLookup = (url) => ({
|
|
298
|
+
url,
|
|
299
|
+
token: Option.none()
|
|
300
|
+
});
|
|
301
|
+
const declaredBy = (version) => pipe(DECLARING_SECTIONS, Array.flatMap((section) => pipe(decodeDependencies(version[section]), Option.map(Record.toEntries), Option.getOrElse(() => []))), Record.fromEntries);
|
|
302
|
+
const npmRelease = (name) => fetched(publicLookup(`${NPM}${String$1.replace("/", "%2f")(name)}`)).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(NpmPackument)), Effect.map(({ "dist-tags": tags, versions }) => ({
|
|
303
|
+
versions: Record.keys(versions),
|
|
304
|
+
latestDependencies: pipe(Record.get(versions, tags.latest), Option.map(declaredBy), Option.getOrElse(() => ({})))
|
|
305
|
+
})));
|
|
306
|
+
const crateRelease = Effect.fn("crateRelease")(function* lookupCrate(name) {
|
|
307
|
+
const found = yield* fetched(publicLookup(`${CRATES}${name}`)).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Crate)));
|
|
308
|
+
const latest = found.crate.max_stable_version ?? found.crate.newest_version;
|
|
309
|
+
const { dependencies } = yield* fetched(publicLookup(`${CRATES}${name}/${latest}/dependencies`)).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(CrateDependencies)));
|
|
310
|
+
return {
|
|
311
|
+
versions: pipe(found.versions, Array.filter(({ yanked }) => !yanked), Array.map(({ num }) => num)),
|
|
312
|
+
latestDependencies: Record.fromEntries(pipe(dependencies, Array.map(({ crate_id: crateId, req }) => [crateId, req])))
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
const releaseOf = (condition) => {
|
|
316
|
+
if (condition.registry === "npm") return npmRelease(condition.name);
|
|
317
|
+
return crateRelease(condition.name);
|
|
318
|
+
};
|
|
319
|
+
const declaresMet = (release) => (condition) => {
|
|
320
|
+
const declared = Record.get(release.latestDependencies, condition.dependency);
|
|
321
|
+
if (condition.relation === "drops") return Option.isNone(declared);
|
|
322
|
+
return Option.exists(declared, (range) => {
|
|
323
|
+
if (semver.validRange(range) === null) return false;
|
|
324
|
+
if (condition.relation === "allows") return semver.intersects(range, condition.range, RANGE_OPTIONS);
|
|
325
|
+
return semver.subset(range, condition.range, RANGE_OPTIONS);
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
/** @internal */
|
|
329
|
+
const isMet = (release) => (condition) => Match.value(condition).pipe(Match.discriminatorsExhaustive("kind")({
|
|
330
|
+
unused: () => false,
|
|
331
|
+
closed: () => false,
|
|
332
|
+
published: ({ range }) => pipe(release.versions, Array.some((version) => semver.satisfies(version, range))),
|
|
333
|
+
declares: declaresMet(release)
|
|
334
|
+
}));
|
|
335
|
+
const issueClosed = Effect.fn("issueClosed")(function* lookupIssue(condition) {
|
|
336
|
+
const token = yield* Config.option(Config.String("GH_TOKEN").pipe(Config.orElse(() => Config.String("GITHUB_TOKEN")))).pipe(Effect.orElseSucceed(() => Option.none()));
|
|
337
|
+
return (yield* fetched({
|
|
338
|
+
url: `${GITHUB}${condition.owner}/${condition.repo}/issues/${String(condition.number)}`,
|
|
339
|
+
token
|
|
340
|
+
}).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Issue)))).state === "closed";
|
|
341
|
+
});
|
|
342
|
+
const conditionMet = (condition) => Match.value(condition).pipe(Match.discriminatorsExhaustive("kind")({
|
|
343
|
+
unused: () => Effect.succeed(false),
|
|
344
|
+
closed: issueClosed,
|
|
345
|
+
published: (published) => Effect.map(releaseOf(published), (release) => isMet(release)(published)),
|
|
346
|
+
declares: (declares) => Effect.map(releaseOf(declares), (release) => isMet(release)(declares))
|
|
347
|
+
}));
|
|
348
|
+
/** @internal */
|
|
349
|
+
const exitEntries = (deviations) => {
|
|
350
|
+
const comments = commentsByLine(deviations.comments);
|
|
351
|
+
const entryOf = ({ line, section, key }) => pipe(HashMap.get(comments, line), Option.flatMap(({ text }) => exitTextOf(text)), Option.flatMap(parseCondition), Option.map((conditions) => ({
|
|
352
|
+
line,
|
|
353
|
+
section,
|
|
354
|
+
key,
|
|
355
|
+
conditions
|
|
356
|
+
})), Option.toArray);
|
|
357
|
+
return pipe(deviations.entries, Array.flatMap(entryOf));
|
|
358
|
+
};
|
|
359
|
+
const metOf = (entry, condition) => {
|
|
360
|
+
const described = describeCondition(condition);
|
|
361
|
+
return conditionMet(condition).pipe(Effect.match({
|
|
362
|
+
onSuccess: (met) => Option.liftPredicate({
|
|
363
|
+
entry,
|
|
364
|
+
condition: described,
|
|
365
|
+
outcome: "met"
|
|
366
|
+
}, () => met),
|
|
367
|
+
onFailure: (error) => Option.some({
|
|
368
|
+
entry,
|
|
369
|
+
condition: `${described} (${String(error)})`,
|
|
370
|
+
outcome: "unchecked"
|
|
371
|
+
})
|
|
372
|
+
}));
|
|
373
|
+
};
|
|
374
|
+
/** @internal */
|
|
375
|
+
const metExits = Effect.fn("metExits")(function* metExits(entries) {
|
|
376
|
+
const checksOf = (entry) => pipe(entry.conditions, Array.map((condition) => metOf(entry, condition)));
|
|
377
|
+
const checks = pipe(entries, Array.flatMap(checksOf));
|
|
378
|
+
const results = yield* Effect.all(checks, { concurrency: LOOKUP_CONCURRENCY });
|
|
379
|
+
return Array.getSomes(results);
|
|
380
|
+
});
|
|
381
|
+
// src/features/check-upstream-exits/model/upstream-exits.ts
|
|
382
|
+
const RULE$1 = "upstream-exit";
|
|
383
|
+
const ROOT_FILES = [{
|
|
384
|
+
name: "pnpm-workspace.yaml",
|
|
385
|
+
deviationsOf: workspaceDeviations
|
|
386
|
+
}, {
|
|
387
|
+
name: "Cargo.toml",
|
|
388
|
+
deviationsOf: cargoDeviations
|
|
389
|
+
}];
|
|
390
|
+
const REASON = "Every deviation from an upstream package is temporary, and the comment says when to go back to the official package so that msch-exits can tell.";
|
|
391
|
+
const STRAY = "An exit condition belongs at the end of the line of an overrides, patchedDependencies, packageExtensions or [patch] entry. Move it there or delete it.";
|
|
392
|
+
const problemAt$1 = ({ file, source }) => (index, message) => ({
|
|
393
|
+
file,
|
|
394
|
+
...positionOf(source)(index),
|
|
395
|
+
rule: RULE$1,
|
|
396
|
+
message
|
|
397
|
+
});
|
|
398
|
+
const messageFor = (entry, exitText) => {
|
|
399
|
+
if (Option.isNone(exitText)) return Option.some(`${entry.section} entry ${entry.key} has no exit condition. ${REASON} Add \`# exit: <condition>\` at the end of the line, where the condition is ${GRAMMAR}.`);
|
|
400
|
+
const conditions = parseCondition(exitText.value);
|
|
401
|
+
if (Option.isNone(conditions)) return Option.some(`The exit condition \`${exitText.value}\` of ${entry.key} is not one msch-exits can check. Write ${GRAMMAR}.`);
|
|
402
|
+
if (entry.section !== "overrides" && pipe(conditions.value, Array.some(isUnused))) return Option.some(`\`unused\` is checked only for overrides, by the unused-override and removable-override checks. Give ${entry.key} a condition on a release or an issue.`);
|
|
403
|
+
return Option.none();
|
|
404
|
+
};
|
|
405
|
+
const entryProblems = (read) => {
|
|
406
|
+
const comments = commentsByLine(read.deviations.comments);
|
|
407
|
+
return pipe(read.deviations.entries, Array.flatMap((entry) => {
|
|
408
|
+
const exitText = pipe(HashMap.get(comments, entry.line), Option.flatMap(({ text }) => exitTextOf(text)));
|
|
409
|
+
return pipe(messageFor(entry, exitText), Option.map((message) => problemAt$1(read)(entry.index, message)), Option.toArray);
|
|
410
|
+
}));
|
|
411
|
+
};
|
|
412
|
+
const strayProblems = (read) => {
|
|
413
|
+
const entryLines = HashSet.fromIterable(pipe(read.deviations.entries, Array.map(({ line }) => line)));
|
|
414
|
+
return pipe(read.deviations.comments, Array.filter((comment) => Option.isSome(exitTextOf(comment.text)) && !HashSet.has(entryLines, comment.line)), Array.map((comment) => problemAt$1(read)(comment.index, STRAY)));
|
|
415
|
+
};
|
|
416
|
+
const readRootFiles = Effect.fn("readRootFiles")(function* readRootFiles(root) {
|
|
417
|
+
const files = yield* RepositoryFiles;
|
|
418
|
+
const read = yield* Effect.forEach(ROOT_FILES, ({ name, deviationsOf }) => {
|
|
419
|
+
const file = files.join(root, name);
|
|
420
|
+
return Effect.map(files.readFile(file), Option.map((source) => ({
|
|
421
|
+
file,
|
|
422
|
+
source,
|
|
423
|
+
deviations: deviationsOf(source)
|
|
424
|
+
})));
|
|
425
|
+
}, { concurrency: "unbounded" });
|
|
426
|
+
return Array.getSomes(read);
|
|
427
|
+
});
|
|
428
|
+
/** @internal */
|
|
429
|
+
const checkUpstreamExits = Effect.fn("checkUpstreamExits")(function* checkUpstreamExits(root) {
|
|
430
|
+
const read = yield* readRootFiles(root);
|
|
431
|
+
return pipe(read, Array.flatMap((file) => [...entryProblems(file), ...strayProblems(file)]));
|
|
432
|
+
});
|
|
433
|
+
/** @internal */
|
|
434
|
+
const upstreamExitsMet = Effect.fn("upstreamExitsMet")(function* upstreamExitsMet(root) {
|
|
435
|
+
const read = yield* readRootFiles(root);
|
|
436
|
+
const perFile = yield* Effect.forEach(read, ({ file, deviations }) => {
|
|
437
|
+
const entries = exitEntries(deviations);
|
|
438
|
+
return Effect.map(metExits(entries), Array.map((met) => ({
|
|
439
|
+
file,
|
|
440
|
+
met
|
|
441
|
+
})));
|
|
442
|
+
}, { concurrency: 1 });
|
|
443
|
+
return Array.flatten(perFile);
|
|
444
|
+
});
|
|
445
|
+
// src/features/check-upstream-exits/model/scattered-deviations.ts
|
|
446
|
+
const RULE = "upstream-deviation-place";
|
|
447
|
+
const MANIFEST = "package.json";
|
|
448
|
+
const NESTED_WORKSPACE = "/pnpm-workspace.yaml";
|
|
449
|
+
const NESTED_CARGO = "/Cargo.toml";
|
|
450
|
+
const CARGO_CONFIG = /(?:^|\/)\.cargo\/config(?:\.toml)?$/u;
|
|
451
|
+
const MANAGER_FIELDS = ["overrides", "resolutions"];
|
|
452
|
+
const START = 0;
|
|
453
|
+
const PLACE = "Upstream deviations live only in the root pnpm-workspace.yaml (overrides, patchedDependencies, packageExtensions) and the root Cargo.toml ([patch]), each with an exit condition.";
|
|
454
|
+
const Fields = Schema.Record(Schema.String, Schema.Unknown);
|
|
455
|
+
const Manifest = Schema.fromJsonString(Schema.Struct({
|
|
456
|
+
pnpm: Schema.optional(Fields),
|
|
457
|
+
overrides: Schema.optional(Schema.Unknown),
|
|
458
|
+
resolutions: Schema.optional(Schema.Unknown)
|
|
459
|
+
}));
|
|
460
|
+
const decodeManifest = Schema.decodeUnknownOption(Manifest);
|
|
461
|
+
const isManifest = (name) => name === MANIFEST || String$1.endsWith(`/${MANIFEST}`)(name);
|
|
462
|
+
const problemAt = (entry, source) => (index, message) => ({
|
|
463
|
+
file: entry.file,
|
|
464
|
+
...positionOf(source)(index),
|
|
465
|
+
rule: RULE,
|
|
466
|
+
message
|
|
467
|
+
});
|
|
468
|
+
const keyIndex = (source, key) => Option.getOrElse(String$1.indexOf(`"${key}"`)(source), () => START);
|
|
469
|
+
const fieldsIn = (source) => pipe(decodeManifest(source), Option.match({
|
|
470
|
+
onNone: () => [],
|
|
471
|
+
onSome: (manifest) => {
|
|
472
|
+
const pnpm = Option.getOrElse(Option.fromUndefinedOr(manifest.pnpm), () => ({}));
|
|
473
|
+
const pnpmFields = pipe(WORKSPACE_SECTIONS, Array.filter((key) => Record.has(pnpm, key)), Array.map((key) => ({
|
|
474
|
+
name: `pnpm.${key}`,
|
|
475
|
+
key
|
|
476
|
+
})));
|
|
477
|
+
const managerFields = pipe(MANAGER_FIELDS, Array.filter((key) => Option.isSome(Option.fromUndefinedOr(manifest[key]))), Array.map((key) => ({
|
|
478
|
+
name: key,
|
|
479
|
+
key
|
|
480
|
+
})));
|
|
481
|
+
return [...pnpmFields, ...managerFields];
|
|
482
|
+
}
|
|
483
|
+
}));
|
|
484
|
+
const manifestProblems = (entry, source) => pipe(fieldsIn(source), Array.map(({ name, key }) => problemAt(entry, source)(keyIndex(source, key), `${name} in package.json is not allowed. ${PLACE} Move it there.`)));
|
|
485
|
+
const firstEntryProblem = (entry, source, deviations) => pipe(Array.head(deviations.entries), Option.map(({ index }) => problemAt(entry, source)(index, `This file is not read for upstream deviations. ${PLACE}`)), Option.toArray);
|
|
486
|
+
const problemsIn = (entry, source) => {
|
|
487
|
+
if (isManifest(entry.name)) return manifestProblems(entry, source);
|
|
488
|
+
if (String$1.endsWith(NESTED_WORKSPACE)(entry.name)) return firstEntryProblem(entry, source, workspaceDeviations(source));
|
|
489
|
+
return firstEntryProblem(entry, source, cargoDeviations(source));
|
|
490
|
+
};
|
|
491
|
+
const isScanned = ({ name }) => isManifest(name) || String$1.endsWith(NESTED_WORKSPACE)(name) || String$1.endsWith(NESTED_CARGO)(name) || CARGO_CONFIG.test(name);
|
|
492
|
+
/** @internal */
|
|
493
|
+
const checkScatteredDeviations = Effect.fn("checkScatteredDeviations")(function* checkScatteredDeviations(root) {
|
|
494
|
+
const listed = yield* listedFiles(root);
|
|
495
|
+
return yield* scanText(pipe(listed, Array.filter(isScanned)), problemsIn);
|
|
496
|
+
});
|
|
497
|
+
export { isRecord as a, isScannedText as c, presentFiles as d, scanText as f, collectNodes as i, isToolVersions as l, checkUpstreamExits as n, tomlSourceComments as o, positionOf as p, upstreamExitsMet as r, yamlSourceComments as s, checkScatteredDeviations as t, listedFiles as u };
|
|
498
|
+
|
|
499
|
+
//# sourceMappingURL=check-upstream-exits-BJNhgkLI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-upstream-exits-BJNhgkLI.mjs","names":["START","Str","Arr","Arr","Arr","Rec","YamlParser","Str","Arr","Str","Arr","Arr","Rec","Str","RULE","problemAt","Arr","Str","Arr","Rec"],"sources":["../src/shared/lib/text-position.ts","../src/shared/lib/scanned-files.ts","../src/shared/lib/config-comments.ts","../src/features/check-upstream-exits/model/deviation-entries.ts","../src/features/check-upstream-exits/model/exit-condition.ts","../src/features/check-upstream-exits/model/met-exits.ts","../src/features/check-upstream-exits/model/upstream-exits.ts","../src/features/check-upstream-exits/model/scattered-deviations.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem } from \"./problem.ts\";\n\nconst START = 0;\nconst FIRST_COLUMN = 1;\n\nexport const positionOf =\n (source: string) =>\n (index: number): Pick<Problem, \"line\" | \"column\"> => {\n const before = pipe(source, Str.slice(START, index), Str.split(\"\\n\"));\n return {\n line: before.length,\n column: pipe(\n Arr.last(before),\n Option.match({ onNone: () => FIRST_COLUMN, onSome: (last) => last.length + FIRST_COLUMN }),\n ),\n };\n };\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { Problem } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst SCANNED_FILE =\n /(?:\\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\\/)(?:(?:Dockerfile|Containerfile)[^/]*|Makefile|justfile|\\.tool-versions|[^./][^./]*))$/u;\n\nconst LOCKFILE = /(?:^|\\/)(?:[^/]*\\.lock|[^/]*-lock\\.(?:json|ya?ml))$/u;\n\nconst TOOL_VERSIONS = /(?:^|\\/)(?:\\.?mise(?:\\.[^/]+)?\\.toml|\\.tool-versions)$/u;\n\nconst READ_CONCURRENCY = 64;\n\nexport interface Listed {\n readonly name: string;\n readonly file: string;\n}\n\nexport const isScannedText = ({ name }: Listed): boolean =>\n SCANNED_FILE.test(name) && !LOCKFILE.test(name);\n\nexport const isToolVersions = ({ name }: Listed): boolean => TOOL_VERSIONS.test(name);\n\n/** @internal */\nexport const listedFiles = Effect.fn(\"listedFiles\")(function* listedFiles(root: string) {\n const files = yield* RepositoryFiles;\n const names = yield* files.ownedFiles(root);\n return pipe(\n names,\n Arr.map((name): Listed => ({ name, file: files.join(root, name) })),\n );\n});\n\n/** @internal */\nexport const presentFiles = Effect.fn(\"presentFiles\")(function* presentFiles(\n listed: readonly Listed[],\n) {\n const files = yield* RepositoryFiles;\n return yield* pipe(\n listed,\n Effect.filter(({ file }) => files.exists(file)),\n );\n});\n\n/** @internal */\nexport const scanText = Effect.fn(\"scanText\")(function* scanText(\n listed: readonly Listed[],\n problemsIn: (entry: Listed, source: string) => readonly Problem[],\n) {\n const files = yield* RepositoryFiles;\n const found = yield* Effect.forEach(\n listed,\n (entry) =>\n files.readFile(entry.file).pipe(\n Effect.map(\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => problemsIn(entry, source),\n }),\n ),\n ),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Record as Rec, String as Str, pipe } from \"effect\";\nimport { parseTOML } from \"toml-eslint-parser\";\nimport { Parser as YamlParser } from \"yaml\";\n\nexport interface SourceComment {\n readonly index: number;\n readonly text: string;\n}\n\nexport const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === \"object\" && value !== null;\n\nconst childrenOf = (value: unknown): readonly unknown[] => {\n if (Arr.isArray(value)) {\n return value;\n }\n if (isRecord(value)) {\n return Rec.values(value);\n }\n return [];\n};\n\nexport const collectNodes =\n <Item>(isItem: (value: unknown) => value is Item) =>\n (value: unknown): readonly Item[] => {\n if (isItem(value)) {\n return [value];\n }\n return pipe(childrenOf(value), Arr.flatMap(collectNodes(isItem)));\n };\n\ninterface YamlSourceToken {\n readonly offset: number;\n readonly source: string;\n}\n\nconst isYamlComment = (value: unknown): value is YamlSourceToken =>\n isRecord(value) &&\n value[\"type\"] === \"comment\" &&\n typeof value[\"offset\"] === \"number\" &&\n typeof value[\"source\"] === \"string\";\n\nexport const yamlSourceComments = (source: string): readonly SourceComment[] =>\n pipe(\n Arr.fromIterable(new YamlParser().parse(source)),\n Arr.flatMap(collectNodes(isYamlComment)),\n Arr.map((token) => ({ index: token.offset, text: token.source })),\n );\n\nexport const tomlSourceComments = (source: string): readonly SourceComment[] =>\n pipe(\n parseTOML(source).comments,\n Arr.map(({ range: [start, end] }) => ({\n index: start,\n text: Str.slice(start, end)(source),\n })),\n );\n","import { Array as Arr, HashMap, Option, Schema, pipe } from \"effect\";\nimport { parseTOML } from \"toml-eslint-parser\";\nimport { parseDocument } from \"yaml\";\n\nimport { tomlSourceComments, yamlSourceComments } from \"#/shared/lib/config-comments.ts\";\nimport type { SourceComment } from \"#/shared/lib/config-comments.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nexport const WORKSPACE_SECTIONS = [\n \"overrides\",\n \"patchedDependencies\",\n \"packageExtensions\",\n] as const;\nconst CARGO_PATCH = \"patch\";\nconst KEY_SEPARATOR = \".\";\nconst PATCH_SOURCE_DEPTH = 2;\n\nexport type Section = (typeof WORKSPACE_SECTIONS)[number] | typeof CARGO_PATCH;\n\nexport interface DeviationEntry {\n readonly section: Section;\n readonly key: string;\n readonly index: number;\n readonly line: number;\n}\n\nexport interface LineComment extends SourceComment {\n readonly line: number;\n}\n\nexport interface Deviations {\n readonly entries: readonly DeviationEntry[];\n readonly comments: readonly LineComment[];\n}\n\nconst NONE: Deviations = { entries: [], comments: [] };\n\nconst KeyValue = Schema.Union([Schema.String, Schema.Finite]);\nconst Positions = Schema.Array(Schema.Finite);\nconst YamlKey = Schema.Struct({ value: KeyValue, range: Positions });\nconst YamlMap = Schema.Struct({ items: Schema.Array(Schema.Struct({ key: YamlKey })) });\n\nconst KeyPart = Schema.Union([\n Schema.Struct({ type: Schema.Literal(\"TOMLBare\"), name: Schema.String }),\n Schema.Struct({ type: Schema.Literal(\"TOMLQuoted\"), value: Schema.String }),\n]);\nconst Located = {\n range: Schema.Array(Schema.Finite),\n loc: Schema.Struct({ start: Schema.Struct({ line: Schema.Finite }) }),\n};\nconst TomlKeyValue = Schema.Struct({\n ...Located,\n type: Schema.Literal(\"TOMLKeyValue\"),\n key: Schema.Struct({ keys: Schema.Array(KeyPart) }),\n});\nconst TomlTable = Schema.Struct({\n ...Located,\n type: Schema.Literal(\"TOMLTable\"),\n resolvedKey: Schema.Array(Schema.Union([Schema.String, Schema.Finite])),\n body: Schema.Array(TomlKeyValue),\n});\nconst TomlNode = Schema.Union([TomlTable, TomlKeyValue]);\nconst TomlTop = Schema.Array(Schema.Struct({ body: Schema.Array(TomlNode) }));\n\ntype TomlTableType = typeof TomlTable.Type;\ntype KeyPartType = typeof KeyPart.Type;\n\nconst decodeYamlMap = Schema.decodeUnknownOption(YamlMap);\nconst decodeTomlTop = Schema.decodeUnknownOption(TomlTop);\nconst FIRST = 0;\n\nconst lineComments = (source: string, comments: readonly SourceComment[]): readonly LineComment[] =>\n pipe(\n comments,\n Arr.map((comment) => ({ ...comment, line: positionOf(source)(comment.index).line })),\n );\n\nconst startOf = (range: readonly number[]): number =>\n Option.getOrElse(Arr.get(range, FIRST), () => FIRST);\n\nconst sectionEntries =\n (source: string, sectionNode: (section: string) => unknown) =>\n (section: (typeof WORKSPACE_SECTIONS)[number]): readonly DeviationEntry[] =>\n pipe(\n decodeYamlMap(sectionNode(section)),\n Option.match({\n onNone: () => [],\n onSome: ({ items }) =>\n pipe(\n items,\n Arr.map(({ key }) => {\n const index = startOf(key.range);\n return {\n section,\n key: String(key.value),\n index,\n line: positionOf(source)(index).line,\n };\n }),\n ),\n }),\n );\n\nexport const workspaceDeviations = (source: string): Deviations => {\n const document = parseDocument(source);\n if (Arr.isReadonlyArrayNonEmpty(document.errors)) {\n return NONE;\n }\n const sectionNode = (section: string): unknown => document.get(section, true);\n return {\n entries: pipe(WORKSPACE_SECTIONS, Arr.flatMap(sectionEntries(source, sectionNode))),\n comments: lineComments(source, yamlSourceComments(source)),\n };\n};\n\nconst partName = (part: KeyPartType): string => {\n if (part.type === \"TOMLBare\") {\n return part.name;\n }\n return part.value;\n};\n\nconst patchEntries = (table: TomlTableType): readonly DeviationEntry[] => {\n const tableKey = pipe(table.resolvedKey, Arr.map(String));\n if (!Option.exists(Arr.get(tableKey, FIRST), (part) => part === CARGO_PATCH)) {\n return [];\n }\n if (tableKey.length > PATCH_SOURCE_DEPTH) {\n return [\n {\n section: CARGO_PATCH,\n key: Arr.join(tableKey, KEY_SEPARATOR),\n index: startOf(table.range),\n line: table.loc.start.line,\n },\n ];\n }\n return pipe(\n table.body,\n Arr.map((value) => ({\n section: CARGO_PATCH,\n key: Arr.join([...tableKey, ...pipe(value.key.keys, Arr.map(partName))], KEY_SEPARATOR),\n index: startOf(value.range),\n line: value.loc.start.line,\n })),\n );\n};\n\nconst isTable = (node: TomlTableType | typeof TomlKeyValue.Type): node is TomlTableType =>\n node.type === \"TOMLTable\";\n\nexport const cargoDeviations = (source: string): Deviations =>\n pipe(\n Option.liftThrowable(() => parseTOML(source).body)(),\n Option.flatMap(decodeTomlTop),\n Option.match({\n onNone: () => NONE,\n onSome: (tops) => ({\n entries: pipe(\n tops,\n Arr.flatMap(({ body }) => body),\n Arr.filter(isTable),\n Arr.flatMap(patchEntries),\n ),\n comments: lineComments(source, tomlSourceComments(source)),\n }),\n }),\n );\n\nexport const commentsByLine = (\n comments: readonly LineComment[],\n): HashMap.HashMap<number, LineComment> =>\n HashMap.fromIterable(\n pipe(\n comments,\n Arr.map((comment) => [comment.line, comment] as const),\n ),\n );\n","import { Array as Arr, Match, Option, String as Str, pipe } from \"effect\";\nimport semver from \"semver\";\n\nimport { groupOf } from \"#/shared/lib/match-groups.ts\";\n\nexport type Registry = \"npm\" | \"crate\";\nexport type Relation = \"drops\" | \"allows\" | \"requires\";\n\nexport interface Unused {\n readonly kind: \"unused\";\n}\n\nexport interface Published {\n readonly kind: \"published\";\n readonly registry: Registry;\n readonly name: string;\n readonly range: string;\n}\n\nexport interface Declares {\n readonly kind: \"declares\";\n readonly registry: Registry;\n readonly name: string;\n readonly relation: Relation;\n readonly dependency: string;\n readonly range: string;\n}\n\nexport interface Closed {\n readonly kind: \"closed\";\n readonly owner: string;\n readonly repo: string;\n readonly number: number;\n}\n\nexport type ExitCondition = Unused | Published | Declares | Closed;\n\nconst ALTERNATIVE = \" || \";\nconst UNUSED = \"unused\";\nconst ANY_RANGE = \"*\";\nconst EXIT_COMMENT = /^#?\\s*exit:\\s*(?<condition>.*?)\\s*$/u;\nconst PACKAGE = String.raw`(?:@[^\\s/@]+\\/)?[^\\s@]+`;\nconst REGISTRY_CONDITION = new RegExp(\n String.raw`^(?<registry>npm|crate):(?<name>${PACKAGE})(?:@(?<range>.+)| (?<relation>drops|allows|requires) (?<dependency>${PACKAGE})(?:@(?<dependencyRange>.+))?)$`,\n \"u\",\n);\nconst GITHUB_CONDITION = /^github:(?<owner>[\\w.-]+)\\/(?<repo>[\\w.-]+)#(?<number>[1-9]\\d*)$/u;\n\nexport const GRAMMAR =\n \"`unused`, `npm:<package>@<range>`, `npm:<package> drops <dependency>`, `npm:<package> allows <dependency>@<range>`, `npm:<package> requires <dependency>@<range>` (the same forms with `crate:`), or `github:<owner>/<repo>#<number>`, joined with ` || `\";\n\nconst isRegistry = (value: string): value is Registry => value === \"npm\" || value === \"crate\";\n\nconst isRelation = (value: string): value is Relation =>\n value === \"drops\" || value === \"allows\" || value === \"requires\";\n\nconst validRange = (range: string): Option.Option<string> =>\n Option.liftPredicate(range, (candidate) => semver.validRange(candidate) !== null);\n\ninterface Subject {\n readonly registry: Registry;\n readonly name: string;\n}\n\nconst declared = (subject: Subject, found: RegExpExecArray): Option.Option<ExitCondition> => {\n const relation = Option.filter(groupOf(\"relation\")(found), isRelation);\n const dependency = groupOf(\"dependency\")(found);\n const range = groupOf(\"dependencyRange\")(found);\n if (Option.isNone(relation) || Option.isNone(dependency)) {\n return Option.none();\n }\n const base = {\n kind: \"declares\",\n ...subject,\n relation: relation.value,\n dependency: dependency.value,\n } as const;\n if (relation.value === \"drops\") {\n return Option.match(range, {\n onNone: () => Option.some({ ...base, range: ANY_RANGE }),\n onSome: () => Option.none(),\n });\n }\n return pipe(\n range,\n Option.flatMap(validRange),\n Option.map((valid): ExitCondition => ({ ...base, range: valid })),\n );\n};\n\nconst registryCondition = (text: string): Option.Option<ExitCondition> => {\n const found = REGISTRY_CONDITION.exec(text);\n if (found === null) {\n return Option.none();\n }\n const subject = Option.all({\n registry: Option.filter(groupOf(\"registry\")(found), isRegistry),\n name: groupOf(\"name\")(found),\n });\n const range = groupOf(\"range\")(found);\n const conditionOf = (resolved: Subject): Option.Option<ExitCondition> =>\n Option.match(range, {\n onNone: () => declared(resolved, found),\n onSome: (published) =>\n Option.map(validRange(published), (valid): ExitCondition => ({\n kind: \"published\",\n ...resolved,\n range: valid,\n })),\n });\n return pipe(subject, Option.flatMap(conditionOf));\n};\n\nconst githubCondition = (text: string): Option.Option<ExitCondition> => {\n const found = GITHUB_CONDITION.exec(text);\n const issueNumber = pipe(groupOf(\"number\")(found), Option.map(Number));\n return pipe(\n Option.all({\n owner: groupOf(\"owner\")(found),\n repo: groupOf(\"repo\")(found),\n number: issueNumber,\n }),\n Option.map((issue): ExitCondition => ({ kind: \"closed\", ...issue })),\n );\n};\n\nconst alternativeOf = (text: string): Option.Option<ExitCondition> => {\n if (text === UNUSED) {\n return Option.some({ kind: \"unused\" });\n }\n return Option.orElse(registryCondition(text), () => githubCondition(text));\n};\n\nexport const parseCondition = (text: string): Option.Option<readonly ExitCondition[]> =>\n pipe(\n Str.split(text, ALTERNATIVE),\n Arr.map((alternative) => alternativeOf(Str.trim(alternative))),\n Option.all,\n );\n\nexport const exitTextOf = (comment: string): Option.Option<string> =>\n groupOf(\"condition\")(EXIT_COMMENT.exec(Str.trim(comment)));\n\nconst describeDeclares = (condition: Declares): string => {\n const subject = `${condition.registry}:${condition.name} ${condition.relation} ${condition.dependency}`;\n if (condition.relation === \"drops\") {\n return subject;\n }\n return `${subject}@${condition.range}`;\n};\n\nexport const describeCondition = (condition: ExitCondition): string =>\n Match.value(condition).pipe(\n Match.discriminatorsExhaustive(\"kind\")({\n unused: () => UNUSED,\n published: ({ registry, name, range }) => `${registry}:${name}@${range}`,\n declares: describeDeclares,\n closed: ({ owner, repo, number }) => `github:${owner}/${repo}#${String(number)}`,\n }),\n );\n\nexport const isUnused = (condition: ExitCondition): boolean => condition.kind === \"unused\";\n","import {\n Array as Arr,\n Config,\n Effect,\n HashMap,\n Match,\n Option,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpClientError } from \"effect/http\";\nimport semver from \"semver\";\n\nimport { commentsByLine } from \"./deviation-entries.ts\";\nimport type { DeviationEntry, Deviations, Section } from \"./deviation-entries.ts\";\nimport { describeCondition, exitTextOf, parseCondition } from \"./exit-condition.ts\";\nimport type { Closed, Declares, ExitCondition, Published } from \"./exit-condition.ts\";\n\nconst NPM = \"https://registry.npmjs.org/\";\nconst CRATES = \"https://crates.io/api/v1/crates/\";\nconst GITHUB = \"https://api.github.com/repos/\";\nconst USER_AGENT = \"msch-exits (https://github.com/masseater/masseater.dev/tree/main/libs/msch)\";\nconst LOOKUP_CONCURRENCY = 4;\nconst RANGE_OPTIONS = { includePrerelease: true } as const;\n\nconst DECLARING_SECTIONS = [\"optionalDependencies\", \"peerDependencies\", \"dependencies\"] as const;\nconst Dependencies = Schema.Record(Schema.String, Schema.String);\nconst NpmVersion = Schema.Record(Schema.String, Schema.Unknown);\nconst decodeDependencies = Schema.decodeUnknownOption(Dependencies);\nconst NpmPackument = Schema.Struct({\n \"dist-tags\": Schema.Struct({ latest: Schema.String }),\n versions: Schema.Record(Schema.String, NpmVersion),\n});\nconst Crate = Schema.Struct({\n crate: Schema.Struct({\n max_stable_version: Schema.NullOr(Schema.String),\n newest_version: Schema.String,\n }),\n versions: Schema.Array(Schema.Struct({ num: Schema.String, yanked: Schema.Boolean })),\n});\nconst CrateDependencies = Schema.Struct({\n dependencies: Schema.Array(Schema.Struct({ crate_id: Schema.String, req: Schema.String })),\n});\nconst Issue = Schema.Struct({ state: Schema.String });\n\ntype NpmVersionType = typeof NpmVersion.Type;\ntype LookupError = HttpClientError.HttpClientError | Schema.SchemaError;\n\n/** @internal */\nexport interface Release {\n readonly versions: readonly string[];\n readonly latestDependencies: Readonly<Record<string, string>>;\n}\n\n/** @internal */\nexport interface ExitEntry {\n readonly line: number;\n readonly section: Section;\n readonly key: string;\n readonly conditions: readonly ExitCondition[];\n}\n\n/** @internal */\nexport interface MetExit {\n readonly entry: ExitEntry;\n readonly condition: string;\n readonly outcome: \"met\" | \"unchecked\";\n}\n\ninterface Lookup {\n readonly url: string;\n readonly token: Option.Option<string>;\n}\n\nconst requestOf = ({ url, token }: Lookup): HttpClientRequest.HttpClientRequest => {\n const request = HttpClientRequest.get(url).pipe(\n HttpClientRequest.setHeader(\"user-agent\", USER_AGENT),\n HttpClientRequest.acceptJson,\n );\n return Option.match(token, {\n onNone: () => request,\n onSome: (value) => HttpClientRequest.bearerToken(value)(request),\n });\n};\n\nconst fetched = (\n lookup: Lookup,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n> =>\n HttpClient.HttpClient.pipe(\n Effect.flatMap((client) => HttpClient.filterStatusOk(client).execute(requestOf(lookup))),\n );\n\nconst publicLookup = (url: string): Lookup => ({ url, token: Option.none() });\n\nconst declaredBy = (version: NpmVersionType): Readonly<Record<string, string>> =>\n pipe(\n DECLARING_SECTIONS,\n Arr.flatMap((section) =>\n pipe(\n decodeDependencies(version[section]),\n Option.map(Rec.toEntries),\n Option.getOrElse((): readonly (readonly [string, string])[] => []),\n ),\n ),\n Rec.fromEntries,\n );\n\nconst npmRelease = (name: string): Effect.Effect<Release, LookupError, HttpClient.HttpClient> =>\n fetched(publicLookup(`${NPM}${Str.replace(\"/\", \"%2f\")(name)}`)).pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(NpmPackument)),\n Effect.map(({ \"dist-tags\": tags, versions }) => ({\n versions: Rec.keys(versions),\n latestDependencies: pipe(\n Rec.get(versions, tags.latest),\n Option.map(declaredBy),\n Option.getOrElse(() => ({})),\n ),\n })),\n );\n\nconst crateRelease = Effect.fn(\"crateRelease\")(function* lookupCrate(name: string) {\n const found = yield* fetched(publicLookup(`${CRATES}${name}`)).pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(Crate)),\n );\n const latest = found.crate.max_stable_version ?? found.crate.newest_version;\n const { dependencies } = yield* fetched(\n publicLookup(`${CRATES}${name}/${latest}/dependencies`),\n ).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(CrateDependencies)));\n const release: Release = {\n versions: pipe(\n found.versions,\n Arr.filter(({ yanked }) => !yanked),\n Arr.map(({ num }) => num),\n ),\n latestDependencies: Rec.fromEntries(\n pipe(\n dependencies,\n Arr.map(({ crate_id: crateId, req }) => [crateId, req] as const),\n ),\n ),\n };\n return release;\n});\n\nconst releaseOf = (\n condition: Published | Declares,\n): Effect.Effect<Release, LookupError, HttpClient.HttpClient> => {\n if (condition.registry === \"npm\") {\n return npmRelease(condition.name);\n }\n return crateRelease(condition.name);\n};\n\nconst declaresMet =\n (release: Release) =>\n (condition: Declares): boolean => {\n const declared = Rec.get(release.latestDependencies, condition.dependency);\n if (condition.relation === \"drops\") {\n return Option.isNone(declared);\n }\n return Option.exists(declared, (range) => {\n if (semver.validRange(range) === null) {\n return false;\n }\n if (condition.relation === \"allows\") {\n return semver.intersects(range, condition.range, RANGE_OPTIONS);\n }\n return semver.subset(range, condition.range, RANGE_OPTIONS);\n });\n };\n\n/** @internal */\nexport const isMet =\n (release: Release) =>\n (condition: ExitCondition): boolean =>\n Match.value(condition).pipe(\n Match.discriminatorsExhaustive(\"kind\")({\n unused: () => false,\n closed: () => false,\n published: ({ range }) =>\n pipe(\n release.versions,\n Arr.some((version) => semver.satisfies(version, range)),\n ),\n declares: declaresMet(release),\n }),\n );\n\nconst issueClosed = Effect.fn(\"issueClosed\")(function* lookupIssue(condition: Closed) {\n const token = yield* Config.option(\n Config.String(\"GH_TOKEN\").pipe(Config.orElse(() => Config.String(\"GITHUB_TOKEN\"))),\n ).pipe(Effect.orElseSucceed(() => Option.none<string>()));\n const issue = yield* fetched({\n url: `${GITHUB}${condition.owner}/${condition.repo}/issues/${String(condition.number)}`,\n token,\n }).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Issue)));\n return issue.state === \"closed\";\n});\n\nconst conditionMet = (\n condition: ExitCondition,\n): Effect.Effect<boolean, LookupError, HttpClient.HttpClient> =>\n Match.value(condition).pipe(\n Match.discriminatorsExhaustive(\"kind\")({\n unused: () => Effect.succeed(false),\n closed: issueClosed,\n published: (published) =>\n Effect.map(releaseOf(published), (release) => isMet(release)(published)),\n declares: (declares) =>\n Effect.map(releaseOf(declares), (release) => isMet(release)(declares)),\n }),\n );\n\n/** @internal */\nexport const exitEntries = (deviations: Deviations): readonly ExitEntry[] => {\n const comments = commentsByLine(deviations.comments);\n const entryOf = ({ line, section, key }: DeviationEntry): readonly ExitEntry[] =>\n pipe(\n HashMap.get(comments, line),\n Option.flatMap(({ text }) => exitTextOf(text)),\n Option.flatMap(parseCondition),\n Option.map((conditions): ExitEntry => ({ line, section, key, conditions })),\n Option.toArray,\n );\n return pipe(deviations.entries, Arr.flatMap(entryOf));\n};\n\nconst metOf = (\n entry: ExitEntry,\n condition: ExitCondition,\n): Effect.Effect<Option.Option<MetExit>, never, HttpClient.HttpClient> => {\n const described = describeCondition(condition);\n return conditionMet(condition).pipe(\n Effect.match({\n onSuccess: (met) =>\n Option.liftPredicate({ entry, condition: described, outcome: \"met\" } as const, () => met),\n onFailure: (error) =>\n Option.some({\n entry,\n condition: `${described} (${String(error)})`,\n outcome: \"unchecked\",\n } as const),\n }),\n );\n};\n\n/** @internal */\nexport const metExits = Effect.fn(\"metExits\")(function* metExits(entries: readonly ExitEntry[]) {\n const checksOf = (entry: ExitEntry): readonly ReturnType<typeof metOf>[] =>\n pipe(\n entry.conditions,\n Arr.map((condition) => metOf(entry, condition)),\n );\n const checks = pipe(entries, Arr.flatMap(checksOf));\n const results = yield* Effect.all(checks, { concurrency: LOOKUP_CONCURRENCY });\n return Arr.getSomes(results);\n});\n","import { Array as Arr, Effect, HashMap, HashSet, Option, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nimport { cargoDeviations, commentsByLine, workspaceDeviations } from \"./deviation-entries.ts\";\nimport type { DeviationEntry, Deviations } from \"./deviation-entries.ts\";\nimport { GRAMMAR, exitTextOf, isUnused, parseCondition } from \"./exit-condition.ts\";\nimport { exitEntries, metExits } from \"./met-exits.ts\";\nimport type { ExitEntry, MetExit } from \"./met-exits.ts\";\n\nconst RULE: RuleName = \"upstream-exit\";\nconst ROOT_FILES = [\n { name: \"pnpm-workspace.yaml\", deviationsOf: workspaceDeviations },\n { name: \"Cargo.toml\", deviationsOf: cargoDeviations },\n] as const;\nconst REASON =\n \"Every deviation from an upstream package is temporary, and the comment says when to go back to the official package so that msch-exits can tell.\";\nconst STRAY =\n \"An exit condition belongs at the end of the line of an overrides, patchedDependencies, packageExtensions or [patch] entry. Move it there or delete it.\";\n\ninterface ReadFile {\n readonly file: string;\n readonly source: string;\n readonly deviations: Deviations;\n}\n\nconst problemAt =\n ({ file, source }: ReadFile) =>\n (index: number, message: string): Problem => ({\n file,\n ...positionOf(source)(index),\n rule: RULE,\n message,\n });\n\nconst messageFor = (\n entry: DeviationEntry,\n exitText: Option.Option<string>,\n): Option.Option<string> => {\n if (Option.isNone(exitText)) {\n return Option.some(\n `${entry.section} entry ${entry.key} has no exit condition. ${REASON} Add \\`# exit: <condition>\\` at the end of the line, where the condition is ${GRAMMAR}.`,\n );\n }\n const conditions = parseCondition(exitText.value);\n if (Option.isNone(conditions)) {\n return Option.some(\n `The exit condition \\`${exitText.value}\\` of ${entry.key} is not one msch-exits can check. Write ${GRAMMAR}.`,\n );\n }\n if (entry.section !== \"overrides\" && pipe(conditions.value, Arr.some(isUnused))) {\n return Option.some(\n `\\`unused\\` is checked only for overrides, by the unused-override and removable-override checks. Give ${entry.key} a condition on a release or an issue.`,\n );\n }\n return Option.none();\n};\n\nconst entryProblems = (read: ReadFile): readonly Problem[] => {\n const comments = commentsByLine(read.deviations.comments);\n return pipe(\n read.deviations.entries,\n Arr.flatMap((entry) => {\n const exitText = pipe(\n HashMap.get(comments, entry.line),\n Option.flatMap(({ text }) => exitTextOf(text)),\n );\n return pipe(\n messageFor(entry, exitText),\n Option.map((message) => problemAt(read)(entry.index, message)),\n Option.toArray,\n );\n }),\n );\n};\n\nconst strayProblems = (read: ReadFile): readonly Problem[] => {\n const entryLines = HashSet.fromIterable(\n pipe(\n read.deviations.entries,\n Arr.map(({ line }) => line),\n ),\n );\n return pipe(\n read.deviations.comments,\n Arr.filter(\n (comment) =>\n Option.isSome(exitTextOf(comment.text)) && !HashSet.has(entryLines, comment.line),\n ),\n Arr.map((comment) => problemAt(read)(comment.index, STRAY)),\n );\n};\n\nconst readRootFiles = Effect.fn(\"readRootFiles\")(function* readRootFiles(root: string) {\n const files = yield* RepositoryFiles;\n const read = yield* Effect.forEach(\n ROOT_FILES,\n ({ name, deviationsOf }) => {\n const file = files.join(root, name);\n return Effect.map(\n files.readFile(file),\n Option.map((source): ReadFile => ({ file, source, deviations: deviationsOf(source) })),\n );\n },\n { concurrency: \"unbounded\" },\n );\n return Arr.getSomes(read);\n});\n\n/** @internal */\nexport const checkUpstreamExits = Effect.fn(\"checkUpstreamExits\")(function* checkUpstreamExits(\n root: string,\n) {\n const read = yield* readRootFiles(root);\n return pipe(\n read,\n Arr.flatMap((file) => [...entryProblems(file), ...strayProblems(file)]),\n );\n});\n\n/** @internal */\nexport interface FileExit {\n readonly file: string;\n readonly met: MetExit;\n}\n\n/** @internal */\nexport const upstreamExitsMet = Effect.fn(\"upstreamExitsMet\")(function* upstreamExitsMet(\n root: string,\n) {\n const read = yield* readRootFiles(root);\n const perFile = yield* Effect.forEach(\n read,\n ({ file, deviations }) => {\n const entries: readonly ExitEntry[] = exitEntries(deviations);\n return Effect.map(\n metExits(entries),\n Arr.map((met): FileExit => ({ file, met })),\n );\n },\n { concurrency: 1 },\n );\n return Arr.flatten(perFile);\n});\n","import { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { listedFiles, scanText } from \"#/shared/lib/scanned-files.ts\";\nimport type { Listed } from \"#/shared/lib/scanned-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nimport { WORKSPACE_SECTIONS, cargoDeviations, workspaceDeviations } from \"./deviation-entries.ts\";\nimport type { Deviations } from \"./deviation-entries.ts\";\n\nconst RULE: RuleName = \"upstream-deviation-place\";\nconst MANIFEST = \"package.json\";\nconst NESTED_WORKSPACE = \"/pnpm-workspace.yaml\";\nconst NESTED_CARGO = \"/Cargo.toml\";\nconst CARGO_CONFIG = /(?:^|\\/)\\.cargo\\/config(?:\\.toml)?$/u;\nconst MANAGER_FIELDS = [\"overrides\", \"resolutions\"] as const;\nconst START = 0;\nconst PLACE =\n \"Upstream deviations live only in the root pnpm-workspace.yaml (overrides, patchedDependencies, packageExtensions) and the root Cargo.toml ([patch]), each with an exit condition.\";\n\nconst Fields = Schema.Record(Schema.String, Schema.Unknown);\nconst Manifest = Schema.fromJsonString(\n Schema.Struct({\n pnpm: Schema.optional(Fields),\n overrides: Schema.optional(Schema.Unknown),\n resolutions: Schema.optional(Schema.Unknown),\n }),\n);\nconst decodeManifest = Schema.decodeUnknownOption(Manifest);\n\ninterface Field {\n readonly name: string;\n readonly key: string;\n}\n\nconst isManifest = (name: string): boolean =>\n name === MANIFEST || Str.endsWith(`/${MANIFEST}`)(name);\n\nconst problemAt =\n (entry: Listed, source: string) =>\n (index: number, message: string): Problem => ({\n file: entry.file,\n ...positionOf(source)(index),\n rule: RULE,\n message,\n });\n\nconst keyIndex = (source: string, key: string): number =>\n Option.getOrElse(Str.indexOf(`\"${key}\"`)(source), () => START);\n\nconst fieldsIn = (source: string): readonly Field[] =>\n pipe(\n decodeManifest(source),\n Option.match({\n onNone: (): readonly Field[] => [],\n onSome: (manifest) => {\n const pnpm = Option.getOrElse(Option.fromUndefinedOr(manifest.pnpm), () => ({}));\n const pnpmFields = pipe(\n WORKSPACE_SECTIONS,\n Arr.filter((key) => Rec.has(pnpm, key)),\n Arr.map((key) => ({ name: `pnpm.${key}`, key })),\n );\n const managerFields = pipe(\n MANAGER_FIELDS,\n Arr.filter((key) => Option.isSome(Option.fromUndefinedOr(manifest[key]))),\n Arr.map((key) => ({ name: key, key })),\n );\n return [...pnpmFields, ...managerFields];\n },\n }),\n );\n\nconst manifestProblems = (entry: Listed, source: string): readonly Problem[] =>\n pipe(\n fieldsIn(source),\n Arr.map(({ name, key }) =>\n problemAt(entry, source)(\n keyIndex(source, key),\n `${name} in package.json is not allowed. ${PLACE} Move it there.`,\n ),\n ),\n );\n\nconst firstEntryProblem = (\n entry: Listed,\n source: string,\n deviations: Deviations,\n): readonly Problem[] =>\n pipe(\n Arr.head(deviations.entries),\n Option.map(({ index }) =>\n problemAt(entry, source)(index, `This file is not read for upstream deviations. ${PLACE}`),\n ),\n Option.toArray,\n );\n\nconst problemsIn = (entry: Listed, source: string): readonly Problem[] => {\n if (isManifest(entry.name)) {\n return manifestProblems(entry, source);\n }\n if (Str.endsWith(NESTED_WORKSPACE)(entry.name)) {\n return firstEntryProblem(entry, source, workspaceDeviations(source));\n }\n return firstEntryProblem(entry, source, cargoDeviations(source));\n};\n\nconst isScanned = ({ name }: Listed): boolean =>\n isManifest(name) ||\n Str.endsWith(NESTED_WORKSPACE)(name) ||\n Str.endsWith(NESTED_CARGO)(name) ||\n CARGO_CONFIG.test(name);\n\n/** @internal */\nexport const checkScatteredDeviations = Effect.fn(\"checkScatteredDeviations\")(\n function* checkScatteredDeviations(root: string) {\n const listed = yield* listedFiles(root);\n return yield* scanText(pipe(listed, Arr.filter(isScanned)), problemsIn);\n },\n);\n"],"mappings":";;;;;;;AAIA,MAAMA,UAAQ;AACd,MAAM,eAAe;AAErB,MAAa,cACV,YACA,UAAoD;CACnD,MAAM,SAAS,KAAK,QAAQC,SAAI,MAAMD,SAAO,KAAK,GAAGC,SAAI,MAAM,IAAI,CAAC;CACpE,OAAO;EACL,MAAM,OAAO;EACb,QAAQ,KACNC,MAAI,KAAK,MAAM,GACf,OAAO,MAAM;GAAE,cAAc;GAAc,SAAS,SAAS,KAAK,SAAS;EAAa,CAAC,CAC3F;CACF;AACF;;ACbF,MAAM,eACJ;AAEF,MAAM,WAAW;AAEjB,MAAM,gBAAgB;AAEtB,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AO,GAC3B,OAAO,KAAK,EAAE,YACZ,UAAU,OAAO,MAAM,CAAC,CAAC,OAAO,kDAAkD,OAAO,CAC3F,GACA,OAAO,OACT;AAEF,MAAM,cAAc,OAAe,WAAuC;CACxE,IAAI,WAAW,MAAM,IAAI,GACvB,OAAO,iBAAiB,OAAO,MAAM;CAEvC,IAAID,SAAI,SAAS,gBAAgB,CAAC,CAAC,MAAM,IAAI,GAC3C,OAAO,kBAAkB,OAAO,QAAQ,oBAAoB,MAAM,CAAC;CAErE,OAAO,kBAAkB,OAAO,QAAQ,gBAAgB,MAAM,CAAC;AACjE;AAEA,MAAM,aAAa,EAAE,WACnB,WAAW,IAAI,KACfA,SAAI,SAAS,gBAAgB,CAAC,CAAC,IAAI,KACnCA,SAAI,SAAS,YAAY,CAAC,CAAC,IAAI,KAC/B,aAAa,KAAK,IAAI;;AAGxB,MAAa,2BAA2B,OAAO,GAAG,0BAA0B,CAAC,CAC3E,UAAU,yBAAyB,MAAc;CAC/C,MAAM,SAAS,OAAO,YAAY,IAAI;CACtC,OAAO,OAAO,SAAS,KAAK,QAAQC,MAAI,OAAO,SAAS,CAAC,GAAG,UAAU;AACxE,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-contract-D7btWrEu.mjs","names":[],"sources":["../src/shared/lib/cli-contract.ts"],"sourcesContent":["export const JSON_FLAG = \"--json\";\n"],"mappings":";AAAA,MAAa,YAAY"}
|