From 2b85b49c24f4c2e97905b2aa9cae1399203c0dc4 Mon Sep 17 00:00:00 2001 From: 844196 <844196@users.noreply.github.com> Date: Sun, 20 Jul 2025 00:18:22 +0900 Subject: [PATCH] :zap: Use raw-imports --- .gitignore | 5 ++--- deno.jsonc | 3 ++- mise.toml | 5 +++-- src/cli.ts | 8 +++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ef44bfb..fe366f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -.task/ -dist/ -.env +/dist +/VERSION diff --git a/deno.jsonc b/deno.jsonc index ad024c6..927f5ee 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -23,5 +23,6 @@ "@std/path": "jsr:@std/path@1.0.8", "@std/yaml": "jsr:@std/yaml@1.0.5", "xdg-basedir": "npm:xdg-basedir@5.1.0" - } + }, + "unstable": ["raw-imports"] } diff --git a/mise.toml b/mise.toml index d92d79f..29273c8 100644 --- a/mise.toml +++ b/mise.toml @@ -11,10 +11,11 @@ run = 'deno fmt --check' run = 'deno lint' [tasks.'check:type'] +depends = 'generate:version' run = 'deno check src/cli.ts' [tasks.'generate:version'] -run = 'echo "WK_VERSION=${VERSION:-unknown}" > .env' +run = 'echo "${VERSION:-unknown}" > VERSION' [tasks.build] depends = [ @@ -27,5 +28,5 @@ depends = [ [tasks.'build:internal'] depends = 'generate:version' -run = 'deno compile --env-file --allow-all --include src/widget.eta --target {{arg(name="target")}} --output dist/wk-{{arg(name="target")}} src/cli.ts' +run = 'deno compile --allow-all --target {{arg(name="target")}} --output dist/wk-{{arg(name="target")}} src/cli.ts' hide = true diff --git a/src/cli.ts b/src/cli.ts index 39d66c2..c4f1154 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -10,6 +10,8 @@ import { type Context, defaultContext } from './types/Context.ts' import { getKeySymbol, renderPrompt, renderTable } from './ui.ts' import { parse as parseYaml } from '@std/yaml' import { parseArgs } from 'node:util' +import VERSION from '../VERSION' with { type: 'text' } +import WIDGET_TEMPLATE from './widget.eta' with { type: 'text' } const { values: opts } = parseArgs({ options: { @@ -27,14 +29,14 @@ const { values: opts } = parseArgs({ }) if (opts.version) { - console.log(Deno.env.get('WK_VERSION') ?? 'unknown') + console.log(VERSION.trim()) Deno.exit(0) } if (opts.init !== undefined) { - const eta = new Eta({ views: import.meta.dirname }) + const eta = new Eta() - const rendered = eta.render('./widget', { + const rendered = eta.renderString(WIDGET_TEMPLATE, { wk_path: Deno.execPath(), bindkey: opts.init, })