From a60fc09b043e5d55f229666564edce59336f2054 Mon Sep 17 00:00:00 2001 From: Andrew Brey <34140052+andrewbrey@users.noreply.github.com> Date: Sat, 19 Oct 2024 12:45:42 -0700 Subject: [PATCH] chore: prepare jsr package --- .hooks/pre-commit | 24 ++++++++++++++++++++---- deno.jsonc | 3 +++ deps.dev.ts | 2 +- mod.ts | 5 ++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.hooks/pre-commit b/.hooks/pre-commit index f3eb755..cf27d17 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -1,16 +1,32 @@ #!/usr/bin/env -S deno run -A -import { greaterThan, parse } from "../deps.dev.ts"; +import { equals, greaterThan, parse } from "../deps.dev.ts"; import { $, colors } from "../deps.ts"; import { daxVersion, version } from "../mod.ts"; const root = $.relativePath(import.meta.url, ".."); const latestTag = await $`git describe --tags --abbrev=0`.cwd(root).text(); -const depsDaxVersion = Deno.readTextFileSync($.path(root).join("deno.jsonc").toString()) - .match(/@david\/dax@([^"]+)/)?.at(1) ?? ""; +const denoJson = Deno.readTextFileSync($.path(root).join("deno.jsonc").toString()); -const nextIsNewer = greaterThan(parse(version), parse(latestTag)); +const configVersion = denoJson.match(/version\": \"([^"]+)\"/)?.at(1) ?? ""; +const depsDaxVersion = denoJson.match(/@david\/dax@([^"]+)/)?.at(1) ?? ""; + +const parsedCliVersion = parse(version); +const parsedCfgVersion = parse(configVersion); +const parsedGitVersion = parse(latestTag); + +const cliAndCfgMatch = equals(parsedCliVersion, parsedCfgVersion); +if (!cliAndCfgMatch) { + throw new Error($.dedent` + ${colors.red(`mod.ts version and deno.jsonc version do not match`)} + + Deno config "version" is ${colors.yellow(configVersion)} and mod.ts "version" is set to ${colors.blue(version)} + + `); +} + +const nextIsNewer = greaterThan(parsedCliVersion, parsedGitVersion); if (!nextIsNewer) { throw new Error($.dedent` ${colors.red(`mod.ts version is out of date`)} diff --git a/deno.jsonc b/deno.jsonc index da9b7f2..ffdff25 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,4 +1,7 @@ { + "name": "@andrewbrey/mdrb", + "version": "3.0.1", + "exports": "./mod.ts", "fmt": { "lineWidth": 120, "useTabs": true, "exclude": [".deno_cache", "deno.lock"] }, "lint": { "exclude": [".deno_cache", "deno.lock"] }, "tasks": { diff --git a/deps.dev.ts b/deps.dev.ts index 7ee1e04..f1847bc 100644 --- a/deps.dev.ts +++ b/deps.dev.ts @@ -1,4 +1,4 @@ export { assertEquals, assertInstanceOf, assertRejects, assertStringIncludes, assertThrows } from "@std/assert"; export { expandGlob } from "@std/fs"; export { joinGlobs } from "@std/path"; -export { greaterThan, parse } from "@std/semver"; +export { equals, greaterThan, parse } from "@std/semver"; diff --git a/mod.ts b/mod.ts index 2fc77d9..f336902 100644 --- a/mod.ts +++ b/mod.ts @@ -2,7 +2,10 @@ import { $, colors, Command, EnumType, readAll, ValidationError } from "./deps.t import { type CodeBlock, mdCodeBlocks, renderMDToString } from "./src/markdown.ts"; import { invariant, toFileURL } from "./src/util.ts"; -export const version = "3.0.0"; +/* Current version of MDRB */ +export const version = "3.0.1"; + +/* Bundled version of `@david/dax` */ export const daxVersion = "0.42.0"; if (import.meta.main) {