@r_masseater/msch 0.6.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/dist/cli-contract-DlE7gy0b.mjs +115 -0
- package/dist/cli-contract-DlE7gy0b.mjs.map +1 -0
- package/dist/cli.mjs +684 -236
- package/dist/cli.mjs.map +1 -1
- package/dist/comment-directives-DApQXgQf.mjs +20 -0
- package/dist/comment-directives-DApQXgQf.mjs.map +1 -0
- package/dist/dependencies-x3j9tLcR.mjs +186 -0
- package/dist/dependencies-x3j9tLcR.mjs.map +1 -0
- package/dist/lint.d.mts +6 -1
- package/dist/lint.mjs +47 -17
- package/dist/lint.mjs.map +1 -1
- package/dist/oxlint.mjs +2 -2
- package/dist/workspace-settings.d.mts +32 -0
- package/dist/workspace-settings.mjs +216 -0
- package/dist/workspace-settings.mjs.map +1 -0
- package/dist/workspace-tasks-CRL-gm__.mjs +298 -0
- package/dist/workspace-tasks-CRL-gm__.mjs.map +1 -0
- package/package.json +13 -3
- package/src/vite.d.ts +36 -1
- package/dist/cli-contract-DpQurUwC.mjs +0 -286
- package/dist/cli-contract-DpQurUwC.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as isTypeAliasDeclaration, A as getTextOfJSDocComment, B as isInterfaceDeclaration, C as API, D as getJSDocTags, E as SyntaxKind, F as isElementAccessExpression, G as isObjectLiteralExpression, H as isModuleDeclaration, I as isEnumDeclaration, J as isSatisfiesExpression, K as isPropertyAccessExpression, L as isExportDeclaration, M as isBinaryExpression, N as isCallExpression, O as getLeadingCommentRanges, P as isClassDeclaration, Q as isStringLiteral, R as isIdentifier, S as uniqueByReference, T as InternalSymbolName, U as isNewExpression, V as isModuleBlock, W as isNumericLiteral, X as isSourceFile, Y as isSignatureDeclaration, Z as isSpreadElement, _ as lineOf, a as problemAt, at as isVariableStatement, b as resolvedSymbol, c as childrenOf$2, d as declarationsOf, et as isTypeLiteralNode, f as descendantsOf, g as isTypeDeclaration, h as isGenericDeclaration, i as formatProblem, it as isVariableDeclarationList, j as isArrayLiteralExpression, k as getNameOfDeclaration, l as columnOf, m as isExternalDeclaration, n as ProblemList, nt as isUnionTypeNode, o as sortProblems, p as importedModulesOf, q as isPropertyAssignment, rt as isVariableDeclaration, s as NODE_MODULES_SEGMENT, tt as isTypeReferenceNode, u as contains, v as propertyNamesOf, w as IndexKind, x as symbolAt, y as referencedSymbols, z as isImportDeclaration } from "./cli-contract-DlE7gy0b.mjs";
|
|
3
|
+
import { a as workspaceDependencies, c as nodeServicesLayer, i as readManifest, n as NODE_MODULES, o as RepositoryFiles, r as dependencyEntries, s as nodeRepositoryFiles, t as MANIFEST_FILE } from "./dependencies-x3j9tLcR.mjs";
|
|
4
|
+
import { _ as publishedWorkspaces, c as programOf, d as childrenOf$3, i as hasVerifyTask, m as workspaceDirectories, n as VERIFY_TASK, r as definesTask, v as publicEntriesOf } from "./workspace-tasks-CRL-gm__.mjs";
|
|
5
|
+
import { t as COMMENT_DIRECTIVES } from "./comment-directives-DApQXgQf.mjs";
|
|
3
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";
|
|
4
7
|
import { ChildProcess } from "effect/process";
|
|
5
|
-
import { resolveConfigFromFile } from "vite-plus";
|
|
6
|
-
import { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
|
|
8
|
+
import { parse, resolveConfigFromFile } from "vite-plus";
|
|
9
|
+
import { LineCounter, Parser, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import treeSitter from "@vscode/tree-sitter-wasm";
|
|
13
|
+
import { isComment, isTag, isText } from "domhandler";
|
|
14
|
+
import { DomUtils, parseDocument as parseDocument$1 } from "htmlparser2";
|
|
15
|
+
import { DockerfileParser } from "dockerfile-ast";
|
|
16
|
+
import { parse as parse$2 } from "sql-parser-cst";
|
|
17
|
+
import { parseTOML } from "toml-eslint-parser";
|
|
7
18
|
import { runMain } from "@effect/platform-node-shared/NodeRuntime";
|
|
8
19
|
import { FetchHttpClient } from "effect/http";
|
|
9
20
|
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
@@ -456,7 +467,7 @@ const derivationScopeOf = (node) => {
|
|
|
456
467
|
};
|
|
457
468
|
const sourcesOf = (checker) => (node) => pipe(referencedSymbols(checker)(derivationScopeOf(node)), Array.filter((symbol) => Option.isSome(namedValuesOf(checker)(symbol))));
|
|
458
469
|
const sitesUnder = (checker) => (node) => {
|
|
459
|
-
const nested = pipe(childrenOf$
|
|
470
|
+
const nested = pipe(childrenOf$2(node), Array.flatMap((child) => sitesUnder(checker)(child)));
|
|
460
471
|
if (Array.isReadonlyArrayNonEmpty(nested)) return nested;
|
|
461
472
|
return siteValuesOf(checker)(node).pipe(Option.map((values) => ({
|
|
462
473
|
node,
|
|
@@ -659,25 +670,19 @@ const annotateResources = (api) => Effect.gen(function* annotateCompiler() {
|
|
|
659
670
|
});
|
|
660
671
|
});
|
|
661
672
|
// src/project.ts
|
|
662
|
-
const
|
|
673
|
+
const CONFIG_PATHSPEC = `:(glob)**/tsconfig.json`;
|
|
663
674
|
const HIDDEN_PREFIX = ".";
|
|
664
675
|
const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
665
676
|
NODE_MODULES,
|
|
666
677
|
"dist",
|
|
667
678
|
"coverage"
|
|
668
679
|
]);
|
|
669
|
-
const
|
|
680
|
+
const isVisible = (file) => pipe(String$1.split(file, "/"), Array.every((segment) => !String$1.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment)));
|
|
681
|
+
const listConfigFiles = (root) => Effect.gen(function* configFilesUnder() {
|
|
670
682
|
const files = yield* RepositoryFiles;
|
|
671
|
-
const
|
|
672
|
-
const visible = pipe(
|
|
673
|
-
|
|
674
|
-
onNone: () => Effect.succeed([]),
|
|
675
|
-
onSome: (directoryEntry) => {
|
|
676
|
-
if (directoryEntry) return listConfigFiles(entryPath);
|
|
677
|
-
return Effect.succeed(Array.filter([entryPath], () => files.basename(entryPath) === CONFIG_FILE$1));
|
|
678
|
-
}
|
|
679
|
-
})))));
|
|
680
|
-
return Array.sort(nested.flat(), Order.String);
|
|
683
|
+
const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);
|
|
684
|
+
const visible = pipe(listed, Array.filter(isVisible), Array.map((file) => files.join(root, file)));
|
|
685
|
+
return Array.sort(visible, Order.String);
|
|
681
686
|
});
|
|
682
687
|
const parseConfig = (api) => (configPath) => Option.some(api.parseConfigFile(configPath)).pipe(Option.filter((parsed) => Array.isReadonlyArrayNonEmpty(parsed.fileNames)));
|
|
683
688
|
const nearestPackageDirectory = (directory, root) => Effect.gen(function* nearestPackage() {
|
|
@@ -748,7 +753,7 @@ const withProject = (workspace) => (configPath) => (work) => Effect.acquireUseRe
|
|
|
748
753
|
onNone: () => Effect.void,
|
|
749
754
|
onSome: releaseProject
|
|
750
755
|
}));
|
|
751
|
-
const mentions = (needle) => ({ api }) => (configPath) => Effect.gen(function* mentionsNeedle() {
|
|
756
|
+
const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function* mentionsNeedle() {
|
|
752
757
|
const files = yield* RepositoryFiles;
|
|
753
758
|
const fileNames = Option.match(parseConfig(api)(configPath), {
|
|
754
759
|
onNone: () => [],
|
|
@@ -760,7 +765,7 @@ const mentions = (needle) => ({ api }) => (configPath) => Effect.gen(function* m
|
|
|
760
765
|
});
|
|
761
766
|
// src/check.ts
|
|
762
767
|
const scanOwners = Effect.fn("scanOwners")(function* scanOwners(workspace, configPaths) {
|
|
763
|
-
const ownerConfigs = yield* pipe(configPaths, Effect.filter(mentions(`@${OWNER_TAG}`)(workspace.compiler)));
|
|
768
|
+
const ownerConfigs = yield* pipe(configPaths, Effect.filter(mentions$1(`@${OWNER_TAG}`)(workspace.compiler)));
|
|
764
769
|
const scans = yield* pipe(ownerConfigs, Effect.forEach((configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => ownersIn(project)))));
|
|
765
770
|
return combineOwnerScans(Array.getSomes(scans));
|
|
766
771
|
});
|
|
@@ -794,59 +799,11 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
794
799
|
...duplicateProblems(relative)(unowned)
|
|
795
800
|
]);
|
|
796
801
|
}, Effect.scoped);
|
|
797
|
-
// src/text-position.ts
|
|
798
|
-
const START$2 = 0;
|
|
799
|
-
const FIRST_COLUMN$1 = 1;
|
|
800
|
-
const positionOf = (source) => (index) => {
|
|
801
|
-
const before = pipe(source, String$1.slice(START$2, index), String$1.split("\n"));
|
|
802
|
-
return {
|
|
803
|
-
line: before.length,
|
|
804
|
-
column: pipe(Array.last(before), Option.match({
|
|
805
|
-
onNone: () => FIRST_COLUMN$1,
|
|
806
|
-
onSome: (last) => last.length + FIRST_COLUMN$1
|
|
807
|
-
}))
|
|
808
|
-
};
|
|
809
|
-
};
|
|
810
|
-
// src/hidden-unicode.ts
|
|
811
|
-
const HIDDEN = /[\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]|[\u{E0000}-\u{E007F}]/gu;
|
|
812
|
-
const NUL = "\0";
|
|
813
|
-
const START$1 = 0;
|
|
814
|
-
const HEX = 16;
|
|
815
|
-
const CODE_POINT_WIDTH = 4;
|
|
816
|
-
const READ_CONCURRENCY$3 = 64;
|
|
817
|
-
const RULE$1 = "hidden-unicode";
|
|
818
|
-
const hexOf = (character) => pipe(String$1.codePointAt(START$1)(character), Option.getOrElse(() => START$1), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
|
|
819
|
-
const problemOf = (file, source) => (found) => {
|
|
820
|
-
const hex = hexOf(found[START$1]);
|
|
821
|
-
return {
|
|
822
|
-
file,
|
|
823
|
-
...positionOf(source)(found.index ?? START$1),
|
|
824
|
-
rule: RULE$1,
|
|
825
|
-
message: `U+${hex} is invisible in editors and reviews and can change what the text means. Remove it, or write it as the escape \\u${hex}.`
|
|
826
|
-
};
|
|
827
|
-
};
|
|
828
|
-
const problemsIn = (file, source) => {
|
|
829
|
-
if (String$1.includes(NUL)(source)) return [];
|
|
830
|
-
return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf(file, source)));
|
|
831
|
-
};
|
|
832
|
-
/** @internal */
|
|
833
|
-
const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHiddenUnicode(root) {
|
|
834
|
-
const files = yield* RepositoryFiles;
|
|
835
|
-
const names = yield* files.listedFiles(root);
|
|
836
|
-
const found = yield* Effect.forEach(names, (name) => {
|
|
837
|
-
const file = files.join(root, name);
|
|
838
|
-
return files.readFile(file).pipe(Effect.map(Option.match({
|
|
839
|
-
onNone: () => [],
|
|
840
|
-
onSome: (source) => problemsIn(file, source)
|
|
841
|
-
})));
|
|
842
|
-
}, { concurrency: READ_CONCURRENCY$3 });
|
|
843
|
-
return Array.flatten(found);
|
|
844
|
-
});
|
|
845
802
|
// src/import-graph.ts
|
|
846
803
|
const RELATIVE = /^\.\.?(?:\/|$)/u;
|
|
847
804
|
const SUBPATH_IMPORT = "#";
|
|
848
805
|
const WILDCARD = "*";
|
|
849
|
-
const SCOPE = "@";
|
|
806
|
+
const SCOPE$1 = "@";
|
|
850
807
|
const SEPARATOR$3 = "/";
|
|
851
808
|
const SOURCE_SUFFIXES = [
|
|
852
809
|
"",
|
|
@@ -860,7 +817,7 @@ const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Sche
|
|
|
860
817
|
const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
|
|
861
818
|
const packageNameOf = (specifier) => {
|
|
862
819
|
const segments = String$1.split(specifier, SEPARATOR$3);
|
|
863
|
-
if (String$1.startsWith(SCOPE)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$3));
|
|
820
|
+
if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$3));
|
|
864
821
|
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$3));
|
|
865
822
|
};
|
|
866
823
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
@@ -964,7 +921,7 @@ const installedNames = (manifest) => [
|
|
|
964
921
|
...keysOf$1(manifest.optionalDependencies),
|
|
965
922
|
...pipe(keysOf$1(manifest.peerDependencies), Array.filter((name) => !isOptionalPeer(manifest, name)))
|
|
966
923
|
];
|
|
967
|
-
const childrenOf = Effect.fn("childrenOf")(function* childrenOf(directory) {
|
|
924
|
+
const childrenOf$1 = Effect.fn("childrenOf")(function* childrenOf(directory) {
|
|
968
925
|
const files = yield* RepositoryFiles;
|
|
969
926
|
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
970
927
|
return pipe(text, Option.flatMap(decodeManifest), Option.map(installedNames), Option.getOrElse(() => []), Array.map((child) => [directory, child]));
|
|
@@ -993,7 +950,7 @@ const closureOf = (provided, collect) => Array.match(collect.pending, {
|
|
|
993
950
|
...collect,
|
|
994
951
|
pending: rest
|
|
995
952
|
});
|
|
996
|
-
return childrenOf(resolved.value).pipe(Effect.flatMap((children) => closureOf(provided, {
|
|
953
|
+
return childrenOf$1(resolved.value).pipe(Effect.flatMap((children) => closureOf(provided, {
|
|
997
954
|
pending: [...rest, ...children],
|
|
998
955
|
seen: HashSet.add(collect.seen, resolved.value)
|
|
999
956
|
})));
|
|
@@ -1019,137 +976,19 @@ const installedSize = (directory) => {
|
|
|
1019
976
|
if (String$1.includes(`/node_modules/`)(directory)) return directorySize(directory);
|
|
1020
977
|
return Effect.succeed(EMPTY);
|
|
1021
978
|
};
|
|
1022
|
-
// src/
|
|
1023
|
-
const
|
|
1024
|
-
const
|
|
1025
|
-
const
|
|
1026
|
-
const
|
|
1027
|
-
const ROOT_SUBPATH = ".";
|
|
1028
|
-
const BIN_LABEL = "bin";
|
|
1029
|
-
const targetsIn = (held) => {
|
|
1030
|
-
if (Predicate.isString(held)) return [held];
|
|
1031
|
-
if (!Predicate.isObject(held)) return [];
|
|
1032
|
-
return pipe(Record.values(held), Array.flatMap(targetsIn));
|
|
1033
|
-
};
|
|
1034
|
-
const subpathsOf = (exportsField) => {
|
|
1035
|
-
if (!Predicate.isObject(exportsField)) return [[ROOT_SUBPATH, exportsField]];
|
|
1036
|
-
const entries = Record.toEntries(exportsField);
|
|
1037
|
-
if (pipe(entries, Array.some(([key]) => String$1.startsWith(ROOT_SUBPATH)(key)))) return entries;
|
|
1038
|
-
return [[ROOT_SUBPATH, exportsField]];
|
|
1039
|
-
};
|
|
1040
|
-
const binsOf = (manifest) => {
|
|
1041
|
-
if (Predicate.isString(manifest.bin)) {
|
|
1042
|
-
const name = Option.getOrElse(Option.fromUndefinedOr(manifest.name), () => "");
|
|
1043
|
-
return [[`${BIN_LABEL} ${name}`, manifest.bin]];
|
|
1044
|
-
}
|
|
1045
|
-
if (!Predicate.isObject(manifest.bin)) return [];
|
|
1046
|
-
return pipe(Record.toEntries(manifest.bin), Array.map(([name, target]) => [`${BIN_LABEL} ${name}`, target]));
|
|
1047
|
-
};
|
|
1048
|
-
const baseNameOf = (target) => pipe(String$1.split(target, SEPARATOR$2), Array.last, Option.getOrElse(() => target), String$1.replace(BUILT, ""));
|
|
1049
|
-
const sourceOf = ({ join, packEntries }) => (target) => {
|
|
1050
|
-
if (SOURCE.test(target) && !String$1.includes(DECLARATION)(target)) return Option.some(join(target));
|
|
1051
|
-
const name = baseNameOf(target);
|
|
1052
|
-
return pipe(packEntries, Array.findFirst((entry) => entry.name === name), Option.map((entry) => entry.source));
|
|
1053
|
-
};
|
|
1054
|
-
const publicEntriesOf = (lookup) => pipe([...subpathsOf(lookup.manifest.exports), ...binsOf(lookup.manifest)], Array.flatMap(([label, held]) => pipe(targetsIn(held), Array.map(sourceOf(lookup)), Array.getSomes, Array.map((source) => ({
|
|
1055
|
-
label,
|
|
1056
|
-
source
|
|
1057
|
-
})))), Array.dedupeWith((left, right) => left.label === right.label && left.source === right.source));
|
|
1058
|
-
// src/published.ts
|
|
1059
|
-
const CONFIG_FILE = "vite.config.ts";
|
|
1060
|
-
const SEPARATOR$1 = "/";
|
|
1061
|
-
const READ_CONCURRENCY$2 = 16;
|
|
1062
|
-
const SOURCE_EXTENSION = /\.[cm]?tsx?$/u;
|
|
1063
|
-
const UNIT_BYTES = [
|
|
1064
|
-
["B", 1],
|
|
1065
|
-
["kB", 1e3],
|
|
1066
|
-
["MB", 1e6]
|
|
1067
|
-
];
|
|
1068
|
-
const SizeText = Schema.TemplateLiteralParser([
|
|
1069
|
-
Schema.Finite,
|
|
1070
|
-
" ",
|
|
1071
|
-
Schema.Literals([
|
|
1072
|
-
"B",
|
|
1073
|
-
"kB",
|
|
1074
|
-
"MB"
|
|
1075
|
-
])
|
|
1076
|
-
]);
|
|
1077
|
-
const PackEntry = Schema.Union([
|
|
1078
|
-
Schema.String,
|
|
1079
|
-
Schema.Array(Schema.String),
|
|
1080
|
-
Schema.Record(Schema.String, Schema.String)
|
|
1081
|
-
]);
|
|
1082
|
-
const PackSettings = Schema.Struct({ entry: Schema.optional(PackEntry) });
|
|
1083
|
-
const PackList = Schema.Union([PackSettings, Schema.Array(PackSettings)]);
|
|
1084
|
-
const isEntryList = Schema.is(Schema.Array(Schema.String));
|
|
1085
|
-
const WorkspaceConfig = Schema.Struct({
|
|
1086
|
-
msch: Schema.Struct({ publish: Schema.Struct({ installSize: SizeText }) }),
|
|
1087
|
-
pack: Schema.optional(PackList)
|
|
1088
|
-
});
|
|
1089
|
-
const PublicManifest = Schema.Struct({ private: Schema.optional(Schema.Literal(false)) });
|
|
1090
|
-
const taggedError$2 = Schema.TaggedError;
|
|
1091
|
-
var WorkspaceConfigUnreadable = class extends taggedError$2()("WorkspaceConfigUnreadable", { file: Schema.String }) {};
|
|
1092
|
-
const bytesPer = (unit) => pipe(UNIT_BYTES, Array.findFirst(([name]) => name === unit), Option.map(([, bytes]) => bytes), Option.getOrElse(() => NaN));
|
|
1093
|
-
const nameOf = (source) => pipe(String$1.split(source, SEPARATOR$1), Array.last, Option.getOrElse(() => source), String$1.replace(SOURCE_EXTENSION, ""));
|
|
1094
|
-
const entriesOf = (entry) => {
|
|
1095
|
-
if (Predicate.isString(entry)) return [{
|
|
1096
|
-
name: nameOf(entry),
|
|
1097
|
-
source: entry
|
|
1098
|
-
}];
|
|
1099
|
-
if (isEntryList(entry)) return pipe(entry, Array.map((source) => ({
|
|
1100
|
-
name: nameOf(source),
|
|
1101
|
-
source
|
|
1102
|
-
})));
|
|
1103
|
-
return pipe(Record.toEntries(entry), Array.map(([name, source]) => ({
|
|
1104
|
-
name,
|
|
1105
|
-
source
|
|
1106
|
-
})));
|
|
1107
|
-
};
|
|
1108
|
-
const packEntriesOf = (pack) => pipe(Option.fromUndefinedOr(pack), Option.map(Array.ensure), Option.getOrElse(() => []), Array.flatMap((setting) => pipe(Option.fromUndefinedOr(setting.entry), Option.match({
|
|
1109
|
-
onNone: () => [],
|
|
1110
|
-
onSome: entriesOf
|
|
1111
|
-
}))));
|
|
1112
|
-
const settingsIn = Effect.fn("settingsIn")(function* settingsIn(file) {
|
|
1113
|
-
const config = yield* Effect.tryPromise({
|
|
1114
|
-
try: () => resolveConfigFromFile(file),
|
|
1115
|
-
catch: () => WorkspaceConfigUnreadable.make({ file })
|
|
1116
|
-
}).pipe(Effect.option);
|
|
1117
|
-
return pipe(config, Option.flatMap(Schema.decodeUnknownOption(WorkspaceConfig)));
|
|
1118
|
-
});
|
|
1119
|
-
const isPublicPackage = Effect.fn("isPublicPackage")(function* isPublicPackage(directory) {
|
|
1120
|
-
const files = yield* RepositoryFiles;
|
|
1121
|
-
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
1122
|
-
return Option.exists(text, (found) => Option.isSome(Schema.decodeOption(Schema.fromJsonString(PublicManifest))(found)));
|
|
1123
|
-
});
|
|
1124
|
-
const workspaceOf = (directory, configFile, join) => ({ msch, pack }) => {
|
|
1125
|
-
const [amount, , unit] = msch.publish.installSize;
|
|
979
|
+
// src/text-position.ts
|
|
980
|
+
const START$5 = 0;
|
|
981
|
+
const FIRST_COLUMN$2 = 1;
|
|
982
|
+
const positionOf = (source) => (index) => {
|
|
983
|
+
const before = pipe(source, String$1.slice(START$5, index), String$1.split("\n"));
|
|
1126
984
|
return {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
name: entry.name,
|
|
1133
|
-
source: join(entry.source)
|
|
1134
|
-
})))
|
|
985
|
+
line: before.length,
|
|
986
|
+
column: pipe(Array.last(before), Option.match({
|
|
987
|
+
onNone: () => FIRST_COLUMN$2,
|
|
988
|
+
onSome: (last) => last.length + FIRST_COLUMN$2
|
|
989
|
+
}))
|
|
1135
990
|
};
|
|
1136
991
|
};
|
|
1137
|
-
const publishedIn = Effect.fn("publishedIn")(function* publishedIn(root, configName) {
|
|
1138
|
-
const files = yield* RepositoryFiles;
|
|
1139
|
-
const configFile = files.join(root, configName);
|
|
1140
|
-
const directory = files.dirname(configFile);
|
|
1141
|
-
if (!(yield* isPublicPackage(directory))) return Option.none();
|
|
1142
|
-
const settings = yield* settingsIn(configFile);
|
|
1143
|
-
return pipe(settings, Option.map(workspaceOf(directory, configFile, (source) => files.join(directory, source))));
|
|
1144
|
-
});
|
|
1145
|
-
/** @internal */
|
|
1146
|
-
const publishedWorkspaces = Effect.fn("publishedWorkspaces")(function* publishedWorkspaces(root) {
|
|
1147
|
-
const files = yield* RepositoryFiles;
|
|
1148
|
-
const names = yield* files.listedFiles(root);
|
|
1149
|
-
const configs = pipe(names, Array.filter((name) => files.basename(name) === CONFIG_FILE && String$1.includes(SEPARATOR$1)(name)));
|
|
1150
|
-
const found = yield* Effect.forEach(configs, (name) => publishedIn(root, name), { concurrency: READ_CONCURRENCY$2 });
|
|
1151
|
-
return Array.getSomes(found);
|
|
1152
|
-
});
|
|
1153
992
|
// src/install-size.ts
|
|
1154
993
|
const INSTALL_SIZE = "install-size";
|
|
1155
994
|
const STACK_DEPENDENCY = "stack-dependency";
|
|
@@ -1160,11 +999,11 @@ const LISTED_LARGEST = 5;
|
|
|
1160
999
|
const SIZE_CONCURRENCY = 32;
|
|
1161
1000
|
const MEGABYTE = 1e6;
|
|
1162
1001
|
const MEGABYTE_DIGITS = 1;
|
|
1163
|
-
const START = 0;
|
|
1002
|
+
const START$4 = 0;
|
|
1164
1003
|
const SINGLE_ENTRY = 1;
|
|
1165
1004
|
const megabytes = (bytes) => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;
|
|
1166
1005
|
const usageHint = (dependency, entryCount) => {
|
|
1167
|
-
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START && dependency.entries.length < entryCount)) return "";
|
|
1006
|
+
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$4 && dependency.entries.length < entryCount)) return "";
|
|
1168
1007
|
return ` (imported only from ${Array.join(dependency.entries, ", ")})`;
|
|
1169
1008
|
};
|
|
1170
1009
|
const listed = ({ largest, entryCount }) => pipe(largest, Array.map((dependency) => `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`), Array.join(", "));
|
|
@@ -1173,7 +1012,7 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
|
|
|
1173
1012
|
const { workspace, total } = overrun;
|
|
1174
1013
|
const config = yield* files.readFile(workspace.configFile);
|
|
1175
1014
|
const source = Option.getOrElse(config, () => "");
|
|
1176
|
-
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START);
|
|
1015
|
+
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$4);
|
|
1177
1016
|
return {
|
|
1178
1017
|
file: workspace.configFile,
|
|
1179
1018
|
...positionOf(source)(index),
|
|
@@ -1190,7 +1029,7 @@ const measure = Effect.fn("measure")(function* measure({ workspace, provided },
|
|
|
1190
1029
|
const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
|
|
1191
1030
|
const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
|
|
1192
1031
|
const sizes = HashMap.fromIterable(measured);
|
|
1193
|
-
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START))));
|
|
1032
|
+
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$4))));
|
|
1194
1033
|
return {
|
|
1195
1034
|
closures,
|
|
1196
1035
|
sizeOf,
|
|
@@ -1223,11 +1062,11 @@ const sizeProblems = Effect.fn("sizeProblems")(function* sizeProblems(published,
|
|
|
1223
1062
|
})];
|
|
1224
1063
|
});
|
|
1225
1064
|
const stackProblems = (file, source, dependencies) => {
|
|
1226
|
-
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START);
|
|
1065
|
+
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$4);
|
|
1227
1066
|
const rest = String$1.slice(section)(source);
|
|
1228
1067
|
return pipe(Record.toEntries(dependencies), Array.filter(([, specifier]) => specifier === STACK_CATALOG), Array.map(([name]) => ({
|
|
1229
1068
|
file,
|
|
1230
|
-
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START)),
|
|
1069
|
+
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$4)),
|
|
1231
1070
|
rule: STACK_DEPENDENCY,
|
|
1232
1071
|
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.`
|
|
1233
1072
|
})));
|
|
@@ -1273,38 +1112,69 @@ const checkPublishedPackages = Effect.fn("checkPublishedPackages")(function* che
|
|
|
1273
1112
|
return Array.flatten(found);
|
|
1274
1113
|
});
|
|
1275
1114
|
// src/nested-docs.ts
|
|
1276
|
-
const RULE = "nested-docs";
|
|
1277
|
-
const
|
|
1278
|
-
const
|
|
1279
|
-
const
|
|
1115
|
+
const RULE$6 = "nested-docs";
|
|
1116
|
+
const CONFIG_FILE$4 = "vite.config.ts";
|
|
1117
|
+
const SEPARATOR$2 = "/";
|
|
1118
|
+
const FIRST$3 = 1;
|
|
1119
|
+
const READ_CONCURRENCY$6 = 64;
|
|
1280
1120
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1281
|
-
const
|
|
1282
|
-
const
|
|
1283
|
-
const
|
|
1121
|
+
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
1122
|
+
const README$1 = /^README(?:\.[^/]+)?$/iu;
|
|
1123
|
+
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1124
|
+
const taggedError$4 = Schema.TaggedError;
|
|
1125
|
+
var RootConfigUnreadable = class extends taggedError$4()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1126
|
+
const isNested = (name) => String$1.includes(SEPARATOR$2)(name);
|
|
1127
|
+
const problemFor$1 = (file, message) => ({
|
|
1284
1128
|
file,
|
|
1285
|
-
line: FIRST,
|
|
1286
|
-
column: FIRST,
|
|
1287
|
-
rule: RULE,
|
|
1129
|
+
line: FIRST$3,
|
|
1130
|
+
column: FIRST$3,
|
|
1131
|
+
rule: RULE$6,
|
|
1288
1132
|
message
|
|
1289
1133
|
});
|
|
1290
1134
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
1291
|
-
const
|
|
1292
|
-
const
|
|
1135
|
+
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.";
|
|
1136
|
+
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.";
|
|
1137
|
+
const agentDocProblem = ({ file, base, directory }, allowed) => {
|
|
1138
|
+
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$1(file, `${base} ${AGENT_DOCS_MESSAGE}`));
|
|
1139
|
+
if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1140
|
+
return Option.some(problemFor$1(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
|
|
1141
|
+
};
|
|
1142
|
+
const readmeProblem = ({ file, base, directory }, allowed) => {
|
|
1143
|
+
if (!README$1.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1144
|
+
return Option.some(problemFor$1(file, `${base} ${README_MESSAGE}`));
|
|
1145
|
+
};
|
|
1146
|
+
const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, allowed, name) {
|
|
1293
1147
|
const files = yield* RepositoryFiles;
|
|
1294
|
-
const base = files.basename(name);
|
|
1295
1148
|
const file = files.join(root, name);
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1149
|
+
const doc = {
|
|
1150
|
+
file,
|
|
1151
|
+
base: files.basename(name),
|
|
1152
|
+
directory: files.dirname(file)
|
|
1153
|
+
};
|
|
1154
|
+
if (AGENT_DOCS.test(doc.base)) return agentDocProblem(doc, allowed);
|
|
1155
|
+
return readmeProblem(doc, allowed);
|
|
1156
|
+
});
|
|
1157
|
+
const allowsWorkspaceAgentDocs = Effect.fn("allowsWorkspaceAgentDocs")(function* allowsWorkspaceAgentDocs(root) {
|
|
1158
|
+
const files = yield* RepositoryFiles;
|
|
1159
|
+
const file = files.join(root, CONFIG_FILE$4);
|
|
1160
|
+
if (!(yield* files.exists(file))) return false;
|
|
1161
|
+
const config = yield* Effect.tryPromise({
|
|
1162
|
+
try: () => resolveConfigFromFile(file),
|
|
1163
|
+
catch: () => RootConfigUnreadable.make({ file })
|
|
1164
|
+
}).pipe(Effect.option);
|
|
1165
|
+
return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig$1)), Option.isSome);
|
|
1300
1166
|
});
|
|
1301
1167
|
/** @internal */
|
|
1302
1168
|
const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(root) {
|
|
1303
|
-
const
|
|
1169
|
+
const files = yield* RepositoryFiles;
|
|
1170
|
+
const names = yield* files.listedFiles(root);
|
|
1304
1171
|
const nested = pipe(names, Array.filter(isNested));
|
|
1305
|
-
const
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1172
|
+
const workspaceAgentDocs = yield* allowsWorkspaceAgentDocs(root);
|
|
1173
|
+
const allowed = {
|
|
1174
|
+
workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
|
|
1175
|
+
workspaceAgentDocs
|
|
1176
|
+
};
|
|
1177
|
+
const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$6 });
|
|
1308
1178
|
return Array.getSomes(found);
|
|
1309
1179
|
});
|
|
1310
1180
|
// src/override-findings.ts
|
|
@@ -1498,12 +1368,12 @@ const RESOLUTION_FILES = [
|
|
|
1498
1368
|
];
|
|
1499
1369
|
const RESOLUTION_CONCURRENCY = 4;
|
|
1500
1370
|
const SUCCEEDED = 0;
|
|
1501
|
-
const taggedError$
|
|
1502
|
-
var OverrideResolutionFailed = class extends taggedError$
|
|
1371
|
+
const taggedError$3 = Schema.TaggedError;
|
|
1372
|
+
var OverrideResolutionFailed = class extends taggedError$3()("OverrideResolutionFailed", {
|
|
1503
1373
|
override: Schema.String,
|
|
1504
1374
|
output: Schema.String
|
|
1505
1375
|
}) {};
|
|
1506
|
-
const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
1376
|
+
const textOf$1 = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
1507
1377
|
const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override) {
|
|
1508
1378
|
const handle = yield* ChildProcess.make("vp", [
|
|
1509
1379
|
"install",
|
|
@@ -1517,7 +1387,7 @@ const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override
|
|
|
1517
1387
|
extendEnv: true,
|
|
1518
1388
|
stdin: "ignore"
|
|
1519
1389
|
});
|
|
1520
|
-
const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
1390
|
+
const [output, status] = yield* Effect.all([textOf$1(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
1521
1391
|
if (Number(status) !== SUCCEEDED) return yield* OverrideResolutionFailed.make({
|
|
1522
1392
|
override,
|
|
1523
1393
|
output
|
|
@@ -1534,7 +1404,7 @@ const auditIn = Effect.fn("auditIn")(function* auditIn(directory) {
|
|
|
1534
1404
|
extendEnv: true,
|
|
1535
1405
|
stdin: "ignore"
|
|
1536
1406
|
});
|
|
1537
|
-
const [report] = yield* Effect.all([textOf(handle.stdout), handle.exitCode], { concurrency: "unbounded" });
|
|
1407
|
+
const [report] = yield* Effect.all([textOf$1(handle.stdout), handle.exitCode], { concurrency: "unbounded" });
|
|
1538
1408
|
return advisoriesIn(report);
|
|
1539
1409
|
}, Effect.scoped);
|
|
1540
1410
|
const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* trackedFiles(root) {
|
|
@@ -1544,7 +1414,7 @@ const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* tra
|
|
|
1544
1414
|
"--",
|
|
1545
1415
|
...RESOLUTION_FILES
|
|
1546
1416
|
], { cwd: root });
|
|
1547
|
-
const listed = yield* textOf(handle.stdout);
|
|
1417
|
+
const listed = yield* textOf$1(handle.stdout);
|
|
1548
1418
|
return pipe(String$1.split(listed, "\0"), Array.filter(String$1.isNonEmpty));
|
|
1549
1419
|
}, Effect.scoped);
|
|
1550
1420
|
const copyFiles = Effect.fn("copyFiles")(function* copyFiles(workspace, directory) {
|
|
@@ -1601,6 +1471,425 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
|
|
|
1601
1471
|
if (Option.isNone(manifest) || !Array.isReadonlyArrayNonEmpty(keys)) return [];
|
|
1602
1472
|
return yield* problemsFor(root, manifest.value, keys);
|
|
1603
1473
|
});
|
|
1474
|
+
// src/root-readme.ts
|
|
1475
|
+
const RULE$5 = "root-readme";
|
|
1476
|
+
const SEPARATOR$1 = "/";
|
|
1477
|
+
const ALTERNATIVE = "|";
|
|
1478
|
+
const SCOPE = /^@[^/]+\//u;
|
|
1479
|
+
const README = /^README(?:\.[^/]+)?$/iu;
|
|
1480
|
+
const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
|
|
1481
|
+
const READ_CONCURRENCY$5 = 16;
|
|
1482
|
+
const START$3 = 0;
|
|
1483
|
+
const NamedManifest = Schema.fromJsonString(Schema.Struct({ name: Schema.optional(Schema.String) }));
|
|
1484
|
+
const patternOf = (names) => {
|
|
1485
|
+
const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
|
|
1486
|
+
return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
|
|
1487
|
+
};
|
|
1488
|
+
const packageNameIn = (text) => pipe(text, Option.flatMap(Schema.decodeOption(NamedManifest)), Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)));
|
|
1489
|
+
const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(root, name) {
|
|
1490
|
+
const files = yield* RepositoryFiles;
|
|
1491
|
+
const directory = files.dirname(name);
|
|
1492
|
+
const text = yield* files.readFile(files.join(root, name));
|
|
1493
|
+
const packageName = packageNameIn(text);
|
|
1494
|
+
const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
|
|
1495
|
+
const names = pipe([
|
|
1496
|
+
Option.some(directory),
|
|
1497
|
+
Option.some(files.basename(directory)),
|
|
1498
|
+
packageName,
|
|
1499
|
+
unscoped
|
|
1500
|
+
], Array.getSomes, Array.dedupe);
|
|
1501
|
+
return {
|
|
1502
|
+
directory,
|
|
1503
|
+
pattern: patternOf(names)
|
|
1504
|
+
};
|
|
1505
|
+
});
|
|
1506
|
+
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.`;
|
|
1507
|
+
const problemsIn$2 = (file, source) => ({ directory, pattern }) => {
|
|
1508
|
+
const message = messageFor(directory);
|
|
1509
|
+
const at = positionOf(source);
|
|
1510
|
+
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1511
|
+
file,
|
|
1512
|
+
...at(found.index ?? START$3),
|
|
1513
|
+
rule: RULE$5,
|
|
1514
|
+
message
|
|
1515
|
+
})));
|
|
1516
|
+
};
|
|
1517
|
+
const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadme(file, workspaces) {
|
|
1518
|
+
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1519
|
+
return pipe(text, Option.match({
|
|
1520
|
+
onNone: () => [],
|
|
1521
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$2(file, source)))
|
|
1522
|
+
}));
|
|
1523
|
+
});
|
|
1524
|
+
/** @internal */
|
|
1525
|
+
const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(root) {
|
|
1526
|
+
const files = yield* RepositoryFiles;
|
|
1527
|
+
const names = yield* files.listedFiles(root);
|
|
1528
|
+
const readmes = pipe(names, Array.filter((name) => README.test(name)));
|
|
1529
|
+
const manifests = pipe(names, Array.filter((name) => String$1.includes(SEPARATOR$1)(name) && files.basename(name) === "package.json"));
|
|
1530
|
+
const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), { concurrency: READ_CONCURRENCY$5 });
|
|
1531
|
+
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$5 });
|
|
1532
|
+
return Array.flatten(found);
|
|
1533
|
+
});
|
|
1534
|
+
// src/found-comment.ts
|
|
1535
|
+
const taggedError$2 = Schema.TaggedError;
|
|
1536
|
+
var CommentsUnreadable = class extends taggedError$2()("CommentsUnreadable", {
|
|
1537
|
+
reader: Schema.String,
|
|
1538
|
+
message: Schema.String
|
|
1539
|
+
}) {};
|
|
1540
|
+
const unreadable = (reader) => (cause) => CommentsUnreadable.make({
|
|
1541
|
+
reader,
|
|
1542
|
+
message: String(cause)
|
|
1543
|
+
});
|
|
1544
|
+
const trimmed = ({ index, text }) => ({
|
|
1545
|
+
index,
|
|
1546
|
+
text: String$1.trimEnd(text)
|
|
1547
|
+
});
|
|
1548
|
+
// src/config-comments.ts
|
|
1549
|
+
const NEXT$2 = 1;
|
|
1550
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
1551
|
+
const childrenOf = (value) => {
|
|
1552
|
+
if (Array.isArray(value)) return value;
|
|
1553
|
+
if (isRecord(value)) return Record.values(value);
|
|
1554
|
+
return [];
|
|
1555
|
+
};
|
|
1556
|
+
const collect = (isItem) => (value) => {
|
|
1557
|
+
if (isItem(value)) return [value];
|
|
1558
|
+
return pipe(childrenOf(value), Array.flatMap(collect(isItem)));
|
|
1559
|
+
};
|
|
1560
|
+
const isYamlComment = (value) => isRecord(value) && value["type"] === "comment" && typeof value["offset"] === "number" && typeof value["source"] === "string";
|
|
1561
|
+
const yamlComments = (source) => Effect.try({
|
|
1562
|
+
try: () => pipe(Array.fromIterable(new Parser().parse(source)), Array.flatMap(collect(isYamlComment)), Array.map((token) => trimmed({
|
|
1563
|
+
index: token.offset,
|
|
1564
|
+
text: token.source
|
|
1565
|
+
}))),
|
|
1566
|
+
catch: unreadable("yaml")
|
|
1567
|
+
});
|
|
1568
|
+
const tomlComments = (source) => Effect.try({
|
|
1569
|
+
try: () => pipe(parseTOML(source).comments, Array.map(({ range: [start, end] }) => trimmed({
|
|
1570
|
+
index: start,
|
|
1571
|
+
text: String$1.slice(start, end)(source)
|
|
1572
|
+
}))),
|
|
1573
|
+
catch: unreadable("toml")
|
|
1574
|
+
});
|
|
1575
|
+
const isSqlComment = (value) => isRecord(value) && (value["type"] === "line_comment" || value["type"] === "block_comment") && typeof value["text"] === "string" && Array.isArray(value["range"]);
|
|
1576
|
+
const sqlComments = (source) => Effect.try({
|
|
1577
|
+
try: () => {
|
|
1578
|
+
const program = parse$2(source, {
|
|
1579
|
+
dialect: "sqlite",
|
|
1580
|
+
includeComments: true,
|
|
1581
|
+
includeRange: true,
|
|
1582
|
+
paramTypes: []
|
|
1583
|
+
});
|
|
1584
|
+
return pipe(collect(isSqlComment)(program), Array.map(({ range: [start], text }) => trimmed({
|
|
1585
|
+
index: start,
|
|
1586
|
+
text
|
|
1587
|
+
})));
|
|
1588
|
+
},
|
|
1589
|
+
catch: unreadable("sql")
|
|
1590
|
+
});
|
|
1591
|
+
const offsetAt = (lines) => ({ line, character }) => character + pipe(lines, Array.take(line), Array.map((text) => text.length + NEXT$2), Number$1.sumAll);
|
|
1592
|
+
const dockerfileComments = (source) => Effect.try({
|
|
1593
|
+
try: () => {
|
|
1594
|
+
const lines = String$1.split(source, "\n");
|
|
1595
|
+
return pipe(DockerfileParser.parse(source).getComments(), Array.map((comment) => trimmed({
|
|
1596
|
+
index: offsetAt(lines)(comment.getRange().start),
|
|
1597
|
+
text: comment.toString()
|
|
1598
|
+
})));
|
|
1599
|
+
},
|
|
1600
|
+
catch: unreadable("dockerfile")
|
|
1601
|
+
});
|
|
1602
|
+
// src/comment-readers.ts
|
|
1603
|
+
const GRAMMARS = [
|
|
1604
|
+
"bash",
|
|
1605
|
+
"c-sharp",
|
|
1606
|
+
"cpp",
|
|
1607
|
+
"css",
|
|
1608
|
+
"go",
|
|
1609
|
+
"java",
|
|
1610
|
+
"javascript",
|
|
1611
|
+
"php",
|
|
1612
|
+
"powershell",
|
|
1613
|
+
"ruby",
|
|
1614
|
+
"rust",
|
|
1615
|
+
"tsx",
|
|
1616
|
+
"typescript"
|
|
1617
|
+
];
|
|
1618
|
+
const COMMENT_NODES = [
|
|
1619
|
+
"comment",
|
|
1620
|
+
"line_comment",
|
|
1621
|
+
"block_comment",
|
|
1622
|
+
"multiline_comment"
|
|
1623
|
+
];
|
|
1624
|
+
const START$2 = 0;
|
|
1625
|
+
const NEXT$1 = 1;
|
|
1626
|
+
const NONE$1 = [];
|
|
1627
|
+
const grammarFile = (grammar) => fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));
|
|
1628
|
+
const loadGrammar = (grammar) => Effect.tryPromise({
|
|
1629
|
+
try: () => treeSitter.Language.load(grammarFile(grammar)),
|
|
1630
|
+
catch: unreadable(grammar)
|
|
1631
|
+
}).pipe(Effect.map((language) => [grammar, language]));
|
|
1632
|
+
const loadGrammars = Effect.fn("loadGrammars")(function* loadGrammars() {
|
|
1633
|
+
yield* Effect.tryPromise({
|
|
1634
|
+
try: () => treeSitter.Parser.init(),
|
|
1635
|
+
catch: unreadable("javascript")
|
|
1636
|
+
});
|
|
1637
|
+
const loaded = yield* pipe(GRAMMARS, Effect.forEach((grammar) => loadGrammar(grammar)));
|
|
1638
|
+
const languages = Record.fromEntries(loaded);
|
|
1639
|
+
const grammars = (grammar) => Record.get(languages, grammar);
|
|
1640
|
+
return grammars;
|
|
1641
|
+
});
|
|
1642
|
+
const commentNodesIn = (language, source) => {
|
|
1643
|
+
const parser = new treeSitter.Parser();
|
|
1644
|
+
parser.setLanguage(language);
|
|
1645
|
+
const tree = parser.parse(source);
|
|
1646
|
+
parser.delete();
|
|
1647
|
+
if (tree === null) return NONE$1;
|
|
1648
|
+
const found = pipe(tree.rootNode.descendantsOfType(COMMENT_NODES), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.map((node) => trimmed({
|
|
1649
|
+
index: node.startIndex,
|
|
1650
|
+
text: node.text
|
|
1651
|
+
})));
|
|
1652
|
+
tree.delete();
|
|
1653
|
+
return found;
|
|
1654
|
+
};
|
|
1655
|
+
const syntaxComments = (grammars, grammar) => (source) => Option.match(grammars(grammar), {
|
|
1656
|
+
onNone: () => Effect.fail(unreadable(grammar)("the grammar is not loaded")),
|
|
1657
|
+
onSome: (language) => Effect.try({
|
|
1658
|
+
try: () => commentNodesIn(language, source),
|
|
1659
|
+
catch: unreadable(grammar)
|
|
1660
|
+
})
|
|
1661
|
+
});
|
|
1662
|
+
const SCRIPT_TYPE = /^(?:|module|text\/javascript|application\/javascript)$/iu;
|
|
1663
|
+
const SHADER_TYPE = /shader|glsl/iu;
|
|
1664
|
+
const scriptGrammar = (attribs) => {
|
|
1665
|
+
const type = String$1.trim(Option.getOrElse(Record.get(attribs, "type"), () => ""));
|
|
1666
|
+
if (Record.get(attribs, "lang").pipe(Option.contains("ts"))) return Option.some("typescript");
|
|
1667
|
+
if (SHADER_TYPE.test(type)) return Option.some("cpp");
|
|
1668
|
+
return Option.liftPredicate("javascript", () => SCRIPT_TYPE.test(type));
|
|
1669
|
+
};
|
|
1670
|
+
const embeddedGrammar = ({ name, attribs }) => {
|
|
1671
|
+
if (name === "style") return Option.some("css");
|
|
1672
|
+
if (name === "script") return scriptGrammar(attribs);
|
|
1673
|
+
return Option.none();
|
|
1674
|
+
};
|
|
1675
|
+
const shifted = (offset) => ({ index, text }) => ({
|
|
1676
|
+
index: index + offset,
|
|
1677
|
+
text
|
|
1678
|
+
});
|
|
1679
|
+
const markupComment = (source) => (node) => {
|
|
1680
|
+
if (!isComment(node) || node.startIndex === null || node.endIndex === null) return NONE$1;
|
|
1681
|
+
return [{
|
|
1682
|
+
index: node.startIndex,
|
|
1683
|
+
text: String$1.slice(node.startIndex, node.endIndex + NEXT$1)(source)
|
|
1684
|
+
}];
|
|
1685
|
+
};
|
|
1686
|
+
const textComments = (grammars, grammar) => (text) => {
|
|
1687
|
+
const shift = shifted(text.startIndex ?? START$2);
|
|
1688
|
+
return syntaxComments(grammars, grammar)(text.data).pipe(Effect.map(Array.map(shift)));
|
|
1689
|
+
};
|
|
1690
|
+
const embeddedComments = (grammars) => (node) => {
|
|
1691
|
+
if (!isTag(node)) return Effect.succeed(NONE$1);
|
|
1692
|
+
const texts = pipe(node.children, Array.filter(isText));
|
|
1693
|
+
return Option.match(embeddedGrammar(node), {
|
|
1694
|
+
onNone: () => Effect.succeed(NONE$1),
|
|
1695
|
+
onSome: (grammar) => pipe(texts, Effect.forEach(textComments(grammars, grammar)), Effect.map(Array.flatten))
|
|
1696
|
+
});
|
|
1697
|
+
};
|
|
1698
|
+
const markupComments = (grammars, markup) => (source) => Effect.gen(function* readMarkup() {
|
|
1699
|
+
const document = parseDocument$1(source, {
|
|
1700
|
+
xmlMode: markup === "xml",
|
|
1701
|
+
withStartIndices: true,
|
|
1702
|
+
withEndIndices: true
|
|
1703
|
+
});
|
|
1704
|
+
const nodes = DomUtils.filter(() => true, document.children, true);
|
|
1705
|
+
const own = pipe(nodes, Array.flatMap(markupComment(source)));
|
|
1706
|
+
if (markup === "xml") return own;
|
|
1707
|
+
const embedded = yield* pipe(nodes, Effect.forEach(embeddedComments(grammars)));
|
|
1708
|
+
return [...own, ...Array.flatten(embedded)];
|
|
1709
|
+
});
|
|
1710
|
+
const isGrammar = (reader) => pipe(GRAMMARS, Array.contains(reader));
|
|
1711
|
+
const commentsWith = (grammars) => (reader, source) => {
|
|
1712
|
+
if (isGrammar(reader)) return syntaxComments(grammars, reader)(source);
|
|
1713
|
+
return {
|
|
1714
|
+
html: markupComments(grammars, "html"),
|
|
1715
|
+
xml: markupComments(grammars, "xml"),
|
|
1716
|
+
yaml: yamlComments,
|
|
1717
|
+
toml: tomlComments,
|
|
1718
|
+
sql: sqlComments,
|
|
1719
|
+
dockerfile: dockerfileComments
|
|
1720
|
+
}[reader](source);
|
|
1721
|
+
};
|
|
1722
|
+
// src/comments.ts
|
|
1723
|
+
const RULE$4 = "comment";
|
|
1724
|
+
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1725
|
+
const VENDORED_PATHSPEC = ":(attr:linguist-vendored)";
|
|
1726
|
+
const READ_CONCURRENCY$4 = 64;
|
|
1727
|
+
const START$1 = 0;
|
|
1728
|
+
const FIRST_LINE$1 = 1;
|
|
1729
|
+
const FIRST_COLUMN$1 = 1;
|
|
1730
|
+
const READERS = [
|
|
1731
|
+
[/\.(?:[cm]?jsx?)$/u, "javascript"],
|
|
1732
|
+
[/\.(?:[cm]?ts)$/u, "typescript"],
|
|
1733
|
+
[/\.tsx$/u, "tsx"],
|
|
1734
|
+
[/\.rs$/u, "rust"],
|
|
1735
|
+
[/\.(?:cs|csx)$/u, "c-sharp"],
|
|
1736
|
+
[/\.(?:sh|bash|zsh|ksh)$/u, "bash"],
|
|
1737
|
+
[/(?:^|\/)\.(?:vite-hooks|husky|githooks)\/[^./][^/]*$/u, "bash"],
|
|
1738
|
+
[/\.(?:ps1|psm1|psd1)$/u, "powershell"],
|
|
1739
|
+
[/\.go$/u, "go"],
|
|
1740
|
+
[/\.(?:java|kt|kts)$/u, "java"],
|
|
1741
|
+
[/\.(?:rb|rake)$/u, "ruby"],
|
|
1742
|
+
[/\.php$/u, "php"],
|
|
1743
|
+
[/\.(?:c|h|cc|cpp|cxx|hpp|hh|m|mm|glsl|frag|vert|comp|wgsl|hlsl|metal)$/u, "cpp"],
|
|
1744
|
+
[/\.(?:css|pcss)$/u, "css"],
|
|
1745
|
+
[/\.(?:html?|vue|svelte|astro)$/u, "html"],
|
|
1746
|
+
[/\.(?:xml|xaml|plist|resx|props|targets|[a-z]+proj|manifest|nuspec)$/u, "xml"],
|
|
1747
|
+
[/\.ya?ml$/u, "yaml"],
|
|
1748
|
+
[/\.toml$/u, "toml"],
|
|
1749
|
+
[/\.sql$/u, "sql"],
|
|
1750
|
+
[/(?:^|\/)(?:Dockerfile|Containerfile)(?:\.[^/]+)?$|\.dockerfile$/u, "dockerfile"]
|
|
1751
|
+
];
|
|
1752
|
+
const SHEBANG_READERS = [
|
|
1753
|
+
[/^#!.*\b(?:ba|z|k|da)?sh\b/u, "bash"],
|
|
1754
|
+
[/^#!.*\b(?:node|bun|deno|tsx)\b/u, "javascript"],
|
|
1755
|
+
[/^#!.*\bpwsh\b/u, "powershell"]
|
|
1756
|
+
];
|
|
1757
|
+
const SHEBANG = "#!";
|
|
1758
|
+
const PIN = /@(?:[0-9a-f]{40}|sha256:[0-9a-f]{64})\s*$/u;
|
|
1759
|
+
const VERSION = /^\s?v?\d[\w.+-]*$/u;
|
|
1760
|
+
const DELIMITERS = /^(?:\/\/|\/\*|<!--|<#|#|--)|(?:\*\/|-->|#>)$/gu;
|
|
1761
|
+
const MESSAGE = "Comments are not written in this repository. Say it with names and types in the code, put the reason in the commit message, and delete the comment.";
|
|
1762
|
+
const Patterns = Schema.Array(Schema.String);
|
|
1763
|
+
const CommentSettings = Schema.Struct({ allow: Patterns });
|
|
1764
|
+
const MschSettings = Schema.Struct({ comments: Schema.optional(CommentSettings) });
|
|
1765
|
+
const LintSettings = Schema.Struct({ ignorePatterns: Schema.optional(Patterns) });
|
|
1766
|
+
const RootConfig = Schema.Struct({
|
|
1767
|
+
msch: Schema.optional(MschSettings),
|
|
1768
|
+
lint: Schema.optional(LintSettings)
|
|
1769
|
+
});
|
|
1770
|
+
const NO_SETTINGS = {
|
|
1771
|
+
allow: [],
|
|
1772
|
+
ignorePatterns: []
|
|
1773
|
+
};
|
|
1774
|
+
const NONE = [];
|
|
1775
|
+
const taggedError$1 = Schema.TaggedError;
|
|
1776
|
+
var CommentConfigUnreadable = class extends taggedError$1()("CommentConfigUnreadable", { file: Schema.String }) {};
|
|
1777
|
+
const shebangReader = (source) => {
|
|
1778
|
+
if (!String$1.startsWith(SHEBANG)(source)) return Option.none();
|
|
1779
|
+
return pipe(SHEBANG_READERS, Array.findFirst(([pattern]) => pattern.test(source)));
|
|
1780
|
+
};
|
|
1781
|
+
const readerOf = (name, source) => pipe(READERS, Array.findFirst(([pattern]) => pattern.test(name)), Option.orElse(() => shebangReader(source)), Option.map(([, reader]) => reader));
|
|
1782
|
+
const valueOf = (text) => String$1.replaceAll(DELIMITERS, "")(text);
|
|
1783
|
+
const lineBefore = (source, index) => {
|
|
1784
|
+
const lines = pipe(source, String$1.slice(START$1, index), String$1.split("\n"));
|
|
1785
|
+
return Option.getOrElse(Array.last(lines), () => "");
|
|
1786
|
+
};
|
|
1787
|
+
const isPinVersion = (source, { index, text }) => PIN.test(lineBefore(source, index)) && VERSION.test(valueOf(text));
|
|
1788
|
+
const isShebang = ({ index, text }) => index === START$1 && String$1.startsWith(SHEBANG)(text);
|
|
1789
|
+
const isAllowed = (source, directives) => (comment) => isShebang(comment) || directives.test(valueOf(comment.text)) || isPinVersion(source, comment);
|
|
1790
|
+
const problemOf$1 = (file, source) => ({ index }) => ({
|
|
1791
|
+
file,
|
|
1792
|
+
...positionOf(source)(index),
|
|
1793
|
+
rule: RULE$4,
|
|
1794
|
+
message: MESSAGE
|
|
1795
|
+
});
|
|
1796
|
+
const unreadableProblem = (file, message) => ({
|
|
1797
|
+
file,
|
|
1798
|
+
line: FIRST_LINE$1,
|
|
1799
|
+
column: FIRST_COLUMN$1,
|
|
1800
|
+
rule: RULE$4,
|
|
1801
|
+
message: `msch could not read the comments in this file: ${message}`
|
|
1802
|
+
});
|
|
1803
|
+
const settingsOf = ({ msch, lint }) => ({
|
|
1804
|
+
allow: pipe(Option.fromUndefinedOr(msch), Option.flatMap(({ comments }) => Option.fromUndefinedOr(comments)), Option.match({
|
|
1805
|
+
onNone: () => NO_SETTINGS.allow,
|
|
1806
|
+
onSome: ({ allow }) => allow
|
|
1807
|
+
})),
|
|
1808
|
+
ignorePatterns: pipe(Option.fromUndefinedOr(lint), Option.flatMap(({ ignorePatterns }) => Option.fromUndefinedOr(ignorePatterns)), Option.getOrElse(() => NO_SETTINGS.ignorePatterns))
|
|
1809
|
+
});
|
|
1810
|
+
const rootSettings = Effect.fn("rootSettings")(function* rootSettings(root) {
|
|
1811
|
+
const files = yield* RepositoryFiles;
|
|
1812
|
+
const file = files.join(root, CONFIG_FILE$3);
|
|
1813
|
+
if (!(yield* files.exists(file))) return NO_SETTINGS;
|
|
1814
|
+
const config = yield* Effect.tryPromise({
|
|
1815
|
+
try: () => resolveConfigFromFile(file),
|
|
1816
|
+
catch: () => CommentConfigUnreadable.make({ file })
|
|
1817
|
+
}).pipe(Effect.option);
|
|
1818
|
+
return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig)), Option.match({
|
|
1819
|
+
onNone: () => NO_SETTINGS,
|
|
1820
|
+
onSome: settingsOf
|
|
1821
|
+
}));
|
|
1822
|
+
});
|
|
1823
|
+
const directivePattern = (directives) => new RegExp(String.raw`^\s?(?:${Array.join(directives, "|")})`, "u");
|
|
1824
|
+
const isIgnored = (patterns) => (name) => pipe(patterns, Array.some((pattern) => path.matchesGlob(name, pattern)));
|
|
1825
|
+
const scannedFiles = Effect.fn("scannedFiles")(function* scannedFiles(root, settings) {
|
|
1826
|
+
const files = yield* RepositoryFiles;
|
|
1827
|
+
const listed = yield* files.listedFiles(root);
|
|
1828
|
+
const generated = yield* files.generatedFiles(root);
|
|
1829
|
+
const vendored = yield* files.matchingFiles(root, [VENDORED_PATHSPEC]);
|
|
1830
|
+
const skipped = HashSet.fromIterable([...generated, ...pipe(vendored, Array.map((name) => files.join(root, name)))]);
|
|
1831
|
+
return pipe(listed, Array.filter((name) => !isIgnored(settings.ignorePatterns)(name)), Array.map((name) => ({
|
|
1832
|
+
name,
|
|
1833
|
+
file: files.join(root, name)
|
|
1834
|
+
})), Array.filter(({ file }) => !HashSet.has(skipped, file)));
|
|
1835
|
+
});
|
|
1836
|
+
/** @internal */
|
|
1837
|
+
const checkComments = Effect.fn("checkComments")(function* checkComments(root) {
|
|
1838
|
+
const files = yield* RepositoryFiles;
|
|
1839
|
+
const settings = yield* rootSettings(root);
|
|
1840
|
+
const scanned = yield* scannedFiles(root, settings);
|
|
1841
|
+
const directives = directivePattern([...COMMENT_DIRECTIVES, ...settings.allow]);
|
|
1842
|
+
const grammars = yield* loadGrammars();
|
|
1843
|
+
const comments = commentsWith(grammars);
|
|
1844
|
+
const problemsIn = ({ name, file }, source) => {
|
|
1845
|
+
const kept = Predicate.not(isAllowed(source, directives));
|
|
1846
|
+
const toProblem = problemOf$1(file, source);
|
|
1847
|
+
return Option.match(readerOf(name, source), {
|
|
1848
|
+
onNone: () => Effect.succeed(NONE),
|
|
1849
|
+
onSome: (reader) => comments(reader, source).pipe(Effect.map(Array.filter(kept)), Effect.map(Array.map(toProblem)), Effect.catchTag("CommentsUnreadable", ({ message }) => Effect.succeed([unreadableProblem(file, message)])))
|
|
1850
|
+
});
|
|
1851
|
+
};
|
|
1852
|
+
const found = yield* Effect.forEach(scanned, (entry) => files.readFile(entry.file).pipe(Effect.flatMap(Option.match({
|
|
1853
|
+
onNone: () => Effect.succeed(NONE),
|
|
1854
|
+
onSome: (source) => problemsIn(entry, source)
|
|
1855
|
+
}))), { concurrency: READ_CONCURRENCY$4 });
|
|
1856
|
+
return Array.flatten(found);
|
|
1857
|
+
});
|
|
1858
|
+
// src/hidden-unicode.ts
|
|
1859
|
+
const HIDDEN = /[\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]|[\u{E0000}-\u{E007F}]/gu;
|
|
1860
|
+
const NUL = "\0";
|
|
1861
|
+
const START = 0;
|
|
1862
|
+
const HEX = 16;
|
|
1863
|
+
const CODE_POINT_WIDTH = 4;
|
|
1864
|
+
const READ_CONCURRENCY$3 = 64;
|
|
1865
|
+
const RULE$3 = "hidden-unicode";
|
|
1866
|
+
const hexOf = (character) => pipe(String$1.codePointAt(START)(character), Option.getOrElse(() => START), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
|
|
1867
|
+
const problemOf = (file, source) => (found) => {
|
|
1868
|
+
const hex = hexOf(found[START]);
|
|
1869
|
+
return {
|
|
1870
|
+
file,
|
|
1871
|
+
...positionOf(source)(found.index ?? START),
|
|
1872
|
+
rule: RULE$3,
|
|
1873
|
+
message: `U+${hex} is invisible in editors and reviews and can change what the text means. Remove it, or write it as the escape \\u${hex}.`
|
|
1874
|
+
};
|
|
1875
|
+
};
|
|
1876
|
+
const problemsIn$1 = (file, source) => {
|
|
1877
|
+
if (String$1.includes(NUL)(source)) return [];
|
|
1878
|
+
return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf(file, source)));
|
|
1879
|
+
};
|
|
1880
|
+
/** @internal */
|
|
1881
|
+
const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHiddenUnicode(root) {
|
|
1882
|
+
const files = yield* RepositoryFiles;
|
|
1883
|
+
const names = yield* files.listedFiles(root);
|
|
1884
|
+
const found = yield* Effect.forEach(names, (name) => {
|
|
1885
|
+
const file = files.join(root, name);
|
|
1886
|
+
return files.readFile(file).pipe(Effect.map(Option.match({
|
|
1887
|
+
onNone: () => [],
|
|
1888
|
+
onSome: (source) => problemsIn$1(file, source)
|
|
1889
|
+
})));
|
|
1890
|
+
}, { concurrency: READ_CONCURRENCY$3 });
|
|
1891
|
+
return Array.flatten(found);
|
|
1892
|
+
});
|
|
1604
1893
|
// src/python.ts
|
|
1605
1894
|
const PYTHON_FILE = /(?:\.(?:py|pyi|pyw|pyx|ipynb)|(?:^|\/)(?:pyproject\.toml|uv\.lock|uv\.toml|poetry\.lock|Pipfile|Pipfile\.lock|setup\.cfg|tox\.ini|pytest\.ini|\.python-version|requirements[^/]*\.txt))$/u;
|
|
1606
1895
|
const SCANNED_FILE = /(?:\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\/)(?:Dockerfile[^/]*|Makefile|justfile|\.tool-versions|[^./][^./]*))$/u;
|
|
@@ -1617,7 +1906,7 @@ const COMMAND_PATTERNS = [
|
|
|
1617
1906
|
/\buses:\s*["']?(?:actions\/setup-python|astral-sh\/setup-uv|astral-sh\/ruff-action|pypa\/[\w.-]+|snok\/install-poetry|abatilo\/actions-poetry|conda-incubator\/setup-miniconda|mamba-org\/setup-micromamba|pdm-project\/setup-pdm)\b/gu
|
|
1618
1907
|
];
|
|
1619
1908
|
const TOOL_PATTERNS = [/^[ \t]*["']?(?:python|uv|pipx|poetry|ruff|pdm|hatch|pipx:[^"'\s=]+)["']?[ \t]*(?:=|[ \t]+\S)/gmu];
|
|
1620
|
-
const READ_CONCURRENCY = 64;
|
|
1909
|
+
const READ_CONCURRENCY$2 = 64;
|
|
1621
1910
|
const FIRST_LINE = 1;
|
|
1622
1911
|
const FIRST_COLUMN = 1;
|
|
1623
1912
|
const WHOLE_MATCH = 0;
|
|
@@ -1655,20 +1944,179 @@ const checkPython = Effect.fn("checkPython")(function* checkPython(root) {
|
|
|
1655
1944
|
onNone: () => [],
|
|
1656
1945
|
onSome: (source) => commandProblems(entry, source)
|
|
1657
1946
|
})));
|
|
1658
|
-
const scanned = yield* Effect.forEach(pipe(listed, Array.filter(isScanned)), problemsIn, { concurrency: READ_CONCURRENCY });
|
|
1947
|
+
const scanned = yield* Effect.forEach(pipe(listed, Array.filter(isScanned)), problemsIn, { concurrency: READ_CONCURRENCY$2 });
|
|
1659
1948
|
const present = yield* Effect.filter(pipe(listed, Array.filter(isPython)), ({ file }) => files.exists(file));
|
|
1660
1949
|
return [...pipe(present, Array.map(fileProblem)), ...Array.flatten(scanned)];
|
|
1661
1950
|
});
|
|
1951
|
+
// src/tracked-text.ts
|
|
1952
|
+
/** @internal */
|
|
1953
|
+
const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedText(root) {
|
|
1954
|
+
const found = yield* Effect.all([
|
|
1955
|
+
checkHiddenUnicode(root),
|
|
1956
|
+
checkPython(root),
|
|
1957
|
+
checkComments(root)
|
|
1958
|
+
], { concurrency: "unbounded" });
|
|
1959
|
+
return Array.flatten(found);
|
|
1960
|
+
});
|
|
1961
|
+
// src/crates.ts
|
|
1962
|
+
const RULE$2 = "unverified-crate";
|
|
1963
|
+
const CARGO_FILE = "Cargo.toml";
|
|
1964
|
+
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1965
|
+
const SEPARATOR = "/";
|
|
1966
|
+
const FIRST$2 = 1;
|
|
1967
|
+
const READ_CONCURRENCY$1 = 8;
|
|
1968
|
+
const CrateEntry = Schema.Struct({
|
|
1969
|
+
name: Schema.String,
|
|
1970
|
+
manifest_path: Schema.String
|
|
1971
|
+
});
|
|
1972
|
+
const CrateList = Schema.fromJsonString(Schema.Struct({ packages: Schema.Array(CrateEntry) }));
|
|
1973
|
+
const decodeCrateList = Schema.decodeUnknownEffect(CrateList);
|
|
1974
|
+
const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
1975
|
+
const output = yield* (yield* ChildProcess.make("cargo", [
|
|
1976
|
+
"metadata",
|
|
1977
|
+
"--no-deps",
|
|
1978
|
+
"--format-version",
|
|
1979
|
+
"1",
|
|
1980
|
+
"--offline"
|
|
1981
|
+
], {
|
|
1982
|
+
cwd: root,
|
|
1983
|
+
extendEnv: true,
|
|
1984
|
+
stdin: "ignore"
|
|
1985
|
+
})).stdout.pipe(Stream.decodeText(), Stream.mkString);
|
|
1986
|
+
const list = yield* decodeCrateList(output);
|
|
1987
|
+
return pipe(list.packages, Array.map((crate) => ({
|
|
1988
|
+
name: crate.name,
|
|
1989
|
+
manifest: crate.manifest_path
|
|
1990
|
+
})));
|
|
1991
|
+
}, Effect.scoped);
|
|
1992
|
+
const owningWorkspace = (directories) => (directory) => {
|
|
1993
|
+
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR}`)(directory)));
|
|
1994
|
+
return Array.last(Array.sort(owners, String$1.Order));
|
|
1995
|
+
};
|
|
1996
|
+
const problemFor = (crate, message) => ({
|
|
1997
|
+
file: crate.manifest,
|
|
1998
|
+
line: FIRST$2,
|
|
1999
|
+
column: FIRST$2,
|
|
2000
|
+
rule: RULE$2,
|
|
2001
|
+
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
2002
|
+
});
|
|
2003
|
+
const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
2004
|
+
const files = yield* RepositoryFiles;
|
|
2005
|
+
const workspace = owningWorkspace(directories)(files.relative(root, files.dirname(crate.manifest)));
|
|
2006
|
+
if (Option.isNone(workspace)) return Option.some(problemFor(crate, "is outside every workspace package"));
|
|
2007
|
+
if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$2))) return Option.none();
|
|
2008
|
+
return Option.some(problemFor(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$2} has no verify task`));
|
|
2009
|
+
});
|
|
2010
|
+
/** @internal */
|
|
2011
|
+
const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
2012
|
+
const files = yield* RepositoryFiles;
|
|
2013
|
+
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
2014
|
+
const directories = yield* workspaceDirectories(root);
|
|
2015
|
+
const crates = yield* cratesIn(root);
|
|
2016
|
+
const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$1 });
|
|
2017
|
+
return Array.getSomes(found);
|
|
2018
|
+
});
|
|
2019
|
+
// src/hidden-verify.ts
|
|
2020
|
+
const RULE$1 = "hidden-verify";
|
|
2021
|
+
const CONFIG_FILE$1 = "vite.config.ts";
|
|
2022
|
+
const FIRST$1 = 1;
|
|
2023
|
+
const READ_CONCURRENCY = 8;
|
|
2024
|
+
const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
2025
|
+
const files = yield* RepositoryFiles;
|
|
2026
|
+
const file = files.join(root, directory, CONFIG_FILE$1);
|
|
2027
|
+
const text = yield* files.readFile(file);
|
|
2028
|
+
if (Option.isNone(text)) return Option.none();
|
|
2029
|
+
const program = yield* programOf(file, text.value);
|
|
2030
|
+
if (definesTask(VERIFY_TASK)(program)) return Option.none();
|
|
2031
|
+
const verified = yield* hasVerifyTask(file);
|
|
2032
|
+
return Option.some({
|
|
2033
|
+
file,
|
|
2034
|
+
line: FIRST$1,
|
|
2035
|
+
column: FIRST$1,
|
|
2036
|
+
rule: RULE$1,
|
|
2037
|
+
message: `${directory} gets its verify task from code outside ${CONFIG_FILE$1}. The root verify reads ${CONFIG_FILE$1} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$1}.`
|
|
2038
|
+
}).pipe(Option.filter(() => verified));
|
|
2039
|
+
});
|
|
2040
|
+
/** @internal */
|
|
2041
|
+
const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVerify(root) {
|
|
2042
|
+
const directories = yield* workspaceDirectories(root);
|
|
2043
|
+
const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY });
|
|
2044
|
+
return Array.getSomes(found);
|
|
2045
|
+
});
|
|
2046
|
+
// src/root-workspace-paths.ts
|
|
2047
|
+
const RULE = "root-workspace-path";
|
|
2048
|
+
const CONFIG_FILE = "vite.config.ts";
|
|
2049
|
+
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
2050
|
+
const NAME_CHARACTER = /[\w.@-]/u;
|
|
2051
|
+
const FIRST = 0;
|
|
2052
|
+
const NEXT = 1;
|
|
2053
|
+
const StringNode = Schema.Union([Schema.Struct({
|
|
2054
|
+
type: Schema.Literal("Literal"),
|
|
2055
|
+
value: Schema.String,
|
|
2056
|
+
start: Schema.Finite
|
|
2057
|
+
}), Schema.Struct({
|
|
2058
|
+
type: Schema.Literal("TemplateElement"),
|
|
2059
|
+
value: Schema.Struct({ cooked: Schema.String }),
|
|
2060
|
+
start: Schema.Finite
|
|
2061
|
+
})]);
|
|
2062
|
+
const decodeStringNode = Schema.decodeUnknownOption(StringNode);
|
|
2063
|
+
const textOf = (node) => {
|
|
2064
|
+
if (node.type === "Literal") return node.value;
|
|
2065
|
+
return node.value.cooked;
|
|
2066
|
+
};
|
|
2067
|
+
const stringsIn = (node) => {
|
|
2068
|
+
return [...pipe(decodeStringNode(node), Option.map((found) => ({
|
|
2069
|
+
text: textOf(found),
|
|
2070
|
+
start: found.start
|
|
2071
|
+
})), Option.toArray), ...pipe(childrenOf$3(node), Array.flatMap(stringsIn))];
|
|
2072
|
+
};
|
|
2073
|
+
const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
|
|
2074
|
+
const mentions = (directory) => (text) => {
|
|
2075
|
+
const parts = String$1.split(text, directory);
|
|
2076
|
+
return pipe(Array.drop(parts, NEXT), Array.some((after, index) => {
|
|
2077
|
+
const before = parts[index] ?? "";
|
|
2078
|
+
const previous = String$1.slice(before.length - NEXT)(before);
|
|
2079
|
+
const following = String$1.slice(FIRST, NEXT)(after);
|
|
2080
|
+
return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
|
|
2081
|
+
}));
|
|
2082
|
+
};
|
|
2083
|
+
const problemsIn = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
2084
|
+
file,
|
|
2085
|
+
...positionOf(source)(found.start),
|
|
2086
|
+
rule: RULE,
|
|
2087
|
+
message: `${directory} is a workspace. The root ${CONFIG_FILE} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE}: msch.lint, msch.devDependencies or its verify task.`
|
|
2088
|
+
})));
|
|
2089
|
+
/** @internal */
|
|
2090
|
+
const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* checkRootWorkspacePaths(root) {
|
|
2091
|
+
const files = yield* RepositoryFiles;
|
|
2092
|
+
const file = files.join(root, CONFIG_FILE);
|
|
2093
|
+
const source = yield* files.readFile(file);
|
|
2094
|
+
if (Option.isNone(source)) return [];
|
|
2095
|
+
const directories = yield* workspaceDirectories(root);
|
|
2096
|
+
const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: "ts" }));
|
|
2097
|
+
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn(file, source.value, directories)));
|
|
2098
|
+
});
|
|
2099
|
+
// src/workspace-checks.ts
|
|
2100
|
+
/** @internal */
|
|
2101
|
+
const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(root) {
|
|
2102
|
+
const found = yield* Effect.all([
|
|
2103
|
+
checkCrates(root),
|
|
2104
|
+
checkHiddenVerify(root),
|
|
2105
|
+
checkRootWorkspacePaths(root)
|
|
2106
|
+
], { concurrency: "unbounded" });
|
|
2107
|
+
return Array.flatten(found);
|
|
2108
|
+
});
|
|
1662
2109
|
// src/all-checks.ts
|
|
1663
2110
|
/** @internal */
|
|
1664
2111
|
const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
1665
2112
|
const found = yield* Effect.all([
|
|
1666
2113
|
checkRepository(root),
|
|
1667
2114
|
checkOverrides(root),
|
|
1668
|
-
|
|
1669
|
-
checkPython(root),
|
|
2115
|
+
checkTrackedText(root),
|
|
1670
2116
|
checkNestedDocs(root),
|
|
1671
|
-
|
|
2117
|
+
checkRootReadme(root),
|
|
2118
|
+
checkPublishedPackages(root),
|
|
2119
|
+
checkWorkspaces(root)
|
|
1672
2120
|
], { concurrency: "unbounded" });
|
|
1673
2121
|
return Array.flatten(found);
|
|
1674
2122
|
});
|