@r_masseater/msch 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +671 -134
- package/dist/cli.mjs.map +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{problem-BeBSq75T.mjs → problem-PUlrIOu9.mjs} +6 -2
- package/dist/{problem-BeBSq75T.mjs.map → problem-PUlrIOu9.mjs.map} +1 -1
- package/dist/{repository-files-CfhXZQrO.mjs → repository-files-BiKs7S7N.mjs} +32 -12
- package/dist/repository-files-BiKs7S7N.mjs.map +1 -0
- package/dist/{workspace-jN1GGTGn.mjs → workspace-De9R-Kix.mjs} +65 -29
- package/dist/workspace-De9R-Kix.mjs.map +1 -0
- package/dist/workspace-settings.mjs +2 -2
- package/package.json +1 -1
- package/dist/repository-files-CfhXZQrO.mjs.map +0 -1
- package/dist/workspace-jN1GGTGn.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-
|
|
3
|
-
import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-
|
|
4
|
-
import { C as
|
|
2
|
+
import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-PUlrIOu9.mjs";
|
|
3
|
+
import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-BiKs7S7N.mjs";
|
|
4
|
+
import { C as publishedWorkspaces, D as readManifest, E as dependencyEntries, O as workspaceDependencies, T as MANIFEST_FILE, _ as childrenOf$3, a as hasVerifyTask, b as nestedValues, g as KeySchema, h as workspaceConfigOf, i as definesTask, l as workspaceDirectories, r as VERIFY_TASK, t as namedWorkspaces, v as keyName, w as publicEntriesOf, y as literalOf } from "./workspace-De9R-Kix.mjs";
|
|
5
5
|
import { t as COMMENT_DIRECTIVES } from "./comment-directives-TN0dNEbg.mjs";
|
|
6
6
|
import { Array, Cause, Effect, FileSystem, Function, HashMap, HashSet, Layer, Number as Number$1, Option, Order, Path, Predicate, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
7
7
|
import { ChildProcess } from "effect/process";
|
|
8
8
|
import { parse, resolveConfigFromFile } from "vite-plus";
|
|
9
|
-
import { LineCounter, Parser, isMap, isScalar, parse as parse$1, parseAllDocuments, parseDocument } from "yaml";
|
|
9
|
+
import { LineCounter, Parser, isMap, isPair, isScalar, isSeq, parse as parse$1, parseAllDocuments, parseDocument, visit } from "yaml";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import treeSitter from "@vscode/tree-sitter-wasm";
|
|
@@ -243,6 +243,7 @@ const nearestPackageDirectory = (directory, root) => Effect.gen(function* neares
|
|
|
243
243
|
if (hasManifest || directory === root || parent === directory) return directory;
|
|
244
244
|
return yield* nearestPackageDirectory(parent, root);
|
|
245
245
|
});
|
|
246
|
+
const packageDirectoryOf = (root) => (directory) => nearestPackageDirectory(directory, root);
|
|
246
247
|
const packageInfoOf = Effect.fn("packageInfoOf")(function* packageInfoOf(configPath, root) {
|
|
247
248
|
const files = yield* RepositoryFiles;
|
|
248
249
|
const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);
|
|
@@ -314,11 +315,65 @@ const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function*
|
|
|
314
315
|
const includesNeedle = String$1.includes(needle);
|
|
315
316
|
return pipe(texts, Array.some((text) => Option.exists(text, includesNeedle)));
|
|
316
317
|
});
|
|
318
|
+
// src/entities/project/model/inputs.ts
|
|
319
|
+
const SEPARATOR$6 = "/";
|
|
320
|
+
const encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
321
|
+
const nearestManifestDirectory = Effect.fn("nearestManifestDirectory")(function* nearestManifestDirectory(start) {
|
|
322
|
+
const files = yield* RepositoryFiles;
|
|
323
|
+
let directory = start;
|
|
324
|
+
let parent = files.dirname(directory);
|
|
325
|
+
while (parent !== directory && !(yield* files.exists(files.join(directory, "package.json")))) {
|
|
326
|
+
directory = parent;
|
|
327
|
+
parent = files.dirname(directory);
|
|
328
|
+
}
|
|
329
|
+
return directory;
|
|
330
|
+
});
|
|
331
|
+
const dependenciesOf = Effect.fn("dependenciesOf")(function* dependenciesOf(directory) {
|
|
332
|
+
const files = yield* RepositoryFiles;
|
|
333
|
+
const manifest = yield* readManifest(directory);
|
|
334
|
+
const names = Option.match(manifest, {
|
|
335
|
+
onNone: () => [],
|
|
336
|
+
onSome: workspaceDependencies
|
|
337
|
+
});
|
|
338
|
+
return yield* pipe(names, Effect.forEach((name) => files.realPath(files.join(directory, NODE_MODULES, name))));
|
|
339
|
+
});
|
|
340
|
+
const workspaceClosure = Effect.fn("workspaceClosure")(function* workspaceClosure(start) {
|
|
341
|
+
const seen = /* @__PURE__ */ new Set([start]);
|
|
342
|
+
const queue = [start];
|
|
343
|
+
for (const directory of queue) {
|
|
344
|
+
const next = yield* dependenciesOf(directory);
|
|
345
|
+
for (const dependency of next) if (!seen.has(dependency)) {
|
|
346
|
+
seen.add(dependency);
|
|
347
|
+
queue.push(dependency);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return [...seen];
|
|
351
|
+
});
|
|
352
|
+
const isUnder = (prefixes) => (file) => !String$1.includes(SEPARATOR$6)(file) || pipe(prefixes, Array.some((prefix) => String$1.startsWith(prefix)(file)));
|
|
353
|
+
const prefixesOf = Effect.fn("prefixesOf")(function* prefixesOf(root, configPath) {
|
|
354
|
+
const files = yield* RepositoryFiles;
|
|
355
|
+
const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));
|
|
356
|
+
const directories = yield* workspaceClosure(directory);
|
|
357
|
+
return pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$6}`));
|
|
358
|
+
});
|
|
359
|
+
const projectInputs = ({ workspace: { compiler, root }, listed }) => (configPath) => Effect.gen(function* collectInputs() {
|
|
360
|
+
const files = yield* RepositoryFiles;
|
|
361
|
+
const parsed = parseConfig(compiler.api)(configPath);
|
|
362
|
+
if (Option.isNone(parsed)) return Option.none();
|
|
363
|
+
const prefixes = yield* prefixesOf(root, configPath);
|
|
364
|
+
const options = yield* encodeOptions(parsed.value.options).pipe(Effect.orElseSucceed(() => ""));
|
|
365
|
+
const sources = pipe(parsed.value.fileNames, Array.map((fileName) => files.relative(root, fileName)));
|
|
366
|
+
const shared = pipe(listed, Array.filter(isUnder(prefixes)));
|
|
367
|
+
return Option.some({
|
|
368
|
+
options,
|
|
369
|
+
files: Array.sort(Array.dedupe([...sources, ...shared]), Order.String)
|
|
370
|
+
});
|
|
371
|
+
});
|
|
317
372
|
// src/shared/lib/text-position.ts
|
|
318
|
-
const START$
|
|
373
|
+
const START$7 = 0;
|
|
319
374
|
const FIRST_COLUMN$3 = 1;
|
|
320
375
|
const positionOf = (source) => (index) => {
|
|
321
|
-
const before = pipe(source, String$1.slice(START$
|
|
376
|
+
const before = pipe(source, String$1.slice(START$7, index), String$1.split("\n"));
|
|
322
377
|
return {
|
|
323
378
|
line: before.length,
|
|
324
379
|
column: pipe(Array.last(before), Option.match({
|
|
@@ -330,9 +385,9 @@ const positionOf = (source) => (index) => {
|
|
|
330
385
|
// src/features/install-size/model/import-graph.ts
|
|
331
386
|
const RELATIVE = /^\.\.?(?:\/|$)/u;
|
|
332
387
|
const SUBPATH_IMPORT = "#";
|
|
333
|
-
const WILDCARD = "*";
|
|
334
|
-
const SCOPE
|
|
335
|
-
const SEPARATOR$
|
|
388
|
+
const WILDCARD$1 = "*";
|
|
389
|
+
const SCOPE = "@";
|
|
390
|
+
const SEPARATOR$5 = "/";
|
|
336
391
|
const SOURCE_SUFFIXES = [
|
|
337
392
|
"",
|
|
338
393
|
".ts",
|
|
@@ -344,9 +399,9 @@ const PLAIN_SEGMENTS = 1;
|
|
|
344
399
|
const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Schema.String, Schema.String)) });
|
|
345
400
|
const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
|
|
346
401
|
const packageNameOf = (specifier) => {
|
|
347
|
-
const segments = String$1.split(specifier, SEPARATOR$
|
|
348
|
-
if (String$1.startsWith(SCOPE
|
|
349
|
-
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$
|
|
402
|
+
const segments = String$1.split(specifier, SEPARATOR$5);
|
|
403
|
+
if (String$1.startsWith(SCOPE)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS$1), Array.join(SEPARATOR$5));
|
|
404
|
+
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$5));
|
|
350
405
|
};
|
|
351
406
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
352
407
|
const runtimeSpecifierOf = (statement) => {
|
|
@@ -364,9 +419,9 @@ const specifiersIn = (api, file, text) => {
|
|
|
364
419
|
return Array.getSomes(found);
|
|
365
420
|
};
|
|
366
421
|
const subpathTarget = (imports, specifier) => pipe(Record.toEntries(imports), Array.findFirst(([pattern, target]) => {
|
|
367
|
-
if (!String$1.endsWith(WILDCARD)(pattern)) return Option.liftPredicate(target, () => pattern === specifier);
|
|
368
|
-
const prefix = String$1.replace(WILDCARD, "")(pattern);
|
|
369
|
-
return Option.liftPredicate(String$1.replace(WILDCARD, String$1.replace(prefix, "")(specifier))(target), () => String$1.startsWith(prefix)(specifier));
|
|
422
|
+
if (!String$1.endsWith(WILDCARD$1)(pattern)) return Option.liftPredicate(target, () => pattern === specifier);
|
|
423
|
+
const prefix = String$1.replace(WILDCARD$1, "")(pattern);
|
|
424
|
+
return Option.liftPredicate(String$1.replace(WILDCARD$1, String$1.replace(prefix, "")(specifier))(target), () => String$1.startsWith(prefix)(specifier));
|
|
370
425
|
}));
|
|
371
426
|
const existingSource = Effect.fn("existingSource")(function* existingSource(base) {
|
|
372
427
|
const files = yield* RepositoryFiles;
|
|
@@ -431,7 +486,7 @@ const packagesByEntry = Effect.fn("packagesByEntry")(function* packagesByEntry(a
|
|
|
431
486
|
}).pipe(Effect.map((packages) => [entry, packages]))));
|
|
432
487
|
});
|
|
433
488
|
// src/features/install-size/model/installed-closure.ts
|
|
434
|
-
const EMPTY = 0;
|
|
489
|
+
const EMPTY$1 = 0;
|
|
435
490
|
const DependencyMap = Schema.optional(Schema.Record(Schema.String, Schema.String));
|
|
436
491
|
const PeerMetaEntry = Schema.Struct({ optional: Schema.optional(Schema.Boolean) });
|
|
437
492
|
const PeerMeta = Schema.optional(Schema.Record(Schema.String, PeerMetaEntry));
|
|
@@ -490,7 +545,7 @@ const directorySize = (directory) => Effect.gen(function* sizeOfDirectory() {
|
|
|
490
545
|
const names = yield* files.readDirectory(directory);
|
|
491
546
|
const entries = pipe(names, Array.filter((name) => name !== NODE_MODULES), Array.map((name) => files.join(directory, name)));
|
|
492
547
|
const sizes = yield* pipe(entries, Effect.forEach((entry) => files.isDirectory(entry).pipe(Effect.flatMap((kind) => {
|
|
493
|
-
if (Option.isNone(kind)) return Effect.succeed(EMPTY);
|
|
548
|
+
if (Option.isNone(kind)) return Effect.succeed(EMPTY$1);
|
|
494
549
|
if (kind.value) return directorySize(entry);
|
|
495
550
|
return files.fileSize(entry);
|
|
496
551
|
}))));
|
|
@@ -502,7 +557,7 @@ const installedClosure = ({ provided, from, name }) => closureOf(provided, {
|
|
|
502
557
|
});
|
|
503
558
|
const installedSize = (directory) => {
|
|
504
559
|
if (String$1.includes(`/node_modules/`)(directory)) return directorySize(directory);
|
|
505
|
-
return Effect.succeed(EMPTY);
|
|
560
|
+
return Effect.succeed(EMPTY$1);
|
|
506
561
|
};
|
|
507
562
|
// src/features/install-size/model/install-size.ts
|
|
508
563
|
const INSTALL_SIZE = "install-size";
|
|
@@ -514,11 +569,11 @@ const LISTED_LARGEST = 5;
|
|
|
514
569
|
const SIZE_CONCURRENCY = 32;
|
|
515
570
|
const MEGABYTE = 1e6;
|
|
516
571
|
const MEGABYTE_DIGITS = 1;
|
|
517
|
-
const START$
|
|
572
|
+
const START$6 = 0;
|
|
518
573
|
const SINGLE_ENTRY = 1;
|
|
519
574
|
const megabytes = (bytes) => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;
|
|
520
575
|
const usageHint = (dependency, entryCount) => {
|
|
521
|
-
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$
|
|
576
|
+
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$6 && dependency.entries.length < entryCount)) return "";
|
|
522
577
|
return ` (imported only from ${Array.join(dependency.entries, ", ")})`;
|
|
523
578
|
};
|
|
524
579
|
const listed = ({ largest, entryCount }) => pipe(largest, Array.map((dependency) => `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`), Array.join(", "));
|
|
@@ -527,7 +582,7 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
|
|
|
527
582
|
const { workspace, total } = overrun;
|
|
528
583
|
const config = yield* files.readFile(workspace.configFile);
|
|
529
584
|
const source = Option.getOrElse(config, () => "");
|
|
530
|
-
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$
|
|
585
|
+
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$6);
|
|
531
586
|
return {
|
|
532
587
|
file: workspace.configFile,
|
|
533
588
|
...positionOf(source)(index),
|
|
@@ -544,7 +599,7 @@ const measure = Effect.fn("measure")(function* measure({ workspace, provided },
|
|
|
544
599
|
const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
|
|
545
600
|
const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
|
|
546
601
|
const sizes = HashMap.fromIterable(measured);
|
|
547
|
-
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$
|
|
602
|
+
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$6))));
|
|
548
603
|
return {
|
|
549
604
|
closures,
|
|
550
605
|
sizeOf,
|
|
@@ -577,11 +632,11 @@ const sizeProblems = Effect.fn("sizeProblems")(function* sizeProblems(published,
|
|
|
577
632
|
})];
|
|
578
633
|
});
|
|
579
634
|
const stackProblems = (file, source, dependencies) => {
|
|
580
|
-
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$
|
|
635
|
+
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$6);
|
|
581
636
|
const rest = String$1.slice(section)(source);
|
|
582
637
|
return pipe(Record.toEntries(dependencies), Array.filter(([, specifier]) => specifier === STACK_CATALOG), Array.map(([name]) => ({
|
|
583
638
|
file,
|
|
584
|
-
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$
|
|
639
|
+
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$6)),
|
|
585
640
|
rule: STACK_DEPENDENCY,
|
|
586
641
|
message: `${name} comes from the stack catalog, so every project that installs this package already has it. Move it to peerDependencies and keep it in devDependencies, so the installing project shares one copy.`
|
|
587
642
|
})));
|
|
@@ -920,14 +975,42 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
|
|
|
920
975
|
if (Option.isNone(manifest) || !Array.isReadonlyArrayNonEmpty(keys)) return [];
|
|
921
976
|
return yield* problemsFor(root, manifest.value, keys);
|
|
922
977
|
});
|
|
978
|
+
// src/features/placement/model/agent-docs-length.ts
|
|
979
|
+
const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
|
|
980
|
+
const RECOMMENDED_LINES = 200;
|
|
981
|
+
const READ_CONCURRENCY$12 = 16;
|
|
982
|
+
const FIRST$7 = 1;
|
|
983
|
+
const RULE$12 = "agent-docs-length";
|
|
984
|
+
const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
|
|
985
|
+
const problemFor$4 = (file) => (lines) => {
|
|
986
|
+
if (lines <= RECOMMENDED_LINES) return Option.none();
|
|
987
|
+
return Option.some({
|
|
988
|
+
file,
|
|
989
|
+
line: 201,
|
|
990
|
+
column: FIRST$7,
|
|
991
|
+
rule: RULE$12,
|
|
992
|
+
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.`
|
|
993
|
+
});
|
|
994
|
+
};
|
|
995
|
+
/** @internal */
|
|
996
|
+
const checkAgentDocsLength = Effect.fn("checkAgentDocsLength")(function* checkAgentDocsLength(root) {
|
|
997
|
+
const files = yield* RepositoryFiles;
|
|
998
|
+
const listed = yield* files.listedFiles(root);
|
|
999
|
+
const docs = pipe(listed, Array.filter((name) => AGENT_DOC.test(name)));
|
|
1000
|
+
const found = yield* Effect.forEach(docs, (name) => {
|
|
1001
|
+
const file = files.join(root, name);
|
|
1002
|
+
return files.readFile(file).pipe(Effect.map(Option.flatMap((source) => problemFor$4(file)(lineCount(source)))));
|
|
1003
|
+
}, { concurrency: READ_CONCURRENCY$12 });
|
|
1004
|
+
return Array.getSomes(found);
|
|
1005
|
+
});
|
|
923
1006
|
// src/features/placement/model/colocated-tests.ts
|
|
924
|
-
const RULE$
|
|
925
|
-
const FIRST$
|
|
926
|
-
const READ_CONCURRENCY$
|
|
1007
|
+
const RULE$11 = "colocated-test";
|
|
1008
|
+
const FIRST$6 = 1;
|
|
1009
|
+
const READ_CONCURRENCY$11 = 64;
|
|
927
1010
|
const ROOT_SUBPATH = ".";
|
|
928
1011
|
const NAME_GROUP = "name";
|
|
929
1012
|
const SPECIFIER_GROUP = "specifier";
|
|
930
|
-
const SCRIPT = /\.[cm]?[jt]sx?$/u;
|
|
1013
|
+
const SCRIPT$1 = /\.[cm]?[jt]sx?$/u;
|
|
931
1014
|
const TEST_FILE = /\.test\.[cm]?[jt]sx?$/u;
|
|
932
1015
|
const MANIFEST_NAME = /package\.json$/u;
|
|
933
1016
|
const SEPARATE_TEST_DIRECTORY = /(?:^|\/)(?:__tests__|__mocks__|tests?|specs?)\//u;
|
|
@@ -943,15 +1026,15 @@ const Manifest = Schema.Struct({
|
|
|
943
1026
|
});
|
|
944
1027
|
const decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));
|
|
945
1028
|
const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
946
|
-
const problemFor$
|
|
1029
|
+
const problemFor$3 = (test, message) => ({
|
|
947
1030
|
file: test.file,
|
|
948
|
-
line: FIRST$
|
|
949
|
-
column: FIRST$
|
|
950
|
-
rule: RULE$
|
|
1031
|
+
line: FIRST$6,
|
|
1032
|
+
column: FIRST$6,
|
|
1033
|
+
rule: RULE$11,
|
|
951
1034
|
message: `${test.base} ${message}`
|
|
952
1035
|
});
|
|
953
|
-
const groupsOf = (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);
|
|
954
|
-
const namesSibling = (source) => pipe([...groupsOf(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE.test(name)));
|
|
1036
|
+
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);
|
|
1037
|
+
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)));
|
|
955
1038
|
const ownerOf$1 = (packages, name) => {
|
|
956
1039
|
const owners = pipe(packages, Array.filter((directory) => String$1.startsWith(directory)(name)));
|
|
957
1040
|
return Array.last(Array.sort(owners, byLength));
|
|
@@ -975,7 +1058,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
|
|
|
975
1058
|
});
|
|
976
1059
|
const refersToOwnDirectory = Effect.fn("refersToOwnDirectory")(function* refersToOwnDirectory(context, test, source) {
|
|
977
1060
|
if (namesSibling(source)) return true;
|
|
978
|
-
const specifiers = groupsOf(source, MODULE_SPECIFIER, SPECIFIER_GROUP);
|
|
1061
|
+
const specifiers = groupsOf$1(source, MODULE_SPECIFIER, SPECIFIER_GROUP);
|
|
979
1062
|
if (Array.isReadonlyArrayEmpty(specifiers)) return false;
|
|
980
1063
|
const own = yield* ownSpecifiers(context, test);
|
|
981
1064
|
return pipe(specifiers, Array.some((specifier) => pipe(own, Array.contains(specifier))));
|
|
@@ -986,10 +1069,10 @@ const refersIn = Effect.fn("refersIn")(function* refersIn(context, test) {
|
|
|
986
1069
|
return yield* refersToOwnDirectory(context, test, source.value);
|
|
987
1070
|
});
|
|
988
1071
|
const problemIn$3 = Effect.fn("problemIn")(function* problemIn(context, test) {
|
|
989
|
-
if (SEPARATE_TEST_DIRECTORY.test(test.name)) return Option.some(problemFor$
|
|
1072
|
+
if (SEPARATE_TEST_DIRECTORY.test(test.name)) return Option.some(problemFor$3(test, DIRECTORY_MESSAGE));
|
|
990
1073
|
if (!TEST_FILE.test(test.name)) return Option.none();
|
|
991
1074
|
if (yield* refersIn(context, test)) return Option.none();
|
|
992
|
-
return Option.some(problemFor$
|
|
1075
|
+
return Option.some(problemFor$3(test, SIBLING_MESSAGE));
|
|
993
1076
|
});
|
|
994
1077
|
/** @internal */
|
|
995
1078
|
const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColocatedTests(root) {
|
|
@@ -1000,7 +1083,7 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1000
1083
|
root,
|
|
1001
1084
|
packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map(String$1.replace(MANIFEST_NAME, "")))
|
|
1002
1085
|
};
|
|
1003
|
-
const tests = pipe(names, Array.filter((name) => SCRIPT.test(name)), Array.map((name) => {
|
|
1086
|
+
const tests = pipe(names, Array.filter((name) => SCRIPT$1.test(name)), Array.map((name) => {
|
|
1004
1087
|
const file = files.join(root, name);
|
|
1005
1088
|
return {
|
|
1006
1089
|
name,
|
|
@@ -1009,40 +1092,40 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1009
1092
|
directory: files.dirname(file)
|
|
1010
1093
|
};
|
|
1011
1094
|
}));
|
|
1012
|
-
const found = yield* Effect.forEach(tests, (test) => problemIn$3(context, test), { concurrency: READ_CONCURRENCY$
|
|
1095
|
+
const found = yield* Effect.forEach(tests, (test) => problemIn$3(context, test), { concurrency: READ_CONCURRENCY$11 });
|
|
1013
1096
|
return Array.getSomes(found);
|
|
1014
1097
|
});
|
|
1015
1098
|
// src/features/placement/model/nested-docs.ts
|
|
1016
|
-
const RULE$
|
|
1099
|
+
const RULE$10 = "nested-docs";
|
|
1017
1100
|
const CONFIG_FILE$4 = "vite.config.ts";
|
|
1018
|
-
const SEPARATOR$
|
|
1019
|
-
const FIRST$
|
|
1020
|
-
const READ_CONCURRENCY$
|
|
1101
|
+
const SEPARATOR$4 = "/";
|
|
1102
|
+
const FIRST$5 = 1;
|
|
1103
|
+
const READ_CONCURRENCY$10 = 64;
|
|
1021
1104
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1022
1105
|
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
1023
|
-
const README
|
|
1106
|
+
const README = /^README(?:\.[^/]+)?$/iu;
|
|
1024
1107
|
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1025
1108
|
const taggedError$3 = Schema.TaggedError;
|
|
1026
1109
|
var RootConfigUnreadable = class extends taggedError$3()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1027
|
-
const isNested = (name) => String$1.includes(SEPARATOR$
|
|
1028
|
-
const problemFor$
|
|
1110
|
+
const isNested = (name) => String$1.includes(SEPARATOR$4)(name);
|
|
1111
|
+
const problemFor$2 = (file, message) => ({
|
|
1029
1112
|
file,
|
|
1030
|
-
line: FIRST$
|
|
1031
|
-
column: FIRST$
|
|
1032
|
-
rule: RULE$
|
|
1113
|
+
line: FIRST$5,
|
|
1114
|
+
column: FIRST$5,
|
|
1115
|
+
rule: RULE$10,
|
|
1033
1116
|
message
|
|
1034
1117
|
});
|
|
1035
1118
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
1036
1119
|
const WORKSPACE_AGENT_DOCS_MESSAGE = "belongs only at the repository root or as AGENTS.md directly in a workspace, the directory that holds its package.json. Move what agents need there and delete this file.";
|
|
1037
1120
|
const README_MESSAGE = "is allowed below the root only in a workspace, the directory that holds its package.json. Move it into the workspace it describes.";
|
|
1038
1121
|
const agentDocProblem = ({ file, base, directory }, allowed) => {
|
|
1039
|
-
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$
|
|
1122
|
+
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$2(file, `${base} ${AGENT_DOCS_MESSAGE}`));
|
|
1040
1123
|
if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1041
|
-
return Option.some(problemFor$
|
|
1124
|
+
return Option.some(problemFor$2(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
|
|
1042
1125
|
};
|
|
1043
1126
|
const readmeProblem = ({ file, base, directory }, allowed) => {
|
|
1044
|
-
if (!README
|
|
1045
|
-
return Option.some(problemFor$
|
|
1127
|
+
if (!README.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1128
|
+
return Option.some(problemFor$2(file, `${base} ${README_MESSAGE}`));
|
|
1046
1129
|
};
|
|
1047
1130
|
const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, allowed, name) {
|
|
1048
1131
|
const files = yield* RepositoryFiles;
|
|
@@ -1075,49 +1158,22 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
|
|
|
1075
1158
|
workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
|
|
1076
1159
|
workspaceAgentDocs
|
|
1077
1160
|
};
|
|
1078
|
-
const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$
|
|
1161
|
+
const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$10 });
|
|
1079
1162
|
return Array.getSomes(found);
|
|
1080
1163
|
});
|
|
1081
1164
|
// src/features/placement/model/root-readme.ts
|
|
1082
|
-
const RULE$
|
|
1083
|
-
const
|
|
1084
|
-
const
|
|
1085
|
-
const
|
|
1086
|
-
const
|
|
1087
|
-
const
|
|
1088
|
-
const READ_CONCURRENCY$6 = 16;
|
|
1089
|
-
const START$4 = 0;
|
|
1090
|
-
const NamedManifest = Schema.fromJsonString(Schema.Struct({ name: Schema.optional(Schema.String) }));
|
|
1091
|
-
const patternOf = (names) => {
|
|
1092
|
-
const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
|
|
1093
|
-
return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
|
|
1094
|
-
};
|
|
1095
|
-
const packageNameIn = (text) => pipe(text, Option.flatMap(Schema.decodeOption(NamedManifest)), Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)));
|
|
1096
|
-
const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(root, name) {
|
|
1097
|
-
const files = yield* RepositoryFiles;
|
|
1098
|
-
const directory = files.dirname(name);
|
|
1099
|
-
const text = yield* files.readFile(files.join(root, name));
|
|
1100
|
-
const packageName = packageNameIn(text);
|
|
1101
|
-
const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
|
|
1102
|
-
const names = pipe([
|
|
1103
|
-
Option.some(directory),
|
|
1104
|
-
Option.some(files.basename(directory)),
|
|
1105
|
-
packageName,
|
|
1106
|
-
unscoped
|
|
1107
|
-
], Array.getSomes, Array.dedupe);
|
|
1108
|
-
return {
|
|
1109
|
-
directory,
|
|
1110
|
-
pattern: patternOf(names)
|
|
1111
|
-
};
|
|
1112
|
-
});
|
|
1113
|
-
const messageFor = (directory) => `names the workspace ${directory}. The root README describes the repository as a whole. Write what belongs to the workspace in ${directory}/README.md.`;
|
|
1114
|
-
const problemsIn$2 = (file, source) => ({ directory, pattern }) => {
|
|
1165
|
+
const RULE$9 = "root-readme";
|
|
1166
|
+
const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
|
|
1167
|
+
const READ_CONCURRENCY$9 = 16;
|
|
1168
|
+
const START$5 = 0;
|
|
1169
|
+
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.`;
|
|
1170
|
+
const problemsIn$4 = (file, source) => ({ directory, pattern }) => {
|
|
1115
1171
|
const message = messageFor(directory);
|
|
1116
1172
|
const at = positionOf(source);
|
|
1117
1173
|
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1118
1174
|
file,
|
|
1119
|
-
...at(found.index ?? START$
|
|
1120
|
-
rule: RULE$
|
|
1175
|
+
...at(found.index ?? START$5),
|
|
1176
|
+
rule: RULE$9,
|
|
1121
1177
|
message
|
|
1122
1178
|
})));
|
|
1123
1179
|
};
|
|
@@ -1125,17 +1181,16 @@ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadm
|
|
|
1125
1181
|
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1126
1182
|
return pipe(text, Option.match({
|
|
1127
1183
|
onNone: () => [],
|
|
1128
|
-
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$
|
|
1184
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$4(file, source)))
|
|
1129
1185
|
}));
|
|
1130
1186
|
});
|
|
1131
1187
|
/** @internal */
|
|
1132
1188
|
const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(root) {
|
|
1133
1189
|
const files = yield* RepositoryFiles;
|
|
1134
1190
|
const names = yield* files.listedFiles(root);
|
|
1135
|
-
const readmes = pipe(names, Array.filter((name) =>
|
|
1136
|
-
const
|
|
1137
|
-
const
|
|
1138
|
-
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$6 });
|
|
1191
|
+
const readmes = pipe(names, Array.filter((name) => ROOT_DOC.test(name)));
|
|
1192
|
+
const workspaces = yield* namedWorkspaces(root);
|
|
1193
|
+
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$9 });
|
|
1139
1194
|
return Array.flatten(found);
|
|
1140
1195
|
});
|
|
1141
1196
|
// src/features/placement/model/placement-checks.ts
|
|
@@ -1144,17 +1199,18 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
|
|
|
1144
1199
|
const found = yield* Effect.all([
|
|
1145
1200
|
checkNestedDocs(root),
|
|
1146
1201
|
checkRootReadme(root),
|
|
1147
|
-
checkColocatedTests(root)
|
|
1202
|
+
checkColocatedTests(root),
|
|
1203
|
+
checkAgentDocsLength(root)
|
|
1148
1204
|
], { concurrency: "unbounded" });
|
|
1149
1205
|
return Array.flatten(found);
|
|
1150
1206
|
});
|
|
1151
1207
|
// src/features/repository-layout/model/crates.ts
|
|
1152
|
-
const RULE$
|
|
1208
|
+
const RULE$8 = "unverified-crate";
|
|
1153
1209
|
const CARGO_FILE = "Cargo.toml";
|
|
1154
1210
|
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1155
|
-
const SEPARATOR$
|
|
1156
|
-
const FIRST$
|
|
1157
|
-
const READ_CONCURRENCY$
|
|
1211
|
+
const SEPARATOR$3 = "/";
|
|
1212
|
+
const FIRST$4 = 1;
|
|
1213
|
+
const READ_CONCURRENCY$8 = 8;
|
|
1158
1214
|
const CrateEntry = Schema.Struct({
|
|
1159
1215
|
name: Schema.String,
|
|
1160
1216
|
manifest_path: Schema.String
|
|
@@ -1180,22 +1236,22 @@ const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
|
1180
1236
|
})));
|
|
1181
1237
|
}, Effect.scoped);
|
|
1182
1238
|
const owningWorkspace = (directories) => (directory) => {
|
|
1183
|
-
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$
|
|
1239
|
+
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$3}`)(directory)));
|
|
1184
1240
|
return Array.last(Array.sort(owners, String$1.Order));
|
|
1185
1241
|
};
|
|
1186
|
-
const problemFor = (crate, message) => ({
|
|
1242
|
+
const problemFor$1 = (crate, message) => ({
|
|
1187
1243
|
file: crate.manifest,
|
|
1188
|
-
line: FIRST$
|
|
1189
|
-
column: FIRST$
|
|
1190
|
-
rule: RULE$
|
|
1244
|
+
line: FIRST$4,
|
|
1245
|
+
column: FIRST$4,
|
|
1246
|
+
rule: RULE$8,
|
|
1191
1247
|
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
1192
1248
|
});
|
|
1193
1249
|
const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
1194
1250
|
const files = yield* RepositoryFiles;
|
|
1195
1251
|
const workspace = owningWorkspace(directories)(files.relative(root, files.dirname(crate.manifest)));
|
|
1196
|
-
if (Option.isNone(workspace)) return Option.some(problemFor(crate, "is outside every workspace package"));
|
|
1252
|
+
if (Option.isNone(workspace)) return Option.some(problemFor$1(crate, "is outside every workspace package"));
|
|
1197
1253
|
if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$3))) return Option.none();
|
|
1198
|
-
return Option.some(problemFor(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$3} has no verify task`));
|
|
1254
|
+
return Option.some(problemFor$1(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$3} has no verify task`));
|
|
1199
1255
|
});
|
|
1200
1256
|
/** @internal */
|
|
1201
1257
|
const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
@@ -1203,14 +1259,14 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
|
1203
1259
|
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
1204
1260
|
const directories = yield* workspaceDirectories(root);
|
|
1205
1261
|
const crates = yield* cratesIn(root);
|
|
1206
|
-
const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$
|
|
1262
|
+
const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$8 });
|
|
1207
1263
|
return Array.getSomes(found);
|
|
1208
1264
|
});
|
|
1209
1265
|
// src/features/repository-layout/model/hidden-verify.ts
|
|
1210
|
-
const RULE$
|
|
1266
|
+
const RULE$7 = "hidden-verify";
|
|
1211
1267
|
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1212
|
-
const FIRST$
|
|
1213
|
-
const READ_CONCURRENCY$
|
|
1268
|
+
const FIRST$3 = 1;
|
|
1269
|
+
const READ_CONCURRENCY$7 = 8;
|
|
1214
1270
|
const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
1215
1271
|
const config = yield* workspaceConfigOf(root, directory);
|
|
1216
1272
|
if (Option.isNone(config)) return Option.none();
|
|
@@ -1219,24 +1275,24 @@ const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
|
1219
1275
|
const verified = yield* hasVerifyTask(file);
|
|
1220
1276
|
return Option.some({
|
|
1221
1277
|
file,
|
|
1222
|
-
line: FIRST$
|
|
1223
|
-
column: FIRST$
|
|
1224
|
-
rule: RULE$
|
|
1278
|
+
line: FIRST$3,
|
|
1279
|
+
column: FIRST$3,
|
|
1280
|
+
rule: RULE$7,
|
|
1225
1281
|
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}.`
|
|
1226
1282
|
}).pipe(Option.filter(() => verified));
|
|
1227
1283
|
});
|
|
1228
1284
|
/** @internal */
|
|
1229
1285
|
const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVerify(root) {
|
|
1230
1286
|
const directories = yield* workspaceDirectories(root);
|
|
1231
|
-
const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY$
|
|
1287
|
+
const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY$7 });
|
|
1232
1288
|
return Array.getSomes(found);
|
|
1233
1289
|
});
|
|
1234
1290
|
// src/features/repository-layout/model/root-workspace-paths.ts
|
|
1235
|
-
const RULE$
|
|
1291
|
+
const RULE$6 = "root-workspace-path";
|
|
1236
1292
|
const CONFIG_FILE$1 = "vite.config.ts";
|
|
1237
1293
|
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
1238
1294
|
const NAME_CHARACTER = /[\w.@-]/u;
|
|
1239
|
-
const FIRST = 0;
|
|
1295
|
+
const FIRST$2 = 0;
|
|
1240
1296
|
const NEXT$2 = 1;
|
|
1241
1297
|
const StringNode = Schema.Union([Schema.Struct({
|
|
1242
1298
|
type: Schema.Literal("Literal"),
|
|
@@ -1264,14 +1320,14 @@ const mentions = (directory) => (text) => {
|
|
|
1264
1320
|
return pipe(Array.drop(parts, NEXT$2), Array.some((after, index) => {
|
|
1265
1321
|
const before = parts[index] ?? "";
|
|
1266
1322
|
const previous = String$1.slice(before.length - NEXT$2)(before);
|
|
1267
|
-
const following = String$1.slice(FIRST, NEXT$2)(after);
|
|
1323
|
+
const following = String$1.slice(FIRST$2, NEXT$2)(after);
|
|
1268
1324
|
return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
|
|
1269
1325
|
}));
|
|
1270
1326
|
};
|
|
1271
|
-
const problemsIn$
|
|
1327
|
+
const problemsIn$3 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
1272
1328
|
file,
|
|
1273
1329
|
...positionOf(source)(found.start),
|
|
1274
|
-
rule: RULE$
|
|
1330
|
+
rule: RULE$6,
|
|
1275
1331
|
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.`
|
|
1276
1332
|
})));
|
|
1277
1333
|
/** @internal */
|
|
@@ -1282,12 +1338,12 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
|
|
|
1282
1338
|
if (Option.isNone(source)) return [];
|
|
1283
1339
|
const directories = yield* workspaceDirectories(root);
|
|
1284
1340
|
const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: "ts" }));
|
|
1285
|
-
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$
|
|
1341
|
+
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$3(file, source.value, directories)));
|
|
1286
1342
|
});
|
|
1287
1343
|
// src/features/repository-layout/model/shared-uncached-tasks.ts
|
|
1288
|
-
const RULE$
|
|
1344
|
+
const RULE$5 = "shared-uncached-task";
|
|
1289
1345
|
const TASKS_PATH = ["run", "tasks"];
|
|
1290
|
-
const READ_CONCURRENCY$
|
|
1346
|
+
const READ_CONCURRENCY$6 = 8;
|
|
1291
1347
|
const SHARED = 2;
|
|
1292
1348
|
const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
|
|
1293
1349
|
const TaskProperty = Schema.Struct({
|
|
@@ -1309,12 +1365,12 @@ const decodeTaskProperty = Schema.decodeUnknownOption(TaskProperty);
|
|
|
1309
1365
|
const decodeTaskObject = Schema.decodeUnknownOption(TaskObject);
|
|
1310
1366
|
const decodeUncachedTask = Schema.decodeUnknownOption(UncachedTask);
|
|
1311
1367
|
const encodeDefinition = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));
|
|
1312
|
-
const commandText = (command) => Array.join(Array.ensure(command), " && ");
|
|
1368
|
+
const commandText$1 = (command) => Array.join(Array.ensure(command), " && ");
|
|
1313
1369
|
const runsOwnProgram = (command) => pipe(String$1.trim(command), String$1.split(/\s+/u), Array.head, Option.exists((program) => OWN_PROGRAM.test(program)));
|
|
1314
1370
|
const definitionOf = ({ directory, file, source }) => (task) => Option.gen(function* uncachedDefinition() {
|
|
1315
1371
|
const literal = yield* literalOf(task.value);
|
|
1316
1372
|
const { command } = yield* decodeUncachedTask(literal);
|
|
1317
|
-
const text = commandText(command);
|
|
1373
|
+
const text = commandText$1(command);
|
|
1318
1374
|
if (runsOwnProgram(text)) return yield* Option.none();
|
|
1319
1375
|
const definition = yield* encodeDefinition(literal);
|
|
1320
1376
|
return {
|
|
@@ -1342,16 +1398,236 @@ const problemsOf = (definitions) => {
|
|
|
1342
1398
|
return pipe(definitions, Array.map(({ file, position, name, command }) => ({
|
|
1343
1399
|
file,
|
|
1344
1400
|
...position,
|
|
1345
|
-
rule: RULE$
|
|
1401
|
+
rule: RULE$5,
|
|
1346
1402
|
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.`
|
|
1347
1403
|
})));
|
|
1348
1404
|
};
|
|
1349
1405
|
/** @internal */
|
|
1350
1406
|
const checkSharedUncachedTasks = Effect.fn("checkSharedUncachedTasks")(function* checkSharedUncachedTasks(root) {
|
|
1351
1407
|
const directories = yield* workspaceDirectories(root);
|
|
1352
|
-
const found = yield* Effect.forEach(directories, (directory) => definitionsIn(root, directory), { concurrency: READ_CONCURRENCY$
|
|
1408
|
+
const found = yield* Effect.forEach(directories, (directory) => definitionsIn(root, directory), { concurrency: READ_CONCURRENCY$6 });
|
|
1353
1409
|
return pipe(Array.flatten(found), Array.groupBy(({ name, definition }) => `${name}\u0000${definition}`), Record.values, Array.flatMap(problemsOf));
|
|
1354
1410
|
});
|
|
1411
|
+
// src/features/repository-layout/model/workflow-nodes.ts
|
|
1412
|
+
const MISSING_OFFSET = 0;
|
|
1413
|
+
const isRanged = (node) => isScalar(node) || isMap(node) || isSeq(node);
|
|
1414
|
+
/** @internal */
|
|
1415
|
+
const isText$1 = (node) => isScalar(node) && typeof node.value === "string";
|
|
1416
|
+
const isTextPair = (pair) => isPair(pair) && isText$1(pair.key);
|
|
1417
|
+
const offsetOf = (node) => pipe(Option.liftPredicate(node, isRanged), Option.flatMap((ranged) => Option.fromNullishOr(ranged.range)), Option.map(([start]) => start), Option.getOrElse(() => MISSING_OFFSET));
|
|
1418
|
+
/** @internal */
|
|
1419
|
+
const stringOf = (node) => pipe(Option.liftPredicate(node, isText$1), Option.map((scalar) => ({
|
|
1420
|
+
text: scalar.value,
|
|
1421
|
+
offset: offsetOf(scalar)
|
|
1422
|
+
})));
|
|
1423
|
+
/** @internal */
|
|
1424
|
+
const childOf = (key) => (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => map.get(key, true)), Option.getOrUndefined);
|
|
1425
|
+
/** @internal */
|
|
1426
|
+
const workingDirectoryOf = (owner) => {
|
|
1427
|
+
const run = childOf("run")(childOf("defaults")(owner));
|
|
1428
|
+
return stringOf(childOf("working-directory")(run));
|
|
1429
|
+
};
|
|
1430
|
+
/** @internal */
|
|
1431
|
+
const itemsOf = (node) => pipe(Option.liftPredicate(node, isSeq), Option.map((seq) => seq.items), Option.getOrElse(() => []));
|
|
1432
|
+
const pairsOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => map.items), Option.getOrElse(() => []));
|
|
1433
|
+
/** @internal */
|
|
1434
|
+
const entriesOf = (node) => pipe(pairsOf(node), Array.filter(isTextPair), Array.map((pair) => [pair.key.value, pair.value]));
|
|
1435
|
+
/** @internal */
|
|
1436
|
+
const scalarsIn = (source) => {
|
|
1437
|
+
const found = [];
|
|
1438
|
+
visit(parseDocument(source), { Scalar: (_key, node) => {
|
|
1439
|
+
found.push(...Option.toArray(stringOf(node)));
|
|
1440
|
+
} });
|
|
1441
|
+
return found;
|
|
1442
|
+
};
|
|
1443
|
+
// src/features/repository-layout/model/workflow-references.ts
|
|
1444
|
+
const ROOT = ".";
|
|
1445
|
+
const LOCAL = "./";
|
|
1446
|
+
const NEGATION = "!";
|
|
1447
|
+
const SEPARATOR$2 = "/";
|
|
1448
|
+
const LINE = "\n";
|
|
1449
|
+
const UNRESOLVED_MARKERS = [
|
|
1450
|
+
"${{",
|
|
1451
|
+
"$",
|
|
1452
|
+
"{"
|
|
1453
|
+
];
|
|
1454
|
+
const ABSOLUTE_MARKERS = ["/", "~"];
|
|
1455
|
+
const FILE_INPUT_SUFFIX = "-file";
|
|
1456
|
+
const DEPENDENCY_PATH_INPUT = "cache-dependency-path";
|
|
1457
|
+
const FILTER_KEYS = ["paths", "paths-ignore"];
|
|
1458
|
+
const HASH_FILES = /hashFiles\((?<arguments>[^)]*)\)/gu;
|
|
1459
|
+
const QUOTED$1 = /'(?<path>[^']*)'/gu;
|
|
1460
|
+
const SCRIPT = /^[\w.@/-]+\.(?:ts|mts|cts|sh)$/u;
|
|
1461
|
+
const TOKEN_SEPARATOR = /[\s;&|()<>"'`=]+/u;
|
|
1462
|
+
/** @internal */
|
|
1463
|
+
const ACTION_DEFINITIONS = ["action.yml", "action.yaml"];
|
|
1464
|
+
const containsAny = (markers) => (path) => pipe(markers, Array.some((marker) => String$1.includes(marker)(path)));
|
|
1465
|
+
const startsWithAny = (markers) => (path) => pipe(markers, Array.some((marker) => String$1.startsWith(marker)(path)));
|
|
1466
|
+
const isLiteralPath = (path) => String$1.isNonEmpty(path) && !containsAny(UNRESOLVED_MARKERS)(path) && !startsWithAny(ABSOLUTE_MARKERS)(path);
|
|
1467
|
+
const withoutLocal = (path) => {
|
|
1468
|
+
if (String$1.startsWith(LOCAL)(path)) return String$1.slice(2)(path);
|
|
1469
|
+
return path;
|
|
1470
|
+
};
|
|
1471
|
+
const joinPath = (base, path) => {
|
|
1472
|
+
const relative = withoutLocal(String$1.trim(path));
|
|
1473
|
+
if (base === ROOT) return relative;
|
|
1474
|
+
return `${base}${SEPARATOR$2}${relative}`;
|
|
1475
|
+
};
|
|
1476
|
+
const reference = (kind, field, base = ROOT) => ({ text, offset }) => {
|
|
1477
|
+
const path = String$1.trim(text);
|
|
1478
|
+
if (!isLiteralPath(path) || !isLiteralPath(base)) return [];
|
|
1479
|
+
return [{
|
|
1480
|
+
kind,
|
|
1481
|
+
field,
|
|
1482
|
+
path: joinPath(base, path),
|
|
1483
|
+
offset
|
|
1484
|
+
}];
|
|
1485
|
+
};
|
|
1486
|
+
const isPositive = ({ text }) => !String$1.startsWith(NEGATION)(String$1.trim(text));
|
|
1487
|
+
const globsIn = (field, node) => pipe(itemsOf(node), Array.flatMap((item) => Option.toArray(stringOf(item))), Array.filter(isPositive), Array.flatMap(reference("glob", field)));
|
|
1488
|
+
const filtersOf = ([event, filters]) => pipe(FILTER_KEYS, Array.flatMap((key) => globsIn(`on.${event}.${key}`, childOf(key)(filters))));
|
|
1489
|
+
const directoryOf$1 = (located, base) => pipe(located, Option.map(({ text }) => joinPath(ROOT, text)), Option.getOrElse(() => base));
|
|
1490
|
+
const located = (kind, field, base = ROOT) => (found) => pipe(found, Option.toArray, Array.flatMap(reference(kind, field, base)));
|
|
1491
|
+
const localUses = (node) => pipe(stringOf(childOf("uses")(node)), Option.filter(({ text }) => String$1.startsWith(LOCAL)(text)));
|
|
1492
|
+
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)({
|
|
1493
|
+
text: token,
|
|
1494
|
+
offset
|
|
1495
|
+
})));
|
|
1496
|
+
const isFileInput = ([key]) => String$1.endsWith(FILE_INPUT_SUFFIX)(key) || key === DEPENDENCY_PATH_INPUT;
|
|
1497
|
+
const linesOf = ({ text, offset }) => pipe(String$1.split(text, LINE), Array.map((line) => ({
|
|
1498
|
+
text: line,
|
|
1499
|
+
offset
|
|
1500
|
+
})));
|
|
1501
|
+
const fileInputOf = (field) => ([key, value]) => pipe(stringOf(value), Option.toArray, Array.flatMap(linesOf), Array.flatMap(reference("glob", `${field}.with.${key}`)));
|
|
1502
|
+
const fileInputsIn = (field, step) => pipe(entriesOf(childOf("with")(step)), Array.filter(isFileInput), Array.flatMap(fileInputOf(field)));
|
|
1503
|
+
const stepReferences = (job, base) => (step, index) => {
|
|
1504
|
+
const field = `jobs.${job}.steps[${index}]`;
|
|
1505
|
+
const own = stringOf(childOf("working-directory")(step));
|
|
1506
|
+
const directory = directoryOf$1(own, base);
|
|
1507
|
+
return [
|
|
1508
|
+
...located("action", `${field}.uses`)(localUses(step)),
|
|
1509
|
+
...located("directory", `${field}.working-directory`)(own),
|
|
1510
|
+
...pipe(stringOf(childOf("run")(step)), Option.toArray, Array.flatMap(scriptsIn(`${field}.run`, directory))),
|
|
1511
|
+
...fileInputsIn(field, step)
|
|
1512
|
+
];
|
|
1513
|
+
};
|
|
1514
|
+
const jobReferences = (base) => ([job, node]) => {
|
|
1515
|
+
const own = workingDirectoryOf(node);
|
|
1516
|
+
const steps = itemsOf(childOf("steps")(node));
|
|
1517
|
+
const directory = directoryOf$1(own, base);
|
|
1518
|
+
return [
|
|
1519
|
+
...located("file", `jobs.${job}.uses`)(localUses(node)),
|
|
1520
|
+
...located("directory", `jobs.${job}.defaults.run.working-directory`)(own),
|
|
1521
|
+
...pipe(steps, Array.flatMap(stepReferences(job, directory)))
|
|
1522
|
+
];
|
|
1523
|
+
};
|
|
1524
|
+
const groupsOf = (pattern, group) => ({ text, offset }) => pipe(Array.fromIterable(String$1.matchAll(pattern)(text)), Array.flatMap((match) => pipe(Option.fromNullishOr(match.groups), Option.flatMap((groups) => Option.fromNullishOr(groups[group])), Option.toArray)), Array.map((value) => ({
|
|
1525
|
+
text: value,
|
|
1526
|
+
offset
|
|
1527
|
+
})));
|
|
1528
|
+
const hashFilesIn = (source) => pipe(scalarsIn(source), Array.flatMap(groupsOf(HASH_FILES, "arguments")), Array.flatMap(groupsOf(QUOTED$1, "path")), Array.filter(isPositive), Array.flatMap(reference("glob", "hashFiles")));
|
|
1529
|
+
const jobsOf = (source) => entriesOf(childOf("jobs")(parseDocument(source).contents));
|
|
1530
|
+
/** @internal */
|
|
1531
|
+
const workflowReferences = (source) => {
|
|
1532
|
+
const root = parseDocument(source).contents;
|
|
1533
|
+
const workflowDefault = workingDirectoryOf(root);
|
|
1534
|
+
const base = directoryOf$1(workflowDefault, ROOT);
|
|
1535
|
+
return [
|
|
1536
|
+
...pipe(entriesOf(childOf("on")(root)), Array.flatMap(filtersOf)),
|
|
1537
|
+
...located("directory", "defaults.run.working-directory")(workflowDefault),
|
|
1538
|
+
...pipe(jobsOf(source), Array.flatMap(jobReferences(base))),
|
|
1539
|
+
...hashFilesIn(source)
|
|
1540
|
+
];
|
|
1541
|
+
};
|
|
1542
|
+
const pathInputOf = (step) => childOf("path")(childOf("with")(step));
|
|
1543
|
+
const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray, Array.flatMap(linesOf), Array.map(({ text }) => joinPath(ROOT, text)), Array.filter(isLiteralPath));
|
|
1544
|
+
/** @internal */
|
|
1545
|
+
const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
|
|
1546
|
+
// src/features/repository-layout/model/workflow-paths.ts
|
|
1547
|
+
const RULE$4 = "workflow-path";
|
|
1548
|
+
const WORKFLOW_DIRECTORY = ".github/workflows/";
|
|
1549
|
+
const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
|
|
1550
|
+
const READ_CONCURRENCY$5 = 8;
|
|
1551
|
+
const WILDCARD = /[*?[]/u;
|
|
1552
|
+
const SEPARATOR$1 = "/";
|
|
1553
|
+
const FIRST$1 = 0;
|
|
1554
|
+
const EXPECTED = {
|
|
1555
|
+
action: "a directory with action.yml",
|
|
1556
|
+
directory: "a directory",
|
|
1557
|
+
file: "a file",
|
|
1558
|
+
glob: "a pattern that matches a tracked file",
|
|
1559
|
+
script: "a file"
|
|
1560
|
+
};
|
|
1561
|
+
const isWorkflow = (file) => String$1.startsWith(WORKFLOW_DIRECTORY)(file) && pipe(WORKFLOW_EXTENSIONS, Array.some((extension) => String$1.endsWith(extension)(file)));
|
|
1562
|
+
const matchesAny = Effect.fn("matchesAny")(function* matchesAny(root, pathspecs) {
|
|
1563
|
+
const matched = yield* (yield* RepositoryFiles).matchingFiles(root, pathspecs);
|
|
1564
|
+
return Array.isReadonlyArrayNonEmpty(matched);
|
|
1565
|
+
});
|
|
1566
|
+
const existsAt = Effect.fn("existsAt")(function* existsAt(root, path) {
|
|
1567
|
+
const files = yield* RepositoryFiles;
|
|
1568
|
+
return yield* files.exists(files.join(root, path));
|
|
1569
|
+
});
|
|
1570
|
+
const matchesGlob = (root, path) => matchesAny(root, [`:(glob)${path}`]);
|
|
1571
|
+
const isDirectoryAt = Effect.fn("isDirectoryAt")(function* isDirectoryAt(root, path) {
|
|
1572
|
+
const files = yield* RepositoryFiles;
|
|
1573
|
+
const directory = yield* files.isDirectory(files.join(root, path));
|
|
1574
|
+
return Option.getOrElse(directory, () => false);
|
|
1575
|
+
});
|
|
1576
|
+
const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
|
|
1577
|
+
const found = yield* pipe(ACTION_DEFINITIONS, Effect.forEach((name) => existsAt(root, `${path}${SEPARATOR$1}${name}`)));
|
|
1578
|
+
return pipe(found, Array.some(Boolean));
|
|
1579
|
+
});
|
|
1580
|
+
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$1))}`;
|
|
1581
|
+
const RESOLVERS = {
|
|
1582
|
+
action: hasAction,
|
|
1583
|
+
directory: isDirectoryAt,
|
|
1584
|
+
file: existsAt,
|
|
1585
|
+
glob: matchesGlob,
|
|
1586
|
+
script: Effect.fn("findsScript")(function* findsScript(root, path) {
|
|
1587
|
+
if (yield* existsAt(root, path)) return true;
|
|
1588
|
+
const segments = String$1.split(path, SEPARATOR$1);
|
|
1589
|
+
return yield* matchesAny(root, Array.makeBy(segments.length, suffixAt(segments)));
|
|
1590
|
+
})
|
|
1591
|
+
};
|
|
1592
|
+
const staticPrefix = (path) => {
|
|
1593
|
+
const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD));
|
|
1594
|
+
if (String$1.endsWith(SEPARATOR$1)(prefix)) return String$1.slice(FIRST$1, -1)(prefix);
|
|
1595
|
+
return prefix;
|
|
1596
|
+
};
|
|
1597
|
+
const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
1598
|
+
const prefix = staticPrefix(path);
|
|
1599
|
+
if (String$1.isEmpty(prefix)) return false;
|
|
1600
|
+
const ignored = yield* (yield* RepositoryFiles).ignoredPaths(root, [prefix]);
|
|
1601
|
+
return Array.isReadonlyArrayNonEmpty(ignored);
|
|
1602
|
+
});
|
|
1603
|
+
const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR$1}`)(produced) || String$1.startsWith(`${produced}${SEPARATOR$1}`)(path);
|
|
1604
|
+
const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, found) {
|
|
1605
|
+
const prefix = staticPrefix(found.path);
|
|
1606
|
+
if (pipe(produced, Array.some(overlaps(prefix)))) return false;
|
|
1607
|
+
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
1608
|
+
return !(yield* isIgnored$1(root, found.path));
|
|
1609
|
+
});
|
|
1610
|
+
const problemOf$2 = (file, source) => (found) => ({
|
|
1611
|
+
file,
|
|
1612
|
+
...positionOf(source)(found.offset),
|
|
1613
|
+
rule: RULE$4,
|
|
1614
|
+
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.`
|
|
1615
|
+
});
|
|
1616
|
+
const problemsIn$2 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
|
|
1617
|
+
const files = yield* RepositoryFiles;
|
|
1618
|
+
const file = files.join(root, workflow);
|
|
1619
|
+
const source = yield* files.readFile(file);
|
|
1620
|
+
if (Option.isNone(source)) return [];
|
|
1621
|
+
const produced = producedPaths(source.value);
|
|
1622
|
+
const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
|
|
1623
|
+
return pipe(missing, Array.map(problemOf$2(file, source.value)));
|
|
1624
|
+
});
|
|
1625
|
+
/** @internal */
|
|
1626
|
+
const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
|
|
1627
|
+
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
1628
|
+
const found = yield* Effect.forEach(pipe(listed, Array.filter(isWorkflow)), (workflow) => problemsIn$2(root, workflow), { concurrency: READ_CONCURRENCY$5 });
|
|
1629
|
+
return Array.flatten(found);
|
|
1630
|
+
});
|
|
1355
1631
|
// src/features/repository-layout/model/workspace-checks.ts
|
|
1356
1632
|
/** @internal */
|
|
1357
1633
|
const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(root) {
|
|
@@ -1359,10 +1635,116 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
|
|
|
1359
1635
|
checkCrates(root),
|
|
1360
1636
|
checkHiddenVerify(root),
|
|
1361
1637
|
checkRootWorkspacePaths(root),
|
|
1362
|
-
checkSharedUncachedTasks(root)
|
|
1638
|
+
checkSharedUncachedTasks(root),
|
|
1639
|
+
checkWorkflowPaths(root)
|
|
1363
1640
|
], { concurrency: "unbounded" });
|
|
1364
1641
|
return Array.flatten(found);
|
|
1365
1642
|
});
|
|
1643
|
+
// src/features/scripts/model/shell-scripts.ts
|
|
1644
|
+
const SHELL_FILE = /\.(?:sh|bash|zsh|ksh|fish|command)$/u;
|
|
1645
|
+
const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|^#!\S*fish\b/u;
|
|
1646
|
+
const EXTENSION = /\.[^./]+$/u;
|
|
1647
|
+
const SETTINGS_FILE = ".claude/settings.json";
|
|
1648
|
+
const READ_CONCURRENCY$4 = 64;
|
|
1649
|
+
const FIRST = 1;
|
|
1650
|
+
const RULE$3 = "shell-script";
|
|
1651
|
+
const MESSAGE$2 = "is a shell script. Do the work in TypeScript as a Vite+ task in vite.config.ts, a test, or the tool's own hook, and delete this file. Only the SessionStart hook in .claude/settings.json, which installs the toolchain before TypeScript can run, stays a shell script.";
|
|
1652
|
+
const HookSchema = Schema.Struct({
|
|
1653
|
+
command: Schema.optional(Schema.String),
|
|
1654
|
+
args: Schema.optional(Schema.Array(Schema.String))
|
|
1655
|
+
});
|
|
1656
|
+
const MatcherSchema = Schema.Struct({ hooks: Schema.Array(HookSchema) });
|
|
1657
|
+
const HooksSchema = Schema.Struct({ SessionStart: Schema.optional(Schema.Array(MatcherSchema)) });
|
|
1658
|
+
const SettingsSchema = Schema.Struct({ hooks: Schema.optional(HooksSchema) });
|
|
1659
|
+
const decodeSettings = Schema.decodeOption(Schema.fromJsonString(SettingsSchema));
|
|
1660
|
+
const NO_TEXT = [];
|
|
1661
|
+
const commandText = ({ command, args }) => [...Option.toArray(Option.fromUndefinedOr(command)), ...pipe(Option.fromUndefinedOr(args), Option.getOrElse(() => NO_TEXT))];
|
|
1662
|
+
const matcherText = ({ hooks }) => pipe(hooks, Array.flatMap((hook) => commandText(hook)));
|
|
1663
|
+
const sessionStartCommands = (source) => {
|
|
1664
|
+
const matchers = pipe(decodeSettings(source), Option.flatMap(({ hooks }) => Option.fromUndefinedOr(hooks)), Option.flatMap(({ SessionStart }) => Option.fromUndefinedOr(SessionStart)));
|
|
1665
|
+
return pipe(matchers, Option.map(Array.flatMap((matcher) => matcherText(matcher))), Option.getOrElse(() => NO_TEXT));
|
|
1666
|
+
};
|
|
1667
|
+
const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.getOrElse(() => name));
|
|
1668
|
+
const hasExtension = (name) => EXTENSION.test(baseName(name));
|
|
1669
|
+
const startsWithShellShebang = (source) => SHELL_SHEBANG.test(source);
|
|
1670
|
+
const problemFor = (file) => ({
|
|
1671
|
+
file,
|
|
1672
|
+
line: FIRST,
|
|
1673
|
+
column: FIRST,
|
|
1674
|
+
rule: RULE$3,
|
|
1675
|
+
message: MESSAGE$2
|
|
1676
|
+
});
|
|
1677
|
+
/** @internal */
|
|
1678
|
+
const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
|
|
1679
|
+
const files = yield* RepositoryFiles;
|
|
1680
|
+
const names = yield* files.listedFiles(root);
|
|
1681
|
+
const settings = yield* files.readFile(files.join(root, SETTINGS_FILE));
|
|
1682
|
+
const commands = pipe(settings, Option.map(sessionStartCommands), Option.getOrElse(() => NO_TEXT));
|
|
1683
|
+
const isSessionStartHook = (name) => pipe(commands, Array.some(String$1.includes(name)));
|
|
1684
|
+
const isShell = (name) => {
|
|
1685
|
+
const file = files.join(root, name);
|
|
1686
|
+
if (SHELL_FILE.test(name)) return files.exists(file);
|
|
1687
|
+
if (hasExtension(name)) return Effect.succeed(false);
|
|
1688
|
+
return files.readFile(file).pipe(Effect.map(Option.exists(startsWithShellShebang)));
|
|
1689
|
+
};
|
|
1690
|
+
const candidates = pipe(names, Array.filter((name) => !isSessionStartHook(name)));
|
|
1691
|
+
const shell = yield* Effect.filter(candidates, isShell, { concurrency: READ_CONCURRENCY$4 });
|
|
1692
|
+
return pipe(shell, Array.map((name) => problemFor(files.join(root, name))));
|
|
1693
|
+
});
|
|
1694
|
+
// src/features/scripts/model/workflows.ts
|
|
1695
|
+
const WORKFLOW_FILE = /^\.github\/workflows\/[^/]+\.ya?ml$/u;
|
|
1696
|
+
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
1697
|
+
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
1698
|
+
const COMMENT = "#";
|
|
1699
|
+
const RUN_KEY = "run";
|
|
1700
|
+
const RULE$2 = "workflow-script";
|
|
1701
|
+
const READ_CONCURRENCY$3 = 16;
|
|
1702
|
+
const START$4 = 0;
|
|
1703
|
+
const ONE_COMMAND = 1;
|
|
1704
|
+
const MESSAGE$1 = "runs more than one command. Keep a step to one command, `vp run <task>` or `vp exec <bin>`, and put the logic in a Vite+ task in TypeScript.";
|
|
1705
|
+
const startOf = (range) => pipe(Option.fromNullishOr(range), Option.map(([start]) => start), Option.getOrElse(() => START$4));
|
|
1706
|
+
const runScriptsOf = (source) => {
|
|
1707
|
+
const found = [];
|
|
1708
|
+
visit(parseDocument(source), { Pair: (_key, pair) => {
|
|
1709
|
+
if (isPair(pair) && isScalar(pair.key) && pair.key.value === RUN_KEY && isScalar(pair.value) && typeof pair.value.value === "string") found.push({
|
|
1710
|
+
text: pair.value.value,
|
|
1711
|
+
start: startOf(pair.value.range)
|
|
1712
|
+
});
|
|
1713
|
+
} });
|
|
1714
|
+
return found;
|
|
1715
|
+
};
|
|
1716
|
+
const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
|
|
1717
|
+
const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED, "")(line));
|
|
1718
|
+
const runsMoreThanOneCommand = ({ text }) => {
|
|
1719
|
+
const lines = pipe(String$1.split("\n")(text), Array.map(String$1.trim), Array.filter(isCommand));
|
|
1720
|
+
return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
|
|
1721
|
+
};
|
|
1722
|
+
const problemsIn$1 = (file) => (source) => {
|
|
1723
|
+
const at = positionOf(source);
|
|
1724
|
+
return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
|
|
1725
|
+
file,
|
|
1726
|
+
...at(start),
|
|
1727
|
+
rule: RULE$2,
|
|
1728
|
+
message: MESSAGE$1
|
|
1729
|
+
})));
|
|
1730
|
+
};
|
|
1731
|
+
/** @internal */
|
|
1732
|
+
const checkWorkflows = Effect.fn("checkWorkflows")(function* checkWorkflows(root) {
|
|
1733
|
+
const files = yield* RepositoryFiles;
|
|
1734
|
+
const names = yield* files.listedFiles(root);
|
|
1735
|
+
const workflows = pipe(names, Array.filter((name) => WORKFLOW_FILE.test(name)));
|
|
1736
|
+
const found = yield* Effect.forEach(workflows, (name) => {
|
|
1737
|
+
const file = files.join(root, name);
|
|
1738
|
+
return files.readFile(file).pipe(Effect.map((text) => pipe(text, Option.map(problemsIn$1(file)), Option.getOrElse(() => []))));
|
|
1739
|
+
}, { concurrency: READ_CONCURRENCY$3 });
|
|
1740
|
+
return Array.flatten(found);
|
|
1741
|
+
});
|
|
1742
|
+
// src/features/scripts/model/script-checks.ts
|
|
1743
|
+
/** @internal */
|
|
1744
|
+
const checkScripts = Effect.fn("checkScripts")(function* checkScripts(root) {
|
|
1745
|
+
const found = yield* Effect.all([checkShellScripts(root), checkWorkflows(root)], { concurrency: "unbounded" });
|
|
1746
|
+
return Array.flatten(found);
|
|
1747
|
+
});
|
|
1366
1748
|
// src/features/value-owners/model/slots.ts
|
|
1367
1749
|
const ANNOTATED_KINDS = /* @__PURE__ */ new Set([
|
|
1368
1750
|
SyntaxKind.Parameter,
|
|
@@ -1780,6 +2162,112 @@ const analyzeProject = (owners) => (project) => {
|
|
|
1780
2162
|
unowned: pipe(verdicts, Array.flatMap((found) => found.unowned))
|
|
1781
2163
|
};
|
|
1782
2164
|
};
|
|
2165
|
+
// src/features/value-owners/model/cache.ts
|
|
2166
|
+
const CACHE_DIRECTORY = [
|
|
2167
|
+
NODE_MODULES,
|
|
2168
|
+
".cache",
|
|
2169
|
+
"msch",
|
|
2170
|
+
"value-owners"
|
|
2171
|
+
];
|
|
2172
|
+
const CACHE_SUFFIX = ".json";
|
|
2173
|
+
const MANIFEST_ENTRY = "package.json";
|
|
2174
|
+
const FINGERPRINTED = ["src", "dist"];
|
|
2175
|
+
const EMPTY = "";
|
|
2176
|
+
const FIELD_SEPARATOR = "\0";
|
|
2177
|
+
const LINE_SEPARATOR = "\n";
|
|
2178
|
+
const ValueSchema = Schema.Union([Schema.String, Schema.Finite]);
|
|
2179
|
+
const UnownedSiteSchema = Schema.Struct({
|
|
2180
|
+
scope: Schema.Struct({
|
|
2181
|
+
name: Schema.String,
|
|
2182
|
+
dependencies: Schema.Array(Schema.String)
|
|
2183
|
+
}),
|
|
2184
|
+
file: Schema.String,
|
|
2185
|
+
start: Schema.Int,
|
|
2186
|
+
line: Schema.Int,
|
|
2187
|
+
column: Schema.Int,
|
|
2188
|
+
values: Schema.Array(ValueSchema)
|
|
2189
|
+
});
|
|
2190
|
+
const AnalysisSchema = Schema.Struct({
|
|
2191
|
+
problems: ProblemList,
|
|
2192
|
+
unowned: Schema.Array(UnownedSiteSchema)
|
|
2193
|
+
});
|
|
2194
|
+
const AnalysisJson = Schema.fromJsonString(AnalysisSchema);
|
|
2195
|
+
const hasher = Effect.gen(function* currentHasher() {
|
|
2196
|
+
return (yield* RepositoryFiles).hash;
|
|
2197
|
+
});
|
|
2198
|
+
const entryOf = (file, found) => `${file}${FIELD_SEPARATOR}${found}`;
|
|
2199
|
+
const fileDigest = (hash) => {
|
|
2200
|
+
const digests = /* @__PURE__ */ new Map();
|
|
2201
|
+
return (file) => Option.match(Option.fromUndefinedOr(digests.get(file)), {
|
|
2202
|
+
onSome: Effect.succeed,
|
|
2203
|
+
onNone: () => Effect.gen(function* readDigest() {
|
|
2204
|
+
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
2205
|
+
const found = yield* hash(Option.getOrElse(text, () => EMPTY));
|
|
2206
|
+
digests.set(file, found);
|
|
2207
|
+
return found;
|
|
2208
|
+
})
|
|
2209
|
+
});
|
|
2210
|
+
};
|
|
2211
|
+
const digestEntries = (digestFile) => (named) => pipe(named, Effect.forEach(([name, file]) => digestFile(file).pipe(Effect.map((found) => entryOf(name, found)))));
|
|
2212
|
+
const fingerprintedFiles = Effect.fn("fingerprintedFiles")(function* fingerprintedFiles(root) {
|
|
2213
|
+
const files = yield* RepositoryFiles;
|
|
2214
|
+
const nested = yield* pipe(FINGERPRINTED, Effect.forEach((entry) => {
|
|
2215
|
+
const base = files.join(root, entry);
|
|
2216
|
+
return files.walkDirectory(base).pipe(Effect.map(Array.map((file) => files.join(base, file))));
|
|
2217
|
+
}));
|
|
2218
|
+
return Array.sort([files.join(root, MANIFEST_ENTRY), ...Array.flatten(nested)], String$1.Order);
|
|
2219
|
+
});
|
|
2220
|
+
const fingerprintOf = Effect.fn("fingerprintOf")(function* fingerprintOf(hash) {
|
|
2221
|
+
const root = yield* nearestManifestDirectory(import.meta.dirname);
|
|
2222
|
+
const listed = yield* fingerprintedFiles(root);
|
|
2223
|
+
const entries = yield* digestEntries(fileDigest(hash))(pipe(listed, Array.map((file) => [file, file])));
|
|
2224
|
+
return yield* hash(Array.join(entries, LINE_SEPARATOR));
|
|
2225
|
+
});
|
|
2226
|
+
const analysisCache = Effect.fn("analysisCache")(function* analysisCache(root, owners) {
|
|
2227
|
+
const files = yield* RepositoryFiles;
|
|
2228
|
+
const hash = yield* hasher;
|
|
2229
|
+
const fingerprint = yield* fingerprintOf(hash);
|
|
2230
|
+
const salt = yield* hash(Array.join([fingerprint, owners], FIELD_SEPARATOR));
|
|
2231
|
+
return {
|
|
2232
|
+
root,
|
|
2233
|
+
directory: files.join(root, ...CACHE_DIRECTORY),
|
|
2234
|
+
salt,
|
|
2235
|
+
digestFile: fileDigest(hash),
|
|
2236
|
+
hash
|
|
2237
|
+
};
|
|
2238
|
+
});
|
|
2239
|
+
const keyOf = (cache) => (configPath, inputs) => Effect.gen(function* deriveKey() {
|
|
2240
|
+
const files = yield* RepositoryFiles;
|
|
2241
|
+
const entries = yield* digestEntries(cache.digestFile)(pipe(inputs.files, Array.map((file) => [file, files.join(cache.root, file)])));
|
|
2242
|
+
const header = [
|
|
2243
|
+
cache.salt,
|
|
2244
|
+
files.relative(cache.root, configPath),
|
|
2245
|
+
inputs.options
|
|
2246
|
+
];
|
|
2247
|
+
return yield* cache.hash(Array.join([...header, ...entries], LINE_SEPARATOR));
|
|
2248
|
+
});
|
|
2249
|
+
const entryFile = (cache, key) => `${cache.directory}/${key}${CACHE_SUFFIX}`;
|
|
2250
|
+
const readAnalysis = (cache) => (key) => Effect.gen(function* readCached() {
|
|
2251
|
+
const text = yield* (yield* RepositoryFiles).readFile(entryFile(cache, key));
|
|
2252
|
+
return yield* Option.match(text, {
|
|
2253
|
+
onNone: () => Effect.succeedNone,
|
|
2254
|
+
onSome: (found) => Schema.decodeEffect(AnalysisJson)(found).pipe(Effect.option)
|
|
2255
|
+
});
|
|
2256
|
+
});
|
|
2257
|
+
const writeAnalysis = (cache) => (key, analysis) => Effect.gen(function* writeCached() {
|
|
2258
|
+
const files = yield* RepositoryFiles;
|
|
2259
|
+
const text = yield* Schema.encodeEffect(AnalysisJson)(analysis).pipe(Effect.option);
|
|
2260
|
+
yield* Option.match(text, {
|
|
2261
|
+
onNone: () => Effect.void,
|
|
2262
|
+
onSome: (found) => files.writeFile(entryFile(cache, key), found)
|
|
2263
|
+
});
|
|
2264
|
+
});
|
|
2265
|
+
const pruneAnalyses = (cache) => (kept) => Effect.gen(function* pruneCached() {
|
|
2266
|
+
const files = yield* RepositoryFiles;
|
|
2267
|
+
const keep = new Set(pipe(kept, Array.map((key) => `${key}${CACHE_SUFFIX}`)));
|
|
2268
|
+
const present = yield* files.readDirectory(cache.directory);
|
|
2269
|
+
yield* pipe(present, Array.filter((name) => !keep.has(name)), Effect.forEach((name) => files.removeFile(files.join(cache.directory, name))), Effect.asVoid);
|
|
2270
|
+
});
|
|
1783
2271
|
// src/features/value-owners/model/duplicates.ts
|
|
1784
2272
|
const DUPLICATE_THRESHOLD = 1;
|
|
1785
2273
|
const unownedSiteOf = (scope) => (site) => ({
|
|
@@ -1822,14 +2310,54 @@ const scopeOf = (project, configPath) => ({
|
|
|
1822
2310
|
name: Option.getOrElse(project.packageName, () => configPath),
|
|
1823
2311
|
dependencies: project.workspaceDependencies
|
|
1824
2312
|
});
|
|
1825
|
-
const
|
|
2313
|
+
const freshAnalysis = ({ workspace, owners }) => (configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => {
|
|
1826
2314
|
const analysis = analyzeProject(owners)(project);
|
|
1827
2315
|
const scope = scopeOf(project, configPath);
|
|
1828
2316
|
return {
|
|
1829
2317
|
problems: analysis.problems,
|
|
1830
2318
|
unowned: pipe(analysis.unowned, Array.map(unownedSiteOf(scope)))
|
|
1831
2319
|
};
|
|
1832
|
-
}).pipe(Effect.withSpan("analyzeProject")))
|
|
2320
|
+
}).pipe(Effect.withSpan("analyzeProject")));
|
|
2321
|
+
const keyedAnalysis = (context) => (configPath, key) => Effect.gen(function* lookupAnalysis() {
|
|
2322
|
+
const cached = yield* readAnalysis(context.cache)(key);
|
|
2323
|
+
if (Option.isSome(cached)) return cached;
|
|
2324
|
+
const fresh = yield* freshAnalysis(context)(configPath);
|
|
2325
|
+
yield* Option.match(fresh, {
|
|
2326
|
+
onNone: () => Effect.void,
|
|
2327
|
+
onSome: (analysis) => writeAnalysis(context.cache)(key, analysis)
|
|
2328
|
+
});
|
|
2329
|
+
return fresh;
|
|
2330
|
+
});
|
|
2331
|
+
const analyzeConfig = (context) => (configPath) => Effect.gen(function* analyzeOne() {
|
|
2332
|
+
const inputs = yield* projectInputs(context)(configPath);
|
|
2333
|
+
if (Option.isNone(inputs)) return Option.none();
|
|
2334
|
+
const key = yield* keyOf(context.cache)(configPath, inputs.value);
|
|
2335
|
+
const analysis = yield* keyedAnalysis(context)(configPath, key);
|
|
2336
|
+
return pipe(analysis, Option.map((found) => [key, found]));
|
|
2337
|
+
});
|
|
2338
|
+
const encodeOwners = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
2339
|
+
const cacheFor = Effect.fn("cacheFor")(function* cacheFor(root, owners) {
|
|
2340
|
+
const plain = pipe(owners, Array.map((owner) => ({
|
|
2341
|
+
...owner,
|
|
2342
|
+
packageName: Option.getOrNull(owner.packageName)
|
|
2343
|
+
})));
|
|
2344
|
+
const encoded = yield* encodeOwners(plain).pipe(Effect.orElseSucceed(() => ""));
|
|
2345
|
+
return yield* analysisCache(root, encoded);
|
|
2346
|
+
});
|
|
2347
|
+
const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(workspace, owners, configPaths) {
|
|
2348
|
+
const files = yield* RepositoryFiles;
|
|
2349
|
+
const cache = yield* cacheFor(workspace.root, owners);
|
|
2350
|
+
const listed = yield* files.listedFiles(workspace.root);
|
|
2351
|
+
const keyed = yield* pipe(configPaths, Effect.forEach(analyzeConfig({
|
|
2352
|
+
workspace,
|
|
2353
|
+
owners,
|
|
2354
|
+
cache,
|
|
2355
|
+
listed
|
|
2356
|
+
})));
|
|
2357
|
+
const found = Array.getSomes(keyed);
|
|
2358
|
+
yield* pruneAnalyses(cache)(pipe(found, Array.map(([key]) => key)));
|
|
2359
|
+
return pipe(found, Array.map(([, analysis]) => analysis));
|
|
2360
|
+
});
|
|
1833
2361
|
const checkRepository = Effect.fn("checkRepository")(function* checkRepository(root) {
|
|
1834
2362
|
const files = yield* RepositoryFiles;
|
|
1835
2363
|
const workspace = {
|
|
@@ -1839,7 +2367,7 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
1839
2367
|
};
|
|
1840
2368
|
const configPaths = yield* listConfigFiles(root);
|
|
1841
2369
|
const ownerScan = yield* scanOwners(workspace, configPaths);
|
|
1842
|
-
const analyses = yield* analyzeProjects(workspace, ownerScan.owners
|
|
2370
|
+
const analyses = yield* analyzeProjects(workspace, ownerScan.owners, configPaths);
|
|
1843
2371
|
const relative = (file) => files.relative(root, file);
|
|
1844
2372
|
const unowned = pipe(analyses, Array.flatMap((analysis) => analysis.unowned));
|
|
1845
2373
|
return sortProblems([
|
|
@@ -2300,6 +2828,7 @@ const SETUP_PATTERNS = [
|
|
|
2300
2828
|
/(?<![\w./@-])cargo[ \t]+(?:vendor|fetch)\b/gu,
|
|
2301
2829
|
/\buses:\s*["']?(?:dtolnay\/rust-toolchain|actions-rust-lang\/setup-rust-toolchain|actions-rs\/toolchain|moonrepo\/setup-rust)\b/gu
|
|
2302
2830
|
];
|
|
2831
|
+
const INSTALL_PATTERNS = [/(?<![\w./@-])cargo[ \t]+b?install\b/gu];
|
|
2303
2832
|
const TOOL_PATTERNS = [/^[ \t]*["']?(?:rust|rustup)["']?[ \t]*(?:=|[ \t]+\S)/gmu];
|
|
2304
2833
|
const START = 0;
|
|
2305
2834
|
const LAST_SEGMENT = 1;
|
|
@@ -2331,17 +2860,24 @@ const generatedCargoConfig = (entry, source) => {
|
|
|
2331
2860
|
return [pnpmCargoConfig(entry)];
|
|
2332
2861
|
};
|
|
2333
2862
|
const cargoOutsidePnpm = problemAtStart(CARGO_RULE, `pnpm does not manage these crates. Set \`cargo: { enabled: true }\` in ${WORKSPACE_FILE} so pnpm install fetches the crates and the Rust toolchain.`);
|
|
2334
|
-
const setupProblem = ({ file }, source) => (found) => ({
|
|
2863
|
+
const setupProblem = ({ file }, source, advice) => (found) => ({
|
|
2335
2864
|
file,
|
|
2336
2865
|
...positionOf(source)(found.index ?? WHOLE_MATCH),
|
|
2337
2866
|
rule: SETUP_RULE,
|
|
2338
|
-
message:
|
|
2867
|
+
message: advice(String$1.trim(found[WHOLE_MATCH]))
|
|
2339
2868
|
});
|
|
2869
|
+
const removeSetup = (command) => `pnpm install already installs the toolchain in rust-toolchain.toml and vendors the crates in Cargo.lock. Remove \`${command}\`.`;
|
|
2870
|
+
const buildInstead = (command) => `\`${command}\` fetches crates that pnpm does not vendor. Add the tool as a dependency of a Cargo workspace that pnpm vendors, and build its binary there with \`cargo build -p <crate> --bin <name>\`.`;
|
|
2340
2871
|
const setupPatternsFor = (entry) => {
|
|
2341
2872
|
if (isToolVersions(entry)) return [...SETUP_PATTERNS, ...TOOL_PATTERNS];
|
|
2342
2873
|
return SETUP_PATTERNS;
|
|
2343
2874
|
};
|
|
2344
|
-
const
|
|
2875
|
+
const matchesOf = (source) => (patterns) => pipe(patterns, Array.flatMap((pattern) => Array.fromIterable(String$1.matchAll(pattern)(source))));
|
|
2876
|
+
const setupProblems = (entry, source) => {
|
|
2877
|
+
const found = matchesOf(source);
|
|
2878
|
+
const installs = pipe(found(INSTALL_PATTERNS), Array.map(setupProblem(entry, source, buildInstead)));
|
|
2879
|
+
return pipe(found(setupPatternsFor(entry)), Array.map(setupProblem(entry, source, removeSetup)), Array.appendAll(installs), Array.appendAll(generatedCargoConfig(entry, source)));
|
|
2880
|
+
};
|
|
2345
2881
|
const matches = (pattern) => ({ name }) => pattern.test(name);
|
|
2346
2882
|
const isCargoManifest = matches(CARGO_MANIFEST_FILE);
|
|
2347
2883
|
const isForeignLockfile = matches(FOREIGN_LOCKFILE);
|
|
@@ -2355,7 +2891,7 @@ const ancestorsOf = (directory) => {
|
|
|
2355
2891
|
const readsCargoLock = (manifests, workspaces) => ({ name }) => {
|
|
2356
2892
|
const directory = directoryOf(name);
|
|
2357
2893
|
const insideWorkspace = pipe(ancestorsOf(directory), Array.some((ancestor) => Array.contains(workspaces, ancestor)));
|
|
2358
|
-
return Array.contains(manifests, directory) && !insideWorkspace;
|
|
2894
|
+
return Array.contains(manifests, directory) && (Array.contains(workspaces, directory) || !insideWorkspace);
|
|
2359
2895
|
};
|
|
2360
2896
|
const isWorkspaceManifest = (source) => Option.exists(source, (text) => CARGO_WORKSPACE.test(text));
|
|
2361
2897
|
const directoriesOf = (entries) => pipe(entries, Array.map(({ name }) => directoryOf(name)));
|
|
@@ -2419,6 +2955,7 @@ const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
|
2419
2955
|
checkOverrides(root),
|
|
2420
2956
|
checkTrackedText(root),
|
|
2421
2957
|
checkPlacement(root),
|
|
2958
|
+
checkScripts(root),
|
|
2422
2959
|
checkPublishedPackages(root),
|
|
2423
2960
|
checkWorkspaces(root)
|
|
2424
2961
|
], { concurrency: "unbounded" });
|