From 59078f16f381db36cebad513878720b41931ac77 Mon Sep 17 00:00:00 2001 From: Scott Hardy Date: Mon, 16 Jun 2025 01:00:06 -0400 Subject: [PATCH 1/2] JSR readiness (#22) * fix(jsr_readiness): lint/fmt * fix(jsr_readiness): lint/fmt * fix(jsr_readiness): rename _test to .test * fix(jsr_readiness): rename _test to .test * fix(jsr_readiness): remove editorconfig from published files * fix(jsr_readiness): remove editorconfig from published files * fix(jsr_readiness): remove .test files from publishing * fix(jsr_readiness): remove tasks job options * fix(jsr_readiness): remove npm build in favor of jsr, update deno t oreflect this change * fix(jsr_readiness): rename ci and simplify ci files * fix(jsr_readiness): remove unused cli import * fix(jsr_readiness): update deno step to use denoland action * fix(jsr_readiness): remove import map and use deno strat for devImports, and still use jsr * fix(jsr_readiness): reorder command * fix(jsr_readiness): use parallel option for tests, add better dir for coverage * fix(jsr_readiness): remove unused options from deno json * fix(jsr_readiness): move compilerOptions * fix(jsr_readiness): add no lock * fix(jsr_readiness): add root dir location * fix(jsr_readiness): add root dir location * fix(jsr_readiness): use stright strings for tasks * fix(jsr_readiness): fmt * fix(jsr_readiness): ffix imprts back to using a map * fix(jsr_readiness): comments --- .github/DEVELOPMENT.md | 3 +- .../{ts_serialize_tests.yml => ci.yml} | 54 ++-------- .github/workflows/publish.yml | 25 +++++ .github/workflows/ts_serialize_release.yml | 84 --------------- _build_npm.ts | 101 ------------------ deno.json | 70 +++++------- deps_test.ts | 5 + ...messages_test.ts => error_messages.test.ts | 4 +- mod_test.ts => mod.test.ts | 4 +- polymorphic_test.ts => polymorphic.test.ts | 8 +- polymorphic.ts | 4 +- serializable_test.ts => serializable.test.ts | 7 +- ...erty_test.ts => serialize_property.test.ts | 8 +- serialize_property.ts | 4 +- ... => serialize_property_options_map.test.ts | 6 +- serialize_property_options_map.ts | 2 +- strategy/_utils.ts | 2 +- ...ategy_test.ts => compose_strategy.test.ts} | 4 +- strategy/compose_strategy.ts | 2 +- .../from_json/{date_test.ts => date.test.ts} | 5 +- strategy/from_json/date.ts | 4 +- .../{default_test.ts => default.test.ts} | 3 +- ...g_test.ts => to_object_containing.test.ts} | 5 +- strategy/from_json/to_object_containing.ts | 4 +- ...izable_test.ts => to_serializable.test.ts} | 6 +- strategy/from_json/to_serializable.ts | 4 +- .../{default_test.ts => default.test.ts} | 3 +- ...test.ts => from_object_containing.test.ts} | 3 +- strategy/to_json/from_object_containing.ts | 8 +- ...able_test.ts => from_serializable.test.ts} | 5 +- strategy/to_json/from_serializable.ts | 4 +- .../{recursive_test.ts => recursive.test.ts} | 3 +- strategy/to_json/recursive.ts | 6 +- strategy/{utils_test.ts => utils.test.ts} | 5 +- 34 files changed, 152 insertions(+), 313 deletions(-) rename .github/workflows/{ts_serialize_tests.yml => ci.yml} (52%) create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/ts_serialize_release.yml delete mode 100755 _build_npm.ts create mode 100644 deps_test.ts rename error_messages_test.ts => error_messages.test.ts (91%) rename mod_test.ts => mod.test.ts (91%) rename polymorphic_test.ts => polymorphic.test.ts (98%) rename serializable_test.ts => serializable.test.ts (97%) rename serialize_property_test.ts => serialize_property.test.ts (98%) rename serialize_property_options_map_test.ts => serialize_property_options_map.test.ts (97%) rename strategy/{compose_strategy_test.ts => compose_strategy.test.ts} (91%) rename strategy/from_json/{date_test.ts => date.test.ts} (96%) rename strategy/from_json/{default_test.ts => default.test.ts} (84%) rename strategy/from_json/{to_object_containing_test.ts => to_object_containing.test.ts} (97%) rename strategy/from_json/{to_serializable_test.ts => to_serializable.test.ts} (94%) rename strategy/to_json/{default_test.ts => default.test.ts} (84%) rename strategy/to_json/{from_object_containing_test.ts => from_object_containing.test.ts} (98%) rename strategy/to_json/{from_serializable_test.ts => from_serializable.test.ts} (97%) rename strategy/to_json/{recursive_test.ts => recursive.test.ts} (90%) rename strategy/{utils_test.ts => utils.test.ts} (92%) diff --git a/.github/DEVELOPMENT.md b/.github/DEVELOPMENT.md index b89d235c..bde21a64 100644 --- a/.github/DEVELOPMENT.md +++ b/.github/DEVELOPMENT.md @@ -44,7 +44,8 @@ symbols. If you find a bug a test case is the right place to start. Test example: ```ts -import { assertEquals } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { Serializable, SerializeProperty } from "../mod.ts"; Deno.test({ diff --git a/.github/workflows/ts_serialize_tests.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/ts_serialize_tests.yml rename to .github/workflows/ci.yml index 56692a63..ad7d3e6b 100644 --- a/.github/workflows/ts_serialize_tests.yml +++ b/.github/workflows/ci.yml @@ -5,59 +5,33 @@ name: tests -on: - push: - branches: ["**"] - pull_request: - branches: ["**"] +on: [push, pull_request] jobs: - deno_v1: + tests: runs-on: ${{ matrix.os }} strategy: matrix: - deno: [v1.x] + deno: [v1.x, canary] os: [macOS-latest, windows-latest, ubuntu-latest] steps: - name: Setup repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup deno - uses: denolib/setup-deno@v2 + uses: denoland/setup-deno@v2 with: deno-version: ${{ matrix.deno }} - - name: Deno test - run: deno test - - deno_v2_and_up: - runs-on: ${{ matrix.os }} - - needs: deno_v1 - - strategy: - matrix: - deno: [v2.x] - os: [macOS-latest, windows-latest, ubuntu-latest] - - steps: - - name: Setup repo - uses: actions/checkout@v2 - - - name: Setup deno - uses: denolib/setup-deno@v2 - with: - deno-version: ${{ matrix.deno }} - - - name: Deno lint - run: deno task lint - - name: Deno format check - run: deno task fmt --check + run: deno fmt --check if: matrix.os != 'windows-latest' + - name: Deno lint + run: deno lint + - name: Deno test run: deno task test:coverage @@ -70,12 +44,6 @@ jobs: path: ./coverage/lcov.info min_coverage: 100 - - name: Setup node - uses: actions/setup-node@v1 - with: - node-version: 22 - registry-url: https://registry.npmjs.org/ - - - name: Build and test NPM module - run: deno task build + - name: Publish module to jsr.io + run: deno publish --dry-run if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..d1d8ea4b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,25 @@ +name: publish + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + # using npx to avoid needing to install deno + + # --dry-run is used to avoid publishing the + # module until we can figure out how to handle + # the jsr.io publishing with the @gamebridge account admin. + + # When we decide to publish to JSR we'll need to rename the + # module to @gamebridge/serialize or something similar + # because `_` is not allowed in module names. + - run: npx jsr publish --dry-run diff --git a/.github/workflows/ts_serialize_release.yml b/.github/workflows/ts_serialize_release.yml deleted file mode 100644 index a63fbde9..00000000 --- a/.github/workflows/ts_serialize_release.yml +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2018-2021 Gamebridge.ai authors. All rights reserved. MIT license. - -name: release - -on: - push: - tags: ["v*.*.*"] - -jobs: - test: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - deno: ["v2.x"] - os: [macOS-latest, windows-latest, ubuntu-latest] - - steps: - - name: Setup repo - uses: actions/checkout@v2 - - - name: Setup Deno - uses: denolib/setup-deno@v2 - with: - deno-version: ${{ matrix.deno }} - - - name: Deno lint - run: deno task lint - - - name: Deno format check - run: deno task fmt --check - if: matrix.os != 'windows-latest' - - - name: Run deno tests - run: deno task test - - build: - name: Release - runs-on: ubuntu-latest - needs: test - - strategy: - matrix: - deno: ["v2.x"] - - steps: - - name: Get github tag - id: get_github_tag - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - - - name: Setup repo - uses: actions/checkout@v2 - - - name: Setup deno - uses: denolib/setup-deno@v2 - with: - deno-version: ${{ matrix.deno }} - - - name: Setup node - uses: actions/setup-node@v1 - with: - node-version: 22 - registry-url: https://registry.npmjs.org/ - - - name: Build and test NPM module - run: deno task build -v ${{ steps.get_github_tag.outputs.VERSION }} - - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - - name: Deploy to NPM - run: | - cd dist - npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/_build_npm.ts b/_build_npm.ts deleted file mode 100755 index 33de1d24..00000000 --- a/_build_npm.ts +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env -S deno run --allow-env --allow-read --allow-write --allow-run=npm --allow-net=jsr.io -// Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. - -import { build, emptyDir } from "@deno/dnt"; -import { parseArgs } from "@std/cli"; - -const entryPointDefault = "./mod.ts"; -const outDirDefault = "./dist"; -const versionDefault = "v0.0.0-test"; - -const helpText = ` -Deno to node transpiler, converts the ts_serialize module to a node compatible \ -module, and writes it to .github/workflows/npm, or the directory of your choice. - -This must be run from the project root if using the default arguments. - -Usage: - ./_build_npm.ts [-v ${versionDefault}] [-e ${entryPointDefault}] [-o ${outDirDefault}] - ./_build_npm.ts --help - -Command line arguments: - -h, --help Prints this help message, then exits. - -v, --version=[version] The version value to set in the resulting package.json. Defaults to "${versionDefault}". - -e, --entry-point=[path] The path to the mod.ts file to transpile into the npm package. Defaults to "${entryPointDefault}" - -o, --out=[path] The path to the target directory where the built files should be placed. Defaults to "${outDirDefault}" -`; - -function printHelpText(message = "") { - if (message.length) { - console.error(`\n${message}`); - console.log(helpText); - Deno.exit(1); - } - console.log(helpText); - Deno.exit(0); -} - -const flags = parseArgs(Deno.args, { - string: ["v", "e", "o"], - boolean: ["h"], - alias: { h: "help", e: "entry-point", v: "version", o: "out" }, - default: { e: entryPointDefault, o: outDirDefault, v: versionDefault }, - unknown: () => printHelpText("Unknown argument"), -}); - -if (flags.h) { - printHelpText(); -} - -await Deno.remove(`${flags.o}`, { recursive: true }).catch((_) => {}); - -try { - await emptyDir(flags.o); - - await build({ - importMap: "./deno.json", - entryPoints: [flags.e], - outDir: flags.o, - compilerOptions: { lib: ["ESNext"], experimentalDecorators: true }, - shims: { - deno: true, - }, - package: { - name: "@gamebridgeai/ts_serialize", - version: flags.v, - description: "A zero dependency library for serializing data.", - repository: { - type: "git", - url: "https://github.com/GameBridgeAI/ts_serialize.git", - }, - author: "GameBridgeAI", - license: "MIT", - bugs: { - url: "https://github.com/GameBridgeAI/ts_serialize/issues", - }, - homepage: "https://github.com/GameBridgeAI/ts_serialize", - keywords: [ - "ts_serialize", - "ts_serializable", - "ts-serialize", - "ts-serializable", - "typescript", - "serializable", - "serialize", - "deserialize", - "serialization", - "deserialization", - "json", - "node", - "deno", - ], - }, - }); - - await Deno.copyFile("LICENSE", `${flags.o}/LICENSE`); - await Deno.copyFile("README.md", `${flags.o}/README.md`); - await Deno.copyFile("CHANGELOG.md", `${flags.o}/CHANGELOG.md`); -} catch (e) { - const { message } = e instanceof Error ? e : { message: `${e}` }; - printHelpText(message); -} diff --git a/deno.json b/deno.json index 964c5802..71b695d4 100644 --- a/deno.json +++ b/deno.json @@ -1,53 +1,33 @@ { + "name": "@gamebridge/ts_serialize", + "version": "v2.1.0", + "exports": { + ".": "./mod.ts" + }, "imports": { - "@deno/dnt": "jsr:@deno/dnt@^0.42.1", - "@std/assert": "jsr:@std/assert@^1.0.13", - "@std/cli": "jsr:@std/cli@^1.0.17" + "@std/assert": "jsr:@std/assert@^1.0/assert", + "@std/assert/equals": "jsr:@std/assert@^1.0/equals", + "@std/assert/assertStrictEquals": "jsr:@std/assert@^1.0/strict-equals", + "@std/assert/assertNotEquals": "jsr:@std/assert@^1.0/not-equals", + "@std/assert/fail": "jsr:@std/assert@^1.0/fail" }, "lock": false, - "compilerOptions": { - "experimentalDecorators": true - }, - "fmt": { - "include": ["./"], - "exclude": ["./dist"] - }, - "test": { - "include": ["./"], - "exclude": ["./dist"] - }, - "lint": { - "include": ["./"], - "exclude": ["./dist"] - }, - "typeCheck": { - "include": ["./"], - "exclude": ["./dist"] + "publish": { + "exclude": [ + ".github", + ".vim", + ".vscode", + "coverage", + ".editorconfig", + "**/*.test.ts" + ] }, "tasks": { - "build": { - "description": "Build the project for npm, pass in your flags to override the defaults", - "command": "./_build_npm.ts -v v0.0.0-test -e ./mod.ts -o ./dist" - }, - "lint": { - "description": "Run linting", - "command": "deno lint" - }, - "fmt": { - "description": "Run formatting", - "command": "deno fmt" - }, - "test": { - "description": "Run tests", - "command": "deno test --doc" - }, - "test:coverage": { - "description": "Run tests with coverage", - "command": "deno test --coverage=coverage --doc" - }, - "test:coverage:report": { - "description": "Generate coverage report", - "command": "deno coverage --lcov coverage > coverage/lcov.info" - } + "test": "deno test --doc --parallel", + "test:coverage": "deno test --doc --parallel --coverage=./coverage", + "test:coverage:report": "deno coverage --lcov ./coverage > ./coverage/lcov.info" + }, + "compilerOptions": { + "experimentalDecorators": true } } diff --git a/deps_test.ts b/deps_test.ts new file mode 100644 index 00000000..5a1a175c --- /dev/null +++ b/deps_test.ts @@ -0,0 +1,5 @@ +export { assert } from "jsr:@std/assert@^1.0/assert"; +export { assertEquals } from "jsr:@std/assert@^1.0/equals"; +export { assertStrictEquals } from "jsr:@std/assert@^1.0/strict-equals"; +export { assertNotEquals } from "jsr:@std/assert@^1.0/not-equals"; +export { fail } from "jsr:@std/assert@^1.0/fail"; diff --git a/error_messages_test.ts b/error_messages.test.ts similarity index 91% rename from error_messages_test.ts rename to error_messages.test.ts index 214b42ae..40448504 100644 --- a/error_messages_test.ts +++ b/error_messages.test.ts @@ -1,6 +1,8 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals } from "@std/assert"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import * as mod from "./error_messages.ts"; Deno.test({ diff --git a/mod_test.ts b/mod.test.ts similarity index 91% rename from mod_test.ts rename to mod.test.ts index 186fe01d..0ceb5d27 100644 --- a/mod_test.ts +++ b/mod.test.ts @@ -1,6 +1,8 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals } from "@std/assert"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import * as mod from "./mod.ts"; Deno.test({ diff --git a/polymorphic_test.ts b/polymorphic.test.ts similarity index 98% rename from polymorphic_test.ts rename to polymorphic.test.ts index ff6bc983..6d89b8a2 100644 --- a/polymorphic_test.ts +++ b/polymorphic.test.ts @@ -1,7 +1,11 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, assertNotEquals, fail } from "@std/assert"; -import { JSONObject, Serializable } from "./serializable.ts"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; +import { assertNotEquals } from "@std/assert/assertNotEquals"; + +import { type JSONObject, Serializable } from "./serializable.ts"; import { SerializeProperty } from "./serialize_property.ts"; import { polymorphicClassFromJSON, diff --git a/polymorphic.ts b/polymorphic.ts index 2932fcc3..356682ac 100644 --- a/polymorphic.ts +++ b/polymorphic.ts @@ -1,8 +1,8 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. import { - JSONObject, - Serializable, + type JSONObject, + type Serializable, SERIALIZABLE_CLASS_MAP, } from "./serializable.ts"; import { ERROR_FAILED_TO_RESOLVE_POLYMORPHIC_CLASS } from "./error_messages.ts"; diff --git a/serializable_test.ts b/serializable.test.ts similarity index 97% rename from serializable_test.ts rename to serializable.test.ts index 0b992366..26e66177 100644 --- a/serializable_test.ts +++ b/serializable.test.ts @@ -1,7 +1,10 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, fail } from "@std/assert"; -import { Serializable, toPojo, TransformKey } from "./serializable.ts"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + +import { Serializable, toPojo, type TransformKey } from "./serializable.ts"; import { SerializeProperty } from "./serialize_property.ts"; import { toSerializable } from "./strategy/from_json/to_serializable.ts"; import { ERROR_MISSING_PROPERTIES_MAP } from "./error_messages.ts"; diff --git a/serialize_property_test.ts b/serialize_property.test.ts similarity index 98% rename from serialize_property_test.ts rename to serialize_property.test.ts index 1d3d9231..2b51c3a2 100644 --- a/serialize_property_test.ts +++ b/serialize_property.test.ts @@ -1,7 +1,11 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, assertStrictEquals, fail } from "@std/assert"; -import { JSONObject, Serializable } from "./serializable.ts"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; +import { assertStrictEquals } from "@std/assert/assertStrictEquals"; + +import { type JSONObject, Serializable } from "./serializable.ts"; import { SerializeProperty } from "./serialize_property.ts"; import { ERROR_DUPLICATE_SERIALIZE_KEY, diff --git a/serialize_property.ts b/serialize_property.ts index d93f84ed..63eccb49 100644 --- a/serialize_property.ts +++ b/serialize_property.ts @@ -1,9 +1,9 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { Serializable, SERIALIZABLE_CLASS_MAP } from "./serializable.ts"; +import { type Serializable, SERIALIZABLE_CLASS_MAP } from "./serializable.ts"; import { SerializePropertyOptionsMap } from "./serialize_property_options_map.ts"; -import { +import type { FromJSONStrategy, ToJSONStrategy, } from "./strategy/compose_strategy.ts"; diff --git a/serialize_property_options_map_test.ts b/serialize_property_options_map.test.ts similarity index 97% rename from serialize_property_options_map_test.ts rename to serialize_property_options_map.test.ts index 2b9a02bb..e637d8e7 100644 --- a/serialize_property_options_map_test.ts +++ b/serialize_property_options_map.test.ts @@ -1,6 +1,10 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, assertStrictEquals, fail } from "@std/assert"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; +import { assertStrictEquals } from "@std/assert/assertStrictEquals"; + import { SerializePropertyOptionsMap } from "./serialize_property_options_map.ts"; import { SerializePropertyOptions } from "./serialize_property.ts"; import { diff --git a/serialize_property_options_map.ts b/serialize_property_options_map.ts index 2049fe70..b37804a6 100644 --- a/serialize_property_options_map.ts +++ b/serialize_property_options_map.ts @@ -1,5 +1,5 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { SerializePropertyOptions } from "./serialize_property.ts"; +import type { SerializePropertyOptions } from "./serialize_property.ts"; import { ERROR_DUPLICATE_PROPERTY_KEY, ERROR_DUPLICATE_SERIALIZE_KEY, diff --git a/strategy/_utils.ts b/strategy/_utils.ts index 7ea8917b..37b8490b 100644 --- a/strategy/_utils.ts +++ b/strategy/_utils.ts @@ -1,6 +1,6 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { FunctionSerializable, NewSerializable } from "./utils.ts"; +import type { FunctionSerializable, NewSerializable } from "./utils.ts"; /** for strategy values */ export function isObject(obj: unknown): obj is Record { diff --git a/strategy/compose_strategy_test.ts b/strategy/compose_strategy.test.ts similarity index 91% rename from strategy/compose_strategy_test.ts rename to strategy/compose_strategy.test.ts index f1325a60..fa2cb52d 100644 --- a/strategy/compose_strategy_test.ts +++ b/strategy/compose_strategy.test.ts @@ -1,5 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; + +import { assertEquals } from "@std/assert/equals"; + import { composeStrategy } from "./compose_strategy.ts"; Deno.test({ diff --git a/strategy/compose_strategy.ts b/strategy/compose_strategy.ts index 0fd5e09d..be8cee5d 100644 --- a/strategy/compose_strategy.ts +++ b/strategy/compose_strategy.ts @@ -1,6 +1,6 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { JSONValue } from "../serializable.ts"; +import type { JSONValue } from "../serializable.ts"; /** Functions used when hydrating data. While we do know that the incoming param * is a JSONValue, this forces authors using the library to recast the known diff --git a/strategy/from_json/date_test.ts b/strategy/from_json/date.test.ts similarity index 96% rename from strategy/from_json/date_test.ts rename to strategy/from_json/date.test.ts index 1f91ab81..0d7b4f7d 100644 --- a/strategy/from_json/date_test.ts +++ b/strategy/from_json/date.test.ts @@ -1,6 +1,9 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, fail } from "@std/assert"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { createDateStrategy, iso8601Date } from "./date.ts"; import { Serializable, SerializeProperty } from "../../mod.ts"; import { ERROR_INVALID_DATE } from "../../error_messages.ts"; diff --git a/strategy/from_json/date.ts b/strategy/from_json/date.ts index e769d7e0..91d41d61 100644 --- a/strategy/from_json/date.ts +++ b/strategy/from_json/date.ts @@ -1,6 +1,6 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { FromJSONStrategy } from "../compose_strategy.ts"; -import { JSONValue } from "../../serializable.ts"; +import type { FromJSONStrategy } from "../compose_strategy.ts"; +import type { JSONValue } from "../../serializable.ts"; import { ERROR_INVALID_DATE } from "../../error_messages.ts"; /** allows authors to pass a regex to parse as a date */ diff --git a/strategy/from_json/default_test.ts b/strategy/from_json/default.test.ts similarity index 84% rename from strategy/from_json/default_test.ts rename to strategy/from_json/default.test.ts index 1d8fa051..a3d03377 100644 --- a/strategy/from_json/default_test.ts +++ b/strategy/from_json/default.test.ts @@ -1,6 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { fromJSONDefault } from "./default.ts"; Deno.test({ diff --git a/strategy/from_json/to_object_containing_test.ts b/strategy/from_json/to_object_containing.test.ts similarity index 97% rename from strategy/from_json/to_object_containing_test.ts rename to strategy/from_json/to_object_containing.test.ts index 83a0c4ce..ef68aae8 100644 --- a/strategy/from_json/to_object_containing_test.ts +++ b/strategy/from_json/to_object_containing.test.ts @@ -1,6 +1,9 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, fail } from "@std/assert"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { toObjectContaining } from "./to_object_containing.ts"; import { Serializable } from "../../serializable.ts"; import { SerializeProperty } from "../../serialize_property.ts"; diff --git a/strategy/from_json/to_object_containing.ts b/strategy/from_json/to_object_containing.ts index dfe9a390..4c855033 100644 --- a/strategy/from_json/to_object_containing.ts +++ b/strategy/from_json/to_object_containing.ts @@ -1,7 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { JSONObject, Serializable } from "../../serializable.ts"; -import { FromJSONStrategy } from "../compose_strategy.ts"; +import type { JSONObject, Serializable } from "../../serializable.ts"; +import type { FromJSONStrategy } from "../compose_strategy.ts"; import { ERROR_TO_OBJECT_CONTAINING_INVALID_SUB_VALUE, ERROR_TO_OBJECT_CONTAINING_INVALID_VALUE, diff --git a/strategy/from_json/to_serializable_test.ts b/strategy/from_json/to_serializable.test.ts similarity index 94% rename from strategy/from_json/to_serializable_test.ts rename to strategy/from_json/to_serializable.test.ts index 18da5b33..4c4e4746 100644 --- a/strategy/from_json/to_serializable_test.ts +++ b/strategy/from_json/to_serializable.test.ts @@ -1,8 +1,10 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals } from "@std/assert"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { toSerializable } from "./to_serializable.ts"; -import { JSONObject, Serializable } from "../../serializable.ts"; +import { type JSONObject, Serializable } from "../../serializable.ts"; import { SerializeProperty } from "../../serialize_property.ts"; Deno.test({ diff --git a/strategy/from_json/to_serializable.ts b/strategy/from_json/to_serializable.ts index b770e47f..9e1695e0 100644 --- a/strategy/from_json/to_serializable.ts +++ b/strategy/from_json/to_serializable.ts @@ -1,7 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { JSONObject, Serializable } from "../../serializable.ts"; -import { FromJSONStrategy } from "../compose_strategy.ts"; +import type { JSONObject, Serializable } from "../../serializable.ts"; +import type { FromJSONStrategy } from "../compose_strategy.ts"; import { getNewSerializable } from "../utils.ts"; /** revive data using `fromJSON` on a subclass type */ diff --git a/strategy/to_json/default_test.ts b/strategy/to_json/default.test.ts similarity index 84% rename from strategy/to_json/default_test.ts rename to strategy/to_json/default.test.ts index 004f5af7..e6d7ea50 100644 --- a/strategy/to_json/default_test.ts +++ b/strategy/to_json/default.test.ts @@ -1,6 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { toJSONDefault } from "./default.ts"; Deno.test({ diff --git a/strategy/to_json/from_object_containing_test.ts b/strategy/to_json/from_object_containing.test.ts similarity index 98% rename from strategy/to_json/from_object_containing_test.ts rename to strategy/to_json/from_object_containing.test.ts index c7d5109a..e168d2fe 100644 --- a/strategy/to_json/from_object_containing_test.ts +++ b/strategy/to_json/from_object_containing.test.ts @@ -1,6 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { fromObjectContaining } from "./from_object_containing.ts"; import { Serializable } from "../../serializable.ts"; import { SerializeProperty } from "../../serialize_property.ts"; diff --git a/strategy/to_json/from_object_containing.ts b/strategy/to_json/from_object_containing.ts index 2cf2c53e..108a34b8 100644 --- a/strategy/to_json/from_object_containing.ts +++ b/strategy/to_json/from_object_containing.ts @@ -1,7 +1,11 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { JSONObject, JSONValue, Serializable } from "../../serializable.ts"; -import { ToJSONStrategy } from "../compose_strategy.ts"; +import type { + JSONObject, + JSONValue, + Serializable, +} from "../../serializable.ts"; +import type { ToJSONStrategy } from "../compose_strategy.ts"; /** convert `{ [_: string]: Serializable }` to `{ [_: string]: Serializable.tsSerialize() }` */ export function fromObjectContaining(): ToJSONStrategy { diff --git a/strategy/to_json/from_serializable_test.ts b/strategy/to_json/from_serializable.test.ts similarity index 97% rename from strategy/to_json/from_serializable_test.ts rename to strategy/to_json/from_serializable.test.ts index e55d6aa1..10d183af 100644 --- a/strategy/to_json/from_serializable_test.ts +++ b/strategy/to_json/from_serializable.test.ts @@ -1,10 +1,11 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { Serializable } from "../../serializable.ts"; import { SerializeProperty, - SerializePropertyArgument, + type SerializePropertyArgument, } from "../../serialize_property.ts"; import { fromSerializable } from "./from_serializable.ts"; diff --git a/strategy/to_json/from_serializable.ts b/strategy/to_json/from_serializable.ts index 98cfb809..6aaa0297 100644 --- a/strategy/to_json/from_serializable.ts +++ b/strategy/to_json/from_serializable.ts @@ -1,7 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { JSONValue, Serializable } from "../../serializable.ts"; -import { ToJSONStrategy } from "../compose_strategy.ts"; +import type { JSONValue, Serializable } from "../../serializable.ts"; +import type { ToJSONStrategy } from "../compose_strategy.ts"; /** serialize data using `tsSerialize` on a subclass Serializable type */ export function fromSerializable(): ToJSONStrategy { diff --git a/strategy/to_json/recursive_test.ts b/strategy/to_json/recursive.test.ts similarity index 90% rename from strategy/to_json/recursive_test.ts rename to strategy/to_json/recursive.test.ts index 42845674..962c69f5 100644 --- a/strategy/to_json/recursive_test.ts +++ b/strategy/to_json/recursive.test.ts @@ -1,6 +1,7 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { toJSONRecursive } from "./recursive.ts"; import { Serializable } from "../../serializable.ts"; import { SerializeProperty } from "../../serialize_property.ts"; diff --git a/strategy/to_json/recursive.ts b/strategy/to_json/recursive.ts index 2b7c80b5..5cb4d327 100644 --- a/strategy/to_json/recursive.ts +++ b/strategy/to_json/recursive.ts @@ -1,6 +1,10 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { JSONObject, Serializable, toPojo } from "../../serializable.ts"; +import { + type JSONObject, + type Serializable, + toPojo, +} from "../../serializable.ts"; /** Recursively serialize a serializable class */ export function toJSONRecursive(value: Serializable): JSONObject { diff --git a/strategy/utils_test.ts b/strategy/utils.test.ts similarity index 92% rename from strategy/utils_test.ts rename to strategy/utils.test.ts index d6ba5f08..45cba206 100644 --- a/strategy/utils_test.ts +++ b/strategy/utils.test.ts @@ -1,6 +1,9 @@ // Copyright 2018-2025 Gamebridge.ai authors. All rights reserved. MIT license. -import { assert, assertEquals, fail } from "@std/assert"; +import { fail } from "@std/assert/fail"; +import { assert } from "@std/assert"; +import { assertEquals } from "@std/assert/equals"; + import { getNewSerializable } from "./utils.ts"; import { Serializable } from "../serializable.ts"; import { SerializeProperty } from "../serialize_property.ts"; From 294a2a5c3be0591d01be0801d7654148ab6a6242 Mon Sep 17 00:00:00 2001 From: Scott Hardy Date: Mon, 16 Jun 2025 01:14:40 -0400 Subject: [PATCH 2/2] delete file (#24) --- deps_test.ts | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 deps_test.ts diff --git a/deps_test.ts b/deps_test.ts deleted file mode 100644 index 5a1a175c..00000000 --- a/deps_test.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { assert } from "jsr:@std/assert@^1.0/assert"; -export { assertEquals } from "jsr:@std/assert@^1.0/equals"; -export { assertStrictEquals } from "jsr:@std/assert@^1.0/strict-equals"; -export { assertNotEquals } from "jsr:@std/assert@^1.0/not-equals"; -export { fail } from "jsr:@std/assert@^1.0/fail";