@r_masseater/msch 0.54.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +18 -18
  2. package/dist/app-B22Gq0no.mjs +2120 -0
  3. package/dist/app-B22Gq0no.mjs.map +1 -0
  4. package/dist/cargo-inputs.d.mts +1 -1
  5. package/dist/cargo-inputs.mjs +5 -11
  6. package/dist/cargo-inputs.mjs.map +1 -1
  7. package/dist/changed.mjs +90 -19
  8. package/dist/changed.mjs.map +1 -1
  9. package/dist/cli.mjs +1361 -707
  10. package/dist/cli.mjs.map +1 -1
  11. package/dist/config.d.mts +1 -1
  12. package/dist/config.mjs +3 -2
  13. package/dist/config.mjs.map +1 -1
  14. package/dist/credential-broker-9FMyTp1H.mjs +44 -0
  15. package/dist/credential-broker-9FMyTp1H.mjs.map +1 -0
  16. package/dist/decision-rules.d.mts +1 -1
  17. package/dist/decision-rules.mjs +1 -1
  18. package/dist/{define-lint-preset-CWEkZVIC.mjs → define-lint-preset-DeLIlDuA.mjs} +7 -634
  19. package/dist/define-lint-preset-DeLIlDuA.mjs.map +1 -0
  20. package/dist/dependencies-B6p7x90y.mjs +215 -0
  21. package/dist/dependencies-B6p7x90y.mjs.map +1 -0
  22. package/dist/exits.mjs +4 -5
  23. package/dist/exits.mjs.map +1 -1
  24. package/dist/{ignored-directories-BTMTNuAx.mjs → ignored-directories-BgUqwuc4.mjs} +12 -3
  25. package/dist/ignored-directories-BgUqwuc4.mjs.map +1 -0
  26. package/dist/{index-BeH2yfX6.d.mts → index-Cwnhs7VE.d.mts} +4 -51
  27. package/dist/library.d.mts +18 -0
  28. package/dist/library.mjs +28 -0
  29. package/dist/library.mjs.map +1 -0
  30. package/dist/lint-rules.mjs +243 -40
  31. package/dist/lint-rules.mjs.map +1 -1
  32. package/dist/lint.d.mts +2 -2
  33. package/dist/lint.mjs +1 -1
  34. package/dist/locked-inputs-DMSoGCa-.mjs +20 -0
  35. package/dist/locked-inputs-DMSoGCa-.mjs.map +1 -0
  36. package/dist/locked-inputs.d.mts +2 -3
  37. package/dist/locked-inputs.mjs +1 -20
  38. package/dist/oxlint.mjs +28 -14
  39. package/dist/oxlint.mjs.map +1 -1
  40. package/dist/{project-C4uzq7_4.mjs → pass-records-BCT1Ls9c.mjs} +38 -66
  41. package/dist/pass-records-BCT1Ls9c.mjs.map +1 -0
  42. package/dist/{problem-CzOlOb5f.mjs → problem-BoHYLMQT.mjs} +10 -6
  43. package/dist/problem-BoHYLMQT.mjs.map +1 -0
  44. package/dist/publish.mjs +634 -303
  45. package/dist/publish.mjs.map +1 -1
  46. package/dist/published-BNJdq0h1.mjs +510 -0
  47. package/dist/published-BNJdq0h1.mjs.map +1 -0
  48. package/dist/runtime-LT40e_l3.mjs +28 -0
  49. package/dist/runtime-LT40e_l3.mjs.map +1 -0
  50. package/dist/{syntax-3AJkpCcs.mjs → syntax-CTiXR0EJ.mjs} +13 -4
  51. package/dist/syntax-CTiXR0EJ.mjs.map +1 -0
  52. package/dist/{check-upstream-exits-DYxWDyHC.mjs → upstream-exits-DitN-yYH.mjs} +10 -92
  53. package/dist/upstream-exits-DitN-yYH.mjs.map +1 -0
  54. package/dist/wake.d.mts +1 -0
  55. package/dist/wake.mjs +25 -0
  56. package/dist/wake.mjs.map +1 -0
  57. package/dist/workspace-settings.mjs +69 -7
  58. package/dist/workspace-settings.mjs.map +1 -1
  59. package/package.json +31 -22
  60. package/skills/{publishing → msch-publishing}/SKILL.md +8 -2
  61. package/skills/{repository-config → msch-repository-config}/SKILL.md +5 -2
  62. package/skills/{workspace-settings → msch-workspace-settings}/SKILL.md +4 -3
  63. package/dist/check-upstream-exits-DYxWDyHC.mjs.map +0 -1
  64. package/dist/define-lint-preset-CWEkZVIC.mjs.map +0 -1
  65. package/dist/dependencies-DCJv7YcW.mjs +0 -684
  66. package/dist/dependencies-DCJv7YcW.mjs.map +0 -1
  67. package/dist/ignored-directories-BTMTNuAx.mjs.map +0 -1
  68. package/dist/locked-inputs.mjs.map +0 -1
  69. package/dist/package-LeBO9czg.mjs +0 -144
  70. package/dist/package-LeBO9czg.mjs.map +0 -1
  71. package/dist/problem-CzOlOb5f.mjs.map +0 -1
  72. package/dist/project-C4uzq7_4.mjs.map +0 -1
  73. package/dist/reachable-Cc-255L3.mjs +0 -13
  74. package/dist/reachable-Cc-255L3.mjs.map +0 -1
  75. package/dist/runtime-DFsdNYI0.mjs +0 -29
  76. package/dist/runtime-DFsdNYI0.mjs.map +0 -1
  77. package/dist/syntax-3AJkpCcs.mjs.map +0 -1
@@ -0,0 +1,28 @@
1
+ import { r as nodeRepositoryFiles } from "./repository-files-B5sRbxlz.mjs";
2
+ import { Cause, Effect, Option, Schema, Stdio, Stream } from "effect";
3
+ import { runMainWith } from "@r_masseater/node-main";
4
+ // src/app/output.ts
5
+ const taggedError = Schema.TaggedError;
6
+ var ProblemsFound = class extends taggedError()("ProblemsFound", { count: Schema.Finite }) {};
7
+ /** @internal */
8
+ const writeStdout = Effect.fn("writeStdout")(function* writeStdout(text) {
9
+ const stdio = yield* Stdio.Stdio;
10
+ yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);
11
+ });
12
+ // src/app/runtime.ts
13
+ const reportFailure = (cause) => Effect.gen(function* report() {
14
+ const stdio = yield* Stdio.Stdio;
15
+ if (Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)))) return;
16
+ yield* Stream.make(`${Cause.pretty(cause)}\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);
17
+ });
18
+ /** @internal */
19
+ const runCli = (program) => {
20
+ runMainWith({
21
+ serviceName: "msch",
22
+ services: nodeRepositoryFiles,
23
+ onFailure: reportFailure
24
+ })(program);
25
+ };
26
+ export { ProblemsFound as n, writeStdout as r, runCli as t };
27
+
28
+ //# sourceMappingURL=runtime-LT40e_l3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-LT40e_l3.mjs","names":[],"sources":["../src/app/output.ts","../src/app/runtime.ts"],"sourcesContent":["import { Effect, Schema, Stdio, Stream } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class ProblemsFound extends taggedError<ProblemsFound, { readonly brand: unique symbol }>()(\n \"ProblemsFound\",\n {\n count: Schema.Finite,\n },\n) {}\n\n/** @internal */\nexport const writeStdout = Effect.fn(\"writeStdout\")(function* writeStdout(text: string) {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n});\n","import { runMainWith } from \"@r_masseater/node-main\";\nimport { Cause, Effect, Option, Schema, Stdio, Stream } from \"effect\";\nimport type { FileSystem, Path } from \"effect\";\nimport type { HttpClient } from \"effect/http\";\nimport type { ChildProcessSpawner } from \"effect/process\";\n\nimport { nodeRepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport type { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { ProblemsFound } from \"./output.ts\";\n\nconst reportFailure = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const failed = Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)));\n if (failed) {\n return;\n }\n yield* Stream.make(`${Cause.pretty(cause)}\\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const runCli = <Value, Failure>(\n program: Effect.Effect<\n Value,\n Failure,\n | RepositoryFiles\n | Stdio.Stdio\n | FileSystem.FileSystem\n | Path.Path\n | ChildProcessSpawner.ChildProcessSpawner\n | HttpClient.HttpClient\n >,\n): void => {\n runMainWith({\n serviceName: \"msch\",\n services: nodeRepositoryFiles,\n onFailure: reportFailure,\n })(program);\n};\n"],"mappings":";;;;AAEA,MAAM,cAAc,OAAO;AAE3B,IAAa,gBAAb,cAAmC,YAA8D,CAAC,CAChG,iBACA,EACE,OAAO,OAAO,OAChB,CACF,CAAC,CAAC,CAAC;;AAGH,MAAa,cAAc,OAAO,GAAG,aAAa,CAAC,CAAC,UAAU,YAAY,MAAc;CACtF,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,KAAK;AACxE,CAAC;;ACJD,MAAM,iBACJ,UAEA,OAAO,IAAI,UAAU,SAAS;CAC5B,MAAM,QAAQ,OAAO,MAAM;CAE3B,IADe,MAAM,gBAAgB,KAAK,CAAC,CAAC,KAAK,OAAO,OAAO,OAAO,GAAG,aAAa,CAAC,CAC9E,GACP;CAEF,OAAO,OAAO,KAAK,GAAG,MAAM,OAAO,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,KAAK;AAC9F,CAAC;;AAGH,MAAa,UACX,YAUS;CACT,YAAY;EACV,aAAa;EACb,UAAU;EACV,WAAW;CACb,CAAC,CAAC,CAAC,OAAO;AACZ"}
@@ -1,8 +1,8 @@
1
1
  import { t as NODE_MODULES } from "./repository-files-B5sRbxlz.mjs";
2
2
  import { Array, Option, String, pipe } from "effect";
3
3
  import { InternalSymbolName, SyntaxKind, getJSDocTags, getLeadingCommentRanges, getNameOfDeclaration, getTextOfJSDocComment } from "typescript/ast";
4
- import { isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isReturnStatement, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "typescript/ast/is";
5
- import { API, IndexKind, SignatureKind } from "typescript/sync";
4
+ import { isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isExpressionStatement, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isLiteralTypeNode, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isPropertySignatureDeclaration, isReturnStatement, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "typescript/ast/is";
5
+ import { API, IndexKind, SignatureKind, SymbolFlags as SymbolFlags$1 } from "typescript/sync";
6
6
  // src/shared/lib/syntax.ts
7
7
  const NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;
8
8
  const uniqueByReference = (items) => Array.dedupeWith(items, (left, right) => left === right);
@@ -28,6 +28,7 @@ const packageOf = (fileName) => {
28
28
  const descendantsOf = (node) => pipe(childrenOf(node), Array.flatMap((child) => Array.prepend(descendantsOf(child), child)));
29
29
  const isExternalFile = (program) => (sourceFile) => !program.isSourceFileDefaultLibrary(sourceFile) && (String.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) || program.isSourceFileFromExternalLibrary(sourceFile));
30
30
  const isExternalDeclaration = (program) => (declaration) => isExternalFile(program)(declaration.getSourceFile());
31
+ const isOutsideDeclaration = (program) => (declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()) || isExternalDeclaration(program)(declaration);
31
32
  const ALIAS_KINDS = /* @__PURE__ */ new Set([
32
33
  SyntaxKind.ImportSpecifier,
33
34
  SyntaxKind.ImportClause,
@@ -61,6 +62,14 @@ const columnOf = (node) => {
61
62
  const contains = (outer) => (inner) => outer.getSourceFile().fileName === inner.getSourceFile().fileName && outer.getStart() <= inner.getStart() && inner.getEnd() <= outer.getEnd();
62
63
  const isInsideAny = (outers) => (node) => pipe(outers, Array.some((outer) => contains(outer)(node)));
63
64
  const isTypeDeclaration = (declaration) => isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration) || isEnumDeclaration(declaration);
65
+ const membersOf = (declaration) => {
66
+ if (isInterfaceDeclaration(declaration) || isClassDeclaration(declaration)) return declaration.members;
67
+ if (isTypeAliasDeclaration(declaration) && isTypeLiteralNode(declaration.type)) return declaration.type.members;
68
+ return [];
69
+ };
70
+ const isTagNamed = (name) => (member) => (isPropertySignatureDeclaration(member) || isPropertyDeclaration(member)) && pipe(Option.fromUndefinedOr(member.type), Option.exists((type) => isLiteralTypeNode(type) && isStringLiteral(type.literal) && type.literal.text === name));
71
+ const declaresAType = (declarations) => pipe(declarations, Array.some((declaration) => isTypeDeclaration(declaration) || isClassDeclaration(declaration)));
72
+ const carriesTag = (name) => (declarations) => pipe(declarations, Array.flatMap(membersOf), Array.some(isTagNamed(name)));
64
73
  const isGenericDeclaration = (declaration) => (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) && Array.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);
65
74
  const propertyNamesOf = (checker) => (type) => pipe(checker.getPropertiesOfType(type), Array.map((property) => property.name));
66
75
  const moduleSpecifierOf = (statement) => {
@@ -68,6 +77,6 @@ const moduleSpecifierOf = (statement) => {
68
77
  return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter((specifier) => isStringLiteral(specifier)), Option.map((specifier) => specifier.text));
69
78
  };
70
79
  const importedModulesOf = (sourceFile) => pipe(sourceFile.statements, Array.map((statement) => moduleSpecifierOf(statement)), Array.getSomes);
71
- export { isSpreadElement as $, isBlock as A, isInterfaceDeclaration as B, getJSDocTags as C, isArrayLiteralExpression as D, getTextOfJSDocComment as E, isExportDeclaration as F, isObjectLiteralExpression as G, isModuleDeclaration as H, isFunctionDeclaration as I, isPropertyAssignment as J, isParenthesizedExpression as K, isFunctionExpression as L, isClassDeclaration as M, isElementAccessExpression as N, isArrowFunction as O, isEnumDeclaration as P, isSourceFile as Q, isIdentifier as R, SyntaxKind as S, getNameOfDeclaration as T, isNewExpression as U, isModuleBlock as V, isNumericLiteral as W, isSatisfiesExpression as X, isReturnStatement as Y, isSignatureDeclaration as Z, uniqueByReference as _, descendantsOf as a, isVariableDeclaration as at, InternalSymbolName as b, isGenericDeclaration as c, lineOf as d, isStringLiteral as et, packageOf as f, symbolAt as g, resolvedSymbol as h, declarationsOf as i, isUnionTypeNode as it, isCallExpression as j, isBinaryExpression as k, isInsideAny as l, referencedSymbols as m, columnOf as n, isTypeLiteralNode as nt, importedModulesOf as o, isVariableDeclarationList as ot, propertyNamesOf as p, isPropertyAccessExpression as q, contains as r, isTypeReferenceNode as rt, isExternalDeclaration as s, isVariableStatement as st, childrenOf as t, isTypeAliasDeclaration as tt, isTypeDeclaration as u, API as v, getLeadingCommentRanges as w, SignatureKind as x, IndexKind as y, isImportDeclaration as z };
80
+ export { isPropertyAssignment as $, getTextOfJSDocComment as A, isExpressionStatement as B, InternalSymbolName as C, getJSDocTags as D, SyntaxKind as E, isCallExpression as F, isInterfaceDeclaration as G, isFunctionExpression as H, isClassDeclaration as I, isNewExpression as J, isModuleBlock as K, isElementAccessExpression as L, isArrowFunction as M, isBinaryExpression as N, getLeadingCommentRanges as O, isBlock as P, isPropertyAccessExpression as Q, isEnumDeclaration as R, IndexKind as S, SymbolFlags$1 as T, isIdentifier as U, isFunctionDeclaration as V, isImportDeclaration as W, isObjectLiteralExpression as X, isNumericLiteral as Y, isParenthesizedExpression as Z, referencedSymbols as _, declarationsOf as a, isStringLiteral as at, uniqueByReference as b, importedModulesOf as c, isTypeReferenceNode as ct, isInsideAny as d, isVariableDeclarationList as dt, isReturnStatement as et, isOutsideDeclaration as f, isVariableStatement as ft, propertyNamesOf as g, packageOf as h, contains as i, isSpreadElement as it, isArrayLiteralExpression as j, getNameOfDeclaration as k, isExternalDeclaration as l, isUnionTypeNode as lt, lineOf as m, childrenOf as n, isSignatureDeclaration as nt, declaresAType as o, isTypeAliasDeclaration as ot, isTypeDeclaration as p, isModuleDeclaration as q, columnOf as r, isSourceFile as rt, descendantsOf as s, isTypeLiteralNode as st, carriesTag as t, isSatisfiesExpression as tt, isGenericDeclaration as u, isVariableDeclaration as ut, resolvedSymbol as v, SignatureKind as w, API as x, symbolAt as y, isExportDeclaration as z };
72
81
 
73
- //# sourceMappingURL=syntax-3AJkpCcs.mjs.map
82
+ //# sourceMappingURL=syntax-CTiXR0EJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-CTiXR0EJ.mjs","names":["Arr","Str"],"sources":["../src/shared/lib/syntax.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n isClassDeclaration,\n isEnumDeclaration,\n isExportAssignment,\n isExportDeclaration,\n isIdentifier,\n isImportDeclaration,\n isInterfaceDeclaration,\n isLiteralTypeNode,\n isPropertyAccessExpression,\n isPropertyDeclaration,\n isPropertySignatureDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n EnumDeclaration,\n Expression,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n} from \"./compiler.ts\";\nimport { NODE_MODULES } from \"./repository-files.ts\";\n\nconst NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;\n\nexport const POSITION_BASE = 1;\n\nexport const uniqueByReference = <Item>(items: readonly Item[]): readonly Item[] =>\n Arr.dedupeWith(items, (left, right) => left === right);\n\nexport const childrenOf = (node: Node): readonly Node[] => {\n const children: Node[] = [];\n node.forEachChild((child) => {\n children.push(child);\n });\n return children;\n};\n\nconst SCOPE_PREFIX = \"@\";\nconst SCOPED_SEGMENTS = 2;\nconst UNSCOPED_SEGMENTS = 1;\n\nexport const packageOf = (fileName: string): string => {\n const afterModules = pipe(\n fileName,\n Str.lastIndexOf(NODE_MODULES_SEGMENT),\n Option.match({\n onNone: () => fileName,\n onSome: (index) => Str.slice(index + NODE_MODULES_SEGMENT.length)(fileName),\n }),\n );\n const segments = Str.split(\"/\")(afterModules);\n if (Str.startsWith(SCOPE_PREFIX)(afterModules)) {\n return pipe(Arr.take(segments, SCOPED_SEGMENTS), Arr.join(\"/\"));\n }\n return pipe(Arr.take(segments, UNSCOPED_SEGMENTS), Arr.join(\"/\"));\n};\n\nexport const descendantsOf = (node: Node): readonly Node[] =>\n pipe(\n childrenOf(node),\n Arr.flatMap((child) => Arr.prepend(descendantsOf(child), child)),\n );\n\nconst isExternalFile =\n (program: Program) =>\n (sourceFile: SourceFile): boolean =>\n !program.isSourceFileDefaultLibrary(sourceFile) &&\n (Str.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) ||\n program.isSourceFileFromExternalLibrary(sourceFile));\n\nexport const isExternalDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n isExternalFile(program)(declaration.getSourceFile());\n\nexport const isOutsideDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n program.isSourceFileDefaultLibrary(declaration.getSourceFile()) ||\n isExternalDeclaration(program)(declaration);\n\nconst ALIAS_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ImportSpecifier,\n SyntaxKind.ImportClause,\n SyntaxKind.NamespaceImport,\n SyntaxKind.ExportSpecifier,\n SyntaxKind.ImportEqualsDeclaration,\n SyntaxKind.ExportAssignment,\n]);\n\nexport const declarationsOf = (symbol: TypeSymbol): readonly Declaration[] =>\n pipe(\n symbol.declarations,\n Arr.flatMap((handle) => Option.toArray(Option.fromUndefinedOr(handle.resolve()))),\n );\n\nconst isEntityName = (expression: Expression): boolean =>\n isIdentifier(expression) ||\n (isPropertyAccessExpression(expression) && isEntityName(expression.expression));\n\nconst aliasesAnEntity = (declaration: Node): boolean =>\n !isExportAssignment(declaration) || isEntityName(declaration.expression);\n\nconst isAliasDeclaration = (declaration: Node): boolean =>\n ALIAS_KINDS.has(declaration.kind) && aliasesAnEntity(declaration);\n\nexport const resolvedSymbol =\n (checker: Checker) =>\n (symbol: TypeSymbol): TypeSymbol => {\n if (\n !pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isAliasDeclaration(declaration)),\n )\n ) {\n return symbol;\n }\n return checker.getAliasedSymbol(symbol);\n };\n\nexport const symbolAt =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(node)).pipe(\n Option.map(resolvedSymbol(checker)),\n );\n\nexport const referencedSymbols =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] => {\n const identifiers = pipe(\n Arr.prepend(descendantsOf(node), node),\n Arr.filter((candidate) => isIdentifier(candidate)),\n );\n const symbols = pipe(\n checker.getSymbolAtLocation(identifiers),\n Arr.flatMap((symbol) => Option.toArray(Option.fromUndefinedOr(symbol))),\n Arr.map(resolvedSymbol(checker)),\n );\n return uniqueByReference(symbols);\n };\n\nexport const lineOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + POSITION_BASE;\n};\n\nexport const columnOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return (\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).character + POSITION_BASE\n );\n};\n\nexport const contains =\n (outer: Node) =>\n (inner: Node): boolean =>\n outer.getSourceFile().fileName === inner.getSourceFile().fileName &&\n outer.getStart() <= inner.getStart() &&\n inner.getEnd() <= outer.getEnd();\n\nexport const isInsideAny =\n (outers: readonly Node[]) =>\n (node: Node): boolean =>\n pipe(\n outers,\n Arr.some((outer) => contains(outer)(node)),\n );\n\nexport const isTypeDeclaration = (\n declaration: Node,\n): declaration is TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration =>\n isTypeAliasDeclaration(declaration) ||\n isInterfaceDeclaration(declaration) ||\n isEnumDeclaration(declaration);\n\nconst membersOf = (declaration: Node): readonly Node[] => {\n if (isInterfaceDeclaration(declaration) || isClassDeclaration(declaration)) {\n return declaration.members;\n }\n if (isTypeAliasDeclaration(declaration) && isTypeLiteralNode(declaration.type)) {\n return declaration.type.members;\n }\n return [];\n};\n\nconst isTagNamed =\n (name: string) =>\n (member: Node): boolean =>\n (isPropertySignatureDeclaration(member) || isPropertyDeclaration(member)) &&\n pipe(\n Option.fromUndefinedOr(member.type),\n Option.exists(\n (type) =>\n isLiteralTypeNode(type) && isStringLiteral(type.literal) && type.literal.text === name,\n ),\n );\n\nexport const declaresAType = (declarations: readonly Node[]): boolean =>\n pipe(\n declarations,\n Arr.some((declaration) => isTypeDeclaration(declaration) || isClassDeclaration(declaration)),\n );\n\nexport const carriesTag =\n (name: string) =>\n (declarations: readonly Node[]): boolean =>\n pipe(declarations, Arr.flatMap(membersOf), Arr.some(isTagNamed(name)));\n\nexport const isGenericDeclaration = (declaration: Node): boolean =>\n (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) &&\n Arr.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);\n\nexport const propertyNamesOf =\n (checker: Checker) =>\n (type: Type): readonly string[] =>\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => property.name),\n );\n\nconst moduleSpecifierOf = (statement: Node): Option.Option<string> => {\n if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(\n Option.filter((specifier) => isStringLiteral(specifier)),\n Option.map((specifier) => specifier.text),\n );\n};\n\nexport const importedModulesOf = (sourceFile: SourceFile): readonly string[] =>\n pipe(\n sourceFile.statements,\n Arr.map((statement) => moduleSpecifierOf(statement)),\n Arr.getSomes,\n );\n"],"mapp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,CACrC;AAEJ,MAAM,qBAAqB,cAA2C;CACpE,IAAI,CAAC,oBAAoB,SAAS,KAAK,CAAC,oBAAoB,SAAS,GACnE,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,gBAAgB,UAAU,eAAe,CAAC,CAAC,KACvD,OAAO,QAAQ,cAAc,gBAAgB,SAAS,CAAC,GACvD,OAAO,KAAK,cAAc,UAAU,IAAI,CAC1C;AACF;AAEA,MAAa,qBAAqB,eAChC,KACE,WAAW,YACXA,MAAI,KAAK,cAAc,kBAAkB,SAAS,CAAC,GACnDA,MAAI,QACN"}
@@ -5,10 +5,10 @@ import semver from "semver";
5
5
  import { parseTOML } from "toml-eslint-parser";
6
6
  import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
7
7
  // src/shared/lib/text-position.ts
8
- const START$1 = 0;
8
+ const START = 0;
9
9
  const FIRST_COLUMN = 1;
10
10
  const positionOf = (source) => (index) => {
11
- const before = pipe(source, String$1.slice(START$1, index), String$1.split("\n"));
11
+ const before = pipe(source, String$1.slice(START, index), String$1.split("\n"));
12
12
  return {
13
13
  line: before.length,
14
14
  column: pipe(Array.last(before), Option.match({
@@ -17,36 +17,6 @@ const positionOf = (source) => (index) => {
17
17
  }))
18
18
  };
19
19
  };
20
- // src/shared/lib/scanned-files.ts
21
- const SCANNED_FILE = /(?:\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\/)(?:(?:Dockerfile|Containerfile)[^/]*|Makefile|justfile|\.tool-versions|[^./][^./]*))$/u;
22
- const LOCKFILE = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
23
- const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
24
- const READ_CONCURRENCY = 64;
25
- const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE.test(name);
26
- const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
27
- /** @internal */
28
- const listedFiles = Effect.fn("listedFiles")(function* listedFiles(root) {
29
- const files = yield* RepositoryFiles;
30
- const names = yield* files.ownedFiles(root);
31
- return pipe(names, Array.map((name) => ({
32
- name,
33
- file: files.join(root, name)
34
- })));
35
- });
36
- /** @internal */
37
- const presentFiles = Effect.fn("presentFiles")(function* presentFiles(listed) {
38
- const files = yield* RepositoryFiles;
39
- return yield* pipe(listed, Effect.filter(({ file }) => files.exists(file)));
40
- });
41
- /** @internal */
42
- const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
43
- const files = yield* RepositoryFiles;
44
- const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
45
- onNone: () => [],
46
- onSome: (source) => problemsIn(entry, source)
47
- }))), { concurrency: READ_CONCURRENCY });
48
- return Array.flatten(found);
49
- });
50
20
  // src/shared/lib/config-comments.ts
51
21
  const isRecord = (value) => typeof value === "object" && value !== null;
52
22
  const childrenOf = (value) => {
@@ -256,7 +226,7 @@ const isUnused = (condition) => condition.kind === "unused";
256
226
  const NPM = "https://registry.npmjs.org/";
257
227
  const CRATES = "https://crates.io/api/v1/crates/";
258
228
  const GITHUB = "https://api.github.com/repos/";
259
- const USER_AGENT = "msch-exits (https://github.com/masseater/masseater.dev/tree/main/libs/msch)";
229
+ const USER_AGENT = "msch-exits (https://github.com/masseater/ecosystems/tree/main/libs/msch)";
260
230
  const LOOKUP_CONCURRENCY = 4;
261
231
  const RANGE_OPTIONS = { includePrerelease: true };
262
232
  const DECLARING_SECTIONS = [
@@ -379,7 +349,7 @@ const metExits = Effect.fn("metExits")(function* metExits(entries) {
379
349
  return Array.getSomes(results);
380
350
  });
381
351
  // src/features/check-upstream-exits/model/upstream-exits.ts
382
- const RULE$1 = "upstream-exit";
352
+ const RULE = "upstream-exit";
383
353
  const ROOT_FILES = [{
384
354
  name: "pnpm-workspace.yaml",
385
355
  deviationsOf: workspaceDeviations
@@ -389,10 +359,10 @@ const ROOT_FILES = [{
389
359
  }];
390
360
  const REASON = "Every deviation from an upstream package is temporary, and the comment says when to go back to the official package so that msch-exits can tell.";
391
361
  const STRAY = "An exit condition belongs at the end of the line of an overrides, patchedDependencies, packageExtensions or [patch] entry. Move it there or delete it.";
392
- const problemAt$1 = ({ file, source }) => (index, message) => ({
362
+ const problemAt = ({ file, source }) => (index, message) => ({
393
363
  file,
394
364
  ...positionOf(source)(index),
395
- rule: RULE$1,
365
+ rule: RULE,
396
366
  message
397
367
  });
398
368
  const messageFor = (entry, exitText) => {
@@ -406,12 +376,12 @@ const entryProblems = (read) => {
406
376
  const comments = commentsByLine(read.deviations.comments);
407
377
  return pipe(read.deviations.entries, Array.flatMap((entry) => {
408
378
  const exitText = pipe(HashMap.get(comments, entry.line), Option.flatMap(({ text }) => exitTextOf(text)));
409
- return pipe(messageFor(entry, exitText), Option.map((message) => problemAt$1(read)(entry.index, message)), Option.toArray);
379
+ return pipe(messageFor(entry, exitText), Option.map((message) => problemAt(read)(entry.index, message)), Option.toArray);
410
380
  }));
411
381
  };
412
382
  const strayProblems = (read) => {
413
383
  const entryLines = HashSet.fromIterable(pipe(read.deviations.entries, Array.map(({ line }) => line)));
414
- return pipe(read.deviations.comments, Array.filter((comment) => Option.isSome(exitTextOf(comment.text)) && !HashSet.has(entryLines, comment.line)), Array.map((comment) => problemAt$1(read)(comment.index, STRAY)));
384
+ return pipe(read.deviations.comments, Array.filter((comment) => Option.isSome(exitTextOf(comment.text)) && !HashSet.has(entryLines, comment.line)), Array.map((comment) => problemAt(read)(comment.index, STRAY)));
415
385
  };
416
386
  const readRootFiles = Effect.fn("readRootFiles")(function* readRootFiles(root) {
417
387
  const files = yield* RepositoryFiles;
@@ -442,58 +412,6 @@ const upstreamExitsMet = Effect.fn("upstreamExitsMet")(function* upstreamExitsMe
442
412
  }, { concurrency: 1 });
443
413
  return Array.flatten(perFile);
444
414
  });
445
- // src/features/check-upstream-exits/model/scattered-deviations.ts
446
- const RULE = "upstream-deviation-place";
447
- const MANIFEST = "package.json";
448
- const NESTED_WORKSPACE = "/pnpm-workspace.yaml";
449
- const NESTED_CARGO = "/Cargo.toml";
450
- const CARGO_CONFIG = /(?:^|\/)\.cargo\/config(?:\.toml)?$/u;
451
- const MANAGER_FIELDS = ["overrides", "resolutions"];
452
- const START = 0;
453
- const PLACE = "Upstream deviations live only in the root pnpm-workspace.yaml (overrides, patchedDependencies, packageExtensions) and the root Cargo.toml ([patch]), each with an exit condition.";
454
- const Fields = Schema.Record(Schema.String, Schema.Unknown);
455
- const Manifest = Schema.fromJsonString(Schema.Struct({
456
- pnpm: Schema.optional(Fields),
457
- overrides: Schema.optional(Schema.Unknown),
458
- resolutions: Schema.optional(Schema.Unknown)
459
- }));
460
- const decodeManifest = Schema.decodeUnknownOption(Manifest);
461
- const isManifest = (name) => name === MANIFEST || String$1.endsWith(`/${MANIFEST}`)(name);
462
- const problemAt = (entry, source) => (index, message) => ({
463
- file: entry.file,
464
- ...positionOf(source)(index),
465
- rule: RULE,
466
- message
467
- });
468
- const keyIndex = (source, key) => Option.getOrElse(String$1.indexOf(`"${key}"`)(source), () => START);
469
- const fieldsIn = (source) => pipe(decodeManifest(source), Option.match({
470
- onNone: () => [],
471
- onSome: (manifest) => {
472
- const pnpm = Option.getOrElse(Option.fromUndefinedOr(manifest.pnpm), () => ({}));
473
- const pnpmFields = pipe(WORKSPACE_SECTIONS, Array.filter((key) => Record.has(pnpm, key)), Array.map((key) => ({
474
- name: `pnpm.${key}`,
475
- key
476
- })));
477
- const managerFields = pipe(MANAGER_FIELDS, Array.filter((key) => Option.isSome(Option.fromUndefinedOr(manifest[key]))), Array.map((key) => ({
478
- name: key,
479
- key
480
- })));
481
- return [...pnpmFields, ...managerFields];
482
- }
483
- }));
484
- const manifestProblems = (entry, source) => pipe(fieldsIn(source), Array.map(({ name, key }) => problemAt(entry, source)(keyIndex(source, key), `${name} in package.json is not allowed. ${PLACE} Move it there.`)));
485
- const firstEntryProblem = (entry, source, deviations) => pipe(Array.head(deviations.entries), Option.map(({ index }) => problemAt(entry, source)(index, `This file is not read for upstream deviations. ${PLACE}`)), Option.toArray);
486
- const problemsIn = (entry, source) => {
487
- if (isManifest(entry.name)) return manifestProblems(entry, source);
488
- if (String$1.endsWith(NESTED_WORKSPACE)(entry.name)) return firstEntryProblem(entry, source, workspaceDeviations(source));
489
- return firstEntryProblem(entry, source, cargoDeviations(source));
490
- };
491
- const isScanned = ({ name }) => isManifest(name) || String$1.endsWith(NESTED_WORKSPACE)(name) || String$1.endsWith(NESTED_CARGO)(name) || CARGO_CONFIG.test(name);
492
- /** @internal */
493
- const checkScatteredDeviations = Effect.fn("checkScatteredDeviations")(function* checkScatteredDeviations(root) {
494
- const listed = yield* listedFiles(root);
495
- return yield* scanText(pipe(listed, Array.filter(isScanned)), problemsIn);
496
- });
497
- export { isRecord as a, isScannedText as c, presentFiles as d, scanText as f, collectNodes as i, isToolVersions as l, checkUpstreamExits as n, tomlSourceComments as o, positionOf as p, upstreamExitsMet as r, yamlSourceComments as s, checkScatteredDeviations as t, listedFiles as u };
415
+ export { workspaceDeviations as a, tomlSourceComments as c, cargoDeviations as i, yamlSourceComments as l, upstreamExitsMet as n, collectNodes as o, WORKSPACE_SECTIONS as r, isRecord as s, checkUpstreamExits as t, positionOf as u };
498
416
 
499
- //# sourceMappingURL=check-upstream-exits-DYxWDyHC.mjs.map
417
+ //# sourceMappingURL=upstream-exits-DitN-yYH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upstream-exits-DitN-yYH.mjs","names":["Str","Arr","Arr","Rec","YamlParser","Str","Arr","Str","Arr","Arr","Rec","Str","Arr"],"sources":["../src/shared/lib/text-position.ts","../src/shared/lib/config-comments.ts","../src/features/check-upstream-exits/model/deviation-entries.ts","../src/features/check-upstream-exits/model/exit-condition.ts","../src/features/check-upstream-exits/model/met-exits.ts","../src/features/check-upstream-exits/model/upstream-exits.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem } from \"./problem.ts\";\n\nconst START = 0;\nconst FIRST_COLUMN = 1;\n\nexport const positionOf =\n (source: string) =>\n (index: number): Pick<Problem, \"line\" | \"column\"> => {\n const before = pipe(source, Str.slice(START, index), Str.split(\"\\n\"));\n return {\n line: before.length,\n column: pipe(\n Arr.last(before),\n Option.match({ onNone: () => FIRST_COLUMN, onSome: (last) => last.length + FIRST_COLUMN }),\n ),\n };\n };\n","import { Array as Arr, Record as Rec, String as Str, pipe } from \"effect\";\nimport { parseTOML } from \"toml-eslint-parser\";\nimport { Parser as YamlParser } from \"yaml\";\n\nexport interface SourceComment {\n readonly index: number;\n readonly text: string;\n}\n\nexport const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === \"object\" && value !== null;\n\nconst childrenOf = (value: unknown): readonly unknown[] => {\n if (Arr.isArray(value)) {\n return value;\n }\n if (isRecord(value)) {\n return Rec.values(value);\n }\n return [];\n};\n\nexport const collectNodes =\n <Item>(isItem: (value: unknown) => value is Item) =>\n (value: unknown): readonly Item[] => {\n if (isItem(value)) {\n return [value];\n }\n return pipe(childrenOf(value), Arr.flatMap(collectNodes(isItem)));\n };\n\ninterface YamlSourceToken {\n readonly offset: number;\n readonly source: string;\n}\n\nconst isYamlComment = (value: unknown): value is YamlSourceToken =>\n isRecord(value) &&\n value[\"type\"] === \"comment\" &&\n typeof value[\"offset\"] === \"number\" &&\n typeof value[\"source\"] === \"string\";\n\nexport const yamlSourceComments = (source: string): readonly SourceComment[] =>\n pipe(\n Arr.fromIterable(new YamlParser().parse(source)),\n Arr.flatMap(collectNodes(isYamlComment)),\n Arr.map((token) => ({ index: token.offset, text: token.source })),\n );\n\nexport const tomlSourceComments = (source: string): readonly SourceComment[] =>\n pipe(\n parseTOML(source).comments,\n Arr.map(({ range: [start, end] }) => ({\n index: start,\n text: Str.slice(start, end)(source),\n })),\n );\n","import { Array as Arr, HashMap, Option, Schema, pipe } from \"effect\";\nimport { parseTOML } from \"toml-eslint-parser\";\nimport { parseDocument } from \"yaml\";\n\nimport { tomlSourceComments, yamlSourceComments } from \"#/shared/lib/config-comments.ts\";\nimport type { SourceComment } from \"#/shared/lib/config-comments.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nexport const WORKSPACE_SECTIONS = [\n \"overrides\",\n \"patchedDependencies\",\n \"packageExtensions\",\n] as const;\nconst CARGO_PATCH = \"patch\";\nconst KEY_SEPARATOR = \".\";\nconst PATCH_SOURCE_DEPTH = 2;\n\nexport type Section = (typeof WORKSPACE_SECTIONS)[number] | typeof CARGO_PATCH;\n\nexport interface DeviationEntry {\n readonly section: Section;\n readonly key: string;\n readonly index: number;\n readonly line: number;\n}\n\nexport interface LineComment extends SourceComment {\n readonly line: number;\n}\n\nexport interface Deviations {\n readonly entries: readonly DeviationEntry[];\n readonly comments: readonly LineComment[];\n}\n\nconst NONE: Deviations = { entries: [], comments: [] };\n\nconst KeyValue = Schema.Union([Schema.String, Schema.Finite]);\nconst Positions = Schema.Array(Schema.Finite);\nconst YamlKey = Schema.Struct({ value: KeyValue, range: Positions });\nconst YamlMap = Schema.Struct({ items: Schema.Array(Schema.Struct({ key: YamlKey })) });\n\nconst KeyPart = Schema.Union([\n Schema.Struct({ type: Schema.Literal(\"TOMLBare\"), name: Schema.String }),\n Schema.Struct({ type: Schema.Literal(\"TOMLQuoted\"), value: Schema.String }),\n]);\nconst Located = {\n range: Schema.Array(Schema.Finite),\n loc: Schema.Struct({ start: Schema.Struct({ line: Schema.Finite }) }),\n};\nconst TomlKeyValue = Schema.Struct({\n ...Located,\n type: Schema.Literal(\"TOMLKeyValue\"),\n key: Schema.Struct({ keys: Schema.Array(KeyPart) }),\n});\nconst TomlTable = Schema.Struct({\n ...Located,\n type: Schema.Literal(\"TOMLTable\"),\n resolvedKey: Schema.Array(Schema.Union([Schema.String, Schema.Finite])),\n body: Schema.Array(TomlKeyValue),\n});\nconst TomlNode = Schema.Union([TomlTable, TomlKeyValue]);\nconst TomlTop = Schema.Array(Schema.Struct({ body: Schema.Array(TomlNode) }));\n\ntype TomlTableType = typeof TomlTable.Type;\ntype KeyPartType = typeof KeyPart.Type;\n\nconst decodeYamlMap = Schema.decodeUnknownOption(YamlMap);\nconst decodeTomlTop = Schema.decodeUnknownOption(TomlTop);\nconst FIRST = 0;\n\nconst lineComments = (source: string, comments: readonly SourceComment[]): readonly LineComment[] =>\n pipe(\n comments,\n Arr.map((comment) => ({ ...comment, line: positionOf(source)(comment.index).line })),\n );\n\nconst startOf = (range: readonly number[]): number =>\n Option.getOrElse(Arr.get(range, FIRST), () => FIRST);\n\nconst sectionEntries =\n (source: string, sectionNode: (section: string) => unknown) =>\n (section: (typeof WORKSPACE_SECTIONS)[number]): readonly DeviationEntry[] =>\n pipe(\n decodeYamlMap(sectionNode(section)),\n Option.match({\n onNone: () => [],\n onSome: ({ items }) =>\n pipe(\n items,\n Arr.map(({ key }) => {\n const index = startOf(key.range);\n return {\n section,\n key: String(key.value),\n index,\n line: positionOf(source)(index).line,\n };\n }),\n ),\n }),\n );\n\nexport const workspaceDeviations = (source: string): Deviations => {\n const document = parseDocument(source);\n if (Arr.isReadonlyArrayNonEmpty(document.errors)) {\n return NONE;\n }\n const sectionNode = (section: string): unknown => document.get(section, true);\n return {\n entries: pipe(WORKSPACE_SECTIONS, Arr.flatMap(sectionEntries(source, sectionNode))),\n comments: lineComments(source, yamlSourceComments(source)),\n };\n};\n\nconst partName = (part: KeyPartType): string => {\n if (part.type === \"TOMLBare\") {\n return part.name;\n }\n return part.value;\n};\n\nconst patchEntries = (table: TomlTableType): readonly DeviationEntry[] => {\n const tableKey = pipe(table.resolvedKey, Arr.map(String));\n if (!Option.exists(Arr.get(tableKey, FIRST), (part) => part === CARGO_PATCH)) {\n return [];\n }\n if (tableKey.length > PATCH_SOURCE_DEPTH) {\n return [\n {\n section: CARGO_PATCH,\n key: Arr.join(tableKey, KEY_SEPARATOR),\n index: startOf(table.range),\n line: table.loc.start.line,\n },\n ];\n }\n return pipe(\n table.body,\n Arr.map((value) => ({\n section: CARGO_PATCH,\n key: Arr.join([...tableKey, ...pipe(value.key.keys, Arr.map(partName))], KEY_SEPARATOR),\n index: startOf(value.range),\n line: value.loc.start.line,\n })),\n );\n};\n\nconst isTable = (node: TomlTableType | typeof TomlKeyValue.Type): node is TomlTableType =>\n node.type === \"TOMLTable\";\n\nexport const cargoDeviations = (source: string): Deviations =>\n pipe(\n Option.liftThrowable(() => parseTOML(source).body)(),\n Option.flatMap(decodeTomlTop),\n Option.match({\n onNone: () => NONE,\n onSome: (tops) => ({\n entries: pipe(\n tops,\n Arr.flatMap(({ body }) => body),\n Arr.filter(isTable),\n Arr.flatMap(patchEntries),\n ),\n comments: lineComments(source, tomlSourceComments(source)),\n }),\n }),\n );\n\nexport const commentsByLine = (\n comments: readonly LineComment[],\n): HashMap.HashMap<number, LineComment> =>\n HashMap.fromIterable(\n pipe(\n comments,\n Arr.map((comment) => [comment.line, comment] as const),\n ),\n );\n","import { Array as Arr, Match, Option, String as Str, pipe } from \"effect\";\nimport semver from \"semver\";\n\nimport { groupOf } from \"#/shared/lib/match-groups.ts\";\n\nexport type Registry = \"npm\" | \"crate\";\nexport type Relation = \"drops\" | \"allows\" | \"requires\";\n\nexport interface Unused {\n readonly kind: \"unused\";\n}\n\nexport interface Published {\n readonly kind: \"published\";\n readonly registry: Registry;\n readonly name: string;\n readonly range: string;\n}\n\nexport interface Declares {\n readonly kind: \"declares\";\n readonly registry: Registry;\n readonly name: string;\n readonly relation: Relation;\n readonly dependency: string;\n readonly range: string;\n}\n\nexport interface Closed {\n readonly kind: \"closed\";\n readonly owner: string;\n readonly repo: string;\n readonly number: number;\n}\n\nexport type ExitCondition = Unused | Published | Declares | Closed;\n\nconst ALTERNATIVE = \" || \";\nconst UNUSED = \"unused\";\nconst ANY_RANGE = \"*\";\nconst EXIT_COMMENT = /^#?\\s*exit:\\s*(?<condition>.*?)\\s*$/u;\nconst PACKAGE = String.raw`(?:@[^\\s/@]+\\/)?[^\\s@]+`;\nconst REGISTRY_CONDITION = new RegExp(\n String.raw`^(?<registry>npm|crate):(?<name>${PACKAGE})(?:@(?<range>.+)| (?<relation>drops|allows|requires) (?<dependency>${PACKAGE})(?:@(?<dependencyRange>.+))?)$`,\n \"u\",\n);\nconst GITHUB_CONDITION = /^github:(?<owner>[\\w.-]+)\\/(?<repo>[\\w.-]+)#(?<number>[1-9]\\d*)$/u;\n\nexport const GRAMMAR =\n \"`unused`, `npm:<package>@<range>`, `npm:<package> drops <dependency>`, `npm:<package> allows <dependency>@<range>`, `npm:<package> requires <dependency>@<range>` (the same forms with `crate:`), or `github:<owner>/<repo>#<number>`, joined with ` || `\";\n\nconst isRegistry = (value: string): value is Registry => value === \"npm\" || value === \"crate\";\n\nconst isRelation = (value: string): value is Relation =>\n value === \"drops\" || value === \"allows\" || value === \"requires\";\n\nconst validRange = (range: string): Option.Option<string> =>\n Option.liftPredicate(range, (candidate) => semver.validRange(candidate) !== null);\n\ninterface Subject {\n readonly registry: Registry;\n readonly name: string;\n}\n\nconst declared = (subject: Subject, found: RegExpExecArray): Option.Option<ExitCondition> => {\n const relation = Option.filter(groupOf(\"relation\")(found), isRelation);\n const dependency = groupOf(\"dependency\")(found);\n const range = groupOf(\"dependencyRange\")(found);\n if (Option.isNone(relation) || Option.isNone(dependency)) {\n return Option.none();\n }\n const base = {\n kind: \"declares\",\n ...subject,\n relation: relation.value,\n dependency: dependency.value,\n } as const;\n if (relation.value === \"drops\") {\n return Option.match(range, {\n onNone: () => Option.some({ ...base, range: ANY_RANGE }),\n onSome: () => Option.none(),\n });\n }\n return pipe(\n range,\n Option.flatMap(validRange),\n Option.map((valid): ExitCondition => ({ ...base, range: valid })),\n );\n};\n\nconst registryCondition = (text: string): Option.Option<ExitCondition> => {\n const found = REGISTRY_CONDITION.exec(text);\n if (found === null) {\n return Option.none();\n }\n const subject = Option.all({\n registry: Option.filter(groupOf(\"registry\")(found), isRegistry),\n name: groupOf(\"name\")(found),\n });\n const range = groupOf(\"range\")(found);\n const conditionOf = (resolved: Subject): Option.Option<ExitCondition> =>\n Option.match(range, {\n onNone: () => declared(resolved, found),\n onSome: (published) =>\n Option.map(validRange(published), (valid): ExitCondition => ({\n kind: \"published\",\n ...resolved,\n range: valid,\n })),\n });\n return pipe(subject, Option.flatMap(conditionOf));\n};\n\nconst githubCondition = (text: string): Option.Option<ExitCondition> => {\n const found = GITHUB_CONDITION.exec(text);\n const issueNumber = pipe(groupOf(\"number\")(found), Option.map(Number));\n return pipe(\n Option.all({\n owner: groupOf(\"owner\")(found),\n repo: groupOf(\"repo\")(found),\n number: issueNumber,\n }),\n Option.map((issue): ExitCondition => ({ kind: \"closed\", ...issue })),\n );\n};\n\nconst alternativeOf = (text: string): Option.Option<ExitCondition> => {\n if (text === UNUSED) {\n return Option.some({ kind: \"unused\" });\n }\n return Option.orElse(registryCondition(text), () => githubCondition(text));\n};\n\nexport const parseCondition = (text: string): Option.Option<readonly ExitCondition[]> =>\n pipe(\n Str.split(text, ALTERNATIVE),\n Arr.map((alternative) => alternativeOf(Str.trim(alternative))),\n Option.all,\n );\n\nexport const exitTextOf = (comment: string): Option.Option<string> =>\n groupOf(\"condition\")(EXIT_COMMENT.exec(Str.trim(comment)));\n\nconst describeDeclares = (condition: Declares): string => {\n const subject = `${condition.registry}:${condition.name} ${condition.relation} ${condition.dependency}`;\n if (condition.relation === \"drops\") {\n return subject;\n }\n return `${subject}@${condition.range}`;\n};\n\nexport const describeCondition = (condition: ExitCondition): string =>\n Match.value(condition).pipe(\n Match.discriminatorsExhaustive(\"kind\")({\n unused: () => UNUSED,\n published: ({ registry, name, range }) => `${registry}:${name}@${range}`,\n declares: describeDeclares,\n closed: ({ owner, repo, number }) => `github:${owner}/${repo}#${String(number)}`,\n }),\n );\n\nexport const isUnused = (condition: ExitCondition): boolean => condition.kind === \"unused\";\n","import {\n Array as Arr,\n Config,\n Effect,\n HashMap,\n Match,\n Option,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpClientError } from \"effect/http\";\nimport semver from \"semver\";\n\nimport { commentsByLine } from \"./deviation-entries.ts\";\nimport type { DeviationEntry, Deviations, Section } from \"./deviation-entries.ts\";\nimport { describeCondition, exitTextOf, parseCondition } from \"./exit-condition.ts\";\nimport type { Closed, Declares, ExitCondition, Published } from \"./exit-condition.ts\";\n\nconst NPM = \"https://registry.npmjs.org/\";\nconst CRATES = \"https://crates.io/api/v1/crates/\";\nconst GITHUB = \"https://api.github.com/repos/\";\nconst USER_AGENT = \"msch-exits (https://github.com/masseater/ecosystems/tree/main/libs/msch)\";\nconst LOOKUP_CONCURRENCY = 4;\nconst RANGE_OPTIONS = { includePrerelease: true } as const;\n\nconst DECLARING_SECTIONS = [\"optionalDependencies\", \"peerDependencies\", \"dependencies\"] as const;\nconst Dependencies = Schema.Record(Schema.String, Schema.String);\nconst NpmVersion = Schema.Record(Schema.String, Schema.Unknown);\nconst decodeDependencies = Schema.decodeUnknownOption(Dependencies);\nconst NpmPackument = Schema.Struct({\n \"dist-tags\": Schema.Struct({ latest: Schema.String }),\n versions: Schema.Record(Schema.String, NpmVersion),\n});\nconst Crate = Schema.Struct({\n crate: Schema.Struct({\n max_stable_version: Schema.NullOr(Schema.String),\n newest_version: Schema.String,\n }),\n versions: Schema.Array(Schema.Struct({ num: Schema.String, yanked: Schema.Boolean })),\n});\nconst CrateDependencies = Schema.Struct({\n dependencies: Schema.Array(Schema.Struct({ crate_id: Schema.String, req: Schema.String })),\n});\nconst Issue = Schema.Struct({ state: Schema.String });\n\ntype NpmVersionType = typeof NpmVersion.Type;\ntype LookupError = HttpClientError.HttpClientError | Schema.SchemaError;\n\n/** @internal */\nexport interface Release {\n readonly versions: readonly string[];\n readonly latestDependencies: Readonly<Record<string, string>>;\n}\n\n/** @internal */\nexport interface ExitEntry {\n readonly line: number;\n readonly section: Section;\n readonly key: string;\n readonly conditions: readonly ExitCondition[];\n}\n\n/** @internal */\nexport interface MetExit {\n readonly entry: ExitEntry;\n readonly condition: string;\n readonly outcome: \"met\" | \"unchecked\";\n}\n\ninterface Lookup {\n readonly url: string;\n readonly token: Option.Option<string>;\n}\n\nconst requestOf = ({ url, token }: Lookup): HttpClientRequest.HttpClientRequest => {\n const request = HttpClientRequest.get(url).pipe(\n HttpClientRequest.setHeader(\"user-agent\", USER_AGENT),\n HttpClientRequest.acceptJson,\n );\n return Option.match(token, {\n onNone: () => request,\n onSome: (value) => HttpClientRequest.bearerToken(value)(request),\n });\n};\n\nconst fetched = (\n lookup: Lookup,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n> =>\n HttpClient.HttpClient.pipe(\n Effect.flatMap((client) => HttpClient.filterStatusOk(client).execute(requestOf(lookup))),\n );\n\nconst publicLookup = (url: string): Lookup => ({ url, token: Option.none() });\n\nconst declaredBy = (version: NpmVersionType): Readonly<Record<string, string>> =>\n pipe(\n DECLARING_SECTIONS,\n Arr.flatMap((section) =>\n pipe(\n decodeDependencies(version[section]),\n Option.map(Rec.toEntries),\n Option.getOrElse((): readonly (readonly [string, string])[] => []),\n ),\n ),\n Rec.fromEntries,\n );\n\nconst npmRelease = (name: string): Effect.Effect<Release, LookupError, HttpClient.HttpClient> =>\n fetched(publicLookup(`${NPM}${Str.replace(\"/\", \"%2f\")(name)}`)).pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(NpmPackument)),\n Effect.map(({ \"dist-tags\": tags, versions }) => ({\n versions: Rec.keys(versions),\n latestDependencies: pipe(\n Rec.get(versions, tags.latest),\n Option.map(declaredBy),\n Option.getOrElse(() => ({})),\n ),\n })),\n );\n\nconst crateRelease = Effect.fn(\"crateRelease\")(function* lookupCrate(name: string) {\n const found = yield* fetched(publicLookup(`${CRATES}${name}`)).pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(Crate)),\n );\n const latest = found.crate.max_stable_version ?? found.crate.newest_version;\n const { dependencies } = yield* fetched(\n publicLookup(`${CRATES}${name}/${latest}/dependencies`),\n ).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(CrateDependencies)));\n const release: Release = {\n versions: pipe(\n found.versions,\n Arr.filter(({ yanked }) => !yanked),\n Arr.map(({ num }) => num),\n ),\n latestDependencies: Rec.fromEntries(\n pipe(\n dependencies,\n Arr.map(({ crate_id: crateId, req }) => [crateId, req] as const),\n ),\n ),\n };\n return release;\n});\n\nconst releaseOf = (\n condition: Published | Declares,\n): Effect.Effect<Release, LookupError, HttpClient.HttpClient> => {\n if (condition.registry === \"npm\") {\n return npmRelease(condition.name);\n }\n return crateRelease(condition.name);\n};\n\nconst declaresMet =\n (release: Release) =>\n (condition: Declares): boolean => {\n const declared = Rec.get(release.latestDependencies, condition.dependency);\n if (condition.relation === \"drops\") {\n return Option.isNone(declared);\n }\n return Option.exists(declared, (range) => {\n if (semver.validRange(range) === null) {\n return false;\n }\n if (condition.relation === \"allows\") {\n return semver.intersects(range, condition.range, RANGE_OPTIONS);\n }\n return semver.subset(range, condition.range, RANGE_OPTIONS);\n });\n };\n\n/** @internal */\nexport const isMet =\n (release: Release) =>\n (condition: ExitCondition): boolean =>\n Match.value(condition).pipe(\n Match.discriminatorsExhaustive(\"kind\")({\n unused: () => false,\n closed: () => false,\n published: ({ range }) =>\n pipe(\n release.versions,\n Arr.some((version) => semver.satisfies(version, range)),\n ),\n declares: declaresMet(release),\n }),\n );\n\nconst issueClosed = Effect.fn(\"issueClosed\")(function* lookupIssue(condition: Closed) {\n const token = yield* Config.option(\n Config.String(\"GH_TOKEN\").pipe(Config.orElse(() => Config.String(\"GITHUB_TOKEN\"))),\n ).pipe(Effect.orElseSucceed(() => Option.none<string>()));\n const issue = yield* fetched({\n url: `${GITHUB}${condition.owner}/${condition.repo}/issues/${String(condition.number)}`,\n token,\n }).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Issue)));\n return issue.state === \"closed\";\n});\n\nconst conditionMet = (\n condition: ExitCondition,\n): Effect.Effect<boolean, LookupError, HttpClient.HttpClient> =>\n Match.value(condition).pipe(\n Match.discriminatorsExhaustive(\"kind\")({\n unused: () => Effect.succeed(false),\n closed: issueClosed,\n published: (published) =>\n Effect.map(releaseOf(published), (release) => isMet(release)(published)),\n declares: (declares) =>\n Effect.map(releaseOf(declares), (release) => isMet(release)(declares)),\n }),\n );\n\n/** @internal */\nexport const exitEntries = (deviations: Deviations): readonly ExitEntry[] => {\n const comments = commentsByLine(deviations.comments);\n const entryOf = ({ line, section, key }: DeviationEntry): readonly ExitEntry[] =>\n pipe(\n HashMap.get(comments, line),\n Option.flatMap(({ text }) => exitTextOf(text)),\n Option.flatMap(parseCondition),\n Option.map((conditions): ExitEntry => ({ line, section, key, conditions })),\n Option.toArray,\n );\n return pipe(deviations.entries, Arr.flatMap(entryOf));\n};\n\nconst metOf = (\n entry: ExitEntry,\n condition: ExitCondition,\n): Effect.Effect<Option.Option<MetExit>, never, HttpClient.HttpClient> => {\n const described = describeCondition(condition);\n return conditionMet(condition).pipe(\n Effect.match({\n onSuccess: (met) =>\n Option.liftPredicate({ entry, condition: described, outcome: \"met\" } as const, () => met),\n onFailure: (error) =>\n Option.some({\n entry,\n condition: `${described} (${String(error)})`,\n outcome: \"unchecked\",\n } as const),\n }),\n );\n};\n\n/** @internal */\nexport const metExits = Effect.fn(\"metExits\")(function* metExits(entries: readonly ExitEntry[]) {\n const checksOf = (entry: ExitEntry): readonly ReturnType<typeof metOf>[] =>\n pipe(\n entry.conditions,\n Arr.map((condition) => metOf(entry, condition)),\n );\n const checks = pipe(entries, Arr.flatMap(checksOf));\n const results = yield* Effect.all(checks, { concurrency: LOOKUP_CONCURRENCY });\n return Arr.getSomes(results);\n});\n","import { Array as Arr, Effect, HashMap, HashSet, Option, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nimport { cargoDeviations, commentsByLine, workspaceDeviations } from \"./deviation-entries.ts\";\nimport type { DeviationEntry, Deviations } from \"./deviation-entries.ts\";\nimport { GRAMMAR, exitTextOf, isUnused, parseCondition } from \"./exit-condition.ts\";\nimport { exitEntries, metExits } from \"./met-exits.ts\";\nimport type { ExitEntry, MetExit } from \"./met-exits.ts\";\n\nconst RULE: RuleName = \"upstream-exit\";\nconst ROOT_FILES = [\n { name: \"pnpm-workspace.yaml\", deviationsOf: workspaceDeviations },\n { name: \"Cargo.toml\", deviationsOf: cargoDeviations },\n] as const;\nconst REASON =\n \"Every deviation from an upstream package is temporary, and the comment says when to go back to the official package so that msch-exits can tell.\";\nconst STRAY =\n \"An exit condition belongs at the end of the line of an overrides, patchedDependencies, packageExtensions or [patch] entry. Move it there or delete it.\";\n\ninterface ReadFile {\n readonly file: string;\n readonly source: string;\n readonly deviations: Deviations;\n}\n\nconst problemAt =\n ({ file, source }: ReadFile) =>\n (index: number, message: string): Problem => ({\n file,\n ...positionOf(source)(index),\n rule: RULE,\n message,\n });\n\nconst messageFor = (\n entry: DeviationEntry,\n exitText: Option.Option<string>,\n): Option.Option<string> => {\n if (Option.isNone(exitText)) {\n return Option.some(\n `${entry.section} entry ${entry.key} has no exit condition. ${REASON} Add \\`# exit: <condition>\\` at the end of the line, where the condition is ${GRAMMAR}.`,\n );\n }\n const conditions = parseCondition(exitText.value);\n if (Option.isNone(conditions)) {\n return Option.some(\n `The exit condition \\`${exitText.value}\\` of ${entry.key} is not one msch-exits can check. Write ${GRAMMAR}.`,\n );\n }\n if (entry.section !== \"overrides\" && pipe(conditions.value, Arr.some(isUnused))) {\n return Option.some(\n `\\`unused\\` is checked only for overrides, by the unused-override and removable-override checks. Give ${entry.key} a condition on a release or an issue.`,\n );\n }\n return Option.none();\n};\n\nconst entryProblems = (read: ReadFile): readonly Problem[] => {\n const comments = commentsByLine(read.deviations.comments);\n return pipe(\n read.deviations.entries,\n Arr.flatMap((entry) => {\n const exitText = pipe(\n HashMap.get(comments, entry.line),\n Option.flatMap(({ text }) => exitTextOf(text)),\n );\n return pipe(\n messageFor(entry, exitText),\n Option.map((message) => problemAt(read)(entry.index, message)),\n Option.toArray,\n );\n }),\n );\n};\n\nconst strayProblems = (read: ReadFile): readonly Problem[] => {\n const entryLines = HashSet.fromIterable(\n pipe(\n read.deviations.entries,\n Arr.map(({ line }) => line),\n ),\n );\n return pipe(\n read.deviations.comments,\n Arr.filter(\n (comment) =>\n Option.isSome(exitTextOf(comment.text)) && !HashSet.has(entryLines, comment.line),\n ),\n Arr.map((comment) => problemAt(read)(comment.index, STRAY)),\n );\n};\n\nconst readRootFiles = Effect.fn(\"readRootFiles\")(function* readRootFiles(root: string) {\n const files = yield* RepositoryFiles;\n const read = yield* Effect.forEach(\n ROOT_FILES,\n ({ name, deviationsOf }) => {\n const file = files.join(root, name);\n return Effect.map(\n files.readFile(file),\n Option.map((source): ReadFile => ({ file, source, deviations: deviationsOf(source) })),\n );\n },\n { concurrency: \"unbounded\" },\n );\n return Arr.getSomes(read);\n});\n\n/** @internal */\nexport const checkUpstreamExits = Effect.fn(\"checkUpstreamExits\")(function* checkUpstreamExits(\n root: string,\n) {\n const read = yield* readRootFiles(root);\n return pipe(\n read,\n Arr.flatMap((file) => [...entryProblems(file), ...strayProblems(file)]),\n );\n});\n\n/** @internal */\nexport interface FileExit {\n readonly file: string;\n readonly met: MetExit;\n}\n\n/** @internal */\nexport const upstreamExitsMet = Effect.fn(\"upstreamExitsMet\")(function* upstreamExitsMet(\n root: string,\n) {\n const read = yield* readRootFiles(root);\n const perFile = yield* Effect.forEach(\n read,\n ({ file, deviations }) => {\n const entries: readonly ExitEntry[] = exitEntries(deviations);\n return Effect.map(\n metExits(entries),\n Arr.map((met): FileExit => ({ file, met })),\n );\n },\n { concurrency: 1 },\n );\n return Arr.flatten(perFile);\n});\n"],"mappings":";;;;;;;AAIA,MAAM,QAAQ;AACd,MAAM,eAAe;AAErB,M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B,OACC,EAAE,MAAM,iBAAiB;EACxB,MAAM,UAAgC,YAAY,UAAU;EAC5D,OAAO,OAAO,IACZ,SAAS,OAAO,GAChBA,MAAI,KAAK,SAAmB;GAAE;GAAM;EAAI,EAAE,CAC5C;CACF,GACA,EAAE,aAAa,EAAE,CACnB;CACA,OAAOA,MAAI,QAAQ,OAAO;AAC5B,CAAC"}
@@ -0,0 +1 @@
1
+ export {}
package/dist/wake.mjs ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { t as runCli } from "./runtime-LT40e_l3.mjs";
3
+ import { n as actionsOidcToken, t as BROKER } from "./credential-broker-9FMyTp1H.mjs";
4
+ import { Boolean, Console, Effect, Option, Schema } from "effect";
5
+ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
6
+ // src/features/wake-project/model/wake.ts
7
+ const Woken = Schema.Struct({ woken: Schema.Boolean });
8
+ /** @internal */
9
+ const wakeOnRedMain = Effect.fn("wake.redMain")(function* wakeOnRedMain() {
10
+ const oidc = yield* actionsOidcToken;
11
+ if (Option.isNone(oidc)) return yield* Console.log("Not running in GitHub Actions: nothing to tell the broker");
12
+ const client = yield* HttpClient.HttpClient;
13
+ const request = HttpClientRequest.post(`${BROKER}wake/main-red`).pipe(HttpClientRequest.bearerToken(oidc.value));
14
+ const response = yield* HttpClient.filterStatusOk(client).execute(request);
15
+ const { woken } = yield* HttpClientResponse.schemaBodyJson(Woken)(response);
16
+ return yield* Console.log(Boolean.match(woken, {
17
+ onTrue: () => "Asked the project to fix main",
18
+ onFalse: () => "Asked recently: skipped"
19
+ }));
20
+ });
21
+ // bin/msch-wake.ts
22
+ runCli(wakeOnRedMain());
23
+ export {};
24
+
25
+ //# sourceMappingURL=wake.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wake.mjs","names":["Bool"],"sources":["../src/features/wake-project/model/wake.ts","../bin/msch-wake.ts"],"sourcesContent":["import { Boolean as Bool, Console, Effect, Option, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\n\nimport { BROKER, actionsOidcToken } from \"#/shared/lib/credential-broker.ts\";\n\nconst Woken = Schema.Struct({ woken: Schema.Boolean });\n\n/** @internal */\nexport const wakeOnRedMain = Effect.fn(\"wake.redMain\")(function* wakeOnRedMain() {\n const oidc = yield* actionsOidcToken;\n if (Option.isNone(oidc)) {\n return yield* Console.log(\"Not running in GitHub Actions: nothing to tell the broker\");\n }\n const client = yield* HttpClient.HttpClient;\n const request = HttpClientRequest.post(`${BROKER}wake/main-red`).pipe(\n HttpClientRequest.bearerToken(oidc.value),\n );\n const response = yield* HttpClient.filterStatusOk(client).execute(request);\n const { woken } = yield* HttpClientResponse.schemaBodyJson(Woken)(response);\n return yield* Console.log(\n Bool.match(woken, {\n onTrue: () => \"Asked the project to fix main\",\n onFalse: () => \"Asked recently: skipped\",\n }),\n );\n});\n","#!/usr/bin/env node\nimport { runCli } from \"#/app/runtime.ts\";\nimport { wakeOnRedMain } from \"#/features/wake-project/index.ts\";\n\nrunCli(wakeOnRedMain());\n"],"mappings":";;;;;;AAKA,MAAM,QAAQ,OAAO,OAAO,EAAE,OAAO,OAAO,QAAQ,CAAC;;AAGrD,MAAa,gBAAgB,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,gBAAgB;CAC/E,MAAM,OAAO,OAAO;CACpB,IAAI,OAAO,OAAO,IAAI,GACpB,OAAO,OAAO,QAAQ,IAAI,2DAA2D;CAEvF,MAAM,SAAS,OAAO,WAAW;CACjC,MAAM,UAAU,kBAAkB,KAAK,GAAG,OAAO,cAAc,CAAC,CAAC,KAC/D,kBAAkB,YAAY,KAAK,KAAK,CAC1C;CACA,MAAM,WAAW,OAAO,WAAW,eAAe,MAAM,CAAC,CAAC,QAAQ,OAAO;CACzE,MAAM,EAAE,UAAU,OAAO,mBAAmB,eAAe,KAAK,CAAC,CAAC,QAAQ;CAC1E,OAAO,OAAO,QAAQ,IACpBA,QAAK,MAAM,OAAO;EAChB,cAAc;EACd,eAAe;CACjB,CAAC,CACH;AACF,CAAC;;ACrBD,OAAO,cAAc,CAAC"}
@@ -1,12 +1,74 @@
1
- import { a as publicEntriesOf, i as EntryManifestJson, n as entriesOf, t as PackEntry } from "./package-LeBO9czg.mjs";
2
- import { A as merged, D as tasksOf, M as settingsInvalid, N as usedFrom, O as testsItself, R as literalOf, S as NO_TASKS, d as deployEntries, g as prefixed, j as programOf, k as literalSettings, m as shadcnUiIn, r as readManifest, s as writeLockedClosures, t as MANIFEST_FILE, v as workspaceDirectories, z as nestedValues } from "./dependencies-DCJv7YcW.mjs";
3
- import { r as ignoredDirectories, t as collectIgnoredDirectories } from "./ignored-directories-BTMTNuAx.mjs";
1
+ import { o as workspaceDirectories, r as readManifest, t as MANIFEST_FILE } from "./dependencies-B6p7x90y.mjs";
2
+ import { A as programOf, D as testsItself, E as tasksOf, L as literalOf, M as usedFrom, O as literalSettings, R as nestedValues, _ as deployEntries, a as EntryManifestJson, b as prefixed, c as publicEntriesOf, f as depPathsOf, h as wantedLockfile, j as settingsInvalid, k as merged, n as entriesOf, t as PackEntry, u as linkedPaths, v as shadcnUiIn, x as NO_TASKS } from "./published-BNJdq0h1.mjs";
3
+ import { n as FINGERPRINT_FILE, r as LOCK_FILE, t as CLOSURE_FILE } from "./locked-closure-paths-Dtqs8uBU.mjs";
4
4
  import { n as RepositoryFiles, r as nodeRepositoryFiles } from "./repository-files-B5sRbxlz.mjs";
5
- import { Array, Effect, Option, Record, Schema, pipe } from "effect";
5
+ import { i as reachable, r as ignoredDirectories, t as collectIgnoredDirectories } from "./ignored-directories-BgUqwuc4.mjs";
6
+ import { Array, Effect, Option, Record, Schema, String, pipe } from "effect";
7
+ // src/entities/workspace/model/locked-closures.ts
8
+ const IMPORTER = "importer:";
9
+ const ROOT_IMPORTER = ".";
10
+ const usedSections = ({ dependencies, optionalDependencies }) => [dependencies, optionalDependencies];
11
+ const packageEdges = (packages) => pipe(Record.toEntries(packages), Array.map(([id, snapshot]) => [id, pipe(usedSections(snapshot), Array.flatMap(depPathsOf))]));
12
+ const closureOf = (edges) => ({ own }) => {
13
+ const packages = pipe(reachable(edges, own), Array.filter((id) => !String.startsWith(IMPORTER)(id)));
14
+ return Array.sort(packages, String.Order);
15
+ };
16
+ /** @internal */
17
+ const lockedClosures = Effect.fn("lockedClosures")(function* lockedClosures(root) {
18
+ const files = yield* RepositoryFiles;
19
+ const lockfile = yield* wantedLockfile(root);
20
+ const nodesOf = (id, sections) => [...pipe(sections, Array.flatMap(depPathsOf)), ...pipe(linkedPaths(sections), Array.map((path) => files.relative(root, files.join(root, id, path))), Array.map((linked) => `${IMPORTER}${Option.getOrElse(Option.liftPredicate(linked, String.isNonEmpty), () => ROOT_IMPORTER)}`))];
21
+ return pipe(lockfile, Option.map(({ importers, packages }) => {
22
+ const found = pipe(Record.toEntries(importers), Array.map(([id, project]) => {
23
+ const used = usedSections(project);
24
+ return {
25
+ id,
26
+ own: nodesOf(id, [...used, project.devDependencies]),
27
+ used: nodesOf(id, used)
28
+ };
29
+ }));
30
+ const edges = Record.fromEntries([...pipe(found, Array.map(({ id, used }) => [`${IMPORTER}${id}`, used])), ...packageEdges(packages ?? {})]);
31
+ return Record.fromEntries(pipe(found, Array.map((importer) => [importer.id, closureOf(edges)(importer)])));
32
+ }));
33
+ });
34
+ // src/entities/workspace/model/locked-closure-files.ts
35
+ const LINE = "\n";
36
+ const FILE_CONCURRENCY = 16;
37
+ const writeChanged = Effect.fn("writeChanged")(function* writeChanged(file, text) {
38
+ const files = yield* RepositoryFiles;
39
+ const written = yield* files.readFile(file);
40
+ if (!Option.exists(written, (found) => found === text)) yield* files.writeFile(file, text);
41
+ });
42
+ const isWritten = Effect.fn("isWritten")(function* isWritten(root, fingerprint) {
43
+ const files = yield* RepositoryFiles;
44
+ const recorded = yield* files.readFile(files.join(root, FINGERPRINT_FILE));
45
+ const [hash, ...importers] = String.split(Option.getOrElse(recorded, () => ""), LINE);
46
+ if (hash !== fingerprint) return false;
47
+ const present = yield* Effect.forEach(importers, (importer) => files.exists(files.join(root, importer, CLOSURE_FILE)), { concurrency: FILE_CONCURRENCY });
48
+ return pipe(present, Array.every(Boolean));
49
+ });
50
+ const writeAll = Effect.fn("writeAll")(function* writeAll(root, fingerprint) {
51
+ const files = yield* RepositoryFiles;
52
+ const closures = yield* lockedClosures(root);
53
+ const entries = Record.toEntries(Option.getOrElse(closures, () => ({})));
54
+ yield* Effect.forEach(entries, ([importer, closure]) => writeChanged(files.join(root, importer, CLOSURE_FILE), Array.join(closure, LINE)), {
55
+ concurrency: FILE_CONCURRENCY,
56
+ discard: true
57
+ });
58
+ const importers = pipe(entries, Array.map(([importer]) => importer));
59
+ yield* files.writeFile(files.join(root, FINGERPRINT_FILE), Array.join([fingerprint, ...importers], LINE));
60
+ });
61
+ /** @internal */
62
+ const writeLockedClosures = Effect.fn("writeLockedClosures")(function* writeLockedClosures(root) {
63
+ const files = yield* RepositoryFiles;
64
+ const fingerprint = yield* files.hashFile(files.join(root, LOCK_FILE));
65
+ if (Option.isNone(fingerprint)) return;
66
+ if (!(yield* isWritten(root, fingerprint.value))) yield* writeAll(root, fingerprint.value);
67
+ });
6
68
  // src/features/build-workspace-settings/model/dependency-allowances.ts
7
69
  const MSCH_DEV_DEPENDENCIES = ["msch", "devDependencies"];
8
70
  const MSCH_DEPENDENCIES = ["msch", "dependencies"];
9
- const Names$1 = Schema.optional(Schema.Array(Schema.String));
71
+ const Names$1 = Schema.String.pipe(Schema.Array, Schema.optional);
10
72
  const DependencySettings = Schema.Struct({
11
73
  use: Names$1,
12
74
  dependencies: Names$1
@@ -94,7 +156,7 @@ const SeverityWithOptions = Schema.mutable(Schema.TupleWithRest(Schema.Tuple([Se
94
156
  const RuleSetting = Schema.Union([Severity, SeverityWithOptions]);
95
157
  const Rules = Schema.Record(Schema.String, RuleSetting);
96
158
  const decodeRules = Schema.decodeUnknownEffect(Rules);
97
- const Names = Schema.optional(Schema.Array(Schema.String));
159
+ const Names = Schema.String.pipe(Schema.Array, Schema.optional);
98
160
  const WorkspaceOverride = Schema.Struct({
99
161
  files: Schema.Array(Schema.String),
100
162
  excludeFiles: Names,
@@ -103,7 +165,7 @@ const WorkspaceOverride = Schema.Struct({
103
165
  });
104
166
  const WorkspaceLintSettings = Schema.Struct({
105
167
  ignorePatterns: Names,
106
- overrides: Schema.optional(Schema.Array(WorkspaceOverride))
168
+ overrides: WorkspaceOverride.pipe(Schema.Array, Schema.optional)
107
169
  });
108
170
  const overrideOf = Effect.fn("overrideOf")(function* overrideOf(source, ruleSets, override) {
109
171
  const { file, directory } = source;