Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3fcae77
Use latest jsr std crypto
PaulThompson Mar 23, 2025
a838440
Open .denoversion to any <3 in ./dnit
PaulThompson Mar 23, 2025
bb8cd60
fix: override keyword in dnit.ts on loggers
PaulThompson Mar 23, 2025
37d9f90
fix: exceptions as unknown in adl runtime json.ts
PaulThompson Mar 23, 2025
47e49ef
ci: Use v2 throughout
PaulThompson Mar 23, 2025
1f52f41
fix: Use denoland/setup-deno@v2
PaulThompson Mar 25, 2025
03a0a84
ci: Try using any v2.x
PaulThompson Mar 25, 2025
9c1b1eb
fix: @setup-deno v2.x gets v2.2.4 so specify exactly that.
PaulThompson Mar 25, 2025
4d5972a
Update setup-deno for test
PaulThompson Mar 29, 2025
920b73c
Update from deprecated @std/flags to @std/cli/parse-args
PaulThompson Mar 29, 2025
3c74fef
Update path to jsr @std
PaulThompson Mar 29, 2025
780dbce
Cleanup setupLogging
PaulThompson Mar 29, 2025
9d4f9c0
Dev utils dnit lint, fmt, check (for this repo only)
PaulThompson Mar 29, 2025
e1fb2de
Update to jsr:@std/log@0.224.14
PaulThompson Mar 29, 2025
a8c9e9a
Update to jsr:@std/fs@1.0.15
PaulThompson Mar 29, 2025
d53fa48
Update semver to @std/semver
PaulThompson Mar 29, 2025
24eea73
Add allow-import on the launch args
PaulThompson Mar 29, 2025
1566917
Bump version manually for dev on v2
PaulThompson Mar 29, 2025
5919627
Switch to import map in deno.json - requires install with --config arg
PaulThompson Mar 29, 2025
75099ab
Require v2.1 at least
PaulThompson Mar 29, 2025
22165f9
Tidy comments in github workflow
PaulThompson Mar 29, 2025
a18ef5a
Drop old example dir
PaulThompson Mar 29, 2025
ef3b08d
Drop allow-import
PaulThompson Mar 29, 2025
1ac690c
Re-support v1.x
PaulThompson Mar 29, 2025
963b0f4
Revert "Re-support v1.x"
PaulThompson Mar 29, 2025
d8c7c86
fixes for deno publish
PaulThompson Mar 29, 2025
2747812
lint fixes
PaulThompson Apr 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ on:

jobs:
lint:
runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS
runs-on: ${{ matrix.os }}

strategy:
matrix:
deno: ["v1.42.x"]
deno: ["v2.2.4"]
os: [ubuntu-latest]

steps:
- name: Setup repo
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
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:
deno: ["v1.42.0", "v1.38.0"]
deno: ["v2.2.4", "v2.1.x"]
os: [macOS-latest, windows-latest, ubuntu-latest]

steps:
- name: Setup repo
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
deno-version: ${{ matrix.deno }}

- name: Cache Dependencies
run: deno cache deps.ts
Expand Down
6 changes: 3 additions & 3 deletions ADLMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ADLMap<K, V> {
}
return existing;
}
set(k: K, v: V) {
set(k: K, v: V) : ADLMap<K, V> {
const ind = this.findIndex(k);
if (ind === -1) {
this.data.push({ v1: k, v2: v });
Expand All @@ -41,11 +41,11 @@ export class ADLMap<K, V> {
entries(): [K, V][] {
return this.data.map((p) => [p.v1, p.v2]);
}
toData() {
toData() : sysTypes.Map<K, V> {
return this.data;
}

findIndex(k: K) {
findIndex(k: K) : number {
return this.data.findIndex((p) => this.isEqual(p.v1, k));
}
}
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ 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

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 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
```

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
Expand Down
4 changes: 2 additions & 2 deletions adl-gen/resolver.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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);
4 changes: 2 additions & 2 deletions adl-gen/runtime/adl.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions adl-gen/runtime/dynamic.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions adl-gen/runtime/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function createJsonBinding<T>(
function fromJsonE(json: Json): T {
try {
return jb0.fromJson(json);
} catch (e) {
} catch (e : unknown) {
throw mapJsonException(e);
}
}
Expand All @@ -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"
) {
Expand Down Expand Up @@ -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 (<JsonParseException> exception).kind === "JsonParseException";
}
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions adl-gen/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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">;'
Expand Down
11 changes: 11 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"name": "@dnit/dnit",
"version": "2.0.0-pre.0",
"exports": "./mod.ts",
"fmt": {
"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"
}
}
97 changes: 96 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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 * as semver from "https://deno.land/x/semver@v1.4.1/mod.ts";

export { crypto, flags, fs, log, path, semver };
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};
Loading