Remove stepCount/stepSize; patterns own their geometry
The stepCount and stepSize knobs were two controls for one quantity users actually care about (reach), and the number of steps is an implementation detail nobody meaningfully tunes. Each pattern has a natural size and resolution — a jitter is inherently small, an arc a broad curve — so those now live as constants in each strategy rather than as global config. - strategies.ts: each pattern defines its own step count and size; MoveContext drops `config` down to pure geometry (start/width/height/rng), and the module no longer imports Config at all (dissolving the type-only-import cycle workaround). line stays byte-for-byte: 250 one-pixel steps. - executor.ts: executePath takes `config` for pacing (stepDelay); the path itself needs nothing from it. - config.ts / cli.ts / move.ts / config.default.json: drop stepCount and stepSize from the type, seed, validation, resolver, CLI flags (-n, -s), and help. stepDelay stays as the one pacing lever. - configFile.ts: tolerate the removed keys instead of rejecting them — every pre-1.3.0 install seeded stepCount, so a hard "unknown key" failure on upgrade is avoided. They're ignored with a one-line stderr notice; genuine unknown keys still error. The -n/--step-count CLI flag (shipped since 1.0.0) is now an unknown option; config files degrade gracefully, command lines don't. Stays in the unpushed 1.3.0 release. 64 tests pass.
This commit is contained in:
@@ -43,7 +43,7 @@ describe("loadConfigFile (explicit path)", () => {
|
||||
// Fields not in the file are undefined.
|
||||
expect(result!.checkInterval).toBeUndefined();
|
||||
expect(result!.stepDelay).toBeUndefined();
|
||||
expect(result!.stepCount).toBeUndefined();
|
||||
expect(result!.pattern).toBeUndefined();
|
||||
});
|
||||
|
||||
test("returns all-undefined overrides for an empty object", () => {
|
||||
@@ -81,8 +81,8 @@ describe("loadConfigFile (explicit path)", () => {
|
||||
});
|
||||
|
||||
test("throws on non-positive numeric values", () => {
|
||||
const negative = writeFixture("neg.json", JSON.stringify({ stepCount: -1 }));
|
||||
expect(() => loadConfigFile(negative)).toThrow(/'stepCount'.*positive number/);
|
||||
const negative = writeFixture("neg.json", JSON.stringify({ moveInterval: -1 }));
|
||||
expect(() => loadConfigFile(negative)).toThrow(/'moveInterval'.*positive number/);
|
||||
|
||||
const zero = writeFixture("zero.json", JSON.stringify({ stepDelay: 0 }));
|
||||
expect(() => loadConfigFile(zero)).toThrow(/'stepDelay'.*positive number/);
|
||||
@@ -98,11 +98,10 @@ describe("loadConfigFile (explicit path)", () => {
|
||||
expect(() => loadConfigFile(path)).toThrow(/'verbose'.*boolean/);
|
||||
});
|
||||
|
||||
test("accepts a known pattern and a positive stepSize", () => {
|
||||
const path = writeFixture("pattern.json", JSON.stringify({ pattern: "arc", stepSize: 3 }));
|
||||
test("accepts a known pattern", () => {
|
||||
const path = writeFixture("pattern.json", JSON.stringify({ pattern: "arc" }));
|
||||
const result = loadConfigFile(path);
|
||||
expect(result!.pattern).toBe("arc");
|
||||
expect(result!.stepSize).toBe(3);
|
||||
});
|
||||
|
||||
test("normalizes a loosely-spelled pattern to its canonical name", () => {
|
||||
@@ -117,9 +116,23 @@ describe("loadConfigFile (explicit path)", () => {
|
||||
expect(() => loadConfigFile(path)).toThrow(/line/);
|
||||
});
|
||||
|
||||
test("throws on a non-positive stepSize", () => {
|
||||
const path = writeFixture("badsize.json", JSON.stringify({ stepSize: 0 }));
|
||||
expect(() => loadConfigFile(path)).toThrow(/'stepSize'.*positive number/);
|
||||
test("tolerates obsolete stepCount/stepSize keys, ignoring their values", () => {
|
||||
// Seeded by pre-1.3.0 installs; must not hard-fail on upgrade. They're
|
||||
// accepted but not surfaced as overrides (and even an invalid value,
|
||||
// like a negative, is ignored rather than rejected).
|
||||
const path = writeFixture(
|
||||
"obsolete.json",
|
||||
JSON.stringify({ moveInterval: 60, stepCount: -1, stepSize: 3 }),
|
||||
);
|
||||
const result = loadConfigFile(path);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.moveInterval).toBe(60);
|
||||
expect(result as unknown as Record<string, unknown>).not.toHaveProperty("stepCount");
|
||||
});
|
||||
|
||||
test("still rejects a genuinely unknown key", () => {
|
||||
const path = writeFixture("unknown.json", JSON.stringify({ movInterval: 60 }));
|
||||
expect(() => loadConfigFile(path)).toThrow(/unknown key 'movInterval'/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user