@r_masseater/msch 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-B5LCnsRC.mjs";
3
- import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-DcTnXciI.mjs";
4
- import { C as publishedWorkspaces, D as readManifest, E as dependencyEntries, O as workspaceDependencies, T as MANIFEST_FILE, _ as childrenOf$3, a as hasVerifyTask, b as nestedValues, g as KeySchema, h as workspaceConfigOf, i as definesTask, l as workspaceDirectories, r as VERIFY_TASK, t as namedWorkspaces, v as keyName, w as publicEntriesOf, y as literalOf } from "./workspace-B1-fCPnh.mjs";
2
+ import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-PUlrIOu9.mjs";
3
+ import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-BiKs7S7N.mjs";
4
+ import { C as publishedWorkspaces, D as readManifest, E as dependencyEntries, O as workspaceDependencies, T as MANIFEST_FILE, _ as childrenOf$3, a as hasVerifyTask, b as nestedValues, g as KeySchema, h as workspaceConfigOf, i as definesTask, l as workspaceDirectories, r as VERIFY_TASK, t as namedWorkspaces, v as keyName, w as publicEntriesOf, y as literalOf } from "./workspace-De9R-Kix.mjs";
5
5
  import { t as COMMENT_DIRECTIVES } from "./comment-directives-TN0dNEbg.mjs";
6
6
  import { Array, Cause, Effect, FileSystem, Function, HashMap, HashSet, Layer, Number as Number$1, Option, Order, Path, Predicate, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
7
7
  import { ChildProcess } from "effect/process";
@@ -243,6 +243,7 @@ const nearestPackageDirectory = (directory, root) => Effect.gen(function* neares
243
243
  if (hasManifest || directory === root || parent === directory) return directory;
244
244
  return yield* nearestPackageDirectory(parent, root);
245
245
  });
246
+ const packageDirectoryOf = (root) => (directory) => nearestPackageDirectory(directory, root);
246
247
  const packageInfoOf = Effect.fn("packageInfoOf")(function* packageInfoOf(configPath, root) {
247
248
  const files = yield* RepositoryFiles;
248
249
  const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);
@@ -314,6 +315,60 @@ const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function*
314
315
  const includesNeedle = String$1.includes(needle);
315
316
  return pipe(texts, Array.some((text) => Option.exists(text, includesNeedle)));
316
317
  });
318
+ // src/entities/project/model/inputs.ts
319
+ const SEPARATOR$6 = "/";
320
+ const encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
321
+ const nearestManifestDirectory = Effect.fn("nearestManifestDirectory")(function* nearestManifestDirectory(start) {
322
+ const files = yield* RepositoryFiles;
323
+ let directory = start;
324
+ let parent = files.dirname(directory);
325
+ while (parent !== directory && !(yield* files.exists(files.join(directory, "package.json")))) {
326
+ directory = parent;
327
+ parent = files.dirname(directory);
328
+ }
329
+ return directory;
330
+ });
331
+ const dependenciesOf = Effect.fn("dependenciesOf")(function* dependenciesOf(directory) {
332
+ const files = yield* RepositoryFiles;
333
+ const manifest = yield* readManifest(directory);
334
+ const names = Option.match(manifest, {
335
+ onNone: () => [],
336
+ onSome: workspaceDependencies
337
+ });
338
+ return yield* pipe(names, Effect.forEach((name) => files.realPath(files.join(directory, NODE_MODULES, name))));
339
+ });
340
+ const workspaceClosure = Effect.fn("workspaceClosure")(function* workspaceClosure(start) {
341
+ const seen = /* @__PURE__ */ new Set([start]);
342
+ const queue = [start];
343
+ for (const directory of queue) {
344
+ const next = yield* dependenciesOf(directory);
345
+ for (const dependency of next) if (!seen.has(dependency)) {
346
+ seen.add(dependency);
347
+ queue.push(dependency);
348
+ }
349
+ }
350
+ return [...seen];
351
+ });
352
+ const isUnder = (prefixes) => (file) => !String$1.includes(SEPARATOR$6)(file) || pipe(prefixes, Array.some((prefix) => String$1.startsWith(prefix)(file)));
353
+ const prefixesOf = Effect.fn("prefixesOf")(function* prefixesOf(root, configPath) {
354
+ const files = yield* RepositoryFiles;
355
+ const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));
356
+ const directories = yield* workspaceClosure(directory);
357
+ return pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$6}`));
358
+ });
359
+ const projectInputs = ({ workspace: { compiler, root }, listed }) => (configPath) => Effect.gen(function* collectInputs() {
360
+ const files = yield* RepositoryFiles;
361
+ const parsed = parseConfig(compiler.api)(configPath);
362
+ if (Option.isNone(parsed)) return Option.none();
363
+ const prefixes = yield* prefixesOf(root, configPath);
364
+ const options = yield* encodeOptions(parsed.value.options).pipe(Effect.orElseSucceed(() => ""));
365
+ const sources = pipe(parsed.value.fileNames, Array.map((fileName) => files.relative(root, fileName)));
366
+ const shared = pipe(listed, Array.filter(isUnder(prefixes)));
367
+ return Option.some({
368
+ options,
369
+ files: Array.sort(Array.dedupe([...sources, ...shared]), Order.String)
370
+ });
371
+ });
317
372
  // src/shared/lib/text-position.ts
318
373
  const START$7 = 0;
319
374
  const FIRST_COLUMN$3 = 1;
@@ -431,7 +486,7 @@ const packagesByEntry = Effect.fn("packagesByEntry")(function* packagesByEntry(a
431
486
  }).pipe(Effect.map((packages) => [entry, packages]))));
432
487
  });
433
488
  // src/features/install-size/model/installed-closure.ts
434
- const EMPTY = 0;
489
+ const EMPTY$1 = 0;
435
490
  const DependencyMap = Schema.optional(Schema.Record(Schema.String, Schema.String));
436
491
  const PeerMetaEntry = Schema.Struct({ optional: Schema.optional(Schema.Boolean) });
437
492
  const PeerMeta = Schema.optional(Schema.Record(Schema.String, PeerMetaEntry));
@@ -490,7 +545,7 @@ const directorySize = (directory) => Effect.gen(function* sizeOfDirectory() {
490
545
  const names = yield* files.readDirectory(directory);
491
546
  const entries = pipe(names, Array.filter((name) => name !== NODE_MODULES), Array.map((name) => files.join(directory, name)));
492
547
  const sizes = yield* pipe(entries, Effect.forEach((entry) => files.isDirectory(entry).pipe(Effect.flatMap((kind) => {
493
- if (Option.isNone(kind)) return Effect.succeed(EMPTY);
548
+ if (Option.isNone(kind)) return Effect.succeed(EMPTY$1);
494
549
  if (kind.value) return directorySize(entry);
495
550
  return files.fileSize(entry);
496
551
  }))));
@@ -502,7 +557,7 @@ const installedClosure = ({ provided, from, name }) => closureOf(provided, {
502
557
  });
503
558
  const installedSize = (directory) => {
504
559
  if (String$1.includes(`/node_modules/`)(directory)) return directorySize(directory);
505
- return Effect.succeed(EMPTY);
560
+ return Effect.succeed(EMPTY$1);
506
561
  };
507
562
  // src/features/install-size/model/install-size.ts
508
563
  const INSTALL_SIZE = "install-size";
@@ -2107,6 +2162,112 @@ const analyzeProject = (owners) => (project) => {
2107
2162
  unowned: pipe(verdicts, Array.flatMap((found) => found.unowned))
2108
2163
  };
2109
2164
  };
2165
+ // src/features/value-owners/model/cache.ts
2166
+ const CACHE_DIRECTORY = [
2167
+ NODE_MODULES,
2168
+ ".cache",
2169
+ "msch",
2170
+ "value-owners"
2171
+ ];
2172
+ const CACHE_SUFFIX = ".json";
2173
+ const MANIFEST_ENTRY = "package.json";
2174
+ const FINGERPRINTED = ["src", "dist"];
2175
+ const EMPTY = "";
2176
+ const FIELD_SEPARATOR = "\0";
2177
+ const LINE_SEPARATOR = "\n";
2178
+ const ValueSchema = Schema.Union([Schema.String, Schema.Finite]);
2179
+ const UnownedSiteSchema = Schema.Struct({
2180
+ scope: Schema.Struct({
2181
+ name: Schema.String,
2182
+ dependencies: Schema.Array(Schema.String)
2183
+ }),
2184
+ file: Schema.String,
2185
+ start: Schema.Int,
2186
+ line: Schema.Int,
2187
+ column: Schema.Int,
2188
+ values: Schema.Array(ValueSchema)
2189
+ });
2190
+ const AnalysisSchema = Schema.Struct({
2191
+ problems: ProblemList,
2192
+ unowned: Schema.Array(UnownedSiteSchema)
2193
+ });
2194
+ const AnalysisJson = Schema.fromJsonString(AnalysisSchema);
2195
+ const hasher = Effect.gen(function* currentHasher() {
2196
+ return (yield* RepositoryFiles).hash;
2197
+ });
2198
+ const entryOf = (file, found) => `${file}${FIELD_SEPARATOR}${found}`;
2199
+ const fileDigest = (hash) => {
2200
+ const digests = /* @__PURE__ */ new Map();
2201
+ return (file) => Option.match(Option.fromUndefinedOr(digests.get(file)), {
2202
+ onSome: Effect.succeed,
2203
+ onNone: () => Effect.gen(function* readDigest() {
2204
+ const text = yield* (yield* RepositoryFiles).readFile(file);
2205
+ const found = yield* hash(Option.getOrElse(text, () => EMPTY));
2206
+ digests.set(file, found);
2207
+ return found;
2208
+ })
2209
+ });
2210
+ };
2211
+ const digestEntries = (digestFile) => (named) => pipe(named, Effect.forEach(([name, file]) => digestFile(file).pipe(Effect.map((found) => entryOf(name, found)))));
2212
+ const fingerprintedFiles = Effect.fn("fingerprintedFiles")(function* fingerprintedFiles(root) {
2213
+ const files = yield* RepositoryFiles;
2214
+ const nested = yield* pipe(FINGERPRINTED, Effect.forEach((entry) => {
2215
+ const base = files.join(root, entry);
2216
+ return files.walkDirectory(base).pipe(Effect.map(Array.map((file) => files.join(base, file))));
2217
+ }));
2218
+ return Array.sort([files.join(root, MANIFEST_ENTRY), ...Array.flatten(nested)], String$1.Order);
2219
+ });
2220
+ const fingerprintOf = Effect.fn("fingerprintOf")(function* fingerprintOf(hash) {
2221
+ const root = yield* nearestManifestDirectory(import.meta.dirname);
2222
+ const listed = yield* fingerprintedFiles(root);
2223
+ const entries = yield* digestEntries(fileDigest(hash))(pipe(listed, Array.map((file) => [file, file])));
2224
+ return yield* hash(Array.join(entries, LINE_SEPARATOR));
2225
+ });
2226
+ const analysisCache = Effect.fn("analysisCache")(function* analysisCache(root, owners) {
2227
+ const files = yield* RepositoryFiles;
2228
+ const hash = yield* hasher;
2229
+ const fingerprint = yield* fingerprintOf(hash);
2230
+ const salt = yield* hash(Array.join([fingerprint, owners], FIELD_SEPARATOR));
2231
+ return {
2232
+ root,
2233
+ directory: files.join(root, ...CACHE_DIRECTORY),
2234
+ salt,
2235
+ digestFile: fileDigest(hash),
2236
+ hash
2237
+ };
2238
+ });
2239
+ const keyOf = (cache) => (configPath, inputs) => Effect.gen(function* deriveKey() {
2240
+ const files = yield* RepositoryFiles;
2241
+ const entries = yield* digestEntries(cache.digestFile)(pipe(inputs.files, Array.map((file) => [file, files.join(cache.root, file)])));
2242
+ const header = [
2243
+ cache.salt,
2244
+ files.relative(cache.root, configPath),
2245
+ inputs.options
2246
+ ];
2247
+ return yield* cache.hash(Array.join([...header, ...entries], LINE_SEPARATOR));
2248
+ });
2249
+ const entryFile = (cache, key) => `${cache.directory}/${key}${CACHE_SUFFIX}`;
2250
+ const readAnalysis = (cache) => (key) => Effect.gen(function* readCached() {
2251
+ const text = yield* (yield* RepositoryFiles).readFile(entryFile(cache, key));
2252
+ return yield* Option.match(text, {
2253
+ onNone: () => Effect.succeedNone,
2254
+ onSome: (found) => Schema.decodeEffect(AnalysisJson)(found).pipe(Effect.option)
2255
+ });
2256
+ });
2257
+ const writeAnalysis = (cache) => (key, analysis) => Effect.gen(function* writeCached() {
2258
+ const files = yield* RepositoryFiles;
2259
+ const text = yield* Schema.encodeEffect(AnalysisJson)(analysis).pipe(Effect.option);
2260
+ yield* Option.match(text, {
2261
+ onNone: () => Effect.void,
2262
+ onSome: (found) => files.writeFile(entryFile(cache, key), found)
2263
+ });
2264
+ });
2265
+ const pruneAnalyses = (cache) => (kept) => Effect.gen(function* pruneCached() {
2266
+ const files = yield* RepositoryFiles;
2267
+ const keep = new Set(pipe(kept, Array.map((key) => `${key}${CACHE_SUFFIX}`)));
2268
+ const present = yield* files.readDirectory(cache.directory);
2269
+ yield* pipe(present, Array.filter((name) => !keep.has(name)), Effect.forEach((name) => files.removeFile(files.join(cache.directory, name))), Effect.asVoid);
2270
+ });
2110
2271
  // src/features/value-owners/model/duplicates.ts
2111
2272
  const DUPLICATE_THRESHOLD = 1;
2112
2273
  const unownedSiteOf = (scope) => (site) => ({
@@ -2149,14 +2310,54 @@ const scopeOf = (project, configPath) => ({
2149
2310
  name: Option.getOrElse(project.packageName, () => configPath),
2150
2311
  dependencies: project.workspaceDependencies
2151
2312
  });
2152
- const analyzeProjects = (workspace, owners) => (configPaths) => pipe(configPaths, Effect.forEach((configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => {
2313
+ const freshAnalysis = ({ workspace, owners }) => (configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => {
2153
2314
  const analysis = analyzeProject(owners)(project);
2154
2315
  const scope = scopeOf(project, configPath);
2155
2316
  return {
2156
2317
  problems: analysis.problems,
2157
2318
  unowned: pipe(analysis.unowned, Array.map(unownedSiteOf(scope)))
2158
2319
  };
2159
- }).pipe(Effect.withSpan("analyzeProject")))), Effect.map(Array.getSomes));
2320
+ }).pipe(Effect.withSpan("analyzeProject")));
2321
+ const keyedAnalysis = (context) => (configPath, key) => Effect.gen(function* lookupAnalysis() {
2322
+ const cached = yield* readAnalysis(context.cache)(key);
2323
+ if (Option.isSome(cached)) return cached;
2324
+ const fresh = yield* freshAnalysis(context)(configPath);
2325
+ yield* Option.match(fresh, {
2326
+ onNone: () => Effect.void,
2327
+ onSome: (analysis) => writeAnalysis(context.cache)(key, analysis)
2328
+ });
2329
+ return fresh;
2330
+ });
2331
+ const analyzeConfig = (context) => (configPath) => Effect.gen(function* analyzeOne() {
2332
+ const inputs = yield* projectInputs(context)(configPath);
2333
+ if (Option.isNone(inputs)) return Option.none();
2334
+ const key = yield* keyOf(context.cache)(configPath, inputs.value);
2335
+ const analysis = yield* keyedAnalysis(context)(configPath, key);
2336
+ return pipe(analysis, Option.map((found) => [key, found]));
2337
+ });
2338
+ const encodeOwners = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
2339
+ const cacheFor = Effect.fn("cacheFor")(function* cacheFor(root, owners) {
2340
+ const plain = pipe(owners, Array.map((owner) => ({
2341
+ ...owner,
2342
+ packageName: Option.getOrNull(owner.packageName)
2343
+ })));
2344
+ const encoded = yield* encodeOwners(plain).pipe(Effect.orElseSucceed(() => ""));
2345
+ return yield* analysisCache(root, encoded);
2346
+ });
2347
+ const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(workspace, owners, configPaths) {
2348
+ const files = yield* RepositoryFiles;
2349
+ const cache = yield* cacheFor(workspace.root, owners);
2350
+ const listed = yield* files.listedFiles(workspace.root);
2351
+ const keyed = yield* pipe(configPaths, Effect.forEach(analyzeConfig({
2352
+ workspace,
2353
+ owners,
2354
+ cache,
2355
+ listed
2356
+ })));
2357
+ const found = Array.getSomes(keyed);
2358
+ yield* pruneAnalyses(cache)(pipe(found, Array.map(([key]) => key)));
2359
+ return pipe(found, Array.map(([, analysis]) => analysis));
2360
+ });
2160
2361
  const checkRepository = Effect.fn("checkRepository")(function* checkRepository(root) {
2161
2362
  const files = yield* RepositoryFiles;
2162
2363
  const workspace = {
@@ -2166,7 +2367,7 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
2166
2367
  };
2167
2368
  const configPaths = yield* listConfigFiles(root);
2168
2369
  const ownerScan = yield* scanOwners(workspace, configPaths);
2169
- const analyses = yield* analyzeProjects(workspace, ownerScan.owners)(configPaths);
2370
+ const analyses = yield* analyzeProjects(workspace, ownerScan.owners, configPaths);
2170
2371
  const relative = (file) => files.relative(root, file);
2171
2372
  const unowned = pipe(analyses, Array.flatMap((analysis) => analysis.unowned));
2172
2373
  return sortProblems([
@@ -2627,6 +2828,7 @@ const SETUP_PATTERNS = [
2627
2828
  /(?<![\w./@-])cargo[ \t]+(?:vendor|fetch)\b/gu,
2628
2829
  /\buses:\s*["']?(?:dtolnay\/rust-toolchain|actions-rust-lang\/setup-rust-toolchain|actions-rs\/toolchain|moonrepo\/setup-rust)\b/gu
2629
2830
  ];
2831
+ const INSTALL_PATTERNS = [/(?<![\w./@-])cargo[ \t]+b?install\b/gu];
2630
2832
  const TOOL_PATTERNS = [/^[ \t]*["']?(?:rust|rustup)["']?[ \t]*(?:=|[ \t]+\S)/gmu];
2631
2833
  const START = 0;
2632
2834
  const LAST_SEGMENT = 1;
@@ -2658,17 +2860,24 @@ const generatedCargoConfig = (entry, source) => {
2658
2860
  return [pnpmCargoConfig(entry)];
2659
2861
  };
2660
2862
  const cargoOutsidePnpm = problemAtStart(CARGO_RULE, `pnpm does not manage these crates. Set \`cargo: { enabled: true }\` in ${WORKSPACE_FILE} so pnpm install fetches the crates and the Rust toolchain.`);
2661
- const setupProblem = ({ file }, source) => (found) => ({
2863
+ const setupProblem = ({ file }, source, advice) => (found) => ({
2662
2864
  file,
2663
2865
  ...positionOf(source)(found.index ?? WHOLE_MATCH),
2664
2866
  rule: SETUP_RULE,
2665
- message: `pnpm install already installs the toolchain in rust-toolchain.toml and vendors the crates in Cargo.lock. Remove \`${String$1.trim(found[WHOLE_MATCH])}\`.`
2867
+ message: advice(String$1.trim(found[WHOLE_MATCH]))
2666
2868
  });
2869
+ const removeSetup = (command) => `pnpm install already installs the toolchain in rust-toolchain.toml and vendors the crates in Cargo.lock. Remove \`${command}\`.`;
2870
+ const buildInstead = (command) => `\`${command}\` fetches crates that pnpm does not vendor. Add the tool as a dependency of a Cargo workspace that pnpm vendors, and build its binary there with \`cargo build -p <crate> --bin <name>\`.`;
2667
2871
  const setupPatternsFor = (entry) => {
2668
2872
  if (isToolVersions(entry)) return [...SETUP_PATTERNS, ...TOOL_PATTERNS];
2669
2873
  return SETUP_PATTERNS;
2670
2874
  };
2671
- const setupProblems = (entry, source) => pipe(setupPatternsFor(entry), Array.flatMap((pattern) => Array.fromIterable(String$1.matchAll(pattern)(source))), Array.map(setupProblem(entry, source)), Array.appendAll(generatedCargoConfig(entry, source)));
2875
+ const matchesOf = (source) => (patterns) => pipe(patterns, Array.flatMap((pattern) => Array.fromIterable(String$1.matchAll(pattern)(source))));
2876
+ const setupProblems = (entry, source) => {
2877
+ const found = matchesOf(source);
2878
+ const installs = pipe(found(INSTALL_PATTERNS), Array.map(setupProblem(entry, source, buildInstead)));
2879
+ return pipe(found(setupPatternsFor(entry)), Array.map(setupProblem(entry, source, removeSetup)), Array.appendAll(installs), Array.appendAll(generatedCargoConfig(entry, source)));
2880
+ };
2672
2881
  const matches = (pattern) => ({ name }) => pattern.test(name);
2673
2882
  const isCargoManifest = matches(CARGO_MANIFEST_FILE);
2674
2883
  const isForeignLockfile = matches(FOREIGN_LOCKFILE);
@@ -2682,7 +2891,7 @@ const ancestorsOf = (directory) => {
2682
2891
  const readsCargoLock = (manifests, workspaces) => ({ name }) => {
2683
2892
  const directory = directoryOf(name);
2684
2893
  const insideWorkspace = pipe(ancestorsOf(directory), Array.some((ancestor) => Array.contains(workspaces, ancestor)));
2685
- return Array.contains(manifests, directory) && !insideWorkspace;
2894
+ return Array.contains(manifests, directory) && (Array.contains(workspaces, directory) || !insideWorkspace);
2686
2895
  };
2687
2896
  const isWorkspaceManifest = (source) => Option.exists(source, (text) => CARGO_WORKSPACE.test(text));
2688
2897
  const directoriesOf = (entries) => pipe(entries, Array.map(({ name }) => directoryOf(name)));