Skip to content

Commit

Permalink
chore: prepare jsr package
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbrey committed Oct 19, 2024
1 parent bd8639f commit a60fc09
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
24 changes: 20 additions & 4 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -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`)}
Expand Down
3 changes: 3 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion deps.dev.ts
Original file line number Diff line number Diff line change
@@ -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";
5 changes: 4 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a60fc09

Please sign in to comment.