@kurvball/rehearse 1.9.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.
- package/README.md +3 -2
- package/dist/affected/affected.d.ts +1 -0
- package/dist/affected/affected.js +16 -6
- package/dist/commands/init.js +52 -7
- package/dist/commands/list.js +1 -0
- package/dist/compare/compare.js +2 -0
- package/dist/detect/detect.d.ts +6 -0
- package/dist/detect/detect.js +48 -0
- package/dist/detect/finding.d.ts +18 -0
- package/dist/detect/finding.js +4 -0
- package/dist/detect/globs.d.ts +10 -0
- package/dist/detect/globs.js +43 -0
- package/dist/detect/index.d.ts +2 -0
- package/dist/detect/index.js +2 -0
- package/dist/detect/lockfiles.d.ts +15 -0
- package/dist/detect/lockfiles.js +64 -0
- package/dist/detect/paths.d.ts +5 -0
- package/dist/detect/paths.js +39 -0
- package/dist/detect/pieces.d.ts +14 -0
- package/dist/detect/pieces.js +119 -0
- package/dist/detect/prepare.d.ts +14 -0
- package/dist/detect/prepare.js +78 -0
- package/dist/detect/repository.d.ts +33 -0
- package/dist/detect/repository.js +166 -0
- package/dist/detect/scenarios.d.ts +26 -0
- package/dist/detect/scenarios.js +170 -0
- package/dist/detect/scripts.d.ts +46 -0
- package/dist/detect/scripts.js +233 -0
- package/dist/detect/services.d.ts +16 -0
- package/dist/detect/services.js +171 -0
- package/dist/detect/write.d.ts +18 -0
- package/dist/detect/write.js +115 -0
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.js +2 -2
- package/dist/manifest/init.d.ts +47 -1
- package/dist/manifest/init.js +19 -16
- package/dist/manifest/load.d.ts +1 -0
- package/dist/manifest/load.js +14 -1
- package/dist/manifest/types.d.ts +2 -0
- package/dist/scenarios/glob.d.ts +1 -0
- package/dist/scenarios/glob.js +10 -3
- package/dist/scenarios/index.d.ts +1 -1
- package/dist/scenarios/index.js +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/schema/v1/init.schema.json +69 -1
- package/schema/v1/list.schema.json +7 -0
- package/schema/v1/manifest.schema.json +5 -0
- package/schema/v1/samples/init.json +46 -1
- package/skill/rehearse/SKILL.md +5 -0
package/dist/manifest/init.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const STARTER_HEAD = `# rehearse.yaml: what this repository has, so a change can be rehearsed before it ships.
|
|
2
2
|
# Every block is optional. Delete what you don't have. Reference: the docs' rehearse.yaml page.
|
|
3
3
|
version: 1
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
`;
|
|
5
|
+
export const STARTER_BLOCKS = {
|
|
6
|
+
base: `# The branch production runs. Comparisons use it as the base.
|
|
6
7
|
base: main
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
`,
|
|
9
|
+
prepare: `# Run once in a fresh checkout of a base commit, before anything else.
|
|
9
10
|
# prepare: pnpm install --frozen-lockfile --offline
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
`,
|
|
12
|
+
services: `# What can come up. {{port}} is filled with the port; port: auto picks a free one.
|
|
12
13
|
services:
|
|
13
14
|
web:
|
|
14
15
|
up: pnpm dev --port {{port}}
|
|
15
16
|
port: auto
|
|
16
17
|
ready: http://127.0.0.1:{{port}}/
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
`,
|
|
19
|
+
people: `# Who you can sign in as. A sign-in command prints {"people": {"name": "token"}}.
|
|
19
20
|
# signIn: node scripts/people.mjs
|
|
20
21
|
people:
|
|
21
22
|
owner:
|
|
22
23
|
describe: The organisation's owner
|
|
23
24
|
default: true
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
`,
|
|
26
|
+
worlds: `# Named starting states. A world extends another and adds to it.
|
|
26
27
|
worlds:
|
|
27
28
|
empty:
|
|
28
29
|
describe: Nothing but the schema
|
|
@@ -30,18 +31,20 @@ worlds:
|
|
|
30
31
|
# one-org:
|
|
31
32
|
# extends: empty
|
|
32
33
|
# add: node scripts/seed.mjs one-org --url {{web_url}}
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
`,
|
|
35
|
+
standins: `# Fakes for what can't run locally, named in every result.
|
|
35
36
|
# standins:
|
|
36
37
|
# ai:
|
|
37
38
|
# replaces: The model provider
|
|
38
39
|
# by: test/fixtures/ai-fake.ts
|
|
39
40
|
# env: { AI_PROVIDER: fake }
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
`,
|
|
42
|
+
scenarios: `# Where the scenarios are. A path starting with ./ is read beside this file; any other, from each checkout.
|
|
42
43
|
scenarios:
|
|
43
44
|
pieces: ['src/**/*.stories.tsx']
|
|
44
45
|
flows: ['**/*.flow.yaml']
|
|
45
46
|
calls: ['**/*.hurl']
|
|
46
47
|
files: ['**/*.rehearse.yaml']
|
|
47
|
-
|
|
48
|
+
`,
|
|
49
|
+
};
|
|
50
|
+
export const STARTER = [STARTER_HEAD, ...Object.values(STARTER_BLOCKS)].join('\n');
|
package/dist/manifest/load.d.ts
CHANGED
|
@@ -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;
|
package/dist/manifest/load.js
CHANGED
|
@@ -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
|
};
|
package/dist/manifest/types.d.ts
CHANGED
|
@@ -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/dist/scenarios/glob.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const NEVER_WALKED: Set<string>;
|
|
2
|
+
export declare const escapeGlob: (text: string) => string;
|
|
2
3
|
export declare function globToRegExp(glob: string): RegExp;
|
|
3
4
|
export declare function globRoot(glob: string): string;
|
|
4
5
|
export declare const toPosix: (p: string) => string;
|
package/dist/scenarios/glob.js
CHANGED
|
@@ -16,12 +16,19 @@ export const NEVER_WALKED = new Set([
|
|
|
16
16
|
'.venv',
|
|
17
17
|
]);
|
|
18
18
|
const escape = (c) => c.replace(/[.+^$()|\\]/g, '\\$&');
|
|
19
|
+
const literal = (c) => c.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
20
|
+
export const escapeGlob = (text) => text.replace(/[*?[\]{}\\]/g, '\\$&');
|
|
19
21
|
export function globToRegExp(glob) {
|
|
20
22
|
let out = '';
|
|
21
23
|
let i = 0;
|
|
22
24
|
let braces = 0;
|
|
23
25
|
while (i < glob.length) {
|
|
24
26
|
const c = glob[i];
|
|
27
|
+
if (c === '\\' && i + 1 < glob.length) {
|
|
28
|
+
out += literal(glob[i + 1]);
|
|
29
|
+
i += 2;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
25
32
|
if (c === '*') {
|
|
26
33
|
if (glob[i + 1] === '*') {
|
|
27
34
|
const slashAfter = glob[i + 2] === '/';
|
|
@@ -59,15 +66,15 @@ export function globToRegExp(glob) {
|
|
|
59
66
|
out += escape(c);
|
|
60
67
|
i += 1;
|
|
61
68
|
}
|
|
62
|
-
return new RegExp(`^${out}
|
|
69
|
+
return new RegExp(`^${out}$`, 's');
|
|
63
70
|
}
|
|
64
71
|
export function globRoot(glob) {
|
|
65
72
|
const parts = glob.split('/');
|
|
66
73
|
const fixed = [];
|
|
67
74
|
for (const part of parts.slice(0, -1)) {
|
|
68
|
-
if (/[*?{[]/.test(part))
|
|
75
|
+
if (/[*?{[]/.test(part.replace(/\\[\s\S]/g, '')))
|
|
69
76
|
break;
|
|
70
|
-
fixed.push(part);
|
|
77
|
+
fixed.push(part.replace(/\\([\s\S])/g, '$1'));
|
|
71
78
|
}
|
|
72
79
|
return fixed.join('/');
|
|
73
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { packageDirOf, packageNameOf } from './area.ts';
|
|
2
|
-
export { findFiles, globRoot, globToRegExp, matches, toPosix } from './glob.ts';
|
|
2
|
+
export { escapeGlob, findFiles, globRoot, globToRegExp, matches, NEVER_WALKED, toPosix } from './glob.ts';
|
|
3
3
|
export { readScenarios, registerReader } from './read.ts';
|
|
4
4
|
export { refOf, type Refused, type Scenario, type ScenarioRef } from './scenario.ts';
|
package/dist/scenarios/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { packageDirOf, packageNameOf } from './area.js';
|
|
2
|
-
export { findFiles, globRoot, globToRegExp, matches, toPosix } from './glob.js';
|
|
2
|
+
export { escapeGlob, findFiles, globRoot, globToRegExp, matches, NEVER_WALKED, toPosix } from './glob.js';
|
|
3
3
|
export { readScenarios, registerReader } from './read.js';
|
|
4
4
|
export { refOf } from './scenario.js';
|
package/llms.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Commands
|
|
6
6
|
|
|
7
|
-
- `rehearse init`: writes a starter rehearse.yaml, every block commented.
|
|
7
|
+
- `rehearse init [--detect] [--force] [--json]`: writes a starter rehearse.yaml, every block commented. With --detect it fills in what the repository has (base from origin/HEAD, prepare from the lockfile, a service per app whose dev script runs Vite, Next, Astro or a Node server reading PORT, and globs for stories, flows, .hurl and *.rehearse.yaml), each block commented with what it was detected from; --json adds `detected` {base, findings: [{kind, name?, from, count?, written, why, next?}], next} (schema init), naming what it found but couldn't write (OpenAPI, Playwright, a dev server it can't give a port). It writes only rehearse.yaml.
|
|
8
8
|
- `rehearse check [--json]`: reads the manifest and every scenario file; says what it can't read and where (schema check).
|
|
9
9
|
- `rehearse services | people | worlds [--json]`: what can come up; who you can sign in as (people: the sign-in shape {name: {token, …}}, everyone described in about; tokens only with --json); the named starting states.
|
|
10
10
|
- `rehearse list [--affected <file>… | --since <ref>] [--json]`: the scenarios, or those a change reaches, each with reachedBy (schema list).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurvball/rehearse",
|
|
3
|
-
"version": "1.
|
|
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": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://rehearse.kurvball.ca/schema/v1/init.schema.json",
|
|
4
4
|
"title": "Rehearse v1: rehearse init --json",
|
|
5
|
-
"description": "Where the starter manifest was written.",
|
|
5
|
+
"description": "Where the starter manifest was written, and with --detect, what it found in the repository.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"required": ["v", "file", "replaced"],
|
|
8
8
|
"properties": {
|
|
@@ -15,6 +15,74 @@
|
|
|
15
15
|
"replaced": {
|
|
16
16
|
"description": "Whether it replaced a manifest (--force).",
|
|
17
17
|
"type": "boolean"
|
|
18
|
+
},
|
|
19
|
+
"detected": {
|
|
20
|
+
"description": "With --detect: what it found, and whether each finding is in the manifest.",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"required": ["base", "findings", "next"],
|
|
23
|
+
"properties": {
|
|
24
|
+
"base": {
|
|
25
|
+
"description": "The base branch it wrote: the repository's default branch, or main when it found none.",
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"findings": {
|
|
29
|
+
"description": "Each thing it found, written or not, in the order of the manifest's blocks.",
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"required": ["kind", "from", "written", "why"],
|
|
34
|
+
"properties": {
|
|
35
|
+
"kind": {
|
|
36
|
+
"description": "What it found.",
|
|
37
|
+
"type": "string",
|
|
38
|
+
"examples": [
|
|
39
|
+
"base",
|
|
40
|
+
"prepare",
|
|
41
|
+
"build",
|
|
42
|
+
"service",
|
|
43
|
+
"pieces",
|
|
44
|
+
"flows",
|
|
45
|
+
"calls",
|
|
46
|
+
"files",
|
|
47
|
+
"openapi",
|
|
48
|
+
"playwright",
|
|
49
|
+
"gitignore"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"name": {
|
|
53
|
+
"description": "The service's name in the manifest, for a service it wrote.",
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"from": {
|
|
57
|
+
"description": "Where it found it, relative to the manifest's folder: a file, a glob, or a git ref.",
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"count": {
|
|
61
|
+
"description": "How many scenario files the glob holds.",
|
|
62
|
+
"type": "integer",
|
|
63
|
+
"minimum": 0
|
|
64
|
+
},
|
|
65
|
+
"written": {
|
|
66
|
+
"description": "Whether it is in the manifest.",
|
|
67
|
+
"type": "boolean"
|
|
68
|
+
},
|
|
69
|
+
"why": {
|
|
70
|
+
"description": "What it wrote, or why it didn't, in one line.",
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"next": {
|
|
74
|
+
"description": "What to do next, when something is left to do.",
|
|
75
|
+
"type": "string"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"next": {
|
|
81
|
+
"description": "The commands to run next: check, list, then compare with the base.",
|
|
82
|
+
"type": "array",
|
|
83
|
+
"items": { "type": "string" }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
18
86
|
}
|
|
19
87
|
}
|
|
20
88
|
}
|
|
@@ -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
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"v": 1,
|
|
3
|
+
"file": "/work/acme/rehearse.yaml",
|
|
4
|
+
"replaced": false,
|
|
5
|
+
"detected": {
|
|
6
|
+
"base": "main",
|
|
7
|
+
"findings": [
|
|
8
|
+
{ "kind": "base", "from": "origin/HEAD", "written": true, "why": "main, the default branch" },
|
|
9
|
+
{
|
|
10
|
+
"kind": "prepare",
|
|
11
|
+
"from": "pnpm-lock.yaml",
|
|
12
|
+
"written": true,
|
|
13
|
+
"why": "pnpm install --frozen-lockfile --prefer-offline"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"kind": "service",
|
|
17
|
+
"name": "web",
|
|
18
|
+
"from": "apps/web/package.json",
|
|
19
|
+
"written": true,
|
|
20
|
+
"why": "Vite's dev server, on a free port"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"kind": "service",
|
|
24
|
+
"name": "api",
|
|
25
|
+
"from": "apps/api/package.json",
|
|
26
|
+
"written": true,
|
|
27
|
+
"why": "a Node server that reads PORT, on a free port"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"kind": "calls",
|
|
31
|
+
"from": "apps/api/**/*.hurl",
|
|
32
|
+
"count": 4,
|
|
33
|
+
"written": true,
|
|
34
|
+
"why": "4 .hurl files, sent to api"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"kind": "openapi",
|
|
38
|
+
"from": "apps/api/openapi.yaml",
|
|
39
|
+
"written": false,
|
|
40
|
+
"why": "Rehearse compares calls written in Hurl, and doesn't read an OpenAPI description.",
|
|
41
|
+
"next": "Write a .hurl file beside the handlers, one call for each answer that matters: https://rehearse.kurvball.ca/guides/calls/"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"next": ["rehearse check", "rehearse list", "rehearse compare --base main"]
|
|
45
|
+
}
|
|
46
|
+
}
|
package/skill/rehearse/SKILL.md
CHANGED
|
@@ -42,6 +42,11 @@ A scenario's id is its file, then `#` and its name when the file holds more than
|
|
|
42
42
|
`apps/api/members.hurl#A member isn't told the directory exists`, `src/Badge.stories.tsx#Primary`,
|
|
43
43
|
`flows/sign-in.flow.yaml`.
|
|
44
44
|
|
|
45
|
+
No `rehearse.yaml` yet? `rehearse init --detect --json` writes one from what the repository has: the base branch,
|
|
46
|
+
`prepare`, a service per app's dev server, and globs for the scenarios it finds. Read `detected.findings`: each one
|
|
47
|
+
`written: false` says why and what to do `next`. It never writes people or worlds; ask the person before you invent
|
|
48
|
+
them. Then run `rehearse check --json`.
|
|
49
|
+
|
|
45
50
|
## 2. Find what your change reaches
|
|
46
51
|
|
|
47
52
|
```bash
|