From ed6f47045f983c0a737324a8d814df0865b41b7e Mon Sep 17 00:00:00 2001 From: Marais Rossouw Date: Fri, 6 Sep 2024 13:02:36 +1000 Subject: [PATCH] :construction: WIP --- deno.json | 3 +++ lib/mod.test.ts | 4 ++-- lib/mod.ts | 2 +- lib/output.console.ts | 4 ++-- lib/stream.test.ts | 3 ++- lib/stream.ts | 2 +- lib/using.test.ts | 3 ++- lib/using.ts | 2 +- lib/utils.test.ts | 3 ++- scripts/build.ts | 6 ++---- 10 files changed, 18 insertions(+), 14 deletions(-) diff --git a/deno.json b/deno.json index a1540a1..6f35d35 100644 --- a/deno.json +++ b/deno.json @@ -12,6 +12,9 @@ "./utils": "./lib/utils.ts" }, "imports": { + "diary": "./lib/mod.ts", + "diary/utils": "./lib/utils.ts", + "@std/assert": "jsr:@std/assert@^1", "@std/async": "jsr:@std/async@^1", "@std/testing": "jsr:@std/testing@^1", diff --git a/lib/mod.test.ts b/lib/mod.test.ts index 7302062..aaa35cf 100644 --- a/lib/mod.test.ts +++ b/lib/mod.test.ts @@ -1,8 +1,8 @@ import { assertInstanceOf } from '@std/assert'; import { assertSpyCall, spy } from '@std/testing/mock'; -import type { Level } from '../lib/mod.ts'; -import * as lib from '../lib/mod.ts'; +import type { Level } from 'diary'; +import * as lib from 'diary'; Deno.test('api', () => { assertInstanceOf(lib.diary, Function); diff --git a/lib/mod.ts b/lib/mod.ts index feafd44..40eaff4 100644 --- a/lib/mod.ts +++ b/lib/mod.ts @@ -1,4 +1,4 @@ -import type { Dict, Pretty, Props } from './utils.ts'; +import type { Dict, Pretty, Props } from 'diary/utils'; /** * TODO diff --git a/lib/output.console.ts b/lib/output.console.ts index 3563fd4..d3b4f0a 100644 --- a/lib/output.console.ts +++ b/lib/output.console.ts @@ -1,5 +1,5 @@ -import type { Level } from './mod.ts'; -import { interpolate } from './utils.ts'; +import type { Level } from 'diary'; +import { interpolate } from 'diary/utils'; import { blue, bold, gray, magenta, red, yellow } from 'kleur/colors'; diff --git a/lib/stream.test.ts b/lib/stream.test.ts index 40db017..746efc0 100644 --- a/lib/stream.test.ts +++ b/lib/stream.test.ts @@ -1,7 +1,8 @@ import { assertEquals, assertInstanceOf } from '@std/assert'; import { delay } from '@std/async'; + import * as stream from './stream.ts'; -import * as lib from './mod.ts'; +import * as lib from 'diary'; Deno.test('api', () => { assertInstanceOf(lib.diary, Function); diff --git a/lib/stream.ts b/lib/stream.ts index 5bd9767..b21a535 100644 --- a/lib/stream.ts +++ b/lib/stream.ts @@ -1,4 +1,4 @@ -import * as lib from './mod.ts'; +import * as lib from "diary"; export function diary( cb: (r: ReadableStream) => any, diff --git a/lib/using.test.ts b/lib/using.test.ts index 6a58fd3..9896076 100644 --- a/lib/using.test.ts +++ b/lib/using.test.ts @@ -1,8 +1,9 @@ import { assertInstanceOf } from '@std/assert'; -import * as lib from './using.ts'; import { assertSpyCall, spy } from '@std/testing/mock'; import { delay } from '@std/async'; +import * as lib from './using.ts'; + Deno.test('api', () => { assertInstanceOf(lib.diary, Function); }); diff --git a/lib/using.ts b/lib/using.ts index f2db3f2..c1526ae 100644 --- a/lib/using.ts +++ b/lib/using.ts @@ -1,4 +1,4 @@ -import * as lib from './mod.ts'; +import * as lib from 'diary'; export interface Diary extends lib.Diary { [Symbol.dispose](): void; diff --git a/lib/utils.test.ts b/lib/utils.test.ts index 7d6dd35..fa5b42a 100644 --- a/lib/utils.test.ts +++ b/lib/utils.test.ts @@ -1,5 +1,6 @@ import { assertEquals } from '@std/assert'; -import * as lib from './utils.ts'; + +import * as lib from 'diary/utils'; Deno.test('api', () => { assertEquals(lib.interpolate('hello {name}', { name: 'world' }), 'hello world'); diff --git a/scripts/build.ts b/scripts/build.ts index f8a5a65..fb764a4 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -29,13 +29,11 @@ async function transform(name: string, filename: string) { let outfile = `${outdir}/${name}.d.ts`; console.log('> writing "%s" file', outfile); - let outsource = xform.declaration!.replaceAll(/\.ts/g, '.js'); - await Deno.writeTextFile(outfile, outsource); + await Deno.writeTextFile(outfile, xform.declaration!); outfile = `${outdir}/${name}.js`; console.log('> writing "%s" file', outfile); - outsource = xform.sourceText.replaceAll(/\.ts/g, '.js'); - await Deno.writeTextFile(outfile, outsource); + await Deno.writeTextFile(outfile, xform.sourceText); } if (exists(outdir)) {