@r_masseater/msch 0.27.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-contract-WGNqIbe-.mjs → cli-contract-kyLbx4PX.mjs} +4 -63
- package/dist/cli-contract-kyLbx4PX.mjs.map +1 -0
- package/dist/cli.mjs +469 -175
- package/dist/cli.mjs.map +1 -1
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{index-4R3V2V1f.d.mts → index-B3B75yJ6.d.mts} +2 -1
- package/dist/{lint-preset-Bh97-3cg.mjs → lint-preset-D8OFdSZ-.mjs} +2 -2
- package/dist/{lint-preset-Bh97-3cg.mjs.map → lint-preset-D8OFdSZ-.mjs.map} +1 -1
- package/dist/lint.d.mts +1 -1
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{workspace-g6vKzUNI.mjs → workspace-DuBjvDMC.mjs} +32 -6
- package/dist/workspace-DuBjvDMC.mjs.map +1 -0
- package/dist/workspace-settings.d.mts +7 -1
- package/dist/workspace-settings.mjs +53 -6
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +1 -1
- package/skills/msch-checks/SKILL.md +1 -1
- package/dist/cli-contract-WGNqIbe-.mjs.map +0 -1
- package/dist/workspace-g6vKzUNI.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as
|
|
3
|
-
import { $ as
|
|
2
|
+
import { A as EntryManifestJson, C as literalOf, E as stringsIn, F as workspaceDependencies, M as MANIFEST_FILE, N as dependencyEntries, P as readManifest, S as keyName, T as propertyValue, b as KeySchema, d as definesTask, f as hasVerifyTask, j as publicEntriesOf, k as publishedWorkspaces, l as RUN_TASKS, n as namedWorkspaces, o as workspaceDirectories, r as patternOf, s as runTasksOf, t as deployEntries, u as VERIFY_TASK, w as nestedValues, x as childrenOf$2, y as workspaceConfigOf } from "./workspace-DuBjvDMC.mjs";
|
|
3
|
+
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, a as problemAt$6, 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-kyLbx4PX.mjs";
|
|
4
4
|
import { a as groupOf$1, i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-B11FFAIk.mjs";
|
|
5
5
|
import { t as COMMENT_DIRECTIVES } from "./comment-directives-WcDqvLwJ.mjs";
|
|
6
6
|
import { VpToolsError, runVpa } from "@r_masseater/vite-plus-adopt";
|
|
@@ -317,7 +317,7 @@ const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function*
|
|
|
317
317
|
return pipe(texts, Array.some((text) => Option.exists(text, includesNeedle)));
|
|
318
318
|
});
|
|
319
319
|
// src/entities/project/model/inputs.ts
|
|
320
|
-
const SEPARATOR$
|
|
320
|
+
const SEPARATOR$18 = "/";
|
|
321
321
|
const SCOPE_PREFIX$1 = "@";
|
|
322
322
|
const HIDDEN_PREFIX = ".";
|
|
323
323
|
const encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
@@ -359,14 +359,14 @@ const closureOf$1 = Effect.fn("closureOf")(function* closureOf(root, configPath)
|
|
|
359
359
|
const directories = yield* workspaceClosure(directory);
|
|
360
360
|
return {
|
|
361
361
|
directories,
|
|
362
|
-
prefixes: pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$
|
|
362
|
+
prefixes: pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$18}`))
|
|
363
363
|
};
|
|
364
364
|
});
|
|
365
365
|
const scopedNames = (modules) => (name) => Effect.gen(function* listScope() {
|
|
366
366
|
const files = yield* RepositoryFiles;
|
|
367
367
|
if (!String$1.startsWith(SCOPE_PREFIX$1)(name)) return [name];
|
|
368
368
|
const scoped = yield* files.readDirectory(files.join(modules, name));
|
|
369
|
-
return pipe(scoped, Array.map((entry) => `${name}${SEPARATOR$
|
|
369
|
+
return pipe(scoped, Array.map((entry) => `${name}${SEPARATOR$18}${entry}`));
|
|
370
370
|
});
|
|
371
371
|
const installedNames$1 = Effect.fn("installedNames")(function* installedNames(modules) {
|
|
372
372
|
const listed = yield* (yield* RepositoryFiles).readDirectory(modules);
|
|
@@ -416,7 +416,7 @@ const RELATIVE$1 = /^\.\.?(?:\/|$)/u;
|
|
|
416
416
|
const SUBPATH_IMPORT = "#";
|
|
417
417
|
const WILDCARD$2 = "*";
|
|
418
418
|
const SCOPE$1 = "@";
|
|
419
|
-
const SEPARATOR$
|
|
419
|
+
const SEPARATOR$17 = "/";
|
|
420
420
|
const SOURCE_SUFFIXES = [
|
|
421
421
|
"",
|
|
422
422
|
".ts",
|
|
@@ -428,9 +428,9 @@ const PLAIN_SEGMENTS = 1;
|
|
|
428
428
|
const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Schema.String, Schema.String)) });
|
|
429
429
|
const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
|
|
430
430
|
const packageNameOf = (specifier) => {
|
|
431
|
-
const segments = String$1.split(specifier, SEPARATOR$
|
|
432
|
-
if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$
|
|
433
|
-
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$
|
|
431
|
+
const segments = String$1.split(specifier, SEPARATOR$17);
|
|
432
|
+
if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$17));
|
|
433
|
+
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$17));
|
|
434
434
|
};
|
|
435
435
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
436
436
|
const runtimeSpecifierOf = (statement) => {
|
|
@@ -525,7 +525,7 @@ const InstalledManifest = Schema.Struct({
|
|
|
525
525
|
peerDependencies: DependencyMap,
|
|
526
526
|
peerDependenciesMeta: PeerMeta
|
|
527
527
|
});
|
|
528
|
-
const decodeManifest$
|
|
528
|
+
const decodeManifest$5 = Schema.decodeOption(Schema.fromJsonString(InstalledManifest));
|
|
529
529
|
const keysOf$2 = (map) => pipe(Option.fromUndefinedOr(map), Option.map(Record.keys), Option.getOrElse(() => []));
|
|
530
530
|
const isOptionalPeer = (manifest, name) => pipe(Option.fromUndefinedOr(manifest.peerDependenciesMeta), Option.flatMap(Record.get(name)), Option.exists((meta) => meta.optional === true));
|
|
531
531
|
const installedNames = (manifest) => [
|
|
@@ -536,7 +536,7 @@ const installedNames = (manifest) => [
|
|
|
536
536
|
const childrenOf$1 = Effect.fn("childrenOf")(function* childrenOf(directory) {
|
|
537
537
|
const files = yield* RepositoryFiles;
|
|
538
538
|
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
539
|
-
return pipe(text, Option.flatMap(decodeManifest$
|
|
539
|
+
return pipe(text, Option.flatMap(decodeManifest$5), Option.map(installedNames), Option.getOrElse(() => []), Array.map((child) => [directory, child]));
|
|
540
540
|
});
|
|
541
541
|
const resolveFrom = (from, name) => Effect.gen(function* resolvePackage() {
|
|
542
542
|
const files = yield* RepositoryFiles;
|
|
@@ -1008,7 +1008,7 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
|
|
|
1008
1008
|
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;
|
|
1009
1009
|
const LOCKFILE = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
|
|
1010
1010
|
const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
|
|
1011
|
-
const READ_CONCURRENCY$
|
|
1011
|
+
const READ_CONCURRENCY$20 = 64;
|
|
1012
1012
|
const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE.test(name);
|
|
1013
1013
|
const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
|
|
1014
1014
|
/** @internal */
|
|
@@ -1031,45 +1031,45 @@ const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
|
|
|
1031
1031
|
const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
|
|
1032
1032
|
onNone: () => [],
|
|
1033
1033
|
onSome: (source) => problemsIn(entry, source)
|
|
1034
|
-
}))), { concurrency: READ_CONCURRENCY$
|
|
1034
|
+
}))), { concurrency: READ_CONCURRENCY$20 });
|
|
1035
1035
|
return Array.flatten(found);
|
|
1036
1036
|
});
|
|
1037
1037
|
// src/features/overrides/model/git-subpath.ts
|
|
1038
1038
|
const DEPENDENCY_FILE = /(?:^|\/)(?:package\.json|pnpm-workspace\.ya?ml)$/u;
|
|
1039
1039
|
const GIT_SUBPATH = /(?<![^\s"':])[^\s"'#]+#(?:[^\s"'&]*&)*path:[^\s"']*/gu;
|
|
1040
|
-
const RULE$
|
|
1040
|
+
const RULE$30 = "git-subpath-dependency";
|
|
1041
1041
|
const WHOLE_MATCH$3 = 0;
|
|
1042
1042
|
const problemAt$5 = ({ file }, source) => (found) => ({
|
|
1043
1043
|
file,
|
|
1044
1044
|
...positionOf(source)(found.index ?? WHOLE_MATCH$3),
|
|
1045
|
-
rule: RULE$
|
|
1045
|
+
rule: RULE$30,
|
|
1046
1046
|
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])}\`.`
|
|
1047
1047
|
});
|
|
1048
|
-
const problemsIn$
|
|
1048
|
+
const problemsIn$13 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(GIT_SUBPATH)(source)), Array.map(problemAt$5(entry, source)));
|
|
1049
1049
|
const isDependencyFile = ({ name }) => DEPENDENCY_FILE.test(name);
|
|
1050
1050
|
/** @internal */
|
|
1051
1051
|
const checkGitSubpath = Effect.fn("checkGitSubpath")(function* checkGitSubpath(root) {
|
|
1052
1052
|
const listed = yield* listedFiles(root);
|
|
1053
|
-
return yield* scanText(pipe(listed, Array.filter(isDependencyFile)), problemsIn$
|
|
1053
|
+
return yield* scanText(pipe(listed, Array.filter(isDependencyFile)), problemsIn$13);
|
|
1054
1054
|
});
|
|
1055
1055
|
// src/features/overrides/model/restricted-rules.ts
|
|
1056
|
-
const RULE$
|
|
1056
|
+
const RULE$29 = "unnamed-restriction";
|
|
1057
1057
|
const WHOLE_MATCH$2 = 0;
|
|
1058
1058
|
const UNNAMED = new RegExp(`(?:[\\w@-]+/)?no-restricted-(?:imports|properties)\\b`, "gu");
|
|
1059
|
-
const problemsIn$
|
|
1059
|
+
const problemsIn$12 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(UNNAMED)(source)), Array.map((found) => ({
|
|
1060
1060
|
file: entry.file,
|
|
1061
1061
|
...positionOf(source)(found.index ?? WHOLE_MATCH$2),
|
|
1062
|
-
rule: RULE$
|
|
1062
|
+
rule: RULE$29,
|
|
1063
1063
|
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.`
|
|
1064
1064
|
})));
|
|
1065
1065
|
/** @internal */
|
|
1066
1066
|
const checkRestrictedRules = Effect.fn("checkRestrictedRules")(function* checkRestrictedRules(root) {
|
|
1067
1067
|
const listed = yield* listedFiles(root);
|
|
1068
|
-
return yield* scanText(pipe(listed, Array.filter(isScannedText)), problemsIn$
|
|
1068
|
+
return yield* scanText(pipe(listed, Array.filter(isScannedText)), problemsIn$12);
|
|
1069
1069
|
});
|
|
1070
1070
|
// src/shared/lib/agent-docs.ts
|
|
1071
1071
|
const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
|
|
1072
|
-
const READ_CONCURRENCY$
|
|
1072
|
+
const READ_CONCURRENCY$19 = 16;
|
|
1073
1073
|
const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblems(root, problemIn) {
|
|
1074
1074
|
const files = yield* RepositoryFiles;
|
|
1075
1075
|
const listed = yield* files.listedFiles(root);
|
|
@@ -1078,13 +1078,13 @@ const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblem
|
|
|
1078
1078
|
const file = files.join(root, name);
|
|
1079
1079
|
const problemOf = Option.flatMap(problemIn(file));
|
|
1080
1080
|
return files.readFile(file).pipe(Effect.map(problemOf));
|
|
1081
|
-
}, { concurrency: READ_CONCURRENCY$
|
|
1081
|
+
}, { concurrency: READ_CONCURRENCY$19 });
|
|
1082
1082
|
return Array.getSomes(found);
|
|
1083
1083
|
});
|
|
1084
1084
|
// src/features/placement/model/agent-docs-length.ts
|
|
1085
1085
|
const RECOMMENDED_LINES = 200;
|
|
1086
1086
|
const FIRST$15 = 1;
|
|
1087
|
-
const RULE$
|
|
1087
|
+
const RULE$28 = "agent-docs-length";
|
|
1088
1088
|
const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
|
|
1089
1089
|
const problemFor$5 = (file) => (lines) => {
|
|
1090
1090
|
if (lines <= RECOMMENDED_LINES) return Option.none();
|
|
@@ -1092,21 +1092,21 @@ const problemFor$5 = (file) => (lines) => {
|
|
|
1092
1092
|
file,
|
|
1093
1093
|
line: 201,
|
|
1094
1094
|
column: FIRST$15,
|
|
1095
|
-
rule: RULE$
|
|
1095
|
+
rule: RULE$28,
|
|
1096
1096
|
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.`
|
|
1097
1097
|
});
|
|
1098
1098
|
};
|
|
1099
1099
|
/** @internal */
|
|
1100
1100
|
const checkAgentDocsLength = (root) => agentDocProblems(root, (file) => (source) => problemFor$5(file)(lineCount(source)));
|
|
1101
1101
|
// src/features/placement/model/colocated-tests.ts
|
|
1102
|
-
const RULE$
|
|
1102
|
+
const RULE$27 = "colocated-test";
|
|
1103
1103
|
const FIRST$14 = 1;
|
|
1104
|
-
const READ_CONCURRENCY$
|
|
1104
|
+
const READ_CONCURRENCY$18 = 64;
|
|
1105
1105
|
const ROOT_SUBPATH = ".";
|
|
1106
1106
|
const NAME_GROUP = "name";
|
|
1107
1107
|
const SPECIFIER_GROUP = "specifier";
|
|
1108
1108
|
const SCRIPT$2 = /\.[cm]?[jt]sx?$/u;
|
|
1109
|
-
const TEST_FILE = /\.test\.[cm]?[jt]sx?$/u;
|
|
1109
|
+
const TEST_FILE$1 = /\.test\.[cm]?[jt]sx?$/u;
|
|
1110
1110
|
const MANIFEST_NAME = /package\.json$/u;
|
|
1111
1111
|
const SEPARATE_TEST_DIRECTORY = /(?:^|\/)(?:__tests__|__mocks__|tests?)\//u;
|
|
1112
1112
|
const SPEC_DIRECTORY = /(?:^|\/)specs?\//u;
|
|
@@ -1121,17 +1121,17 @@ const Manifest$3 = Schema.Struct({
|
|
|
1121
1121
|
name: Schema.optional(Schema.String),
|
|
1122
1122
|
exports: Schema.optional(Schema.Unknown)
|
|
1123
1123
|
});
|
|
1124
|
-
const decodeManifest$
|
|
1124
|
+
const decodeManifest$4 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$3));
|
|
1125
1125
|
const byLength$1 = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1126
1126
|
const problemFor$4 = (test, message) => ({
|
|
1127
1127
|
file: test.file,
|
|
1128
1128
|
line: FIRST$14,
|
|
1129
1129
|
column: FIRST$14,
|
|
1130
|
-
rule: RULE$
|
|
1130
|
+
rule: RULE$27,
|
|
1131
1131
|
message: `${test.base} ${message}`
|
|
1132
1132
|
});
|
|
1133
1133
|
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);
|
|
1134
|
-
const namesSibling = (source) => pipe([...groupsOf$1(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf$1(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE.test(name)));
|
|
1134
|
+
const namesSibling = (source) => pipe([...groupsOf$1(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf$1(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE$1.test(name)));
|
|
1135
1135
|
const ownerOf$3 = (packages, name) => {
|
|
1136
1136
|
const owners = pipe(packages, Array.filter((directory) => String$1.startsWith(directory)(name)));
|
|
1137
1137
|
return Array.last(Array.sort(owners, byLength$1));
|
|
@@ -1147,7 +1147,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
|
|
|
1147
1147
|
if (Option.isNone(owner)) return [];
|
|
1148
1148
|
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE));
|
|
1149
1149
|
const join = (target) => files.join(context.root, owner.value, target);
|
|
1150
|
-
return pipe(text, Option.flatMap(decodeManifest$
|
|
1150
|
+
return pipe(text, Option.flatMap(decodeManifest$4), Option.map(specifiersBeside({
|
|
1151
1151
|
join,
|
|
1152
1152
|
dirname: files.dirname,
|
|
1153
1153
|
directory: test.directory
|
|
@@ -1168,7 +1168,7 @@ const refersIn = Effect.fn("refersIn")(function* refersIn(context, test) {
|
|
|
1168
1168
|
const inSeparateTestDirectory = (name) => SEPARATE_TEST_DIRECTORY.test(name) || SPEC_DIRECTORY.test(name) && SPEC_FILE.test(name);
|
|
1169
1169
|
const problemIn$5 = Effect.fn("problemIn")(function* problemIn(context, test) {
|
|
1170
1170
|
if (inSeparateTestDirectory(test.name)) return Option.some(problemFor$4(test, DIRECTORY_MESSAGE));
|
|
1171
|
-
if (!TEST_FILE.test(test.name)) return Option.none();
|
|
1171
|
+
if (!TEST_FILE$1.test(test.name)) return Option.none();
|
|
1172
1172
|
if (yield* refersIn(context, test)) return Option.none();
|
|
1173
1173
|
return Option.some(problemFor$4(test, SIBLING_MESSAGE));
|
|
1174
1174
|
});
|
|
@@ -1190,15 +1190,15 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1190
1190
|
directory: files.dirname(file)
|
|
1191
1191
|
};
|
|
1192
1192
|
}));
|
|
1193
|
-
const found = yield* Effect.forEach(tests, (test) => problemIn$5(context, test), { concurrency: READ_CONCURRENCY$
|
|
1193
|
+
const found = yield* Effect.forEach(tests, (test) => problemIn$5(context, test), { concurrency: READ_CONCURRENCY$18 });
|
|
1194
1194
|
return Array.getSomes(found);
|
|
1195
1195
|
});
|
|
1196
1196
|
// src/features/placement/model/dangling-links.ts
|
|
1197
|
-
const RULE$
|
|
1198
|
-
const SEPARATOR$
|
|
1197
|
+
const RULE$26 = "dangling-link";
|
|
1198
|
+
const SEPARATOR$16 = "/";
|
|
1199
1199
|
const FIRST$13 = 1;
|
|
1200
|
-
const READ_CONCURRENCY$
|
|
1201
|
-
const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$
|
|
1200
|
+
const READ_CONCURRENCY$17 = 16;
|
|
1201
|
+
const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$16}`)(name);
|
|
1202
1202
|
/** @internal */
|
|
1203
1203
|
const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDanglingLinks(root) {
|
|
1204
1204
|
const files = yield* RepositoryFiles;
|
|
@@ -1210,25 +1210,28 @@ const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDangli
|
|
|
1210
1210
|
file,
|
|
1211
1211
|
line: FIRST$13,
|
|
1212
1212
|
column: FIRST$13,
|
|
1213
|
-
rule: RULE$
|
|
1213
|
+
rule: RULE$26,
|
|
1214
1214
|
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.`
|
|
1215
1215
|
})));
|
|
1216
1216
|
});
|
|
1217
|
-
const found = yield* Effect.forEach(links, problemOf, { concurrency: READ_CONCURRENCY$
|
|
1217
|
+
const found = yield* Effect.forEach(links, problemOf, { concurrency: READ_CONCURRENCY$17 });
|
|
1218
1218
|
return Array.getSomes(found);
|
|
1219
1219
|
});
|
|
1220
1220
|
// src/features/placement/model/member-sources.ts
|
|
1221
|
-
const ROOT_WORKSPACE = ".";
|
|
1221
|
+
const ROOT_WORKSPACE$1 = ".";
|
|
1222
1222
|
const EXCLUDED$2 = [
|
|
1223
1223
|
":(exclude,attr:linguist-vendored)",
|
|
1224
1224
|
":(exclude,attr:linguist-generated)",
|
|
1225
1225
|
":(exclude,attr:linguist-documentation)"
|
|
1226
1226
|
];
|
|
1227
|
+
const memberWorkspaces = Effect.fn("memberWorkspaces")(function* memberWorkspaces(root) {
|
|
1228
|
+
const declared = yield* workspaceDirectories(root);
|
|
1229
|
+
return pipe(declared, Array.filter((workspace) => workspace !== ROOT_WORKSPACE$1));
|
|
1230
|
+
});
|
|
1227
1231
|
const memberSources = Effect.fn("memberSources")(function* memberSources(root) {
|
|
1228
1232
|
const files = yield* RepositoryFiles;
|
|
1229
|
-
const declared = yield* workspaceDirectories(root);
|
|
1230
1233
|
return {
|
|
1231
|
-
workspaces:
|
|
1234
|
+
workspaces: yield* memberWorkspaces(root),
|
|
1232
1235
|
listed: yield* files.matchingFiles(root, EXCLUDED$2)
|
|
1233
1236
|
};
|
|
1234
1237
|
});
|
|
@@ -1237,7 +1240,7 @@ const LAYERED_RULE = "layered-source";
|
|
|
1237
1240
|
const ENTRY_RULE = "public-entry";
|
|
1238
1241
|
const FIRST$12 = 1;
|
|
1239
1242
|
const SOURCE_DIRECTORY = "src";
|
|
1240
|
-
const SEPARATOR$
|
|
1243
|
+
const SEPARATOR$15 = "/";
|
|
1241
1244
|
const LOOSE_DEPTH = 2;
|
|
1242
1245
|
const LAYERS = [
|
|
1243
1246
|
"app",
|
|
@@ -1263,16 +1266,16 @@ const problemAt$4 = (file, rule, message) => ({
|
|
|
1263
1266
|
rule,
|
|
1264
1267
|
message
|
|
1265
1268
|
});
|
|
1266
|
-
const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$
|
|
1269
|
+
const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$15}`)(name)), (owners) => Array.last(Array.sort(owners, byLength)), Option.map((workspace) => ({
|
|
1267
1270
|
workspace,
|
|
1268
1271
|
inner: String$1.slice(workspace.length + 1)(name)
|
|
1269
1272
|
})));
|
|
1270
1273
|
const layerProblemOf = (owned) => {
|
|
1271
|
-
const parts = String$1.split(owned.inner, SEPARATOR$
|
|
1274
|
+
const parts = String$1.split(owned.inner, SEPARATOR$15);
|
|
1272
1275
|
const [top, layer] = parts;
|
|
1273
|
-
if (top !== SOURCE_DIRECTORY) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$
|
|
1274
|
-
if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$
|
|
1275
|
-
return Option.liftPredicate([`${owned.workspace}${SEPARATOR$
|
|
1276
|
+
if (top !== SOURCE_DIRECTORY) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$15}${owned.inner}`, OUTSIDE_MESSAGE], () => !ROOT_ALLOWED.test(owned.inner));
|
|
1277
|
+
if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$15}${owned.inner}`, LOOSE_MESSAGE]);
|
|
1278
|
+
return Option.liftPredicate([`${owned.workspace}${SEPARATOR$15}${SOURCE_DIRECTORY}${SEPARATOR$15}${layer}`, LAYER_MESSAGE], () => !pipe(LAYERS, Array.contains(layer ?? "")));
|
|
1276
1279
|
};
|
|
1277
1280
|
const entryProblems = Effect.fn("entryProblems")(function* entryProblems(root, workspace) {
|
|
1278
1281
|
const files = yield* RepositoryFiles;
|
|
@@ -1294,23 +1297,23 @@ const checkLayeredSource = Effect.fn("checkLayeredSource")(function* checkLayere
|
|
|
1294
1297
|
return [...layered, ...Array.flatten(entries)];
|
|
1295
1298
|
});
|
|
1296
1299
|
// src/features/placement/model/nested-docs.ts
|
|
1297
|
-
const RULE$
|
|
1300
|
+
const RULE$25 = "nested-docs";
|
|
1298
1301
|
const CONFIG_FILE$4 = "vite.config.ts";
|
|
1299
|
-
const SEPARATOR$
|
|
1302
|
+
const SEPARATOR$14 = "/";
|
|
1300
1303
|
const FIRST$11 = 1;
|
|
1301
|
-
const READ_CONCURRENCY$
|
|
1304
|
+
const READ_CONCURRENCY$16 = 64;
|
|
1302
1305
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1303
1306
|
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
1304
1307
|
const README = /^README(?:\.[^/]+)?$/iu;
|
|
1305
1308
|
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1306
1309
|
const taggedError$3 = Schema.TaggedError;
|
|
1307
1310
|
var RootConfigUnreadable = class extends taggedError$3()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1308
|
-
const isNested = (name) => String$1.includes(SEPARATOR$
|
|
1311
|
+
const isNested = (name) => String$1.includes(SEPARATOR$14)(name);
|
|
1309
1312
|
const problemFor$3 = (file, message) => ({
|
|
1310
1313
|
file,
|
|
1311
1314
|
line: FIRST$11,
|
|
1312
1315
|
column: FIRST$11,
|
|
1313
|
-
rule: RULE$
|
|
1316
|
+
rule: RULE$25,
|
|
1314
1317
|
message
|
|
1315
1318
|
});
|
|
1316
1319
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
@@ -1356,17 +1359,17 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
|
|
|
1356
1359
|
workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
|
|
1357
1360
|
workspaceAgentDocs
|
|
1358
1361
|
};
|
|
1359
|
-
const found = yield* Effect.forEach(nested, (name) => problemIn$4(root, allowed, name), { concurrency: READ_CONCURRENCY$
|
|
1362
|
+
const found = yield* Effect.forEach(nested, (name) => problemIn$4(root, allowed, name), { concurrency: READ_CONCURRENCY$16 });
|
|
1360
1363
|
return Array.getSomes(found);
|
|
1361
1364
|
});
|
|
1362
1365
|
// src/features/placement/model/root-docs.ts
|
|
1363
|
-
const RULE$
|
|
1364
|
-
const SEPARATOR$
|
|
1366
|
+
const RULE$24 = "root-docs";
|
|
1367
|
+
const SEPARATOR$13 = "/";
|
|
1365
1368
|
const FIRST$10 = 1;
|
|
1366
1369
|
const MARKDOWN$1 = /\.(?:md|mdx|markdown)$/iu;
|
|
1367
1370
|
const ALLOWED = /^(?:README(?:\.[^/]+)?|AGENTS|CLAUDE|ARCHITECTURE|DESIGN|CHANGELOG|LICENSE|NOTICE)\.(?:md|mdx|markdown)$/iu;
|
|
1368
|
-
const MESSAGE$
|
|
1369
|
-
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$
|
|
1371
|
+
const MESSAGE$6 = "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.";
|
|
1372
|
+
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$13)(name) && MARKDOWN$1.test(name) && !ALLOWED.test(name);
|
|
1370
1373
|
/** @internal */
|
|
1371
1374
|
const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
|
|
1372
1375
|
const files = yield* RepositoryFiles;
|
|
@@ -1375,19 +1378,19 @@ const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
|
|
|
1375
1378
|
file: files.join(root, name),
|
|
1376
1379
|
line: FIRST$10,
|
|
1377
1380
|
column: FIRST$10,
|
|
1378
|
-
rule: RULE$
|
|
1379
|
-
message: `${name} ${MESSAGE$
|
|
1381
|
+
rule: RULE$24,
|
|
1382
|
+
message: `${name} ${MESSAGE$6}`
|
|
1380
1383
|
})));
|
|
1381
1384
|
});
|
|
1382
1385
|
// src/features/placement/model/root-readme.ts
|
|
1383
|
-
const RULE$
|
|
1386
|
+
const RULE$23 = "root-readme";
|
|
1384
1387
|
const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
|
|
1385
|
-
const READ_CONCURRENCY$
|
|
1388
|
+
const READ_CONCURRENCY$15 = 16;
|
|
1386
1389
|
const START$12 = 0;
|
|
1387
1390
|
const CHECK_POLICY = "@r_masseater/msch";
|
|
1388
1391
|
const MARKETPLACE = ".claude-plugin/marketplace.json";
|
|
1389
1392
|
const RELATIVE = /^\.\//u;
|
|
1390
|
-
const SEPARATOR$
|
|
1393
|
+
const SEPARATOR$12 = "/";
|
|
1391
1394
|
const MarketplacePlugin = Schema.Struct({
|
|
1392
1395
|
name: Schema.optional(Schema.String),
|
|
1393
1396
|
source: Schema.Unknown
|
|
@@ -1399,7 +1402,7 @@ const NO_PLUGINS = {
|
|
|
1399
1402
|
};
|
|
1400
1403
|
const isCheckPolicy = ({ packageName }) => Option.contains(packageName, CHECK_POLICY);
|
|
1401
1404
|
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.`;
|
|
1402
|
-
const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$
|
|
1405
|
+
const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$12)(directory), Array.last, Option.getOrElse(() => directory));
|
|
1403
1406
|
const pluginsOf = (plugins) => {
|
|
1404
1407
|
const directories = pipe(plugins, Array.map(({ source }) => source), Array.filter(Predicate.isString), Array.map(String$1.replace(RELATIVE, "")));
|
|
1405
1408
|
const segments = pipe(directories, Array.map(lastSegment));
|
|
@@ -1422,14 +1425,14 @@ const patternFor = (plugins) => ({ directory, names }) => patternOf(Option.match
|
|
|
1422
1425
|
onNone: () => ownNames(plugins, names),
|
|
1423
1426
|
onSome: () => [directory]
|
|
1424
1427
|
}));
|
|
1425
|
-
const problemsIn$
|
|
1428
|
+
const problemsIn$11 = (file, source, plugins) => (workspace) => {
|
|
1426
1429
|
const message = messageFor(workspace.directory);
|
|
1427
1430
|
const at = positionOf(source);
|
|
1428
1431
|
const pattern = patternFor(plugins)(workspace);
|
|
1429
1432
|
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1430
1433
|
file,
|
|
1431
1434
|
...at(found.index ?? START$12),
|
|
1432
|
-
rule: RULE$
|
|
1435
|
+
rule: RULE$23,
|
|
1433
1436
|
message
|
|
1434
1437
|
})));
|
|
1435
1438
|
};
|
|
@@ -1437,7 +1440,7 @@ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadm
|
|
|
1437
1440
|
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1438
1441
|
return pipe(text, Option.match({
|
|
1439
1442
|
onNone: () => [],
|
|
1440
|
-
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$
|
|
1443
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$11(file, source, plugins)))
|
|
1441
1444
|
}));
|
|
1442
1445
|
});
|
|
1443
1446
|
/** @internal */
|
|
@@ -1448,36 +1451,18 @@ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(r
|
|
|
1448
1451
|
const named = yield* namedWorkspaces(root);
|
|
1449
1452
|
const workspaces = pipe(named, Array.filter((workspace) => !isCheckPolicy(workspace)));
|
|
1450
1453
|
const plugins = yield* marketplacePlugins(root);
|
|
1451
|
-
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces, plugins), { concurrency: READ_CONCURRENCY$
|
|
1454
|
+
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces, plugins), { concurrency: READ_CONCURRENCY$15 });
|
|
1452
1455
|
return Array.flatten(found);
|
|
1453
1456
|
});
|
|
1454
|
-
// src/features/placement/model/source-
|
|
1457
|
+
// src/features/placement/model/source-aliases.ts
|
|
1455
1458
|
const ALIAS_RULE = "source-alias";
|
|
1456
|
-
const RUNTIME_RULE = "runtime-name";
|
|
1457
1459
|
const FIRST$9 = 1;
|
|
1458
|
-
const SEPARATOR$10 = "/";
|
|
1459
1460
|
const SOURCE_ALIAS = "#/*";
|
|
1460
1461
|
const SOURCE_TARGET = "./src/*";
|
|
1461
1462
|
const SOURCE_PREFIX = /^\.\/src(?:\/|$)/u;
|
|
1462
|
-
const RUNTIME_NAMES = [
|
|
1463
|
-
"worker",
|
|
1464
|
-
"workers",
|
|
1465
|
-
"cloudflare",
|
|
1466
|
-
"durable-objects",
|
|
1467
|
-
"node",
|
|
1468
|
-
"nodejs",
|
|
1469
|
-
"bun",
|
|
1470
|
-
"deno",
|
|
1471
|
-
"browser",
|
|
1472
|
-
"tauri",
|
|
1473
|
-
"electron",
|
|
1474
|
-
"lambda",
|
|
1475
|
-
"vercel"
|
|
1476
|
-
];
|
|
1477
1463
|
const ALIAS_MESSAGE = `points into src/ under its own name. Import source through "${SOURCE_ALIAS}": "${SOURCE_TARGET}" only, so an import names the layer and slice it uses instead of a folder alias.`;
|
|
1478
|
-
const RUNTIME_MESSAGE = "names the runtime that runs the code. Name folders after what the code does: entry code goes in app/entrypoint/, and code that does not depend on the runtime moves to the slice or shared segment of its role.";
|
|
1479
1464
|
const Manifest$2 = Schema.Struct({ imports: Schema.optional(Schema.Unknown) });
|
|
1480
|
-
const decodeManifest$
|
|
1465
|
+
const decodeManifest$3 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$2));
|
|
1481
1466
|
const problemAt$3 = (file, rule, message) => ({
|
|
1482
1467
|
file,
|
|
1483
1468
|
line: FIRST$9,
|
|
@@ -1495,17 +1480,13 @@ const aliasProblems = Effect.fn("aliasProblems")(function* aliasProblems(root, w
|
|
|
1495
1480
|
const files = yield* RepositoryFiles;
|
|
1496
1481
|
const manifest = files.join(root, workspace, MANIFEST_FILE);
|
|
1497
1482
|
const text = yield* files.readFile(manifest);
|
|
1498
|
-
return pipe(text, Option.flatMap(decodeManifest$
|
|
1483
|
+
return pipe(text, Option.flatMap(decodeManifest$3), 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$3(manifest, ALIAS_RULE, `"${key}" ${ALIAS_MESSAGE}`)));
|
|
1499
1484
|
});
|
|
1500
|
-
const RUNTIME_FOLDER = new RegExp(`^(?<folder>.*?/src(?:/[^/]+)*?/(?:${Array.join(RUNTIME_NAMES, "|")}))/`, "u");
|
|
1501
|
-
const runtimeFolderOf = (name) => pipe(Option.fromNullishOr(RUNTIME_FOLDER.exec(name)), Option.flatMap((found) => Option.fromUndefinedOr(found.groups)), Option.flatMap((groups) => Option.fromUndefinedOr(groups["folder"])));
|
|
1502
1485
|
/** @internal */
|
|
1503
|
-
const
|
|
1504
|
-
const
|
|
1505
|
-
const { workspaces, listed } = yield* memberSources(root);
|
|
1506
|
-
const folders = pipe(listed, Array.filter((name) => pipe(workspaces, Array.some((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$10}src${SEPARATOR$10}`)(name)))), Array.map(runtimeFolderOf), Array.getSomes, Array.dedupe, Array.map((folder) => problemAt$3(files.join(root, folder), RUNTIME_RULE, RUNTIME_MESSAGE)));
|
|
1486
|
+
const checkSourceAliases = Effect.fn("checkSourceAliases")(function* checkSourceAliases(root) {
|
|
1487
|
+
const workspaces = yield* memberWorkspaces(root);
|
|
1507
1488
|
const aliases = yield* pipe(workspaces, Effect.forEach((workspace) => aliasProblems(root, workspace)));
|
|
1508
|
-
return
|
|
1489
|
+
return Array.flatten(aliases);
|
|
1509
1490
|
});
|
|
1510
1491
|
// src/features/placement/model/placement-checks.ts
|
|
1511
1492
|
/** @internal */
|
|
@@ -1518,7 +1499,7 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
|
|
|
1518
1499
|
checkAgentDocsLength(root),
|
|
1519
1500
|
checkLayeredSource(root),
|
|
1520
1501
|
checkDanglingLinks(root),
|
|
1521
|
-
|
|
1502
|
+
checkSourceAliases(root)
|
|
1522
1503
|
], { concurrency: "unbounded" });
|
|
1523
1504
|
return Array.flatten(found);
|
|
1524
1505
|
});
|
|
@@ -1529,9 +1510,9 @@ const SCRIPTS = "scripts-directory";
|
|
|
1529
1510
|
const BIN = "bin";
|
|
1530
1511
|
const SCRIPTS_DIRECTORY = "scripts";
|
|
1531
1512
|
const WORKFLOW_DIRECTORY$1 = ".github/";
|
|
1532
|
-
const SEPARATOR$
|
|
1513
|
+
const SEPARATOR$11 = "/";
|
|
1533
1514
|
const CURRENT = "./";
|
|
1534
|
-
const READ_CONCURRENCY$
|
|
1515
|
+
const READ_CONCURRENCY$14 = 8;
|
|
1535
1516
|
const FIRST$8 = 1;
|
|
1536
1517
|
const RUN_FILE = /(?:^|[\s;&|(])(?:node|vpx|tsx|bun|deno)\s+(?:-\S+\s+)*(?<file>[^\s;&|)]+\.[cm]?[jt]s)\b/gu;
|
|
1537
1518
|
const COMMAND = /^bin\/[^/]+\.[cm]?ts$/u;
|
|
@@ -1542,7 +1523,7 @@ const Manifest$1 = Schema.Struct({
|
|
|
1542
1523
|
exports: Schema.optional(Schema.Unknown)
|
|
1543
1524
|
});
|
|
1544
1525
|
const TargetMap = Schema.Record(Schema.String, Schema.Unknown);
|
|
1545
|
-
const decodeManifest$
|
|
1526
|
+
const decodeManifest$2 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$1));
|
|
1546
1527
|
const decodeTarget = Schema.decodeUnknownOption(Schema.String);
|
|
1547
1528
|
const decodeTargetMap = Schema.decodeUnknownOption(TargetMap);
|
|
1548
1529
|
const NO_ENTRIES = {
|
|
@@ -1569,22 +1550,22 @@ const entriesOf$1 = (manifest) => {
|
|
|
1569
1550
|
const declaredEntries = Effect.fn("declaredEntries")(function* declaredEntries(root, directory) {
|
|
1570
1551
|
const files = yield* RepositoryFiles;
|
|
1571
1552
|
const text = yield* files.readFile(files.join(root, directory, MANIFEST_FILE));
|
|
1572
|
-
return pipe(text, Option.flatMap(decodeManifest$
|
|
1553
|
+
return pipe(text, Option.flatMap(decodeManifest$2), Option.map(entriesOf$1), Option.getOrElse(() => NO_ENTRIES));
|
|
1573
1554
|
});
|
|
1574
1555
|
const isCommand$1 = (path) => COMMAND.test(path) && !NOT_COMMAND.test(path);
|
|
1575
1556
|
const commandFilesIn = Effect.fn("commandFilesIn")(function* commandFilesIn(root, directory) {
|
|
1576
1557
|
const files = yield* RepositoryFiles;
|
|
1577
1558
|
const names = yield* files.readDirectory(files.join(root, directory, BIN));
|
|
1578
|
-
return pipe(names, Array.map((name) => `${BIN}${SEPARATOR$
|
|
1559
|
+
return pipe(names, Array.map((name) => `${BIN}${SEPARATOR$11}${name}`), Array.filter(isCommand$1));
|
|
1579
1560
|
});
|
|
1580
1561
|
const workflowText = Effect.fn("workflowText")(function* workflowText(root) {
|
|
1581
1562
|
const files = yield* RepositoryFiles;
|
|
1582
1563
|
const listed = yield* files.listedFiles(root);
|
|
1583
1564
|
const workflows = pipe(listed, Array.filter(String$1.startsWith(WORKFLOW_DIRECTORY$1)));
|
|
1584
|
-
const texts = yield* Effect.forEach(workflows, (file) => files.readFile(files.join(root, file)), { concurrency: READ_CONCURRENCY$
|
|
1565
|
+
const texts = yield* Effect.forEach(workflows, (file) => files.readFile(files.join(root, file)), { concurrency: READ_CONCURRENCY$14 });
|
|
1585
1566
|
return pipe(Array.getSomes(texts), Array.join("\n"));
|
|
1586
1567
|
});
|
|
1587
|
-
const workspacePath = (directory, path) => pipe([directory, path], Array.filter(String$1.isNonEmpty), Array.join(SEPARATOR$
|
|
1568
|
+
const workspacePath = (directory, path) => pipe([directory, path], Array.filter(String$1.isNonEmpty), Array.join(SEPARATOR$11));
|
|
1588
1569
|
const outsideProblems = ({ file, source, runs, entries }) => pipe(runs, Array.filter(({ path }) => !COMMAND.test(path) && !Array.contains(entries.all, path)), Array.map(({ path, start }) => ({
|
|
1589
1570
|
file,
|
|
1590
1571
|
...positionOf(source)(start),
|
|
@@ -1592,7 +1573,7 @@ const outsideProblems = ({ file, source, runs, entries }) => pipe(runs, Array.fi
|
|
|
1592
1573
|
message: `A task runs ${path}. Put each file that a task runs at ${BIN}/<name>.ts, the one place where every workspace keeps its commands, so that fallow and the other tools find it without a list of files.`
|
|
1593
1574
|
})));
|
|
1594
1575
|
const runsOf = (program) => pipe(nestedValues(RUN_TASKS)(program), Array.flatMap(stringsIn), Array.flatMap(runsIn));
|
|
1595
|
-
const problemsIn$
|
|
1576
|
+
const problemsIn$10 = Effect.fn("problemsIn")(function* problemsIn(root, directory, workflows) {
|
|
1596
1577
|
const files = yield* RepositoryFiles;
|
|
1597
1578
|
const config = yield* workspaceConfigOf(root, directory);
|
|
1598
1579
|
const entries = yield* declaredEntries(root, directory);
|
|
@@ -1631,17 +1612,17 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
|
|
|
1631
1612
|
const checkCommandEntries = Effect.fn("checkCommandEntries")(function* checkCommandEntries(root) {
|
|
1632
1613
|
const all = ["", ...yield* workspaceDirectories(root)];
|
|
1633
1614
|
const workflows = yield* workflowText(root);
|
|
1634
|
-
const found = yield* Effect.forEach(all, (directory) => problemsIn$
|
|
1635
|
-
const scripts = yield* Effect.forEach(all, (directory) => scriptsProblem(root, directory), { concurrency: READ_CONCURRENCY$
|
|
1615
|
+
const found = yield* Effect.forEach(all, (directory) => problemsIn$10(root, directory, workflows), { concurrency: READ_CONCURRENCY$14 });
|
|
1616
|
+
const scripts = yield* Effect.forEach(all, (directory) => scriptsProblem(root, directory), { concurrency: READ_CONCURRENCY$14 });
|
|
1636
1617
|
return [...Array.flatten(found), ...Array.getSomes(scripts)];
|
|
1637
1618
|
});
|
|
1638
1619
|
// src/features/repository-layout/model/crates.ts
|
|
1639
|
-
const RULE$
|
|
1620
|
+
const RULE$22 = "unverified-crate";
|
|
1640
1621
|
const CARGO_FILE = "Cargo.toml";
|
|
1641
1622
|
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1642
|
-
const SEPARATOR$
|
|
1623
|
+
const SEPARATOR$10 = "/";
|
|
1643
1624
|
const FIRST$7 = 1;
|
|
1644
|
-
const READ_CONCURRENCY$
|
|
1625
|
+
const READ_CONCURRENCY$13 = 8;
|
|
1645
1626
|
const CrateEntry = Schema.Struct({
|
|
1646
1627
|
name: Schema.String,
|
|
1647
1628
|
manifest_path: Schema.String
|
|
@@ -1667,14 +1648,14 @@ const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
|
1667
1648
|
})));
|
|
1668
1649
|
}, Effect.scoped);
|
|
1669
1650
|
const owningWorkspace = (directories) => (directory) => {
|
|
1670
|
-
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$
|
|
1651
|
+
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$10}`)(directory)));
|
|
1671
1652
|
return Array.last(Array.sort(owners, String$1.Order));
|
|
1672
1653
|
};
|
|
1673
1654
|
const problemFor$2 = (crate, message) => ({
|
|
1674
1655
|
file: crate.manifest,
|
|
1675
1656
|
line: FIRST$7,
|
|
1676
1657
|
column: FIRST$7,
|
|
1677
|
-
rule: RULE$
|
|
1658
|
+
rule: RULE$22,
|
|
1678
1659
|
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
1679
1660
|
});
|
|
1680
1661
|
const problemIn$3 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
@@ -1690,11 +1671,115 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
|
1690
1671
|
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
1691
1672
|
const directories = yield* workspaceDirectories(root);
|
|
1692
1673
|
const crates = yield* cratesIn(root);
|
|
1693
|
-
const found = yield* Effect.forEach(crates, (crate) => problemIn$3(root, directories, crate), { concurrency: READ_CONCURRENCY$
|
|
1674
|
+
const found = yield* Effect.forEach(crates, (crate) => problemIn$3(root, directories, crate), { concurrency: READ_CONCURRENCY$13 });
|
|
1694
1675
|
return Array.getSomes(found);
|
|
1695
1676
|
});
|
|
1677
|
+
// src/features/repository-layout/model/deploy-entry-patterns.ts
|
|
1678
|
+
const RULE$21 = "deploy-entry-pattern";
|
|
1679
|
+
const FALLOW_KEYS = [
|
|
1680
|
+
"entry",
|
|
1681
|
+
"entryPoints",
|
|
1682
|
+
"supportEntry",
|
|
1683
|
+
"dynamicallyLoaded",
|
|
1684
|
+
"alwaysUsed"
|
|
1685
|
+
];
|
|
1686
|
+
const VITE_KEYS = ["files"];
|
|
1687
|
+
const FALLOW_CONFIG$1 = /(?:^|\/)(?:\.fallowrc\.jsonc?|fallow-plugin-[^/]+\.jsonc?)$/u;
|
|
1688
|
+
const VITE_CONFIG = /(?:^|\/)vite\.config\.[cm]?ts$/u;
|
|
1689
|
+
const BRACE_GROUP = /\{(?<options>[^{}]*)\}/u;
|
|
1690
|
+
const OPTION_SEPARATOR = ",";
|
|
1691
|
+
const PAIR = 2;
|
|
1692
|
+
const NEGATED = "!";
|
|
1693
|
+
const ROOT_WORKSPACE = ".";
|
|
1694
|
+
const WRAP_OFFSET$1 = 1;
|
|
1695
|
+
const NO_OFFSET = 0;
|
|
1696
|
+
const READ_CONCURRENCY$12 = 8;
|
|
1697
|
+
const MESSAGE$5 = "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.";
|
|
1698
|
+
const decodeKey$1 = Schema.decodeUnknownOption(KeySchema);
|
|
1699
|
+
const FALLOW = {
|
|
1700
|
+
keys: FALLOW_KEYS,
|
|
1701
|
+
offset: WRAP_OFFSET$1,
|
|
1702
|
+
sourceOf: (text) => `(${text})`,
|
|
1703
|
+
bases: (directory, workspaces) => [directory, ...workspaces]
|
|
1704
|
+
};
|
|
1705
|
+
const VITE = {
|
|
1706
|
+
keys: VITE_KEYS,
|
|
1707
|
+
offset: NO_OFFSET,
|
|
1708
|
+
sourceOf: (text) => text,
|
|
1709
|
+
bases: (directory) => [directory]
|
|
1710
|
+
};
|
|
1711
|
+
const isPatternProperty = (keys) => (node) => node["type"] === "Property" && pipe(decodeKey$1(node["key"]), Option.exists((key) => Array.contains(keys, keyName(key))));
|
|
1712
|
+
const patternsIn = (keys) => (node) => {
|
|
1713
|
+
if (Predicate.isReadonlyObject(node) && isPatternProperty(keys)(node)) return stringsIn(node["value"]);
|
|
1714
|
+
return pipe(childrenOf$2(node), Array.flatMap(patternsIn(keys)));
|
|
1715
|
+
};
|
|
1716
|
+
const choicesOf = ([literal = "", options]) => pipe(Option.fromUndefinedOr(options), Option.map(String$1.split(OPTION_SEPARATOR)), Option.getOrElse(() => [""]), Array.map((option) => `${literal}${option}`));
|
|
1717
|
+
const combined = (chunks) => Array.matchLeft(chunks, {
|
|
1718
|
+
onEmpty: () => [""],
|
|
1719
|
+
onNonEmpty: (head, tail) => pipe(choicesOf(head), Array.flatMap((choice) => pipe(combined(tail), Array.map((rest) => `${choice}${rest}`))))
|
|
1720
|
+
});
|
|
1721
|
+
const expanded = (pattern) => combined(Array.chunksOf(String$1.split(pattern, BRACE_GROUP), PAIR));
|
|
1722
|
+
const selectsOnlyDeployEntries = Effect.fn("selectsOnlyDeployEntries")(function* selectsOnlyDeployEntries({ root, bases, entries }, pattern) {
|
|
1723
|
+
const files = yield* RepositoryFiles;
|
|
1724
|
+
const pathspecs = pipe(bases, Array.flatMap((base) => pipe(expanded(pattern.text), Array.map((spec) => `:(glob)${files.join(base, spec)}`))));
|
|
1725
|
+
const matched = yield* files.matchingFiles(root, pathspecs);
|
|
1726
|
+
const selects = Array.isReadonlyArrayNonEmpty(matched) && pipe(matched, Array.every((file) => Array.contains(entries, file)));
|
|
1727
|
+
return Option.liftPredicate(pattern, () => selects);
|
|
1728
|
+
});
|
|
1729
|
+
const patternsOf = Effect.fn("patternsOf")(function* patternsOf(file, text, kind) {
|
|
1730
|
+
const parsed = yield* Effect.promise(() => parse(`${file}.ts`, kind.sourceOf(text), { lang: "ts" }));
|
|
1731
|
+
return pipe(patternsIn(kind.keys)(parsed.program), Array.filter(({ text: pattern }) => !String$1.startsWith(NEGATED)(pattern)));
|
|
1732
|
+
});
|
|
1733
|
+
const problemsIn$9 = Effect.fn("problemsIn")(function* problemsIn(request) {
|
|
1734
|
+
const { root, file, kind, workspaces, entries } = request;
|
|
1735
|
+
const files = yield* RepositoryFiles;
|
|
1736
|
+
const path = files.join(root, file);
|
|
1737
|
+
const text = yield* files.readFile(path);
|
|
1738
|
+
if (Option.isNone(text)) return [];
|
|
1739
|
+
const patterns = yield* patternsOf(file, text.value, kind);
|
|
1740
|
+
const selection = {
|
|
1741
|
+
root,
|
|
1742
|
+
bases: kind.bases(files.dirname(file), workspaces),
|
|
1743
|
+
entries
|
|
1744
|
+
};
|
|
1745
|
+
const flagged = yield* pipe(patterns, Effect.forEach((pattern) => selectsOnlyDeployEntries(selection, pattern)));
|
|
1746
|
+
return pipe(Array.getSomes(flagged), Array.map(({ text: pattern, start }) => ({
|
|
1747
|
+
file: path,
|
|
1748
|
+
...positionOf(text.value)(start - kind.offset),
|
|
1749
|
+
rule: RULE$21,
|
|
1750
|
+
message: `${pattern} ${MESSAGE$5}`
|
|
1751
|
+
})));
|
|
1752
|
+
});
|
|
1753
|
+
/** @internal */
|
|
1754
|
+
const checkDeployEntryPatterns = Effect.fn("checkDeployEntryPatterns")(function* checkDeployEntryPatterns(root) {
|
|
1755
|
+
const files = yield* RepositoryFiles;
|
|
1756
|
+
const entries = yield* deployEntries(root);
|
|
1757
|
+
if (!Array.isReadonlyArrayNonEmpty(entries)) return [];
|
|
1758
|
+
const listed = yield* files.listedFiles(root);
|
|
1759
|
+
const declared = yield* workspaceDirectories(root);
|
|
1760
|
+
const workspaces = pipe(declared, Array.filter((workspace) => workspace !== ROOT_WORKSPACE));
|
|
1761
|
+
const configs = pipe(listed, Array.flatMap((file) => {
|
|
1762
|
+
if (FALLOW_CONFIG$1.test(file)) return [{
|
|
1763
|
+
file,
|
|
1764
|
+
kind: FALLOW
|
|
1765
|
+
}];
|
|
1766
|
+
if (VITE_CONFIG.test(file)) return [{
|
|
1767
|
+
file,
|
|
1768
|
+
kind: VITE
|
|
1769
|
+
}];
|
|
1770
|
+
return [];
|
|
1771
|
+
}));
|
|
1772
|
+
const found = yield* Effect.forEach(configs, ({ file, kind }) => problemsIn$9({
|
|
1773
|
+
root,
|
|
1774
|
+
file,
|
|
1775
|
+
kind,
|
|
1776
|
+
workspaces,
|
|
1777
|
+
entries
|
|
1778
|
+
}), { concurrency: READ_CONCURRENCY$12 });
|
|
1779
|
+
return Array.flatten(found);
|
|
1780
|
+
});
|
|
1696
1781
|
// src/features/repository-layout/model/fallow-entries.ts
|
|
1697
|
-
const RULE$
|
|
1782
|
+
const RULE$20 = "listed-entry";
|
|
1698
1783
|
const ENTRY_KEYS = [
|
|
1699
1784
|
"entry",
|
|
1700
1785
|
"entryPoints",
|
|
@@ -1702,7 +1787,7 @@ const ENTRY_KEYS = [
|
|
|
1702
1787
|
];
|
|
1703
1788
|
const FALLOW_CONFIG = /(?:^|\/)(?:\.fallowrc\.jsonc?|fallow-plugin-[^/]+\.jsonc?|\.fallow\/plugins\/[^/]+\.jsonc?)$/u;
|
|
1704
1789
|
const WILDCARD$1 = /[*?{[]/u;
|
|
1705
|
-
const SEPARATOR$
|
|
1790
|
+
const SEPARATOR$9 = "/";
|
|
1706
1791
|
const WRAP_OFFSET = 1;
|
|
1707
1792
|
const READ_CONCURRENCY$11 = 8;
|
|
1708
1793
|
const decodeKey = Schema.decodeUnknownOption(KeySchema);
|
|
@@ -1714,7 +1799,7 @@ const entryPatternsIn = (node) => {
|
|
|
1714
1799
|
})));
|
|
1715
1800
|
return pipe(childrenOf$2(node), Array.flatMap(entryPatternsIn));
|
|
1716
1801
|
};
|
|
1717
|
-
const namesOneFile = (directories) => ({ text }) => pipe(directories, Array.some((directory) => String$1.startsWith(`${directory}${SEPARATOR$
|
|
1802
|
+
const namesOneFile = (directories) => ({ text }) => pipe(directories, Array.some((directory) => String$1.startsWith(`${directory}${SEPARATOR$9}`)(text))) || String$1.includes(SEPARATOR$9)(text) && !WILDCARD$1.test(text);
|
|
1718
1803
|
const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, file, directories) {
|
|
1719
1804
|
const files = yield* RepositoryFiles;
|
|
1720
1805
|
const path = files.join(root, file);
|
|
@@ -1724,8 +1809,8 @@ const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, file, di
|
|
|
1724
1809
|
return pipe(entryPatternsIn(parsed.program), Array.filter(namesOneFile(directories)), Array.map(({ text: pattern, start }) => ({
|
|
1725
1810
|
file: path,
|
|
1726
1811
|
...positionOf(text.value)(start),
|
|
1727
|
-
rule: RULE$
|
|
1728
|
-
message: `${pattern} names files one by one.
|
|
1812
|
+
rule: RULE$20,
|
|
1813
|
+
message: `${pattern} names files one by one. Let fallow find the file through what declares it: package.json bin and exports, a tool's config file, or the main of the Alchemy resource that deploys it.`
|
|
1729
1814
|
})));
|
|
1730
1815
|
});
|
|
1731
1816
|
/** @internal */
|
|
@@ -1736,7 +1821,7 @@ const checkFallowEntries = Effect.fn("checkFallowEntries")(function* checkFallow
|
|
|
1736
1821
|
return Array.flatten(found);
|
|
1737
1822
|
});
|
|
1738
1823
|
// src/features/repository-layout/model/hidden-verify.ts
|
|
1739
|
-
const RULE$
|
|
1824
|
+
const RULE$19 = "hidden-verify";
|
|
1740
1825
|
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1741
1826
|
const FIRST$6 = 1;
|
|
1742
1827
|
const READ_CONCURRENCY$10 = 8;
|
|
@@ -1750,7 +1835,7 @@ const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, directory)
|
|
|
1750
1835
|
file,
|
|
1751
1836
|
line: FIRST$6,
|
|
1752
1837
|
column: FIRST$6,
|
|
1753
|
-
rule: RULE$
|
|
1838
|
+
rule: RULE$19,
|
|
1754
1839
|
message: `${directory} gets its verify task from code outside ${CONFIG_FILE$2}. The root verify reads ${CONFIG_FILE$2} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$2}.`
|
|
1755
1840
|
}).pipe(Option.filter(() => verified));
|
|
1756
1841
|
});
|
|
@@ -1761,7 +1846,7 @@ const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVe
|
|
|
1761
1846
|
return Array.getSomes(found);
|
|
1762
1847
|
});
|
|
1763
1848
|
// src/features/repository-layout/model/root-workspace-paths.ts
|
|
1764
|
-
const RULE$
|
|
1849
|
+
const RULE$18 = "root-workspace-path";
|
|
1765
1850
|
const CONFIG_FILE$1 = "vite.config.ts";
|
|
1766
1851
|
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
1767
1852
|
const NAME_CHARACTER = /[\w.@-]/u;
|
|
@@ -1780,7 +1865,7 @@ const mentions = (directory) => (text) => {
|
|
|
1780
1865
|
const problemsIn$7 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
1781
1866
|
file,
|
|
1782
1867
|
...positionOf(source)(found.start),
|
|
1783
|
-
rule: RULE$
|
|
1868
|
+
rule: RULE$18,
|
|
1784
1869
|
message: `${directory} is a workspace. The root ${CONFIG_FILE$1} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE$1}: msch.lint, msch.devDependencies or its verify task.`
|
|
1785
1870
|
})));
|
|
1786
1871
|
/** @internal */
|
|
@@ -1794,7 +1879,7 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
|
|
|
1794
1879
|
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$7(file, source.value, directories)));
|
|
1795
1880
|
});
|
|
1796
1881
|
// src/features/repository-layout/model/shared-uncached-tasks.ts
|
|
1797
|
-
const RULE$
|
|
1882
|
+
const RULE$17 = "shared-uncached-task";
|
|
1798
1883
|
const READ_CONCURRENCY$9 = 8;
|
|
1799
1884
|
const SHARED = 2;
|
|
1800
1885
|
const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
|
|
@@ -1837,7 +1922,7 @@ const problemsOf$1 = (definitions) => {
|
|
|
1837
1922
|
return pipe(definitions, Array.map(({ file, position, name, command }) => ({
|
|
1838
1923
|
file,
|
|
1839
1924
|
...position,
|
|
1840
|
-
rule: RULE$
|
|
1925
|
+
rule: RULE$17,
|
|
1841
1926
|
message: `The uncached task ${name} (${command}) is written the same way in ${Array.join(directories, ", ")}. Write it once in a shared helper and spread it into each run.tasks, so that a change to it reaches every workspace.`
|
|
1842
1927
|
})));
|
|
1843
1928
|
};
|
|
@@ -1880,10 +1965,10 @@ const scalarsIn = (source) => {
|
|
|
1880
1965
|
return found;
|
|
1881
1966
|
};
|
|
1882
1967
|
// src/features/repository-layout/model/workflow-references.ts
|
|
1883
|
-
const ROOT = ".";
|
|
1968
|
+
const ROOT$1 = ".";
|
|
1884
1969
|
const LOCAL = "./";
|
|
1885
1970
|
const NEGATION = "!";
|
|
1886
|
-
const SEPARATOR$
|
|
1971
|
+
const SEPARATOR$8 = "/";
|
|
1887
1972
|
const LINE$1 = "\n";
|
|
1888
1973
|
const UNRESOLVED_MARKERS = [
|
|
1889
1974
|
"${{",
|
|
@@ -1909,10 +1994,10 @@ const withoutLocal = (path) => {
|
|
|
1909
1994
|
};
|
|
1910
1995
|
const joinPath = (base, path) => {
|
|
1911
1996
|
const relative = withoutLocal(String$1.trim(path));
|
|
1912
|
-
if (base === ROOT) return relative;
|
|
1913
|
-
return `${base}${SEPARATOR$
|
|
1997
|
+
if (base === ROOT$1) return relative;
|
|
1998
|
+
return `${base}${SEPARATOR$8}${relative}`;
|
|
1914
1999
|
};
|
|
1915
|
-
const reference = (kind, field, base = ROOT) => ({ text, offset }) => {
|
|
2000
|
+
const reference = (kind, field, base = ROOT$1) => ({ text, offset }) => {
|
|
1916
2001
|
const path = String$1.trim(text);
|
|
1917
2002
|
if (!isLiteralPath(path) || !isLiteralPath(base)) return [];
|
|
1918
2003
|
return [{
|
|
@@ -1925,8 +2010,8 @@ const reference = (kind, field, base = ROOT) => ({ text, offset }) => {
|
|
|
1925
2010
|
const isPositive = ({ text }) => !String$1.startsWith(NEGATION)(String$1.trim(text));
|
|
1926
2011
|
const globsIn = (field, node) => pipe(itemsOf(node), Array.flatMap((item) => Option.toArray(stringOf(item))), Array.filter(isPositive), Array.flatMap(reference("glob", field)));
|
|
1927
2012
|
const filtersOf = ([event, filters]) => pipe(FILTER_KEYS$1, Array.flatMap((key) => globsIn(`on.${event}.${key}`, childOf(key)(filters))));
|
|
1928
|
-
const directoryOf$1 = (located, base) => pipe(located, Option.map(({ text }) => joinPath(ROOT, text)), Option.getOrElse(() => base));
|
|
1929
|
-
const located = (kind, field, base = ROOT) => (found) => pipe(found, Option.toArray, Array.flatMap(reference(kind, field, base)));
|
|
2013
|
+
const directoryOf$1 = (located, base) => pipe(located, Option.map(({ text }) => joinPath(ROOT$1, text)), Option.getOrElse(() => base));
|
|
2014
|
+
const located = (kind, field, base = ROOT$1) => (found) => pipe(found, Option.toArray, Array.flatMap(reference(kind, field, base)));
|
|
1930
2015
|
const localUses = (node) => pipe(stringOf(childOf("uses")(node)), Option.filter(({ text }) => String$1.startsWith(LOCAL)(text)));
|
|
1931
2016
|
const scriptsIn = (field, base) => ({ text, offset }) => pipe(String$1.split(text, TOKEN_SEPARATOR), Array.filter((token) => SCRIPT.test(token)), Array.dedupe, Array.flatMap((token) => reference("script", field, base)({
|
|
1932
2017
|
text: token,
|
|
@@ -1970,7 +2055,7 @@ const jobsOf = (source) => entriesOf(childOf("jobs")(parseDocument(source).conte
|
|
|
1970
2055
|
const workflowReferences = (source) => {
|
|
1971
2056
|
const root = parseDocument(source).contents;
|
|
1972
2057
|
const workflowDefault = workingDirectoryOf(root);
|
|
1973
|
-
const base = directoryOf$1(workflowDefault, ROOT);
|
|
2058
|
+
const base = directoryOf$1(workflowDefault, ROOT$1);
|
|
1974
2059
|
return [
|
|
1975
2060
|
...pipe(entriesOf(childOf("on")(root)), Array.flatMap(filtersOf)),
|
|
1976
2061
|
...located("directory", "defaults.run.working-directory")(workflowDefault),
|
|
@@ -1979,16 +2064,16 @@ const workflowReferences = (source) => {
|
|
|
1979
2064
|
];
|
|
1980
2065
|
};
|
|
1981
2066
|
const pathInputOf = (step) => childOf("path")(childOf("with")(step));
|
|
1982
|
-
const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray, Array.flatMap(linesOf), Array.map(({ text }) => joinPath(ROOT, text)), Array.filter(isLiteralPath));
|
|
2067
|
+
const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray, Array.flatMap(linesOf), Array.map(({ text }) => joinPath(ROOT$1, text)), Array.filter(isLiteralPath));
|
|
1983
2068
|
/** @internal */
|
|
1984
2069
|
const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
|
|
1985
2070
|
// src/features/repository-layout/model/workflow-paths.ts
|
|
1986
|
-
const RULE$
|
|
2071
|
+
const RULE$16 = "workflow-path";
|
|
1987
2072
|
const WORKFLOW_DIRECTORY = ".github/workflows/";
|
|
1988
2073
|
const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
|
|
1989
2074
|
const READ_CONCURRENCY$8 = 8;
|
|
1990
2075
|
const WILDCARD = /[*?[]/u;
|
|
1991
|
-
const SEPARATOR$
|
|
2076
|
+
const SEPARATOR$7 = "/";
|
|
1992
2077
|
const FIRST$4 = 0;
|
|
1993
2078
|
const EXPECTED = {
|
|
1994
2079
|
action: "a directory with action.yml",
|
|
@@ -2013,10 +2098,10 @@ const isDirectoryAt = Effect.fn("isDirectoryAt")(function* isDirectoryAt(root, p
|
|
|
2013
2098
|
return Option.getOrElse(directory, () => false);
|
|
2014
2099
|
});
|
|
2015
2100
|
const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
|
|
2016
|
-
const found = yield* pipe(ACTION_DEFINITIONS, Effect.forEach((name) => existsAt(root, `${path}${SEPARATOR$
|
|
2101
|
+
const found = yield* pipe(ACTION_DEFINITIONS, Effect.forEach((name) => existsAt(root, `${path}${SEPARATOR$7}${name}`)));
|
|
2017
2102
|
return pipe(found, Array.some(Boolean));
|
|
2018
2103
|
});
|
|
2019
|
-
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$
|
|
2104
|
+
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$7))}`;
|
|
2020
2105
|
const RESOLVERS = {
|
|
2021
2106
|
action: hasAction,
|
|
2022
2107
|
directory: isDirectoryAt,
|
|
@@ -2024,13 +2109,13 @@ const RESOLVERS = {
|
|
|
2024
2109
|
glob: matchesGlob,
|
|
2025
2110
|
script: Effect.fn("findsScript")(function* findsScript(root, path) {
|
|
2026
2111
|
if (yield* existsAt(root, path)) return true;
|
|
2027
|
-
const segments = String$1.split(path, SEPARATOR$
|
|
2112
|
+
const segments = String$1.split(path, SEPARATOR$7);
|
|
2028
2113
|
return yield* matchesAny(root, Array.makeBy(segments.length, suffixAt(segments)));
|
|
2029
2114
|
})
|
|
2030
2115
|
};
|
|
2031
2116
|
const staticPrefix = (path) => {
|
|
2032
2117
|
const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD));
|
|
2033
|
-
if (String$1.endsWith(SEPARATOR$
|
|
2118
|
+
if (String$1.endsWith(SEPARATOR$7)(prefix)) return String$1.slice(FIRST$4, -1)(prefix);
|
|
2034
2119
|
return prefix;
|
|
2035
2120
|
};
|
|
2036
2121
|
const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
@@ -2039,17 +2124,17 @@ const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
|
2039
2124
|
const ignored = yield* (yield* RepositoryFiles).ignoredPaths(root, [prefix]);
|
|
2040
2125
|
return Array.isReadonlyArrayNonEmpty(ignored);
|
|
2041
2126
|
});
|
|
2042
|
-
const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR$
|
|
2127
|
+
const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR$7}`)(produced) || String$1.startsWith(`${produced}${SEPARATOR$7}`)(path);
|
|
2043
2128
|
const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, found) {
|
|
2044
2129
|
const prefix = staticPrefix(found.path);
|
|
2045
2130
|
if (pipe(produced, Array.some(overlaps(prefix)))) return false;
|
|
2046
2131
|
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
2047
2132
|
return !(yield* isIgnored$1(root, found.path));
|
|
2048
2133
|
});
|
|
2049
|
-
const problemOf$
|
|
2134
|
+
const problemOf$6 = (file, source) => (found) => ({
|
|
2050
2135
|
file,
|
|
2051
2136
|
...positionOf(source)(found.offset),
|
|
2052
|
-
rule: RULE$
|
|
2137
|
+
rule: RULE$16,
|
|
2053
2138
|
message: `${found.field} names ${found.path}, which is not ${EXPECTED[found.kind]} in this repository. Point it at a path that exists or remove it.`
|
|
2054
2139
|
});
|
|
2055
2140
|
const problemsIn$6 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
|
|
@@ -2059,7 +2144,7 @@ const problemsIn$6 = Effect.fn("problemsIn")(function* problemsIn(root, workflow
|
|
|
2059
2144
|
if (Option.isNone(source)) return [];
|
|
2060
2145
|
const produced = producedPaths(source.value);
|
|
2061
2146
|
const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
|
|
2062
|
-
return pipe(missing, Array.map(problemOf$
|
|
2147
|
+
return pipe(missing, Array.map(problemOf$6(file, source.value)));
|
|
2063
2148
|
});
|
|
2064
2149
|
/** @internal */
|
|
2065
2150
|
const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
|
|
@@ -2077,7 +2162,7 @@ const PATHS_FILTER_ACTION = /(?:^|\/)paths-filter@/u;
|
|
|
2077
2162
|
const PACKAGE_FILTER = /(?:^|\s)(?:--filter|-F)(?:\s+|=)(?<quote>["']?)(?<value>[^\s"'$][^\s"']*)\k<quote>/gu;
|
|
2078
2163
|
const START$11 = 0;
|
|
2079
2164
|
const READ_CONCURRENCY$7 = 8;
|
|
2080
|
-
const SEPARATOR$
|
|
2165
|
+
const SEPARATOR$6 = "/";
|
|
2081
2166
|
const WORD_SEPARATORS = /[-_]/gu;
|
|
2082
2167
|
const SPACE = " ";
|
|
2083
2168
|
const FILTER_MESSAGE = "A workflow that reacts to changes under listed paths needs a new entry for every package and drifts from the packages it is meant to cover. Run the generic pipeline on every push and let it decide from the workspace what changed.";
|
|
@@ -2100,7 +2185,7 @@ const pathFiltersIn = (file, source) => {
|
|
|
2100
2185
|
};
|
|
2101
2186
|
const matching = (workspaces, text) => pipe(workspaces, Array.findFirst(({ names }) => Array.isReadonlyArrayNonEmpty(names) && Option.isSome(String$1.match(patternOf(names))(text))), Option.map(({ directory }) => directory));
|
|
2102
2187
|
const named = (workspaces, text) => Option.orElse(matching(workspaces, text), () => matching(workspaces, String$1.replaceAll(WORD_SEPARATORS, SPACE)(text)));
|
|
2103
|
-
const containing = (workspaces, path) => pipe(workspaces, Array.findFirst(({ directory }) => path === directory || String$1.startsWith(`${directory}${SEPARATOR$
|
|
2188
|
+
const containing = (workspaces, path) => pipe(workspaces, Array.findFirst(({ directory }) => path === directory || String$1.startsWith(`${directory}${SEPARATOR$6}`)(path)), Option.map(({ directory }) => directory));
|
|
2104
2189
|
const namesIn = (name, source) => {
|
|
2105
2190
|
const root = parseDocument(source).contents;
|
|
2106
2191
|
return [
|
|
@@ -2166,6 +2251,7 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
|
|
|
2166
2251
|
const found = yield* Effect.all([
|
|
2167
2252
|
checkCommandEntries(root),
|
|
2168
2253
|
checkCrates(root),
|
|
2254
|
+
checkDeployEntryPatterns(root),
|
|
2169
2255
|
checkFallowEntries(root),
|
|
2170
2256
|
checkHiddenVerify(root),
|
|
2171
2257
|
checkRootWorkspacePaths(root),
|
|
@@ -2176,7 +2262,7 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
|
|
|
2176
2262
|
return Array.flatten(found);
|
|
2177
2263
|
});
|
|
2178
2264
|
// src/features/pass-through-wrappers/model/pass-through-wrappers.ts
|
|
2179
|
-
const RULE$
|
|
2265
|
+
const RULE$15 = "pass-through-wrapper";
|
|
2180
2266
|
const SINGLE_STATEMENT = 1;
|
|
2181
2267
|
const SINGLE_DECLARATION = 1;
|
|
2182
2268
|
const THIS_PARAMETER = "this";
|
|
@@ -2270,14 +2356,14 @@ const isPassThrough = (checker) => (candidate) => (forward) => {
|
|
|
2270
2356
|
const restForwarded = pipe(wrapper.parameters, Array.some(isRest));
|
|
2271
2357
|
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);
|
|
2272
2358
|
};
|
|
2273
|
-
const problemOf$
|
|
2359
|
+
const problemOf$5 = (checker) => (candidate) => {
|
|
2274
2360
|
if (changesTheCall(candidate.wrapper)) return Option.none();
|
|
2275
2361
|
return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt$6({
|
|
2276
|
-
rule: RULE$
|
|
2362
|
+
rule: RULE$15,
|
|
2277
2363
|
message: messageOf(forward.callee.getText())
|
|
2278
2364
|
})(candidate.name)));
|
|
2279
2365
|
};
|
|
2280
|
-
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$
|
|
2366
|
+
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$5(checker)), Array.getSomes);
|
|
2281
2367
|
// src/features/value-owners/model/slots.ts
|
|
2282
2368
|
const ANNOTATED_KINDS = /* @__PURE__ */ new Set([
|
|
2283
2369
|
SyntaxKind.Parameter,
|
|
@@ -2330,6 +2416,36 @@ const flowOf = (context) => (expression) => Option.fromUndefinedOr(context.check
|
|
|
2330
2416
|
target
|
|
2331
2417
|
})))));
|
|
2332
2418
|
const flowsIn = (context) => (sourceFile) => Array.getSomes(pipe(descendantsOf(sourceFile), Array.filter((node) => isFlowSource(node)), Array.map((node) => flowOf(context)(node))));
|
|
2419
|
+
// src/features/value-owners/model/free-literals.ts
|
|
2420
|
+
const NAME = /^[\w@.#/:$-]{2,}$/u;
|
|
2421
|
+
const REQUIRE = "require";
|
|
2422
|
+
const isModuleSpecifier = (node) => {
|
|
2423
|
+
const { parent } = node;
|
|
2424
|
+
return isImportDeclaration(parent) || isExportDeclaration(parent) || parent.kind === SyntaxKind.ExternalModuleReference || parent.kind === SyntaxKind.LiteralType || isCallExpression(parent) && (parent.expression.kind === SyntaxKind.ImportKeyword || parent.expression.getText() === REQUIRE);
|
|
2425
|
+
};
|
|
2426
|
+
const isModuleScope = (node) => {
|
|
2427
|
+
const { parent } = node;
|
|
2428
|
+
if (isSourceFile(parent)) return true;
|
|
2429
|
+
return !isSignatureDeclaration(parent) && isModuleScope(parent);
|
|
2430
|
+
};
|
|
2431
|
+
const isModuleConstant = (node) => isVariableDeclaration(node.parent) && node.parent.initializer === node && isModuleScope(node.parent);
|
|
2432
|
+
const isDefinition = (node) => {
|
|
2433
|
+
const { parent } = node;
|
|
2434
|
+
if (isPropertyAssignment(parent)) return parent.initializer === node && isObjectLiteralExpression(parent.parent) && isModuleConstant(parent.parent);
|
|
2435
|
+
return isModuleConstant(node);
|
|
2436
|
+
};
|
|
2437
|
+
const isTyped = (checker) => (node) => Option.fromUndefinedOr(checker.getContextualType(node)).pipe(Option.flatMap(finiteValuesOf(checker)), Option.isSome);
|
|
2438
|
+
const specifierOf = (statement) => {
|
|
2439
|
+
if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) return Option.none();
|
|
2440
|
+
return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter(isStringLiteral));
|
|
2441
|
+
};
|
|
2442
|
+
const importedFilesOf = (checker) => (sourceFile) => pipe(sourceFile.statements, Array.map(specifierOf), Array.getSomes, Array.flatMap((specifier) => pipe(Option.fromUndefinedOr(checker.getSymbolAtLocation(specifier)), Option.flatMap((symbol) => Array.head(declarationsOf(symbol))), Option.map((declaration) => declaration.getSourceFile().fileName), Option.toArray)), Array.dedupe);
|
|
2443
|
+
const freeLiteralsIn = (checker) => (sourceFile, excluded) => pipe(descendantsOf(sourceFile), Array.filter((node) => isStringLiteral(node)), Array.filter((node) => NAME.test(node.text)), Array.filter(isDefinition), Array.filter((node) => !isModuleSpecifier(node)), Array.filter((node) => !isInsideAny(excluded)(node) && !isTyped(checker)(node)), Array.map((node) => node.text), Array.dedupe);
|
|
2444
|
+
const fileFactsIn = (checker) => (sourceFiles, excluded) => pipe(sourceFiles, Array.map((sourceFile) => ({
|
|
2445
|
+
file: sourceFile.fileName,
|
|
2446
|
+
values: freeLiteralsIn(checker)(sourceFile, excluded),
|
|
2447
|
+
imports: importedFilesOf(checker)(sourceFile)
|
|
2448
|
+
})), Array.filter((facts) => Array.isReadonlyArrayNonEmpty(facts.values) || Array.isReadonlyArrayNonEmpty(facts.imports)));
|
|
2333
2449
|
// src/features/value-owners/model/owners.ts
|
|
2334
2450
|
const OWNER_TAG = "msch";
|
|
2335
2451
|
const FIRST_OWNER_COUNT = 1;
|
|
@@ -2414,6 +2530,10 @@ const combineOwnerScans = (scans) => {
|
|
|
2414
2530
|
problems: [...pipe(scans, Array.flatMap((scan) => scan.problems)), ...conflictProblems(owners)]
|
|
2415
2531
|
};
|
|
2416
2532
|
};
|
|
2533
|
+
const ownerDeclarationsIn = (owners) => (project) => {
|
|
2534
|
+
const keys = new Set(pipe(owners, Array.map((owner) => owner.key)));
|
|
2535
|
+
return pipe(project.sourceFiles, Array.flatMap((sourceFile) => pipe(descendantsOf(sourceFile), Array.filter((node) => isVariableDeclaration(node)), Array.filter((declaration) => Option.exists(ownerKeyOf(declaration), (key) => keys.has(key))))));
|
|
2536
|
+
};
|
|
2417
2537
|
// src/features/value-owners/model/derivation.ts
|
|
2418
2538
|
const contractOf = (node) => {
|
|
2419
2539
|
const { parent } = node;
|
|
@@ -2542,7 +2662,17 @@ const selectsKeys = (checker) => (node, values) => {
|
|
|
2542
2662
|
const typeArguments = parent.typeArguments ?? [];
|
|
2543
2663
|
return pipe(typeArguments, Array.filter((argument) => argument !== node), Array.some((argument) => isSubsetOf(values, propertyNamesOf(checker)(checker.getTypeFromTypeNode(argument)))));
|
|
2544
2664
|
};
|
|
2545
|
-
const
|
|
2665
|
+
const FILTERED_TYPE = 0;
|
|
2666
|
+
const isConditionalAlias = (checker) => (reference) => isTypeReferenceNode(reference) && Option.fromUndefinedOr(checker.getSymbolAtLocation(reference.typeName)).pipe(Option.map(declarationsOf), Option.exists(Array.some((declaration) => isTypeAliasDeclaration(declaration) && declaration.type.kind === SyntaxKind.ConditionalType)));
|
|
2667
|
+
const filtersBy = (checker) => (node) => {
|
|
2668
|
+
const { parent } = node;
|
|
2669
|
+
if (isTypeReferenceNode(parent)) {
|
|
2670
|
+
const typeArguments = parent.typeArguments ?? [];
|
|
2671
|
+
if (Array.findFirstIndex(typeArguments, (argument) => argument === node).pipe(Option.exists((position) => position > FILTERED_TYPE)) && isConditionalAlias(checker)(parent)) return true;
|
|
2672
|
+
}
|
|
2673
|
+
return parent.kind !== SyntaxKind.SourceFile && filtersBy(checker)(parent);
|
|
2674
|
+
};
|
|
2675
|
+
const unionValuesOf = (checker) => (node) => literalUnionOf(checker.getTypeFromTypeNode(node)).pipe(Option.filter((values) => !selectsKeys(checker)(node, values) && !filtersBy(checker)(node)));
|
|
2546
2676
|
const isExpressionSite = (node) => isArrayLiteralExpression(node) || isCallExpression(node);
|
|
2547
2677
|
const expressionSiteValuesOf = (checker) => (node) => Option.liftPredicate(node, isExpressionSite).pipe(Option.flatMap(expressionValuesOf(checker)));
|
|
2548
2678
|
const siteValuesOf = (checker) => (node) => {
|
|
@@ -2564,6 +2694,7 @@ const sitesUnder = (checker) => (node) => {
|
|
|
2564
2694
|
sources: sourcesOf(checker)(node)
|
|
2565
2695
|
})), Option.toArray);
|
|
2566
2696
|
};
|
|
2697
|
+
const sitesOutside = (checker) => (project, outers) => pipe(project.sourceFiles, Array.flatMap((sourceFile) => sitesUnder(checker)(sourceFile)), Array.filter((site) => !isInsideAny(outers)(site.node)));
|
|
2567
2698
|
// src/features/value-owners/model/value-checks.ts
|
|
2568
2699
|
const OWNER_SEARCH_DEPTH = 4;
|
|
2569
2700
|
const NOTHING_HIDDEN = 0;
|
|
@@ -2654,19 +2785,13 @@ const ownedLiteralProblem = (context) => (literal) => Option.fromUndefinedOr(con
|
|
|
2654
2785
|
rule: "owned-literal",
|
|
2655
2786
|
message: `${literal.getText()} is a value of ${describeOwners(owners)}. Write it through the owner's binding instead of as a literal.`
|
|
2656
2787
|
})(literal)));
|
|
2657
|
-
const ownedLiteralProblems = (context) => (sourceFile, excluded) => Array.getSomes(pipe(descendantsOf(sourceFile), Array.filter((node) => isStringLiteral(node) || isNumericLiteral(node)), Array.filter((node) => isValuePosition(node)), Array.filter((node) => !
|
|
2788
|
+
const ownedLiteralProblems = (context) => (sourceFile, excluded) => Array.getSomes(pipe(descendantsOf(sourceFile), Array.filter((node) => isStringLiteral(node) || isNumericLiteral(node)), Array.filter((node) => isValuePosition(node)), Array.filter((node) => !isInsideAny(excluded)(node)), Array.map((node) => ownedLiteralProblem(context)(node))));
|
|
2658
2789
|
// src/features/value-owners/model/analysis.ts
|
|
2659
2790
|
const isVisibleTo = (project) => (owner) => pipe(project.sourceFiles, Array.some((sourceFile) => sourceFile.fileName === owner.file)) || Option.exists(owner.packageName, (name) => Option.contains(project.packageName, name) || project.workspaceDependencies.includes(name));
|
|
2660
|
-
const ownerDeclarationsIn = (project, owners) => {
|
|
2661
|
-
const keys = new Set(pipe(owners, Array.map((owner) => owner.key)));
|
|
2662
|
-
return pipe(project.sourceFiles, Array.flatMap((sourceFile) => pipe(descendantsOf(sourceFile), Array.filter((node) => isVariableDeclaration(node)), Array.filter((declaration) => Option.exists(ownerKeyOf(declaration), (key) => keys.has(key))))));
|
|
2663
|
-
};
|
|
2664
|
-
const isInside = (outers) => (node) => pipe(outers, Array.some((outer) => contains(outer)(node)));
|
|
2665
|
-
const sitesOutside = (checker) => (project, outers) => pipe(project.sourceFiles, Array.flatMap((sourceFile) => sitesUnder(checker)(sourceFile)), Array.filter((site) => !isInside(outers)(site.node)));
|
|
2666
2791
|
const nodesOf = (sites) => pipe(sites, Array.map((site) => site.node));
|
|
2667
2792
|
const analyzeProject = ({ owners, sourceChecks }) => (project) => {
|
|
2668
2793
|
const { checker } = project;
|
|
2669
|
-
const ownerDeclarations = ownerDeclarationsIn(
|
|
2794
|
+
const ownerDeclarations = ownerDeclarationsIn(owners)(project);
|
|
2670
2795
|
const sites = sitesOutside(checker)(project, ownerDeclarations);
|
|
2671
2796
|
const flowContext = {
|
|
2672
2797
|
checker,
|
|
@@ -2692,7 +2817,8 @@ const analyzeProject = ({ owners, sourceChecks }) => (project) => {
|
|
|
2692
2817
|
...shapeProblemsIn(shapeContext)(sourceFile),
|
|
2693
2818
|
...pipe(sourceChecks, Array.flatMap((check) => check(checker)(sourceFile)))
|
|
2694
2819
|
]))],
|
|
2695
|
-
unowned: pipe(verdicts, Array.flatMap((found) => found.unowned))
|
|
2820
|
+
unowned: pipe(verdicts, Array.flatMap((found) => found.unowned)),
|
|
2821
|
+
literals: fileFactsIn(checker)(project.sourceFiles, excluded)
|
|
2696
2822
|
};
|
|
2697
2823
|
};
|
|
2698
2824
|
// src/features/value-owners/model/cache.ts
|
|
@@ -2709,11 +2835,19 @@ const EMPTY = "";
|
|
|
2709
2835
|
const FIELD_SEPARATOR = "\0";
|
|
2710
2836
|
const LINE_SEPARATOR = "\n";
|
|
2711
2837
|
const ValueSchema = Schema.Union([Schema.String, Schema.Finite]);
|
|
2838
|
+
const Strings = Schema.Array(Schema.String);
|
|
2839
|
+
const ScopeSchema = Schema.Struct({
|
|
2840
|
+
name: Schema.String,
|
|
2841
|
+
dependencies: Strings
|
|
2842
|
+
});
|
|
2843
|
+
const FileLiteralsSchema = Schema.Struct({
|
|
2844
|
+
scope: ScopeSchema,
|
|
2845
|
+
file: Schema.String,
|
|
2846
|
+
values: Strings,
|
|
2847
|
+
imports: Strings
|
|
2848
|
+
});
|
|
2712
2849
|
const UnownedSiteSchema = Schema.Struct({
|
|
2713
|
-
scope:
|
|
2714
|
-
name: Schema.String,
|
|
2715
|
-
dependencies: Schema.Array(Schema.String)
|
|
2716
|
-
}),
|
|
2850
|
+
scope: ScopeSchema,
|
|
2717
2851
|
file: Schema.String,
|
|
2718
2852
|
start: Schema.Int,
|
|
2719
2853
|
line: Schema.Int,
|
|
@@ -2722,7 +2856,8 @@ const UnownedSiteSchema = Schema.Struct({
|
|
|
2722
2856
|
});
|
|
2723
2857
|
const AnalysisSchema = Schema.Struct({
|
|
2724
2858
|
problems: ProblemList,
|
|
2725
|
-
unowned: Schema.Array(UnownedSiteSchema)
|
|
2859
|
+
unowned: Schema.Array(UnownedSiteSchema),
|
|
2860
|
+
literals: Schema.Array(FileLiteralsSchema)
|
|
2726
2861
|
});
|
|
2727
2862
|
const AnalysisJson = Schema.fromJsonString(AnalysisSchema);
|
|
2728
2863
|
const hasher = Effect.gen(function* currentHasher() {
|
|
@@ -2815,7 +2950,7 @@ const unownedSiteOf = (scope) => (site) => ({
|
|
|
2815
2950
|
column: columnOf(site.node),
|
|
2816
2951
|
values: site.values
|
|
2817
2952
|
});
|
|
2818
|
-
const canDerive = (left, right) => left.scope.name === right.scope.name || left.scope.dependencies.includes(right.scope.name) || right.scope.dependencies.includes(left.scope.name);
|
|
2953
|
+
const canDerive$1 = (left, right) => left.scope.name === right.scope.name || left.scope.dependencies.includes(right.scope.name) || right.scope.dependencies.includes(left.scope.name);
|
|
2819
2954
|
const siteKey = (site) => `${site.file}#${String(site.start)}`;
|
|
2820
2955
|
const valueSetKey = (site) => {
|
|
2821
2956
|
const keys = pipe(site.values, Array.map((value) => valueKey(value)));
|
|
@@ -2825,7 +2960,7 @@ const duplicateProblems = (relative) => (sites) => {
|
|
|
2825
2960
|
const unique = Array.dedupeWith(sites, (left, right) => siteKey(left) === siteKey(right));
|
|
2826
2961
|
const groups = Record.values(Array.groupBy(unique, (site) => valueSetKey(site)));
|
|
2827
2962
|
return pipe(groups, Array.filter((group) => group.length > DUPLICATE_THRESHOLD), Array.flatMap((group) => pipe(group, Array.flatMap((site) => {
|
|
2828
|
-
const related = pipe(group, Array.filter((other) => other !== site && canDerive(site, other)));
|
|
2963
|
+
const related = pipe(group, Array.filter((other) => other !== site && canDerive$1(site, other)));
|
|
2829
2964
|
if (!Array.isReadonlyArrayNonEmpty(related)) return [];
|
|
2830
2965
|
const others = pipe(related, Array.map((other) => `${relative(other.file)}:${String(other.line)}`), Array.join(", "));
|
|
2831
2966
|
return [{
|
|
@@ -2837,6 +2972,154 @@ const duplicateProblems = (relative) => (sites) => {
|
|
|
2837
2972
|
}];
|
|
2838
2973
|
}))));
|
|
2839
2974
|
};
|
|
2975
|
+
// src/features/value-owners/model/name-lists.ts
|
|
2976
|
+
const RULE$14 = "hand-written-names";
|
|
2977
|
+
const TEST_FILE = /\.test(?:\.[\w-]+)?\.[cm]?tsx?$/u;
|
|
2978
|
+
const nameListOf = (site) => {
|
|
2979
|
+
if (TEST_FILE.test(site.file) || site.values.length < 2) return Option.none();
|
|
2980
|
+
const names = pipe(site.values, Array.filter(Predicate.isString));
|
|
2981
|
+
return Option.liftPredicate({
|
|
2982
|
+
site,
|
|
2983
|
+
names
|
|
2984
|
+
}, (list) => list.names.length === site.values.length);
|
|
2985
|
+
};
|
|
2986
|
+
const mostNamesOf = (list) => Math.max(2, list.names.length - 1);
|
|
2987
|
+
const problemOf$4 = ({ list, reason }) => ({
|
|
2988
|
+
file: list.site.file,
|
|
2989
|
+
line: list.site.line,
|
|
2990
|
+
column: list.site.column,
|
|
2991
|
+
rule: RULE$14,
|
|
2992
|
+
message: `The names ${formatValues(list.names)} are listed by hand, but ${reason}`
|
|
2993
|
+
});
|
|
2994
|
+
// src/features/value-owners/model/declared-names.ts
|
|
2995
|
+
const MOST_DEFINING_FILES = 2;
|
|
2996
|
+
const SINGLE_NAME = 1;
|
|
2997
|
+
const SHOWN_FILES = 3;
|
|
2998
|
+
const canDerive = (left, right) => left.name === right.name || left.dependencies.includes(right.name) || right.dependencies.includes(left.name);
|
|
2999
|
+
const definitionsOf = (entry) => pipe(entry.values, Array.map((value) => [value, {
|
|
3000
|
+
scope: entry.scope,
|
|
3001
|
+
file: entry.file
|
|
3002
|
+
}]));
|
|
3003
|
+
const uniqueFiles = (pairs) => pipe(pairs, Array.map(([, defined]) => defined), Array.dedupeWith((left, right) => left.file === right.file));
|
|
3004
|
+
const definedIndexOf = (files) => pipe(files, Array.filter((entry) => !TEST_FILE.test(entry.file)), Array.flatMap(definitionsOf), Array.groupBy(([value]) => value), Record.map(uniqueFiles));
|
|
3005
|
+
const ownedOneByOne = (defined) => {
|
|
3006
|
+
const hosted = pipe(defined, Array.flatMap(([, files]) => files), Array.groupBy((file) => file), Record.map((files) => files.length));
|
|
3007
|
+
const hostsOne = (file) => Record.get(hosted, file).pipe(Option.exists((count) => count === SINGLE_NAME));
|
|
3008
|
+
return pipe(defined, Array.map(([name, files]) => [name, pipe(files, Array.filter(hostsOne))]));
|
|
3009
|
+
};
|
|
3010
|
+
const filesDefining = (index, list) => (name) => {
|
|
3011
|
+
return [name, pipe(Record.get(index, name), Option.getOrElse(() => []), Array.filter((defined) => defined.file !== list.site.file && canDerive(list.site.scope, defined.scope)), Array.map((defined) => defined.file))];
|
|
3012
|
+
};
|
|
3013
|
+
const definingFiles = (index) => (list) => pipe(list.names, Array.map(filesDefining(index, list)), ownedOneByOne, Array.filter(([, files]) => Array.isReadonlyArrayNonEmpty(files) && files.length <= MOST_DEFINING_FILES));
|
|
3014
|
+
const declaredNameProblem = ({ literals, relative }) => {
|
|
3015
|
+
const index = definedIndexOf(literals);
|
|
3016
|
+
return (list) => {
|
|
3017
|
+
const defined = definingFiles(index)(list);
|
|
3018
|
+
const files = pipe(defined, Array.flatMap(([, found]) => found), Array.dedupe);
|
|
3019
|
+
if (defined.length < mostNamesOf(list) || files.length < 2) return Option.none();
|
|
3020
|
+
const names = pipe(defined, Array.map(([name]) => name));
|
|
3021
|
+
const shown = pipe(files, Array.take(SHOWN_FILES), Array.map(relative), Array.join(", "));
|
|
3022
|
+
return Option.some(problemOf$4({
|
|
3023
|
+
list,
|
|
3024
|
+
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.`
|
|
3025
|
+
}));
|
|
3026
|
+
};
|
|
3027
|
+
};
|
|
3028
|
+
// src/features/value-owners/model/listed-paths.ts
|
|
3029
|
+
const PATH_PREFIX = /^(?:!|\.\/)+/u;
|
|
3030
|
+
const GLOB = /[*?{[]/u;
|
|
3031
|
+
const EXTENSION$1 = /\.[^./]+$/u;
|
|
3032
|
+
const SEPARATOR$5 = "/";
|
|
3033
|
+
const ROOT = ".";
|
|
3034
|
+
const namedPath = (repository, file) => (name) => {
|
|
3035
|
+
const bare = pipe(name, String$1.replace(PATH_PREFIX, ""));
|
|
3036
|
+
if (GLOB.test(bare) || String$1.isEmpty(bare)) return Option.none();
|
|
3037
|
+
const fromFile = repository.relative(repository.join(repository.dirname(file), bare));
|
|
3038
|
+
return pipe([fromFile, bare], Array.findFirst((path) => HashSet.has(repository.paths, path)));
|
|
3039
|
+
};
|
|
3040
|
+
const kindOf = (repository) => (path) => {
|
|
3041
|
+
if (HashSet.has(repository.directories, path)) return SEPARATOR$5;
|
|
3042
|
+
return pipe(path, String$1.match(EXTENSION$1), Option.flatMap(Array.head), Option.getOrElse(() => path));
|
|
3043
|
+
};
|
|
3044
|
+
const siblingsOf = (repository) => (path) => pipe(Record.get(repository.entries, repository.dirname(path)), Option.getOrElse(() => []), Array.filter((entry) => kindOf(repository)(entry) === kindOf(repository)(path)));
|
|
3045
|
+
const coversDirectory = (repository) => (group) => pipe(Array.head(group), Option.exists((first) => group.length >= Math.max(2, siblingsOf(repository)(first).length - 1)));
|
|
3046
|
+
const enumeratedDirectory = (repository) => (paths) => pipe(paths, Array.groupBy((path) => `${repository.dirname(path)}${SEPARATOR$5}${kindOf(repository)(path)}`), Record.values, Array.findFirst(coversDirectory(repository)), Option.flatMap(Array.head), Option.map(repository.dirname));
|
|
3047
|
+
const directoryLabel = (directory) => {
|
|
3048
|
+
if (directory === ROOT) return "the repository root";
|
|
3049
|
+
return directory;
|
|
3050
|
+
};
|
|
3051
|
+
const listedPathProblem = (repository) => (list) => {
|
|
3052
|
+
const paths = pipe(list.names, Array.map(namedPath(repository, list.site.file)), Array.getSomes);
|
|
3053
|
+
const packages = pipe(list.names, Array.filter((name) => HashSet.has(repository.packages, name)));
|
|
3054
|
+
const directory = enumeratedDirectory(repository)(paths);
|
|
3055
|
+
if (Option.isSome(directory)) return Option.some(problemOf$4({
|
|
3056
|
+
list,
|
|
3057
|
+
reason: `they enumerate the entries of ${directoryLabel(directory.value)}. Find them with a glob or derive them from the declaration that names them.`
|
|
3058
|
+
}));
|
|
3059
|
+
if (packages.length >= 2) return Option.some(problemOf$4({
|
|
3060
|
+
list,
|
|
3061
|
+
reason: `${formatValues(packages)} are workspace packages. Derive them from the workspace manifests or from a property that each package declares.`
|
|
3062
|
+
}));
|
|
3063
|
+
return Option.none();
|
|
3064
|
+
};
|
|
3065
|
+
// src/features/value-owners/model/subset-lists.ts
|
|
3066
|
+
const SUBSET_SHARE = 2;
|
|
3067
|
+
const canImport = (importer, imported) => importer.name === imported.name || importer.dependencies.includes(imported.name);
|
|
3068
|
+
const importIndexOf = (files) => pipe(files, Array.map((entry) => [entry.file, entry.imports]), Record.fromEntries);
|
|
3069
|
+
const imports = (index) => (importer, imported) => Record.get(index, importer).pipe(Option.exists(Array.contains(imported)));
|
|
3070
|
+
const connected = (index) => (left, right) => left === right || imports(index)(left, right) || imports(index)(right, left);
|
|
3071
|
+
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);
|
|
3072
|
+
const subsetListProblem = ({ lists, literals, relative }) => {
|
|
3073
|
+
const index = importIndexOf(literals);
|
|
3074
|
+
return (list) => pipe(lists, Array.findFirst(isPartOf(index, list)), Option.map((other) => problemOf$4({
|
|
3075
|
+
list,
|
|
3076
|
+
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.`
|
|
3077
|
+
})));
|
|
3078
|
+
};
|
|
3079
|
+
// src/features/value-owners/model/hand-lists.ts
|
|
3080
|
+
const handWrittenNameProblems = ({ repository, literals }) => (sites) => {
|
|
3081
|
+
const lists = pipe(sites, Array.dedupeWith((left, right) => left.file === right.file && left.start === right.start), Array.map(nameListOf), Array.getSomes);
|
|
3082
|
+
const { relative } = repository;
|
|
3083
|
+
const listedPath = listedPathProblem(repository);
|
|
3084
|
+
const declared = declaredNameProblem({
|
|
3085
|
+
literals,
|
|
3086
|
+
relative
|
|
3087
|
+
});
|
|
3088
|
+
const subset = subsetListProblem({
|
|
3089
|
+
lists,
|
|
3090
|
+
literals,
|
|
3091
|
+
relative
|
|
3092
|
+
});
|
|
3093
|
+
return pipe(lists, Array.map((list) => listedPath(list).pipe(Option.orElse(() => declared(list)), Option.orElse(() => subset(list)))), Array.getSomes);
|
|
3094
|
+
};
|
|
3095
|
+
// src/features/value-owners/model/repository-names.ts
|
|
3096
|
+
const MANIFEST$1 = "package.json";
|
|
3097
|
+
const SEPARATOR$4 = "/";
|
|
3098
|
+
const FIRST_SEGMENT = 1;
|
|
3099
|
+
const ManifestJson = Schema.fromJsonString(Schema.Struct({ name: Schema.optionalKey(Schema.String) }));
|
|
3100
|
+
const decodeManifest$1 = Schema.decodeUnknownOption(ManifestJson);
|
|
3101
|
+
const prefixesOf = (file) => {
|
|
3102
|
+
const segments = pipe(file, String$1.split(SEPARATOR$4));
|
|
3103
|
+
return pipe(Array.range(FIRST_SEGMENT, segments.length), Array.map((count) => pipe(Array.take(segments, count), Array.join(SEPARATOR$4))));
|
|
3104
|
+
};
|
|
3105
|
+
const directoriesOf$1 = (file) => pipe(prefixesOf(file), Array.dropRight(FIRST_SEGMENT));
|
|
3106
|
+
const nameOf = (text) => pipe(text, Option.flatMap(decodeManifest$1), Option.flatMap((parsed) => Option.fromUndefinedOr(parsed.name)));
|
|
3107
|
+
const repositoryNamesOf = Effect.fn("repositoryNamesOf")(function* repositoryNamesOf(root) {
|
|
3108
|
+
const files = yield* RepositoryFiles;
|
|
3109
|
+
const listed = yield* files.listedFiles(root);
|
|
3110
|
+
const names = yield* pipe(listed, Array.filter((file) => files.basename(file) === MANIFEST$1), Effect.forEach((manifest) => files.readFile(files.join(root, manifest)).pipe(Effect.map(nameOf))));
|
|
3111
|
+
const paths = pipe(listed, Array.flatMap(prefixesOf), Array.dedupe);
|
|
3112
|
+
return {
|
|
3113
|
+
root,
|
|
3114
|
+
paths: HashSet.fromIterable(paths),
|
|
3115
|
+
directories: HashSet.fromIterable(pipe(listed, Array.flatMap(directoriesOf$1))),
|
|
3116
|
+
entries: pipe(paths, Array.groupBy(files.dirname)),
|
|
3117
|
+
packages: HashSet.fromIterable(Array.getSomes(names)),
|
|
3118
|
+
relative: (file) => files.relative(root, file),
|
|
3119
|
+
join: files.join,
|
|
3120
|
+
dirname: files.dirname
|
|
3121
|
+
};
|
|
3122
|
+
});
|
|
2840
3123
|
// src/features/value-owners/model/check.ts
|
|
2841
3124
|
const scanOwners = Effect.fn("scanOwners")(function* scanOwners(workspace, configPaths) {
|
|
2842
3125
|
const ownerConfigs = yield* pipe(configPaths, Effect.filter(mentions$1(`@${OWNER_TAG}`)(workspace.compiler)));
|
|
@@ -2855,7 +3138,11 @@ const freshAnalysis = ({ workspace, owners, sourceChecks }) => (configPath) => w
|
|
|
2855
3138
|
const scope = scopeOf(project, configPath);
|
|
2856
3139
|
return {
|
|
2857
3140
|
problems: analysis.problems,
|
|
2858
|
-
unowned: pipe(analysis.unowned, Array.map(unownedSiteOf(scope)))
|
|
3141
|
+
unowned: pipe(analysis.unowned, Array.map(unownedSiteOf(scope))),
|
|
3142
|
+
literals: pipe(analysis.literals, Array.map((entry) => ({
|
|
3143
|
+
...entry,
|
|
3144
|
+
scope
|
|
3145
|
+
})))
|
|
2859
3146
|
};
|
|
2860
3147
|
}).pipe(Effect.withSpan("analyzeProject")));
|
|
2861
3148
|
const keyedAnalysis = (context) => (configPath, key) => Effect.gen(function* lookupAnalysis() {
|
|
@@ -2899,6 +3186,18 @@ const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(w
|
|
|
2899
3186
|
yield* pruneAnalyses(cache)(pipe(found, Array.map(([key]) => key)));
|
|
2900
3187
|
return pipe(found, Array.map(([, analysis]) => analysis));
|
|
2901
3188
|
});
|
|
3189
|
+
const repositoryProblems = (repository) => (analyses) => {
|
|
3190
|
+
const unowned = pipe(analyses, Array.flatMap((analysis) => analysis.unowned));
|
|
3191
|
+
const literals = pipe(analyses, Array.flatMap((analysis) => analysis.literals));
|
|
3192
|
+
return [
|
|
3193
|
+
...pipe(analyses, Array.flatMap((analysis) => analysis.problems)),
|
|
3194
|
+
...duplicateProblems(repository.relative)(unowned),
|
|
3195
|
+
...handWrittenNameProblems({
|
|
3196
|
+
repository,
|
|
3197
|
+
literals
|
|
3198
|
+
})(unowned)
|
|
3199
|
+
];
|
|
3200
|
+
};
|
|
2902
3201
|
const checkRepository = Effect.fn("checkRepository")(function* checkRepository(root, sourceChecks = []) {
|
|
2903
3202
|
const files = yield* RepositoryFiles;
|
|
2904
3203
|
const workspace = {
|
|
@@ -2912,13 +3211,8 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
2912
3211
|
owners: ownerScan.owners,
|
|
2913
3212
|
sourceChecks
|
|
2914
3213
|
}, configPaths);
|
|
2915
|
-
const
|
|
2916
|
-
|
|
2917
|
-
return sortProblems([
|
|
2918
|
-
...ownerScan.problems,
|
|
2919
|
-
...pipe(analyses, Array.flatMap((analysis) => analysis.problems)),
|
|
2920
|
-
...duplicateProblems(relative)(unowned)
|
|
2921
|
-
]);
|
|
3214
|
+
const repository = yield* repositoryNamesOf(root);
|
|
3215
|
+
return sortProblems([...ownerScan.problems, ...repositoryProblems(repository)(analyses)]);
|
|
2922
3216
|
}, Effect.scoped);
|
|
2923
3217
|
// src/app/source-checks.ts
|
|
2924
3218
|
/** @internal */
|