Skip to content

Commit 21a106f

Browse files
committed
refactor: simplify jsr package
1 parent a3f7f51 commit 21a106f

File tree

12 files changed

+39
-31
lines changed

12 files changed

+39
-31
lines changed

.github/demos/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expandGlob, joinGlobs } from "../../deps.dev.ts";
2-
import { $ } from "../../deps.ts";
1+
import { expandGlob, joinGlobs } from "../../src/deps.dev.ts";
2+
import { $ } from "../../src/deps.ts";
33
import { invariant } from "../../src/util.ts";
44

55
const root = $.relativePath(import.meta.url, "..", "..");

.hooks/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env -S deno run -A
22

3-
import { equals, greaterThan, parse } from "../deps.dev.ts";
4-
import { $, colors } from "../deps.ts";
5-
import { daxVersion, version } from "../mod.ts";
3+
import { equals, greaterThan, parse } from "../src/deps.dev.ts";
4+
import { $, colors } from "../src/deps.ts";
5+
import { daxVersion, version } from "../src/cli.ts";
66

77
const root = $.relativePath(import.meta.url, "..");
88

.hooks/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env -S deno run -A
22

3-
import { $ } from "../deps.ts";
3+
import { $ } from "../src/deps.ts";
44

55
const root = $.relativePath(import.meta.url, "..");
66

deno.jsonc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
{
22
"name": "@andrewbrey/mdrb",
33
"version": "3.0.2",
4-
"exports": "./mod.ts",
4+
"exports": "./src/cli.ts",
5+
"publish": {
6+
"include": [
7+
"LICENSE",
8+
"README.md",
9+
"demo.md",
10+
"src/**/*.ts"
11+
]
12+
},
513
"fmt": { "lineWidth": 120, "useTabs": true, "exclude": [".deno_cache", "deno.lock"] },
614
"lint": { "exclude": [".deno_cache", "deno.lock"] },
715
"tasks": {
816
"test": "deno test -A --no-check",
9-
"lint": "deno check mod.ts && deno lint && deno fmt --check",
17+
"lint": "deno check **/*.ts && deno lint && deno fmt --check",
1018
// Bump dependencies using @molt/cli (https://jsr.io/@molt/cli) - may prompt for read perms on ~/.local/share/deno-wasmbuild
1119
"deps": "deno run -E=XDG_DATA_HOME,HOME,GITHUB_TOKEN -R='./' -W=deno.jsonc -N=api.jsr.io,jsr.io,deno.land,registry.npmjs.org,esm.sh jsr:@molt/cli --write deno.jsonc",
1220
"demos": "deno run -A .github/demos/generate.ts",

mod.test.ts renamed to src/cli.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { assertEquals, assertRejects, assertStringIncludes } from "./deps.dev.ts";
22
import { $, CommandBuilder } from "./deps.ts";
33

4-
const mod = $.relativePath(import.meta.url, "mod.ts");
5-
const demo = $.relativePath(import.meta.url, "demo.md");
4+
const cli = $.relativePath(import.meta.url, "cli.ts");
5+
const demo = $.relativePath(import.meta.url, "..", "demo.md");
66
const demoText = Deno.readTextFileSync(demo);
77

88
const t$ = $.build$({
@@ -55,7 +55,7 @@ function withServer(action: (serverUrl: URL) => Promise<void>) {
5555
}
5656

5757
Deno.test("mdrb works with local file", async () => {
58-
const { combined } = await t$`deno run -A ${mod} ${demo}`.stdinText("");
58+
const { combined } = await t$`deno run -A ${cli} ${demo}`.stdinText("");
5959

6060
const expected = $.dedent`
6161
step 1 of 3 // say hello to the world
@@ -75,7 +75,7 @@ Deno.test("mdrb works with local file", async () => {
7575
});
7676

7777
Deno.test("mdrb shows error output for local file if no file exists", async () => {
78-
const { combined, code } = await t$`deno run -A ${mod} ./does-not-exist.md`.stdinText("");
78+
const { combined, code } = await t$`deno run -A ${cli} ./does-not-exist.md`.stdinText("");
7979

8080
assertEquals(code, 2);
8181
assertStringIncludes(combined, "no file exists at ./does-not-exist.md");
@@ -84,7 +84,7 @@ Deno.test("mdrb shows error output for local file if no file exists", async () =
8484
Deno.test("mdrb shows error output for local file if text read", async () => {
8585
const file = await Deno.makeTempFile({ prefix: "mdrb-test_", suffix: ".md" });
8686

87-
const { combined, code } = await t$`deno run -A ${mod} ${file}`.stdinText("");
87+
const { combined, code } = await t$`deno run -A ${cli} ${file}`.stdinText("");
8888

8989
assertEquals(code, 2);
9090
assertStringIncludes(combined, `no code to run for ${file}`);
@@ -94,7 +94,7 @@ Deno.test("mdrb works with http", async () => {
9494
await withServer(async (serverURL) => {
9595
const url = new URL("/demo", serverURL);
9696

97-
const { combined } = await t$`deno run -A ${mod} ${url}`.stdinText("");
97+
const { combined } = await t$`deno run -A ${cli} ${url}`.stdinText("");
9898

9999
const expected = $.dedent`
100100
step 1 of 3 // say hello to the world
@@ -118,15 +118,15 @@ Deno.test("mdrb shows error output for http if no text served", async () => {
118118
await withServer(async (serverURL) => {
119119
const url = new URL("/does-not-exist", serverURL);
120120

121-
const { combined, code } = await t$`deno run -A ${mod} ${url}`.stdinText("");
121+
const { combined, code } = await t$`deno run -A ${cli} ${url}`.stdinText("");
122122

123123
assertEquals(code, 2);
124124
assertStringIncludes(combined, "no code to run for http://localhost");
125125
});
126126
});
127127

128128
Deno.test("mdrb works with stdin", async () => {
129-
const { combined } = await t$`deno run -A ${mod}`.stdinText(demoText);
129+
const { combined } = await t$`deno run -A ${cli}`.stdinText(demoText);
130130

131131
const expected = $.dedent`
132132
step 1 of 3 // say hello to the world
@@ -146,7 +146,7 @@ Deno.test("mdrb works with stdin", async () => {
146146
});
147147

148148
Deno.test("mdrb shows error output for stdin if no text piped", async () => {
149-
const { combined, code } = await t$`deno run -A ${mod}`.stdinText("");
149+
const { combined, code } = await t$`deno run -A ${cli}`.stdinText("");
150150

151151
assertEquals(code, 2);
152152
assertStringIncludes(combined, "no code to run from stdin");
@@ -157,7 +157,7 @@ Deno.test(
157157
async () => {
158158
const timeout = 3_000;
159159

160-
await t$`deno run -A ${mod} --mode runbook`.stdinText(demoText)
160+
await t$`deno run -A ${cli} --mode runbook`.stdinText(demoText)
161161
.timeout(timeout).noThrow(false);
162162
},
163163
);
@@ -169,7 +169,7 @@ Deno.test("$ is defined by default", async () => {
169169
~~~
170170
`;
171171

172-
const { combined } = await t$`deno run -A ${mod}`
172+
const { combined } = await t$`deno run -A ${cli}`
173173
.stdinText(md);
174174

175175
assertStringIncludes(combined, "$ is function");
@@ -182,7 +182,7 @@ Deno.test("$ is undefined if dax integration disabled", async () => {
182182
~~~
183183
`;
184184

185-
const { combined } = await t$`deno run -A ${mod} --dax=false`
185+
const { combined } = await t$`deno run -A ${cli} --dax=false`
186186
.stdinText(md);
187187

188188
assertStringIncludes(combined, "$ is undefined");
@@ -201,7 +201,7 @@ Deno.test("single mode throws if blocks are incompatible", async () => {
201201
~~~
202202
`;
203203

204-
await t$`deno run -A ${mod} --mode=single`.stdinText(md).noThrow(false);
204+
await t$`deno run -A ${cli} --mode=single`.stdinText(md).noThrow(false);
205205
});
206206
});
207207

@@ -216,7 +216,7 @@ Deno.test("summary is printed if one is available", async () => {
216216
~~~
217217
`;
218218

219-
const { combined } = await t$`deno run -A ${mod}`
219+
const { combined } = await t$`deno run -A ${cli}`
220220
.stdinText(md);
221221

222222
assertStringIncludes(combined, `step 1 of 1 // ${summary}`);
@@ -233,7 +233,7 @@ Deno.test("summary is not printed if one is not available", async () => {
233233
~~~
234234
`;
235235

236-
const { stderr } = await t$`deno run -A ${mod}`
236+
const { stderr } = await t$`deno run -A ${cli}`
237237
.captureCombined(false).stdinText(md);
238238

239239
assertEquals(stderr.trim(), "step 1 of 1");

mod.ts renamed to src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { $, colors, Command, EnumType, readAll, ValidationError } from "./deps.ts";
2-
import { type CodeBlock, mdCodeBlocks, renderMDToString } from "./src/markdown.ts";
3-
import { invariant, toFileURL } from "./src/util.ts";
2+
import { type CodeBlock, mdCodeBlocks, renderMDToString } from "./markdown.ts";
3+
import { invariant, toFileURL } from "./util.ts";
44

55
/* Current version of MDRB */
66
export const version = "3.0.2";
File renamed without changes.

deps.ts renamed to src/deps.ts

File renamed without changes.

src/markdown.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { assertEquals } from "../deps.dev.ts";
2-
import { $ } from "../deps.ts";
1+
import { assertEquals } from "./deps.dev.ts";
2+
import { $ } from "./deps.ts";
33
import { fileProtocolifyLocalImports, mdCodeBlocks, replaceImportMeta } from "./markdown.ts";
44

55
const FENCE = "```";

src/markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { $, colors, type Extension, renderMarkdown } from "../deps.ts";
1+
import { $, colors, type Extension, renderMarkdown } from "./deps.ts";
22

33
export type CodeBlock = {
44
idx: number;

src/util.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { assertEquals, assertInstanceOf, assertThrows } from "../deps.dev.ts";
2-
import { $, POSIX_SEP, SEP } from "../deps.ts";
1+
import { assertEquals, assertInstanceOf, assertThrows } from "./deps.dev.ts";
2+
import { $, POSIX_SEP, SEP } from "./deps.ts";
33
import { invariant, toFileURL } from "./util.ts";
44

55
Deno.test("invariant throws if condition false", () => {

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { $, POSIX_SEP, SEP } from "../deps.ts";
1+
import { $, POSIX_SEP, SEP } from "./deps.ts";
22

33
/** Enforce that a condition is true, and narrow types based on the assertion */
44
export function invariant(

0 commit comments

Comments
 (0)