@kurvball/rehearse 1.10.0 → 1.11.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.
@@ -14,6 +14,7 @@ export interface Affected {
14
14
  by: 'all' | 'graph' | 'packages';
15
15
  graph: string | null;
16
16
  files: string[];
17
+ inert: string[];
17
18
  said: string | null;
18
19
  reached: Reached[];
19
20
  }
@@ -79,6 +79,11 @@ export async function affected(m, checkout, given, scenarios) {
79
79
  const files = [
80
80
  ...new Set(given.map((f) => toPosix(path.relative(checkout, path.resolve(checkout, f))))),
81
81
  ].sort();
82
+ const neverInert = new Set([
83
+ toPosix(path.relative(checkout, m.file)),
84
+ ...scenarios.map((s) => toPosix(path.relative(checkout, path.resolve(s.from === 'manifest' ? m.dir : checkout, s.file)))),
85
+ ]);
86
+ const inert = files.filter((f) => !neverInert.has(f) && matches(f, m.affected.inert));
82
87
  const pkgs = workspaceOf(checkout);
83
88
  const graph = graphCommand(m, checkout);
84
89
  let said = null;
@@ -119,7 +124,7 @@ export async function affected(m, checkout, given, scenarios) {
119
124
  why.add(`it covers ${r}${via}`);
120
125
  const p = pkgOf(r);
121
126
  if (!p) {
122
- if (!graphHolds && (!through || through === r))
127
+ if (!graphHolds && (!through || through === r) && !inert.includes(r))
123
128
  why.add(`${r} is outside every package, so it reaches every scenario`);
124
129
  return;
125
130
  }
@@ -148,15 +153,20 @@ export async function affected(m, checkout, given, scenarios) {
148
153
  reached.push({ scenario: s, reachedBy: [...why] });
149
154
  }
150
155
  const unknown = graphRead?.unknown.filter((f) => files.includes(f)) ?? [];
156
+ const howItReached = graphRead
157
+ ? unknown.length
158
+ ? `The graph doesn't hold ${unknown.join(', ')}: for ${unknown.length === 1 ? 'it' : 'those'}, Rehearse took the package and the packages that depend on it.`
159
+ : null
160
+ : [said, jsOnly].filter(Boolean).join(' ') || null;
161
+ const inertSaid = inert.length
162
+ ? `${inert.length === 1 ? `${inert[0]} is` : `${inert.length} files (${inert.join(', ')}) are`} outside every package but change no behaviour, so ${inert.length === 1 ? 'it reaches' : 'they reach'} only what covers ${inert.length === 1 ? 'it' : 'them'} or what the graph says (affected.inert).`
163
+ : null;
151
164
  return {
152
165
  by: graphRead ? 'graph' : 'packages',
153
166
  graph: graphRead ? graph : null,
154
167
  files,
155
- said: graphRead
156
- ? unknown.length
157
- ? `The graph doesn't hold ${unknown.join(', ')}: for ${unknown.length === 1 ? 'it' : 'those'}, Rehearse took the package and the packages that depend on it.`
158
- : null
159
- : [said, jsOnly].filter(Boolean).join(' ') || null,
168
+ inert,
169
+ said: [howItReached, inertSaid].filter(Boolean).join(' ') || null,
160
170
  reached,
161
171
  };
162
172
  }
@@ -55,6 +55,7 @@ export const list = {
55
55
  by: reach.by,
56
56
  graph: reach.graph,
57
57
  files: reach.files,
58
+ ...(reach.inert.length && { inert: reach.inert }),
58
59
  said: reach.said,
59
60
  scenarios: reach.reached.map((r) => row(r.scenario, r.reachedBy)),
60
61
  refused: read.refused,
@@ -125,6 +125,8 @@ export async function compare(m, o) {
125
125
  const baseCommit = commitOf(base.path);
126
126
  const files = baseCommit ? changedFiles(head.path, baseCommit) : [];
127
127
  const reach = await affected(m, head.path, files, headScenarios);
128
+ if (reach.inert.length && reach.said)
129
+ o.progress(reach.said);
128
130
  const ids = new Set(reach.reached.map((r) => r.scenario.id));
129
131
  headScenarios = headScenarios.filter((s) => ids.has(s.id));
130
132
  const baseReach = await affected(m, base.path, files, baseScenarios);
@@ -1,5 +1,5 @@
1
1
  export { fill, fillEnv } from './fill.ts';
2
2
  export { STARTER, STARTER_BLOCKS, STARTER_HEAD } from './init.ts';
3
- export { findManifest, hashOf, loadManifest, MANIFEST_FILE, manifestFrom } from './load.ts';
3
+ export { findManifest, hashOf, INERT_BY_DEFAULT, loadManifest, MANIFEST_FILE, manifestFrom } from './load.ts';
4
4
  export { KIND_BLOCK, KINDS, type Kind, type Manifest, type PathEntry, type Person, type Real, type Service, type Standin, type World, } from './types.ts';
5
5
  export { readYaml } from './yaml.ts';
@@ -1,5 +1,5 @@
1
1
  export { fill, fillEnv } from './fill.js';
2
2
  export { STARTER, STARTER_BLOCKS, STARTER_HEAD } from './init.js';
3
- export { findManifest, hashOf, loadManifest, MANIFEST_FILE, manifestFrom } from './load.js';
3
+ export { findManifest, hashOf, INERT_BY_DEFAULT, loadManifest, MANIFEST_FILE, manifestFrom } from './load.js';
4
4
  export { KIND_BLOCK, KINDS, } from './types.js';
5
5
  export { readYaml } from './yaml.js';
@@ -1,4 +1,5 @@
1
1
  import type { Manifest } from './types.ts';
2
+ export declare const INERT_BY_DEFAULT: readonly string[];
2
3
  export declare const MANIFEST_FILE = "rehearse.yaml";
3
4
  export declare const MANIFEST_VARIABLE = "REHEARSE_MANIFEST";
4
5
  export declare function findManifest(cwd: string, given: string | null, env?: NodeJS.ProcessEnv): string;
@@ -4,6 +4,19 @@ import path from 'node:path';
4
4
  import { RehearseError } from '../errors.js';
5
5
  import { validate } from '../schema.js';
6
6
  import { readYaml } from './yaml.js';
7
+ export const INERT_BY_DEFAULT = [
8
+ '.changeset/*.md',
9
+ '.github/workflows/**',
10
+ '.github/ISSUE_TEMPLATE/**',
11
+ '.github/PULL_REQUEST_TEMPLATE*',
12
+ '.github/CODEOWNERS',
13
+ '.github/dependabot.yml',
14
+ '.vscode/**',
15
+ '.idea/**',
16
+ '*.md',
17
+ 'LICENSE',
18
+ 'LICENSE.*',
19
+ ];
7
20
  export const MANIFEST_FILE = 'rehearse.yaml';
8
21
  export const MANIFEST_VARIABLE = 'REHEARSE_MANIFEST';
9
22
  const isFile = (file) => {
@@ -213,7 +226,7 @@ export function manifestFrom(text, file) {
213
226
  values: raw.setAside?.values ?? [],
214
227
  keep: raw.setAside?.keep ?? [],
215
228
  },
216
- affected: { graph: raw.affected?.graph ?? null },
229
+ affected: { graph: raw.affected?.graph ?? null, inert: raw.affected?.inert ?? [...INERT_BY_DEFAULT] },
217
230
  budget: { services: raw.budget?.services ?? 1, checkouts: raw.budget?.checkouts ?? 3 },
218
231
  lineOf: (at, key) => read.lineOf(at, key),
219
232
  };
@@ -40,6 +40,7 @@ export interface RawManifest {
40
40
  setAside?: SetAsideRules;
41
41
  affected?: {
42
42
  graph?: string;
43
+ inert?: string[];
43
44
  };
44
45
  budget?: {
45
46
  services?: number;
@@ -246,6 +247,7 @@ export interface Manifest {
246
247
  setAside: Required<SetAsideRules>;
247
248
  affected: {
248
249
  graph: string | null;
250
+ inert: string[];
249
251
  };
250
252
  budget: {
251
253
  services: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kurvball/rehearse",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Rehearse a change before it ships: bring the product up, sign in as named people, start from named worlds, and compare any scenario on the base and on the head.",
5
5
  "homepage": "https://rehearse.kurvball.ca/",
6
6
  "repository": {
@@ -21,6 +21,13 @@
21
21
  "type": "string"
22
22
  }
23
23
  },
24
+ "inert": {
25
+ "description": "With --affected, the touched files outside every package that change no behaviour (affected.inert in rehearse.yaml), such as a changeset: they don't reach every scenario. Left out when there are none.",
26
+ "type": "array",
27
+ "items": {
28
+ "type": "string"
29
+ }
30
+ },
24
31
  "said": {
25
32
  "description": "Anything the reader should know, such as why Ashlar wasn't used.",
26
33
  "type": ["string", "null"]
@@ -106,6 +106,11 @@
106
106
  "graph": {
107
107
  "description": "A command that prints the dependents of the files appended to it, as schema/v1/dependents.schema.json says. By default, Ashlar's when Ashlar is present.",
108
108
  "type": "string"
109
+ },
110
+ "inert": {
111
+ "description": "Globs over files outside every package that change no behaviour, such as changesets and CI workflows: they don't reach every scenario, but still reach what covers them, what the import graph says, and their own package. The manifest and scenario files are never inert. By default .changeset/*.md, .github/workflows/**, .github/ISSUE_TEMPLATE/**, .github/PULL_REQUEST_TEMPLATE*, .github/CODEOWNERS, .github/dependabot.yml, .vscode/**, .idea/**, *.md at the root, LICENSE and LICENSE.*; [] makes every file count",
112
+ "type": "array",
113
+ "items": { "type": "string" }
109
114
  }
110
115
  },
111
116
  "additionalProperties": false