@r_masseater/msch 0.41.0 → 0.42.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 +7 -0
- package/dist/cargo-inputs.d.mts +14 -0
- package/dist/cargo-inputs.mjs +226 -0
- package/dist/cargo-inputs.mjs.map +1 -0
- package/dist/{cli-contract-8SnKqhGw.mjs → cli-contract-DdTV5DaG.mjs} +2 -2
- package/dist/{cli-contract-8SnKqhGw.mjs.map → cli-contract-DdTV5DaG.mjs.map} +1 -1
- package/dist/cli.mjs +475 -462
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +9 -6
- package/dist/config.mjs.map +1 -1
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-BYMl7wof.mjs → define-lint-preset-DKJku2ZR.mjs} +124 -85
- package/dist/define-lint-preset-DKJku2ZR.mjs.map +1 -0
- package/dist/ignored-directories-CfACwIvu.mjs +50 -0
- package/dist/ignored-directories-CfACwIvu.mjs.map +1 -0
- package/dist/{index-lM4Pphgz.d.mts → index-BwiAHe_u.d.mts} +21 -16
- package/dist/{index-CcVKuHBw.d.mts → index-DdJXnW1q.d.mts} +2 -2
- package/dist/lint.d.mts +2 -2
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{package-A62qq8pE.mjs → package-vbK0Qycn.mjs} +2 -2
- package/dist/{package-A62qq8pE.mjs.map → package-vbK0Qycn.mjs.map} +1 -1
- package/dist/publish.d.mts +1 -0
- package/dist/publish.mjs +578 -0
- package/dist/publish.mjs.map +1 -0
- package/dist/{repository-files-CorshdqY.mjs → repository-files-CPfBA4mf.mjs} +7 -1
- package/dist/repository-files-CPfBA4mf.mjs.map +1 -0
- package/dist/runtime-Dc5gCUSF.mjs +29 -0
- package/dist/runtime-Dc5gCUSF.mjs.map +1 -0
- package/dist/workspace-settings.d.mts +1 -1
- package/dist/workspace-settings.mjs +6 -63
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +17 -7
- package/skills/msch-checks/SKILL.md +0 -5
- package/skills/publishing/SKILL.md +44 -0
- package/skills/repository-config/SKILL.md +8 -7
- package/src/app/vite.d.ts +4 -0
- package/dist/define-lint-preset-BYMl7wof.mjs.map +0 -1
- package/dist/repository-files-CorshdqY.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { B as stringsIn, E as hasVerifyTask, F as childrenOf$2, I as keyName, L as literalOf, N as workspaceConfigOf, P as KeySchema, R as nestedValues, S as RUN_TASKS, T as definesTask, _ as publishedProjects, a as publicEntriesOf, b as runTasksOf, c as readManifest, d as lockedPackages, f as deployEntries, i as EntryManifestJson, l as workspaceDependencies, m as patternOf$1, o as MANIFEST_FILE$
|
|
3
|
-
import { a as groupOf$2,
|
|
2
|
+
import { B as stringsIn, E as hasVerifyTask, F as childrenOf$2, I as keyName, L as literalOf, N as workspaceConfigOf, P as KeySchema, R as nestedValues, S as RUN_TASKS, T as definesTask, _ as publishedProjects, a as publicEntriesOf, b as runTasksOf, c as readManifest, d as lockedPackages, f as deployEntries, i as EntryManifestJson, l as workspaceDependencies, m as patternOf$1, o as MANIFEST_FILE$3, p as namedWorkspaces, r as publishedWorkspaces, s as dependencyEntries, u as lockedGraph, v as workspaceDirectories, w as VERIFY_TASK, y as workspaceManifest, z as propertyValue } from "./package-vbK0Qycn.mjs";
|
|
3
|
+
import { a as groupOf$2, n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-CPfBA4mf.mjs";
|
|
4
4
|
import { n as JAPANESE, t as COMMENT_DIRECTIVES } from "./comment-directives-5-f_qs1E.mjs";
|
|
5
|
-
import { $ as isPropertyAccessExpression, A as getLeadingCommentRanges, B as isEnumDeclaration, C as uniqueByReference, D as SignatureKind, E as InternalSymbolName, F as isBinaryExpression, G as isImportDeclaration, H as isFunctionDeclaration, I as isBlock, J as isModuleDeclaration, K as isInterfaceDeclaration, L as isCallExpression, M as getTextOfJSDocComment, N as isArrayLiteralExpression, O as SyntaxKind, P as isArrowFunction, Q as isParenthesizedExpression, R as isClassDeclaration, S as symbolAt, T as IndexKind, U as isFunctionExpression, V as isExportDeclaration, W as isIdentifier, X as isNumericLiteral, Y as isNewExpression, Z as isObjectLiteralExpression, _ as lineOf$3, a as problemAt$9, at as isSpreadElement, b as referencedSymbols, c as columnOf, ct as isTypeLiteralNode, d as descendantsOf, dt as isVariableDeclaration, et as isPropertyAssignment, f as importedModulesOf, ft as isVariableDeclarationList, g as isTypeDeclaration, h as isInsideAny, i as formatProblem, it as isSourceFile, j as getNameOfDeclaration, k as getJSDocTags, l as contains, lt as isTypeReferenceNode, m as isGenericDeclaration, n as ProblemList, nt as isSatisfiesExpression, o as sortProblems, ot as isStringLiteral, p as isExternalDeclaration, pt as isVariableStatement, q as isModuleBlock, rt as isSignatureDeclaration, s as childrenOf$3, st as isTypeAliasDeclaration, tt as isReturnStatement, u as declarationsOf, ut as isUnionTypeNode, v as packageOf$1, w as API, x as resolvedSymbol, y as propertyNamesOf, z as isElementAccessExpression } from "./cli-contract-
|
|
5
|
+
import { $ as isPropertyAccessExpression, A as getLeadingCommentRanges, B as isEnumDeclaration, C as uniqueByReference, D as SignatureKind, E as InternalSymbolName, F as isBinaryExpression, G as isImportDeclaration, H as isFunctionDeclaration, I as isBlock, J as isModuleDeclaration, K as isInterfaceDeclaration, L as isCallExpression, M as getTextOfJSDocComment, N as isArrayLiteralExpression, O as SyntaxKind, P as isArrowFunction, Q as isParenthesizedExpression, R as isClassDeclaration, S as symbolAt, T as IndexKind, U as isFunctionExpression, V as isExportDeclaration, W as isIdentifier, X as isNumericLiteral, Y as isNewExpression, Z as isObjectLiteralExpression, _ as lineOf$3, a as problemAt$9, at as isSpreadElement, b as referencedSymbols, c as columnOf, ct as isTypeLiteralNode, d as descendantsOf, dt as isVariableDeclaration, et as isPropertyAssignment, f as importedModulesOf, ft as isVariableDeclarationList, g as isTypeDeclaration, h as isInsideAny, i as formatProblem, it as isSourceFile, j as getNameOfDeclaration, k as getJSDocTags, l as contains, lt as isTypeReferenceNode, m as isGenericDeclaration, n as ProblemList, nt as isSatisfiesExpression, o as sortProblems, ot as isStringLiteral, p as isExternalDeclaration, pt as isVariableStatement, q as isModuleBlock, rt as isSignatureDeclaration, s as childrenOf$3, st as isTypeAliasDeclaration, tt as isReturnStatement, u as declarationsOf, ut as isUnionTypeNode, v as packageOf$1, w as API, x as resolvedSymbol, y as propertyNamesOf, z as isElementAccessExpression } from "./cli-contract-DdTV5DaG.mjs";
|
|
6
|
+
import { n as ProblemsFound, r as writeStdout, t as runCli } from "./runtime-Dc5gCUSF.mjs";
|
|
6
7
|
import { VpToolsError, runVpa } from "@r_masseater/vite-plus-adopt";
|
|
7
|
-
import { Array,
|
|
8
|
+
import { Array, Boolean as Boolean$1, Config, Effect, FileSystem, Function, HashMap, HashSet, Number as Number$1, Option, Order, Path, Predicate, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
8
9
|
import { updateWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-writer";
|
|
9
10
|
import { ChildProcess } from "effect/process";
|
|
10
11
|
import { parse, resolveConfigFromFile } from "vite-plus";
|
|
@@ -14,6 +15,8 @@ import treeSitter from "@vscode/tree-sitter-wasm";
|
|
|
14
15
|
import { Parser, isMap, isPair, isScalar, isSeq, parse as parse$2, parseDocument, visit } from "yaml";
|
|
15
16
|
import semver from "semver";
|
|
16
17
|
import { diagnosticDetail, lint, markdownPathspecs, y8Section } from "@r_masseater/y8";
|
|
18
|
+
import { lint as lint$1, wismPathspecs, wismSection } from "@r_masseater/wism";
|
|
19
|
+
import { fu4Section, lint as lint$2, workflowPathspecs } from "@r_masseater/fu4";
|
|
17
20
|
import path from "node:path";
|
|
18
21
|
import { isComment, isTag, isText } from "domhandler";
|
|
19
22
|
import { DomUtils, parseDocument as parseDocument$1 } from "htmlparser2";
|
|
@@ -21,9 +24,6 @@ import { DockerfileParser } from "dockerfile-ast";
|
|
|
21
24
|
import { parse as parse$3 } from "sql-parser-cst";
|
|
22
25
|
import { getStaticTOMLValue, parseTOML } from "toml-eslint-parser";
|
|
23
26
|
import { findSkillFiles } from "@tanstack/intent";
|
|
24
|
-
import { runMain } from "@effect/platform-node-shared/NodeRuntime";
|
|
25
|
-
import { FetchHttpClient } from "effect/http";
|
|
26
|
-
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
27
27
|
// src/features/check-overrides/model/override-findings.ts
|
|
28
28
|
const describeVersions = (versions) => Option.getOrElse(Option.liftPredicate(Array.join(versions, ","), (joined) => joined !== ""), () => "-");
|
|
29
29
|
const describeChanges = (report) => {
|
|
@@ -208,12 +208,12 @@ const RESOLUTION_FILES = [
|
|
|
208
208
|
];
|
|
209
209
|
const RESOLUTION_CONCURRENCY = 4;
|
|
210
210
|
const SUCCEEDED$1 = 0;
|
|
211
|
-
const taggedError$
|
|
212
|
-
var OverrideResolutionFailed = class extends taggedError$
|
|
211
|
+
const taggedError$6 = Schema.TaggedError;
|
|
212
|
+
var OverrideResolutionFailed = class extends taggedError$6()("OverrideResolutionFailed", {
|
|
213
213
|
override: Schema.String,
|
|
214
214
|
output: Schema.String
|
|
215
215
|
}) {};
|
|
216
|
-
const textOf
|
|
216
|
+
const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
217
217
|
const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override) {
|
|
218
218
|
const handle = yield* ChildProcess.make("vp", [
|
|
219
219
|
"install",
|
|
@@ -227,7 +227,7 @@ const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override
|
|
|
227
227
|
extendEnv: true,
|
|
228
228
|
stdin: "ignore"
|
|
229
229
|
});
|
|
230
|
-
const [output, status] = yield* Effect.all([textOf
|
|
230
|
+
const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
231
231
|
if (Number(status) !== SUCCEEDED$1) return yield* OverrideResolutionFailed.make({
|
|
232
232
|
override,
|
|
233
233
|
output
|
|
@@ -244,7 +244,7 @@ const auditIn = Effect.fn("auditIn")(function* auditIn(directory) {
|
|
|
244
244
|
extendEnv: true,
|
|
245
245
|
stdin: "ignore"
|
|
246
246
|
});
|
|
247
|
-
const [report] = yield* Effect.all([textOf
|
|
247
|
+
const [report] = yield* Effect.all([textOf(handle.stdout), handle.exitCode], { concurrency: "unbounded" });
|
|
248
248
|
return advisoriesIn(report);
|
|
249
249
|
}, Effect.scoped);
|
|
250
250
|
const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* trackedFiles(root) {
|
|
@@ -254,7 +254,7 @@ const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* tra
|
|
|
254
254
|
"--",
|
|
255
255
|
...RESOLUTION_FILES
|
|
256
256
|
], { cwd: root });
|
|
257
|
-
const listed = yield* textOf
|
|
257
|
+
const listed = yield* textOf(handle.stdout);
|
|
258
258
|
return pipe(String$1.split(listed, "\0"), Array.filter(String$1.isNonEmpty));
|
|
259
259
|
}, Effect.scoped);
|
|
260
260
|
const copyFiles = Effect.fn("copyFiles")(function* copyFiles(workspace, directory) {
|
|
@@ -330,13 +330,13 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
|
|
|
330
330
|
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;
|
|
331
331
|
const LOCKFILE$1 = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
|
|
332
332
|
const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
|
|
333
|
-
const READ_CONCURRENCY$
|
|
333
|
+
const READ_CONCURRENCY$28 = 64;
|
|
334
334
|
const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE$1.test(name);
|
|
335
335
|
const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
|
|
336
336
|
/** @internal */
|
|
337
337
|
const listedFiles = Effect.fn("listedFiles")(function* listedFiles(root) {
|
|
338
338
|
const files = yield* RepositoryFiles;
|
|
339
|
-
const names = yield* files.
|
|
339
|
+
const names = yield* files.ownedFiles(root);
|
|
340
340
|
return pipe(names, Array.map((name) => ({
|
|
341
341
|
name,
|
|
342
342
|
file: files.join(root, name)
|
|
@@ -353,18 +353,18 @@ const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
|
|
|
353
353
|
const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
|
|
354
354
|
onNone: () => [],
|
|
355
355
|
onSome: (source) => problemsIn(entry, source)
|
|
356
|
-
}))), { concurrency: READ_CONCURRENCY$
|
|
356
|
+
}))), { concurrency: READ_CONCURRENCY$28 });
|
|
357
357
|
return Array.flatten(found);
|
|
358
358
|
});
|
|
359
359
|
// src/features/check-overrides/model/git-subpath.ts
|
|
360
360
|
const DEPENDENCY_FILE = /(?:^|\/)(?:package\.json|pnpm-workspace\.ya?ml)$/u;
|
|
361
361
|
const GIT_SUBPATH = /(?<![^\s"':])[^\s"'#]+#(?:[^\s"'&]*&)*path:[^\s"']*/gu;
|
|
362
|
-
const RULE$
|
|
362
|
+
const RULE$45 = "git-subpath-dependency";
|
|
363
363
|
const WHOLE_MATCH$3 = 0;
|
|
364
364
|
const problemAt$8 = ({ file }, source) => (found) => ({
|
|
365
365
|
file,
|
|
366
366
|
...positionOf(source)(found.index ?? WHOLE_MATCH$3),
|
|
367
|
-
rule: RULE$
|
|
367
|
+
rule: RULE$45,
|
|
368
368
|
message: `Git subpath dependencies are banned. Publish the package to npm and depend on a released version instead of \`${String$1.trim(found[WHOLE_MATCH$3])}\`.`
|
|
369
369
|
});
|
|
370
370
|
const problemsIn$16 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(GIT_SUBPATH)(source)), Array.map(problemAt$8(entry, source)));
|
|
@@ -375,13 +375,13 @@ const checkGitSubpath = Effect.fn("checkGitSubpath")(function* checkGitSubpath(r
|
|
|
375
375
|
return yield* scanText(pipe(listed, Array.filter(isDependencyFile)), problemsIn$16);
|
|
376
376
|
});
|
|
377
377
|
// src/features/check-overrides/model/restricted-rules.ts
|
|
378
|
-
const RULE$
|
|
378
|
+
const RULE$44 = "unnamed-restriction";
|
|
379
379
|
const WHOLE_MATCH$2 = 0;
|
|
380
380
|
const UNNAMED = new RegExp(`(?:[\\w@-]+/)?no-restricted-(?:imports|properties)\\b`, "gu");
|
|
381
381
|
const problemsIn$15 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(UNNAMED)(source)), Array.map((found) => ({
|
|
382
382
|
file: entry.file,
|
|
383
383
|
...positionOf(source)(found.index ?? WHOLE_MATCH$2),
|
|
384
|
-
rule: RULE$
|
|
384
|
+
rule: RULE$44,
|
|
385
385
|
message: `${found[WHOLE_MATCH$2]} is not used in this repository, because its name does not say what an entry protects. Ban a package in dependencyRules.banned, and write any other restriction as a rule in msch-lint whose name states the intent.`
|
|
386
386
|
})));
|
|
387
387
|
/** @internal */
|
|
@@ -390,7 +390,7 @@ const checkRestrictedRules = Effect.fn("checkRestrictedRules")(function* checkRe
|
|
|
390
390
|
return yield* scanText(pipe(listed, Array.filter(isScannedText)), problemsIn$15);
|
|
391
391
|
});
|
|
392
392
|
// src/features/check-overrides/model/package-registry.ts
|
|
393
|
-
const RULE$
|
|
393
|
+
const RULE$43 = "package-registry";
|
|
394
394
|
const REGISTRY = "https://npm.flatt.tech/";
|
|
395
395
|
const TRAILING_SLASH = /\/$/u;
|
|
396
396
|
const WORKSPACE_FILE$4 = "pnpm-workspace.yaml";
|
|
@@ -407,7 +407,7 @@ const offsetIn = (found) => pipe(Option.fromNullishOr(found), Option.map(({ inde
|
|
|
407
407
|
const workspaceProblem = (file, source, registry) => ({
|
|
408
408
|
file,
|
|
409
409
|
...positionOf(source)(offsetIn(WORKSPACE_REGISTRY.exec(source))),
|
|
410
|
-
rule: RULE$
|
|
410
|
+
rule: RULE$43,
|
|
411
411
|
message: Option.match(registry, {
|
|
412
412
|
onNone: () => `${REASON} Set \`registry: ${REGISTRY}\` in ${WORKSPACE_FILE$4}.`,
|
|
413
413
|
onSome: (value) => `${REASON} \`registry\` is ${value}. Set it to ${REGISTRY}.`
|
|
@@ -416,7 +416,7 @@ const workspaceProblem = (file, source, registry) => ({
|
|
|
416
416
|
const npmrcProblems = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(NPMRC_REGISTRY)(source)), Array.filter((found) => !Option.exists(groupOf$2("value")(found), isGuarded)), Array.map((found) => ({
|
|
417
417
|
file: entry.file,
|
|
418
418
|
...positionOf(source)(found.index ?? START$15),
|
|
419
|
-
rule: RULE$
|
|
419
|
+
rule: RULE$43,
|
|
420
420
|
message: `${REASON} This .npmrc overrides it with \`${String$1.trim(found[START$15])}\`. Remove the line.`
|
|
421
421
|
})));
|
|
422
422
|
const checkWorkspace = Effect.fn("checkWorkspace")(function* checkWorkspace(root) {
|
|
@@ -436,36 +436,36 @@ const checkPackageRegistry = Effect.fn("checkPackageRegistry")(function* checkPa
|
|
|
436
436
|
return [...yield* checkWorkspace(root), ...overrides];
|
|
437
437
|
});
|
|
438
438
|
// src/features/check-placement/model/colocated-git-patterns.ts
|
|
439
|
-
const RULE$
|
|
439
|
+
const RULE$42 = "colocated-git-patterns";
|
|
440
440
|
const PATTERN_FILES = [":(glob)**/.gitignore", ":(glob)**/.gitattributes"];
|
|
441
441
|
const ROOT$2 = ".";
|
|
442
|
-
const SEPARATOR$
|
|
442
|
+
const SEPARATOR$21 = "/";
|
|
443
443
|
const NEGATION$1 = "!";
|
|
444
444
|
const COMMENT$1 = "#";
|
|
445
445
|
const ANY_DEPTH = "**";
|
|
446
|
-
const FLOATING_PREFIX = `${ANY_DEPTH}${SEPARATOR$
|
|
446
|
+
const FLOATING_PREFIX = `${ANY_DEPTH}${SEPARATOR$21}`;
|
|
447
447
|
const LEADING_SLASHES = /^\/+/u;
|
|
448
448
|
const TRAILING_SLASHES = /\/+$/u;
|
|
449
449
|
const SPACES = /\s+/u;
|
|
450
|
-
const FIRST$
|
|
451
|
-
const READ_CONCURRENCY$
|
|
452
|
-
const isInside = (directory) => (inner) => inner !== directory && (directory === ROOT$2 || String$1.startsWith(`${directory}${SEPARATOR$
|
|
450
|
+
const FIRST$22 = 1;
|
|
451
|
+
const READ_CONCURRENCY$27 = 16;
|
|
452
|
+
const isInside = (directory) => (inner) => inner !== directory && (directory === ROOT$2 || String$1.startsWith(`${directory}${SEPARATOR$21}`)(inner));
|
|
453
453
|
const withoutPrefix = (prefix, text) => {
|
|
454
454
|
if (String$1.startsWith(prefix)(text)) return String$1.slice(prefix.length)(text);
|
|
455
455
|
return text;
|
|
456
456
|
};
|
|
457
457
|
const isAnchored = (pattern) => {
|
|
458
458
|
const body = withoutPrefix(NEGATION$1, pattern);
|
|
459
|
-
return pipe(body, String$1.replace(TRAILING_SLASHES, ""), String$1.includes(SEPARATOR$
|
|
459
|
+
return pipe(body, String$1.replace(TRAILING_SLASHES, ""), String$1.includes(SEPARATOR$21));
|
|
460
460
|
};
|
|
461
|
-
const segmentsOf
|
|
461
|
+
const segmentsOf = ({ directory, pattern }) => {
|
|
462
462
|
const body = withoutPrefix(NEGATION$1, pattern);
|
|
463
463
|
const trimmed = pipe(body, String$1.replace(LEADING_SLASHES, ""), String$1.replace(TRAILING_SLASHES, ""));
|
|
464
|
-
const own = String$1.split(SEPARATOR$
|
|
464
|
+
const own = String$1.split(SEPARATOR$21)(trimmed);
|
|
465
465
|
if (directory === ROOT$2) return own;
|
|
466
|
-
return [...String$1.split(SEPARATOR$
|
|
466
|
+
return [...String$1.split(SEPARATOR$21)(directory), ...own];
|
|
467
467
|
};
|
|
468
|
-
const depthOf = (directory) => String$1.split(SEPARATOR$
|
|
468
|
+
const depthOf = (directory) => String$1.split(SEPARATOR$21)(directory).length;
|
|
469
469
|
const entryOf$1 = (file, kind, directory) => (line, index) => {
|
|
470
470
|
const [pattern, ...values] = pipe(String$1.trim(line), String$1.split(SPACES));
|
|
471
471
|
if (String$1.isEmpty(pattern) || String$1.startsWith(COMMENT$1)(pattern)) return Option.none();
|
|
@@ -473,7 +473,7 @@ const entryOf$1 = (file, kind, directory) => (line, index) => {
|
|
|
473
473
|
file,
|
|
474
474
|
kind,
|
|
475
475
|
directory,
|
|
476
|
-
line: index + FIRST$
|
|
476
|
+
line: index + FIRST$22,
|
|
477
477
|
pattern,
|
|
478
478
|
values: Array.join(values, " ")
|
|
479
479
|
});
|
|
@@ -488,12 +488,12 @@ const entriesIn$1 = Effect.fn("entriesIn")(function* entriesIn(root, file) {
|
|
|
488
488
|
const problemAt$7 = (entry, message) => ({
|
|
489
489
|
file: entry.file,
|
|
490
490
|
line: entry.line,
|
|
491
|
-
column: FIRST$
|
|
492
|
-
rule: RULE$
|
|
491
|
+
column: FIRST$22,
|
|
492
|
+
rule: RULE$42,
|
|
493
493
|
message
|
|
494
494
|
});
|
|
495
495
|
const misplacedMessage = (kind, workspaces) => {
|
|
496
|
-
if (workspaces.length === FIRST$
|
|
496
|
+
if (workspaces.length === FIRST$22) {
|
|
497
497
|
const workspace = Array.join(workspaces, "");
|
|
498
498
|
return `matches only paths inside the workspace ${workspace}. Move it to ${workspace}/${kind} and write it relative to that directory.`;
|
|
499
499
|
}
|
|
@@ -503,12 +503,12 @@ const matchedAtDepth = Effect.fn("matchedAtDepth")(function* matchedAtDepth(root
|
|
|
503
503
|
const files = yield* RepositoryFiles;
|
|
504
504
|
const leading = Array.take(segments, depth);
|
|
505
505
|
if (Array.contains(leading, ANY_DEPTH)) return [];
|
|
506
|
-
const manifests = yield* files.matchingFiles(root, [`:(glob)${Array.join(leading, SEPARATOR$
|
|
506
|
+
const manifests = yield* files.matchingFiles(root, [`:(glob)${Array.join(leading, SEPARATOR$21)}${SEPARATOR$21}${MANIFEST_FILE$3}`]);
|
|
507
507
|
return pipe(manifests, Array.map((manifest) => files.dirname(manifest)));
|
|
508
508
|
});
|
|
509
509
|
const deepestOf = (inner) => pipe(inner, Array.filter((workspace) => !pipe(inner, Array.some(isInside(workspace)))));
|
|
510
510
|
const matchedWorkspaces = Effect.fn("matchedWorkspaces")(function* matchedWorkspaces(root, workspaces, entry) {
|
|
511
|
-
const segments = segmentsOf
|
|
511
|
+
const segments = segmentsOf(entry);
|
|
512
512
|
const candidates = pipe(workspaces, Array.filter(isInside(entry.directory)), Array.filter((workspace) => depthOf(workspace) < segments.length));
|
|
513
513
|
const depths = pipe(candidates, Array.map(depthOf), Array.dedupe);
|
|
514
514
|
const matched = yield* Effect.forEach(depths, (depth) => matchedAtDepth(root, segments, depth), { concurrency: 1 });
|
|
@@ -524,12 +524,12 @@ const misplaced = Effect.fn("misplaced")(function* misplaced(root, workspaces, e
|
|
|
524
524
|
const isFloating = (pattern) => !String$1.startsWith(NEGATION$1)(pattern) && (!isAnchored(pattern) || String$1.startsWith(FLOATING_PREFIX)(pattern));
|
|
525
525
|
const ownLevelName = (pattern) => {
|
|
526
526
|
if (isFloating(pattern)) return Option.some(pattern);
|
|
527
|
-
const name = withoutPrefix(SEPARATOR$
|
|
527
|
+
const name = withoutPrefix(SEPARATOR$21, pattern);
|
|
528
528
|
return Option.liftPredicate(name, (own) => isFloating(own) && !isAnchored(own));
|
|
529
529
|
};
|
|
530
530
|
const sameName = (outer, name) => {
|
|
531
531
|
if (outer === name) return true;
|
|
532
|
-
return String$1.endsWith(SEPARATOR$
|
|
532
|
+
return String$1.endsWith(SEPARATOR$21)(name) && `${outer}${SEPARATOR$21}` === name;
|
|
533
533
|
};
|
|
534
534
|
const coveredBy = (entry, name) => (outer) => outer.kind === entry.kind && outer.values === entry.values && isFloating(outer.pattern) && isInside(outer.directory)(entry.directory) && sameName(outer.pattern, name);
|
|
535
535
|
const outerName = ({ directory, kind }) => {
|
|
@@ -543,22 +543,22 @@ const repeated = (entries) => (entry) => {
|
|
|
543
543
|
/** @internal */
|
|
544
544
|
const checkColocatedGitPatterns = Effect.fn("checkColocatedGitPatterns")(function* checkColocatedGitPatterns(root) {
|
|
545
545
|
const patternFiles = yield* (yield* RepositoryFiles).matchingFiles(root, PATTERN_FILES);
|
|
546
|
-
const read = yield* Effect.forEach(patternFiles, (file) => entriesIn$1(root, file), { concurrency: READ_CONCURRENCY$
|
|
546
|
+
const read = yield* Effect.forEach(patternFiles, (file) => entriesIn$1(root, file), { concurrency: READ_CONCURRENCY$27 });
|
|
547
547
|
const entries = Array.flatten(read);
|
|
548
548
|
const workspaces = yield* workspaceDirectories(root);
|
|
549
|
-
const misplacedFound = yield* Effect.forEach(entries, (entry) => misplaced(root, workspaces, entry), { concurrency: READ_CONCURRENCY$
|
|
549
|
+
const misplacedFound = yield* Effect.forEach(entries, (entry) => misplaced(root, workspaces, entry), { concurrency: READ_CONCURRENCY$27 });
|
|
550
550
|
const repeatedFound = pipe(entries, Array.map(repeated(entries)));
|
|
551
551
|
return Array.getSomes([...misplacedFound, ...repeatedFound]);
|
|
552
552
|
});
|
|
553
553
|
// src/features/check-placement/model/colocated-tests.ts
|
|
554
|
-
const RULE$
|
|
555
|
-
const FIRST$
|
|
556
|
-
const READ_CONCURRENCY$
|
|
554
|
+
const RULE$41 = "colocated-test";
|
|
555
|
+
const FIRST$21 = 1;
|
|
556
|
+
const READ_CONCURRENCY$26 = 64;
|
|
557
557
|
const ROOT_SUBPATH = ".";
|
|
558
558
|
const NAME_GROUP = "name";
|
|
559
559
|
const SPECIFIER_GROUP = "specifier";
|
|
560
|
-
const SCRIPT$
|
|
561
|
-
const TEST_FILE$
|
|
560
|
+
const SCRIPT$2 = /\.[cm]?[jt]sx?$/u;
|
|
561
|
+
const TEST_FILE$2 = /\.test\.[cm]?[jt]sx?$/u;
|
|
562
562
|
const MANIFEST_NAME = /package\.json$/u;
|
|
563
563
|
const SEPARATE_TEST_DIRECTORY = /(?:^|\/)(?:__tests__|__mocks__|tests?)\//u;
|
|
564
564
|
const SPEC_DIRECTORY = /(?:^|\/)specs?\//u;
|
|
@@ -575,15 +575,15 @@ const Manifest$4 = Schema.Struct({
|
|
|
575
575
|
});
|
|
576
576
|
const decodeManifest$7 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$4));
|
|
577
577
|
const byLength$2 = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
578
|
-
const problemFor$
|
|
578
|
+
const problemFor$7 = (test, message) => ({
|
|
579
579
|
file: test.file,
|
|
580
|
-
line: FIRST$
|
|
581
|
-
column: FIRST$
|
|
582
|
-
rule: RULE$
|
|
580
|
+
line: FIRST$21,
|
|
581
|
+
column: FIRST$21,
|
|
582
|
+
rule: RULE$41,
|
|
583
583
|
message: `${test.base} ${message}`
|
|
584
584
|
});
|
|
585
585
|
const groupsOf$1 = (source, pattern, group) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((match) => pipe(Option.fromUndefinedOr(match.groups), Option.flatMap((groups) => Option.fromUndefinedOr(groups[group])))), Array.getSomes);
|
|
586
|
-
const namesSibling = (source) => pipe([...groupsOf$1(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf$1(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE$
|
|
586
|
+
const namesSibling = (source) => pipe([...groupsOf$1(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf$1(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE$2.test(name)));
|
|
587
587
|
const ownerOf$4 = (packages, name) => {
|
|
588
588
|
const owners = pipe(packages, Array.filter((directory) => String$1.startsWith(directory)(name)));
|
|
589
589
|
return Array.last(Array.sort(owners, byLength$2));
|
|
@@ -597,7 +597,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
|
|
|
597
597
|
const files = yield* RepositoryFiles;
|
|
598
598
|
const owner = ownerOf$4(context.packages, test.name);
|
|
599
599
|
if (Option.isNone(owner)) return [];
|
|
600
|
-
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE$
|
|
600
|
+
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE$3));
|
|
601
601
|
const join = (target) => files.join(context.root, owner.value, target);
|
|
602
602
|
return pipe(text, Option.flatMap(decodeManifest$7), Option.map(specifiersBeside({
|
|
603
603
|
join,
|
|
@@ -619,10 +619,10 @@ const refersIn = Effect.fn("refersIn")(function* refersIn(context, test) {
|
|
|
619
619
|
});
|
|
620
620
|
const inSeparateTestDirectory = (name) => SEPARATE_TEST_DIRECTORY.test(name) || SPEC_DIRECTORY.test(name) && SPEC_FILE.test(name);
|
|
621
621
|
const problemIn$6 = Effect.fn("problemIn")(function* problemIn(context, test) {
|
|
622
|
-
if (inSeparateTestDirectory(test.name)) return Option.some(problemFor$
|
|
623
|
-
if (!TEST_FILE$
|
|
622
|
+
if (inSeparateTestDirectory(test.name)) return Option.some(problemFor$7(test, DIRECTORY_MESSAGE));
|
|
623
|
+
if (!TEST_FILE$2.test(test.name)) return Option.none();
|
|
624
624
|
if (yield* refersIn(context, test)) return Option.none();
|
|
625
|
-
return Option.some(problemFor$
|
|
625
|
+
return Option.some(problemFor$7(test, SIBLING_MESSAGE));
|
|
626
626
|
});
|
|
627
627
|
/** @internal */
|
|
628
628
|
const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColocatedTests(root) {
|
|
@@ -631,9 +631,9 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
631
631
|
const names = pipe(listed, Array.filter(String$1.isNonEmpty));
|
|
632
632
|
const context = {
|
|
633
633
|
root,
|
|
634
|
-
packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE$
|
|
634
|
+
packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE$3), Array.map(String$1.replace(MANIFEST_NAME, "")))
|
|
635
635
|
};
|
|
636
|
-
const tests = pipe(names, Array.filter((name) => SCRIPT$
|
|
636
|
+
const tests = pipe(names, Array.filter((name) => SCRIPT$2.test(name)), Array.map((name) => {
|
|
637
637
|
const file = files.join(root, name);
|
|
638
638
|
return {
|
|
639
639
|
name,
|
|
@@ -642,12 +642,12 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
642
642
|
directory: files.dirname(file)
|
|
643
643
|
};
|
|
644
644
|
}));
|
|
645
|
-
const found = yield* Effect.forEach(tests, (test) => problemIn$6(context, test), { concurrency: READ_CONCURRENCY$
|
|
645
|
+
const found = yield* Effect.forEach(tests, (test) => problemIn$6(context, test), { concurrency: READ_CONCURRENCY$26 });
|
|
646
646
|
return Array.getSomes(found);
|
|
647
647
|
});
|
|
648
648
|
// src/shared/lib/agent-docs.ts
|
|
649
649
|
const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
|
|
650
|
-
const READ_CONCURRENCY$
|
|
650
|
+
const READ_CONCURRENCY$25 = 16;
|
|
651
651
|
const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblems(root, problemIn) {
|
|
652
652
|
const files = yield* RepositoryFiles;
|
|
653
653
|
const listed = yield* files.listedFiles(root);
|
|
@@ -656,32 +656,60 @@ const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblem
|
|
|
656
656
|
const file = files.join(root, name);
|
|
657
657
|
const problemOf = Option.flatMap(problemIn(file));
|
|
658
658
|
return files.readFile(file).pipe(Effect.map(problemOf));
|
|
659
|
-
}, { concurrency: READ_CONCURRENCY$
|
|
659
|
+
}, { concurrency: READ_CONCURRENCY$25 });
|
|
660
660
|
return Array.getSomes(found);
|
|
661
661
|
});
|
|
662
662
|
// src/features/check-placement/model/agent-docs-length.ts
|
|
663
663
|
const RECOMMENDED_LINES = 200;
|
|
664
|
-
const FIRST$
|
|
665
|
-
const RULE$
|
|
664
|
+
const FIRST$20 = 1;
|
|
665
|
+
const RULE$40 = "agent-docs-length";
|
|
666
666
|
const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
|
|
667
|
-
const problemFor$
|
|
667
|
+
const problemFor$6 = (file) => (lines) => {
|
|
668
668
|
if (lines <= RECOMMENDED_LINES) return Option.none();
|
|
669
669
|
return Option.some({
|
|
670
670
|
file,
|
|
671
671
|
line: 201,
|
|
672
|
-
column: FIRST$
|
|
673
|
-
rule: RULE$
|
|
672
|
+
column: FIRST$20,
|
|
673
|
+
rule: RULE$40,
|
|
674
674
|
message: `has ${String(lines)} lines. Claude Code recommends under ${String(RECOMMENDED_LINES)} lines per file: longer files cost context and are followed less reliably. Cut what the code already tells, and move rules shared across repositories into skills.`
|
|
675
675
|
});
|
|
676
676
|
};
|
|
677
677
|
/** @internal */
|
|
678
|
-
const checkAgentDocsLength = (root) => agentDocProblems(root, (file) => (source) => problemFor$
|
|
678
|
+
const checkAgentDocsLength = (root) => agentDocProblems(root, (file) => (source) => problemFor$6(file)(lineCount(source)));
|
|
679
|
+
// src/features/check-placement/model/claude-link.ts
|
|
680
|
+
const RULE$39 = "claude-md-link";
|
|
681
|
+
const CLAUDE = "CLAUDE.md";
|
|
682
|
+
const AGENTS = "AGENTS.md";
|
|
683
|
+
const FIRST$19 = 1;
|
|
684
|
+
const READ_CONCURRENCY$24 = 16;
|
|
685
|
+
const MESSAGE$14 = "CLAUDE.md must be a symbolic link to AGENTS.md";
|
|
686
|
+
/** @internal */
|
|
687
|
+
const checkClaudeLinks = Effect.fn("checkClaudeLinks")(function* checkClaudeLinks(root) {
|
|
688
|
+
const files = yield* RepositoryFiles;
|
|
689
|
+
const [listed, links] = yield* Effect.all([files.listedFiles(root), files.linkedFiles(root)], { concurrency: "unbounded" });
|
|
690
|
+
const problemOf = Effect.fn("problemOf")(function* problemOf(name) {
|
|
691
|
+
const file = files.join(root, name);
|
|
692
|
+
const target = yield* files.readLink(file);
|
|
693
|
+
const isLink = pipe(links, Array.contains(name));
|
|
694
|
+
const pointsElsewhere = pipe(target, Option.exists((value) => value !== AGENTS));
|
|
695
|
+
return pipe(Option.liftPredicate(file, () => !isLink || pointsElsewhere), Option.map((path) => ({
|
|
696
|
+
file: path,
|
|
697
|
+
line: FIRST$19,
|
|
698
|
+
column: FIRST$19,
|
|
699
|
+
rule: RULE$39,
|
|
700
|
+
message: MESSAGE$14
|
|
701
|
+
})));
|
|
702
|
+
});
|
|
703
|
+
const claude = pipe(listed, Array.filter((name) => files.basename(name) === CLAUDE));
|
|
704
|
+
const found = yield* Effect.forEach(claude, problemOf, { concurrency: READ_CONCURRENCY$24 });
|
|
705
|
+
return Array.getSomes(found);
|
|
706
|
+
});
|
|
679
707
|
// src/features/check-placement/model/dangling-links.ts
|
|
680
|
-
const RULE$
|
|
681
|
-
const SEPARATOR$
|
|
682
|
-
const FIRST$
|
|
708
|
+
const RULE$38 = "dangling-link";
|
|
709
|
+
const SEPARATOR$20 = "/";
|
|
710
|
+
const FIRST$18 = 1;
|
|
683
711
|
const READ_CONCURRENCY$23 = 16;
|
|
684
|
-
const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$
|
|
712
|
+
const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$20}`)(name);
|
|
685
713
|
/** @internal */
|
|
686
714
|
const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDanglingLinks(root) {
|
|
687
715
|
const files = yield* RepositoryFiles;
|
|
@@ -691,9 +719,9 @@ const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDangli
|
|
|
691
719
|
const link = yield* files.readLink(file);
|
|
692
720
|
return pipe(link, Option.map((target) => files.relative(root, files.resolve(files.dirname(file), target))), Option.filter((target) => !pipe(listed, Array.some(holds(target)))), Option.map((target) => ({
|
|
693
721
|
file,
|
|
694
|
-
line: FIRST$
|
|
695
|
-
column: FIRST$
|
|
696
|
-
rule: RULE$
|
|
722
|
+
line: FIRST$18,
|
|
723
|
+
column: FIRST$18,
|
|
724
|
+
rule: RULE$38,
|
|
697
725
|
message: `is a link to ${target}, where no file is tracked. A fresh checkout gets a link to nothing, and GitHub Actions fails to load the repository's actions. Track a file there, such as .gitkeep, or delete the link.`
|
|
698
726
|
})));
|
|
699
727
|
});
|
|
@@ -701,36 +729,36 @@ const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDangli
|
|
|
701
729
|
return Array.getSomes(found);
|
|
702
730
|
});
|
|
703
731
|
// src/features/check-placement/model/nested-docs.ts
|
|
704
|
-
const RULE$
|
|
732
|
+
const RULE$37 = "nested-docs";
|
|
705
733
|
const CONFIG_FILE$6 = "vite.config.ts";
|
|
706
|
-
const SEPARATOR$
|
|
707
|
-
const FIRST$
|
|
734
|
+
const SEPARATOR$19 = "/";
|
|
735
|
+
const FIRST$17 = 1;
|
|
708
736
|
const READ_CONCURRENCY$22 = 64;
|
|
709
737
|
const AGENT_DOCS$1 = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
710
738
|
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
711
739
|
const README = /^README(?:\.[^/]+)?$/iu;
|
|
712
740
|
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
713
|
-
const taggedError$
|
|
714
|
-
var RootConfigUnreadable = class extends taggedError$
|
|
715
|
-
const isNested = (name) => String$1.includes(SEPARATOR$
|
|
716
|
-
const problemFor$
|
|
741
|
+
const taggedError$5 = Schema.TaggedError;
|
|
742
|
+
var RootConfigUnreadable = class extends taggedError$5()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
743
|
+
const isNested = (name) => String$1.includes(SEPARATOR$19)(name);
|
|
744
|
+
const problemFor$5 = (file, message) => ({
|
|
717
745
|
file,
|
|
718
|
-
line: FIRST$
|
|
719
|
-
column: FIRST$
|
|
720
|
-
rule: RULE$
|
|
746
|
+
line: FIRST$17,
|
|
747
|
+
column: FIRST$17,
|
|
748
|
+
rule: RULE$37,
|
|
721
749
|
message
|
|
722
750
|
});
|
|
723
751
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
724
752
|
const WORKSPACE_AGENT_DOCS_MESSAGE = "belongs only at the repository root or as AGENTS.md directly in a workspace, the directory that holds its package.json. Move what agents need there and delete this file.";
|
|
725
753
|
const README_MESSAGE = "is allowed below the root only in a workspace, the directory that holds its package.json. Move it into the workspace it describes.";
|
|
726
754
|
const agentDocProblem = ({ file, base, directory }, allowed) => {
|
|
727
|
-
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$
|
|
755
|
+
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$5(file, `${base} ${AGENT_DOCS_MESSAGE}`));
|
|
728
756
|
if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
729
|
-
return Option.some(problemFor$
|
|
757
|
+
return Option.some(problemFor$5(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
|
|
730
758
|
};
|
|
731
759
|
const readmeProblem = ({ file, base, directory }, allowed) => {
|
|
732
760
|
if (!README.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
733
|
-
return Option.some(problemFor$
|
|
761
|
+
return Option.some(problemFor$5(file, `${base} ${README_MESSAGE}`));
|
|
734
762
|
};
|
|
735
763
|
const problemIn$5 = Effect.fn("problemIn")(function* problemIn(root, allowed, name) {
|
|
736
764
|
const files = yield* RepositoryFiles;
|
|
@@ -756,7 +784,7 @@ const allowsWorkspaceAgentDocs = Effect.fn("allowsWorkspaceAgentDocs")(function*
|
|
|
756
784
|
/** @internal */
|
|
757
785
|
const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(root) {
|
|
758
786
|
const files = yield* RepositoryFiles;
|
|
759
|
-
const names = yield* files.
|
|
787
|
+
const names = yield* files.ownedFiles(root);
|
|
760
788
|
const nested = pipe(names, Array.filter(isNested));
|
|
761
789
|
const workspaceAgentDocs = yield* allowsWorkspaceAgentDocs(root);
|
|
762
790
|
const directories = yield* workspaceDirectories(root);
|
|
@@ -768,22 +796,31 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
|
|
|
768
796
|
return Array.getSomes(found);
|
|
769
797
|
});
|
|
770
798
|
// src/features/check-placement/model/published-readme.ts
|
|
771
|
-
const RULE$
|
|
799
|
+
const RULE$36 = "published-readme";
|
|
772
800
|
const README_FILE = "README.md";
|
|
773
801
|
const READ_CONCURRENCY$21 = 16;
|
|
774
|
-
const MESSAGE$
|
|
802
|
+
const MESSAGE$13 = "contains Japanese. This package is published to npm, so write its README in English.";
|
|
803
|
+
const MISSING_MESSAGE = "is missing. This package is published to npm, so give it an English README.md.";
|
|
804
|
+
const FILE_START$2 = 1;
|
|
775
805
|
const problemIn$4 = Effect.fn("problemIn")(function* problemIn(root, { directory }) {
|
|
776
806
|
const files = yield* RepositoryFiles;
|
|
777
807
|
const file = files.join(root, directory, README_FILE);
|
|
778
808
|
const text = yield* files.readFile(file);
|
|
809
|
+
if (Option.isNone(text)) return Option.some({
|
|
810
|
+
file,
|
|
811
|
+
line: FILE_START$2,
|
|
812
|
+
column: FILE_START$2,
|
|
813
|
+
rule: RULE$36,
|
|
814
|
+
message: MISSING_MESSAGE
|
|
815
|
+
});
|
|
779
816
|
return pipe(text, Option.flatMap((source) => pipe(Option.fromNullishOr(JAPANESE.exec(source)), Option.map((found) => {
|
|
780
817
|
const { line, column } = positionOf(source)(found.index);
|
|
781
818
|
return {
|
|
782
819
|
file,
|
|
783
820
|
line,
|
|
784
821
|
column,
|
|
785
|
-
rule: RULE$
|
|
786
|
-
message: MESSAGE$
|
|
822
|
+
rule: RULE$36,
|
|
823
|
+
message: MESSAGE$13
|
|
787
824
|
};
|
|
788
825
|
}))));
|
|
789
826
|
});
|
|
@@ -793,24 +830,53 @@ const checkPublishedReadme = Effect.fn("checkPublishedReadme")(function* checkPu
|
|
|
793
830
|
const found = yield* Effect.forEach(projects, (project) => problemIn$4(root, project), { concurrency: READ_CONCURRENCY$21 });
|
|
794
831
|
return Array.getSomes(found);
|
|
795
832
|
});
|
|
833
|
+
// src/features/check-placement/model/published-tests.ts
|
|
834
|
+
const RULE$35 = "published-tests";
|
|
835
|
+
const MANIFEST_FILE$2 = "package.json";
|
|
836
|
+
const FILE_START$1 = 1;
|
|
837
|
+
const TEST_FILE$1 = /\.test\.[cm]?[jt]sx?$/u;
|
|
838
|
+
const MESSAGE$12 = "belongs to a package published to npm that has no tests. Write tests for what the package offers before publishing it.";
|
|
839
|
+
const testedIn = (listed) => (prefix) => pipe(listed, Array.some((file) => String$1.startsWith(prefix)(file) && TEST_FILE$1.test(file)));
|
|
840
|
+
const problemFor$4 = Effect.fn("problemFor")(function* problemFor(root, listed, { directory }) {
|
|
841
|
+
const files = yield* RepositoryFiles;
|
|
842
|
+
const absolute = files.join(root, directory);
|
|
843
|
+
const prefix = `${absolute}/`;
|
|
844
|
+
if (testedIn(listed)(prefix)) return Option.none();
|
|
845
|
+
return Option.some({
|
|
846
|
+
file: files.join(absolute, MANIFEST_FILE$2),
|
|
847
|
+
line: FILE_START$1,
|
|
848
|
+
column: FILE_START$1,
|
|
849
|
+
rule: RULE$35,
|
|
850
|
+
message: MESSAGE$12
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
/** @internal */
|
|
854
|
+
const checkPublishedTests = Effect.fn("checkPublishedTests")(function* checkPublishedTests(root) {
|
|
855
|
+
const files = yield* RepositoryFiles;
|
|
856
|
+
const projects = yield* publishedProjects(root);
|
|
857
|
+
const listed = yield* files.listedFiles(root);
|
|
858
|
+
const absolute = pipe(listed, Array.map((file) => files.join(root, file)));
|
|
859
|
+
const found = yield* Effect.forEach(projects, (project) => problemFor$4(root, absolute, project), { concurrency: 1 });
|
|
860
|
+
return Array.getSomes(found);
|
|
861
|
+
});
|
|
796
862
|
// src/features/check-placement/model/root-docs.ts
|
|
797
863
|
const RULE$34 = "root-docs";
|
|
798
|
-
const SEPARATOR$
|
|
799
|
-
const FIRST$
|
|
864
|
+
const SEPARATOR$18 = "/";
|
|
865
|
+
const FIRST$16 = 1;
|
|
800
866
|
const MARKDOWN$1 = /\.(?:md|mdx|markdown)$/iu;
|
|
801
867
|
const ALLOWED = /^(?:README(?:\.[^/]+)?|AGENTS|CLAUDE|ARCHITECTURE|DESIGN|CHANGELOG|LICENSE|NOTICE)\.(?:md|mdx|markdown)$/iu;
|
|
802
|
-
const MESSAGE$
|
|
803
|
-
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$
|
|
868
|
+
const MESSAGE$11 = "is a hand-written document outside the places documents belong. Hand-written text goes only in the root README.md, AGENTS.md, CLAUDE.md, ARCHITECTURE.md and DESIGN.md, and under docs/. Move what is still true and not already told by the code into one of them, and delete this file.";
|
|
869
|
+
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$18)(name) && MARKDOWN$1.test(name) && !ALLOWED.test(name);
|
|
804
870
|
/** @internal */
|
|
805
871
|
const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
|
|
806
872
|
const files = yield* RepositoryFiles;
|
|
807
873
|
const names = yield* files.listedFiles(root);
|
|
808
874
|
return pipe(names, Array.filter(isStrayRootDoc), Array.map((name) => ({
|
|
809
875
|
file: files.join(root, name),
|
|
810
|
-
line: FIRST$
|
|
811
|
-
column: FIRST$
|
|
876
|
+
line: FIRST$16,
|
|
877
|
+
column: FIRST$16,
|
|
812
878
|
rule: RULE$34,
|
|
813
|
-
message: `${name} ${MESSAGE$
|
|
879
|
+
message: `${name} ${MESSAGE$11}`
|
|
814
880
|
})));
|
|
815
881
|
});
|
|
816
882
|
// src/features/check-placement/model/root-readme.ts
|
|
@@ -821,7 +887,7 @@ const START$14 = 0;
|
|
|
821
887
|
const CHECK_POLICY = "@r_masseater/msch";
|
|
822
888
|
const MARKETPLACE = ".claude-plugin/marketplace.json";
|
|
823
889
|
const RELATIVE$1 = /^\.\//u;
|
|
824
|
-
const SEPARATOR$
|
|
890
|
+
const SEPARATOR$17 = "/";
|
|
825
891
|
const MarketplacePlugin = Schema.Struct({
|
|
826
892
|
name: Schema.optional(Schema.String),
|
|
827
893
|
source: Schema.Unknown
|
|
@@ -833,7 +899,7 @@ const NO_PLUGINS = {
|
|
|
833
899
|
};
|
|
834
900
|
const isCheckPolicy = ({ packageName }) => Option.contains(packageName, CHECK_POLICY);
|
|
835
901
|
const messageFor = (directory) => `names the workspace ${directory}. The root README, AGENTS.md and CLAUDE.md describe the repository as a whole. Write what belongs to the workspace in ${directory}/README.md, or for agents in ${directory}/AGENTS.md.`;
|
|
836
|
-
const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$
|
|
902
|
+
const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$17)(directory), Array.last, Option.getOrElse(() => directory));
|
|
837
903
|
const pluginsOf = (plugins) => {
|
|
838
904
|
const directories = pipe(plugins, Array.map(({ source }) => source), Array.filter(Predicate.isString), Array.map(String$1.replace(RELATIVE$1, "")));
|
|
839
905
|
const segments = pipe(directories, Array.map(lastSegment));
|
|
@@ -890,11 +956,13 @@ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(r
|
|
|
890
956
|
const checkDocPlacement = Effect.fn("checkDocPlacement")(function* checkDocPlacement(root) {
|
|
891
957
|
const found = yield* Effect.all([
|
|
892
958
|
checkNestedDocs(root),
|
|
959
|
+
checkClaudeLinks(root),
|
|
893
960
|
checkRootReadme(root),
|
|
894
961
|
checkRootDocs(root),
|
|
895
962
|
checkAgentDocsLength(root),
|
|
896
963
|
checkDanglingLinks(root),
|
|
897
|
-
checkPublishedReadme(root)
|
|
964
|
+
checkPublishedReadme(root),
|
|
965
|
+
checkPublishedTests(root)
|
|
898
966
|
], { concurrency: "unbounded" });
|
|
899
967
|
return Array.flatten(found);
|
|
900
968
|
});
|
|
@@ -958,24 +1026,24 @@ const checkDocsMirror = Effect.fn("checkDocsMirror")(function* checkDocsMirror(r
|
|
|
958
1026
|
// src/features/check-placement/model/ignored-sources.ts
|
|
959
1027
|
const RULE$31 = "ignored-sources";
|
|
960
1028
|
const SOURCES = [":(glob)**/src/**", ":(exclude,glob)**/node_modules/**"];
|
|
961
|
-
const FIRST$
|
|
962
|
-
const MESSAGE$
|
|
1029
|
+
const FIRST$15 = 1;
|
|
1030
|
+
const MESSAGE$10 = "is under src/ but .gitignore ignores it, so verify passes here while the file never reaches the commit. Narrow the pattern in .gitignore.";
|
|
963
1031
|
/** @internal */
|
|
964
1032
|
const checkIgnoredSources = Effect.fn("checkIgnoredSources")(function* checkIgnoredSources(root) {
|
|
965
1033
|
const files = yield* RepositoryFiles;
|
|
966
1034
|
const ignored = yield* files.ignoredFiles(root, SOURCES);
|
|
967
1035
|
return pipe(ignored, Array.map((file) => ({
|
|
968
1036
|
file: files.join(root, file),
|
|
969
|
-
line: FIRST$
|
|
970
|
-
column: FIRST$
|
|
1037
|
+
line: FIRST$15,
|
|
1038
|
+
column: FIRST$15,
|
|
971
1039
|
rule: RULE$31,
|
|
972
|
-
message: MESSAGE$
|
|
1040
|
+
message: MESSAGE$10
|
|
973
1041
|
})));
|
|
974
1042
|
});
|
|
975
1043
|
// src/features/check-placement/model/member-sources.ts
|
|
976
1044
|
const ROOT_WORKSPACE$1 = ".";
|
|
977
|
-
const FIRST$
|
|
978
|
-
const SEPARATOR$
|
|
1045
|
+
const FIRST$14 = 1;
|
|
1046
|
+
const SEPARATOR$16 = "/";
|
|
979
1047
|
const EXCLUDED$4 = [
|
|
980
1048
|
":(exclude,attr:linguist-vendored)",
|
|
981
1049
|
":(exclude,attr:linguist-generated)",
|
|
@@ -995,48 +1063,24 @@ const memberSources = Effect.fn("memberSources")(function* memberSources(root) {
|
|
|
995
1063
|
const byLength$1 = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
996
1064
|
const fileProblem$1 = ({ file, rule, message }) => ({
|
|
997
1065
|
file,
|
|
998
|
-
line: FIRST$
|
|
999
|
-
column: FIRST$
|
|
1066
|
+
line: FIRST$14,
|
|
1067
|
+
column: FIRST$14,
|
|
1000
1068
|
rule,
|
|
1001
1069
|
message
|
|
1002
1070
|
});
|
|
1003
|
-
const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$
|
|
1071
|
+
const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$16}`)(name)), (owners) => Array.last(Array.sort(owners, byLength$1)), Option.map((workspace) => ({
|
|
1004
1072
|
workspace,
|
|
1005
1073
|
inner: String$1.slice(workspace.length + 1)(name)
|
|
1006
1074
|
})));
|
|
1007
|
-
// src/features/check-placement/model/
|
|
1008
|
-
const LAYERED_RULE$1 = "layered-source";
|
|
1075
|
+
// src/features/check-placement/model/public-entries.ts
|
|
1009
1076
|
const ENTRY_RULE$3 = "public-entry";
|
|
1010
|
-
const SOURCE_DIRECTORY$1 = "src";
|
|
1011
|
-
const SEPARATOR$16 = "/";
|
|
1012
|
-
const LOOSE_DEPTH = 2;
|
|
1013
|
-
const LAYERS$1 = [
|
|
1014
|
-
"app",
|
|
1015
|
-
"pages",
|
|
1016
|
-
"widgets",
|
|
1017
|
-
"features",
|
|
1018
|
-
"entities",
|
|
1019
|
-
"shared"
|
|
1020
|
-
];
|
|
1021
|
-
const SCRIPT$2 = /\.[cm]?[jt]sx?$/u;
|
|
1022
|
-
const ROOT_ALLOWED = /^(?:[^/]+\.config\.[cm]?[jt]s|alchemy\.[^/]+\.ts|[^/]+\.d\.[cm]?ts|bin\/.+)$/u;
|
|
1023
1077
|
const PUBLIC_ENTRY = /^(?:bin\/[^/]+|src\/(?:app\/[^/]+|(?:pages|widgets|features|entities)\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/(?:ui|lib)\/.+))$/u;
|
|
1024
|
-
const OUTSIDE_MESSAGE$1 = "sits outside src/. Put every module of a workspace under src/ in an FSD layer; only bin/, *.config.ts, alchemy.*.ts and *.d.ts may stay at the workspace root.";
|
|
1025
|
-
const LOOSE_MESSAGE = "sits directly in src/. Put it in a layer: app/ for entry points and wiring, features/<verb>-<object>/ for one operation, entities/<noun>/ for a shared domain object, or shared/<segment>/ for code without domain rules.";
|
|
1026
|
-
const LAYER_MESSAGE$1 = `is not an FSD layer. src/ holds only ${Array.join(LAYERS$1, ", ")}.`;
|
|
1027
1078
|
const ENTRY_MESSAGE$2 = "is a package entry that points inside a slice. Point exports and bin at bin/<name>.ts, src/app/<entry>.ts or a slice's index.ts.";
|
|
1028
1079
|
const decodeEntryManifest = Schema.decodeUnknownOption(EntryManifestJson);
|
|
1029
|
-
const layerProblemOf = (owned) => {
|
|
1030
|
-
const parts = String$1.split(owned.inner, SEPARATOR$16);
|
|
1031
|
-
const [top, layer] = parts;
|
|
1032
|
-
if (top !== SOURCE_DIRECTORY$1) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$16}${owned.inner}`, OUTSIDE_MESSAGE$1], () => !ROOT_ALLOWED.test(owned.inner));
|
|
1033
|
-
if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$16}${owned.inner}`, LOOSE_MESSAGE]);
|
|
1034
|
-
return Option.liftPredicate([`${owned.workspace}${SEPARATOR$16}${SOURCE_DIRECTORY$1}${SEPARATOR$16}${layer}`, LAYER_MESSAGE$1], () => !pipe(LAYERS$1, Array.contains(layer ?? "")));
|
|
1035
|
-
};
|
|
1036
1080
|
const entryProblems$2 = Effect.fn("entryProblems")(function* entryProblems(root, workspace) {
|
|
1037
1081
|
const files = yield* RepositoryFiles;
|
|
1038
1082
|
const directory = files.join(root, workspace);
|
|
1039
|
-
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$
|
|
1083
|
+
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$3));
|
|
1040
1084
|
const join = (target) => files.join(directory, target);
|
|
1041
1085
|
return pipe(text, Option.flatMap(decodeEntryManifest), Option.map((manifest) => publicEntriesOf({
|
|
1042
1086
|
manifest,
|
|
@@ -1049,20 +1093,14 @@ const entryProblems$2 = Effect.fn("entryProblems")(function* entryProblems(root,
|
|
|
1049
1093
|
})));
|
|
1050
1094
|
});
|
|
1051
1095
|
/** @internal */
|
|
1052
|
-
const
|
|
1053
|
-
const
|
|
1054
|
-
const { workspaces, listed } = yield* memberSources(root);
|
|
1055
|
-
const layered = pipe(listed, Array.filter((name) => SCRIPT$2.test(name)), Array.map(ownerOf$2(workspaces)), Array.getSomes, Array.map(layerProblemOf), Array.getSomes, Array.dedupeWith(([left], [right]) => left === right), Array.map(([file, message]) => fileProblem$1({
|
|
1056
|
-
file: files.join(root, file),
|
|
1057
|
-
rule: LAYERED_RULE$1,
|
|
1058
|
-
message
|
|
1059
|
-
})));
|
|
1096
|
+
const checkPublicEntries = Effect.fn("checkPublicEntries")(function* checkPublicEntries(root) {
|
|
1097
|
+
const workspaces = yield* memberWorkspaces(root);
|
|
1060
1098
|
const entries = yield* Effect.forEach(workspaces, (workspace) => entryProblems$2(root, workspace), { concurrency: 1 });
|
|
1061
|
-
return
|
|
1099
|
+
return Array.flatten(entries);
|
|
1062
1100
|
});
|
|
1063
1101
|
// src/shared/lib/tree-sitter.ts
|
|
1064
|
-
const taggedError$
|
|
1065
|
-
var GrammarUnreadable = class extends taggedError$
|
|
1102
|
+
const taggedError$4 = Schema.TaggedError;
|
|
1103
|
+
var GrammarUnreadable = class extends taggedError$4()("GrammarUnreadable", {
|
|
1066
1104
|
grammar: Schema.String,
|
|
1067
1105
|
message: Schema.String
|
|
1068
1106
|
}) {};
|
|
@@ -1118,7 +1156,6 @@ const MODULE_INDEX = "mod";
|
|
|
1118
1156
|
const CRATE_ROOTS = ["src/lib.rs", "src/main.rs"];
|
|
1119
1157
|
const OUTSIDE_ALLOWED = /^(?:build\.rs|benches\/.+)$/u;
|
|
1120
1158
|
const SEPARATE_TEST = /^tests\/.+$/u;
|
|
1121
|
-
const SHARED_SLICES = ["app", "shared"];
|
|
1122
1159
|
const SLICED_LAYERS = [
|
|
1123
1160
|
"pages",
|
|
1124
1161
|
"widgets",
|
|
@@ -1129,11 +1166,6 @@ const SLICED_LAYERS = [
|
|
|
1129
1166
|
const LAYER_DEPTH = 1;
|
|
1130
1167
|
const SOURCE_PREFIX$1 = `src/`;
|
|
1131
1168
|
const ROOT_CRATE = "";
|
|
1132
|
-
const NO_RANK = -1;
|
|
1133
|
-
const LAYER_INDEX = 0;
|
|
1134
|
-
const SLICE_INDEX = 1;
|
|
1135
|
-
const upwardMessage = (target, source) => `uses the ${target} layer from the ${source} layer. A layer may only use the layers below it (${Array.join(LAYERS, ", ")}).`;
|
|
1136
|
-
const crossMessage = (layer, target, source) => `uses the ${layer} slice ${target} from the slice ${source}. Slices of one layer must not use each other; move what they share down a layer.`;
|
|
1137
1169
|
const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1138
1170
|
const crateDirectories = (listed) => pipe(listed, Array.filter((name) => MANIFEST$3.test(name)), Array.map((name) => String$1.replace(MANIFEST$3, "")(name)));
|
|
1139
1171
|
const ownedBy = (crate, name) => {
|
|
@@ -1168,120 +1200,13 @@ const kindOf$1 = (inner) => {
|
|
|
1168
1200
|
if (!String$1.startsWith(SOURCE_PREFIX$1)(inner)) return "misplaced";
|
|
1169
1201
|
return sourceKindOf(inner);
|
|
1170
1202
|
};
|
|
1171
|
-
const isInsideSource = (inner) => String$1.startsWith(SOURCE_PREFIX$1)(inner);
|
|
1172
|
-
const resolvedFrom = ({ segments, current }) => {
|
|
1173
|
-
const first = Array.head(segments);
|
|
1174
|
-
const rest = Array.drop(segments, 1);
|
|
1175
|
-
if (Option.contains(first, "crate")) return Option.some(rest);
|
|
1176
|
-
if (Option.contains(first, "self")) return resolvedFrom({
|
|
1177
|
-
segments: rest,
|
|
1178
|
-
current
|
|
1179
|
-
});
|
|
1180
|
-
if (Option.contains(first, "super")) return pipe(Option.liftPredicate(current, Array.isReadonlyArrayNonEmpty), Option.flatMap((parent) => resolvedFrom({
|
|
1181
|
-
segments: rest,
|
|
1182
|
-
current: Array.dropRight(parent, 1)
|
|
1183
|
-
})));
|
|
1184
|
-
return Option.some([...current, ...segments]);
|
|
1185
|
-
};
|
|
1186
|
-
const rankOf = (layer) => pipe(Array.findFirstIndex(LAYERS, (name) => name === layer), Option.getOrElse(() => NO_RANK));
|
|
1187
|
-
const partOf = (path, index) => Option.getOrElse(Array.get(path, index), () => "");
|
|
1188
|
-
const importMessage = ({ source, target }) => {
|
|
1189
|
-
const [sourceLayer, sourceSlice] = [partOf(source, LAYER_INDEX), partOf(source, SLICE_INDEX)];
|
|
1190
|
-
const [targetLayer, targetSlice] = [partOf(target, LAYER_INDEX), partOf(target, SLICE_INDEX)];
|
|
1191
|
-
if (!Array.contains(LAYERS, targetLayer) || target.length < 2) return Option.none();
|
|
1192
|
-
if (rankOf(targetLayer) < rankOf(sourceLayer)) return Option.some(upwardMessage(targetLayer, sourceLayer));
|
|
1193
|
-
if (targetLayer === sourceLayer && targetSlice !== sourceSlice && !Array.contains(SHARED_SLICES, targetLayer)) return Option.some(crossMessage(targetLayer, targetSlice, sourceSlice));
|
|
1194
|
-
return Option.none();
|
|
1195
|
-
};
|
|
1196
1203
|
const isSliceIndex = (modulePath) => modulePath.length === 2 && Option.exists(Array.head(modulePath), (layer) => Array.contains(SLICED_LAYERS, layer));
|
|
1197
1204
|
// src/features/check-placement/model/rust-syntax.ts
|
|
1198
|
-
const ANCHORS = [
|
|
1199
|
-
"crate",
|
|
1200
|
-
"super",
|
|
1201
|
-
"self"
|
|
1202
|
-
];
|
|
1203
|
-
const SCOPED = ["scoped_identifier", "scoped_type_identifier"];
|
|
1204
1205
|
const IGNORED_ITEMS = ["line_comment", "block_comment"];
|
|
1205
|
-
const PATH_SEPARATOR = "::";
|
|
1206
|
-
const SELF = "self";
|
|
1207
1206
|
const NEXT$4 = 1;
|
|
1208
1207
|
const ALLOCATOR = "global_allocator";
|
|
1209
1208
|
const field = (node, name) => Option.fromNullishOr(node.childForFieldName(name));
|
|
1210
1209
|
const namedChildren = (node) => pipe(node.namedChildren, Array.flatMap((child) => Option.toArray(Option.fromNullishOr(child))));
|
|
1211
|
-
const sameNode = (left, right) => Option.exists(left, (node) => node.id === right.id);
|
|
1212
|
-
const segmentsOf = (node) => {
|
|
1213
|
-
if (Array.contains(SCOPED, node.type)) return [...Option.match(field(node, "path"), {
|
|
1214
|
-
onNone: () => [],
|
|
1215
|
-
onSome: segmentsOf
|
|
1216
|
-
}), ...Option.match(field(node, "name"), {
|
|
1217
|
-
onNone: () => [],
|
|
1218
|
-
onSome: (name) => [name.text]
|
|
1219
|
-
})];
|
|
1220
|
-
if (node.type === "generic_type") return Option.match(field(node, "type"), {
|
|
1221
|
-
onNone: () => [],
|
|
1222
|
-
onSome: segmentsOf
|
|
1223
|
-
});
|
|
1224
|
-
return [node.text];
|
|
1225
|
-
};
|
|
1226
|
-
const extendsPath = (parent, node) => Array.contains(SCOPED, parent.type) && sameNode(field(parent, "path"), node) || parent.type === "generic_type" && sameNode(field(parent, "type"), node);
|
|
1227
|
-
const outermostPath = (node) => pipe(Option.fromNullishOr(node.parent), Option.filter((parent) => extendsPath(parent, node)), Option.match({
|
|
1228
|
-
onNone: () => node,
|
|
1229
|
-
onSome: outermostPath
|
|
1230
|
-
}));
|
|
1231
|
-
const tokenSegments = (node) => pipe(Option.fromNullishOr(node.nextSibling), Option.filter((separator) => separator.type === PATH_SEPARATOR), Option.flatMap((separator) => Option.fromNullishOr(separator.nextSibling)), Option.filter((next) => next.type === "identifier" || Array.contains(ANCHORS, next.type)), Option.match({
|
|
1232
|
-
onNone: () => [node.text],
|
|
1233
|
-
onSome: (next) => [node.text, ...tokenSegments(next)]
|
|
1234
|
-
}));
|
|
1235
|
-
const ancestors = (node) => pipe(Option.fromNullishOr(node.parent), Option.match({
|
|
1236
|
-
onNone: () => [],
|
|
1237
|
-
onSome: (parent) => [parent, ...ancestors(parent)]
|
|
1238
|
-
}));
|
|
1239
|
-
const scopeOf$1 = (node) => pipe(ancestors(node), Array.filter((ancestor) => ancestor.type === "mod_item"), Array.flatMap((module) => Option.toArray(field(module, "name"))), Array.map((name) => name.text), Array.reverse);
|
|
1240
|
-
const pathAt = (node, segments) => ({
|
|
1241
|
-
segments,
|
|
1242
|
-
scope: scopeOf$1(node),
|
|
1243
|
-
line: node.startPosition.row + NEXT$4,
|
|
1244
|
-
column: node.startPosition.column + NEXT$4
|
|
1245
|
-
});
|
|
1246
|
-
const insideAny = (node, kinds) => Array.some(ancestors(node), (ancestor) => Array.contains(kinds, ancestor.type));
|
|
1247
|
-
const anchoredPaths = (root) => pipe(root.descendantsOfType([...ANCHORS]), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.filter((node) => !insideAny(node, ["use_declaration", "visibility_modifier"])), Array.map((node) => {
|
|
1248
|
-
if (Option.exists(Option.fromNullishOr(node.parent), (parent) => parent.type === "token_tree")) return pathAt(node, tokenSegments(node));
|
|
1249
|
-
const outer = outermostPath(node);
|
|
1250
|
-
return pathAt(node, segmentsOf(outer));
|
|
1251
|
-
}));
|
|
1252
|
-
const joined = (prefix, node) => {
|
|
1253
|
-
const own = segmentsOf(node);
|
|
1254
|
-
if (own.length === NEXT$4 && Option.contains(Array.head(own), SELF) && Array.isReadonlyArrayNonEmpty(prefix)) return prefix;
|
|
1255
|
-
return [...prefix, ...own];
|
|
1256
|
-
};
|
|
1257
|
-
const treesOfUse = (prefix, node) => {
|
|
1258
|
-
switch (node.type) {
|
|
1259
|
-
case "scoped_use_list": {
|
|
1260
|
-
const base = Option.match(field(node, "path"), {
|
|
1261
|
-
onNone: () => prefix,
|
|
1262
|
-
onSome: (path) => joined(prefix, path)
|
|
1263
|
-
});
|
|
1264
|
-
return Option.match(field(node, "list"), {
|
|
1265
|
-
onNone: () => [base],
|
|
1266
|
-
onSome: (list) => treesOfUse(base, list)
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
case "use_list": return Array.flatMap(namedChildren(node), (child) => treesOfUse(prefix, child));
|
|
1270
|
-
case "use_as_clause": return Option.match(field(node, "path"), {
|
|
1271
|
-
onNone: () => [],
|
|
1272
|
-
onSome: (path) => [joined(prefix, path)]
|
|
1273
|
-
});
|
|
1274
|
-
case "use_wildcard": return pipe(Array.head(namedChildren(node)), Option.match({
|
|
1275
|
-
onNone: () => [prefix],
|
|
1276
|
-
onSome: (path) => [joined(prefix, path)]
|
|
1277
|
-
}));
|
|
1278
|
-
default: return [joined(prefix, node)];
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
const importedPaths = (root) => pipe(root.descendantsOfType("use_declaration"), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.flatMap((declaration) => pipe(field(declaration, "argument"), Option.match({
|
|
1282
|
-
onNone: () => [],
|
|
1283
|
-
onSome: (argument) => Array.map(treesOfUse([], argument), (segments) => pathAt(declaration, segments))
|
|
1284
|
-
}))), Array.filter(({ segments }) => Option.exists(Array.head(segments), (first) => Array.contains(ANCHORS, first))));
|
|
1285
1210
|
const itemOf = (node) => ({
|
|
1286
1211
|
kind: node.type,
|
|
1287
1212
|
name: Option.map(field(node, "name"), (name) => name.text),
|
|
@@ -1292,7 +1217,6 @@ const itemOf = (node) => ({
|
|
|
1292
1217
|
});
|
|
1293
1218
|
const replacesAllocator = (root) => pipe(root.descendantsOfType("attribute"), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.some((attribute) => Option.exists(Array.head(namedChildren(attribute)), (name) => name.text === ALLOCATOR)));
|
|
1294
1219
|
const readRustFile = (root) => ({
|
|
1295
|
-
paths: [...importedPaths(root), ...anchoredPaths(root)],
|
|
1296
1220
|
items: pipe(namedChildren(root), Array.filter((node) => !Array.contains(IGNORED_ITEMS, node.type)), Array.map(itemOf)),
|
|
1297
1221
|
replacesAllocator: replacesAllocator(root)
|
|
1298
1222
|
});
|
|
@@ -9772,7 +9696,6 @@ const LAYERED_RULE = "layered-source";
|
|
|
9772
9696
|
const ENTRY_RULE$1 = "public-entry";
|
|
9773
9697
|
const TEST_RULE = "colocated-test";
|
|
9774
9698
|
const SLICE_RULE = "feature-slice-name";
|
|
9775
|
-
const IMPORT_RULE = "layer-import";
|
|
9776
9699
|
const GRAMMAR = "rust";
|
|
9777
9700
|
const WORD_SEPARATOR = "_";
|
|
9778
9701
|
const FEATURES = "features";
|
|
@@ -9792,27 +9715,12 @@ const LAYER_ITEMS = [
|
|
|
9792
9715
|
const READ_CONCURRENCY$18 = 64;
|
|
9793
9716
|
const EXCLUDED$3 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
9794
9717
|
const NONE$2 = [];
|
|
9795
|
-
const OUTSIDE_MESSAGE = "sits outside src/. Put every module of a crate under src/ in an FSD layer; only build.rs and benches/ may stay outside.";
|
|
9796
|
-
const LAYER_MESSAGE = `is not an FSD layer. A crate's src/ holds only lib.rs, main.rs, bin/ and the layers ${Array.join(LAYERS, ", ")}.`;
|
|
9797
9718
|
const ROOT_MESSAGE = "defines code in the crate root. Keep lib.rs and main.rs to mod declarations of layers, use, pub use and fn main, and put the code in a layer.";
|
|
9798
9719
|
const LAYER_INDEX_MESSAGE = "defines code in a layer module. A layer module holds only mod declarations of its slices and use; put the code in a slice.";
|
|
9799
9720
|
const ENTRY_MESSAGE = "makes an inner module of a slice public. Declare it with plain mod and re-export what other slices use with pub use from the slice module.";
|
|
9800
9721
|
const TEST_MESSAGE = "sits in a separate test directory. Put the test next to the code it tests as a #[cfg(test)] module; only a test that replaces the global allocator needs its own binary in tests/.";
|
|
9801
9722
|
const SLICE_MESSAGE = "is not named <verb>_<object>. Name a feature slice after the one operation it performs, starting with an English verb (for example check_layout, sync_manuscripts).";
|
|
9802
9723
|
const isFeatureName = isVerbObjectBy(WORD_SEPARATOR);
|
|
9803
|
-
const placementProblem = ({ crate, inner, file }, root, join) => {
|
|
9804
|
-
if (!isInsideSource(inner)) return fileProblem$1({
|
|
9805
|
-
file,
|
|
9806
|
-
rule: LAYERED_RULE,
|
|
9807
|
-
message: OUTSIDE_MESSAGE
|
|
9808
|
-
});
|
|
9809
|
-
const top = Option.getOrElse(Array.head(modulePathOf(inner)), () => "");
|
|
9810
|
-
return fileProblem$1({
|
|
9811
|
-
file: join(root, crate, "src", top),
|
|
9812
|
-
rule: LAYERED_RULE,
|
|
9813
|
-
message: LAYER_MESSAGE
|
|
9814
|
-
});
|
|
9815
|
-
};
|
|
9816
9724
|
const itemProblem = (file, rule, message) => ({ line, column }) => ({
|
|
9817
9725
|
file,
|
|
9818
9726
|
line,
|
|
@@ -9826,21 +9734,11 @@ const isRootItem = (inner) => (item) => {
|
|
|
9826
9734
|
return item.kind === "function_item" && (inner === MAIN_FILE || BINARY.test(inner)) && Option.contains(item.name, MAIN);
|
|
9827
9735
|
};
|
|
9828
9736
|
const isLayerItem = (item) => Array.contains(LAYER_ITEMS, item.kind) || item.kind === "mod_item" && !item.inline;
|
|
9829
|
-
const importProblems = (file, modulePath, paths) => pipe(paths, Array.flatMap((path) => pipe(resolvedFrom({
|
|
9830
|
-
segments: path.segments,
|
|
9831
|
-
current: [...modulePath, ...path.scope]
|
|
9832
|
-
}), Option.flatMap((target) => importMessage({
|
|
9833
|
-
source: modulePath,
|
|
9834
|
-
target
|
|
9835
|
-
})), Option.map((message) => itemProblem(file, IMPORT_RULE, message)(path)), Option.toArray)), Array.dedupeWith((left, right) => left.line === right.line && left.column === right.column && left.message === right.message));
|
|
9836
9737
|
const entryProblems$1 = (file, modulePath, parsed) => {
|
|
9837
9738
|
if (!isSliceIndex(modulePath)) return NONE$2;
|
|
9838
9739
|
return pipe(parsed.items, Array.filter((item) => item.kind === "mod_item" && item.visible), Array.map(itemProblem(file, ENTRY_RULE$1, ENTRY_MESSAGE)));
|
|
9839
9740
|
};
|
|
9840
|
-
const moduleProblems = ({ source, parsed }) =>
|
|
9841
|
-
const modulePath = modulePathOf(source.inner);
|
|
9842
|
-
return [...entryProblems$1(source.file, modulePath, parsed), ...importProblems(source.file, modulePath, parsed.paths)];
|
|
9843
|
-
};
|
|
9741
|
+
const moduleProblems = ({ source, parsed }) => entryProblems$1(source.file, modulePathOf(source.inner), parsed);
|
|
9844
9742
|
const testProblems = ({ source, parsed }) => {
|
|
9845
9743
|
if (parsed.replacesAllocator) return NONE$2;
|
|
9846
9744
|
return [fileProblem$1({
|
|
@@ -9868,7 +9766,6 @@ const sliceNameProblems = (root, join, sources) => pipe(sources, Array.filter(({
|
|
|
9868
9766
|
rule: SLICE_RULE,
|
|
9869
9767
|
message: SLICE_MESSAGE
|
|
9870
9768
|
})));
|
|
9871
|
-
const misplacedProblems = (root, join, sources) => pipe(sources, Array.filter(({ inner }) => kindOf$1(inner) === "misplaced"), Array.map((source) => placementProblem(source, root, join)), Array.dedupeWith((left, right) => left.file === right.file));
|
|
9872
9769
|
const parsedWith = (language) => (source, text) => Option.map(readTree({
|
|
9873
9770
|
language,
|
|
9874
9771
|
source: text,
|
|
@@ -9898,15 +9795,11 @@ const checkRustModules = Effect.fn("checkRustModules")(function* checkRustModule
|
|
|
9898
9795
|
const language = yield* loadLanguage(GRAMMAR).pipe(Effect.orDie);
|
|
9899
9796
|
const parse = parsedWith(language);
|
|
9900
9797
|
const read = yield* Effect.forEach(pipe(sources, Array.filter(isRead)), (source) => files.readFile(source.file).pipe(Effect.map(Option.flatMap((text) => parse(source, text)))), { concurrency: READ_CONCURRENCY$18 });
|
|
9901
|
-
return [
|
|
9902
|
-
...misplacedProblems(root, files.join, sources),
|
|
9903
|
-
...sliceNameProblems(root, files.join, sources),
|
|
9904
|
-
...Array.flatMap(Array.getSomes(read), problemsOf$3)
|
|
9905
|
-
];
|
|
9798
|
+
return [...sliceNameProblems(root, files.join, sources), ...Array.flatMap(Array.getSomes(read), problemsOf$3)];
|
|
9906
9799
|
});
|
|
9907
9800
|
// src/features/check-placement/model/source-aliases.ts
|
|
9908
9801
|
const ALIAS_RULE = "source-alias";
|
|
9909
|
-
const FIRST$
|
|
9802
|
+
const FIRST$13 = 1;
|
|
9910
9803
|
const SOURCE_ALIAS = "#/*";
|
|
9911
9804
|
const SOURCE_TARGET = "./src/*";
|
|
9912
9805
|
const SOURCE_PREFIX = /^\.\/src(?:\/|$)/u;
|
|
@@ -9915,8 +9808,8 @@ const Manifest$3 = Schema.Struct({ imports: Schema.optional(Schema.Unknown) });
|
|
|
9915
9808
|
const decodeManifest$6 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$3));
|
|
9916
9809
|
const problemAt$6 = (file, rule, message) => ({
|
|
9917
9810
|
file,
|
|
9918
|
-
line: FIRST$
|
|
9919
|
-
column: FIRST$
|
|
9811
|
+
line: FIRST$13,
|
|
9812
|
+
column: FIRST$13,
|
|
9920
9813
|
rule,
|
|
9921
9814
|
message
|
|
9922
9815
|
});
|
|
@@ -9928,7 +9821,7 @@ const targetsOf = (target) => {
|
|
|
9928
9821
|
const intoSource = ([key, target]) => !(key === SOURCE_ALIAS && pipe(targetsOf(target), Array.every((path) => path === SOURCE_TARGET))) && pipe(targetsOf(target), Array.some((path) => SOURCE_PREFIX.test(path)));
|
|
9929
9822
|
const aliasProblems = Effect.fn("aliasProblems")(function* aliasProblems(root, workspace) {
|
|
9930
9823
|
const files = yield* RepositoryFiles;
|
|
9931
|
-
const manifest = files.join(root, workspace, MANIFEST_FILE$
|
|
9824
|
+
const manifest = files.join(root, workspace, MANIFEST_FILE$3);
|
|
9932
9825
|
const text = yield* files.readFile(manifest);
|
|
9933
9826
|
return pipe(text, Option.flatMap(decodeManifest$6), Option.flatMap(({ imports }) => Option.liftPredicate(imports, Predicate.isObject)), Option.map((imports) => Record.toEntries(imports)), Option.getOrElse(() => Array.empty()), Array.filter(intoSource), Array.map(([key]) => problemAt$6(manifest, ALIAS_RULE, `"${key}" ${ALIAS_MESSAGE}`)));
|
|
9934
9827
|
});
|
|
@@ -9944,7 +9837,7 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
|
|
|
9944
9837
|
const found = yield* Effect.all([
|
|
9945
9838
|
checkDocPlacement(root),
|
|
9946
9839
|
checkColocatedTests(root),
|
|
9947
|
-
|
|
9840
|
+
checkPublicEntries(root),
|
|
9948
9841
|
checkRustModules(root),
|
|
9949
9842
|
checkSourceAliases(root),
|
|
9950
9843
|
checkSourceNames(root),
|
|
@@ -9964,7 +9857,7 @@ const WORKFLOW_DIRECTORY$1 = ".github/";
|
|
|
9964
9857
|
const SEPARATOR$13 = "/";
|
|
9965
9858
|
const CURRENT = "./";
|
|
9966
9859
|
const READ_CONCURRENCY$17 = 8;
|
|
9967
|
-
const FIRST$
|
|
9860
|
+
const FIRST$12 = 1;
|
|
9968
9861
|
const RUN_FILE = /(?:^|[\s;&|(])(?:node|vpx|tsx|bun|deno)\s+(?:-\S+\s+)*(?<file>[^\s;&|)]+\.[cm]?[jt]s)\b/gu;
|
|
9969
9862
|
const COMMAND = /^bin\/[^/]+\.[cm]?ts$/u;
|
|
9970
9863
|
const NOT_COMMAND = /\.(?:test|d|test\.support)\.[cm]?ts$/u;
|
|
@@ -10000,7 +9893,7 @@ const entriesOf$2 = (manifest) => {
|
|
|
10000
9893
|
};
|
|
10001
9894
|
const declaredEntries = Effect.fn("declaredEntries")(function* declaredEntries(root, directory) {
|
|
10002
9895
|
const files = yield* RepositoryFiles;
|
|
10003
|
-
const text = yield* files.readFile(files.join(root, directory, MANIFEST_FILE$
|
|
9896
|
+
const text = yield* files.readFile(files.join(root, directory, MANIFEST_FILE$3));
|
|
10004
9897
|
return pipe(text, Option.flatMap(decodeManifest$5), Option.map(entriesOf$2), Option.getOrElse(() => NO_ENTRIES));
|
|
10005
9898
|
});
|
|
10006
9899
|
const isCommand$1 = (path) => COMMAND.test(path) && !NOT_COMMAND.test(path);
|
|
@@ -10040,8 +9933,8 @@ const problemsIn$13 = Effect.fn("problemsIn")(function* problemsIn(root, directo
|
|
|
10040
9933
|
const isRun = (path) => Array.contains(runPaths, path) || Array.contains(entries.bins, path) || String$1.includes(workspacePath(directory, path))(workflows);
|
|
10041
9934
|
const unrun = pipe(commands, Array.filter((path) => !isRun(path)), Array.map((path) => ({
|
|
10042
9935
|
file: files.join(root, directory, path),
|
|
10043
|
-
line: FIRST$
|
|
10044
|
-
column: FIRST$
|
|
9936
|
+
line: FIRST$12,
|
|
9937
|
+
column: FIRST$12,
|
|
10045
9938
|
rule: UNRUN,
|
|
10046
9939
|
message: `No task, package.json bin or workflow runs ${workspacePath(directory, path)}. Files in ${BIN}/ are entry points for fallow, so an unused one is never reported. Run it from a task or delete it.`
|
|
10047
9940
|
})));
|
|
@@ -10053,8 +9946,8 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
|
|
|
10053
9946
|
const isDirectory = yield* files.isDirectory(file);
|
|
10054
9947
|
return pipe(isDirectory, Option.filter(Boolean), Option.map(() => ({
|
|
10055
9948
|
file,
|
|
10056
|
-
line: FIRST$
|
|
10057
|
-
column: FIRST$
|
|
9949
|
+
line: FIRST$12,
|
|
9950
|
+
column: FIRST$12,
|
|
10058
9951
|
rule: SCRIPTS,
|
|
10059
9952
|
message: `${workspacePath(directory, SCRIPTS_DIRECTORY)} is a scripts directory. Put each command at ${BIN}/<name>.ts and the code that it shares in the package's own source, so that every workspace runs its commands the same way.`
|
|
10060
9953
|
})));
|
|
@@ -10069,15 +9962,20 @@ const checkCommandEntries = Effect.fn("checkCommandEntries")(function* checkComm
|
|
|
10069
9962
|
});
|
|
10070
9963
|
// src/features/check-repository-layout/model/crates.ts
|
|
10071
9964
|
const RULE$30 = "unverified-crate";
|
|
9965
|
+
const VERSION_RULE = "release-version";
|
|
9966
|
+
const MANIFEST_FILE$1 = "package.json";
|
|
9967
|
+
const APP_DIRECTORIES = ["", "src-tauri"];
|
|
10072
9968
|
const CARGO_FILE = "Cargo.toml";
|
|
10073
9969
|
const CONFIG_FILE$5 = "vite.config.ts";
|
|
10074
9970
|
const SEPARATOR$12 = "/";
|
|
10075
|
-
const FIRST$
|
|
9971
|
+
const FIRST$11 = 1;
|
|
10076
9972
|
const READ_CONCURRENCY$16 = 8;
|
|
10077
9973
|
const CrateEntry = Schema.Struct({
|
|
10078
9974
|
name: Schema.String,
|
|
9975
|
+
version: Schema.String,
|
|
10079
9976
|
manifest_path: Schema.String
|
|
10080
9977
|
});
|
|
9978
|
+
const PackageVersion = Schema.fromJsonString(Schema.Struct({ version: Schema.String }));
|
|
10081
9979
|
const CrateList = Schema.fromJsonString(Schema.Struct({ packages: Schema.Array(CrateEntry) }));
|
|
10082
9980
|
const decodeCrateList = Schema.decodeUnknownEffect(CrateList);
|
|
10083
9981
|
const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
@@ -10095,6 +9993,7 @@ const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
|
10095
9993
|
const list = yield* decodeCrateList(output);
|
|
10096
9994
|
return pipe(list.packages, Array.map((crate) => ({
|
|
10097
9995
|
name: crate.name,
|
|
9996
|
+
version: crate.version,
|
|
10098
9997
|
manifest: crate.manifest_path
|
|
10099
9998
|
})));
|
|
10100
9999
|
}, Effect.scoped);
|
|
@@ -10104,8 +10003,8 @@ const owningWorkspace = (directories) => (directory) => {
|
|
|
10104
10003
|
};
|
|
10105
10004
|
const problemFor$2 = (crate, message) => ({
|
|
10106
10005
|
file: crate.manifest,
|
|
10107
|
-
line: FIRST$
|
|
10108
|
-
column: FIRST$
|
|
10006
|
+
line: FIRST$11,
|
|
10007
|
+
column: FIRST$11,
|
|
10109
10008
|
rule: RULE$30,
|
|
10110
10009
|
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
10111
10010
|
});
|
|
@@ -10116,14 +10015,30 @@ const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, directories
|
|
|
10116
10015
|
if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$5))) return Option.none();
|
|
10117
10016
|
return Option.some(problemFor$2(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$5} has no verify task`));
|
|
10118
10017
|
});
|
|
10018
|
+
const versionProblemIn = Effect.fn("versionProblemIn")(function* versionProblemIn(root, directories, crate) {
|
|
10019
|
+
const files = yield* RepositoryFiles;
|
|
10020
|
+
const directory = files.relative(root, files.dirname(crate.manifest));
|
|
10021
|
+
const workspace = pipe(directories, Array.findFirst((candidate) => pipe(APP_DIRECTORIES, Array.map((inner) => pipe([candidate, inner], Array.filter(String$1.isNonEmpty), Array.join(SEPARATOR$12))), Array.contains(directory))));
|
|
10022
|
+
if (Option.isNone(workspace)) return Option.none();
|
|
10023
|
+
const text = yield* files.readFile(files.join(root, workspace.value, MANIFEST_FILE$1));
|
|
10024
|
+
const version = pipe(text, Option.flatMap(Schema.decodeOption(PackageVersion)), Option.map((manifest) => manifest.version));
|
|
10025
|
+
if (Option.isNone(version) || version.value === crate.version) return Option.none();
|
|
10026
|
+
return Option.some({
|
|
10027
|
+
file: crate.manifest,
|
|
10028
|
+
line: FIRST$11,
|
|
10029
|
+
column: FIRST$11,
|
|
10030
|
+
rule: VERSION_RULE,
|
|
10031
|
+
message: `crate ${crate.name} is version ${crate.version} but ${workspace.value}/${MANIFEST_FILE$1} is ${version.value}. msch-publish releases the version in package.json, so bump both in the same PR.`
|
|
10032
|
+
});
|
|
10033
|
+
});
|
|
10119
10034
|
/** @internal */
|
|
10120
10035
|
const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
10121
10036
|
const files = yield* RepositoryFiles;
|
|
10122
10037
|
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
10123
10038
|
const directories = yield* workspaceDirectories(root);
|
|
10124
10039
|
const crates = yield* cratesIn(root);
|
|
10125
|
-
const found = yield* Effect.forEach(crates, (crate) => problemIn$2(root, directories, crate), { concurrency: READ_CONCURRENCY$16 });
|
|
10126
|
-
return Array.getSomes(found);
|
|
10040
|
+
const found = yield* Effect.forEach(crates, (crate) => Effect.all([problemIn$2(root, directories, crate), versionProblemIn(root, directories, crate)], { concurrency: "unbounded" }), { concurrency: READ_CONCURRENCY$16 });
|
|
10041
|
+
return Array.getSomes(Array.flatten(found));
|
|
10127
10042
|
});
|
|
10128
10043
|
// src/features/check-repository-layout/model/deploy-entry-patterns.ts
|
|
10129
10044
|
const RULE$29 = "deploy-entry-pattern";
|
|
@@ -10145,7 +10060,7 @@ const ROOT_WORKSPACE = ".";
|
|
|
10145
10060
|
const WRAP_OFFSET$1 = 1;
|
|
10146
10061
|
const NO_OFFSET = 0;
|
|
10147
10062
|
const READ_CONCURRENCY$15 = 8;
|
|
10148
|
-
const MESSAGE$
|
|
10063
|
+
const MESSAGE$9 = "selects deploy entries by their name or location. A deploy entry is the file that an Alchemy resource names in main, and its name and place change with the code. Use workspaceSettings().lint.deployEntries in lint settings; fallow reads main from the stack by itself.";
|
|
10149
10064
|
const decodeKey$1 = Schema.decodeUnknownOption(KeySchema);
|
|
10150
10065
|
const FALLOW = {
|
|
10151
10066
|
keys: FALLOW_KEYS,
|
|
@@ -10198,7 +10113,7 @@ const problemsIn$12 = Effect.fn("problemsIn")(function* problemsIn(request) {
|
|
|
10198
10113
|
file: path,
|
|
10199
10114
|
...positionOf(text.value)(start - kind.offset),
|
|
10200
10115
|
rule: RULE$29,
|
|
10201
|
-
message: `${pattern} ${MESSAGE$
|
|
10116
|
+
message: `${pattern} ${MESSAGE$9}`
|
|
10202
10117
|
})));
|
|
10203
10118
|
});
|
|
10204
10119
|
/** @internal */
|
|
@@ -10274,7 +10189,7 @@ const checkFallowEntries = Effect.fn("checkFallowEntries")(function* checkFallow
|
|
|
10274
10189
|
// src/features/check-repository-layout/model/hidden-verify.ts
|
|
10275
10190
|
const RULE$27 = "hidden-verify";
|
|
10276
10191
|
const CONFIG_FILE$4 = "vite.config.ts";
|
|
10277
|
-
const FIRST$
|
|
10192
|
+
const FIRST$10 = 1;
|
|
10278
10193
|
const READ_CONCURRENCY$13 = 8;
|
|
10279
10194
|
const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
10280
10195
|
const config = yield* workspaceConfigOf(root, directory);
|
|
@@ -10284,8 +10199,8 @@ const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directory)
|
|
|
10284
10199
|
const verified = yield* hasVerifyTask(file);
|
|
10285
10200
|
return Option.some({
|
|
10286
10201
|
file,
|
|
10287
|
-
line: FIRST$
|
|
10288
|
-
column: FIRST$
|
|
10202
|
+
line: FIRST$10,
|
|
10203
|
+
column: FIRST$10,
|
|
10289
10204
|
rule: RULE$27,
|
|
10290
10205
|
message: `${directory} gets its verify task from code outside ${CONFIG_FILE$4}. The root verify reads ${CONFIG_FILE$4} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$4}.`
|
|
10291
10206
|
}).pipe(Option.filter(() => verified));
|
|
@@ -10301,7 +10216,7 @@ const RULE$26 = "root-workspace-path";
|
|
|
10301
10216
|
const CONFIG_FILE$3 = "vite.config.ts";
|
|
10302
10217
|
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
10303
10218
|
const NAME_CHARACTER = /[\w.@-]/u;
|
|
10304
|
-
const FIRST$
|
|
10219
|
+
const FIRST$9 = 0;
|
|
10305
10220
|
const NEXT$2 = 1;
|
|
10306
10221
|
const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
|
|
10307
10222
|
const mentions$1 = (directory) => (text) => {
|
|
@@ -10309,7 +10224,7 @@ const mentions$1 = (directory) => (text) => {
|
|
|
10309
10224
|
return pipe(Array.drop(parts, NEXT$2), Array.some((after, index) => {
|
|
10310
10225
|
const before = parts[index] ?? "";
|
|
10311
10226
|
const previous = String$1.slice(before.length - NEXT$2)(before);
|
|
10312
|
-
const following = String$1.slice(FIRST$
|
|
10227
|
+
const following = String$1.slice(FIRST$9, NEXT$2)(after);
|
|
10313
10228
|
return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
|
|
10314
10229
|
}));
|
|
10315
10230
|
};
|
|
@@ -10525,7 +10440,7 @@ const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
|
|
|
10525
10440
|
const READ_CONCURRENCY$11 = 8;
|
|
10526
10441
|
const WILDCARD$2 = /[*?[]/u;
|
|
10527
10442
|
const SEPARATOR$9 = "/";
|
|
10528
|
-
const FIRST$
|
|
10443
|
+
const FIRST$8 = 0;
|
|
10529
10444
|
const EXPECTED = {
|
|
10530
10445
|
action: "a directory with action.yml",
|
|
10531
10446
|
directory: "a directory",
|
|
@@ -10566,7 +10481,7 @@ const RESOLVERS = {
|
|
|
10566
10481
|
};
|
|
10567
10482
|
const staticPrefix = (path) => {
|
|
10568
10483
|
const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD$2));
|
|
10569
|
-
if (String$1.endsWith(SEPARATOR$9)(prefix)) return String$1.slice(FIRST$
|
|
10484
|
+
if (String$1.endsWith(SEPARATOR$9)(prefix)) return String$1.slice(FIRST$8, -1)(prefix);
|
|
10570
10485
|
return prefix;
|
|
10571
10486
|
};
|
|
10572
10487
|
const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
@@ -10582,7 +10497,7 @@ const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, fou
|
|
|
10582
10497
|
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
10583
10498
|
return !(yield* isIgnored$1(root, found.path));
|
|
10584
10499
|
});
|
|
10585
|
-
const problemOf$
|
|
10500
|
+
const problemOf$7 = (file, source) => (found) => ({
|
|
10586
10501
|
file,
|
|
10587
10502
|
...positionOf(source)(found.offset),
|
|
10588
10503
|
rule: RULE$24,
|
|
@@ -10595,7 +10510,7 @@ const problemsIn$9 = Effect.fn("problemsIn")(function* problemsIn(root, workflow
|
|
|
10595
10510
|
if (Option.isNone(source)) return [];
|
|
10596
10511
|
const produced = producedPaths(source.value);
|
|
10597
10512
|
const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
|
|
10598
|
-
return pipe(missing, Array.map(problemOf$
|
|
10513
|
+
return pipe(missing, Array.map(problemOf$7(file, source.value)));
|
|
10599
10514
|
});
|
|
10600
10515
|
/** @internal */
|
|
10601
10516
|
const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
|
|
@@ -10718,7 +10633,7 @@ const LOCKFILE = "pnpm-lock.yaml";
|
|
|
10718
10633
|
const COMPILER = "typescript";
|
|
10719
10634
|
const CURRENT_MAJOR = 7;
|
|
10720
10635
|
const LEGACY_COMPILER_PACKAGE = /^@typescript\/typescript\d+$/u;
|
|
10721
|
-
const FIRST$
|
|
10636
|
+
const FIRST$7 = 1;
|
|
10722
10637
|
const legacyOf = (id) => {
|
|
10723
10638
|
const { name, version } = parse$1(id);
|
|
10724
10639
|
const isOldCompiler = name === COMPILER && pipe(Option.fromNullishOr(version), Option.flatMap((found) => Option.fromNullishOr(semver.coerce(found))), Option.exists((found) => found.major < CURRENT_MAJOR));
|
|
@@ -10729,8 +10644,8 @@ const legacyOf = (id) => {
|
|
|
10729
10644
|
};
|
|
10730
10645
|
const dependentsOf = (nodes) => (id) => pipe(nodes, Array.filter(({ dependencies }) => Array.contains(dependencies, id)), Array.map((node) => `\`${node.id}\``));
|
|
10731
10646
|
const lineOf$2 = (source) => (id) => pipe(String$1.split(source, "\n"), Array.findFirstIndex((line) => String$1.replaceAll("'", "")(String$1.trim(line)) === `${id}:`), Option.match({
|
|
10732
|
-
onNone: () => FIRST$
|
|
10733
|
-
onSome: (index) => index + FIRST$
|
|
10647
|
+
onNone: () => FIRST$7,
|
|
10648
|
+
onSome: (index) => index + FIRST$7
|
|
10734
10649
|
}));
|
|
10735
10650
|
const messageOf$2 = (legacy, dependents) => `\`${legacy.id}\` is installed, pulled in by ${Array.join(dependents, ", ")}. Only TypeScript ${String(CURRENT_MAJOR)} or newer is used: remove the dependency that needs the old compiler, move it to the TypeScript ${String(CURRENT_MAJOR)} API, or bundle or port it. Do not install an old compiler beside TypeScript ${String(CURRENT_MAJOR)}.`;
|
|
10736
10651
|
/** @internal */
|
|
@@ -10743,7 +10658,7 @@ const checkTypescriptGeneration = Effect.fn("checkTypescriptGeneration")(functio
|
|
|
10743
10658
|
return pipe(Option.getOrElse(nodes, () => []), Array.flatMap(({ id }) => Option.toArray(legacyOf(id))), Array.map((legacy) => ({
|
|
10744
10659
|
file,
|
|
10745
10660
|
line: lineOf$2(source)(legacy.id),
|
|
10746
|
-
column: FIRST$
|
|
10661
|
+
column: FIRST$7,
|
|
10747
10662
|
rule: RULE$23,
|
|
10748
10663
|
message: messageOf$2(legacy, dependentsOf(Option.getOrElse(nodes, () => []))(legacy.id))
|
|
10749
10664
|
})));
|
|
@@ -10968,7 +10883,7 @@ const listConfigFiles = (root) => Effect.gen(function* configFilesUnder() {
|
|
|
10968
10883
|
const parseConfig = (api) => (configPath) => Option.some(api.parseConfigFile(configPath)).pipe(Option.filter((parsed) => Array.isReadonlyArrayNonEmpty(parsed.fileNames)));
|
|
10969
10884
|
const nearestPackageDirectory = (directory, root) => Effect.gen(function* nearestPackage() {
|
|
10970
10885
|
const files = yield* RepositoryFiles;
|
|
10971
|
-
const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE$
|
|
10886
|
+
const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE$3));
|
|
10972
10887
|
const parent = files.dirname(directory);
|
|
10973
10888
|
if (hasManifest || directory === root || parent === directory) return directory;
|
|
10974
10889
|
return yield* nearestPackageDirectory(parent, root);
|
|
@@ -11218,7 +11133,7 @@ const packagesFrom = (graph, walk) => Array.match(walk.pending, {
|
|
|
11218
11133
|
/** @internal */
|
|
11219
11134
|
const packagesByEntry = Effect.fn("packagesByEntry")(function* packagesByEntry(api, directory, entries) {
|
|
11220
11135
|
const files = yield* RepositoryFiles;
|
|
11221
|
-
const manifest = yield* files.readFile(files.join(directory, MANIFEST_FILE$
|
|
11136
|
+
const manifest = yield* files.readFile(files.join(directory, MANIFEST_FILE$3));
|
|
11222
11137
|
const graph = {
|
|
11223
11138
|
api,
|
|
11224
11139
|
directory,
|
|
@@ -11251,7 +11166,7 @@ const installedNames = (manifest) => [
|
|
|
11251
11166
|
];
|
|
11252
11167
|
const childrenOf$1 = Effect.fn("childrenOf")(function* childrenOf(directory) {
|
|
11253
11168
|
const files = yield* RepositoryFiles;
|
|
11254
|
-
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$
|
|
11169
|
+
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$3));
|
|
11255
11170
|
return pipe(text, Option.flatMap(decodeManifest$4), Option.map(installedNames), Option.getOrElse(() => []), Array.map((child) => [directory, child]));
|
|
11256
11171
|
});
|
|
11257
11172
|
const resolveFrom = (from, name) => Effect.gen(function* resolvePackage() {
|
|
@@ -11413,7 +11328,7 @@ const problemsOf$1 = Effect.fn("problemsOf")(function* problemsOf(workspace, fil
|
|
|
11413
11328
|
});
|
|
11414
11329
|
const workspaceProblems = Effect.fn("workspaceProblems")(function* workspaceProblems(workspace) {
|
|
11415
11330
|
const files = yield* RepositoryFiles;
|
|
11416
|
-
const file = files.join(workspace.directory, MANIFEST_FILE$
|
|
11331
|
+
const file = files.join(workspace.directory, MANIFEST_FILE$3);
|
|
11417
11332
|
const source = yield* files.readFile(file);
|
|
11418
11333
|
return yield* Option.match(source, {
|
|
11419
11334
|
onNone: () => Effect.succeed([]),
|
|
@@ -11892,8 +11807,11 @@ const CACHE_DIRECTORY = [
|
|
|
11892
11807
|
];
|
|
11893
11808
|
const CACHE_SUFFIX = ".json";
|
|
11894
11809
|
const MANIFEST_ENTRY = "package.json";
|
|
11895
|
-
const
|
|
11810
|
+
const SOURCE_ENTRY = "src";
|
|
11811
|
+
const LOWER_LAYERS = ["entities", "shared"];
|
|
11812
|
+
const PATH_SEPARATOR = "/";
|
|
11896
11813
|
const EMPTY = "";
|
|
11814
|
+
const NOT_INSTALLED = [];
|
|
11897
11815
|
const FIELD_SEPARATOR = "\0";
|
|
11898
11816
|
const LINE_SEPARATOR = "\n";
|
|
11899
11817
|
const ValueSchema = Schema.Union([Schema.String, Schema.Finite]);
|
|
@@ -11939,25 +11857,56 @@ const fileDigest = (hash) => {
|
|
|
11939
11857
|
});
|
|
11940
11858
|
};
|
|
11941
11859
|
const digestEntries = (digestFile) => (named) => Effect.forEach(named, ([name, file]) => digestFile(file).pipe(Effect.map((found) => entryOf(name, found))), { concurrency: 1 });
|
|
11942
|
-
const
|
|
11860
|
+
const walked = (directory) => Effect.gen(function* walkFrom() {
|
|
11943
11861
|
const files = yield* RepositoryFiles;
|
|
11944
|
-
const
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11862
|
+
const found = yield* files.walkDirectory(directory);
|
|
11863
|
+
return pipe(found, Array.map((file) => files.join(directory, file)));
|
|
11864
|
+
});
|
|
11865
|
+
const sourceFiles = Effect.fn("sourceFiles")(function* sourceFiles(root, moduleDirectory) {
|
|
11866
|
+
const files = yield* RepositoryFiles;
|
|
11867
|
+
const source = files.join(root, SOURCE_ENTRY);
|
|
11868
|
+
const layers = pipe(LOWER_LAYERS, Array.map((layer) => files.join(source, layer)));
|
|
11869
|
+
const nested = yield* Effect.forEach([files.dirname(moduleDirectory), ...layers], walked, { concurrency: 1 });
|
|
11870
|
+
return Array.flatten(nested);
|
|
11871
|
+
});
|
|
11872
|
+
const bundleParts = Effect.fn("bundleParts")(function* bundleParts(root, moduleDirectory) {
|
|
11873
|
+
const files = yield* RepositoryFiles;
|
|
11874
|
+
const bundled = yield* walked(moduleDirectory);
|
|
11875
|
+
return {
|
|
11876
|
+
listed: [files.join(root, MANIFEST_ENTRY), ...bundled],
|
|
11877
|
+
installed: NOT_INSTALLED
|
|
11878
|
+
};
|
|
11879
|
+
});
|
|
11880
|
+
const sourceParts = Effect.fn("sourceParts")(function* sourceParts(root, moduleDirectory) {
|
|
11881
|
+
return {
|
|
11882
|
+
listed: yield* sourceFiles(root, moduleDirectory),
|
|
11883
|
+
installed: yield* installedPackages(root, root)
|
|
11884
|
+
};
|
|
11885
|
+
});
|
|
11886
|
+
/** @internal */
|
|
11887
|
+
const implementationOf = Effect.fn("implementationOf")(function* implementationOf(moduleDirectory) {
|
|
11888
|
+
const files = yield* RepositoryFiles;
|
|
11889
|
+
const root = yield* nearestManifestDirectory(moduleDirectory);
|
|
11890
|
+
const fromSource = String$1.startsWith(`${files.join(root, SOURCE_ENTRY)}${PATH_SEPARATOR}`)(moduleDirectory);
|
|
11891
|
+
const parts = yield* Boolean$1.match(fromSource, {
|
|
11892
|
+
onFalse: () => bundleParts(root, moduleDirectory),
|
|
11893
|
+
onTrue: () => sourceParts(root, moduleDirectory)
|
|
11894
|
+
});
|
|
11895
|
+
return {
|
|
11896
|
+
files: pipe(Array.sort(parts.listed, String$1.Order), Array.map((file) => [files.relative(root, file), file])),
|
|
11897
|
+
installed: parts.installed
|
|
11898
|
+
};
|
|
11949
11899
|
});
|
|
11950
11900
|
const fingerprintOf = Effect.fn("fingerprintOf")(function* fingerprintOf(hash) {
|
|
11951
|
-
const
|
|
11952
|
-
const
|
|
11953
|
-
|
|
11954
|
-
return yield* hash(Array.join(entries, LINE_SEPARATOR));
|
|
11901
|
+
const implementation = yield* implementationOf(import.meta.dirname);
|
|
11902
|
+
const entries = yield* digestEntries(fileDigest(hash))(implementation.files);
|
|
11903
|
+
return yield* hash(Array.join([...implementation.installed, ...entries], LINE_SEPARATOR));
|
|
11955
11904
|
});
|
|
11956
11905
|
const analysisCache = Effect.fn("analysisCache")(function* analysisCache(root, owners) {
|
|
11957
11906
|
const files = yield* RepositoryFiles;
|
|
11958
11907
|
const hash = yield* hasher;
|
|
11959
11908
|
const fingerprint = yield* fingerprintOf(hash);
|
|
11960
|
-
const salt = yield* hash(Array.join([fingerprint, owners], FIELD_SEPARATOR));
|
|
11909
|
+
const salt = yield* hash(Array.join([fingerprint, String$1.replaceAll(root, EMPTY)(owners)], FIELD_SEPARATOR));
|
|
11961
11910
|
return {
|
|
11962
11911
|
root,
|
|
11963
11912
|
directory: files.join(root, ...CACHE_DIRECTORY),
|
|
@@ -11972,7 +11921,7 @@ const keyOf = (cache) => (configPath, inputs) => Effect.gen(function* deriveKey(
|
|
|
11972
11921
|
const header = [
|
|
11973
11922
|
cache.salt,
|
|
11974
11923
|
files.relative(cache.root, configPath),
|
|
11975
|
-
inputs.options
|
|
11924
|
+
String$1.replaceAll(cache.root, EMPTY)(inputs.options)
|
|
11976
11925
|
];
|
|
11977
11926
|
return yield* cache.hash(Array.join([
|
|
11978
11927
|
...header,
|
|
@@ -11980,17 +11929,35 @@ const keyOf = (cache) => (configPath, inputs) => Effect.gen(function* deriveKey(
|
|
|
11980
11929
|
...entries
|
|
11981
11930
|
], LINE_SEPARATOR));
|
|
11982
11931
|
});
|
|
11932
|
+
const moved = (move) => (analysis) => ({
|
|
11933
|
+
problems: pipe(analysis.problems, Array.map((problem) => ({
|
|
11934
|
+
...problem,
|
|
11935
|
+
file: move(problem.file)
|
|
11936
|
+
}))),
|
|
11937
|
+
unowned: pipe(analysis.unowned, Array.map((site) => ({
|
|
11938
|
+
...site,
|
|
11939
|
+
file: move(site.file)
|
|
11940
|
+
}))),
|
|
11941
|
+
literals: pipe(analysis.literals, Array.map((found) => ({
|
|
11942
|
+
...found,
|
|
11943
|
+
file: move(found.file),
|
|
11944
|
+
imports: pipe(found.imports, Array.map(move))
|
|
11945
|
+
})))
|
|
11946
|
+
});
|
|
11983
11947
|
const entryFile = (cache, key) => `${cache.directory}/${key}${CACHE_SUFFIX}`;
|
|
11984
11948
|
const readAnalysis = (cache) => (key) => Effect.gen(function* readCached() {
|
|
11985
|
-
const
|
|
11949
|
+
const files = yield* RepositoryFiles;
|
|
11950
|
+
const text = yield* files.readFile(entryFile(cache, key));
|
|
11951
|
+
const restored = moved((file) => files.resolve(cache.root, file));
|
|
11986
11952
|
return yield* Option.match(text, {
|
|
11987
11953
|
onNone: () => Effect.succeedNone,
|
|
11988
11954
|
onSome: (found) => Schema.decodeEffect(AnalysisJson)(found).pipe(Effect.option)
|
|
11989
|
-
});
|
|
11955
|
+
}).pipe(Effect.map(Option.map(restored)));
|
|
11990
11956
|
});
|
|
11991
11957
|
const writeAnalysis = (cache) => (key, analysis) => Effect.gen(function* writeCached() {
|
|
11992
11958
|
const files = yield* RepositoryFiles;
|
|
11993
|
-
const
|
|
11959
|
+
const portable = moved((file) => files.relative(cache.root, file))(analysis);
|
|
11960
|
+
const text = yield* Schema.encodeEffect(AnalysisJson)(portable).pipe(Effect.option);
|
|
11994
11961
|
yield* Option.match(text, {
|
|
11995
11962
|
onNone: () => Effect.void,
|
|
11996
11963
|
onSome: (found) => files.writeFile(entryFile(cache, key), found)
|
|
@@ -12046,7 +12013,7 @@ const nameListOf = (site) => {
|
|
|
12046
12013
|
}, (list) => list.names.length === site.values.length);
|
|
12047
12014
|
};
|
|
12048
12015
|
const mostNamesOf = (list) => Math.max(2, list.names.length - 1);
|
|
12049
|
-
const problemOf$
|
|
12016
|
+
const problemOf$6 = ({ list, reason }) => ({
|
|
12050
12017
|
file: list.site.file,
|
|
12051
12018
|
line: list.site.line,
|
|
12052
12019
|
column: list.site.column,
|
|
@@ -12081,7 +12048,7 @@ const declaredNameProblem = ({ literals, relative }) => {
|
|
|
12081
12048
|
if (defined.length < mostNamesOf(list) || files.length < 2) return Option.none();
|
|
12082
12049
|
const names = pipe(defined, Array.map(([name]) => name));
|
|
12083
12050
|
const shown = pipe(files, Array.take(SHOWN_FILES), Array.map(relative), Array.join(", "));
|
|
12084
|
-
return Option.some(problemOf$
|
|
12051
|
+
return Option.some(problemOf$6({
|
|
12085
12052
|
list,
|
|
12086
12053
|
reason: `${formatValues(names)} are each written in another module (${shown}). Type those values with this list, or build this list from them, so that adding one does not mean editing two places.`
|
|
12087
12054
|
}));
|
|
@@ -12114,11 +12081,11 @@ const listedPathProblem = (repository) => (list) => {
|
|
|
12114
12081
|
const paths = pipe(list.names, Array.map(namedPath(repository, list.site.file)), Array.getSomes);
|
|
12115
12082
|
const packages = pipe(list.names, Array.filter((name) => HashSet.has(repository.packages, name)));
|
|
12116
12083
|
const directory = enumeratedDirectory(repository)(paths);
|
|
12117
|
-
if (Option.isSome(directory)) return Option.some(problemOf$
|
|
12084
|
+
if (Option.isSome(directory)) return Option.some(problemOf$6({
|
|
12118
12085
|
list,
|
|
12119
12086
|
reason: `they enumerate the entries of ${directoryLabel(directory.value)}. Find them with a glob or derive them from the declaration that names them.`
|
|
12120
12087
|
}));
|
|
12121
|
-
if (packages.length >= 2) return Option.some(problemOf$
|
|
12088
|
+
if (packages.length >= 2) return Option.some(problemOf$6({
|
|
12122
12089
|
list,
|
|
12123
12090
|
reason: `${formatValues(packages)} are workspace packages. Derive them from the workspace manifests or from a property that each package declares.`
|
|
12124
12091
|
}));
|
|
@@ -12133,7 +12100,7 @@ const connected = (index) => (left, right) => left === right || imports(index)(l
|
|
|
12133
12100
|
const isPartOf = (index, list) => (other) => other !== list && canImport(list.site.scope, other.site.scope) && connected(index)(list.site.file, other.site.file) && isSubsetOf(list.names, other.names) && list.names.length * SUBSET_SHARE >= other.names.length && !sameValues(list.names, other.names);
|
|
12134
12101
|
const subsetListProblem = ({ lists, literals, relative }) => {
|
|
12135
12102
|
const index = importIndexOf(literals);
|
|
12136
|
-
return (list) => pipe(lists, Array.findFirst(isPartOf(index, list)), Option.map((other) => problemOf$
|
|
12103
|
+
return (list) => pipe(lists, Array.findFirst(isPartOf(index, list)), Option.map((other) => problemOf$6({
|
|
12137
12104
|
list,
|
|
12138
12105
|
reason: `they are a part of ${formatValues(other.names)} at ${relative(other.site.file)}:${String(other.site.line)}. Name that list once and select from it with Extract or Exclude.`
|
|
12139
12106
|
})));
|
|
@@ -12292,13 +12259,13 @@ const destructuredName = (declaration) => {
|
|
|
12292
12259
|
if (declaration.name.kind !== SyntaxKind.ObjectBindingPattern) return Option.none();
|
|
12293
12260
|
return pipe(Option.fromUndefinedOr(declaration.initializer), Option.filter(isIdentifier), Option.map((initializer) => initializer.text));
|
|
12294
12261
|
};
|
|
12295
|
-
const problemOf$
|
|
12262
|
+
const problemOf$5 = (names) => (declaration) => pipe(destructuredName(declaration), Option.filter((name) => names.includes(name)), Option.map((name) => problemAt$9({
|
|
12296
12263
|
rule: RULE$21,
|
|
12297
12264
|
message: messageOf$1(name)
|
|
12298
12265
|
})), Option.map((report) => report(declaration)));
|
|
12299
12266
|
const namespaceDestructuringIn = () => (sourceFile) => {
|
|
12300
12267
|
const names = importedNames(sourceFile);
|
|
12301
|
-
return pipe(descendantsOf(sourceFile), Array.filter(isVariableDeclaration), Array.map(problemOf$
|
|
12268
|
+
return pipe(descendantsOf(sourceFile), Array.filter(isVariableDeclaration), Array.map(problemOf$5(names)), Array.getSomes);
|
|
12302
12269
|
};
|
|
12303
12270
|
// src/features/source-code/find-pass-through-wrappers/model/pass-through-wrappers.ts
|
|
12304
12271
|
const RULE$20 = "pass-through-wrapper";
|
|
@@ -12395,14 +12362,14 @@ const isPassThrough = (checker) => (candidate) => (forward) => {
|
|
|
12395
12362
|
const restForwarded = pipe(wrapper.parameters, Array.some(isRest));
|
|
12396
12363
|
return Option.exists(forwardedNames(wrapper, forward), (names) => callsAnotherFunction(candidate, forward, names)) && (restForwarded || calleeTakesExactly(checker)(forward, wrapper.parameters.length)) && keepsTheReturnType(checker)(wrapper, forward) && !isOverloaded(checker)(name);
|
|
12397
12364
|
};
|
|
12398
|
-
const problemOf$
|
|
12365
|
+
const problemOf$4 = (checker) => (candidate) => {
|
|
12399
12366
|
if (changesTheCall(candidate.wrapper)) return Option.none();
|
|
12400
12367
|
return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt$9({
|
|
12401
12368
|
rule: RULE$20,
|
|
12402
12369
|
message: messageOf(forward.callee.getText())
|
|
12403
12370
|
})(candidate.name)));
|
|
12404
12371
|
};
|
|
12405
|
-
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$
|
|
12372
|
+
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$4(checker)), Array.getSomes);
|
|
12406
12373
|
// src/app/source-checks.ts
|
|
12407
12374
|
/** @internal */
|
|
12408
12375
|
const checkSources = (root) => checkRepository(root, [passThroughWrappersIn, namespaceDestructuringIn]);
|
|
@@ -12459,46 +12426,58 @@ const checkMissingHooks = Effect.fn("checkMissingHooks")(function* checkMissingH
|
|
|
12459
12426
|
const found = yield* Effect.forEach(hookFiles, problemsIn$8, { concurrency: READ_CONCURRENCY$9 });
|
|
12460
12427
|
return Array.flatten(found);
|
|
12461
12428
|
});
|
|
12462
|
-
// src/
|
|
12463
|
-
const taggedError$
|
|
12464
|
-
var
|
|
12429
|
+
// src/shared/lib/section-check.ts
|
|
12430
|
+
const taggedError$3 = Schema.TaggedError;
|
|
12431
|
+
var SectionConfigUnreadable = class extends taggedError$3()("SectionConfigUnreadable", { file: Schema.String }) {};
|
|
12465
12432
|
const CONFIG_FILE$2 = "vite.config.ts";
|
|
12466
|
-
const
|
|
12467
|
-
const
|
|
12468
|
-
const sectionAt = Effect.fn("markdownSection")(function* sectionAt(file) {
|
|
12433
|
+
const FIRST$6 = 1;
|
|
12434
|
+
const sectionAt = (file, pick) => Effect.gen(function* readSection() {
|
|
12469
12435
|
if (!(yield* (yield* RepositoryFiles).exists(file))) return Option.none();
|
|
12470
12436
|
const config = yield* Effect.tryPromise({
|
|
12471
12437
|
try: () => resolveConfigFromFile(file),
|
|
12472
|
-
catch: () =>
|
|
12438
|
+
catch: () => SectionConfigUnreadable.make({ file })
|
|
12473
12439
|
}).pipe(Effect.option);
|
|
12474
|
-
return pipe(config, Option.map(
|
|
12440
|
+
return pipe(config, Option.map(pick));
|
|
12475
12441
|
});
|
|
12476
|
-
const
|
|
12477
|
-
file: join(root, diagnostic.path),
|
|
12478
|
-
line: diagnostic.line,
|
|
12479
|
-
column: diagnostic.column ?? FIRST$5,
|
|
12480
|
-
rule: RULE$18,
|
|
12481
|
-
message: `${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`
|
|
12482
|
-
});
|
|
12483
|
-
const failureAt = (file, message) => [{
|
|
12442
|
+
const failureAt = (file, rule, message) => [{
|
|
12484
12443
|
file,
|
|
12485
|
-
line: FIRST$
|
|
12486
|
-
column: FIRST$
|
|
12487
|
-
rule
|
|
12444
|
+
line: FIRST$6,
|
|
12445
|
+
column: FIRST$6,
|
|
12446
|
+
rule,
|
|
12488
12447
|
message
|
|
12489
12448
|
}];
|
|
12490
|
-
const
|
|
12449
|
+
const checkSection = (check) => (root) => Effect.gen(function* runSection() {
|
|
12491
12450
|
const files = yield* RepositoryFiles;
|
|
12492
12451
|
const configFile = files.join(root, CONFIG_FILE$2);
|
|
12493
|
-
const section = yield* sectionAt(configFile);
|
|
12452
|
+
const section = yield* sectionAt(configFile, check.pick);
|
|
12494
12453
|
if (Option.isNone(section)) return [];
|
|
12495
12454
|
const config = section.value;
|
|
12496
|
-
const listed = yield* files.matchingFiles(root,
|
|
12497
|
-
|
|
12455
|
+
const [listed, projectFiles] = yield* Effect.all([files.matchingFiles(root, check.pathspecs(config)), files.listedFiles(root)], { concurrency: "unbounded" });
|
|
12456
|
+
const linted = yield* Effect.result(check.lint({
|
|
12498
12457
|
root,
|
|
12499
12458
|
files: listed,
|
|
12459
|
+
projectFiles,
|
|
12500
12460
|
config
|
|
12501
|
-
})
|
|
12461
|
+
}));
|
|
12462
|
+
return Result.match(linted, {
|
|
12463
|
+
onFailure: (failure) => failureAt(configFile, check.rule, failure.message),
|
|
12464
|
+
onSuccess: (found) => pipe(found, Array.filter(({ severity }) => severity === "error"), Array.map((diagnostic) => ({
|
|
12465
|
+
file: files.join(root, diagnostic.path),
|
|
12466
|
+
line: diagnostic.line,
|
|
12467
|
+
column: diagnostic.column ?? FIRST$6,
|
|
12468
|
+
rule: check.rule,
|
|
12469
|
+
message: `${diagnostic.rule} ${diagnostic.message}${check.detail(diagnostic)}`
|
|
12470
|
+
})))
|
|
12471
|
+
});
|
|
12472
|
+
}).pipe(Effect.withSpan(check.name));
|
|
12473
|
+
// src/features/check-markdown/model/markdown.ts
|
|
12474
|
+
const checkMarkdown = checkSection({
|
|
12475
|
+
name: "checkMarkdown",
|
|
12476
|
+
rule: "markdown",
|
|
12477
|
+
pick: y8Section,
|
|
12478
|
+
pathspecs: (config) => markdownPathspecs({ config }),
|
|
12479
|
+
lint,
|
|
12480
|
+
detail: diagnosticDetail
|
|
12502
12481
|
});
|
|
12503
12482
|
// src/features/check-scripts/model/shell-scripts.ts
|
|
12504
12483
|
const SHELL_FILE = /\.(?:sh|bash|zsh|ksh|fish|command)$/u;
|
|
@@ -12506,9 +12485,9 @@ const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|
|
|
|
12506
12485
|
const EXTENSION = /\.[^./]+$/u;
|
|
12507
12486
|
const SETTINGS_FILE = ".claude/settings.json";
|
|
12508
12487
|
const READ_CONCURRENCY$8 = 64;
|
|
12509
|
-
const FIRST$
|
|
12510
|
-
const RULE$
|
|
12511
|
-
const MESSAGE$
|
|
12488
|
+
const FIRST$5 = 1;
|
|
12489
|
+
const RULE$18 = "shell-script";
|
|
12490
|
+
const MESSAGE$8 = "is a shell script. Do the work in TypeScript as a Vite+ task in vite.config.ts, a test, or the tool's own hook, and delete this file. Only the SessionStart hook in .claude/settings.json, which installs the toolchain before TypeScript can run, stays a shell script.";
|
|
12512
12491
|
const HookSchema = Schema.Struct({
|
|
12513
12492
|
command: Schema.optional(Schema.String),
|
|
12514
12493
|
args: Schema.optional(Schema.Array(Schema.String))
|
|
@@ -12528,15 +12507,15 @@ const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.ge
|
|
|
12528
12507
|
const hasExtension = (name) => EXTENSION.test(baseName(name));
|
|
12529
12508
|
const problemFor$1 = (file) => ({
|
|
12530
12509
|
file,
|
|
12531
|
-
line: FIRST$
|
|
12532
|
-
column: FIRST$
|
|
12533
|
-
rule: RULE$
|
|
12534
|
-
message: MESSAGE$
|
|
12510
|
+
line: FIRST$5,
|
|
12511
|
+
column: FIRST$5,
|
|
12512
|
+
rule: RULE$18,
|
|
12513
|
+
message: MESSAGE$8
|
|
12535
12514
|
});
|
|
12536
12515
|
/** @internal */
|
|
12537
12516
|
const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
|
|
12538
12517
|
const files = yield* RepositoryFiles;
|
|
12539
|
-
const names = yield* files.
|
|
12518
|
+
const names = yield* files.ownedFiles(root);
|
|
12540
12519
|
const settings = yield* files.readFile(files.join(root, SETTINGS_FILE));
|
|
12541
12520
|
const commands = pipe(settings, Option.map(sessionStartCommands), Option.getOrElse(() => NO_TEXT));
|
|
12542
12521
|
const isSessionStartHook = (name) => pipe(commands, Array.some(String$1.includes(name)));
|
|
@@ -12583,9 +12562,9 @@ const runScriptsOf = (source) => {
|
|
|
12583
12562
|
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
12584
12563
|
const QUOTED$1 = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
12585
12564
|
const COMMENT = "#";
|
|
12586
|
-
const RULE$
|
|
12565
|
+
const RULE$17 = "workflow-script";
|
|
12587
12566
|
const ONE_COMMAND = 1;
|
|
12588
|
-
const MESSAGE$
|
|
12567
|
+
const MESSAGE$7 = "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.";
|
|
12589
12568
|
const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
|
|
12590
12569
|
const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED$1, "")(line));
|
|
12591
12570
|
const runsMoreThanOneCommand = ({ text }) => {
|
|
@@ -12597,8 +12576,8 @@ const problemsIn$7 = (file) => (source) => {
|
|
|
12597
12576
|
return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
|
|
12598
12577
|
file,
|
|
12599
12578
|
...at(start),
|
|
12600
|
-
rule: RULE$
|
|
12601
|
-
message: MESSAGE$
|
|
12579
|
+
rule: RULE$17,
|
|
12580
|
+
message: MESSAGE$7
|
|
12602
12581
|
})));
|
|
12603
12582
|
};
|
|
12604
12583
|
/** @internal */
|
|
@@ -12612,6 +12591,15 @@ const checkScripts = Effect.fn("checkScripts")(function* checkScripts(root) {
|
|
|
12612
12591
|
const found = yield* Effect.all([checkShellScripts(root), checkWorkflows(root)], { concurrency: "unbounded" });
|
|
12613
12592
|
return Array.flatten(found);
|
|
12614
12593
|
});
|
|
12594
|
+
// src/features/check-structure/model/structure.ts
|
|
12595
|
+
const checkStructure = checkSection({
|
|
12596
|
+
name: "checkStructure",
|
|
12597
|
+
rule: "structure",
|
|
12598
|
+
pick: wismSection,
|
|
12599
|
+
pathspecs: (config) => wismPathspecs({ config }),
|
|
12600
|
+
lint: lint$1,
|
|
12601
|
+
detail: () => ""
|
|
12602
|
+
});
|
|
12615
12603
|
// src/features/check-vite-plus/model/command-words.ts
|
|
12616
12604
|
const CONTINUATION = /\\\n/gu;
|
|
12617
12605
|
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
@@ -12702,7 +12690,7 @@ const ROOT_DIRECTORY = ".";
|
|
|
12702
12690
|
const COMMAND_KEY = "command";
|
|
12703
12691
|
const ARGUMENTS_KEY = "args";
|
|
12704
12692
|
const EXCLUDED$2 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
12705
|
-
const MANIFESTS = [`:(glob)**/${MANIFEST_FILE$
|
|
12693
|
+
const MANIFESTS = [`:(glob)**/${MANIFEST_FILE$3}`, ...EXCLUDED$2];
|
|
12706
12694
|
const STEP_FILES = [
|
|
12707
12695
|
":(glob).github/workflows/*.yml",
|
|
12708
12696
|
":(glob).github/workflows/*.yaml",
|
|
@@ -12719,7 +12707,7 @@ const AGENT_DOCS = [
|
|
|
12719
12707
|
];
|
|
12720
12708
|
const READ_CONCURRENCY$6 = 16;
|
|
12721
12709
|
const START$9 = 0;
|
|
12722
|
-
const FIRST$
|
|
12710
|
+
const FIRST$4 = 1;
|
|
12723
12711
|
const LINE = "\n";
|
|
12724
12712
|
const CommandText = Schema.Union([Schema.String, Schema.Array(Schema.String)]);
|
|
12725
12713
|
const decodeCommandText = Schema.decodeUnknownOption(CommandText);
|
|
@@ -12750,8 +12738,8 @@ const hookSources = (file, name) => (source) => pipe(String$1.split(source, LINE
|
|
|
12750
12738
|
kind: "hook",
|
|
12751
12739
|
file,
|
|
12752
12740
|
position: {
|
|
12753
|
-
line: index + FIRST$
|
|
12754
|
-
column: FIRST$
|
|
12741
|
+
line: index + FIRST$4,
|
|
12742
|
+
column: FIRST$4
|
|
12755
12743
|
},
|
|
12756
12744
|
name,
|
|
12757
12745
|
text
|
|
@@ -12824,7 +12812,7 @@ const commandSources = Effect.fn("commandSources")(function* commandSources(root
|
|
|
12824
12812
|
return Array.flatten(found);
|
|
12825
12813
|
});
|
|
12826
12814
|
// src/features/check-vite-plus/model/package-scripts.ts
|
|
12827
|
-
const RULE$
|
|
12815
|
+
const RULE$16 = "package-script";
|
|
12828
12816
|
const LIFECYCLE = [
|
|
12829
12817
|
"preinstall",
|
|
12830
12818
|
"install",
|
|
@@ -12847,26 +12835,26 @@ const LIFECYCLE = [
|
|
|
12847
12835
|
const problemOf$3 = ({ file, position, name }) => ({
|
|
12848
12836
|
file,
|
|
12849
12837
|
...position,
|
|
12850
|
-
rule: RULE$
|
|
12838
|
+
rule: RULE$16,
|
|
12851
12839
|
message: `The script ${name} is not a lifecycle script. package.json scripts hold only the scripts the package manager runs by itself, such as prepare and prepack. Write ${name} as a task in run.tasks of this package's vite.config.ts, where its shape is type-checked.`
|
|
12852
12840
|
});
|
|
12853
12841
|
const packageScriptProblems = (sources) => pipe(sources, Array.filter(({ kind, name }) => kind === "script" && !Array.contains(LIFECYCLE, name)), Array.map(problemOf$3));
|
|
12854
12842
|
// src/features/check-vite-plus/model/vite-plus-block.ts
|
|
12855
|
-
const RULE$
|
|
12843
|
+
const RULE$15 = "vite-plus-block";
|
|
12856
12844
|
const MARKER = Array.join([
|
|
12857
12845
|
"<!--",
|
|
12858
12846
|
"VITE PLUS START",
|
|
12859
12847
|
"-->"
|
|
12860
12848
|
], "");
|
|
12861
|
-
const MESSAGE$
|
|
12849
|
+
const MESSAGE$6 = "holds the Vite+ block that `vp create --agent` and `vp migrate --agent` write, and every `vp config` rewrites it. Delete the block with its markers. The vite-plus skill reads the same guidance from node_modules/vite-plus/AGENTS.md.";
|
|
12862
12850
|
const problemIn = (file) => (source) => {
|
|
12863
12851
|
const index = String$1.indexOf(MARKER)(source);
|
|
12864
12852
|
if (Option.isNone(index)) return Option.none();
|
|
12865
12853
|
return Option.some({
|
|
12866
12854
|
file,
|
|
12867
12855
|
...positionOf(source)(index.value),
|
|
12868
|
-
rule: RULE$
|
|
12869
|
-
message: MESSAGE$
|
|
12856
|
+
rule: RULE$15,
|
|
12857
|
+
message: MESSAGE$6
|
|
12870
12858
|
});
|
|
12871
12859
|
};
|
|
12872
12860
|
/** @internal */
|
|
@@ -12907,40 +12895,73 @@ const workflowCheck = ({ rule, message, offsetsOf }) => Effect.fn(rule)(function
|
|
|
12907
12895
|
}));
|
|
12908
12896
|
}));
|
|
12909
12897
|
});
|
|
12898
|
+
const scalarKeyOffsets = ({ name, matches }) => (source) => pipe(pairsNamed(name)(source), Array.filter(({ value }) => isScalar(value) && matches(String(value.value))), Array.flatMap(({ key }) => pipe(Option.liftPredicate(key, isScalar), Option.flatMap((scalar) => Option.fromNullishOr(scalar.range)), Option.map(([start]) => start), Option.toArray)));
|
|
12910
12899
|
// src/features/check-workflows/model/full-history-checkout.ts
|
|
12911
12900
|
const DEPTH_KEY = "fetch-depth";
|
|
12912
12901
|
const WHOLE_HISTORY = "0";
|
|
12913
|
-
const RULE$13 = "full-history-checkout";
|
|
12914
|
-
const MESSAGE$4 = "fetches the whole history with `fetch-depth: 0`. Fetch only the commits the job reads.";
|
|
12915
|
-
const fullHistoryOffsetsOf = (source) => pipe(pairsNamed(DEPTH_KEY)(source), Array.filter(({ value }) => isScalar(value) && String(value.value) === WHOLE_HISTORY), Array.flatMap(({ key }) => pipe(Option.liftPredicate(key, isScalar), Option.flatMap((scalar) => Option.fromNullishOr(scalar.range)), Option.map(([start]) => start), Option.toArray)));
|
|
12916
12902
|
/** @internal */
|
|
12917
12903
|
const checkFullHistoryCheckout = workflowCheck({
|
|
12904
|
+
rule: "full-history-checkout",
|
|
12905
|
+
message: "fetches the whole history with `fetch-depth: 0`. Fetch only the commits the job reads.",
|
|
12906
|
+
offsetsOf: scalarKeyOffsets({
|
|
12907
|
+
name: DEPTH_KEY,
|
|
12908
|
+
matches: (value) => value === WHOLE_HISTORY
|
|
12909
|
+
})
|
|
12910
|
+
});
|
|
12911
|
+
// src/features/check-workflows/model/publish-trigger.ts
|
|
12912
|
+
const RULE$13 = "publish-trigger";
|
|
12913
|
+
const PUBLISH = /\bmsch-publish\b/u;
|
|
12914
|
+
const MANUAL = "workflow_dispatch";
|
|
12915
|
+
const TRIGGER_KEY = "on";
|
|
12916
|
+
const MESSAGE$4 = "publishes with `msch-publish` from a trigger other than `workflow_dispatch`. Publishing is manual: bump the version in a PR, then dispatch the workflow for the workspace.";
|
|
12917
|
+
const triggersOf = (node) => {
|
|
12918
|
+
if (isScalar(node)) return [String(node.value)];
|
|
12919
|
+
if (isSeq(node)) return pipe(node.items, Array.filter(isScalar), Array.map((item) => String(item.value)));
|
|
12920
|
+
if (isMap(node)) return pipe(node.items, Array.flatMap(({ key }) => pipe(Option.liftPredicate(key, isScalar), Option.map((scalar) => String(scalar.value)), Option.toArray)));
|
|
12921
|
+
return [];
|
|
12922
|
+
};
|
|
12923
|
+
const publishTriggerOffsetsOf = (source) => {
|
|
12924
|
+
if (!pipe(runScriptsOf(source), Array.some(({ text }) => PUBLISH.test(text)))) return [];
|
|
12925
|
+
const { contents } = parseDocument(source);
|
|
12926
|
+
const triggers = pipe(pairIn(TRIGGER_KEY)(contents), Option.map(({ value }) => triggersOf(value)), Option.getOrElse(() => []));
|
|
12927
|
+
if (pipe(triggers, Array.every((trigger) => trigger === MANUAL))) return [];
|
|
12928
|
+
return Option.toArray(keyOffsetIn(TRIGGER_KEY)(contents));
|
|
12929
|
+
};
|
|
12930
|
+
/** @internal */
|
|
12931
|
+
const checkPublishTrigger = workflowCheck({
|
|
12918
12932
|
rule: RULE$13,
|
|
12919
12933
|
message: MESSAGE$4,
|
|
12920
|
-
offsetsOf:
|
|
12934
|
+
offsetsOf: publishTriggerOffsetsOf
|
|
12921
12935
|
});
|
|
12922
|
-
// src/features/check-workflows/model/release-
|
|
12923
|
-
const RULE$12 = "release-
|
|
12936
|
+
// src/features/check-workflows/model/release-please.ts
|
|
12937
|
+
const RULE$12 = "release-please";
|
|
12924
12938
|
const RELEASE_PLEASE = /^googleapis\/release-please-action(?:@|$)/u;
|
|
12925
|
-
const
|
|
12926
|
-
const
|
|
12927
|
-
const
|
|
12928
|
-
const
|
|
12929
|
-
const inputs = Option.getOrUndefined(Option.map(pairIn("with")(node), ({ value }) => value));
|
|
12930
|
-
return {
|
|
12931
|
-
opensReleasePr: RELEASE_PLEASE.test(textOf(node, "uses")) && textOf(inputs, "skip-github-pull-request") !== "true",
|
|
12932
|
-
turnsOnAutoMerge: AUTO_MERGE.test(textOf(node, "run")),
|
|
12933
|
-
offset: keyOffsetIn("uses")(node)
|
|
12934
|
-
};
|
|
12935
|
-
};
|
|
12936
|
-
const stepsOf = (node) => pipe(Option.liftPredicate(node, isSeq), Option.map((seq) => pipe(seq.items, Array.map(stepOf))), Option.getOrElse(() => []));
|
|
12937
|
-
const unqueuedOffsetsOf = (steps) => pipe(steps, Array.flatMap((step, index) => pipe(step.offset, Option.filter(() => step.opensReleasePr && !Array.some(Array.drop(steps, index), (later) => later.turnsOnAutoMerge)), Option.toArray)));
|
|
12938
|
-
const releasePrOffsetsOf = (source) => pipe(pairsNamed("steps")(source), Array.flatMap(({ value }) => unqueuedOffsetsOf(stepsOf(value))));
|
|
12939
|
-
/** @internal */
|
|
12940
|
-
const checkReleasePrAutoMerge = workflowCheck({
|
|
12939
|
+
const RELEASE_PLEASE_FILE = /(?:^|\/)(?:release-please-config|\.release-please-manifest)\.json$/u;
|
|
12940
|
+
const FIRST$3 = 1;
|
|
12941
|
+
const MESSAGE$3 = "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.";
|
|
12942
|
+
const checkReleasePleaseSteps = workflowCheck({
|
|
12941
12943
|
rule: RULE$12,
|
|
12942
12944
|
message: MESSAGE$3,
|
|
12943
|
-
offsetsOf:
|
|
12945
|
+
offsetsOf: scalarKeyOffsets({
|
|
12946
|
+
name: "uses",
|
|
12947
|
+
matches: (value) => RELEASE_PLEASE.test(value)
|
|
12948
|
+
})
|
|
12949
|
+
});
|
|
12950
|
+
const checkReleasePleaseFiles = Effect.fn("checkReleasePleaseFiles")(function* checkReleasePleaseFiles(root) {
|
|
12951
|
+
const files = yield* RepositoryFiles;
|
|
12952
|
+
const names = yield* files.listedFiles(root);
|
|
12953
|
+
return pipe(names, Array.filter((name) => RELEASE_PLEASE_FILE.test(name)), Array.map((name) => ({
|
|
12954
|
+
file: files.join(root, name),
|
|
12955
|
+
line: FIRST$3,
|
|
12956
|
+
column: FIRST$3,
|
|
12957
|
+
rule: RULE$12,
|
|
12958
|
+
message: MESSAGE$3
|
|
12959
|
+
})));
|
|
12960
|
+
});
|
|
12961
|
+
/** @internal */
|
|
12962
|
+
const checkReleasePlease = Effect.fn("checkReleasePlease")(function* checkReleasePlease(root) {
|
|
12963
|
+
const found = yield* Effect.all([checkReleasePleaseSteps(root), checkReleasePleaseFiles(root)], { concurrency: "unbounded" });
|
|
12964
|
+
return Array.flatten(found);
|
|
12944
12965
|
});
|
|
12945
12966
|
// src/features/check-workflows/model/workflow-queue.ts
|
|
12946
12967
|
const CONCURRENCY_KEY = "concurrency";
|
|
@@ -12967,6 +12988,15 @@ const checkWorkflowCommits = workflowCheck({
|
|
|
12967
12988
|
message: MESSAGE$1,
|
|
12968
12989
|
offsetsOf: commitOffsetsOf
|
|
12969
12990
|
});
|
|
12991
|
+
// src/features/check-workflows/model/workflow-lint.ts
|
|
12992
|
+
const checkWorkflowLint = checkSection({
|
|
12993
|
+
name: "checkWorkflowLint",
|
|
12994
|
+
rule: "workflow-lint",
|
|
12995
|
+
pick: fu4Section,
|
|
12996
|
+
pathspecs: (config) => workflowPathspecs({ config }),
|
|
12997
|
+
lint: lint$2,
|
|
12998
|
+
detail: () => ""
|
|
12999
|
+
});
|
|
12970
13000
|
// src/app/tool-use.ts
|
|
12971
13001
|
/** @internal */
|
|
12972
13002
|
const checkToolUse = Effect.fn("checkToolUse")(function* checkToolUse(root) {
|
|
@@ -12977,15 +13007,18 @@ const checkToolUse = Effect.fn("checkToolUse")(function* checkToolUse(root) {
|
|
|
12977
13007
|
checkWorkflowQueues(root),
|
|
12978
13008
|
checkWorkflowCommits(root),
|
|
12979
13009
|
checkFullHistoryCheckout(root),
|
|
12980
|
-
|
|
13010
|
+
checkReleasePlease(root),
|
|
13011
|
+
checkPublishTrigger(root),
|
|
12981
13012
|
checkRestrictedRules(root),
|
|
12982
|
-
checkMarkdown(root)
|
|
13013
|
+
checkMarkdown(root),
|
|
13014
|
+
checkStructure(root),
|
|
13015
|
+
checkWorkflowLint(root)
|
|
12983
13016
|
], { concurrency: "unbounded" });
|
|
12984
13017
|
return Array.flatten(found);
|
|
12985
13018
|
});
|
|
12986
13019
|
// src/features/ban-comments/model/found-comment.ts
|
|
12987
|
-
const taggedError$
|
|
12988
|
-
var CommentsUnreadable = class extends taggedError$
|
|
13020
|
+
const taggedError$2 = Schema.TaggedError;
|
|
13021
|
+
var CommentsUnreadable = class extends taggedError$2()("CommentsUnreadable", {
|
|
12989
13022
|
reader: Schema.String,
|
|
12990
13023
|
message: Schema.String
|
|
12991
13024
|
}) {};
|
|
@@ -13214,8 +13247,8 @@ const NO_SETTINGS = {
|
|
|
13214
13247
|
ignorePatterns: []
|
|
13215
13248
|
};
|
|
13216
13249
|
const NONE = [];
|
|
13217
|
-
const taggedError$
|
|
13218
|
-
var CommentConfigUnreadable = class extends taggedError$
|
|
13250
|
+
const taggedError$1 = Schema.TaggedError;
|
|
13251
|
+
var CommentConfigUnreadable = class extends taggedError$1()("CommentConfigUnreadable", { file: Schema.String }) {};
|
|
13219
13252
|
const shebangReader = (source) => {
|
|
13220
13253
|
if (!String$1.startsWith(SHEBANG)(source)) return Option.none();
|
|
13221
13254
|
return pipe(SHEBANG_READERS, Array.findFirst(([pattern]) => pattern.test(source)));
|
|
@@ -13476,8 +13509,8 @@ const Source = Schema.Struct({
|
|
|
13476
13509
|
});
|
|
13477
13510
|
const SkillsConfig = Schema.Struct({ skills: Schema.Record(Schema.String, Source) });
|
|
13478
13511
|
const decodeSkills = Schema.decodeUnknownOption(SkillsConfig);
|
|
13479
|
-
const taggedError
|
|
13480
|
-
var SkillsConfigUnreadable = class extends taggedError
|
|
13512
|
+
const taggedError = Schema.TaggedError;
|
|
13513
|
+
var SkillsConfigUnreadable = class extends taggedError()("SkillsConfigUnreadable", { file: Schema.String }) {};
|
|
13481
13514
|
const problemAt$3 = (rule, file, text) => (anchor, message) => ({
|
|
13482
13515
|
file,
|
|
13483
13516
|
...positionOf(text)(pipe(String$1.indexOf(anchor)(text), Option.getOrElse(() => START$6))),
|
|
@@ -13931,7 +13964,7 @@ const binsIn = (name, text) => pipe(decodeBinField(text), Option.flatMap(({ bin
|
|
|
13931
13964
|
return Record.keys(bin);
|
|
13932
13965
|
}
|
|
13933
13966
|
}));
|
|
13934
|
-
const manifestOf = Option.liftThrowable((name) => fileURLToPath(import.meta.resolve(`${name}/${MANIFEST_FILE$
|
|
13967
|
+
const manifestOf = Option.liftThrowable((name) => fileURLToPath(import.meta.resolve(`${name}/${MANIFEST_FILE$3}`)));
|
|
13935
13968
|
const installedPackage = Effect.fn("installedPackage")(function* installedPackage(name) {
|
|
13936
13969
|
const files = yield* RepositoryFiles;
|
|
13937
13970
|
const text = yield* pipe(manifestOf(name), Option.match({
|
|
@@ -13972,7 +14005,7 @@ const consumersIn = Effect.fn("consumersIn")(function* consumersIn(root, directo
|
|
|
13972
14005
|
});
|
|
13973
14006
|
const manifestUses = Effect.fn("manifestUses")(function* manifestUses(root, appliedNames, directory) {
|
|
13974
14007
|
const files = yield* RepositoryFiles;
|
|
13975
|
-
const file = files.join(root, directory, MANIFEST_FILE$
|
|
14008
|
+
const file = files.join(root, directory, MANIFEST_FILE$3);
|
|
13976
14009
|
const text = yield* files.readFile(file);
|
|
13977
14010
|
const manifest = yield* readManifest(files.join(root, directory));
|
|
13978
14011
|
return pipe(Option.all({
|
|
@@ -14248,7 +14281,7 @@ const problemsIn$1 = (entry, source) => pipe(decodeManifest$1(source), Option.fi
|
|
|
14248
14281
|
/** @internal */
|
|
14249
14282
|
const checkPackageScope = Effect.fn("checkPackageScope")(function* checkPackageScope(root) {
|
|
14250
14283
|
const files = yield* RepositoryFiles;
|
|
14251
|
-
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE$
|
|
14284
|
+
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE$3}`, ...EXCLUDED$1]);
|
|
14252
14285
|
return yield* scanText(pipe(manifests, Array.map((name) => ({
|
|
14253
14286
|
name,
|
|
14254
14287
|
file: files.join(root, name)
|
|
@@ -14334,7 +14367,7 @@ const isVersionSource = (entry) => VERSION_FILE.test(entry.name) || DOCKERFILE.t
|
|
|
14334
14367
|
const checkNodeVersion = Effect.fn("checkNodeVersion")(function* checkNodeVersion(root) {
|
|
14335
14368
|
const files = yield* RepositoryFiles;
|
|
14336
14369
|
const listed = yield* listedFiles(root);
|
|
14337
|
-
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE$
|
|
14370
|
+
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE$3}`, ...EXCLUDED]);
|
|
14338
14371
|
const sources = [...pipe(listed, Array.filter(isVersionSource)), ...pipe(manifests, Array.map((name) => ({
|
|
14339
14372
|
name,
|
|
14340
14373
|
file: files.join(root, name)
|
|
@@ -14386,27 +14419,6 @@ const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
|
14386
14419
|
], { concurrency: "unbounded" });
|
|
14387
14420
|
return Array.flatten(found);
|
|
14388
14421
|
});
|
|
14389
|
-
// src/app/output.ts
|
|
14390
|
-
const taggedError = Schema.TaggedError;
|
|
14391
|
-
var ProblemsFound = class extends taggedError()("ProblemsFound", { count: Schema.Finite }) {};
|
|
14392
|
-
/** @internal */
|
|
14393
|
-
const writeStdout = Effect.fn("writeStdout")(function* writeStdout(text) {
|
|
14394
|
-
const stdio = yield* Stdio.Stdio;
|
|
14395
|
-
yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);
|
|
14396
|
-
});
|
|
14397
|
-
// src/app/runtime.ts
|
|
14398
|
-
const reportFailure = (cause) => Effect.gen(function* report() {
|
|
14399
|
-
const stdio = yield* Stdio.Stdio;
|
|
14400
|
-
if (Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)))) return;
|
|
14401
|
-
yield* Stream.make(`${Cause.pretty(cause)}\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);
|
|
14402
|
-
});
|
|
14403
|
-
const tracing = Otlp.layerFromConfig({ resource: { serviceName: "msch" } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));
|
|
14404
|
-
/** @internal */
|
|
14405
|
-
const runCli = (program) => {
|
|
14406
|
-
const services = Layer.mergeAll(nodeRepositoryFiles, tracing).pipe(Layer.provideMerge(nodeServicesLayer));
|
|
14407
|
-
const main = Layer.build(services).pipe(Effect.flatMap((context) => Effect.provideContext(program.pipe(Effect.tapCause(reportFailure)), context)), Effect.scoped);
|
|
14408
|
-
runMain(main, { disableErrorReporting: true });
|
|
14409
|
-
};
|
|
14410
14422
|
// bin/msch.ts
|
|
14411
14423
|
const NO_PROBLEMS = 0;
|
|
14412
14424
|
const ONE_FAILURE = 1;
|
|
@@ -14441,7 +14453,7 @@ const checkEverything = Effect.fn("checkEverything")(function* checkEverything(r
|
|
|
14441
14453
|
const toolFailures = yield* toolChecks(root, []);
|
|
14442
14454
|
return yield* failWhenAny(problems.length + toolFailures);
|
|
14443
14455
|
});
|
|
14444
|
-
|
|
14456
|
+
const msch = Effect.gen(function* msch() {
|
|
14445
14457
|
const stdio = yield* Stdio.Stdio;
|
|
14446
14458
|
const files = yield* RepositoryFiles;
|
|
14447
14459
|
const args = yield* stdio.args;
|
|
@@ -14449,7 +14461,8 @@ runCli(Effect.gen(function* msch() {
|
|
|
14449
14461
|
if (args.includes("--json")) return yield* writeJson(root);
|
|
14450
14462
|
if (Array.isReadonlyArrayNonEmpty(args)) return yield* toolChecks(root, args).pipe(Effect.flatMap(failWhenAny));
|
|
14451
14463
|
return yield* checkEverything(root);
|
|
14452
|
-
})
|
|
14464
|
+
});
|
|
14465
|
+
runCli(msch);
|
|
14453
14466
|
export {};
|
|
14454
14467
|
|
|
14455
14468
|
//# sourceMappingURL=cli.mjs.map
|