factorio-test-cli 3.1.0 → 3.1.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 CHANGED
@@ -9,60 +9,3 @@ If using an npm package, you can install `factorio-test-cli` to your dev depende
9
9
  ```bash
10
10
  npm install --save-dev factorio-test-cli
11
11
  ```
12
-
13
- ## Configuration Architecture
14
-
15
- ### Config Categories
16
-
17
- | Category | Casing | Location | Example Fields |
18
- |----------|--------|----------|----------------|
19
- | CLI-only | camelCase | `cli-config.ts` | `config`, `graphics`, `watch` |
20
- | File+CLI | camelCase | `cli-config.ts` | `modPath`, `factorioPath`, `verbose`, `forbidOnly` |
21
- | Test | snake_case | `types/config.d.ts` | `test_pattern`, `game_speed`, `bail` |
22
-
23
- - **CLI-only**: Options only available via command line, not in config files
24
- - **File+CLI**: Options that can be set in `factorio-test.json` or via command line (CLI overrides file)
25
- - **Test**: Runner configuration passed to the Factorio mod; uses snake_case for Lua compatibility
26
-
27
- ### Type Hierarchy
28
-
29
- ```
30
- types/config.d.ts
31
- └── TestRunnerConfig # CLI-passable fields (source of truth)
32
-
33
- ├── Extended by: FactorioTest.Config (types/index.d.ts)
34
- │ └── Adds mod-only fields: default_ticks_between_tests,
35
- │ before_test_run, after_test_run, sound_effects
36
-
37
- └── Validated by: testRunnerConfigSchema (cli/config/test-config.ts)
38
- └── Zod schema for runtime validation
39
- ```
40
-
41
- ### Data Flow
42
-
43
- ```
44
- CLI args ─────────────────┐
45
-
46
- factorio-test.json ──► loadConfig() ──► mergeCliConfig() ──► RunOptions
47
-
48
-
49
- buildTestConfig() ──► TestRunnerConfig ──► Factorio mod
50
- ```
51
-
52
- 1. `loadConfig()` reads `factorio-test.json` (or `package.json["factorio-test"]`)
53
- 2. `mergeCliConfig()` merges file config with CLI options (CLI wins)
54
- 3. `buildTestConfig()` extracts test runner options, combining patterns with OR logic
55
-
56
- ### File Organization
57
-
58
- ```
59
- types/
60
- ├── config.d.ts # TestRunnerConfig interface (source of truth for CLI-passable test options)
61
- └── index.d.ts # FactorioTest.Config extends TestRunnerConfig with mod-only fields
62
-
63
- cli/config/
64
- ├── index.ts # Re-exports all public APIs
65
- ├── test-config.ts # Zod schema validating TestRunnerConfig + CLI registration
66
- ├── cli-config.ts # CliConfig + CliOnlyOptions schemas + CLI registration
67
- └── loader.ts # Config loading, path resolution, merging, RunOptions type
68
- ```
package/cli.js CHANGED
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import chalk from "chalk";
3
3
  import { program } from "commander";
4
+ import { readFileSync } from "fs";
4
5
  import { CliError } from "./cli-error.js";
5
6
  import "./run.js";
7
+ const { version } = JSON.parse(readFileSync(new URL("package.json", import.meta.url), "utf8"));
6
8
  try {
7
9
  await program
8
10
  .name("factorio-test")
11
+ .version(version)
9
12
  .description("cli for factorio testing")
10
13
  .helpCommand(true)
11
14
  .showHelpAfterError()
@@ -4,7 +4,7 @@ const testConfigFields = {
4
4
  schema: z.string().optional(),
5
5
  cli: {
6
6
  flags: "--test-pattern <pattern>",
7
- description: "Filter tests by name pattern.",
7
+ description: "Filter tests by Lua pattern (escape - as %-).",
8
8
  },
9
9
  },
10
10
  tag_whitelist: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "factorio-test-cli",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "A CLI to run FactorioTest.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/run.js CHANGED
@@ -23,6 +23,10 @@ When using variadic options (--mods, --factorio-args, etc.) with filter patterns
23
23
  use -- to separate them:
24
24
  factorio-test run -p ./my-mod --mods quality space-age -- "inventory"
25
25
 
26
+ Patterns use Lua pattern syntax (not regex). Special characters like - must be
27
+ escaped with %:
28
+ factorio-test run -p ./my-mod "my%-test" Match "my-test" (escape the dash)
29
+
26
30
  Examples:
27
31
  factorio-test run -p ./my-mod Run all tests
28
32
  factorio-test run -p ./my-mod -v Run with verbose output
@@ -30,7 +34,7 @@ Examples:
30
34
  factorio-test run -p ./my-mod -b Bail on first failure
31
35
  factorio-test run -p ./my-mod "inventory" Run tests matching "inventory"
32
36
  `)
33
- .argument("[filter...]", "Test patterns to filter (OR logic)");
37
+ .argument("[filter...]", "Lua patterns to filter tests (OR logic)");
34
38
  registerAllCliOptions(thisCommand);
35
39
  thisCommand.action((patterns, options) => runTests(patterns, options));
36
40
  async function setupTestRun(patterns, options) {