From 3fcae77c60a0759366525d506b26f317fb1fe567 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Mon, 24 Mar 2025 08:30:22 +1100 Subject: [PATCH 01/27] Use latest jsr std crypto --- deno.lock | 40 +++++++++++++++++++++++++++++++++++++++- deps.ts | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/deno.lock b/deno.lock index f8dbbd0..d35d649 100644 --- a/deno.lock +++ b/deno.lock @@ -1,9 +1,46 @@ { - "version": "3", + "version": "4", + "specifiers": { + "jsr:@std/crypto@*": "1.0.4", + "jsr:@std/crypto@1.0.4": "1.0.4" + }, + "jsr": { + "@std/crypto@1.0.4": { + "integrity": "cee245c453bd5366207f4d8aa25ea3e9c86cecad2be3fefcaa6cb17203d79340" + } + }, "remote": { + "https://deno.land/std@0.221.0/assert/_constants.ts": "a271e8ef5a573f1df8e822a6eb9d09df064ad66a4390f21b3e31f820a38e0975", + "https://deno.land/std@0.221.0/assert/_diff.ts": "4bf42969aa8b1a33aaf23eb8e478b011bfaa31b82d85d2ff4b5c4662d8780d2b", + "https://deno.land/std@0.221.0/assert/_format.ts": "0ba808961bf678437fb486b56405b6fefad2cf87b5809667c781ddee8c32aff4", "https://deno.land/std@0.221.0/assert/assert.ts": "bec068b2fccdd434c138a555b19a2c2393b71dfaada02b7d568a01541e67cdc5", + "https://deno.land/std@0.221.0/assert/assert_almost_equals.ts": "8b96b7385cc117668b0720115eb6ee73d04c9bcb2f5d2344d674918c9113688f", + "https://deno.land/std@0.221.0/assert/assert_array_includes.ts": "1688d76317fd45b7e93ef9e2765f112fdf2b7c9821016cdfb380b9445374aed1", + "https://deno.land/std@0.221.0/assert/assert_equals.ts": "4497c56fe7d2993b0d447926702802fc0becb44e319079e8eca39b482ee01b4e", "https://deno.land/std@0.221.0/assert/assert_exists.ts": "24a7bf965e634f909242cd09fbaf38bde6b791128ece08e33ab08586a7cc55c9", + "https://deno.land/std@0.221.0/assert/assert_false.ts": "6f382568e5128c0f855e5f7dbda8624c1ed9af4fcc33ef4a9afeeedcdce99769", + "https://deno.land/std@0.221.0/assert/assert_greater.ts": "4945cf5729f1a38874d7e589e0fe5cc5cd5abe5573ca2ddca9d3791aa891856c", + "https://deno.land/std@0.221.0/assert/assert_greater_or_equal.ts": "573ed8823283b8d94b7443eb69a849a3c369a8eb9666b2d1db50c33763a5d219", + "https://deno.land/std@0.221.0/assert/assert_instance_of.ts": "72dc1faff1e248692d873c89382fa1579dd7b53b56d52f37f9874a75b11ba444", + "https://deno.land/std@0.221.0/assert/assert_is_error.ts": "6596f2b5ba89ba2fe9b074f75e9318cda97a2381e59d476812e30077fbdb6ed2", + "https://deno.land/std@0.221.0/assert/assert_less.ts": "2b4b3fe7910f65f7be52212f19c3977ecb8ba5b2d6d0a296c83cde42920bb005", + "https://deno.land/std@0.221.0/assert/assert_less_or_equal.ts": "b93d212fe669fbde959e35b3437ac9a4468f2e6b77377e7b6ea2cfdd825d38a0", + "https://deno.land/std@0.221.0/assert/assert_match.ts": "ec2d9680ed3e7b9746ec57ec923a17eef6d476202f339ad91d22277d7f1d16e1", + "https://deno.land/std@0.221.0/assert/assert_not_equals.ts": "ac86413ab70ffb14fdfc41740ba579a983fe355ba0ce4a9ab685e6b8e7f6a250", + "https://deno.land/std@0.221.0/assert/assert_not_instance_of.ts": "8f720d92d83775c40b2542a8d76c60c2d4aeddaf8713c8d11df8984af2604931", + "https://deno.land/std@0.221.0/assert/assert_not_match.ts": "b4b7c77f146963e2b673c1ce4846473703409eb93f5ab0eb60f6e6f8aeffe39f", + "https://deno.land/std@0.221.0/assert/assert_not_strict_equals.ts": "da0b8ab60a45d5a9371088378e5313f624799470c3b54c76e8b8abeec40a77be", + "https://deno.land/std@0.221.0/assert/assert_object_match.ts": "e85e5eef62a56ce364c3afdd27978ccab979288a3e772e6855c270a7b118fa49", + "https://deno.land/std@0.221.0/assert/assert_rejects.ts": "5206ac37d883797d9504e3915a0c7b692df6efcdefff3889cc14bb5a325641dd", + "https://deno.land/std@0.221.0/assert/assert_strict_equals.ts": "0425a98f70badccb151644c902384c12771a93e65f8ff610244b8147b03a2366", + "https://deno.land/std@0.221.0/assert/assert_string_includes.ts": "dfb072a890167146f8e5bdd6fde887ce4657098e9f71f12716ef37f35fb6f4a7", + "https://deno.land/std@0.221.0/assert/assert_throws.ts": "31f3c061338aec2c2c33731973d58ccd4f14e42f355501541409ee958d2eb8e5", "https://deno.land/std@0.221.0/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8", + "https://deno.land/std@0.221.0/assert/equal.ts": "fae5e8a52a11d3ac694bbe1a53e13a7969e3f60791262312e91a3e741ae519e2", + "https://deno.land/std@0.221.0/assert/fail.ts": "f310e51992bac8e54f5fd8e44d098638434b2edb802383690e0d7a9be1979f1c", + "https://deno.land/std@0.221.0/assert/mod.ts": "7e41449e77a31fef91534379716971bebcfc12686e143d38ada5438e04d4a90e", + "https://deno.land/std@0.221.0/assert/unimplemented.ts": "47ca67d1c6dc53abd0bd729b71a31e0825fc452dbcd4fde4ca06789d5644e7fd", + "https://deno.land/std@0.221.0/assert/unreachable.ts": "3670816a4ab3214349acb6730e3e6f5299021234657eefe05b48092f3848c270", "https://deno.land/std@0.221.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs": "f65ea775c52c5641f0154d98d6059e261ca3dc917a8856209d60bc6cb406e699", "https://deno.land/std@0.221.0/crypto/_wasm/mod.ts": "e89fbbc3c4722602ff975dd85f18273c7741ec766a9b68f6de4fd1d9876409f8", "https://deno.land/std@0.221.0/crypto/crypto.ts": "7ccd24e766d026d92ee1260b5a1639624775e94456d2a95c3a42fd3d49df78ab", @@ -128,6 +165,7 @@ "https://deno.land/std@0.221.0/path/windows/resolve.ts": "8dae1dadfed9d46ff46cc337c9525c0c7d959fb400a6308f34595c45bdca1972", "https://deno.land/std@0.221.0/path/windows/to_file_url.ts": "40e560ee4854fe5a3d4d12976cef2f4e8914125c81b11f1108e127934ced502e", "https://deno.land/std@0.221.0/path/windows/to_namespaced_path.ts": "4ffa4fb6fae321448d5fe810b3ca741d84df4d7897e61ee29be961a6aac89a4c", + "https://deno.land/std@0.221.0/testing/asserts.ts": "0cb9c745d9b157bed062a4aa8647168d2221f6456c385a548b0ca24de9e0f3ca", "https://deno.land/x/semver@v1.4.1/mod.ts": "0b79c87562eb8a1f008ab0d98f8bb60076dd65bc06f1f8fdfac2d2dab162c27b" } } diff --git a/deps.ts b/deps.ts index 3b31d86..69d6c83 100644 --- a/deps.ts +++ b/deps.ts @@ -2,7 +2,7 @@ import * as flags from "https://deno.land/std@0.221.0/flags/mod.ts"; import * as path from "https://deno.land/std@0.221.0/path/mod.ts"; import * as log from "https://deno.land/std@0.221.0/log/mod.ts"; import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; -import { crypto } from "https://deno.land/std@0.221.0/crypto/mod.ts"; +import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; export { crypto, flags, fs, log, path, semver }; From a838440b6d4554a25e5c7781851a8b88838cd754 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Mon, 24 Mar 2025 08:30:46 +1100 Subject: [PATCH 02/27] Open .denoversion to any <3 in ./dnit --- dnit/.denoversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dnit/.denoversion b/dnit/.denoversion index ba7c934..9263a2e 100644 --- a/dnit/.denoversion +++ b/dnit/.denoversion @@ -1 +1 @@ ->=1.16.4 <=1.42.0 +>=1.16.4 <3 From bb8cd6025e5c3625ca62e2a723da451401213f3f Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Mon, 24 Mar 2025 08:31:08 +1100 Subject: [PATCH 03/27] fix: override keyword in dnit.ts on loggers --- dnit.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dnit.ts b/dnit.ts index fbd8c9d..fb2d42e 100644 --- a/dnit.ts +++ b/dnit.ts @@ -615,14 +615,14 @@ class StdErrPlainHandler extends log.BaseHandler { }); } - log(msg: string): void { + override log(msg: string): void { Deno.stderr.writeSync(new TextEncoder().encode(msg + "\n")); } } /// StdErr handler on top of ConsoleHandler (which uses colors) class StdErrHandler extends log.ConsoleHandler { - log(msg: string): void { + override log(msg: string): void { Deno.stderr.writeSync(new TextEncoder().encode(msg + "\n")); } } From 37d9f90144ae854d67619e6abc009751e4cbdec9 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Mon, 24 Mar 2025 08:31:28 +1100 Subject: [PATCH 04/27] fix: exceptions as unknown in adl runtime json.ts --- adl-gen/runtime/json.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adl-gen/runtime/json.ts b/adl-gen/runtime/json.ts index 1854f5c..dae6eca 100644 --- a/adl-gen/runtime/json.ts +++ b/adl-gen/runtime/json.ts @@ -55,7 +55,7 @@ export function createJsonBinding( function fromJsonE(json: Json): T { try { return jb0.fromJson(json); - } catch (e) { + } catch (e : unknown) { throw mapJsonException(e); } } @@ -81,7 +81,7 @@ export interface JsonParseException { } // Map a JsonException to an Error value -export function mapJsonException(exception: {}): {} { +export function mapJsonException(exception: unknown): unknown { if ( exception && (exception as { kind: string })["kind"] == "JsonParseException" ) { @@ -125,7 +125,7 @@ export function jsonParseException(message: string): JsonParseException { * @param exception The exception to check. */ export function isJsonParseException( - exception: {}, + exception: unknown, ): exception is JsonParseException { return ( exception).kind === "JsonParseException"; } @@ -301,7 +301,7 @@ function vectorJsonBinding( jarr.forEach((eljson: Json, i: number) => { try { result.push(elementBinding().fromJson(eljson)); - } catch (e) { + } catch (e : unknown) { if (isJsonParseException(e)) { e.pushIndex(i); } From 47e49efda88c9736a55dec684f594a46a7369031 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Mon, 24 Mar 2025 08:31:45 +1100 Subject: [PATCH 05/27] ci: Use v2 throughout --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d689b8b..3e7f0a8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - deno: ["v1.42.x"] + deno: ["v2.2.5"] os: [ubuntu-latest] steps: @@ -33,7 +33,7 @@ jobs: strategy: matrix: - deno: ["v1.42.0", "v1.38.0"] + deno: ["v2.2.5"] os: [macOS-latest, windows-latest, ubuntu-latest] steps: From 1f52f41870857d1b28686065bd85894532117ada Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Tue, 25 Mar 2025 18:58:51 +1100 Subject: [PATCH 06/27] fix: Use denoland/setup-deno@v2 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e7f0a8..ee851fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: deno-version: ${{ matrix.deno }} # tests across multiple Deno versions From 03a0a84d12db25db233493deecadd36119bc83e6 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Tue, 25 Mar 2025 19:02:10 +1100 Subject: [PATCH 07/27] ci: Try using any v2.x --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee851fa..13c2d06 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - deno: ["v2.2.5"] + deno: ["v2.x"] os: [ubuntu-latest] steps: @@ -33,7 +33,7 @@ jobs: strategy: matrix: - deno: ["v2.2.5"] + deno: ["v2.x"] os: [macOS-latest, windows-latest, ubuntu-latest] steps: From 9c1b1ebe9a3102975a17d56fcdeea4d0d8524fbd Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Tue, 25 Mar 2025 19:04:31 +1100 Subject: [PATCH 08/27] fix: @setup-deno v2.x gets v2.2.4 so specify exactly that. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13c2d06..b7866b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - deno: ["v2.x"] + deno: ["v2.2.4"] os: [ubuntu-latest] steps: @@ -33,7 +33,7 @@ jobs: strategy: matrix: - deno: ["v2.x"] + deno: ["v2.2.4"] os: [macOS-latest, windows-latest, ubuntu-latest] steps: From 4d5972a23755327da193fc982814d6cc59b38f3a Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 13:57:18 +1100 Subject: [PATCH 09/27] Update setup-deno for test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7866b2..792c74b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: deno-version: ${{ matrix.deno }} # tests across multiple Deno versions From 920b73cab20e6c4fc95abc35ec09c1152ee5b54a Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 14:28:04 +1100 Subject: [PATCH 10/27] Update from deprecated @std/flags to @std/cli/parse-args --- deno.lock | 5 +++++ deps.ts | 5 +++-- dnit.ts | 12 ++++++------ dnit/deps.ts | 8 +++----- dnit/main.ts | 8 ++++---- main.ts | 4 ++-- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/deno.lock b/deno.lock index d35d649..8d506c5 100644 --- a/deno.lock +++ b/deno.lock @@ -1,10 +1,15 @@ { "version": "4", "specifiers": { + "jsr:@std/cli@*": "1.0.15", + "jsr:@std/cli@1.0.15": "1.0.15", "jsr:@std/crypto@*": "1.0.4", "jsr:@std/crypto@1.0.4": "1.0.4" }, "jsr": { + "@std/cli@1.0.15": { + "integrity": "e79ba3272ec710ca44d8342a7688e6288b0b88802703f3264184b52893d5e93f" + }, "@std/crypto@1.0.4": { "integrity": "cee245c453bd5366207f4d8aa25ea3e9c86cecad2be3fefcaa6cb17203d79340" } diff --git a/deps.ts b/deps.ts index 69d6c83..46c5e3a 100644 --- a/deps.ts +++ b/deps.ts @@ -1,8 +1,9 @@ -import * as flags from "https://deno.land/std@0.221.0/flags/mod.ts"; + +import * as cli from "jsr:@std/cli@1.0.15/parse-args"; import * as path from "https://deno.land/std@0.221.0/path/mod.ts"; import * as log from "https://deno.land/std@0.221.0/log/mod.ts"; import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; -export { crypto, flags, fs, log, path, semver }; +export { crypto, cli, fs, log, path, semver }; diff --git a/dnit.ts b/dnit.ts index fb2d42e..8ee3e39 100644 --- a/dnit.ts +++ b/dnit.ts @@ -1,4 +1,4 @@ -import { crypto, flags, log, path } from "./deps.ts"; +import { cli, crypto, log, path } from "./deps.ts"; import { version } from "./version.ts"; import { textTable } from "./textTable.ts"; @@ -33,7 +33,7 @@ class ExecContext { /// loaded hash manifest readonly manifest: Manifest, /// commandline args - readonly args: flags.Args, + readonly args: cli.Args, ) { if (args["verbose"] !== undefined) { this.internalLogger.levelName = "INFO"; @@ -53,7 +53,7 @@ class ExecContext { export interface TaskContext { logger: log.Logger; task: Task; - args: flags.Args; + args: cli.Args; exec: ExecContext; } @@ -564,7 +564,7 @@ export function task(taskParams: TaskParams): Task { return task; } -function showTaskList(ctx: ExecContext, args: flags.Args) { +function showTaskList(ctx: ExecContext, args: cli.Args) { if (args["quiet"]) { Array.from(ctx.taskRegister.values()).map((task) => console.log(task.name)); } else { @@ -717,7 +717,7 @@ export async function execCli( cliArgs: string[], tasks: Task[], ): Promise { - const args = flags.parse(cliArgs); + const args = cli.parseArgs(cliArgs); await setupLogging(); @@ -781,7 +781,7 @@ export async function execBasic( tasks: Task[], manifest: Manifest, ): Promise { - const args = flags.parse(cliArgs); + const args = cli.parseArgs(cliArgs); const ctx = new ExecContext(manifest, args); tasks.forEach((t) => ctx.taskRegister.set(t.name, t)); diff --git a/dnit/deps.ts b/dnit/deps.ts index cce7ddc..d2a4dab 100644 --- a/dnit/deps.ts +++ b/dnit/deps.ts @@ -1,11 +1,9 @@ // refer to own sources for ease of development -import { file, main, task } from "../dnit.ts"; +import { file, main, task, runAlways, type TaskContext } from "../dnit.ts"; import * as utils from "../utils.ts"; -import * as flags from "https://deno.land/std@0.221.0/flags/mod.ts"; -import * as path from "https://deno.land/std@0.221.0/path/mod.ts"; -import * as log from "https://deno.land/std@0.221.0/log/mod.ts"; +import * as cli from "jsr:@std/cli@1.0.15/parse-args"; import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; -export { file, flags, fs, log, main, path, semver, task, utils }; +export { file, cli, fs, main, runAlways, semver, task, utils, type TaskContext }; diff --git a/dnit/main.ts b/dnit/main.ts index 975a5bb..c1b19e1 100644 --- a/dnit/main.ts +++ b/dnit/main.ts @@ -1,5 +1,4 @@ -import { flags, log, semver, task, utils } from "./deps.ts"; -import { file, main, runAlways, TaskContext } from "../dnit.ts"; +import { file, main, cli, semver, task, utils, runAlways, type TaskContext } from "./deps.ts"; import { fetchTags, @@ -12,7 +11,7 @@ import { runConsole } from "../utils.ts"; const tagPrefix = "dnit-v"; -async function getNextTagVersion(args: flags.Args): Promise { +async function getNextTagVersion(args: cli.Args): Promise { const current = await gitLatestTag(tagPrefix); type Args = { @@ -67,7 +66,8 @@ const tag = task({ cmds.concat(["git", "tag", "-a", "-m", tagMessage, tagName]), ); await utils.runConsole(cmds.concat(["git", "push", origin, tagName])); - log.info( + + ctx.logger.info( `${ dryRun ? "(dry-run) " : "" }Git tagged and pushed ${tagPrefix}${next}`, diff --git a/main.ts b/main.ts index 603f727..3e09623 100644 --- a/main.ts +++ b/main.ts @@ -1,9 +1,9 @@ -import { flags, log, setupLogging } from "./mod.ts"; +import { cli, log, setupLogging } from "./mod.ts"; import { launch } from "./launch.ts"; import { version } from "./version.ts"; export async function main() { - const args = flags.parse(Deno.args); + const args : cli.Args = cli.parseArgs(Deno.args); if (args["version"] === true) { console.log(`dnit ${version}`); Deno.exit(0); From 3c74feff594a3b03f8c6645cdcc6c7181ddab7f0 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 14:58:35 +1100 Subject: [PATCH 11/27] Update path to jsr @std --- deno.lock | 7 ++++++- deps.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deno.lock b/deno.lock index 8d506c5..801cb1b 100644 --- a/deno.lock +++ b/deno.lock @@ -4,7 +4,9 @@ "jsr:@std/cli@*": "1.0.15", "jsr:@std/cli@1.0.15": "1.0.15", "jsr:@std/crypto@*": "1.0.4", - "jsr:@std/crypto@1.0.4": "1.0.4" + "jsr:@std/crypto@1.0.4": "1.0.4", + "jsr:@std/path@*": "1.0.8", + "jsr:@std/path@1.0.8": "1.0.8" }, "jsr": { "@std/cli@1.0.15": { @@ -12,6 +14,9 @@ }, "@std/crypto@1.0.4": { "integrity": "cee245c453bd5366207f4d8aa25ea3e9c86cecad2be3fefcaa6cb17203d79340" + }, + "@std/path@1.0.8": { + "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" } }, "remote": { diff --git a/deps.ts b/deps.ts index 46c5e3a..f43e64a 100644 --- a/deps.ts +++ b/deps.ts @@ -1,6 +1,6 @@ import * as cli from "jsr:@std/cli@1.0.15/parse-args"; -import * as path from "https://deno.land/std@0.221.0/path/mod.ts"; +import * as path from "jsr:@std/path@1.0.8"; import * as log from "https://deno.land/std@0.221.0/log/mod.ts"; import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; From 780dbce226986ca0c6ae5aba9d669d1c5af1ae28 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 14:59:44 +1100 Subject: [PATCH 12/27] Cleanup setupLogging --- dnit.ts | 6 +++--- main.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dnit.ts b/dnit.ts index 8ee3e39..a48db75 100644 --- a/dnit.ts +++ b/dnit.ts @@ -627,8 +627,8 @@ class StdErrHandler extends log.ConsoleHandler { } } -export async function setupLogging() { - await log.setup({ +export function setupLogging() { + log.setup({ handlers: { stderr: new StdErrHandler("DEBUG"), stderrPlain: new StdErrPlainHandler("DEBUG"), @@ -719,7 +719,7 @@ export async function execCli( ): Promise { const args = cli.parseArgs(cliArgs); - await setupLogging(); + setupLogging(); /// directory of user's entrypoint source as discovered by 'launch' util: const dnitDir = args["dnitDir"] || "./dnit"; diff --git a/main.ts b/main.ts index 3e09623..389b01e 100644 --- a/main.ts +++ b/main.ts @@ -9,7 +9,7 @@ export async function main() { Deno.exit(0); } - await setupLogging(); + setupLogging(); const internalLogger = log.getLogger("internal"); if (args["verbose"] !== undefined) { From 9d4f9c0f7cba18f2a0fd0e9d001b500370e85360 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 15:00:07 +1100 Subject: [PATCH 13/27] Dev utils dnit lint, fmt, check (for this repo only) --- dnit/main.ts | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++- main.ts | 12 +++++----- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/dnit/main.ts b/dnit/main.ts index c1b19e1..477d2aa 100644 --- a/dnit/main.ts +++ b/dnit/main.ts @@ -1,4 +1,13 @@ -import { file, main, cli, semver, task, utils, runAlways, type TaskContext } from "./deps.ts"; +import { + cli, + file, + main, + runAlways, + semver, + task, + type TaskContext, + utils, +} from "./deps.ts"; import { fetchTags, @@ -248,6 +257,60 @@ const killTest = task({ uptodate: runAlways, }); +const sourceCheckEntryPoints: string[] = [ + "main.ts", + "mod.ts", + "dnit/main.ts", +]; + +const check = task({ + name: "check", + description: "Run local checks", + action: async () => { + await Promise.all(sourceCheckEntryPoints.map(async (path) => { + await utils.runConsole([ + "deno", + "check", + path, + ]); + })); + }, + deps: [], + uptodate: runAlways, +}); + +const lint = task({ + name: "lint", + description: "Run local lint", + action: async () => { + await Promise.all(sourceCheckEntryPoints.map(async (path) => { + await utils.runConsole([ + "deno", + "lint", + path, + ]); + })); + }, + deps: [], + uptodate: runAlways, +}); + +const fmt = task({ + name: "fmt", + description: "Run local fmt", + action: async () => { + await Promise.all(sourceCheckEntryPoints.map(async (path) => { + await utils.runConsole([ + "deno", + "fmt", + path, + ]); + })); + }, + deps: [], + uptodate: runAlways, +}); + const tasks = [ test, genadl, @@ -257,6 +320,9 @@ const tasks = [ makeReleaseEdits, release, killTest, + check, + lint, + fmt, ]; main(Deno.args, tasks); diff --git a/main.ts b/main.ts index 389b01e..b993550 100644 --- a/main.ts +++ b/main.ts @@ -1,9 +1,10 @@ -import { cli, log, setupLogging } from "./mod.ts"; +import { setupLogging } from "./dnit.ts"; +import { cli, log } from "./deps.ts"; import { launch } from "./launch.ts"; import { version } from "./version.ts"; export async function main() { - const args : cli.Args = cli.parseArgs(Deno.args); + const args: cli.Args = cli.parseArgs(Deno.args); if (args["version"] === true) { console.log(`dnit ${version}`); Deno.exit(0); @@ -18,9 +19,8 @@ export async function main() { internalLogger.info(`starting dnit launch using version: ${version}`); - launch(internalLogger).then((st) => { - Deno.exit(st.code); - }); + const st = await launch(internalLogger); + Deno.exit(st.code); } -main(); +await main(); From e1fb2deb1b7726e74ba3100ac1648170376aa814 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 15:07:04 +1100 Subject: [PATCH 14/27] Update to jsr:@std/log@0.224.14 @std/log is likely to be removed in the future. https://github.com/denoland/std/issues/6124 --- deno.lock | 22 ++++++++++++++++++++++ deps.ts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/deno.lock b/deno.lock index 801cb1b..9e8c79f 100644 --- a/deno.lock +++ b/deno.lock @@ -5,6 +5,11 @@ "jsr:@std/cli@1.0.15": "1.0.15", "jsr:@std/crypto@*": "1.0.4", "jsr:@std/crypto@1.0.4": "1.0.4", + "jsr:@std/fmt@^1.0.5": "1.0.6", + "jsr:@std/fs@^1.0.11": "1.0.15", + "jsr:@std/io@~0.225.2": "0.225.2", + "jsr:@std/log@*": "0.224.14", + "jsr:@std/log@0.224.14": "0.224.14", "jsr:@std/path@*": "1.0.8", "jsr:@std/path@1.0.8": "1.0.8" }, @@ -15,6 +20,23 @@ "@std/crypto@1.0.4": { "integrity": "cee245c453bd5366207f4d8aa25ea3e9c86cecad2be3fefcaa6cb17203d79340" }, + "@std/fmt@1.0.6": { + "integrity": "a2c56a69a2369876ddb3ad6a500bb6501b5bad47bb3ea16bfb0c18974d2661fc" + }, + "@std/fs@1.0.15": { + "integrity": "c083fb479889d6440d768e498195c3fc499d426fbf9a6592f98f53884d1d3f41" + }, + "@std/io@0.225.2": { + "integrity": "3c740cd4ee4c082e6cfc86458f47e2ab7cb353dc6234d5e9b1f91a2de5f4d6c7" + }, + "@std/log@0.224.14": { + "integrity": "257f7adceee3b53bb2bc86c7242e7d1bc59729e57d4981c4a7e5b876c808f05e", + "dependencies": [ + "jsr:@std/fmt", + "jsr:@std/fs", + "jsr:@std/io" + ] + }, "@std/path@1.0.8": { "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" } diff --git a/deps.ts b/deps.ts index f43e64a..c4b73d3 100644 --- a/deps.ts +++ b/deps.ts @@ -1,7 +1,7 @@ import * as cli from "jsr:@std/cli@1.0.15/parse-args"; import * as path from "jsr:@std/path@1.0.8"; -import * as log from "https://deno.land/std@0.221.0/log/mod.ts"; +import * as log from "jsr:@std/log@0.224.14"; import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; From a8c9e9ad394a8d5b58b2aafa1af48dc16254fc76 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 15:09:01 +1100 Subject: [PATCH 15/27] Update to jsr:@std/fs@1.0.15 --- deno.lock | 11 ++++++++--- deps.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/deno.lock b/deno.lock index 9e8c79f..1df2da7 100644 --- a/deno.lock +++ b/deno.lock @@ -6,12 +6,14 @@ "jsr:@std/crypto@*": "1.0.4", "jsr:@std/crypto@1.0.4": "1.0.4", "jsr:@std/fmt@^1.0.5": "1.0.6", + "jsr:@std/fs@1.0.15": "1.0.15", "jsr:@std/fs@^1.0.11": "1.0.15", "jsr:@std/io@~0.225.2": "0.225.2", "jsr:@std/log@*": "0.224.14", "jsr:@std/log@0.224.14": "0.224.14", "jsr:@std/path@*": "1.0.8", - "jsr:@std/path@1.0.8": "1.0.8" + "jsr:@std/path@1.0.8": "1.0.8", + "jsr:@std/path@^1.0.8": "1.0.8" }, "jsr": { "@std/cli@1.0.15": { @@ -24,7 +26,10 @@ "integrity": "a2c56a69a2369876ddb3ad6a500bb6501b5bad47bb3ea16bfb0c18974d2661fc" }, "@std/fs@1.0.15": { - "integrity": "c083fb479889d6440d768e498195c3fc499d426fbf9a6592f98f53884d1d3f41" + "integrity": "c083fb479889d6440d768e498195c3fc499d426fbf9a6592f98f53884d1d3f41", + "dependencies": [ + "jsr:@std/path@^1.0.8" + ] }, "@std/io@0.225.2": { "integrity": "3c740cd4ee4c082e6cfc86458f47e2ab7cb353dc6234d5e9b1f91a2de5f4d6c7" @@ -33,7 +38,7 @@ "integrity": "257f7adceee3b53bb2bc86c7242e7d1bc59729e57d4981c4a7e5b876c808f05e", "dependencies": [ "jsr:@std/fmt", - "jsr:@std/fs", + "jsr:@std/fs@^1.0.11", "jsr:@std/io" ] }, diff --git a/deps.ts b/deps.ts index c4b73d3..1a9112b 100644 --- a/deps.ts +++ b/deps.ts @@ -2,7 +2,7 @@ import * as cli from "jsr:@std/cli@1.0.15/parse-args"; import * as path from "jsr:@std/path@1.0.8"; import * as log from "jsr:@std/log@0.224.14"; -import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; +import * as fs from "jsr:@std/fs@1.0.15"; import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; From d53fa48ad8ecfa8f5c7df1d6a669e3033555bc74 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 15:16:38 +1100 Subject: [PATCH 16/27] Update semver to @std/semver --- deno.lock | 7 ++++++- deps.ts | 5 ++--- dnit/deps.ts | 4 ++-- dnit/main.ts | 12 +++++++----- launch.ts | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/deno.lock b/deno.lock index 1df2da7..b042b9c 100644 --- a/deno.lock +++ b/deno.lock @@ -13,7 +13,9 @@ "jsr:@std/log@0.224.14": "0.224.14", "jsr:@std/path@*": "1.0.8", "jsr:@std/path@1.0.8": "1.0.8", - "jsr:@std/path@^1.0.8": "1.0.8" + "jsr:@std/path@^1.0.8": "1.0.8", + "jsr:@std/semver@*": "1.0.4", + "jsr:@std/semver@1.0.4": "1.0.4" }, "jsr": { "@std/cli@1.0.15": { @@ -44,6 +46,9 @@ }, "@std/path@1.0.8": { "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" + }, + "@std/semver@1.0.4": { + "integrity": "a62af791917d8fd6c48d6ebbb872f83fad3fc6671ffadbbd39ea229c2d34d175" } }, "remote": { diff --git a/deps.ts b/deps.ts index 1a9112b..ff9fc28 100644 --- a/deps.ts +++ b/deps.ts @@ -4,6 +4,5 @@ import * as path from "jsr:@std/path@1.0.8"; import * as log from "jsr:@std/log@0.224.14"; import * as fs from "jsr:@std/fs@1.0.15"; import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; -import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; - -export { crypto, cli, fs, log, path, semver }; +import * as semver from "jsr:@std/semver@1.0.4"; +export { crypto, cli, fs, log, path, semver}; diff --git a/dnit/deps.ts b/dnit/deps.ts index d2a4dab..97d0d66 100644 --- a/dnit/deps.ts +++ b/dnit/deps.ts @@ -3,7 +3,7 @@ import { file, main, task, runAlways, type TaskContext } from "../dnit.ts"; import * as utils from "../utils.ts"; import * as cli from "jsr:@std/cli@1.0.15/parse-args"; -import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; -import * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts"; +import * as fs from "jsr:@std/fs@1.0.15"; +import * as semver from "jsr:@std/semver@1.0.4"; export { file, cli, fs, main, runAlways, semver, task, utils, type TaskContext }; diff --git a/dnit/main.ts b/dnit/main.ts index 477d2aa..3e807f1 100644 --- a/dnit/main.ts +++ b/dnit/main.ts @@ -32,7 +32,9 @@ async function getNextTagVersion(args: cli.Args): Promise { const increment: "major" | "minor" | "patch" = args.major ? "major" : (xargs.minor ? "minor" : ("patch")); - const next = semver.inc(current, increment); + const next = semver.format( + semver.increment(semver.parse(current), increment), + ); return next; } @@ -40,8 +42,6 @@ const tag = task({ name: "tag", description: "Run git tag", action: async (ctx: TaskContext) => { - const current = await gitLatestTag(tagPrefix); - type Args = { "major"?: true; "minor"?: true; @@ -50,11 +50,13 @@ const tag = task({ "origin"?: string; "dry-run"?: true; }; + + const next = await getNextTagVersion(ctx.args); + const args: Args = ctx.args as Args; const increment: "major" | "minor" | "patch" = args.major ? "major" : (args.minor ? "minor" : ("patch")); - const next = semver.inc(current, increment); const tagMessage = args.message || `Tag ${increment} to ${next}`; const tagName = `${tagPrefix}${next}`; @@ -66,7 +68,7 @@ const tag = task({ console.log("Last commit: " + gitLastCommit); const conf = confirm( - `Git tag and push ${tagMessage} tagName?`, + `Git tag and push ${tagName} with message: ${tagMessage}?`, ); if (conf) { const cmds = dryRun ? ["echo"] : []; diff --git a/launch.ts b/launch.ts index 88bdba1..28ad67c 100644 --- a/launch.ts +++ b/launch.ts @@ -115,7 +115,7 @@ export function checkValidDenoVersion( denoVersion: string, denoReqSemverRange: string, ): boolean { - return semver.satisfies(denoVersion, denoReqSemverRange); + return semver.satisfies(semver.parse(denoVersion), semver.parseRange(denoReqSemverRange)) } export async function launch(logger: log.Logger): Promise { From 24eea739d9b96ba325125a41bc60d083c34868af Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 15:40:05 +1100 Subject: [PATCH 17/27] Add allow-import on the launch args --- launch.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/launch.ts b/launch.ts index 28ad67c..f497ef3 100644 --- a/launch.ts +++ b/launch.ts @@ -149,6 +149,7 @@ export async function launch(logger: log.Logger): Promise { "--allow-run", "--allow-env", "--allow-net", + "--allow-import", ]; const flags = [ "--quiet", From 1566917ec22abb4038ab90de11c7b8710ba72f03 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 15:45:40 +1100 Subject: [PATCH 18/27] Bump version manually for dev on v2 --- README.md | 5 +++++ version.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e688e9..2840280 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ convenient entrypoint script and aliases the permission flags. deno install --global --allow-read --allow-write --allow-run -f --name dnit https://deno.land/x/dnit@dnit-v1.14.4/main.ts ``` +Install from a branch: +``` +deno install --global --allow-read --allow-write --allow-run -f --name dnit https://raw.githubusercontent.com/PaulThompson/dnit/d53fa48ad8ecfa8f5c7df1d6a669e3033555bc74/main.ts +``` + Install from source checkout: ``` diff --git a/version.ts b/version.ts index 00628f4..7f1cf46 100644 --- a/version.ts +++ b/version.ts @@ -1 +1 @@ -export const version = "1.14.4"; +export const version = "2.0.0-pre.0"; From 591962754d3bc1d2211520cd0ce14d1d86be8e18 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 16:02:55 +1100 Subject: [PATCH 19/27] Switch to import map in deno.json - requires install with --config arg --- README.md | 6 +++--- deno.json | 8 ++++++++ deno.lock | 17 ++++++++++++++++- deps.ts | 12 ++++++------ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2840280..8f84072 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,18 @@ It is recommended to use `deno install` to install the tool, which provides a convenient entrypoint script and aliases the permission flags. ``` -deno install --global --allow-read --allow-write --allow-run -f --name dnit https://deno.land/x/dnit@dnit-v1.14.4/main.ts +deno install --global --allow-read --allow-write --allow-run -f --name dnit --config deno.json https://deno.land/x/dnit@dnit-v1.14.4/main.ts ``` Install from a branch: ``` -deno install --global --allow-read --allow-write --allow-run -f --name dnit https://raw.githubusercontent.com/PaulThompson/dnit/d53fa48ad8ecfa8f5c7df1d6a669e3033555bc74/main.ts +deno install --global --allow-read --allow-write --allow-run -f --name dnit --config deno.json https://raw.githubusercontent.com/PaulThompson/dnit/d53fa48ad8ecfa8f5c7df1d6a669e3033555bc74/main.ts ``` Install from source checkout: ``` -deno install --global --allow-read --allow-write --allow-run -f --name dnit ./main.ts +deno install --global --allow-read --allow-write --allow-run -f --name dnit --config deno.json ./main.ts ``` - Read, Write and Run permissions are required in order to operate on files and diff --git a/deno.json b/deno.json index b60dac7..7987b75 100644 --- a/deno.json +++ b/deno.json @@ -3,5 +3,13 @@ "exclude": [ "adl-gen/" ] + }, + "imports": { + "@std/cli": "jsr:@std/cli@^1.0.15", + "@std/crypto": "jsr:@std/crypto@^1.0.4", + "@std/fs": "jsr:@std/fs@^1.0.15", + "@std/log": "jsr:@std/log@^0.224.14", + "@std/path": "jsr:@std/path@^1.0.8", + "@std/semver": "jsr:@std/semver@^1.0.4" } } diff --git a/deno.lock b/deno.lock index b042b9c..71ee466 100644 --- a/deno.lock +++ b/deno.lock @@ -3,19 +3,24 @@ "specifiers": { "jsr:@std/cli@*": "1.0.15", "jsr:@std/cli@1.0.15": "1.0.15", + "jsr:@std/cli@^1.0.15": "1.0.15", "jsr:@std/crypto@*": "1.0.4", "jsr:@std/crypto@1.0.4": "1.0.4", + "jsr:@std/crypto@^1.0.4": "1.0.4", "jsr:@std/fmt@^1.0.5": "1.0.6", "jsr:@std/fs@1.0.15": "1.0.15", "jsr:@std/fs@^1.0.11": "1.0.15", + "jsr:@std/fs@^1.0.15": "1.0.15", "jsr:@std/io@~0.225.2": "0.225.2", "jsr:@std/log@*": "0.224.14", "jsr:@std/log@0.224.14": "0.224.14", + "jsr:@std/log@~0.224.14": "0.224.14", "jsr:@std/path@*": "1.0.8", "jsr:@std/path@1.0.8": "1.0.8", "jsr:@std/path@^1.0.8": "1.0.8", "jsr:@std/semver@*": "1.0.4", - "jsr:@std/semver@1.0.4": "1.0.4" + "jsr:@std/semver@1.0.4": "1.0.4", + "jsr:@std/semver@^1.0.4": "1.0.4" }, "jsr": { "@std/cli@1.0.15": { @@ -209,5 +214,15 @@ "https://deno.land/std@0.221.0/path/windows/to_namespaced_path.ts": "4ffa4fb6fae321448d5fe810b3ca741d84df4d7897e61ee29be961a6aac89a4c", "https://deno.land/std@0.221.0/testing/asserts.ts": "0cb9c745d9b157bed062a4aa8647168d2221f6456c385a548b0ca24de9e0f3ca", "https://deno.land/x/semver@v1.4.1/mod.ts": "0b79c87562eb8a1f008ab0d98f8bb60076dd65bc06f1f8fdfac2d2dab162c27b" + }, + "workspace": { + "dependencies": [ + "jsr:@std/cli@^1.0.15", + "jsr:@std/crypto@^1.0.4", + "jsr:@std/fs@^1.0.15", + "jsr:@std/log@~0.224.14", + "jsr:@std/path@^1.0.8", + "jsr:@std/semver@^1.0.4" + ] } } diff --git a/deps.ts b/deps.ts index ff9fc28..9b65516 100644 --- a/deps.ts +++ b/deps.ts @@ -1,8 +1,8 @@ -import * as cli from "jsr:@std/cli@1.0.15/parse-args"; -import * as path from "jsr:@std/path@1.0.8"; -import * as log from "jsr:@std/log@0.224.14"; -import * as fs from "jsr:@std/fs@1.0.15"; -import { crypto } from "jsr:@std/crypto@1.0.4/crypto"; -import * as semver from "jsr:@std/semver@1.0.4"; +import * as cli from "@std/cli/parse-args"; +import * as path from "@std/path"; +import * as log from "@std/log"; +import * as fs from "@std/fs"; +import { crypto } from "@std/crypto/crypto"; +import * as semver from "@std/semver"; export { crypto, cli, fs, log, path, semver}; From 75099ab82225c45b50ff14cc48588abc5174c881 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 16:06:51 +1100 Subject: [PATCH 20/27] Require v2.1 at least --- .github/workflows/test.yml | 2 +- README.md | 4 ++-- dnit/.denoversion | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 792c74b..880816e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: strategy: matrix: - deno: ["v2.2.4"] + deno: ["v2.2.4", "v2.1.x"] os: [macOS-latest, windows-latest, ubuntu-latest] steps: diff --git a/README.md b/README.md index 8f84072..fb4ac57 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ across many files or shared between projects. ### Pre-Requisites - [Deno](https://deno.land/#installation) -- Requires deno v1.16.4 or greater +- Requires deno v2.1 or greater ### Install @@ -20,7 +20,7 @@ convenient entrypoint script and aliases the permission flags. deno install --global --allow-read --allow-write --allow-run -f --name dnit --config deno.json https://deno.land/x/dnit@dnit-v1.14.4/main.ts ``` -Install from a branch: +Install from github: ``` deno install --global --allow-read --allow-write --allow-run -f --name dnit --config deno.json https://raw.githubusercontent.com/PaulThompson/dnit/d53fa48ad8ecfa8f5c7df1d6a669e3033555bc74/main.ts ``` diff --git a/dnit/.denoversion b/dnit/.denoversion index 9263a2e..a0d4707 100644 --- a/dnit/.denoversion +++ b/dnit/.denoversion @@ -1 +1 @@ ->=1.16.4 <3 +>=2.1 <3 From 22165f91d8f6704532e0c288c817f023703bf3b0 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 16:12:18 +1100 Subject: [PATCH 21/27] Tidy comments in github workflow --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 880816e..5d0bf0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: jobs: lint: - runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS + runs-on: ${{ matrix.os }} strategy: matrix: @@ -23,13 +23,13 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v2 with: - deno-version: ${{ matrix.deno }} # tests across multiple Deno versions + deno-version: ${{ matrix.deno }} - name: Run Deno lint run: deno lint test: - runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS + runs-on: ${{ matrix.os }} strategy: matrix: @@ -43,7 +43,7 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v2 with: - deno-version: ${{ matrix.deno }} # tests across multiple Deno versions + deno-version: ${{ matrix.deno }} - name: Cache Dependencies run: deno cache deps.ts From a18ef5a844e47600ff0ecb81a3a386933ae34d6c Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 16:15:55 +1100 Subject: [PATCH 22/27] Drop old example dir --- example/.gitignore | 2 -- example/dnit/deps.ts | 11 ----------- example/dnit/goodBye.ts | 23 ----------------------- example/dnit/helloWorld.ts | 24 ------------------------ example/dnit/import_map.json | 5 ----- example/dnit/main.ts | 10 ---------- example/somedir/.gitignore | 0 example/writeMsg.sh | 8 -------- 8 files changed, 83 deletions(-) delete mode 100644 example/.gitignore delete mode 100644 example/dnit/deps.ts delete mode 100644 example/dnit/goodBye.ts delete mode 100644 example/dnit/helloWorld.ts delete mode 100644 example/dnit/import_map.json delete mode 100644 example/dnit/main.ts delete mode 100644 example/somedir/.gitignore delete mode 100755 example/writeMsg.sh diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 721b360..0000000 --- a/example/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/dnit/.manifest.json -/msg.txt diff --git a/example/dnit/deps.ts b/example/dnit/deps.ts deleted file mode 100644 index 46ba351..0000000 --- a/example/dnit/deps.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - file, - main, - task, -} from "https://deno.land/x/dnit@dnit-v1.14.4/dnit.ts"; -import * as flags from "https://deno.land/std@0.221.0/flags/mod.ts"; -import * as path from "https://deno.land/std@0.221.0/path/mod.ts"; -import * as log from "https://deno.land/std@0.221.0/log/mod.ts"; -import * as fs from "https://deno.land/std@0.221.0/fs/mod.ts"; - -export { file, flags, fs, log, main, path, task }; diff --git a/example/dnit/goodBye.ts b/example/dnit/goodBye.ts deleted file mode 100644 index f407d23..0000000 --- a/example/dnit/goodBye.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { task } from "./deps.ts"; -import { msg } from "./helloWorld.ts"; - -//import { red } from "fmt/colors.ts"; - -//console.log(red("hello world")); - -export const goodbye = task({ - name: "goodbye", - action: async () => { - // use ordinary typescript idiomatically if several actions are required - const actions = [ - async () => { - const txt = await Deno.readTextFile(msg.path); - console.log(txt); - }, - ]; - for (const action of actions) { - await action(); - } - }, - deps: [msg], -}); diff --git a/example/dnit/helloWorld.ts b/example/dnit/helloWorld.ts deleted file mode 100644 index 5bffba1..0000000 --- a/example/dnit/helloWorld.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { file, task } from "./deps.ts"; - -export const msg = file({ - path: "./msg.txt", -}); - -export const helloWorld = task({ - name: "helloWorld", - description: "foo", - action: async () => { - const cmd = new Deno.Command("sh", { - args: ["./writeMsg.sh"], - }); - await cmd.output(); - }, - deps: [ - file({ - path: "./writeMsg.sh", - }), - ], - targets: [ - msg, - ], -}); diff --git a/example/dnit/import_map.json b/example/dnit/import_map.json deleted file mode 100644 index 6842e29..0000000 --- a/example/dnit/import_map.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "imports": { - "fmt/": "https://deno.land/std@0.221.0/fmt/" - } -} diff --git a/example/dnit/main.ts b/example/dnit/main.ts deleted file mode 100644 index 20bfa27..0000000 --- a/example/dnit/main.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { main } from "./deps.ts"; -import { helloWorld } from "./helloWorld.ts"; -import { goodbye } from "./goodBye.ts"; - -const tasks = [ - helloWorld, - goodbye, -]; - -main(Deno.args, tasks); diff --git a/example/somedir/.gitignore b/example/somedir/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/example/writeMsg.sh b/example/writeMsg.sh deleted file mode 100755 index bdb0155..0000000 --- a/example/writeMsg.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# an example task - -cd "$( dirname "${BASH_SOURCE[0]}" )" - -echo "writing msg.txt" -echo helloworld > msg.txt From ef3b08ddd45f3b71ea1e20648a6826bca9c28449 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 17:45:00 +1100 Subject: [PATCH 23/27] Drop allow-import Can use these without requiring allow-import: https://deno.land/ https://jsr.io/ https://esm.sh/ https://raw.githubusercontent.com https://gist.githubusercontent.com --- launch.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/launch.ts b/launch.ts index f497ef3..28ad67c 100644 --- a/launch.ts +++ b/launch.ts @@ -149,7 +149,6 @@ export async function launch(logger: log.Logger): Promise { "--allow-run", "--allow-env", "--allow-net", - "--allow-import", ]; const flags = [ "--quiet", From 1ac690c16cc1ddf8681328a2c03515b87d356071 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 17:46:49 +1100 Subject: [PATCH 24/27] Re-support v1.x --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d0bf0e..293095a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: strategy: matrix: - deno: ["v2.2.4", "v2.1.x"] + deno: ["v2.2.4", "v2.1.x", "v1.x"] os: [macOS-latest, windows-latest, ubuntu-latest] steps: From 963b0f43b40e7e8a944936a0794e3a3924039a54 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 17:49:20 +1100 Subject: [PATCH 25/27] Revert "Re-support v1.x" This reverts commit 1ac690c16cc1ddf8681328a2c03515b87d356071. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 293095a..5d0bf0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: strategy: matrix: - deno: ["v2.2.4", "v2.1.x", "v1.x"] + deno: ["v2.2.4", "v2.1.x"] os: [macOS-latest, windows-latest, ubuntu-latest] steps: From d8c7c8614dd7a2c54916866eb8b0a766de00ac1f Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sat, 29 Mar 2025 18:10:10 +1100 Subject: [PATCH 26/27] fixes for deno publish --- ADLMap.ts | 6 +++--- adl-gen/resolver.ts | 4 ++-- adl-gen/runtime/adl.ts | 4 ++-- adl-gen/runtime/utils.ts | 8 ++++---- deno.json | 3 +++ dnit.ts | 18 +++++++++--------- manifest.ts | 2 +- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ADLMap.ts b/ADLMap.ts index 7d1c168..039dc69 100644 --- a/ADLMap.ts +++ b/ADLMap.ts @@ -24,7 +24,7 @@ export class ADLMap { } return existing; } - set(k: K, v: V) { + set(k: K, v: V) : ADLMap { const ind = this.findIndex(k); if (ind === -1) { this.data.push({ v1: k, v2: v }); @@ -41,11 +41,11 @@ export class ADLMap { entries(): [K, V][] { return this.data.map((p) => [p.v1, p.v2]); } - toData() { + toData() : sysTypes.Map { return this.data; } - findIndex(k: K) { + findIndex(k: K) : number { return this.data.findIndex((p) => this.isEqual(p.v1, k)); } } diff --git a/adl-gen/resolver.ts b/adl-gen/resolver.ts index 2015aa7..3507be2 100644 --- a/adl-gen/resolver.ts +++ b/adl-gen/resolver.ts @@ -1,6 +1,6 @@ // deno-lint-ignore-file /* @generated from adl */ -import { declResolver, ScopedDecl } from "./runtime/adl.ts"; +import { declResolver, ScopedDecl, ScopedName } from "./runtime/adl.ts"; import { _AST_MAP as dnit_manifest } from "./dnit/manifest.ts"; import { _AST_MAP as sys_types } from "./sys/types.ts"; @@ -9,4 +9,4 @@ export const ADL: { [key: string]: ScopedDecl } = { ...sys_types, }; -export const RESOLVER = declResolver(ADL); +export const RESOLVER : (scopedName: ScopedName)=>ScopedDecl = declResolver(ADL); diff --git a/adl-gen/runtime/adl.ts b/adl-gen/runtime/adl.ts index 405aa37..89667e5 100644 --- a/adl-gen/runtime/adl.ts +++ b/adl-gen/runtime/adl.ts @@ -1,5 +1,5 @@ //deno-lint-ignore-file -import type * as AST from "./sys/adlast.ts"; +import * as AST from "./sys/adlast.ts"; import type * as utils from "./utils.ts"; export type ScopedName = AST.ScopedName; @@ -16,7 +16,7 @@ export interface DeclResolver { export function declResolver( ...astMaps: ({ [key: string]: AST.ScopedDecl })[] -) { +) : (scopedName: AST.ScopedName) => AST.ScopedDecl { const astMap: { [key: string]: AST.ScopedDecl } = {}; for (let map of astMaps) { for (let scopedName in map) { diff --git a/adl-gen/runtime/utils.ts b/adl-gen/runtime/utils.ts index e61e70b..df2dac4 100644 --- a/adl-gen/runtime/utils.ts +++ b/adl-gen/runtime/utils.ts @@ -89,10 +89,10 @@ export function typeExprToStringUnscoped(te: AST.TypeExpr): string { // "Flavoured" nominal typing. // https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/ -const symS = Symbol(); -const symT = Symbol(); -const symU = Symbol(); -const symV = Symbol(); +const symS : unique symbol = Symbol(); +const symT : unique symbol = Symbol(); +const symU : unique symbol = Symbol(); +const symV : unique symbol = Symbol(); /// Zero ADL type params - literal string type Name (fully scoped module name) /// eg for 'newtype X = string' -> 'type X = Flavouring0<"X">;' diff --git a/deno.json b/deno.json index 7987b75..fdc8dac 100644 --- a/deno.json +++ b/deno.json @@ -1,4 +1,7 @@ { + "name": "@dnit/dnit", + "version": "2.0.0-pre.0", + "exports": "./mod.ts", "fmt": { "exclude": [ "adl-gen/" diff --git a/dnit.ts b/dnit.ts index a48db75..d2ea54c 100644 --- a/dnit.ts +++ b/dnit.ts @@ -10,24 +10,24 @@ import { AsyncQueue } from "./asyncQueue.ts"; class ExecContext { /// All tasks by name - taskRegister = new Map(); + taskRegister : Map = new Map(); /// Tasks by target - targetRegister = new Map(); + targetRegister : Map = new Map(); /// Done or up-to-date tasks - doneTasks = new Set(); + doneTasks : Set = new Set(); /// In progress tasks - inprogressTasks = new Set(); + inprogressTasks : Set = new Set(); /// Queue for scheduling async work with specified number allowable concurrently. // deno-lint-ignore no-explicit-any asyncQueue: AsyncQueue; - internalLogger = log.getLogger("internal"); - taskLogger = log.getLogger("task"); - userLogger = log.getLogger("user"); + internalLogger : log.Logger = log.getLogger("internal"); + taskLogger : log.Logger = log.getLogger("task"); + userLogger : log.Logger = log.getLogger("user"); constructor( /// loaded hash manifest @@ -394,7 +394,7 @@ export class TrackedFile { return statResult.kind === "fileInfo"; } - async getHash(statInput?: StatResult) { + async getHash(statInput?: StatResult) : Promise { let statResult = statInput; if (statResult === undefined) { statResult = await this.stat(); @@ -407,7 +407,7 @@ export class TrackedFile { return this.#getHash(this.path, statResult.fileInfo); } - async getTimestamp(statInput?: StatResult) { + async getTimestamp(statInput?: StatResult) : Promise { let statResult = statInput; if (statResult === undefined) { statResult = await this.stat(); diff --git a/manifest.ts b/manifest.ts index bdc182e..135d386 100644 --- a/manifest.ts +++ b/manifest.ts @@ -7,7 +7,7 @@ import { RESOLVER } from "./adl-gen/resolver.ts"; import { ADLMap } from "./ADLMap.ts"; export class Manifest { readonly filename: string; - readonly jsonBinding = J.createJsonBinding(RESOLVER, A.texprManifest()); + readonly jsonBinding : J.JsonBinding = J.createJsonBinding(RESOLVER, A.texprManifest()); tasks: ADLMap = new ADLMap( [], (k1, k2) => k1 === k2, From 2747812434a73094976507fafc71737cb9c6fa22 Mon Sep 17 00:00:00 2001 From: Paul Thompson Date: Sun, 6 Apr 2025 12:32:50 +1000 Subject: [PATCH 27/27] lint fixes --- adl-gen/runtime/dynamic.ts | 4 ++-- dnit/main.ts | 2 +- launch.ts | 2 +- tests/basic.test.ts | 2 +- utils/git.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/adl-gen/runtime/dynamic.ts b/adl-gen/runtime/dynamic.ts index db880ba..881883a 100644 --- a/adl-gen/runtime/dynamic.ts +++ b/adl-gen/runtime/dynamic.ts @@ -1,6 +1,6 @@ import { typeExprsEqual } from "./utils.ts"; -import { JsonBinding } from "./json.ts"; -import { Dynamic } from "./sys/dynamic.ts"; +import type { JsonBinding } from "./json.ts"; +import type { Dynamic } from "./sys/dynamic.ts"; /** * Convert an ADL value to a dynamically typed value diff --git a/dnit/main.ts b/dnit/main.ts index 3e807f1..2839d38 100644 --- a/dnit/main.ts +++ b/dnit/main.ts @@ -1,5 +1,5 @@ import { - cli, + type cli, file, main, runAlways, diff --git a/launch.ts b/launch.ts index 28ad67c..505ca93 100644 --- a/launch.ts +++ b/launch.ts @@ -1,6 +1,6 @@ /// Convenience util to launch a user's dnit.ts -import { fs, log, path, semver } from "./deps.ts"; +import { fs, type log, path, semver } from "./deps.ts"; type UserSource = { baseDir: string; diff --git a/tests/basic.test.ts b/tests/basic.test.ts index 7ba73df..0a73a0b 100644 --- a/tests/basic.test.ts +++ b/tests/basic.test.ts @@ -3,7 +3,7 @@ import { execBasic, runAlways, task, - TrackedFile, + type TrackedFile, trackFile, } from "../dnit.ts"; diff --git a/utils/git.ts b/utils/git.ts index ea7def6..0aa68cb 100644 --- a/utils/git.ts +++ b/utils/git.ts @@ -1,5 +1,5 @@ import { run, runConsole } from "./process.ts"; -import { task, TaskContext } from "../dnit.ts"; +import { task, type TaskContext } from "../dnit.ts"; export async function gitLatestTag(tagPrefix: string) { const describeStr = await run(