From f595db2c5c16f77a1c8759e0d8097c6e5009f186 Mon Sep 17 00:00:00 2001 From: Dean Srebnik <49134864+load1n9@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:46:21 -0400 Subject: [PATCH 1/2] chore: bump --- .github/workflows/tests.yml | 2 +- CHANGELOG.md | 2 +- README.md | 4 ++-- cli/build_worker.ts | 7 +------ cli/cms_worker.ts | 8 ++------ core/loaders/mod.ts | 6 +----- core/server.ts | 5 +++-- core/watcher.ts | 4 ++-- core/writer.ts | 7 +++++-- deno.json | 6 +++--- init.ts | 2 +- plugins/decap_cms.ts | 2 +- 12 files changed, 23 insertions(+), 32 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cd60f81f..bdb4bf36 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: run: deno lint - name: Run tests - run: deno task test + run: deno run test - name: Test upgrade run: deno run -A cli.ts upgrade diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ca84c5e..ce667bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -226,7 +226,7 @@ Go to the `v1` branch to see the changelog of Lume 1. - logging: - URL transformation direction is more visually distinct. [#563] - colors replaced to `gray` to support terminals that does not support `dim` colors. [#566] -- `deno task lume upgrade` removes the `deno.lock` file [#527]. +- `deno run lume upgrade` removes the `deno.lock` file [#527]. - `transform_images` plugin: don't enlarge images by default [#530]. ### Fixed diff --git a/README.md b/README.md index 05fb1fc4..bd34556d 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ title: Welcome to my page Build it: -``` -deno run -A https://deno.land/x/lume/cli.ts +```sh +deno -A https://deno.land/x/lume/cli.ts ``` This command will compile your documents to HTML and save them into the diff --git a/cli/build_worker.ts b/cli/build_worker.ts index a321d6ca..fcd96ffa 100644 --- a/cli/build_worker.ts +++ b/cli/build_worker.ts @@ -32,12 +32,7 @@ onmessage = async (event) => { site.root(), ); - function mustReload(files: Set): boolean { - if (files.has(_config)) { - return true; - } - return false; - } + const mustReload = (files: Set): boolean => files.has(_config); watcher.addEventListener("change", (event) => { const files = event.files!; diff --git a/cli/cms_worker.ts b/cli/cms_worker.ts index d37e4adf..b2f3065f 100644 --- a/cli/cms_worker.ts +++ b/cli/cms_worker.ts @@ -43,12 +43,8 @@ onmessage = async (event) => { site.root(), ); - function mustReload(files: Set): boolean { - if (files.has(_config) || files.has(_cms)) { - return true; - } - return false; - } + const mustReload = (files: Set): boolean => + files.has(_config) || files.has(_cms); site.addEventListener("beforeUpdate", (ev) => { if (mustReload(ev.files)) { diff --git a/core/loaders/mod.ts b/core/loaders/mod.ts index c2362d20..e35dd07c 100644 --- a/core/loaders/mod.ts +++ b/core/loaders/mod.ts @@ -30,9 +30,5 @@ const binaryFormats = new Set([ ]); export default function getLoader(extension: string): Loader { - if (binaryFormats.has(extension)) { - return binaryLoader; - } - - return textLoader; + return binaryFormats.has(extension) ? binaryLoader : textLoader; } diff --git a/core/server.ts b/core/server.ts index 8ab3d95c..47b11465 100644 --- a/core/server.ts +++ b/core/server.ts @@ -12,6 +12,7 @@ import { decodeURIComponentSafe } from "./utils/path.ts"; export interface Options extends Deno.ServeOptions { /** The root path */ root: string; + port?: number; } export const defaults: Options = { @@ -92,10 +93,10 @@ export default class Server { stop() { try { this.#server?.shutdown(); - } catch (error) { + } catch (err) { this.dispatchEvent({ type: "error", - error, + error: err as Error, }); } } diff --git a/core/watcher.ts b/core/watcher.ts index 9f6765e2..875f84f1 100644 --- a/core/watcher.ts +++ b/core/watcher.ts @@ -103,8 +103,8 @@ export default class FSWatcher implements Watcher { runningCallback = false; return watcher.close(); } - } catch (error) { - await this.dispatchEvent({ type: "error", error }); + } catch (err) { + await this.dispatchEvent({ type: "error", error: err as Error }); } runningCallback = false; diff --git a/core/writer.ts b/core/writer.ts index e77c2896..4037f3c9 100644 --- a/core/writer.ts +++ b/core/writer.ts @@ -152,8 +152,11 @@ export class FSWriter implements Writer { }`, ); return true; - } catch (error) { - log.error(`Failed to copy file: ${file.outputPath}: ${error.message}`); + } catch (error: unknown) { + log.error( + // deno-lint-ignore no-explicit-any + `Failed to copy file: ${file.outputPath}: ${(error as any).message}`, + ); } return false; diff --git a/deno.json b/deno.json index 28e9654d..323ef7ee 100644 --- a/deno.json +++ b/deno.json @@ -10,9 +10,9 @@ }, "tasks": { "test": "TZ=Z LUME_LOGS=ERROR DENO_FUTURE=1 deno test -A", - "test:update": "deno task test -- --update", - "changelog": "deno run --allow-read --allow-write https://deno.land/x/changelog@v2.5.3/bin.ts", - "update-deps": "deno run -A --quiet 'https://deno.land/x/nudd@v0.2.8/cli.ts' update deps/*.ts deno.json" + "test:update": "deno run test -- --update", + "changelog": "deno --allow-read --allow-write https://deno.land/x/changelog@v2.5.3/bin.ts", + "update-deps": "deno -A --quiet 'https://deno.land/x/nudd@v0.2.8/cli.ts' update deps/*.ts deno.json" }, "imports": { "lume/cms/": "https://cdn.jsdelivr.net/gh/lumeland/cms@0.5.10/" diff --git a/init.ts b/init.ts index 2f510828..4c41bd59 100644 --- a/init.ts +++ b/init.ts @@ -1,7 +1,7 @@ import { run } from "./deps/init.ts"; console.warn( - "This module is deprecated. Use `deno run -A https://lume.land/init.ts` instead.", + "This module is deprecated. Use `deno -A https://lume.land/init.ts` instead.", ); run(); diff --git a/plugins/decap_cms.ts b/plugins/decap_cms.ts index aa769832..fea37e51 100644 --- a/plugins/decap_cms.ts +++ b/plugins/decap_cms.ts @@ -35,7 +35,7 @@ export const defaults: Options = { configKey: "decap_cms", extraHTML: "", proxyCommand: - `deno run --allow-read --allow-net=0.0.0.0 --allow-write --allow-env ${serverUrl}`, + `deno --allow-read --allow-net=0.0.0.0 --allow-write --allow-env ${serverUrl}`, }; /** From 5169e7b6069def205f161b51b7f3d4296325ba14 Mon Sep 17 00:00:00 2001 From: Dean Srebnik <49134864+load1n9@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:29:40 -0400 Subject: [PATCH 2/2] chore: change run to task --- .github/workflows/tests.yml | 2 +- CHANGELOG.md | 2 +- deno.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bdb4bf36..cd60f81f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: run: deno lint - name: Run tests - run: deno run test + run: deno task test - name: Test upgrade run: deno run -A cli.ts upgrade diff --git a/CHANGELOG.md b/CHANGELOG.md index ce667bdd..9ca84c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -226,7 +226,7 @@ Go to the `v1` branch to see the changelog of Lume 1. - logging: - URL transformation direction is more visually distinct. [#563] - colors replaced to `gray` to support terminals that does not support `dim` colors. [#566] -- `deno run lume upgrade` removes the `deno.lock` file [#527]. +- `deno task lume upgrade` removes the `deno.lock` file [#527]. - `transform_images` plugin: don't enlarge images by default [#530]. ### Fixed diff --git a/deno.json b/deno.json index 323ef7ee..511e82d4 100644 --- a/deno.json +++ b/deno.json @@ -10,7 +10,7 @@ }, "tasks": { "test": "TZ=Z LUME_LOGS=ERROR DENO_FUTURE=1 deno test -A", - "test:update": "deno run test -- --update", + "test:update": "deno task test -- --update", "changelog": "deno --allow-read --allow-write https://deno.land/x/changelog@v2.5.3/bin.ts", "update-deps": "deno -A --quiet 'https://deno.land/x/nudd@v0.2.8/cli.ts' update deps/*.ts deno.json" },