Skip to content

Commit 80afc29

Browse files
committed
chore: generate.mjs supports filtering by template/spec
1 parent 46fea1e commit 80afc29

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@biomejs/biome": "2.1.2",
4343
"@biomejs/js-api": "2.0.3",
4444
"@biomejs/wasm-nodejs": "2.1.2",
45+
"@commander-js/extra-typings": "^14.0.0",
4546
"@swc/core": "^1.13.0",
4647
"@swc/jest": "^0.2.39",
4748
"@tsconfig/node24": "^24.0.1",
@@ -50,6 +51,7 @@
5051
"ajv": "^8.17.1",
5152
"ajv-draft-04": "^1.0.0",
5253
"ajv-formats": "^3.0.1",
54+
"commander": "^14.0.0",
5355
"husky": "^9.1.7",
5456
"jest": "^30.0.4",
5557
"lerna": "^8.2.3",

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate.mjs

100644100755
Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
#!/usr/bin/env node
2+
13
import {exec, execSync} from "node:child_process"
24
import path from "node:path"
5+
import {Command, Option} from "@commander-js/extra-typings"
6+
7+
const program = new Command()
8+
.addOption(new Option("-t --template <value>", "filter to a single template"))
9+
.addOption(new Option("-s --spec <value>", "filter to a single spec"))
10+
.showHelpAfterError()
311

412
const templates = execSync(
513
"find ./integration-tests -mindepth 1 -maxdepth 1 -type d",
@@ -8,16 +16,29 @@ const templates = execSync(
816
.split("\n")
917
.map((it) => it.trim())
1018
.filter(Boolean)
19+
1120
const definitions = execSync("find ./integration-tests-definitions -type f")
1221
.toString("utf-8")
1322
.split("\n")
1423
.map((it) => it.trim())
1524
.filter(Boolean)
1625

26+
const config = program.parse().opts()
27+
28+
const filteredTemplate = config.template
29+
const filteredSpec = path.normalize(config.spec)
30+
31+
console.info("filters", {filteredTemplate, filteredSpec})
1732
Promise.all(
18-
templates.flatMap((templatePath) =>
19-
definitions.map((definition) => runSingle(templatePath, definition)),
20-
),
33+
templates
34+
.filter((it) => !filteredTemplate || it.includes(filteredTemplate))
35+
.flatMap((templatePath) =>
36+
definitions
37+
.filter(
38+
(it) => !filteredSpec || path.normalize(it).includes(filteredSpec),
39+
)
40+
.map((definition) => runSingle(templatePath, definition)),
41+
),
2142
)
2243
.then(() => {
2344
console.log("success!")

0 commit comments

Comments
 (0)