From 3684e8fcc10707d8f90a0bab44edb8b93f259ff8 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 12 Mar 2026 10:43:40 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20prefer=20npm=20specifiers=20over?= =?UTF-8?q?=20jsr=20in=20import=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch @standard-schema/spec to npm, remove unused deps, and document the npm preference in AGENTS.md. --- AGENTS.md | 7 ++ deno.json | 5 +- deno.lock | 210 +++++------------------------------- examples/commands.ts | 2 +- examples/phased-commands.ts | 2 +- examples/simple.ts | 2 +- lib/mod.ts | 1 - lib/parse.ts | 14 --- lib/program.ts | 2 +- test/field.test.ts | 4 +- test/help.test.ts | 2 +- test/object.test.ts | 5 +- test/sequence.test.ts | 2 +- test/test-helpers.ts | 17 ++- 14 files changed, 56 insertions(+), 219 deletions(-) delete mode 100644 lib/parse.ts diff --git a/AGENTS.md b/AGENTS.md index 351cda6..d204ffb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -46,6 +46,13 @@ Strongly prefer one-word variable and function names (e.g. `dir` not `tmpDir`, (`deno run`) without errors - **Build**: `deno task build:npm` (dnt) and `deno task build:jsr` +### Dependencies + +When adding dependencies to the import map in `deno.json`, strongly prefer +`npm:` specifiers over `jsr:` specifiers whenever a package is available on npm. +Some packages (e.g. `@std/*`, `@deno/*`) are only available on JSR, and that is +fine. + ### Git - Use gitmoji for commit messages diff --git a/deno.json b/deno.json index be4a039..8f05926 100644 --- a/deno.json +++ b/deno.json @@ -4,13 +4,10 @@ "license": "MIT", "publish": { "include": ["vendor", "lib", "mod.ts", "README.md"] }, "imports": { - "@standard-schema/spec": "jsr:@standard-schema/spec@^1.0.0", - "@std/assert": "jsr:@std/assert@1", - "@std/cli": "jsr:@std/cli@^1.0.21", + "@standard-schema/spec": "npm:@standard-schema/spec@^1.0.0", "@std/expect": "jsr:@std/expect@^1.0.16", "@std/testing": "jsr:@std/testing@^1.0.15", "arktype": "npm:arktype@^2.1.20", - "sprintf-js": "npm:sprintf-js@^1.1.3", "ts-case-convert": "npm:ts-case-convert@^2.1.0", "dnt": "jsr:@deno/dnt@0.42.3" }, diff --git a/deno.lock b/deno.lock index 9b128b3..2d66653 100644 --- a/deno.lock +++ b/deno.lock @@ -1,200 +1,41 @@ { "version": "5", "specifiers": { - "jsr:@david/code-block-writer@^13.0.2": "13.0.3", - "jsr:@david/code-block-writer@^13.0.3": "13.0.3", - "jsr:@deno/cache-dir@~0.10.3": "0.10.3", - "jsr:@deno/dnt@0.41.3": "0.41.3", - "jsr:@deno/dnt@0.42.3": "0.42.3", - "jsr:@standard-schema/spec@1": "1.0.0", - "jsr:@std/assert@0.223": "0.223.0", - "jsr:@std/assert@0.226": "0.226.0", - "jsr:@std/assert@1": "1.0.13", - "jsr:@std/assert@^1.0.13": "1.0.13", - "jsr:@std/bytes@0.223": "0.223.0", - "jsr:@std/cli@^1.0.21": "1.0.21", - "jsr:@std/data-structures@^1.0.9": "1.0.9", - "jsr:@std/expect@^1.0.16": "1.0.16", - "jsr:@std/fmt@0.223": "0.223.0", - "jsr:@std/fmt@1": "1.0.8", - "jsr:@std/fs@0.223": "0.223.0", - "jsr:@std/fs@1": "1.0.19", - "jsr:@std/fs@^1.0.19": "1.0.19", - "jsr:@std/fs@~0.229.3": "0.229.3", - "jsr:@std/internal@^1.0.10": "1.0.10", - "jsr:@std/internal@^1.0.6": "1.0.10", - "jsr:@std/internal@^1.0.7": "1.0.10", - "jsr:@std/internal@^1.0.9": "1.0.10", - "jsr:@std/io@0.223": "0.223.0", - "jsr:@std/path@0.223": "0.223.0", - "jsr:@std/path@1": "1.1.1", - "jsr:@std/path@1.0.0-rc.1": "1.0.0-rc.1", - "jsr:@std/path@^1.1.1": "1.1.1", - "jsr:@std/path@~0.225.2": "0.225.2", - "jsr:@std/testing@^1.0.15": "1.0.15", - "jsr:@ts-morph/bootstrap@0.24": "0.24.0", - "jsr:@ts-morph/bootstrap@0.27": "0.27.0", - "jsr:@ts-morph/common@0.24": "0.24.0", - "jsr:@ts-morph/common@0.27": "0.27.0", + "jsr:@std/assert@^1.0.14": "1.0.18", + "jsr:@std/assert@^1.0.17": "1.0.18", + "jsr:@std/expect@^1.0.16": "1.0.17", + "jsr:@std/internal@^1.0.10": "1.0.12", + "jsr:@std/internal@^1.0.12": "1.0.12", + "jsr:@std/testing@^1.0.15": "1.0.17", + "npm:@standard-schema/spec@1": "1.1.0", "npm:arktype@^2.1.20": "2.1.20", - "npm:sprintf-js@^1.1.3": "1.1.3", "npm:ts-case-convert@^2.1.0": "2.1.0" }, "jsr": { - "@david/code-block-writer@13.0.3": { - "integrity": "f98c77d320f5957899a61bfb7a9bead7c6d83ad1515daee92dbacc861e13bb7f" - }, - "@deno/cache-dir@0.10.3": { - "integrity": "eb022f84ecc49c91d9d98131c6e6b118ff63a29e343624d058646b9d50404776", - "dependencies": [ - "jsr:@std/fmt@0.223", - "jsr:@std/fs@0.223", - "jsr:@std/io", - "jsr:@std/path@0.223" - ] - }, - "@deno/dnt@0.41.3": { - "integrity": "b2ef2c8a5111eef86cb5bfcae103d6a2938e8e649e2461634a7befb7fc59d6d2", - "dependencies": [ - "jsr:@david/code-block-writer@^13.0.2", - "jsr:@deno/cache-dir", - "jsr:@std/fmt@1", - "jsr:@std/fs@1", - "jsr:@std/path@1", - "jsr:@ts-morph/bootstrap@0.24" - ] - }, - "@deno/dnt@0.42.3": { - "integrity": "62a917a0492f3c8af002dce90605bb0d41f7d29debc06aca40dba72ab65d8ae3", - "dependencies": [ - "jsr:@david/code-block-writer@^13.0.3", - "jsr:@std/fmt@1", - "jsr:@std/fs@1", - "jsr:@std/path@1", - "jsr:@ts-morph/bootstrap@0.27" - ] - }, - "@standard-schema/spec@1.0.0": { - "integrity": "4f20bbcf34e92b92f8c01589b958abc7c87385fa9a96170cecdc643d4d5737c0" - }, - "@std/assert@0.223.0": { - "integrity": "eb8d6d879d76e1cc431205bd346ed4d88dc051c6366365b1af47034b0670be24" - }, - "@std/assert@0.226.0": { - "integrity": "0dfb5f7c7723c18cec118e080fec76ce15b4c31154b15ad2bd74822603ef75b3" - }, - "@std/assert@1.0.13": { - "integrity": "ae0d31e41919b12c656c742b22522c32fb26ed0cba32975cb0de2a273cb68b29", + "@std/assert@1.0.18": { + "integrity": "270245e9c2c13b446286de475131dc688ca9abcd94fc5db41d43a219b34d1c78", "dependencies": [ - "jsr:@std/internal@^1.0.6" + "jsr:@std/internal@^1.0.12" ] }, - "@std/bytes@0.223.0": { - "integrity": "84b75052cd8680942c397c2631318772b295019098f40aac5c36cead4cba51a8" - }, - "@std/cli@1.0.21": { - "integrity": "cd25b050bdf6282e321854e3822bee624f07aca7636a3a76d95f77a3a919ca2a" - }, - "@std/data-structures@1.0.9": { - "integrity": "033d6e17e64bf1f84a614e647c1b015fa2576ae3312305821e1a4cb20674bb4d" - }, - "@std/expect@1.0.16": { - "integrity": "ceeef6dda21f256a5f0f083fcc0eaca175428b523359a9b1d9b3a1df11cc7391", + "@std/expect@1.0.17": { + "integrity": "316b47dd65c33e3151344eb3267bf42efba17d1415425f07ed96185d67fc04d9", "dependencies": [ - "jsr:@std/assert@^1.0.13", - "jsr:@std/internal@^1.0.7" - ] - }, - "@std/fmt@0.223.0": { - "integrity": "6deb37794127dfc7d7bded2586b9fc6f5d50e62a8134846608baf71ffc1a5208" - }, - "@std/fmt@1.0.8": { - "integrity": "71e1fc498787e4434d213647a6e43e794af4fd393ef8f52062246e06f7e372b7" - }, - "@std/fs@0.223.0": { - "integrity": "3b4b0550b2c524cbaaa5a9170c90e96cbb7354e837ad1bdaf15fc9df1ae9c31c" - }, - "@std/fs@0.229.3": { - "integrity": "783bca21f24da92e04c3893c9e79653227ab016c48e96b3078377ebd5222e6eb", - "dependencies": [ - "jsr:@std/path@1.0.0-rc.1" - ] - }, - "@std/fs@1.0.19": { - "integrity": "051968c2b1eae4d2ea9f79a08a3845740ef6af10356aff43d3e2ef11ed09fb06", - "dependencies": [ - "jsr:@std/internal@^1.0.9", - "jsr:@std/path@^1.1.1" + "jsr:@std/assert@^1.0.14", + "jsr:@std/internal@^1.0.10" ] }, "@std/internal@1.0.8": { "integrity": "fc66e846d8d38a47cffd274d80d2ca3f0de71040f855783724bb6b87f60891f5" }, - "@std/internal@1.0.10": { - "integrity": "e3be62ce42cab0e177c27698e5d9800122f67b766a0bea6ca4867886cbde8cf7" - }, - "@std/io@0.223.0": { - "integrity": "2d8c3c2ab3a515619b90da2c6ff5ea7b75a94383259ef4d02116b228393f84f1", - "dependencies": [ - "jsr:@std/assert@0.223", - "jsr:@std/bytes" - ] - }, - "@std/path@0.223.0": { - "integrity": "593963402d7e6597f5a6e620931661053572c982fc014000459edc1f93cc3989", - "dependencies": [ - "jsr:@std/assert@0.223" - ] - }, - "@std/path@0.225.2": { - "integrity": "0f2db41d36b50ef048dcb0399aac720a5348638dd3cb5bf80685bf2a745aa506", - "dependencies": [ - "jsr:@std/assert@0.226" - ] - }, - "@std/path@1.0.0-rc.1": { - "integrity": "b8c00ae2f19106a6bb7cbf1ab9be52aa70de1605daeb2dbdc4f87a7cbaf10ff6" - }, - "@std/path@1.1.1": { - "integrity": "fe00026bd3a7e6a27f73709b83c607798be40e20c81dde655ce34052fd82ec76", - "dependencies": [ - "jsr:@std/internal@^1.0.9" - ] - }, - "@std/testing@1.0.15": { - "integrity": "a490169f5ccb0f3ae9c94fbc69d2cd43603f2cffb41713a85f99bbb0e3087cbc", - "dependencies": [ - "jsr:@std/assert@^1.0.13", - "jsr:@std/data-structures", - "jsr:@std/fs@^1.0.19", - "jsr:@std/internal@^1.0.10", - "jsr:@std/path@^1.1.1" - ] + "@std/internal@1.0.12": { + "integrity": "972a634fd5bc34b242024402972cd5143eac68d8dffaca5eaa4dba30ce17b027" }, - "@ts-morph/bootstrap@0.24.0": { - "integrity": "a826a2ef7fa8a7c3f1042df2c034d20744d94da2ee32bf29275bcd4dffd3c060", + "@std/testing@1.0.17": { + "integrity": "87bdc2700fa98249d48a17cd72413352d3d3680dcfbdb64947fd0982d6bbf681", "dependencies": [ - "jsr:@ts-morph/common@0.24" - ] - }, - "@ts-morph/bootstrap@0.27.0": { - "integrity": "b8d7bc8f7942ce853dde4161b28f9aa96769cef3d8eebafb379a81800b9e2448", - "dependencies": [ - "jsr:@ts-morph/common@0.27" - ] - }, - "@ts-morph/common@0.24.0": { - "integrity": "12b625b8e562446ba658cdbe9ad77774b4bd96b992ae8bd34c60dbf24d06c1f3", - "dependencies": [ - "jsr:@std/fs@~0.229.3", - "jsr:@std/path@~0.225.2" - ] - }, - "@ts-morph/common@0.27.0": { - "integrity": "c7b73592d78ce8479b356fd4f3d6ec3c460d77753a8680ff196effea7a939052", - "dependencies": [ - "jsr:@std/fs@1", - "jsr:@std/path@1" + "jsr:@std/assert@^1.0.17", + "jsr:@std/internal@^1.0.12" ] } }, @@ -208,6 +49,9 @@ "@ark/util@0.46.0": { "integrity": "sha512-JPy/NGWn/lvf1WmGCPw2VGpBg5utZraE84I7wli18EDF3p3zc/e9WolT35tINeZO3l7C77SjqRJeAUoT0CvMRg==" }, + "@standard-schema/spec@1.1.0": { + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==" + }, "arktype@2.1.20": { "integrity": "sha512-IZCEEXaJ8g+Ijd59WtSYwtjnqXiwM8sWQ5EjGamcto7+HVN9eK0C4p0zDlCuAwWhpqr6fIBkxPuYDl4/Mcj/+Q==", "dependencies": [ @@ -215,9 +59,6 @@ "@ark/util" ] }, - "sprintf-js@1.1.3": { - "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==" - }, "ts-case-convert@2.1.0": { "integrity": "sha512-Ye79el/pHYXfoew6kqhMwCoxp4NWjKNcm2kBzpmEMIU9dd9aBmHNNFtZ+WTm0rz1ngyDmfqDXDlyUnBXayiD0w==" } @@ -225,13 +66,10 @@ "workspace": { "dependencies": [ "jsr:@deno/dnt@0.42.3", - "jsr:@standard-schema/spec@1", - "jsr:@std/assert@1", - "jsr:@std/cli@^1.0.21", "jsr:@std/expect@^1.0.16", "jsr:@std/testing@^1.0.15", + "npm:@standard-schema/spec@1", "npm:arktype@^2.1.20", - "npm:sprintf-js@^1.1.3", "npm:ts-case-convert@^2.1.0" ] } diff --git a/examples/commands.ts b/examples/commands.ts index f7fbbb9..abdbef8 100644 --- a/examples/commands.ts +++ b/examples/commands.ts @@ -1,4 +1,4 @@ -import { assert } from "@std/assert/assert"; +import assert from "node:assert"; import { type } from "arktype"; import { cli, field } from "../lib/field.ts"; import { object } from "../lib/object.ts"; diff --git a/examples/phased-commands.ts b/examples/phased-commands.ts index 68ce2f3..d853291 100644 --- a/examples/phased-commands.ts +++ b/examples/phased-commands.ts @@ -1,4 +1,4 @@ -import { assert } from "@std/assert/assert"; +import assert from "node:assert"; import { type } from "arktype"; import { cli, field } from "../lib/field.ts"; import { object } from "../lib/object.ts"; diff --git a/examples/simple.ts b/examples/simple.ts index 43ba984..36da280 100644 --- a/examples/simple.ts +++ b/examples/simple.ts @@ -1,4 +1,4 @@ -import { assert } from "@std/assert/assert"; +import assert from "node:assert"; import { type } from "arktype"; import { cli, field } from "../lib/field.ts"; import { object } from "../lib/object.ts"; diff --git a/lib/mod.ts b/lib/mod.ts index 69c38df..6556f53 100644 --- a/lib/mod.ts +++ b/lib/mod.ts @@ -3,7 +3,6 @@ export * from "./constant.ts"; export * from "./field.ts"; export * from "./object.ts"; export * from "./commands.ts"; -export * from "./parse.ts"; export * from "./help.ts"; export * from "./program.ts"; export * from "./sequence.ts"; diff --git a/lib/parse.ts b/lib/parse.ts deleted file mode 100644 index 4046889..0000000 --- a/lib/parse.ts +++ /dev/null @@ -1,14 +0,0 @@ -import assert from "node:assert"; -import type { Done, Fail, Input, Parser, Step } from "./types.ts"; - -export function parseSync( - parser: Parser<[Step]>, - input: Input = {}, -): Done | Fail { - let result = parser.parse(input); - assert( - !("parse" in result && typeof result.parse === "function"), - "parser did not complete in a single step", - ); - return result; -} diff --git a/lib/program.ts b/lib/program.ts index 97137e4..768495a 100644 --- a/lib/program.ts +++ b/lib/program.ts @@ -1,7 +1,7 @@ import type { AnyStep, Input, Parser } from "./types.ts"; import { object } from "./object.ts"; import { format, inspect } from "./help.ts"; -import { assert } from "@std/assert"; +import assert from "node:assert"; export interface Program

> { name: string; diff --git a/test/field.test.ts b/test/field.test.ts index fad2cf0..5eaf9e5 100644 --- a/test/field.test.ts +++ b/test/field.test.ts @@ -2,9 +2,9 @@ import { describe, it } from "@std/testing/bdd"; import { expect } from "@std/expect"; import { type } from "arktype"; import { field } from "../lib/field.ts"; -import { assert } from "@std/assert/assert"; +import assert from "node:assert"; import { ValidationError } from "../lib/validate.ts"; -import { parseSync } from "../lib/parse.ts"; +import { parseSync } from "./test-helpers.ts"; describe("field", () => { describe("from js", () => { diff --git a/test/help.test.ts b/test/help.test.ts index 345c3e5..99401eb 100644 --- a/test/help.test.ts +++ b/test/help.test.ts @@ -4,7 +4,7 @@ import { type } from "arktype"; import { cli, field } from "../lib/field.ts"; import { type Attrs, object } from "../lib/object.ts"; import type { Input } from "../lib/types.ts"; -import { parseSync } from "../lib/parse.ts"; +import { parseSync } from "./test-helpers.ts"; import { format, inspect } from "../lib/help.ts"; function exam(attrs: Attrs, input?: Input): string { diff --git a/test/object.test.ts b/test/object.test.ts index 347b1da..7e8171d 100644 --- a/test/object.test.ts +++ b/test/object.test.ts @@ -3,11 +3,10 @@ import { expect } from "@std/expect"; import { type } from "arktype"; import { object } from "../lib/object.ts"; import { cli, field } from "../lib/field.ts"; -import { assert } from "@std/assert"; +import assert from "node:assert"; import { ValidationError } from "../lib/validate.ts"; import { ObjectValidationError } from "../lib/object.ts"; -import { parseSync } from "../lib/parse.ts"; -import { parseNotOk, parseOk } from "./test-helpers.ts"; +import { parseNotOk, parseOk, parseSync } from "./test-helpers.ts"; describe("object", () => { let configuration = object({ diff --git a/test/sequence.test.ts b/test/sequence.test.ts index f82a266..61c4e92 100644 --- a/test/sequence.test.ts +++ b/test/sequence.test.ts @@ -1,6 +1,6 @@ import { describe, it } from "@std/testing/bdd"; import { expect } from "@std/expect"; -import { assert } from "@std/assert/assert"; +import assert from "node:assert"; import { type } from "arktype"; import { cli, field } from "../lib/field.ts"; import { object } from "../lib/object.ts"; diff --git a/test/test-helpers.ts b/test/test-helpers.ts index a327e5a..daf1953 100644 --- a/test/test-helpers.ts +++ b/test/test-helpers.ts @@ -1,6 +1,5 @@ -import { assert } from "@std/assert/assert"; -import type { Input, Parser, Step } from "../lib/types.ts"; -import { parseSync } from "../lib/parse.ts"; +import assert from "node:assert"; +import type { Done, Fail, Input, Parser, Step } from "../lib/types.ts"; export function parseOk( parser: Parser<[Step]>, @@ -19,3 +18,15 @@ export function parseNotOk( assert(!result.ok, "expected parse to fail, but succeeded"); return result.error; } + +export function parseSync( + parser: Parser<[Step]>, + input: Input = {}, +): Done | Fail { + let result = parser.parse(input); + assert( + !("parse" in result && typeof result.parse === "function"), + "parser did not complete in a single step", + ); + return result; +}