@trops/dash-check 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +355 -2
- package/cli/bin.js +12 -0
- package/cli/index.d.ts +7 -0
- package/cli/index.js +566 -0
- package/examples/changes-match-plan.bad.json +4 -0
- package/examples/changes-match-plan.check.js +18 -0
- package/examples/changes-match-plan.sample.json +4 -0
- package/examples/commits-scoped.bad.json +5 -0
- package/examples/commits-scoped.check.json +6 -0
- package/examples/commits-scoped.sample.json +5 -0
- package/examples/every-acceptance-has-a-test.bad.json +3 -0
- package/examples/every-acceptance-has-a-test.check.js +19 -0
- package/examples/every-acceptance-has-a-test.sample.json +3 -0
- package/examples/helpers/changelog.js +23 -0
- package/examples/jira-comment-from-job.bad.json +5 -0
- package/examples/jira-comment-from-job.check.js +10 -0
- package/examples/jira-comment-from-job.sample.json +5 -0
- package/examples/lockfile-explained.bad.json +11 -0
- package/examples/lockfile-explained.check.json +6 -0
- package/examples/lockfile-explained.sample.json +11 -0
- package/examples/max-growth.bad.json +8 -0
- package/examples/max-growth.check.json +6 -0
- package/examples/max-growth.sample.json +8 -0
- package/examples/merge-outcome.bad.json +4 -0
- package/examples/merge-outcome.check.js +9 -0
- package/examples/merge-outcome.sample.json +4 -0
- package/examples/new-tests-are-run.bad.json +4 -0
- package/examples/new-tests-are-run.check.json +7 -0
- package/examples/new-tests-are-run.sample.json +4 -0
- package/examples/no-new-debt.bad.json +8 -0
- package/examples/no-new-debt.check.json +14 -0
- package/examples/no-new-debt.sample.json +8 -0
- package/examples/on-branch.bad.json +6 -0
- package/examples/on-branch.check.js +12 -0
- package/examples/on-branch.sample.json +6 -0
- package/examples/plan-complete.bad.json +5 -0
- package/examples/plan-complete.check.js +14 -0
- package/examples/plan-complete.sample.json +5 -0
- package/examples/plan-scope.bad.json +4 -0
- package/examples/plan-scope.check.json +6 -0
- package/examples/plan-scope.sample.json +4 -0
- package/examples/pr-ci.bad.json +4 -0
- package/examples/pr-ci.check.js +12 -0
- package/examples/pr-ci.sample.json +4 -0
- package/examples/ready-for-review.bad.json +6 -0
- package/examples/ready-for-review.check.json +12 -0
- package/examples/ready-for-review.sample.json +6 -0
- package/examples/setup.bad.json +6 -0
- package/examples/setup.check.js +8 -0
- package/examples/setup.sample.json +6 -0
- package/examples/source-has-tests.bad.json +4 -0
- package/examples/source-has-tests.check.json +6 -0
- package/examples/source-has-tests.sample.json +4 -0
- package/examples/test-script-is-real.bad.json +6 -0
- package/examples/test-script-is-real.check.json +6 -0
- package/examples/test-script-is-real.sample.json +6 -0
- package/examples/ticket-has-acceptance.bad.json +4 -0
- package/examples/ticket-has-acceptance.check.js +10 -0
- package/examples/ticket-has-acceptance.sample.json +4 -0
- package/examples/validate-leaves-tree-clean.bad.json +6 -0
- package/examples/validate-leaves-tree-clean.check.json +7 -0
- package/examples/validate-leaves-tree-clean.sample.json +6 -0
- package/examples/validate.bad.json +6 -0
- package/examples/validate.check.js +14 -0
- package/examples/validate.sample.json +6 -0
- package/examples/work-committed.bad.json +13 -0
- package/examples/work-committed.check.js +13 -0
- package/examples/work-committed.sample.json +5 -0
- package/examples/workspace-cleaned.bad.json +4 -0
- package/examples/workspace-cleaned.check.js +7 -0
- package/examples/workspace-cleaned.sample.json +4 -0
- package/helpers/commands.js +62 -0
- package/helpers/files.js +124 -0
- package/helpers/git.js +379 -0
- package/helpers/github.js +77 -0
- package/helpers/handoff.js +80 -0
- package/helpers/index.d.ts +103 -0
- package/helpers/index.js +36 -0
- package/helpers/node.js +296 -0
- package/helpers/plan.js +55 -0
- package/helpers/tracker.js +60 -0
- package/index.d.ts +347 -0
- package/index.js +86 -0
- package/lib/adapters/fs.js +85 -0
- package/lib/adapters/git.js +163 -0
- package/lib/adapters/github.js +151 -0
- package/lib/adapters/run.js +76 -0
- package/lib/adapters/tool.js +64 -0
- package/lib/context.js +102 -0
- package/lib/discover.js +102 -0
- package/lib/expect.js +238 -0
- package/lib/glob.js +89 -0
- package/lib/handoff.js +68 -0
- package/lib/helper.js +236 -0
- package/lib/register.js +35 -0
- package/lib/runner.js +214 -0
- package/lib/scope.js +107 -0
- package/lib/util.js +122 -0
- package/lib/values.js +138 -0
- package/package.json +59 -4
- package/recipe/index.d.ts +70 -0
- package/recipe/index.js +381 -0
- package/recipe/schema.json +55 -0
package/helpers/files.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files helpers: what's in the workspace. Built only from Layer 0 (ctx.fs).
|
|
3
|
+
*/
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const { defineHelper, expect, fail, note, matchGlob } = require("..");
|
|
7
|
+
const { baseRef } = require("./git");
|
|
8
|
+
|
|
9
|
+
const exist = defineHelper({
|
|
10
|
+
id: "files.exist",
|
|
11
|
+
group: "Files",
|
|
12
|
+
label: "Files exist",
|
|
13
|
+
description: "Paths in the workspace",
|
|
14
|
+
sentence: "{paths} exist",
|
|
15
|
+
params: { paths: { type: "list", label: "Paths", required: true } },
|
|
16
|
+
reads: ["fs"],
|
|
17
|
+
async run(ctx, { paths }) {
|
|
18
|
+
for (const p of paths) expect(await ctx.fs.exists(p), p).toBe(true, `${p} isn't there: add it`);
|
|
19
|
+
note(`${paths.join(", ")} exist`);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const contain = defineHelper({
|
|
24
|
+
id: "files.contain",
|
|
25
|
+
group: "Files",
|
|
26
|
+
label: "File contains text",
|
|
27
|
+
description: "A file has some text in it",
|
|
28
|
+
sentence: "{path} contains {text}",
|
|
29
|
+
params: {
|
|
30
|
+
path: { type: "path", label: "File", required: true },
|
|
31
|
+
text: { type: "text", label: "Text", required: true },
|
|
32
|
+
},
|
|
33
|
+
reads: ["fs"],
|
|
34
|
+
async run(ctx, { path, text }) {
|
|
35
|
+
if (!(await ctx.fs.exists(path))) {
|
|
36
|
+
fail(`${path} isn't there: add it`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const body = await ctx.fs.read(path);
|
|
40
|
+
if (!body.includes(text)) fail(`${path} doesn't contain ${JSON.stringify(text)}: add it`);
|
|
41
|
+
else note(`${path} contains it`);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const noneMatch = defineHelper({
|
|
46
|
+
id: "files.noneMatch",
|
|
47
|
+
group: "Files",
|
|
48
|
+
label: "No file matches a pattern",
|
|
49
|
+
description: "e.g. no console.log in src",
|
|
50
|
+
sentence: "in {glob} no match for {pattern}",
|
|
51
|
+
params: {
|
|
52
|
+
glob: { type: "glob", label: "Files", required: true, placeholder: "src/**/*.js" },
|
|
53
|
+
pattern: { type: "regex", label: "Pattern", required: true, placeholder: "console\\.log" },
|
|
54
|
+
},
|
|
55
|
+
reads: ["fs"],
|
|
56
|
+
async run(ctx, { glob, pattern }) {
|
|
57
|
+
const files = await ctx.fs.list(glob);
|
|
58
|
+
const hits = [];
|
|
59
|
+
for (const f of files) {
|
|
60
|
+
const lines = (await ctx.fs.read(f)).split(/\r?\n/);
|
|
61
|
+
lines.forEach((line, i) => {
|
|
62
|
+
pattern.lastIndex = 0;
|
|
63
|
+
if (pattern.test(line)) hits.push(`${f}:${i + 1}`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (hits.length) {
|
|
67
|
+
fail(`${glob} has ${hits.length} match${hits.length === 1 ? "" : "es"} for /${pattern.source}/: remove them`, {
|
|
68
|
+
at: `${hits.slice(0, 10).join(", ")}${hits.length > 10 ? `, and ${hits.length - 10} more` : ""}`,
|
|
69
|
+
received: hits,
|
|
70
|
+
});
|
|
71
|
+
} else note(`No match in ${files.length} file${files.length === 1 ? "" : "s"}`);
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/** Lines in a text ("a\nb\n" is 2), or null for binary. */
|
|
76
|
+
const lineCount = (text) => {
|
|
77
|
+
if (text === null || text === undefined) return null;
|
|
78
|
+
const t = String(text);
|
|
79
|
+
if (t.includes("\0")) return null;
|
|
80
|
+
if (!t) return 0;
|
|
81
|
+
return t.split(/\r?\n/).length - (/\r?\n$/.test(t) ? 1 : 0);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const maxGrowth = defineHelper({
|
|
85
|
+
id: "files.maxGrowth",
|
|
86
|
+
group: "Files",
|
|
87
|
+
label: "No file grows too big",
|
|
88
|
+
description: "A changed file stays under a size, and a big file doesn't grow much",
|
|
89
|
+
sentence: "no changed {glob} file since {base} grows past {maxLines} lines, or by more than {maxAdded} when already past",
|
|
90
|
+
params: {
|
|
91
|
+
glob: { type: "list", label: "Files", default: ["**/*.{js,jsx,ts,tsx,mjs,cjs}"] },
|
|
92
|
+
maxLines: { type: "number", label: "Most lines", default: 800 },
|
|
93
|
+
maxAdded: { type: "number", label: "Most added to a big file", default: 50 },
|
|
94
|
+
exempt: { type: "list", label: "Exempt", description: "Files that may grow, e.g. generated ones" },
|
|
95
|
+
base: { type: "text", label: "Base branch", default: "{repo.baseBranch}", description: "Empty: the repo's default branch" },
|
|
96
|
+
},
|
|
97
|
+
reads: ["git", "fs"],
|
|
98
|
+
async run(ctx, { glob, maxLines, maxAdded, exempt, base }) {
|
|
99
|
+
const ref = await baseRef(ctx, base);
|
|
100
|
+
const files = (await ctx.git.changedFiles(ref)).filter((f) => matchGlob(glob, f) && !(exempt.length && matchGlob(exempt, f)));
|
|
101
|
+
let seen = 0;
|
|
102
|
+
let big = 0;
|
|
103
|
+
for (const f of files) {
|
|
104
|
+
if (!(await ctx.fs.exists(f))) continue;
|
|
105
|
+
const now = lineCount(await ctx.fs.read(f));
|
|
106
|
+
if (now === null) continue;
|
|
107
|
+
seen++;
|
|
108
|
+
if (now <= maxLines) continue;
|
|
109
|
+
big++;
|
|
110
|
+
const before = lineCount(await ctx.git.fileAt(ref, f));
|
|
111
|
+
if (before === null) {
|
|
112
|
+
fail(`${f} is new and has ${now} lines (most: ${maxLines}): split it into smaller modules`, { received: now, expected: maxLines });
|
|
113
|
+
} else if (before <= maxLines) {
|
|
114
|
+
fail(`${f} grew past ${maxLines} lines (${before} → ${now}): put the new code in its own module`, { received: now, expected: maxLines });
|
|
115
|
+
} else if (now - before > maxAdded) {
|
|
116
|
+
fail(`${f} already has ${before} lines and grew by ${now - before} (most: ${maxAdded}): put the new code in its own module`, { received: now - before, expected: maxAdded });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!big) note(`${seen} changed file${seen === 1 ? "" : "s"} checked, none past ${maxLines} lines`);
|
|
120
|
+
else note(`${seen} changed file${seen === 1 ? "" : "s"} checked; ${big} past ${maxLines} lines grew ${maxAdded} or fewer`);
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
module.exports = { exist, contain, noneMatch, maxGrowth, lineCount };
|
package/helpers/git.js
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git helpers: the state of the workspace's repo. Built only from Layer 0
|
|
3
|
+
* (ctx.git), never git directly.
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const { defineHelper, expect, fail, note, matchGlob, globToRegExp, DashCheckError } = require("..");
|
|
8
|
+
const { needHandoff } = require("./handoff");
|
|
9
|
+
const { runOrFail } = require("./commands");
|
|
10
|
+
|
|
11
|
+
const listOf = (files, n = 10) => `${files.slice(0, n).join(", ")}${files.length > n ? `, and ${files.length - n} more` : ""}`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The ref to compare with: "origin/<base>" when the remote has it, else the
|
|
15
|
+
* local branch. With no base, the repo's default branch.
|
|
16
|
+
*/
|
|
17
|
+
async function baseRef(ctx, base) {
|
|
18
|
+
let b = String(base || "").trim();
|
|
19
|
+
if (!b) b = (await ctx.git.defaultBranch()) || "";
|
|
20
|
+
if (!b) {
|
|
21
|
+
throw new DashCheckError("No base branch to compare with", {
|
|
22
|
+
fix: "set the base (e.g. main), or give the repo an origin/HEAD",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (b.startsWith("origin/") || b.startsWith("refs/")) return b;
|
|
26
|
+
if (await ctx.git.hasRef(`origin/${b}`)) return `origin/${b}`;
|
|
27
|
+
if (await ctx.git.hasRef(b)) return b;
|
|
28
|
+
return `origin/${b}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const BASE = { type: "text", label: "Base branch", default: "{repo.baseBranch}", description: "Empty: the repo's default branch" };
|
|
32
|
+
|
|
33
|
+
const onBranch = defineHelper({
|
|
34
|
+
id: "git.onBranch",
|
|
35
|
+
group: "Git",
|
|
36
|
+
label: "On the job's branch",
|
|
37
|
+
description: "The workspace is on workspace.branch",
|
|
38
|
+
sentence: "the workspace is on {branch}",
|
|
39
|
+
params: { branch: { type: "text", label: "Branch", default: "{workspace.branch}" } },
|
|
40
|
+
reads: ["git", "workspace"],
|
|
41
|
+
async run(ctx, { branch }) {
|
|
42
|
+
if (!branch) {
|
|
43
|
+
fail("No branch to check: the job's workspace has none. Name it in the handoff's workspace.branch, or set the branch");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const cur = await ctx.git.branch();
|
|
47
|
+
const shown = cur === "HEAD" ? "no branch (a detached HEAD)" : cur;
|
|
48
|
+
expect(cur, "the branch").toBe(branch, `The workspace is on ${shown}, not ${branch}: check out ${branch}`);
|
|
49
|
+
note(`On ${branch}`);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const committedSince = defineHelper({
|
|
54
|
+
id: "git.committedSince",
|
|
55
|
+
group: "Git",
|
|
56
|
+
label: "Work is committed",
|
|
57
|
+
description: "Commits past the base, nothing uncommitted",
|
|
58
|
+
sentence: "at least {min} commit(s) past {base}, and nothing uncommitted",
|
|
59
|
+
params: { base: BASE, min: { type: "number", label: "At least", default: 1 } },
|
|
60
|
+
reads: ["git"],
|
|
61
|
+
async run(ctx, { base, min }) {
|
|
62
|
+
const ref = await baseRef(ctx, base);
|
|
63
|
+
const n = await ctx.git.commitsSince(ref);
|
|
64
|
+
expect(n, `commits past ${ref}`).toBeGreaterThan(min - 1, n === 0 ? `No commits past ${ref}: commit the work (git add -A; git commit)` : `Only ${n} commit(s) past ${ref}; it needs ${min}`);
|
|
65
|
+
const dirty = await ctx.git.uncommitted();
|
|
66
|
+
if (dirty.length) fail("There are uncommitted changes: commit or discard them", { at: listOf(dirty, 5), received: dirty });
|
|
67
|
+
note(`${n} commit${n === 1 ? "" : "s"} past ${ref}, nothing uncommitted`);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const clean = defineHelper({
|
|
72
|
+
id: "git.clean",
|
|
73
|
+
group: "Git",
|
|
74
|
+
label: "Nothing uncommitted",
|
|
75
|
+
description: "No staged, unstaged or untracked changes",
|
|
76
|
+
sentence: "nothing is uncommitted",
|
|
77
|
+
reads: ["git"],
|
|
78
|
+
async run(ctx) {
|
|
79
|
+
const dirty = await ctx.git.uncommitted();
|
|
80
|
+
if (dirty.length) fail("There are uncommitted changes: commit or discard them", { at: listOf(dirty, 5), received: dirty });
|
|
81
|
+
else note("Nothing uncommitted");
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const changedOnly = defineHelper({
|
|
86
|
+
id: "git.changedOnly",
|
|
87
|
+
group: "Git",
|
|
88
|
+
label: "Only these files changed",
|
|
89
|
+
description: "Changed files match globs",
|
|
90
|
+
sentence: "only files matching {globs} changed since {base}",
|
|
91
|
+
params: { globs: { type: "list", label: "Globs", required: true, description: 'e.g. src/**, test/**, !src/generated/**' }, base: BASE },
|
|
92
|
+
reads: ["git"],
|
|
93
|
+
async run(ctx, { globs, base }) {
|
|
94
|
+
const ref = await baseRef(ctx, base);
|
|
95
|
+
const changed = await ctx.git.changedFiles(ref);
|
|
96
|
+
const extra = changed.filter((f) => !matchGlob(globs, f));
|
|
97
|
+
if (extra.length) fail(`Files outside ${globs.join(", ")} changed: undo them, or widen the globs`, { at: listOf(extra), received: extra });
|
|
98
|
+
else note(`${changed.length} changed file${changed.length === 1 ? "" : "s"}, all in ${globs.join(", ")}`);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const noChangesTo = defineHelper({
|
|
103
|
+
id: "git.noChangesTo",
|
|
104
|
+
group: "Git",
|
|
105
|
+
label: "These files didn't change",
|
|
106
|
+
description: "No changed file matches the globs",
|
|
107
|
+
sentence: "nothing matching {globs} changed since {base}",
|
|
108
|
+
params: { globs: { type: "list", label: "Globs", required: true }, base: BASE },
|
|
109
|
+
reads: ["git"],
|
|
110
|
+
async run(ctx, { globs, base }) {
|
|
111
|
+
const ref = await baseRef(ctx, base);
|
|
112
|
+
const touched = (await ctx.git.changedFiles(ref)).filter((f) => matchGlob(globs, f));
|
|
113
|
+
if (touched.length) fail(`These must not change, but did: undo the changes to them`, { at: listOf(touched), received: touched });
|
|
114
|
+
else note(`Nothing in ${globs.join(", ")} changed`);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ---- the plan: the files a handoff names ------------------------------------
|
|
119
|
+
|
|
120
|
+
const PLAN_KEYS = { type: "list", label: "Plan keys", default: ["files", "newFiles", "tests"], description: "Handoff keys that list files: a path, a list of paths, or a list of { file } (or { path })" };
|
|
121
|
+
const ALSO_ALLOW = { type: "list", label: "Also allowed", description: "Globs that may change without being in the plan, e.g. CHANGELOG.md" };
|
|
122
|
+
const LOCKFILES = {
|
|
123
|
+
type: "list",
|
|
124
|
+
label: "Lockfiles",
|
|
125
|
+
default: ["package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml"],
|
|
126
|
+
description: "Allowed outside the plan only when node.lockfileExplained passes for them",
|
|
127
|
+
};
|
|
128
|
+
const norm = (p) => String(p).trim().replace(/\\/g, "/").replace(/^\.\//, "");
|
|
129
|
+
|
|
130
|
+
/** The files the handoff's plan names (deduplicated, as written). */
|
|
131
|
+
function planFiles(ctx, keys) {
|
|
132
|
+
const out = new Set();
|
|
133
|
+
const add = (v) => {
|
|
134
|
+
if (typeof v === "string" && v.trim()) out.add(norm(v));
|
|
135
|
+
else if (v && typeof v === "object" && !Array.isArray(v)) add(v.file !== undefined ? v.file : v.path);
|
|
136
|
+
};
|
|
137
|
+
for (const k of keys) {
|
|
138
|
+
const v = ctx.get(`handoff.${k}`);
|
|
139
|
+
if (Array.isArray(v)) v.forEach(add);
|
|
140
|
+
else add(v);
|
|
141
|
+
}
|
|
142
|
+
return [...out];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Is a file in the plan? A plan entry is a path, a folder ("src/x/") or a glob. */
|
|
146
|
+
const inPlan = (plan, f) =>
|
|
147
|
+
plan.some((p) => p === f || (p.endsWith("/") && f.startsWith(p)) || (/[*?{[]/.test(p) && matchGlob(p, f)));
|
|
148
|
+
|
|
149
|
+
const isLockfile = (lockfiles, f) => lockfiles.some((l) => l === f || l === f.split("/").pop() || (/[*?{[]/.test(l) && matchGlob(l, f)));
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The changed files outside the plan, with lockfiles judged by
|
|
153
|
+
* node.lockfileExplained's rule: { extra, lockProblems: [{ file, reason, at }], lockOk: [file] }.
|
|
154
|
+
*/
|
|
155
|
+
async function outsidePlan(ctx, ref, files, { plan, alsoAllow, lockfiles, changed }) {
|
|
156
|
+
const { lockfileProblem } = require("./node");
|
|
157
|
+
const extra = [];
|
|
158
|
+
const lockProblems = [];
|
|
159
|
+
const lockOk = [];
|
|
160
|
+
const judged = new Map();
|
|
161
|
+
for (const f of files) {
|
|
162
|
+
if (inPlan(plan, f) || (alsoAllow.length && matchGlob(alsoAllow, f))) continue;
|
|
163
|
+
if (isLockfile(lockfiles, f)) {
|
|
164
|
+
if (!judged.has(f)) judged.set(f, await lockfileProblem(ctx, ref, f, { changed }));
|
|
165
|
+
const r = judged.get(f);
|
|
166
|
+
if (!r.changed || !r.reason) lockOk.push(f);
|
|
167
|
+
else lockProblems.push({ file: f, reason: r.reason, at: r.at });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
extra.push(f);
|
|
171
|
+
}
|
|
172
|
+
return { extra, lockProblems, lockOk };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const changesMatchPlan = defineHelper({
|
|
176
|
+
id: "git.changesMatchPlan",
|
|
177
|
+
group: "Git",
|
|
178
|
+
label: "Only the planned files changed",
|
|
179
|
+
description: "Every changed file is named in the handoff's plan",
|
|
180
|
+
sentence: "every file changed since {base} is in handoff {planKeys}, or matches {alsoAllow}",
|
|
181
|
+
params: { base: BASE, planKeys: PLAN_KEYS, alsoAllow: ALSO_ALLOW, lockfiles: LOCKFILES },
|
|
182
|
+
reads: ["git", "fs", "handoff"],
|
|
183
|
+
async run(ctx, { base, planKeys, alsoAllow, lockfiles }) {
|
|
184
|
+
if (!needHandoff(ctx)) return;
|
|
185
|
+
const plan = planFiles(ctx, planKeys);
|
|
186
|
+
if (!plan.length) {
|
|
187
|
+
fail(`The handoff names no files in ${planKeys.join(", ")}: list the files the work changes`);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const ref = await baseRef(ctx, base);
|
|
191
|
+
const changed = await ctx.git.changedFiles(ref);
|
|
192
|
+
const { extra, lockProblems } = await outsidePlan(ctx, ref, changed, { plan, alsoAllow, lockfiles, changed });
|
|
193
|
+
if (extra.length) fail("Files the plan didn't name changed: undo them, or add them to the plan", { at: listOf(extra), received: extra });
|
|
194
|
+
for (const p of lockProblems) fail(p.reason, p.at ? { at: p.at } : undefined);
|
|
195
|
+
if (!extra.length && !lockProblems.length) note(`${changed.length} changed file${changed.length === 1 ? "" : "s"}, all in the plan`);
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const commitsScoped = defineHelper({
|
|
200
|
+
id: "git.commitsScoped",
|
|
201
|
+
group: "Git",
|
|
202
|
+
label: "Each commit is scoped",
|
|
203
|
+
description: "Every commit touches only planned files and names the item",
|
|
204
|
+
sentence: "each commit past {base} changes only files in handoff {planKeys} and mentions {mentions}",
|
|
205
|
+
params: {
|
|
206
|
+
base: BASE,
|
|
207
|
+
planKeys: { ...PLAN_KEYS, description: `${PLAN_KEYS.description}. Empty: don't check the files` },
|
|
208
|
+
alsoAllow: ALSO_ALLOW,
|
|
209
|
+
lockfiles: LOCKFILES,
|
|
210
|
+
mentions: { type: "text", label: "Message mentions", default: "{item.id}", description: "Text every commit message must have. Empty: don't check messages" },
|
|
211
|
+
},
|
|
212
|
+
reads: ["git", "fs", "handoff", "item"],
|
|
213
|
+
async run(ctx, { base, planKeys, alsoAllow, lockfiles, mentions }) {
|
|
214
|
+
let plan = null;
|
|
215
|
+
if (planKeys.length) {
|
|
216
|
+
if (!needHandoff(ctx)) return;
|
|
217
|
+
plan = planFiles(ctx, planKeys);
|
|
218
|
+
if (!plan.length) {
|
|
219
|
+
fail(`The handoff names no files in ${planKeys.join(", ")}: list the files the work changes`);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const ref = await baseRef(ctx, base);
|
|
224
|
+
const commits = (await ctx.git.commits(ref)).filter((c) => c.parents.length < 2);
|
|
225
|
+
if (!commits.length) {
|
|
226
|
+
note(`No commits past ${ref}`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const changed = plan ? await ctx.git.changedFiles(ref) : [];
|
|
230
|
+
let bad = 0;
|
|
231
|
+
for (const c of commits) {
|
|
232
|
+
const name = `${c.sha.slice(0, 7)} "${c.subject}"`;
|
|
233
|
+
if (plan) {
|
|
234
|
+
const { extra, lockProblems } = await outsidePlan(ctx, ref, c.files, { plan, alsoAllow, lockfiles, changed });
|
|
235
|
+
const out = [...extra, ...lockProblems.map((p) => p.file)];
|
|
236
|
+
if (out.length) {
|
|
237
|
+
bad++;
|
|
238
|
+
fail(`Commit ${name} changes files outside the plan: move them to their own branch, or add them to the plan`, { at: listOf(out), received: out });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (mentions && !c.message.includes(mentions)) {
|
|
242
|
+
bad++;
|
|
243
|
+
fail(`Commit ${name} doesn't mention ${mentions}: reword it (git commit --amend, or rebase -i before pushing)`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (!bad) note(`${commits.length} commit${commits.length === 1 ? "" : "s"}, each scoped${mentions ? ` and mentioning ${mentions}` : ""}`);
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// ---- tests next to the source ------------------------------------------------
|
|
251
|
+
|
|
252
|
+
const RE_ESC = /[.*+?^${}()|[\]\\]/g;
|
|
253
|
+
const SENT = { dir: "\u0001D\u0001", name: "\u0001N\u0001", ext: "\u0001E\u0001" };
|
|
254
|
+
|
|
255
|
+
/** A test pattern ("<dir>/<name>.test.*") for one source file, as a RegExp. */
|
|
256
|
+
function pairedTest(pattern, src) {
|
|
257
|
+
const slash = src.lastIndexOf("/");
|
|
258
|
+
const dir = slash < 0 ? "" : src.slice(0, slash);
|
|
259
|
+
const file = src.slice(slash + 1);
|
|
260
|
+
const dot = file.lastIndexOf(".");
|
|
261
|
+
const parts = { dir, name: dot > 0 ? file.slice(0, dot) : file, ext: dot > 0 ? file.slice(dot + 1) : "" };
|
|
262
|
+
let g = String(pattern).replace(/<(dir|name|ext)>/g, (_m, k) => SENT[k]);
|
|
263
|
+
if (!dir) g = g.replace(new RegExp(`^${SENT.dir}/`), "");
|
|
264
|
+
let src2 = globToRegExp(g).source;
|
|
265
|
+
for (const k of Object.keys(SENT)) src2 = src2.split(SENT[k]).join(parts[k].replace(RE_ESC, "\\$&"));
|
|
266
|
+
return new RegExp(src2);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const sourceHasTests = defineHelper({
|
|
270
|
+
id: "git.sourceHasTests",
|
|
271
|
+
group: "Git",
|
|
272
|
+
label: "Changed source has tests",
|
|
273
|
+
description: "Each changed source file has a changed test (paired by name, or any)",
|
|
274
|
+
sentence: "each changed {sources} file since {base} has a changed test ({mode})",
|
|
275
|
+
params: {
|
|
276
|
+
sources: {
|
|
277
|
+
type: "list",
|
|
278
|
+
label: "Source files",
|
|
279
|
+
default: ["src/**/*.{js,jsx,ts,tsx,mjs,cjs}", "lib/**/*.{js,jsx,ts,tsx,mjs,cjs}", "!**/*.{test,spec}.*", "!**/__tests__/**", "!**/*.stories.*", "!**/*.d.ts"],
|
|
280
|
+
},
|
|
281
|
+
tests: { type: "list", label: "Test files", default: ["**/*.{test,spec}.*", "**/__tests__/**", "test/**", "tests/**"], description: "What counts as a test in any mode" },
|
|
282
|
+
testPattern: {
|
|
283
|
+
type: "list",
|
|
284
|
+
label: "Paired test",
|
|
285
|
+
default: ["<dir>/<name>.{test,spec}.*", "<dir>/__tests__/<name>.*", "{test,tests}/**/<name>.{test,spec}.*", "{test,tests}/**/<name>.*"],
|
|
286
|
+
description: "Where a source's test is, in paired mode: <dir>, <name> and <ext> are the source's",
|
|
287
|
+
},
|
|
288
|
+
mode: { type: "select", label: "Mode", options: ["paired", "any"], default: "paired", description: "paired: each source has its own test; any: some test changed" },
|
|
289
|
+
exempt: { type: "list", label: "Exempt", description: "Sources that need no test, e.g. **/index.js" },
|
|
290
|
+
base: BASE,
|
|
291
|
+
},
|
|
292
|
+
reads: ["git", "fs"],
|
|
293
|
+
async run(ctx, { sources, tests, testPattern, mode, exempt, base }) {
|
|
294
|
+
const ref = await baseRef(ctx, base);
|
|
295
|
+
const changed = [];
|
|
296
|
+
for (const f of await ctx.git.changedFiles(ref)) if (await ctx.fs.exists(f)) changed.push(f);
|
|
297
|
+
const srcs = changed.filter((f) => matchGlob(sources, f) && !(exempt.length && matchGlob(exempt, f)));
|
|
298
|
+
if (!srcs.length) {
|
|
299
|
+
note(`No source file changed since ${ref}`);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const changedTests = changed.filter((f) => matchGlob(tests, f));
|
|
303
|
+
if (mode === "any") {
|
|
304
|
+
if (!changedTests.length) fail("Source changed but no test did: add or update a test", { at: listOf(srcs), received: srcs });
|
|
305
|
+
else note(`${srcs.length} source file${srcs.length === 1 ? "" : "s"} and ${changedTests.length} test${changedTests.length === 1 ? "" : "s"} changed`);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const others = changed.filter((f) => !srcs.includes(f));
|
|
309
|
+
const missing = srcs.filter((s) => {
|
|
310
|
+
const res = testPattern.map((p) => pairedTest(p, s));
|
|
311
|
+
return !others.some((f) => res.some((re) => re.test(f)));
|
|
312
|
+
});
|
|
313
|
+
if (missing.length) {
|
|
314
|
+
fail(`Changed source with no changed test next to it: add or update ${missing.length === 1 ? "its test" : "their tests"} (${testPattern[0] || "a test"})`, { at: listOf(missing), received: missing });
|
|
315
|
+
} else note(`${srcs.length} source file${srcs.length === 1 ? "" : "s"}, each with its test`);
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// ---- the lines the work added --------------------------------------------------
|
|
320
|
+
|
|
321
|
+
const noNewMatches = defineHelper({
|
|
322
|
+
id: "git.noNewMatches",
|
|
323
|
+
group: "Git",
|
|
324
|
+
label: "No added line matches a pattern",
|
|
325
|
+
description: "e.g. no new TODO or console.log; lines already there don't count",
|
|
326
|
+
sentence: "no line added since {base} in {glob} matches {pattern}",
|
|
327
|
+
params: {
|
|
328
|
+
glob: { type: "list", label: "Files", required: true, placeholder: "src/**/*.js, !**/*.test.js" },
|
|
329
|
+
pattern: { type: "regex", label: "Pattern", required: true, placeholder: "\\b(TODO|FIXME)\\b" },
|
|
330
|
+
base: BASE,
|
|
331
|
+
},
|
|
332
|
+
reads: ["git"],
|
|
333
|
+
async run(ctx, { glob, pattern, base }) {
|
|
334
|
+
const ref = await baseRef(ctx, base);
|
|
335
|
+
const added = (await ctx.git.addedLines(ref)).filter((l) => matchGlob(glob, l.file));
|
|
336
|
+
const hits = added.filter((l) => {
|
|
337
|
+
pattern.lastIndex = 0;
|
|
338
|
+
return pattern.test(l.text);
|
|
339
|
+
});
|
|
340
|
+
if (hits.length) {
|
|
341
|
+
const where = hits.map((h) => `${h.file}:${h.line}`);
|
|
342
|
+
fail(`${hits.length} added line${hits.length === 1 ? "" : "s"} match${hits.length === 1 ? "es" : ""} /${pattern.source}/: remove ${hits.length === 1 ? "it" : "them"}`, { at: listOf(where), received: where });
|
|
343
|
+
} else note(`No match in ${added.length} added line${added.length === 1 ? "" : "s"}`);
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// ---- validation doesn't rewrite the tree ---------------------------------------
|
|
348
|
+
|
|
349
|
+
const validateLeavesTreeClean = defineHelper({
|
|
350
|
+
id: "git.validateLeavesTreeClean",
|
|
351
|
+
group: "Git",
|
|
352
|
+
label: "Validate doesn't rewrite files",
|
|
353
|
+
description: "Running the validate command leaves no file changed (no formatter --write, no npm install --save)",
|
|
354
|
+
sentence: "{command} passes and leaves nothing uncommitted",
|
|
355
|
+
params: {
|
|
356
|
+
command: { type: "text", label: "Command", default: "npm test" },
|
|
357
|
+
timeoutSec: { type: "number", label: "Time limit (s)", default: 1800 },
|
|
358
|
+
allowDirtyBefore: { type: "boolean", label: "Allow changes before", default: false, description: "Judge only files the command changes" },
|
|
359
|
+
},
|
|
360
|
+
reads: ["git", "run"],
|
|
361
|
+
async run(ctx, { command, timeoutSec, allowDirtyBefore }) {
|
|
362
|
+
const before = await ctx.git.uncommitted();
|
|
363
|
+
if (before.length && !allowDirtyBefore) {
|
|
364
|
+
fail(`There are uncommitted changes before ${command}: commit or discard them first`, { at: listOf(before, 5), received: before });
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const r = await runOrFail(ctx, command, timeoutSec);
|
|
368
|
+
const rewritten = (await ctx.git.uncommitted()).filter((f) => !before.includes(f));
|
|
369
|
+
if (rewritten.length) {
|
|
370
|
+
fail(`${command} changed files: make it check instead of rewrite (e.g. prettier --check, npm ci), and don't commit them`, { at: listOf(rewritten), received: rewritten });
|
|
371
|
+
} else if (r.code === 0 && !r.timedOut) note(`${command} passed and left the tree as it was`);
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
module.exports = {
|
|
376
|
+
onBranch, committedSince, clean, changedOnly, noChangesTo,
|
|
377
|
+
changesMatchPlan, commitsScoped, sourceHasTests, noNewMatches, validateLeavesTreeClean,
|
|
378
|
+
baseRef, planFiles, inPlan, pairedTest,
|
|
379
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub helpers: the PR in the handoff, checked on GitHub itself. Built
|
|
3
|
+
* only from Layer 0 (ctx.github).
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const { defineHelper, expect, fail, note } = require("..");
|
|
8
|
+
|
|
9
|
+
const mins = (sec) => {
|
|
10
|
+
const m = Math.max(1, Math.round(sec / 60));
|
|
11
|
+
return `${m} minute${m === 1 ? "" : "s"}`;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function prUrlOf(ctx, prKey) {
|
|
15
|
+
const url = ctx.get(`handoff.${prKey}`);
|
|
16
|
+
if (url === undefined || url === null || url === "") {
|
|
17
|
+
fail(`The handoff has no ${prKey}: put the PR's link in it`);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return url;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const prOpen = defineHelper({
|
|
24
|
+
id: "github.prOpen",
|
|
25
|
+
group: "GitHub",
|
|
26
|
+
label: "The PR is open",
|
|
27
|
+
description: "The handoff's PR is open on GitHub",
|
|
28
|
+
sentence: "the PR in handoff.{prKey} is open",
|
|
29
|
+
params: { prKey: { type: "text", label: "PR key", default: "prUrl" } },
|
|
30
|
+
reads: ["handoff", "github"],
|
|
31
|
+
async run(ctx, { prKey }) {
|
|
32
|
+
const url = prUrlOf(ctx, prKey);
|
|
33
|
+
if (!url) return;
|
|
34
|
+
const pr = await ctx.github.pr(url);
|
|
35
|
+
expect(pr.state, `PR #${pr.number}'s state`).toBe("open", `PR #${pr.number} isn't open (it's ${pr.merged ? "merged" : pr.state})`);
|
|
36
|
+
note(`PR #${pr.number} is open`);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const ciPassed = defineHelper({
|
|
41
|
+
id: "github.ciPassed",
|
|
42
|
+
group: "GitHub",
|
|
43
|
+
label: "The PR's CI passed",
|
|
44
|
+
description: "Waits, with a deadline",
|
|
45
|
+
sentence: "the CI of the PR in handoff.{prKey} passed, waiting up to {timeoutSec} seconds",
|
|
46
|
+
params: {
|
|
47
|
+
prKey: { type: "text", label: "PR key", default: "prUrl" },
|
|
48
|
+
timeoutSec: { type: "number", label: "Wait up to (s)", default: 1200 },
|
|
49
|
+
noChecksAfterSec: { type: "number", label: "No CI after (s)", default: 180 },
|
|
50
|
+
ifNoChecks: { type: "select", label: "If it has no CI", options: ["fail", "pass"], default: "fail" },
|
|
51
|
+
},
|
|
52
|
+
reads: ["handoff", "github"],
|
|
53
|
+
async run(ctx, { prKey, timeoutSec, noChecksAfterSec, ifNoChecks }) {
|
|
54
|
+
const url = prUrlOf(ctx, prKey);
|
|
55
|
+
if (!url) return;
|
|
56
|
+
const pr = await ctx.github.pr(url);
|
|
57
|
+
if (!pr.head || !pr.head.sha) {
|
|
58
|
+
fail(`Couldn't read PR #${pr.number}'s last commit`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const r = await ctx.github.waitForChecks(pr.head.sha, { timeoutSec, noChecksAfterSec, repo: pr.slug });
|
|
62
|
+
if (r.noChecks) {
|
|
63
|
+
if (ifNoChecks === "pass") note(`${url} has no CI checks (allowed)`);
|
|
64
|
+
else fail(`${url} has no CI after ${mins(noChecksAfterSec)}: enable Actions on the repo, or set "If it has no CI" to pass`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (r.failed.length) {
|
|
68
|
+
fail("CI failed", { at: r.failed.map((x) => `${x.name} (${x.conclusion})`).join(", "), received: r.failed });
|
|
69
|
+
}
|
|
70
|
+
if (r.timedOut) {
|
|
71
|
+
fail(`CI is still running on ${url} after ${mins(timeoutSec)}`, { at: r.pending.map((x) => x.name).join(", ") || undefined });
|
|
72
|
+
}
|
|
73
|
+
if (!r.failed.length && !r.timedOut) note(`${r.passed.length} CI check${r.passed.length === 1 ? "" : "s"} passed`);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
module.exports = { prOpen, ciPassed };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handoff helpers: what the bot's handoff (its last json block) says.
|
|
3
|
+
* Built only from Layer 0.
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const { defineHelper, expect, fail, note } = require("..");
|
|
8
|
+
|
|
9
|
+
/** Fails (and says why) when the answer has no handoff. */
|
|
10
|
+
function needHandoff(ctx) {
|
|
11
|
+
const info = ctx.handoffInfo || {};
|
|
12
|
+
if (info.found) return true;
|
|
13
|
+
if (info.broken) fail(`The answer's last \`\`\`json block doesn't parse (${info.error}): end the answer with one JSON object`);
|
|
14
|
+
else if (info.list) fail('The handoff is a JSON list: it must be one JSON object, e.g. { "summary": "…" }');
|
|
15
|
+
else fail("The answer has no handoff: end it with a ```json block holding a JSON object");
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const has = defineHelper({
|
|
20
|
+
id: "handoff.has",
|
|
21
|
+
group: "Handoff",
|
|
22
|
+
label: "Handoff has keys",
|
|
23
|
+
description: "The bot's handoff includes these, not empty",
|
|
24
|
+
sentence: "the handoff has {keys}",
|
|
25
|
+
params: {
|
|
26
|
+
keys: { type: "list", label: "Keys", required: true, description: 'e.g. prUrl, or plan.cause to reach in' },
|
|
27
|
+
},
|
|
28
|
+
reads: ["handoff"],
|
|
29
|
+
run(ctx, { keys }) {
|
|
30
|
+
if (!needHandoff(ctx)) return;
|
|
31
|
+
for (const k of keys) {
|
|
32
|
+
expect(ctx.get(`handoff.${k}`), `handoff.${k}`).not.toBeEmpty(`The handoff has no ${k}`);
|
|
33
|
+
}
|
|
34
|
+
note(`The handoff has ${keys.join(", ")}`);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const status = defineHelper({
|
|
39
|
+
id: "handoff.status",
|
|
40
|
+
group: "Handoff",
|
|
41
|
+
label: "Handoff status is",
|
|
42
|
+
description: "The handoff's status (ok, none, ask or split)",
|
|
43
|
+
sentence: "the handoff's status is {is}",
|
|
44
|
+
params: {
|
|
45
|
+
is: { type: "select", label: "Status", options: ["ok", "none", "ask", "split"], default: "ok" },
|
|
46
|
+
},
|
|
47
|
+
reads: ["handoff"],
|
|
48
|
+
run(ctx, { is }) {
|
|
49
|
+
if (!needHandoff(ctx)) return;
|
|
50
|
+
const s = ctx.handoff.status;
|
|
51
|
+
expect(s, "handoff.status").toBe(is, `The handoff's status is "${s}", not "${is}"`);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const eachHas = defineHelper({
|
|
56
|
+
id: "handoff.eachHas",
|
|
57
|
+
group: "Handoff",
|
|
58
|
+
label: "Each item in a list has keys",
|
|
59
|
+
description: "Every entry of a handoff list has these, not empty",
|
|
60
|
+
sentence: "each of handoff.{list} has {keys}",
|
|
61
|
+
params: {
|
|
62
|
+
list: { type: "text", label: "List", required: true, description: "e.g. tests" },
|
|
63
|
+
keys: { type: "list", label: "Keys", required: true },
|
|
64
|
+
},
|
|
65
|
+
reads: ["handoff"],
|
|
66
|
+
run(ctx, { list, keys }) {
|
|
67
|
+
if (!needHandoff(ctx)) return;
|
|
68
|
+
const items = ctx.get(`handoff.${list}`);
|
|
69
|
+
if (!expect(items, `handoff.${list}`).toBeArray(`The handoff's ${list} isn't a list`)) return;
|
|
70
|
+
items.forEach((it, i) => {
|
|
71
|
+
for (const k of keys) {
|
|
72
|
+
const v = it && typeof it === "object" ? ctx.get(`handoff.${list}.${i}.${k}`) : undefined;
|
|
73
|
+
expect(v, `handoff.${list}[${i}].${k}`).not.toBeEmpty(`${list}[${i}] has no ${k}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
note(`${items.length} in ${list}, each with ${keys.join(", ")}`);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
module.exports = { has, status, eachHas, needHandoff };
|