Skip to content

Commit

Permalink
fix build and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nleanba committed Oct 30, 2024
1 parent d9edaa0 commit 5b28261
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
with:
ref: main
- name: Setup Deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x
- name: prepare
run: |
mkdir build
Expand All @@ -37,15 +37,10 @@ jobs:
with:
ref: synolib2
path: "synolib2"
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Draw the rest of the owl
run: |
cd synolib2
npm ci
npm run example build
deno task example_build
mkdir ../build/next
cp ./example/index.* ../build/next/
cd ..
Expand Down
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ An example running in the browser is located in `example/index.html` and
To build the example, use

```sh
npm run example
deno task example_build
```

or for a live-reloading server use

```sh
npm run example serve
deno task example_serve
```

(Both require `npm install` first)

The example page uses query parameters for options:

- `q=TAXON` for the search term (Latin name, CoL-URI, taxon-name-URI or
Expand All @@ -54,14 +52,7 @@ e.g. http://localhost:8000/?q=Sadayoshia%20miyakei&show_col=

## Building for npm/web

To build the library for use in web projects, use

```sh
npm run build
```

This will place the built library in `./build/mod.js`.

Note that this does not (yet) generate `.d.ts` typings.
The library is to be published as-is (in typescript) to jsr.io.

(Requires `npm install` first)
It can be used from there in with other deno or node/npm projects. There is no
building step neccesary on our side.
4 changes: 2 additions & 2 deletions SynonymGroup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SparqlEndpoint, SparqlJson } from "./mod.ts";
import type { SparqlEndpoint, SparqlJson } from "./mod.ts";

/** Finds all synonyms of a taxon */
export class SynonymGroup implements AsyncIterable<Name> {
Expand Down Expand Up @@ -60,7 +60,7 @@ export class SynonymGroup implements AsyncIterable<Name> {
*
* @readonly
*/
treatments = new Map<string, Treatment>();
treatments: Map<string, Treatment> = new Map();

/**
* Whether to show taxa deprecated by CoL that would not have been found otherwise.
Expand Down
8 changes: 7 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "@plazi/synolib",
"version": "3.0.0",
"exports": "./mod.ts",
"publish": {
"include": ["./*.ts", "README.md", "LICENSE"],
"exclude": ["./build_example.ts"]
},
"compilerOptions": {
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
Expand Down
11 changes: 8 additions & 3 deletions example/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as Colors from "https://deno.land/[email protected]/fmt/colors.ts";
import { Name, SparqlEndpoint, SynonymGroup, Treatment } from "../mod.ts";
import {
type Name,
SparqlEndpoint,
SynonymGroup,
type Treatment,
} from "../mod.ts";

const HIDE_COL_ONLY_SYNONYMS = true;
const START_WITH_SUBTAXA = false;
Expand Down Expand Up @@ -115,7 +120,7 @@ async function logTreatment(
) {
const details = await trt.details;
console.log(
` ${trtColor[type]("●")} ${details.creators} ${details.date}${
` ${trtColor[type]("●")} ${details.creators} ${trt.date}${
Colors.italic(details.title || Colors.dim("No Title"))
}${Colors.magenta(trt.url)}`,
);
Expand Down Expand Up @@ -167,7 +172,7 @@ async function justify(name: Name): Promise<string> {
const parent = await justify(name.justification.parent);
return `is, according to ${
Colors.italic(
`${details.creators} ${details.date}${
`${details.creators} ${name.justification.treatment.date}${
Colors.italic(details.title || Colors.dim("No Title"))
}${Colors.magenta(name.justification.treatment.url)}`,
)
Expand Down

0 comments on commit 5b28261

Please sign in to comment.