Added Grep plug

pull/1003/head
Zef Hemel 2024-07-30 14:04:43 +02:00
parent b2e7bc8494
commit 60ab40005a
12 changed files with 76 additions and 66 deletions

View File

@ -1,8 +1,7 @@
{ {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"deno.enable": true, "deno.enable": true,
"deno.importMap": "import_map.json", "deno.config": "deno.json",
"deno.config": "deno.jsonc",
"deno.unstable": true, "deno.unstable": true,
"[json]": { "[json]": {
"editor.defaultFormatter": "denoland.vscode-deno" "editor.defaultFormatter": "denoland.vscode-deno"

View File

@ -15,8 +15,7 @@ await esbuild.build({
logLevel: "error", logLevel: "error",
minify: true, minify: true,
plugins: denoPlugins({ plugins: denoPlugins({
importMapURL: new URL("./import_map.json", import.meta.url) configPath: new URL("./deno.json", import.meta.url).pathname,
.toString(),
}), }),
}); });
const bundleJs = await Deno.readTextFile("dist/silverbullet.js"); const bundleJs = await Deno.readTextFile("dist/silverbullet.js");

View File

@ -27,6 +27,7 @@ if (import.meta.main) {
debug: args.debug, debug: args.debug,
reload: args.reload, reload: args.reload,
info: args.info, info: args.info,
configPath: new URL("deno.json", import.meta.url).pathname,
}, },
); );
esbuild.stop(); esbuild.stop();

View File

@ -105,8 +105,7 @@ async function buildCopyBundleAssets() {
jsxFragment: "Fragment", jsxFragment: "Fragment",
jsxImportSource: "https://esm.sh/preact@10.23.1", jsxImportSource: "https://esm.sh/preact@10.23.1",
plugins: denoPlugins({ plugins: denoPlugins({
importMapURL: new URL("./import_map.json", import.meta.url) configPath: new URL("./deno.json", import.meta.url).pathname,
.toString(),
}), }),
}); });

View File

@ -12,6 +12,9 @@ const workerRuntimeUrl =
export type CompileOptions = { export type CompileOptions = {
debug?: boolean; debug?: boolean;
runtimeUrl?: string; runtimeUrl?: string;
// path to config file
configPath?: string;
// path to import map
importMap?: string; importMap?: string;
// Reload plug import cache // Reload plug import cache
reload?: boolean; reload?: boolean;
@ -103,9 +106,9 @@ setupMessageListener(functionMapping, manifest);
treeShaking: true, treeShaking: true,
plugins: [ plugins: [
...denoPlugins({ ...denoPlugins({
// TODO do this differently configPath: options.configPath &&
importMapURL: options.importMap || path.resolve(Deno.cwd(), options.configPath),
new URL("../import_map.json", import.meta.url).toString(), importMapURL: options.importMap,
loader: "native", loader: "native",
}), }),
], ],

View File

@ -2,12 +2,13 @@ import { compileManifests } from "./compile.ts";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
export async function plugCompileCommand( export async function plugCompileCommand(
{ watch, dist, debug, info, importmap, runtimeUrl }: { { watch, dist, debug, info, importmap, config, runtimeUrl }: {
watch: boolean; watch: boolean;
dist: string; dist: string;
debug: boolean; debug: boolean;
info: boolean; info: boolean;
importmap?: string; importmap?: string;
config?: string;
runtimeUrl?: string; runtimeUrl?: string;
}, },
...manifestPaths: string[] ...manifestPaths: string[]
@ -23,6 +24,7 @@ export async function plugCompileCommand(
importMap: importmap importMap: importmap
? new URL(importmap, `file://${Deno.cwd()}/`).toString() ? new URL(importmap, `file://${Deno.cwd()}/`).toString()
: undefined, : undefined,
configPath: config,
}, },
); );
esbuild.stop(); esbuild.stop();

View File

@ -1,4 +1,55 @@
{ {
"tasks": {
"clean": "rm -rf dist dist_client_bundle dist_plug_bundle website_build",
"deep-clean-mac": "rm -f deno.lock && rm -rf $HOME/Library/Caches/deno && deno task clean",
"install": "deno install -g -f --unstable-kv --unstable-worker-options -A --import-map deno.json silverbullet.ts",
"check": "find . -name '*.ts*' | xargs deno check",
"test": "deno test -A --unstable-kv --unstable-worker-options",
"bench": "deno bench",
"build": "deno run -A build_plugs.ts && deno run -A build_web.ts",
"plugs": "deno run -A build_plugs.ts",
"server": "deno run -A --unstable-kv --unstable-worker-options --check silverbullet.ts",
"generate": "./scripts/generate.sh",
"watch-web": "deno run -A --check build_web.ts --watch",
"watch-server": "deno run -A --unstable-kv --unstable-worker-options --check --watch silverbullet.ts",
"watch-plugs": "deno run -A --check build_plugs.ts -w",
"bundle": "deno run -A build_bundle.ts",
"compile": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options -o silverbullet dist/silverbullet.js",
"server:dist:linux-x86_64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target x86_64-unknown-linux-gnu -o silverbullet dist/silverbullet.js && zip silverbullet-server-linux-x86_64.zip silverbullet",
"server:dist:linux-aarch64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target aarch64-unknown-linux-gnu -o silverbullet dist/silverbullet.js && zip silverbullet-server-linux-aarch64 silverbullet",
"server:dist:darwin-x86_64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target x86_64-apple-darwin -o silverbullet dist/silverbullet.js && zip silverbullet-server-darwin-x86_64.zip silverbullet",
"server:dist:darwin-aarch64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target aarch64-apple-darwin -o silverbullet dist/silverbullet.js && zip silverbullet-server-darwin-aarch64.zip silverbullet",
"server:dist:windows-x86_64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target x86_64-pc-windows-msvc -o silverbullet.exe dist/silverbullet.js && zip silverbullet-server-windows-x86_64.zip silverbullet.exe"
},
"compilerOptions": {
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"],
"jsx": "react-jsx",
"jsxImportSource": "https://esm.sh/preact@10.23.1"
},
"lint": {
"exclude": [
"dist",
"dist_bundle"
],
"rules": {
"exclude": ["no-explicit-any"]
}
},
"fmt": {
"exclude": [
"dist",
"dist_bundle",
"website",
"website_build",
"test_space",
"README.md"
]
},
"imports": { "imports": {
"@lezer/common": "https://esm.sh/@lezer/common@1.2.1&target=es2022", "@lezer/common": "https://esm.sh/@lezer/common@1.2.1&target=es2022",
"@lezer/lr": "https://esm.sh/@lezer/lr@1.4.1?external=@lezer/common&target=es2022", "@lezer/lr": "https://esm.sh/@lezer/lr@1.4.1?external=@lezer/common&target=es2022",

View File

@ -1,54 +0,0 @@
{
"tasks": {
"clean": "rm -rf dist dist_client_bundle dist_plug_bundle website_build",
"deep-clean-mac": "rm -f deno.lock && rm -rf $HOME/Library/Caches/deno && deno task clean",
"install": "deno install -g -f --unstable-kv --unstable-worker-options -A --importmap import_map.json silverbullet.ts",
"check": "find . -name '*.ts*' | xargs deno check",
"test": "deno test -A --unstable-kv --unstable-worker-options",
"build": "deno run -A build_plugs.ts && deno run -A build_web.ts",
"plugs": "deno run -A build_plugs.ts",
"server": "deno run -A --unstable-kv --unstable-worker-options --check silverbullet.ts",
"watch-web": "deno run -A --check build_web.ts --watch",
"watch-server": "deno run -A --unstable-kv --unstable-worker-options --check --watch silverbullet.ts",
"watch-plugs": "deno run -A --check build_plugs.ts -w",
"bundle": "deno run -A build_bundle.ts",
// Regenerates some bundle files (checked into the repo)
"generate": "./scripts/generate.sh",
// Compile
"compile": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options -o silverbullet dist/silverbullet.js",
"server:dist:linux-x86_64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target x86_64-unknown-linux-gnu -o silverbullet dist/silverbullet.js && zip silverbullet-server-linux-x86_64.zip silverbullet",
"server:dist:linux-aarch64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target aarch64-unknown-linux-gnu -o silverbullet dist/silverbullet.js && zip silverbullet-server-linux-aarch64 silverbullet",
"server:dist:darwin-x86_64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target x86_64-apple-darwin -o silverbullet dist/silverbullet.js && zip silverbullet-server-darwin-x86_64.zip silverbullet",
"server:dist:darwin-aarch64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target aarch64-apple-darwin -o silverbullet dist/silverbullet.js && zip silverbullet-server-darwin-aarch64.zip silverbullet",
"server:dist:windows-x86_64": "deno task bundle && deno compile -A --unstable-kv --unstable-worker-options --target x86_64-pc-windows-msvc -o silverbullet.exe dist/silverbullet.js && zip silverbullet-server-windows-x86_64.zip silverbullet.exe"
},
"compilerOptions": {
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"],
"jsx": "react-jsx",
"jsxImportSource": "https://esm.sh/preact@10.23.1"
},
"importMap": "import_map.json",
"lint": {
"exclude": [
"dist",
"dist_bundle"
],
"rules": {
"exclude": ["no-explicit-any"]
}
},
"fmt": {
"exclude": [
"dist",
"dist_bundle",
"website",
"website_build",
"test_space",
"README.md"
]
}
}

View File

@ -1,4 +1,4 @@
// Remember to keep in sync with import_map.json ! // Remember to keep in sync with deno.json !
// We have to use different deps for client and server as esbuild doesn't // We have to use different deps for client and server as esbuild doesn't
// support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420 // support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420
export { export {

View File

@ -1,4 +1,4 @@
// Remember to keep in sync with import_map.json ! // Remember to keep in sync with deno.json !
// We have to use different deps for client and server as esbuild doesn't // We have to use different deps for client and server as esbuild doesn't
// support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420 // support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420
export { globToRegExp } from "https://deno.land/std@0.165.0/path/glob.ts"; export { globToRegExp } from "https://deno.land/std@0.165.0/path/glob.ts";

View File

@ -72,6 +72,7 @@ await new Command()
{ default: "." }, { default: "." },
) )
.option("--importmap <path:string>", "Path to import map file to use") .option("--importmap <path:string>", "Path to import map file to use")
.option("-c, --config <path:string>", "Path to deno.json file to use")
.option("--runtimeUrl <url:string>", "URL to worker_runtime.ts to use") .option("--runtimeUrl <url:string>", "URL to worker_runtime.ts to use")
.action(plugCompileCommand) .action(plugCompileCommand)
// plug:run // plug:run

9
website/Plugs/Grep.md Normal file
View File

@ -0,0 +1,9 @@
---
uri: https://github.com/Maarrk/silverbullet-grep/releases/latest/download/grep.plug.js
repo: https://github.com/Maarrk/silverbullet-grep
author: Marek S. Łukasiewicz
tags: plug
---
![[!raw.githubusercontent.com/Maarrk/silverbullet-grep/main/README]]
```