@trops/dash-check 0.3.1 → 0.3.2
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 +1 -1
- package/helpers/node.js +36 -3
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -208,7 +208,7 @@ Checks for a code factory, where a planning bot names the files and a coding bot
|
|
|
208
208
|
| `files.maxGrowth` | A changed file is new and over `maxLines`, crosses `maxLines`, or was already over it and grew by more than `maxAdded` | `glob` (JS/TS), `maxLines` (800), `maxAdded` (50), `exempt`, `base` |
|
|
209
209
|
| `git.validateLeavesTreeClean` | The tree isn't clean before validating, the command fails, or it leaves files changed (a formatter's `--write`, `npm install --save`) | `command` (`npm test`), `timeoutSec` (1800), `allowDirtyBefore` (false) |
|
|
210
210
|
| `node.testScriptIsReal` | The `test` script is missing, empty, a no-op (`exit 0`, `true`, `echo …`, npm's placeholder) or hides its failures (`… \|\| true`). With `run`, also when it reports fewer than `minTests` tests | `script` (`test`), `run` (false), `minTests` (1), `timeoutSec` (900) |
|
|
211
|
-
| `node.newTestsAreRun` | A **new** test file isn't named in a runner file, isn't matched by a glob written in one (`node --test 'test/*.test.js'`), and isn't in `autoGlobs` | `tests` (`**/*.{test,spec}.{js,cjs,mjs,jsx,ts,tsx}`), `runnerFiles` (`package.json`), `autoGlobs` (what the runner finds by itself, e.g. `src/**/*.test.js` for jest), `base` |
|
|
211
|
+
| `node.newTestsAreRun` | A **new** test file isn't named in a runner file, isn't matched by a glob written in one (`node --test 'test/*.test.js'`, brace globs such as `src/**/*.{test,spec}.js` included), and isn't in `autoGlobs` | `tests` (`**/*.{test,spec}.{js,cjs,mjs,jsx,ts,tsx}`), `runnerFiles` (`package.json`), `autoGlobs` (what the runner finds by itself, e.g. `src/**/*.test.js` for jest), `base` |
|
|
212
212
|
|
|
213
213
|
A coding bot's step might run them in this order:
|
|
214
214
|
|
package/helpers/node.js
CHANGED
|
@@ -254,9 +254,42 @@ const testScriptIsReal = defineHelper({
|
|
|
254
254
|
},
|
|
255
255
|
});
|
|
256
256
|
|
|
257
|
-
/**
|
|
257
|
+
/** "a,{b,c}" → ["a", "{b,c}"]: splits on commas outside a glob's {a,b}. */
|
|
258
|
+
function topLevelCommas(word) {
|
|
259
|
+
const out = [];
|
|
260
|
+
let depth = 0;
|
|
261
|
+
let cur = "";
|
|
262
|
+
for (const c of word) {
|
|
263
|
+
if (c === "{") depth++;
|
|
264
|
+
else if (c === "}" && depth > 0) depth--;
|
|
265
|
+
if (c === "," && depth === 0) {
|
|
266
|
+
out.push(cur);
|
|
267
|
+
cur = "";
|
|
268
|
+
} else cur += c;
|
|
269
|
+
}
|
|
270
|
+
out.push(cur);
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Are a word's { and } paired, in order? */
|
|
275
|
+
function bracesBalanced(word) {
|
|
276
|
+
let depth = 0;
|
|
277
|
+
for (const c of word) {
|
|
278
|
+
if (c === "{") depth++;
|
|
279
|
+
else if (c === "}" && --depth < 0) return false;
|
|
280
|
+
}
|
|
281
|
+
return depth === 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Glob-like words in a runner's text ("test/*.test.js", "src/**", "src/**\/*.{test,spec}.js"):
|
|
286
|
+
* what it finds by itself. A backslash (as in package.json's \\") ends a word. Commas inside
|
|
287
|
+
* a glob's {a,b} stay in the glob; a word whose braces don't pair (a fragment of code, not
|
|
288
|
+
* a glob) is left out.
|
|
289
|
+
*/
|
|
258
290
|
function globsIn(text) {
|
|
259
|
-
|
|
291
|
+
const words = String(text).split(/[\s"'`\\=()[\]]+/).flatMap(topLevelCommas);
|
|
292
|
+
return [...new Set(words.map((w) => w.replace(/^\.\//, "")).filter((w) => /[*?]/.test(w) && /[\w]/.test(w) && bracesBalanced(w)))];
|
|
260
293
|
}
|
|
261
294
|
|
|
262
295
|
const newTestsAreRun = defineHelper({
|
|
@@ -293,4 +326,4 @@ const newTestsAreRun = defineHelper({
|
|
|
293
326
|
},
|
|
294
327
|
});
|
|
295
328
|
|
|
296
|
-
module.exports = { testsPass, lintPasses, noNewDependencies, lockfileExplained, testScriptIsReal, newTestsAreRun, testCount, lockfileProblem, noOpScript };
|
|
329
|
+
module.exports = { testsPass, lintPasses, noNewDependencies, lockfileExplained, testScriptIsReal, newTestsAreRun, testCount, lockfileProblem, noOpScript, globsIn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trops/dash-check",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Compose deterministic checks from small, described building blocks: Jest-style files, JSON recipes and helpers. Runs in Dash, in CI and on a laptop.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "trops",
|
|
@@ -10,7 +10,14 @@
|
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://github.com/trops/dash-check#readme",
|
|
12
12
|
"bugs": "https://github.com/trops/dash-check/issues",
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dash",
|
|
15
|
+
"checks",
|
|
16
|
+
"ci",
|
|
17
|
+
"testing",
|
|
18
|
+
"bots",
|
|
19
|
+
"deterministic"
|
|
20
|
+
],
|
|
14
21
|
"engines": {
|
|
15
22
|
"node": ">=18"
|
|
16
23
|
},
|