From cb89f3a65fcb74388cd14f91a89c981430870f8a Mon Sep 17 00:00:00 2001 From: BluJ Date: Sun, 30 Apr 2023 15:00:20 -0600 Subject: [PATCH] chore: Update the builder to ignore the original naming --- README.md | 1 - lib/test/output.test.ts | 38 ++++++++++++++++++------------------- scripts/oldSpecToBuilder.ts | 8 +++++--- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f8a159c..984bdd0 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,4 @@ - run the script `npm run buildOutput` to make the output.ts - Copy this whole file into startos/procedures/config/spec.ts -- rename `inputSpec` -> `configSpec` and `InputSpec` -> `ConfigSpec` - Fix all the TODO diff --git a/lib/test/output.test.ts b/lib/test/output.test.ts index 328f02f..08fb620 100644 --- a/lib/test/output.test.ts +++ b/lib/test/output.test.ts @@ -5,7 +5,7 @@ import { unionValueKey, } from "../config/configTypes" import { deepMerge } from "../util" -import { InputSpec, matchInputSpec } from "./output" +import { ConfigSpec, matchConfigSpec } from "./output" import * as _I from "../index" import { camelCase } from "../../scripts/oldSpecToBuilder" @@ -19,40 +19,40 @@ export function testOutput(): (c: IfEquals) => null { } /// Testing the types of the input spec -testOutput()(null) -testOutput()(null) -testOutput()(null) +testOutput()(null) +testOutput()(null) +testOutput()(null) -testOutput()(null) +testOutput()(null) testOutput< - InputSpec["rpc"]["advanced"]["serialversion"], + ConfigSpec["rpc"]["advanced"]["serialversion"], "segwit" | "non-segwit" >()(null) -testOutput()(null) +testOutput()(null) testOutput< - InputSpec["advanced"]["peers"]["addnode"][0]["hostname"], + ConfigSpec["advanced"]["peers"]["addnode"][0]["hostname"], string | null | undefined >()(null) testOutput< - InputSpec["testListUnion"][0]["union"][UnionValueKey]["name"], + ConfigSpec["testListUnion"][0]["union"][UnionValueKey]["name"], string >()(null) -testOutput()( +testOutput()( null, ) -testOutput>()( +testOutput>()( null, ) // @ts-expect-error Because enable should be a boolean -testOutput()(null) +testOutput()(null) // prettier-ignore // @ts-expect-error Expect that the string is the one above -testOutput()(null); +testOutput()(null); -/// Here we test the output of the matchInputSpec function +/// Here we test the output of the matchConfigSpec function describe("Inputs", () => { - const validInput: InputSpec = { + const validInput: ConfigSpec = { mediasources: ["filebrowser"], testListUnion: [ { @@ -107,24 +107,24 @@ describe("Inputs", () => { } test("test valid input", () => { - const output = matchInputSpec.unsafeCast(validInput) + const output = matchConfigSpec.unsafeCast(validInput) expect(output).toEqual(validInput) }) test("test no longer care about the conversion of min/max and validating", () => { - matchInputSpec.unsafeCast( + matchConfigSpec.unsafeCast( deepMerge({}, validInput, { rpc: { advanced: { threads: 0 } } }), ) }) test("test errors should throw for number in string", () => { expect(() => - matchInputSpec.unsafeCast( + matchConfigSpec.unsafeCast( deepMerge({}, validInput, { rpc: { enable: 2 } }), ), ).toThrowError() }) test("Test that we set serialversion to something not segwit or non-segwit", () => { expect(() => - matchInputSpec.unsafeCast( + matchConfigSpec.unsafeCast( deepMerge({}, validInput, { rpc: { advanced: { serialversion: "testing" } }, }), diff --git a/scripts/oldSpecToBuilder.ts b/scripts/oldSpecToBuilder.ts index 73021db..ecbdf0a 100644 --- a/scripts/oldSpecToBuilder.ts +++ b/scripts/oldSpecToBuilder.ts @@ -38,12 +38,14 @@ export default async function makeFileContentFromOld( const data = await inputData const namedConsts = new Set(["Config", "Value", "List"]) - const configName = newConst("InputSpec", convertInputSpec(data)) + const configName = newConst("ConfigSpec", convertInputSpec(data)) const configMatcherName = newConst( - "matchInputSpec", + "matchConfigSpec", `${configName}.validator()`, ) - outputLines.push(`export type InputSpec = typeof ${configMatcherName}._TYPE;`) + outputLines.push( + `export type ConfigSpec = typeof ${configMatcherName}._TYPE;`, + ) return outputLines.join("\n")