@r_masseater/msch 0.42.0 → 0.47.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.
Files changed (61) hide show
  1. package/README.md +10 -9
  2. package/dist/cargo-inputs.d.mts +1 -0
  3. package/dist/cargo-inputs.mjs +149 -94
  4. package/dist/cargo-inputs.mjs.map +1 -1
  5. package/dist/changed.d.mts +1 -0
  6. package/dist/changed.mjs +178 -0
  7. package/dist/changed.mjs.map +1 -0
  8. package/dist/cli-contract-BY7vwgKc.mjs +41 -0
  9. package/dist/cli-contract-BY7vwgKc.mjs.map +1 -0
  10. package/dist/cli.mjs +757 -938
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/config.d.mts +3 -1
  13. package/dist/config.mjs +19 -9
  14. package/dist/config.mjs.map +1 -1
  15. package/dist/decision-rules.d.mts +1 -1
  16. package/dist/decision-rules.mjs +1 -1
  17. package/dist/{define-lint-preset-DKJku2ZR.mjs → define-lint-preset-CxzPzVuB.mjs} +15 -24
  18. package/dist/define-lint-preset-CxzPzVuB.mjs.map +1 -0
  19. package/dist/{package-vbK0Qycn.mjs → dependencies-v59cxwTD.mjs} +186 -165
  20. package/dist/dependencies-v59cxwTD.mjs.map +1 -0
  21. package/dist/{ignored-directories-CfACwIvu.mjs → ignored-directories-thSB0IAT.mjs} +13 -6
  22. package/dist/ignored-directories-thSB0IAT.mjs.map +1 -0
  23. package/dist/{index-BwiAHe_u.d.mts → index-DL7PSp7j.d.mts} +3 -3
  24. package/dist/lint.d.mts +1 -1
  25. package/dist/lint.mjs +1 -1
  26. package/dist/locked-closure-paths-Dtqs8uBU.mjs +7 -0
  27. package/dist/locked-closure-paths-Dtqs8uBU.mjs.map +1 -0
  28. package/dist/locked-inputs.d.mts +12 -0
  29. package/dist/locked-inputs.mjs +20 -0
  30. package/dist/locked-inputs.mjs.map +1 -0
  31. package/dist/oxlint.mjs +2 -1
  32. package/dist/oxlint.mjs.map +1 -1
  33. package/dist/package-Bdv6W97F.mjs +144 -0
  34. package/dist/package-Bdv6W97F.mjs.map +1 -0
  35. package/dist/project-DeQcAglt.mjs +464 -0
  36. package/dist/project-DeQcAglt.mjs.map +1 -0
  37. package/dist/publish.mjs +413 -169
  38. package/dist/publish.mjs.map +1 -1
  39. package/dist/reachable-Cc-255L3.mjs +13 -0
  40. package/dist/reachable-Cc-255L3.mjs.map +1 -0
  41. package/dist/{repository-files-CPfBA4mf.mjs → repository-files-aXwrITdF.mjs} +3 -2
  42. package/dist/repository-files-aXwrITdF.mjs.map +1 -0
  43. package/dist/{runtime-Dc5gCUSF.mjs → runtime-GbrDfB8K.mjs} +2 -2
  44. package/dist/{runtime-Dc5gCUSF.mjs.map → runtime-GbrDfB8K.mjs.map} +1 -1
  45. package/dist/started-once-CkTooI_o.mjs +13 -0
  46. package/dist/started-once-CkTooI_o.mjs.map +1 -0
  47. package/dist/{cli-contract-DdTV5DaG.mjs → syntax-ct2fFLtv.mjs} +9 -45
  48. package/dist/syntax-ct2fFLtv.mjs.map +1 -0
  49. package/dist/workspace-settings.mjs +8 -32
  50. package/dist/workspace-settings.mjs.map +1 -1
  51. package/package.json +41 -33
  52. package/skills/msch-checks/SKILL.md +1 -1
  53. package/skills/publishing/SKILL.md +6 -4
  54. package/skills/repository-config/SKILL.md +14 -9
  55. package/skills/workspace-settings/SKILL.md +33 -3
  56. package/src/app/vite.d.ts +2 -0
  57. package/dist/cli-contract-DdTV5DaG.mjs.map +0 -1
  58. package/dist/define-lint-preset-DKJku2ZR.mjs.map +0 -1
  59. package/dist/ignored-directories-CfACwIvu.mjs.map +0 -1
  60. package/dist/package-vbK0Qycn.mjs.map +0 -1
  61. package/dist/repository-files-CPfBA4mf.mjs.map +0 -1
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/env node
2
+ import { n as ProblemsFound, t as runCli } from "./runtime-GbrDfB8K.mjs";
3
+ import { a as installedPackages, i as recordsIn, r as keepOnly, s as workspaceClosure } from "./project-DeQcAglt.mjs";
4
+ import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-aXwrITdF.mjs";
5
+ import { v as workspaceDirectories } from "./dependencies-v59cxwTD.mjs";
6
+ import { Array, Effect, Option, Order, Record, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
7
+ import { ChildProcess, ChildProcessSpawner } from "effect/process";
8
+ // src/features/run-changed/model/records.ts
9
+ const RECORDS = [
10
+ NODE_MODULES,
11
+ ".cache",
12
+ "msch",
13
+ "changed"
14
+ ];
15
+ const ARGUMENT_SEPARATOR$1 = "\0";
16
+ const recordsOf = Effect.fn("recordsOf")(function* recordsOf(root, command) {
17
+ const files = yield* RepositoryFiles;
18
+ const name = yield* files.hash(Array.join(command, ARGUMENT_SEPARATOR$1));
19
+ return yield* recordsIn(files.join(root, ...RECORDS, name));
20
+ });
21
+ // src/features/run-changed/model/units.ts
22
+ const SEPARATOR = "/";
23
+ const FIELD_SEPARATOR = "\0";
24
+ const LINE_SEPARATOR = "\n";
25
+ const EMPTY = "";
26
+ const READ_CONCURRENCY = 16;
27
+ const SHARED_CONFIG = /^(?:[^/]+\.config\.[cm]?[jt]s|tsconfig(?:\.[^/]+)?\.json|\.gitignore)$/u;
28
+ const memberOf = (names) => (file) => pipe(names, Array.findFirst((name) => String$1.startsWith(`${name}${SEPARATOR}`)(file)), Option.getOrElse(() => "."));
29
+ const entryOf = ([file, digest]) => `${file}${FIELD_SEPARATOR}${digest}`;
30
+ const digested = Effect.fn("digested")(function* digested(root, file) {
31
+ const files = yield* RepositoryFiles;
32
+ const digest = yield* files.hashFile(files.join(root, file));
33
+ return [file, Option.getOrElse(digest, () => EMPTY)];
34
+ });
35
+ const hashed = (lines) => Effect.gen(function* hashLines() {
36
+ return yield* (yield* RepositoryFiles).hash(Array.join(lines, LINE_SEPARATOR));
37
+ });
38
+ const ownedBy = (listing, name) => Option.getOrElse(Record.get(listing.owned, name), () => []);
39
+ const entriesIn = (listing, name) => pipe(ownedBy(listing, name), Array.map(entryOf));
40
+ const closureOf = Effect.fn("closureOf")(function* closureOf(root, name) {
41
+ const files = yield* RepositoryFiles;
42
+ const directories = yield* workspaceClosure(files.join(root, name));
43
+ const names = pipe(directories, Array.map((directory) => files.relative(root, directory)), Array.filter(String$1.isNonEmpty));
44
+ return Array.sort(names, Order.String);
45
+ });
46
+ const memberIn = (listing) => (name) => Effect.gen(function* readMember() {
47
+ const files = yield* RepositoryFiles;
48
+ return {
49
+ name,
50
+ digest: yield* hashed(entriesIn(listing, name)),
51
+ installed: yield* installedPackages(listing.root, files.join(listing.root, name)),
52
+ closure: yield* closureOf(listing.root, name)
53
+ };
54
+ });
55
+ const reached = (members) => (closure) => pipe(members, Array.filter(({ name }) => Array.contains(closure, name)));
56
+ const linesOf = (found) => {
57
+ const installed = pipe(found, Array.flatMap((member) => member.installed), Array.dedupe);
58
+ const digests = pipe(found, Array.map(({ name, digest }) => entryOf([name, digest])));
59
+ return [...Array.sort(installed, Order.String), ...digests];
60
+ };
61
+ const sharedKey = Effect.fn("sharedKey")(function* sharedKey(listing, members) {
62
+ const installed = yield* installedPackages(listing.root, listing.root);
63
+ const closure = yield* closureOf(listing.root, EMPTY);
64
+ const config = pipe(ownedBy(listing, "."), Array.filter(([file]) => SHARED_CONFIG.test(file)), Array.map(entryOf));
65
+ return yield* hashed([
66
+ ...installed,
67
+ ...config,
68
+ ...linesOf(reached(members)(closure))
69
+ ]);
70
+ });
71
+ const rootPaths = (listing) => pipe(ownedBy(listing, "."), Array.map(([file]) => file), Array.map((file) => {
72
+ const [top] = String$1.split(file, SEPARATOR);
73
+ if (pipe(listing.names, Array.some((name) => String$1.startsWith(`${top}${SEPARATOR}`)(name)))) return file;
74
+ return top;
75
+ }), Array.dedupe);
76
+ const rootUnit = Effect.fn("rootUnit")(function* rootUnit(listing, shared) {
77
+ const key = yield* hashed([
78
+ shared,
79
+ ".",
80
+ ...entriesIn(listing, ".")
81
+ ]);
82
+ return {
83
+ name: ".",
84
+ paths: rootPaths(listing),
85
+ key
86
+ };
87
+ });
88
+ const memberUnit = (shared, members) => (member) => hashed([
89
+ shared,
90
+ member.name,
91
+ ...linesOf(reached(members)(member.closure))
92
+ ]).pipe(Effect.map((key) => ({
93
+ name: member.name,
94
+ paths: [member.name],
95
+ key
96
+ })));
97
+ const unitsOf = Effect.fn("unitsOf")(function* unitsOf(root) {
98
+ const listed = yield* (yield* RepositoryFiles).listedFiles(root);
99
+ const names = yield* workspaceDirectories(root);
100
+ const entries = yield* Effect.forEach(listed, (file) => digested(root, file), { concurrency: READ_CONCURRENCY });
101
+ const listing = {
102
+ root,
103
+ names,
104
+ owned: Array.groupBy(entries, ([file]) => memberOf(names)(file))
105
+ };
106
+ const members = yield* Effect.forEach(names, memberIn(listing), { concurrency: READ_CONCURRENCY });
107
+ const shared = yield* sharedKey(listing, members);
108
+ const units = yield* Effect.forEach(members, memberUnit(shared, members), { concurrency: 1 });
109
+ return [yield* rootUnit(listing, shared), ...units];
110
+ });
111
+ // src/features/run-changed/model/run.ts
112
+ const SUCCESS$1 = 0;
113
+ const LIST_SEPARATOR = ", ";
114
+ const ARGUMENT_SEPARATOR = " ";
115
+ const EVERYTHING = "everything";
116
+ const report = Effect.fn("report")(function* report(text) {
117
+ const stdio = yield* Stdio.Stdio;
118
+ yield* Stream.make(`msch-changed: ${text}\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);
119
+ });
120
+ const pathsOf = (units, changed) => {
121
+ if (changed.length === units.length) return [];
122
+ return pipe(changed, Array.flatMap(({ paths }) => paths));
123
+ };
124
+ const namesOf = (units, changed) => {
125
+ if (changed.length === units.length) return EVERYTHING;
126
+ return pipe(changed, Array.map(({ name }) => name), Array.join(LIST_SEPARATOR));
127
+ };
128
+ const exitCodeOf = Effect.fn("exitCodeOf")(function* exitCodeOf(root, [command, ...args]) {
129
+ const code = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make(command, args, {
130
+ cwd: root,
131
+ extendEnv: true,
132
+ stdin: "ignore",
133
+ stdout: "inherit",
134
+ stderr: "inherit"
135
+ }));
136
+ return Number(code);
137
+ });
138
+ const passedAll = (units) => pipe(units, Array.map(({ key }) => key));
139
+ const ran = Effect.fn("ran")(function* ran(root, command, plan) {
140
+ const code = yield* exitCodeOf(root, [...command, ...pathsOf(plan.units, plan.changed)]);
141
+ yield* Effect.when(keepOnly(plan.records, passedAll(plan.units)), Effect.succeed(code === SUCCESS$1));
142
+ return code;
143
+ });
144
+ /** @internal */
145
+ const runChanged = Effect.fn("runChanged")(function* runChanged(root, command) {
146
+ const units = yield* unitsOf(root);
147
+ const records = yield* recordsOf(root, command);
148
+ const changed = pipe(units, Array.filter(({ key }) => !Array.contains(records.passed, key)));
149
+ const since = `since \`${Array.join(command, ARGUMENT_SEPARATOR)}\` last passed`;
150
+ if (!Array.isReadonlyArrayNonEmpty(changed)) {
151
+ yield* report(`nothing changed ${since}`);
152
+ return SUCCESS$1;
153
+ }
154
+ yield* report(`${String(changed.length)} of ${String(units.length)} changed ${since}: ${namesOf(units, changed)}`);
155
+ return yield* ran(root, command, {
156
+ units,
157
+ changed,
158
+ records
159
+ });
160
+ });
161
+ // bin/msch-changed.ts
162
+ const SUCCESS = 0;
163
+ const ONE_FAILURE = 1;
164
+ const USAGE = "usage: msch-changed <command> [arguments]. Runs the command with the paths of the workspaces whose inputs changed since it last passed.";
165
+ const taggedError = Schema.TaggedError;
166
+ var UsageError = class extends taggedError()("UsageError", { message: Schema.String }) {};
167
+ const changed = Effect.gen(function* changed() {
168
+ const stdio = yield* Stdio.Stdio;
169
+ const files = yield* RepositoryFiles;
170
+ const args = yield* stdio.args;
171
+ if (!Array.isReadonlyArrayNonEmpty(args)) return yield* UsageError.make({ message: USAGE });
172
+ if ((yield* runChanged(files.resolve("."), args)) !== SUCCESS) return yield* ProblemsFound.make({ count: ONE_FAILURE });
173
+ return yield* Effect.void;
174
+ });
175
+ runCli(changed);
176
+ export {};
177
+
178
+ //# sourceMappingURL=changed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changed.mjs","names":["ARGUMENT_SEPARATOR","Arr","Arr","Str","Rec","SUCCESS","Arr","Arr"],"sources":["../src/features/run-changed/model/records.ts","../src/features/run-changed/model/units.ts","../src/features/run-changed/model/run.ts","../bin/msch-changed.ts"],"sourcesContent":["import { Array as Arr, Effect } from \"effect\";\n\nimport { recordsIn } from \"#/shared/lib/pass-records.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RECORDS = [NODE_MODULES, \".cache\", \"msch\", \"changed\"] as const;\nconst ARGUMENT_SEPARATOR = \"\\0\";\n\nexport const recordsOf = Effect.fn(\"recordsOf\")(function* recordsOf(\n root: string,\n command: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const name = yield* files.hash(Arr.join(command, ARGUMENT_SEPARATOR));\n return yield* recordsIn(files.join(root, ...RECORDS, name));\n});\n","import { Array as Arr, Effect, Option, Order, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport { installedPackages, workspaceClosure } from \"#/entities/project/index.ts\";\nimport { workspaceDirectories } from \"#/entities/workspace/index.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst SEPARATOR = \"/\";\nconst FIELD_SEPARATOR = \"\\0\";\nconst LINE_SEPARATOR = \"\\n\";\nconst EMPTY = \"\";\nconst READ_CONCURRENCY = 16;\nconst SHARED_CONFIG = /^(?:[^/]+\\.config\\.[cm]?[jt]s|tsconfig(?:\\.[^/]+)?\\.json|\\.gitignore)$/u;\n\nexport const ROOT_UNIT = \".\";\n\nexport interface Unit {\n readonly name: string;\n readonly paths: readonly string[];\n readonly key: string;\n}\n\ninterface Member {\n readonly name: string;\n readonly digest: string;\n readonly installed: readonly string[];\n readonly closure: readonly string[];\n}\n\ntype Entry = readonly [file: string, digest: string];\n\ninterface Listing {\n readonly root: string;\n readonly names: readonly string[];\n readonly owned: Readonly<Record<string, readonly Entry[]>>;\n}\n\nconst memberOf =\n (names: readonly string[]) =>\n (file: string): string =>\n pipe(\n names,\n Arr.findFirst((name) => Str.startsWith(`${name}${SEPARATOR}`)(file)),\n Option.getOrElse(() => ROOT_UNIT),\n );\n\nconst entryOf = ([file, digest]: Entry): string => `${file}${FIELD_SEPARATOR}${digest}`;\n\nconst digested = Effect.fn(\"digested\")(function* digested(root: string, file: string) {\n const files = yield* RepositoryFiles;\n const digest = yield* files.hashFile(files.join(root, file));\n return [file, Option.getOrElse(digest, () => EMPTY)] as const;\n});\n\nconst hashed = (lines: readonly string[]): Effect.Effect<string, never, RepositoryFiles> =>\n Effect.gen(function* hashLines() {\n const files = yield* RepositoryFiles;\n return yield* files.hash(Arr.join(lines, LINE_SEPARATOR));\n });\n\nconst ownedBy = (listing: Listing, name: string): readonly Entry[] =>\n Option.getOrElse(Rec.get(listing.owned, name), (): readonly Entry[] => []);\n\nconst entriesIn = (listing: Listing, name: string): readonly string[] =>\n pipe(ownedBy(listing, name), Arr.map(entryOf));\n\nconst closureOf = Effect.fn(\"closureOf\")(function* closureOf(root: string, name: string) {\n const files = yield* RepositoryFiles;\n const directories = yield* workspaceClosure(files.join(root, name));\n const names = pipe(\n directories,\n Arr.map((directory) => files.relative(root, directory)),\n Arr.filter(Str.isNonEmpty),\n );\n return Arr.sort(names, Order.String);\n});\n\nconst memberIn =\n (listing: Listing) =>\n (name: string): Effect.Effect<Member, never, RepositoryFiles> =>\n Effect.gen(function* readMember() {\n const files = yield* RepositoryFiles;\n return {\n name,\n digest: yield* hashed(entriesIn(listing, name)),\n installed: yield* installedPackages(listing.root, files.join(listing.root, name)),\n closure: yield* closureOf(listing.root, name),\n };\n });\n\nconst reached =\n (members: readonly Member[]) =>\n (closure: readonly string[]): readonly Member[] =>\n pipe(\n members,\n Arr.filter(({ name }) => Arr.contains(closure, name)),\n );\n\nconst linesOf = (found: readonly Member[]): readonly string[] => {\n const installed = pipe(\n found,\n Arr.flatMap((member) => member.installed),\n Arr.dedupe,\n );\n const digests = pipe(\n found,\n Arr.map(({ name, digest }) => entryOf([name, digest])),\n );\n return [...Arr.sort(installed, Order.String), ...digests];\n};\n\nconst sharedKey = Effect.fn(\"sharedKey\")(function* sharedKey(\n listing: Listing,\n members: readonly Member[],\n) {\n const installed = yield* installedPackages(listing.root, listing.root);\n const closure = yield* closureOf(listing.root, EMPTY);\n const config = pipe(\n ownedBy(listing, ROOT_UNIT),\n Arr.filter(([file]) => SHARED_CONFIG.test(file)),\n Arr.map(entryOf),\n );\n return yield* hashed([...installed, ...config, ...linesOf(reached(members)(closure))]);\n});\n\nconst rootPaths = (listing: Listing): readonly string[] =>\n pipe(\n ownedBy(listing, ROOT_UNIT),\n Arr.map(([file]) => file),\n Arr.map((file) => {\n const [top] = Str.split(file, SEPARATOR);\n const holdsMembers = pipe(\n listing.names,\n Arr.some((name) => Str.startsWith(`${top}${SEPARATOR}`)(name)),\n );\n if (holdsMembers) {\n return file;\n }\n return top;\n }),\n Arr.dedupe,\n );\n\nconst rootUnit = Effect.fn(\"rootUnit\")(function* rootUnit(listing: Listing, shared: string) {\n const key = yield* hashed([shared, ROOT_UNIT, ...entriesIn(listing, ROOT_UNIT)]);\n return { name: ROOT_UNIT, paths: rootPaths(listing), key } satisfies Unit;\n});\n\nconst memberUnit =\n (shared: string, members: readonly Member[]) =>\n (member: Member): Effect.Effect<Unit, never, RepositoryFiles> =>\n hashed([shared, member.name, ...linesOf(reached(members)(member.closure))]).pipe(\n Effect.map((key) => ({ name: member.name, paths: [member.name], key })),\n );\n\nexport const unitsOf = Effect.fn(\"unitsOf\")(function* unitsOf(root: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.listedFiles(root);\n const names = yield* workspaceDirectories(root);\n const entries = yield* Effect.forEach(listed, (file) => digested(root, file), {\n concurrency: READ_CONCURRENCY,\n });\n const owned = Arr.groupBy(entries, ([file]) => memberOf(names)(file));\n const listing: Listing = { root, names, owned };\n const members = yield* Effect.forEach(names, memberIn(listing), {\n concurrency: READ_CONCURRENCY,\n });\n const shared = yield* sharedKey(listing, members);\n const units = yield* Effect.forEach(members, memberUnit(shared, members), { concurrency: 1 });\n return [yield* rootUnit(listing, shared), ...units];\n});\n","import { Array as Arr, Effect, Stdio, Stream, pipe } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { keepOnly } from \"#/shared/lib/pass-records.ts\";\nimport type { Records } from \"#/shared/lib/pass-records.ts\";\n\nimport { recordsOf } from \"./records.ts\";\nimport { unitsOf } from \"./units.ts\";\nimport type { Unit } from \"./units.ts\";\n\nconst SUCCESS = 0;\nconst LIST_SEPARATOR = \", \";\nconst ARGUMENT_SEPARATOR = \" \";\nconst EVERYTHING = \"everything\";\n\nconst report = Effect.fn(\"report\")(function* report(text: string) {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(`msch-changed: ${text}\\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n});\n\nconst pathsOf = (units: readonly Unit[], changed: readonly Unit[]): readonly string[] => {\n if (changed.length === units.length) {\n return [];\n }\n return pipe(\n changed,\n Arr.flatMap(({ paths }) => paths),\n );\n};\n\nconst namesOf = (units: readonly Unit[], changed: readonly Unit[]): string => {\n if (changed.length === units.length) {\n return EVERYTHING;\n }\n return pipe(\n changed,\n Arr.map(({ name }) => name),\n Arr.join(LIST_SEPARATOR),\n );\n};\n\nconst exitCodeOf = Effect.fn(\"exitCodeOf\")(function* exitCodeOf(\n root: string,\n [command, ...args]: readonly [string, ...string[]],\n) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const code = yield* spawner.exitCode(\n ChildProcess.make(command, args, {\n cwd: root,\n extendEnv: true,\n stdin: \"ignore\",\n stdout: \"inherit\",\n stderr: \"inherit\",\n }),\n );\n return Number(code);\n});\n\nconst passedAll = (units: readonly Unit[]): readonly string[] =>\n pipe(\n units,\n Arr.map(({ key }) => key),\n );\n\ninterface Plan {\n readonly units: readonly Unit[];\n readonly changed: readonly Unit[];\n readonly records: Records;\n}\n\nconst ran = Effect.fn(\"ran\")(function* ran(\n root: string,\n command: readonly [string, ...string[]],\n plan: Plan,\n) {\n const code = yield* exitCodeOf(root, [...command, ...pathsOf(plan.units, plan.changed)]);\n yield* Effect.when(\n keepOnly(plan.records, passedAll(plan.units)),\n Effect.succeed(code === SUCCESS),\n );\n return code;\n});\n\n/** @internal */\nexport const runChanged = Effect.fn(\"runChanged\")(function* runChanged(\n root: string,\n command: readonly [string, ...string[]],\n) {\n const units = yield* unitsOf(root);\n const records = yield* recordsOf(root, command);\n const changed = pipe(\n units,\n Arr.filter(({ key }) => !Arr.contains(records.passed, key)),\n );\n const since = `since \\`${Arr.join(command, ARGUMENT_SEPARATOR)}\\` last passed`;\n if (!Arr.isReadonlyArrayNonEmpty(changed)) {\n yield* report(`nothing changed ${since}`);\n return SUCCESS;\n }\n yield* report(\n `${String(changed.length)} of ${String(units.length)} changed ${since}: ${namesOf(units, changed)}`,\n );\n return yield* ran(root, command, { units, changed, records });\n});\n","#!/usr/bin/env node\nimport { Array as Arr, Effect, Schema, Stdio } from \"effect\";\n\nimport { ProblemsFound } from \"#/app/output.ts\";\nimport { runCli } from \"#/app/runtime.ts\";\nimport { runChanged } from \"#/features/run-changed/index.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst SUCCESS = 0;\nconst ONE_FAILURE = 1;\nconst USAGE =\n \"usage: msch-changed <command> [arguments]. Runs the command with the paths of the workspaces whose inputs changed since it last passed.\";\n\nconst taggedError = Schema.TaggedError;\n\nclass UsageError extends taggedError<UsageError, { readonly brand: unique symbol }>()(\n \"UsageError\",\n { message: Schema.String },\n) {}\n\nconst changed = Effect.gen(function* changed() {\n const stdio = yield* Stdio.Stdio;\n const files = yield* RepositoryFiles;\n const args = yield* stdio.args;\n if (!Arr.isReadonlyArrayNonEmpty(args)) {\n return yield* UsageError.make({ message: USAGE });\n }\n const code = yield* runChanged(files.resolve(\".\"), args);\n if (code !== SUCCESS) {\n return yield* ProblemsFound.make({ count: ONE_FAILURE });\n }\n return yield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,cACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,OAAO,IAAI,UAAU,UAAU;CAC7C,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,MAAM;CAC1B,IAAI,CAACE,MAAI,wBAAwB,IAAI,GACnC,OAAO,OAAO,WAAW,KAAK,EAAE,SAAS,MAAM,CAAC;CAGlD,KAAI,OADgB,WAAW,MAAM,QAAQ,GAAG,GAAG,IAAI,OAC1C,SACX,OAAO,OAAO,cAAc,KAAK,EAAE,OAAO,YAAY,CAAC;CAEzD,OAAO,OAAO,OAAO;AACvB,CAAC;AAED,OAAO,OAAO"}
@@ -0,0 +1,41 @@
1
+ import { d as lineOf, n as columnOf } from "./syntax-ct2fFLtv.mjs";
2
+ import { Array, Order, Schema, pipe } from "effect";
3
+ // src/shared/lib/problem.ts
4
+ const RuleNameSchema = Schema.String.check(Schema.isPattern(/^[a-z]+(?:-[a-z]+)*$/u));
5
+ const ProblemSchema = Schema.Struct({
6
+ file: Schema.String,
7
+ line: Schema.Int,
8
+ column: Schema.Int,
9
+ rule: RuleNameSchema,
10
+ message: Schema.String
11
+ });
12
+ const ProblemList = Schema.Array(ProblemSchema);
13
+ const problemAt = ({ rule, message }) => (node) => ({
14
+ file: node.getSourceFile().fileName,
15
+ line: lineOf(node),
16
+ column: columnOf(node),
17
+ rule,
18
+ message
19
+ });
20
+ const problemOrder = Order.combineAll([
21
+ Order.mapInput(Order.String, (problem) => problem.file),
22
+ Order.mapInput(Order.Number, (problem) => problem.line),
23
+ Order.mapInput(Order.Number, (problem) => problem.column),
24
+ Order.mapInput(Order.String, (problem) => problem.rule),
25
+ Order.mapInput(Order.String, (problem) => problem.message)
26
+ ]);
27
+ const problemKey = (problem) => pipe([
28
+ problem.file,
29
+ String(problem.line),
30
+ String(problem.column),
31
+ problem.rule,
32
+ problem.message
33
+ ], Array.join("\0"));
34
+ const sortProblems = (problems) => Array.sort(Array.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)), problemOrder);
35
+ const describeFinding = (problem) => `[${problem.rule}] ${problem.message}`;
36
+ const formatProblem = (relative) => (problem) => `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;
37
+ // src/shared/lib/cli-contract.ts
38
+ const JSON_FLAG = "--json";
39
+ export { problemAt as a, formatProblem as i, ProblemList as n, sortProblems as o, describeFinding as r, JSON_FLAG as t };
40
+
41
+ //# sourceMappingURL=cli-contract-BY7vwgKc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-contract-BY7vwgKc.mjs","names":["Arr"],"sources":["../src/shared/lib/problem.ts","../src/shared/lib/cli-contract.ts"],"sourcesContent":["import { Array as Arr, Order, Schema, pipe } from \"effect\";\n\nimport type { Node } from \"./compiler.ts\";\nimport { columnOf, lineOf } from \"./syntax.ts\";\n\nconst RuleNameSchema = Schema.String.check(Schema.isPattern(/^[a-z]+(?:-[a-z]+)*$/u));\n\nexport type RuleName = typeof RuleNameSchema.Type;\n\nconst ProblemSchema = Schema.Struct({\n file: Schema.String,\n line: Schema.Int,\n column: Schema.Int,\n rule: RuleNameSchema,\n message: Schema.String,\n});\n\nexport type Problem = typeof ProblemSchema.Type;\n\nexport const ProblemList = Schema.Array(ProblemSchema);\n\nexport const CANDIDATE_LIMIT = 3;\n\nexport interface Finding {\n readonly rule: RuleName;\n readonly message: string;\n}\n\nexport const problemAt =\n ({ rule, message }: Finding) =>\n (node: Node): Problem => ({\n file: node.getSourceFile().fileName,\n line: lineOf(node),\n column: columnOf(node),\n rule,\n message,\n });\n\nconst problemOrder: Order.Order<Problem> = Order.combineAll([\n Order.mapInput(Order.String, (problem: Problem) => problem.file),\n Order.mapInput(Order.Number, (problem: Problem) => problem.line),\n Order.mapInput(Order.Number, (problem: Problem) => problem.column),\n Order.mapInput(Order.String, (problem: Problem) => problem.rule),\n Order.mapInput(Order.String, (problem: Problem) => problem.message),\n]);\n\nconst problemKey = (problem: Problem): string =>\n pipe(\n [problem.file, String(problem.line), String(problem.column), problem.rule, problem.message],\n Arr.join(\"\\0\"),\n );\n\nexport const sortProblems = (problems: readonly Problem[]): readonly Problem[] =>\n Arr.sort(\n Arr.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)),\n problemOrder,\n );\n\nexport const describeFinding = (problem: Problem): string => `[${problem.rule}] ${problem.message}`;\n\nexport const formatProblem =\n (relative: (file: string) => string) =>\n (problem: Problem): string =>\n `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;\n","export const JSON_FLAG = \"--json\";\n"],"mappings":";;;AAKA,MAAM,iBAAiB,OAAO,OAAO,MAAM,OAAO,UAAU,uBAAuB,CAAC;AAIpF,MAAM,gBAAgB,OAAO,OAAO;CAClC,MAAM,OAAO;CACb,MAAM,OAAO;CACb,QAAQ,OAAO;CACf,MAAM;CACN,SAAS,OAAO;AAClB,CAAC;AAID,MAAa,cAAc,OAAO,MAAM,aAAa;AASrD,MAAa,aACV,EAAE,MAAM,eACR,UAAyB;CACxB,MAAM,KAAK,cAAc,CAAC,CAAC;CAC3B,MAAM,OAAO,IAAI;CACjB,QAAQ,SAAS,IAAI;CACrB;CACA;AACF;AAEF,MAAM,eAAqC,MAAM,WAAW;CAC1D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,IAAI;CAC/D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,IAAI;CAC/D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,MAAM;CACjE,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,IAAI;CAC/D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,OAAO;AACpE,CAAC;AAED,MAAM,cAAc,YAClB,KACE;CAAC,QAAQ;CAAM,OAAO,QAAQ,IAAI;CAAG,OAAO,QAAQ,MAAM;CAAG,QAAQ;CAAM,QAAQ;AAAO,GAC1FA,MAAI,KAAK,IA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