@r_masseater/msch 0.6.1 → 0.8.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 +22 -1
- package/dist/cli-contract-BvrxbrIy.mjs +114 -0
- package/dist/cli-contract-BvrxbrIy.mjs.map +1 -0
- package/dist/cli.mjs +302 -196
- package/dist/cli.mjs.map +1 -1
- package/dist/dependencies-x3j9tLcR.mjs +186 -0
- package/dist/dependencies-x3j9tLcR.mjs.map +1 -0
- package/dist/lint.d.mts +5 -0
- package/dist/lint.mjs +30 -5
- package/dist/lint.mjs.map +1 -1
- package/dist/oxlint.mjs +1 -1
- 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 -9
- package/src/vite.d.ts +30 -1
- package/dist/cli-contract-DpQurUwC.mjs +0 -286
- package/dist/cli-contract-DpQurUwC.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as
|
|
3
|
-
import {
|
|
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$1, 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-BvrxbrIy.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$2, i as hasVerifyTask, m as workspaceDirectories, n as VERIFY_TASK, r as definesTask, v as publicEntriesOf } from "./workspace-tasks-CRL-gm__.mjs";
|
|
5
|
+
import { Array, Cause, Effect, FileSystem, Function, HashMap, HashSet, Layer, Number as Number$1, Option, Order, Path, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
4
6
|
import { ChildProcess } from "effect/process";
|
|
5
|
-
import { resolveConfigFromFile } from "vite-plus";
|
|
7
|
+
import { parse, resolveConfigFromFile } from "vite-plus";
|
|
6
8
|
import { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
|
|
7
9
|
import { runMain } from "@effect/platform-node-shared/NodeRuntime";
|
|
8
10
|
import { FetchHttpClient } from "effect/http";
|
|
@@ -659,25 +661,19 @@ const annotateResources = (api) => Effect.gen(function* annotateCompiler() {
|
|
|
659
661
|
});
|
|
660
662
|
});
|
|
661
663
|
// src/project.ts
|
|
662
|
-
const
|
|
664
|
+
const CONFIG_PATHSPEC = `:(glob)**/tsconfig.json`;
|
|
663
665
|
const HIDDEN_PREFIX = ".";
|
|
664
666
|
const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
665
667
|
NODE_MODULES,
|
|
666
668
|
"dist",
|
|
667
669
|
"coverage"
|
|
668
670
|
]);
|
|
669
|
-
const
|
|
671
|
+
const isVisible = (file) => pipe(String$1.split(file, "/"), Array.every((segment) => !String$1.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment)));
|
|
672
|
+
const listConfigFiles = (root) => Effect.gen(function* configFilesUnder() {
|
|
670
673
|
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);
|
|
674
|
+
const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);
|
|
675
|
+
const visible = pipe(listed, Array.filter(isVisible), Array.map((file) => files.join(root, file)));
|
|
676
|
+
return Array.sort(visible, Order.String);
|
|
681
677
|
});
|
|
682
678
|
const parseConfig = (api) => (configPath) => Option.some(api.parseConfigFile(configPath)).pipe(Option.filter((parsed) => Array.isReadonlyArrayNonEmpty(parsed.fileNames)));
|
|
683
679
|
const nearestPackageDirectory = (directory, root) => Effect.gen(function* nearestPackage() {
|
|
@@ -748,7 +744,7 @@ const withProject = (workspace) => (configPath) => (work) => Effect.acquireUseRe
|
|
|
748
744
|
onNone: () => Effect.void,
|
|
749
745
|
onSome: releaseProject
|
|
750
746
|
}));
|
|
751
|
-
const mentions = (needle) => ({ api }) => (configPath) => Effect.gen(function* mentionsNeedle() {
|
|
747
|
+
const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function* mentionsNeedle() {
|
|
752
748
|
const files = yield* RepositoryFiles;
|
|
753
749
|
const fileNames = Option.match(parseConfig(api)(configPath), {
|
|
754
750
|
onNone: () => [],
|
|
@@ -760,7 +756,7 @@ const mentions = (needle) => ({ api }) => (configPath) => Effect.gen(function* m
|
|
|
760
756
|
});
|
|
761
757
|
// src/check.ts
|
|
762
758
|
const scanOwners = Effect.fn("scanOwners")(function* scanOwners(workspace, configPaths) {
|
|
763
|
-
const ownerConfigs = yield* pipe(configPaths, Effect.filter(mentions(`@${OWNER_TAG}`)(workspace.compiler)));
|
|
759
|
+
const ownerConfigs = yield* pipe(configPaths, Effect.filter(mentions$1(`@${OWNER_TAG}`)(workspace.compiler)));
|
|
764
760
|
const scans = yield* pipe(ownerConfigs, Effect.forEach((configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => ownersIn(project)))));
|
|
765
761
|
return combineOwnerScans(Array.getSomes(scans));
|
|
766
762
|
});
|
|
@@ -795,10 +791,10 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
795
791
|
]);
|
|
796
792
|
}, Effect.scoped);
|
|
797
793
|
// src/text-position.ts
|
|
798
|
-
const START$
|
|
794
|
+
const START$3 = 0;
|
|
799
795
|
const FIRST_COLUMN$1 = 1;
|
|
800
796
|
const positionOf = (source) => (index) => {
|
|
801
|
-
const before = pipe(source, String$1.slice(START$
|
|
797
|
+
const before = pipe(source, String$1.slice(START$3, index), String$1.split("\n"));
|
|
802
798
|
return {
|
|
803
799
|
line: before.length,
|
|
804
800
|
column: pipe(Array.last(before), Option.match({
|
|
@@ -810,22 +806,22 @@ const positionOf = (source) => (index) => {
|
|
|
810
806
|
// src/hidden-unicode.ts
|
|
811
807
|
const HIDDEN = /[\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]|[\u{E0000}-\u{E007F}]/gu;
|
|
812
808
|
const NUL = "\0";
|
|
813
|
-
const START$
|
|
809
|
+
const START$2 = 0;
|
|
814
810
|
const HEX = 16;
|
|
815
811
|
const CODE_POINT_WIDTH = 4;
|
|
816
|
-
const READ_CONCURRENCY$
|
|
817
|
-
const RULE$
|
|
818
|
-
const hexOf = (character) => pipe(String$1.codePointAt(START$
|
|
812
|
+
const READ_CONCURRENCY$5 = 64;
|
|
813
|
+
const RULE$5 = "hidden-unicode";
|
|
814
|
+
const hexOf = (character) => pipe(String$1.codePointAt(START$2)(character), Option.getOrElse(() => START$2), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
|
|
819
815
|
const problemOf = (file, source) => (found) => {
|
|
820
|
-
const hex = hexOf(found[START$
|
|
816
|
+
const hex = hexOf(found[START$2]);
|
|
821
817
|
return {
|
|
822
818
|
file,
|
|
823
|
-
...positionOf(source)(found.index ?? START$
|
|
824
|
-
rule: RULE$
|
|
819
|
+
...positionOf(source)(found.index ?? START$2),
|
|
820
|
+
rule: RULE$5,
|
|
825
821
|
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
822
|
};
|
|
827
823
|
};
|
|
828
|
-
const problemsIn = (file, source) => {
|
|
824
|
+
const problemsIn$2 = (file, source) => {
|
|
829
825
|
if (String$1.includes(NUL)(source)) return [];
|
|
830
826
|
return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf(file, source)));
|
|
831
827
|
};
|
|
@@ -837,16 +833,16 @@ const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHidden
|
|
|
837
833
|
const file = files.join(root, name);
|
|
838
834
|
return files.readFile(file).pipe(Effect.map(Option.match({
|
|
839
835
|
onNone: () => [],
|
|
840
|
-
onSome: (source) => problemsIn(file, source)
|
|
836
|
+
onSome: (source) => problemsIn$2(file, source)
|
|
841
837
|
})));
|
|
842
|
-
}, { concurrency: READ_CONCURRENCY$
|
|
838
|
+
}, { concurrency: READ_CONCURRENCY$5 });
|
|
843
839
|
return Array.flatten(found);
|
|
844
840
|
});
|
|
845
841
|
// src/import-graph.ts
|
|
846
842
|
const RELATIVE = /^\.\.?(?:\/|$)/u;
|
|
847
843
|
const SUBPATH_IMPORT = "#";
|
|
848
844
|
const WILDCARD = "*";
|
|
849
|
-
const SCOPE = "@";
|
|
845
|
+
const SCOPE$1 = "@";
|
|
850
846
|
const SEPARATOR$3 = "/";
|
|
851
847
|
const SOURCE_SUFFIXES = [
|
|
852
848
|
"",
|
|
@@ -860,7 +856,7 @@ const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Sche
|
|
|
860
856
|
const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
|
|
861
857
|
const packageNameOf = (specifier) => {
|
|
862
858
|
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));
|
|
859
|
+
if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$3));
|
|
864
860
|
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$3));
|
|
865
861
|
};
|
|
866
862
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
@@ -1019,137 +1015,6 @@ const installedSize = (directory) => {
|
|
|
1019
1015
|
if (String$1.includes(`/node_modules/`)(directory)) return directorySize(directory);
|
|
1020
1016
|
return Effect.succeed(EMPTY);
|
|
1021
1017
|
};
|
|
1022
|
-
// src/public-entries.ts
|
|
1023
|
-
const SOURCE = /\.[cm]?tsx?$/u;
|
|
1024
|
-
const BUILT = /\.(?:d\.)?[cm]?[jt]s$/u;
|
|
1025
|
-
const DECLARATION = ".d.";
|
|
1026
|
-
const SEPARATOR$2 = "/";
|
|
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;
|
|
1126
|
-
return {
|
|
1127
|
-
directory,
|
|
1128
|
-
configFile,
|
|
1129
|
-
installSize: `${amount} ${unit}`,
|
|
1130
|
-
installBudget: amount * bytesPer(unit),
|
|
1131
|
-
packEntries: pipe(packEntriesOf(pack), Array.map((entry) => ({
|
|
1132
|
-
name: entry.name,
|
|
1133
|
-
source: join(entry.source)
|
|
1134
|
-
})))
|
|
1135
|
-
};
|
|
1136
|
-
};
|
|
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
1018
|
// src/install-size.ts
|
|
1154
1019
|
const INSTALL_SIZE = "install-size";
|
|
1155
1020
|
const STACK_DEPENDENCY = "stack-dependency";
|
|
@@ -1160,11 +1025,11 @@ const LISTED_LARGEST = 5;
|
|
|
1160
1025
|
const SIZE_CONCURRENCY = 32;
|
|
1161
1026
|
const MEGABYTE = 1e6;
|
|
1162
1027
|
const MEGABYTE_DIGITS = 1;
|
|
1163
|
-
const START = 0;
|
|
1028
|
+
const START$1 = 0;
|
|
1164
1029
|
const SINGLE_ENTRY = 1;
|
|
1165
1030
|
const megabytes = (bytes) => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;
|
|
1166
1031
|
const usageHint = (dependency, entryCount) => {
|
|
1167
|
-
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START && dependency.entries.length < entryCount)) return "";
|
|
1032
|
+
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$1 && dependency.entries.length < entryCount)) return "";
|
|
1168
1033
|
return ` (imported only from ${Array.join(dependency.entries, ", ")})`;
|
|
1169
1034
|
};
|
|
1170
1035
|
const listed = ({ largest, entryCount }) => pipe(largest, Array.map((dependency) => `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`), Array.join(", "));
|
|
@@ -1173,7 +1038,7 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
|
|
|
1173
1038
|
const { workspace, total } = overrun;
|
|
1174
1039
|
const config = yield* files.readFile(workspace.configFile);
|
|
1175
1040
|
const source = Option.getOrElse(config, () => "");
|
|
1176
|
-
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START);
|
|
1041
|
+
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$1);
|
|
1177
1042
|
return {
|
|
1178
1043
|
file: workspace.configFile,
|
|
1179
1044
|
...positionOf(source)(index),
|
|
@@ -1190,7 +1055,7 @@ const measure = Effect.fn("measure")(function* measure({ workspace, provided },
|
|
|
1190
1055
|
const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
|
|
1191
1056
|
const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
|
|
1192
1057
|
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))));
|
|
1058
|
+
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$1))));
|
|
1194
1059
|
return {
|
|
1195
1060
|
closures,
|
|
1196
1061
|
sizeOf,
|
|
@@ -1223,11 +1088,11 @@ const sizeProblems = Effect.fn("sizeProblems")(function* sizeProblems(published,
|
|
|
1223
1088
|
})];
|
|
1224
1089
|
});
|
|
1225
1090
|
const stackProblems = (file, source, dependencies) => {
|
|
1226
|
-
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START);
|
|
1091
|
+
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$1);
|
|
1227
1092
|
const rest = String$1.slice(section)(source);
|
|
1228
1093
|
return pipe(Record.toEntries(dependencies), Array.filter(([, specifier]) => specifier === STACK_CATALOG), Array.map(([name]) => ({
|
|
1229
1094
|
file,
|
|
1230
|
-
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START)),
|
|
1095
|
+
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$1)),
|
|
1231
1096
|
rule: STACK_DEPENDENCY,
|
|
1232
1097
|
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
1098
|
})));
|
|
@@ -1273,38 +1138,69 @@ const checkPublishedPackages = Effect.fn("checkPublishedPackages")(function* che
|
|
|
1273
1138
|
return Array.flatten(found);
|
|
1274
1139
|
});
|
|
1275
1140
|
// src/nested-docs.ts
|
|
1276
|
-
const RULE = "nested-docs";
|
|
1277
|
-
const
|
|
1278
|
-
const
|
|
1279
|
-
const
|
|
1141
|
+
const RULE$4 = "nested-docs";
|
|
1142
|
+
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1143
|
+
const SEPARATOR$2 = "/";
|
|
1144
|
+
const FIRST$3 = 1;
|
|
1145
|
+
const READ_CONCURRENCY$4 = 64;
|
|
1280
1146
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1281
|
-
const
|
|
1282
|
-
const
|
|
1283
|
-
const
|
|
1147
|
+
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
1148
|
+
const README$1 = /^README(?:\.[^/]+)?$/iu;
|
|
1149
|
+
const RootConfig = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1150
|
+
const taggedError$2 = Schema.TaggedError;
|
|
1151
|
+
var RootConfigUnreadable = class extends taggedError$2()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1152
|
+
const isNested = (name) => String$1.includes(SEPARATOR$2)(name);
|
|
1153
|
+
const problemFor$1 = (file, message) => ({
|
|
1284
1154
|
file,
|
|
1285
|
-
line: FIRST,
|
|
1286
|
-
column: FIRST,
|
|
1287
|
-
rule: RULE,
|
|
1155
|
+
line: FIRST$3,
|
|
1156
|
+
column: FIRST$3,
|
|
1157
|
+
rule: RULE$4,
|
|
1288
1158
|
message
|
|
1289
1159
|
});
|
|
1290
1160
|
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
|
|
1161
|
+
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.";
|
|
1162
|
+
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.";
|
|
1163
|
+
const agentDocProblem = ({ file, base, directory }, allowed) => {
|
|
1164
|
+
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$1(file, `${base} ${AGENT_DOCS_MESSAGE}`));
|
|
1165
|
+
if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1166
|
+
return Option.some(problemFor$1(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
|
|
1167
|
+
};
|
|
1168
|
+
const readmeProblem = ({ file, base, directory }, allowed) => {
|
|
1169
|
+
if (!README$1.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1170
|
+
return Option.some(problemFor$1(file, `${base} ${README_MESSAGE}`));
|
|
1171
|
+
};
|
|
1172
|
+
const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, allowed, name) {
|
|
1293
1173
|
const files = yield* RepositoryFiles;
|
|
1294
|
-
const base = files.basename(name);
|
|
1295
1174
|
const file = files.join(root, name);
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1175
|
+
const doc = {
|
|
1176
|
+
file,
|
|
1177
|
+
base: files.basename(name),
|
|
1178
|
+
directory: files.dirname(file)
|
|
1179
|
+
};
|
|
1180
|
+
if (AGENT_DOCS.test(doc.base)) return agentDocProblem(doc, allowed);
|
|
1181
|
+
return readmeProblem(doc, allowed);
|
|
1182
|
+
});
|
|
1183
|
+
const allowsWorkspaceAgentDocs = Effect.fn("allowsWorkspaceAgentDocs")(function* allowsWorkspaceAgentDocs(root) {
|
|
1184
|
+
const files = yield* RepositoryFiles;
|
|
1185
|
+
const file = files.join(root, CONFIG_FILE$3);
|
|
1186
|
+
if (!(yield* files.exists(file))) return false;
|
|
1187
|
+
const config = yield* Effect.tryPromise({
|
|
1188
|
+
try: () => resolveConfigFromFile(file),
|
|
1189
|
+
catch: () => RootConfigUnreadable.make({ file })
|
|
1190
|
+
}).pipe(Effect.option);
|
|
1191
|
+
return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig)), Option.isSome);
|
|
1300
1192
|
});
|
|
1301
1193
|
/** @internal */
|
|
1302
1194
|
const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(root) {
|
|
1303
|
-
const
|
|
1195
|
+
const files = yield* RepositoryFiles;
|
|
1196
|
+
const names = yield* files.listedFiles(root);
|
|
1304
1197
|
const nested = pipe(names, Array.filter(isNested));
|
|
1305
|
-
const
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1198
|
+
const workspaceAgentDocs = yield* allowsWorkspaceAgentDocs(root);
|
|
1199
|
+
const allowed = {
|
|
1200
|
+
workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
|
|
1201
|
+
workspaceAgentDocs
|
|
1202
|
+
};
|
|
1203
|
+
const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$4 });
|
|
1308
1204
|
return Array.getSomes(found);
|
|
1309
1205
|
});
|
|
1310
1206
|
// src/override-findings.ts
|
|
@@ -1503,7 +1399,7 @@ var OverrideResolutionFailed = class extends taggedError$1()("OverrideResolution
|
|
|
1503
1399
|
override: Schema.String,
|
|
1504
1400
|
output: Schema.String
|
|
1505
1401
|
}) {};
|
|
1506
|
-
const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
1402
|
+
const textOf$1 = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
1507
1403
|
const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override) {
|
|
1508
1404
|
const handle = yield* ChildProcess.make("vp", [
|
|
1509
1405
|
"install",
|
|
@@ -1517,7 +1413,7 @@ const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override
|
|
|
1517
1413
|
extendEnv: true,
|
|
1518
1414
|
stdin: "ignore"
|
|
1519
1415
|
});
|
|
1520
|
-
const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
1416
|
+
const [output, status] = yield* Effect.all([textOf$1(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
1521
1417
|
if (Number(status) !== SUCCEEDED) return yield* OverrideResolutionFailed.make({
|
|
1522
1418
|
override,
|
|
1523
1419
|
output
|
|
@@ -1534,7 +1430,7 @@ const auditIn = Effect.fn("auditIn")(function* auditIn(directory) {
|
|
|
1534
1430
|
extendEnv: true,
|
|
1535
1431
|
stdin: "ignore"
|
|
1536
1432
|
});
|
|
1537
|
-
const [report] = yield* Effect.all([textOf(handle.stdout), handle.exitCode], { concurrency: "unbounded" });
|
|
1433
|
+
const [report] = yield* Effect.all([textOf$1(handle.stdout), handle.exitCode], { concurrency: "unbounded" });
|
|
1538
1434
|
return advisoriesIn(report);
|
|
1539
1435
|
}, Effect.scoped);
|
|
1540
1436
|
const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* trackedFiles(root) {
|
|
@@ -1544,7 +1440,7 @@ const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* tra
|
|
|
1544
1440
|
"--",
|
|
1545
1441
|
...RESOLUTION_FILES
|
|
1546
1442
|
], { cwd: root });
|
|
1547
|
-
const listed = yield* textOf(handle.stdout);
|
|
1443
|
+
const listed = yield* textOf$1(handle.stdout);
|
|
1548
1444
|
return pipe(String$1.split(listed, "\0"), Array.filter(String$1.isNonEmpty));
|
|
1549
1445
|
}, Effect.scoped);
|
|
1550
1446
|
const copyFiles = Effect.fn("copyFiles")(function* copyFiles(workspace, directory) {
|
|
@@ -1617,7 +1513,7 @@ const COMMAND_PATTERNS = [
|
|
|
1617
1513
|
/\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
1514
|
];
|
|
1619
1515
|
const TOOL_PATTERNS = [/^[ \t]*["']?(?:python|uv|pipx|poetry|ruff|pdm|hatch|pipx:[^"'\s=]+)["']?[ \t]*(?:=|[ \t]+\S)/gmu];
|
|
1620
|
-
const READ_CONCURRENCY = 64;
|
|
1516
|
+
const READ_CONCURRENCY$3 = 64;
|
|
1621
1517
|
const FIRST_LINE = 1;
|
|
1622
1518
|
const FIRST_COLUMN = 1;
|
|
1623
1519
|
const WHOLE_MATCH = 0;
|
|
@@ -1655,10 +1551,218 @@ const checkPython = Effect.fn("checkPython")(function* checkPython(root) {
|
|
|
1655
1551
|
onNone: () => [],
|
|
1656
1552
|
onSome: (source) => commandProblems(entry, source)
|
|
1657
1553
|
})));
|
|
1658
|
-
const scanned = yield* Effect.forEach(pipe(listed, Array.filter(isScanned)), problemsIn, { concurrency: READ_CONCURRENCY });
|
|
1554
|
+
const scanned = yield* Effect.forEach(pipe(listed, Array.filter(isScanned)), problemsIn, { concurrency: READ_CONCURRENCY$3 });
|
|
1659
1555
|
const present = yield* Effect.filter(pipe(listed, Array.filter(isPython)), ({ file }) => files.exists(file));
|
|
1660
1556
|
return [...pipe(present, Array.map(fileProblem)), ...Array.flatten(scanned)];
|
|
1661
1557
|
});
|
|
1558
|
+
// src/root-readme.ts
|
|
1559
|
+
const RULE$3 = "root-readme";
|
|
1560
|
+
const SEPARATOR$1 = "/";
|
|
1561
|
+
const ALTERNATIVE = "|";
|
|
1562
|
+
const SCOPE = /^@[^/]+\//u;
|
|
1563
|
+
const README = /^README(?:\.[^/]+)?$/iu;
|
|
1564
|
+
const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
|
|
1565
|
+
const READ_CONCURRENCY$2 = 16;
|
|
1566
|
+
const START = 0;
|
|
1567
|
+
const NamedManifest = Schema.fromJsonString(Schema.Struct({ name: Schema.optional(Schema.String) }));
|
|
1568
|
+
const patternOf = (names) => {
|
|
1569
|
+
const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
|
|
1570
|
+
return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
|
|
1571
|
+
};
|
|
1572
|
+
const packageNameIn = (text) => pipe(text, Option.flatMap(Schema.decodeOption(NamedManifest)), Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)));
|
|
1573
|
+
const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(root, name) {
|
|
1574
|
+
const files = yield* RepositoryFiles;
|
|
1575
|
+
const directory = files.dirname(name);
|
|
1576
|
+
const text = yield* files.readFile(files.join(root, name));
|
|
1577
|
+
const packageName = packageNameIn(text);
|
|
1578
|
+
const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
|
|
1579
|
+
const names = pipe([
|
|
1580
|
+
Option.some(directory),
|
|
1581
|
+
Option.some(files.basename(directory)),
|
|
1582
|
+
packageName,
|
|
1583
|
+
unscoped
|
|
1584
|
+
], Array.getSomes, Array.dedupe);
|
|
1585
|
+
return {
|
|
1586
|
+
directory,
|
|
1587
|
+
pattern: patternOf(names)
|
|
1588
|
+
};
|
|
1589
|
+
});
|
|
1590
|
+
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.`;
|
|
1591
|
+
const problemsIn$1 = (file, source) => ({ directory, pattern }) => {
|
|
1592
|
+
const message = messageFor(directory);
|
|
1593
|
+
const at = positionOf(source);
|
|
1594
|
+
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1595
|
+
file,
|
|
1596
|
+
...at(found.index ?? START),
|
|
1597
|
+
rule: RULE$3,
|
|
1598
|
+
message
|
|
1599
|
+
})));
|
|
1600
|
+
};
|
|
1601
|
+
const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadme(file, workspaces) {
|
|
1602
|
+
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1603
|
+
return pipe(text, Option.match({
|
|
1604
|
+
onNone: () => [],
|
|
1605
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$1(file, source)))
|
|
1606
|
+
}));
|
|
1607
|
+
});
|
|
1608
|
+
/** @internal */
|
|
1609
|
+
const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(root) {
|
|
1610
|
+
const files = yield* RepositoryFiles;
|
|
1611
|
+
const names = yield* files.listedFiles(root);
|
|
1612
|
+
const readmes = pipe(names, Array.filter((name) => README.test(name)));
|
|
1613
|
+
const manifests = pipe(names, Array.filter((name) => String$1.includes(SEPARATOR$1)(name) && files.basename(name) === "package.json"));
|
|
1614
|
+
const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), { concurrency: READ_CONCURRENCY$2 });
|
|
1615
|
+
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$2 });
|
|
1616
|
+
return Array.flatten(found);
|
|
1617
|
+
});
|
|
1618
|
+
// src/crates.ts
|
|
1619
|
+
const RULE$2 = "unverified-crate";
|
|
1620
|
+
const CARGO_FILE = "Cargo.toml";
|
|
1621
|
+
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1622
|
+
const SEPARATOR = "/";
|
|
1623
|
+
const FIRST$2 = 1;
|
|
1624
|
+
const READ_CONCURRENCY$1 = 8;
|
|
1625
|
+
const CrateEntry = Schema.Struct({
|
|
1626
|
+
name: Schema.String,
|
|
1627
|
+
manifest_path: Schema.String
|
|
1628
|
+
});
|
|
1629
|
+
const CrateList = Schema.fromJsonString(Schema.Struct({ packages: Schema.Array(CrateEntry) }));
|
|
1630
|
+
const decodeCrateList = Schema.decodeUnknownEffect(CrateList);
|
|
1631
|
+
const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
1632
|
+
const output = yield* (yield* ChildProcess.make("cargo", [
|
|
1633
|
+
"metadata",
|
|
1634
|
+
"--no-deps",
|
|
1635
|
+
"--format-version",
|
|
1636
|
+
"1",
|
|
1637
|
+
"--offline"
|
|
1638
|
+
], {
|
|
1639
|
+
cwd: root,
|
|
1640
|
+
extendEnv: true,
|
|
1641
|
+
stdin: "ignore"
|
|
1642
|
+
})).stdout.pipe(Stream.decodeText(), Stream.mkString);
|
|
1643
|
+
const list = yield* decodeCrateList(output);
|
|
1644
|
+
return pipe(list.packages, Array.map((crate) => ({
|
|
1645
|
+
name: crate.name,
|
|
1646
|
+
manifest: crate.manifest_path
|
|
1647
|
+
})));
|
|
1648
|
+
}, Effect.scoped);
|
|
1649
|
+
const owningWorkspace = (directories) => (directory) => {
|
|
1650
|
+
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR}`)(directory)));
|
|
1651
|
+
return Array.last(Array.sort(owners, String$1.Order));
|
|
1652
|
+
};
|
|
1653
|
+
const problemFor = (crate, message) => ({
|
|
1654
|
+
file: crate.manifest,
|
|
1655
|
+
line: FIRST$2,
|
|
1656
|
+
column: FIRST$2,
|
|
1657
|
+
rule: RULE$2,
|
|
1658
|
+
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
1659
|
+
});
|
|
1660
|
+
const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
1661
|
+
const files = yield* RepositoryFiles;
|
|
1662
|
+
const workspace = owningWorkspace(directories)(files.relative(root, files.dirname(crate.manifest)));
|
|
1663
|
+
if (Option.isNone(workspace)) return Option.some(problemFor(crate, "is outside every workspace package"));
|
|
1664
|
+
if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$2))) return Option.none();
|
|
1665
|
+
return Option.some(problemFor(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$2} has no verify task`));
|
|
1666
|
+
});
|
|
1667
|
+
/** @internal */
|
|
1668
|
+
const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
1669
|
+
const files = yield* RepositoryFiles;
|
|
1670
|
+
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
1671
|
+
const directories = yield* workspaceDirectories(root);
|
|
1672
|
+
const crates = yield* cratesIn(root);
|
|
1673
|
+
const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$1 });
|
|
1674
|
+
return Array.getSomes(found);
|
|
1675
|
+
});
|
|
1676
|
+
// src/hidden-verify.ts
|
|
1677
|
+
const RULE$1 = "hidden-verify";
|
|
1678
|
+
const CONFIG_FILE$1 = "vite.config.ts";
|
|
1679
|
+
const FIRST$1 = 1;
|
|
1680
|
+
const READ_CONCURRENCY = 8;
|
|
1681
|
+
const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
1682
|
+
const files = yield* RepositoryFiles;
|
|
1683
|
+
const file = files.join(root, directory, CONFIG_FILE$1);
|
|
1684
|
+
const text = yield* files.readFile(file);
|
|
1685
|
+
if (Option.isNone(text)) return Option.none();
|
|
1686
|
+
const program = yield* programOf(file, text.value);
|
|
1687
|
+
if (definesTask(VERIFY_TASK)(program)) return Option.none();
|
|
1688
|
+
const verified = yield* hasVerifyTask(file);
|
|
1689
|
+
return Option.some({
|
|
1690
|
+
file,
|
|
1691
|
+
line: FIRST$1,
|
|
1692
|
+
column: FIRST$1,
|
|
1693
|
+
rule: RULE$1,
|
|
1694
|
+
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}.`
|
|
1695
|
+
}).pipe(Option.filter(() => verified));
|
|
1696
|
+
});
|
|
1697
|
+
/** @internal */
|
|
1698
|
+
const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVerify(root) {
|
|
1699
|
+
const directories = yield* workspaceDirectories(root);
|
|
1700
|
+
const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY });
|
|
1701
|
+
return Array.getSomes(found);
|
|
1702
|
+
});
|
|
1703
|
+
// src/root-workspace-paths.ts
|
|
1704
|
+
const RULE = "root-workspace-path";
|
|
1705
|
+
const CONFIG_FILE = "vite.config.ts";
|
|
1706
|
+
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
1707
|
+
const NAME_CHARACTER = /[\w.@-]/u;
|
|
1708
|
+
const FIRST = 0;
|
|
1709
|
+
const NEXT = 1;
|
|
1710
|
+
const StringNode = Schema.Union([Schema.Struct({
|
|
1711
|
+
type: Schema.Literal("Literal"),
|
|
1712
|
+
value: Schema.String,
|
|
1713
|
+
start: Schema.Finite
|
|
1714
|
+
}), Schema.Struct({
|
|
1715
|
+
type: Schema.Literal("TemplateElement"),
|
|
1716
|
+
value: Schema.Struct({ cooked: Schema.String }),
|
|
1717
|
+
start: Schema.Finite
|
|
1718
|
+
})]);
|
|
1719
|
+
const decodeStringNode = Schema.decodeUnknownOption(StringNode);
|
|
1720
|
+
const textOf = (node) => {
|
|
1721
|
+
if (node.type === "Literal") return node.value;
|
|
1722
|
+
return node.value.cooked;
|
|
1723
|
+
};
|
|
1724
|
+
const stringsIn = (node) => {
|
|
1725
|
+
return [...pipe(decodeStringNode(node), Option.map((found) => ({
|
|
1726
|
+
text: textOf(found),
|
|
1727
|
+
start: found.start
|
|
1728
|
+
})), Option.toArray), ...pipe(childrenOf$2(node), Array.flatMap(stringsIn))];
|
|
1729
|
+
};
|
|
1730
|
+
const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
|
|
1731
|
+
const mentions = (directory) => (text) => {
|
|
1732
|
+
const parts = String$1.split(text, directory);
|
|
1733
|
+
return pipe(Array.drop(parts, NEXT), Array.some((after, index) => {
|
|
1734
|
+
const before = parts[index] ?? "";
|
|
1735
|
+
const previous = String$1.slice(before.length - NEXT)(before);
|
|
1736
|
+
const following = String$1.slice(FIRST, NEXT)(after);
|
|
1737
|
+
return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
|
|
1738
|
+
}));
|
|
1739
|
+
};
|
|
1740
|
+
const problemsIn = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
1741
|
+
file,
|
|
1742
|
+
...positionOf(source)(found.start),
|
|
1743
|
+
rule: RULE,
|
|
1744
|
+
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.`
|
|
1745
|
+
})));
|
|
1746
|
+
/** @internal */
|
|
1747
|
+
const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* checkRootWorkspacePaths(root) {
|
|
1748
|
+
const files = yield* RepositoryFiles;
|
|
1749
|
+
const file = files.join(root, CONFIG_FILE);
|
|
1750
|
+
const source = yield* files.readFile(file);
|
|
1751
|
+
if (Option.isNone(source)) return [];
|
|
1752
|
+
const directories = yield* workspaceDirectories(root);
|
|
1753
|
+
const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: "ts" }));
|
|
1754
|
+
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn(file, source.value, directories)));
|
|
1755
|
+
});
|
|
1756
|
+
// src/workspace-checks.ts
|
|
1757
|
+
/** @internal */
|
|
1758
|
+
const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(root) {
|
|
1759
|
+
const found = yield* Effect.all([
|
|
1760
|
+
checkCrates(root),
|
|
1761
|
+
checkHiddenVerify(root),
|
|
1762
|
+
checkRootWorkspacePaths(root)
|
|
1763
|
+
], { concurrency: "unbounded" });
|
|
1764
|
+
return Array.flatten(found);
|
|
1765
|
+
});
|
|
1662
1766
|
// src/all-checks.ts
|
|
1663
1767
|
/** @internal */
|
|
1664
1768
|
const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
@@ -1668,7 +1772,9 @@ const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
|
1668
1772
|
checkHiddenUnicode(root),
|
|
1669
1773
|
checkPython(root),
|
|
1670
1774
|
checkNestedDocs(root),
|
|
1671
|
-
|
|
1775
|
+
checkRootReadme(root),
|
|
1776
|
+
checkPublishedPackages(root),
|
|
1777
|
+
checkWorkspaces(root)
|
|
1672
1778
|
], { concurrency: "unbounded" });
|
|
1673
1779
|
return Array.flatten(found);
|
|
1674
1780
|
});
|