diff --git a/build_plugs.ts b/build_plugs.ts index a3b26619..356c715d 100644 --- a/build_plugs.ts +++ b/build_plugs.ts @@ -2,10 +2,10 @@ import { path } from "./lib/deps_server.ts"; import * as esbuild from "esbuild"; import { compileManifests } from "./cmd/compile.ts"; import { builtinPlugNames } from "./plugs/builtin_plugs.ts"; -import { parse } from "$std/flags/mod.ts"; +import { parseArgs } from "@std/cli/parse-args"; if (import.meta.main) { - const args = parse(Deno.args, { + const args = parseArgs(Deno.args, { boolean: ["debug", "watch", "reload", "info"], alias: { w: "watch" }, }); diff --git a/build_web.ts b/build_web.ts index c07812a0..9004b7f2 100644 --- a/build_web.ts +++ b/build_web.ts @@ -1,9 +1,9 @@ -import { copy } from "$std/fs/copy.ts"; +import { copy } from "@std/fs"; import sass from "denosass"; import { bundleFolder } from "./lib/asset_bundle/builder.ts"; -import { parse } from "$std/flags/mod.ts"; +import { parseArgs } from "@std/cli/parse-args"; import { patchDenoLibJS } from "./cmd/compile.ts"; import { denoPlugins } from "@luca/esbuild-deno-loader"; import * as esbuild from "esbuild"; @@ -126,7 +126,7 @@ async function buildCopyBundleAssets() { } if (import.meta.main) { - const args = parse(Deno.args, { + const args = parseArgs(Deno.args, { boolean: ["watch"], alias: { w: "watch" }, default: { diff --git a/cmd/compile.ts b/cmd/compile.ts index 3459c182..f86f4af6 100644 --- a/cmd/compile.ts +++ b/cmd/compile.ts @@ -2,7 +2,7 @@ import { path, YAML } from "../lib/deps_server.ts"; import { denoPlugins } from "@luca/esbuild-deno-loader"; import * as esbuild from "esbuild"; import { bundleAssets } from "../lib/asset_bundle/builder.ts"; -import { Manifest } from "../lib/plugos/types.ts"; +import type { Manifest } from "../lib/plugos/types.ts"; import { version } from "../version.ts"; // const workerRuntimeUrl = new URL("./worker_runtime.ts", import.meta.url); diff --git a/cmd/plug_run.ts b/cmd/plug_run.ts index 09903a8e..e1305af0 100644 --- a/cmd/plug_run.ts +++ b/cmd/plug_run.ts @@ -1,4 +1,4 @@ -import { resolve } from "$std/path/mod.ts"; +import { resolve } from "@std/path"; import assets from "../dist/plug_asset_bundle.json" with { type: "json" }; import { determineDatabaseBackend } from "../server/db_backend.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; diff --git a/cmd/test/plug_run.test.ts b/cmd/test/plug_run.test.ts index 6c213846..76e69386 100644 --- a/cmd/test/plug_run.test.ts +++ b/cmd/test/plug_run.test.ts @@ -2,8 +2,8 @@ import { AssetBundle } from "$lib/asset_bundle/bundle.ts"; import { compileManifest } from "../compile.ts"; import * as esbuild from "esbuild"; import assets from "../../dist/plug_asset_bundle.json" with { type: "json" }; -import { assertEquals } from "$std/testing/asserts.ts"; -import { dirname, join } from "$std/path/mod.ts"; +import { assertEquals } from "@std/assert"; +import { dirname, join } from "@std/path"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; import { runPlug } from "../plug_run.ts"; diff --git a/cmd/test/runtime.test.ts b/cmd/test/runtime.test.ts index b7553a10..dfd269f2 100644 --- a/cmd/test/runtime.test.ts +++ b/cmd/test/runtime.test.ts @@ -1,6 +1,6 @@ import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts"; import { System } from "../../lib/plugos/system.ts"; -import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; import { compileManifest } from "../compile.ts"; import * as esbuild from "esbuild"; import { diff --git a/cmd/test/test_func.test.ts b/cmd/test/test_func.test.ts index 0d4355b8..29db199b 100644 --- a/cmd/test/test_func.test.ts +++ b/cmd/test/test_func.test.ts @@ -1,6 +1,7 @@ import * as YAML from "js-yaml"; export async function hello() { + // @ts-ignore: syscall is a global function const numbers = await syscall("addNumbers", 1, 2); return { yamlMessage: YAML.dump({ hello: "world" }), diff --git a/cmd/upgrade.ts b/cmd/upgrade.ts index e8cc4198..b8e40e80 100644 --- a/cmd/upgrade.ts +++ b/cmd/upgrade.ts @@ -37,7 +37,7 @@ export async function upgradeCommand() { } // WIP: This is not yet working, but it's a start -import { dirname } from "$std/path/mod.ts"; +import { dirname } from "@std/path"; const silverBulletReleases = "https://github.com/silverbulletmd/silverbullet/releases"; diff --git a/common/command.test.ts b/common/command.test.ts index ef7f2db4..c09be119 100644 --- a/common/command.test.ts +++ b/common/command.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { parseCommand } from "./command.ts"; Deno.test("Command parser", () => { diff --git a/common/expression_parser.test.ts b/common/expression_parser.test.ts index 9363957d..c8f7f239 100644 --- a/common/expression_parser.test.ts +++ b/common/expression_parser.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { parseExpression } from "$common/expression_parser.ts"; Deno.test("Test expression parser", () => { diff --git a/common/markdown_parser/parser.test.ts b/common/markdown_parser/parser.test.ts index 8dcac270..b46ee82f 100644 --- a/common/markdown_parser/parser.test.ts +++ b/common/markdown_parser/parser.test.ts @@ -4,7 +4,7 @@ import { findNodeOfType, renderToText, } from "$sb/lib/tree.ts"; -import { assertEquals, assertNotEquals } from "$std/testing/asserts.ts"; +import { assertEquals, assertNotEquals } from "@std/assert"; import { extendedMarkdownLanguage } from "./parser.ts"; const sample1 = `--- diff --git a/common/query_functions.test.ts b/common/query_functions.test.ts index b94e2ead..3c31d253 100644 --- a/common/query_functions.test.ts +++ b/common/query_functions.test.ts @@ -1,11 +1,7 @@ -import { beforeEach, describe, it } from "$std/testing/bdd.ts"; +import { beforeEach, describe, it } from "@std/testing/bdd"; import { buildQueryFunctions } from "$common/query_functions.ts"; import type { System } from "$lib/plugos/system.ts"; -import { - assertEquals, - assertRejects, - assertThrows, -} from "$std/testing/asserts.ts"; +import { assertEquals, assertRejects, assertThrows } from "@std/assert"; let functions: ReturnType; diff --git a/common/settings.test.ts b/common/settings.test.ts index 590160ca..55888153 100644 --- a/common/settings.test.ts +++ b/common/settings.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { parseYamlSettings } from "./settings.ts"; Deno.test("Settings regex", () => { diff --git a/common/spaces/chunked_datastore_space_primitives.test.ts b/common/spaces/chunked_datastore_space_primitives.test.ts index 1dded6b0..6f2f16a8 100644 --- a/common/spaces/chunked_datastore_space_primitives.test.ts +++ b/common/spaces/chunked_datastore_space_primitives.test.ts @@ -1,5 +1,5 @@ import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts"; import { testSpacePrimitives } from "./space_primitives.test.ts"; diff --git a/common/spaces/disk_space_primitives.ts b/common/spaces/disk_space_primitives.ts index 911eceb8..707ec080 100644 --- a/common/spaces/disk_space_primitives.ts +++ b/common/spaces/disk_space_primitives.ts @@ -1,5 +1,5 @@ -import * as path from "$std/path/mod.ts"; -import { readAll } from "$std/streams/read_all.ts"; +import * as path from "@std/path"; +import { readAll } from "@std/io/read-all"; import { SpacePrimitives } from "./space_primitives.ts"; import { mime } from "mimetypes"; import { FileMeta } from "../../plug-api/types.ts"; diff --git a/common/spaces/space_primitives.test.ts b/common/spaces/space_primitives.test.ts index dff34ad1..5ad3daf9 100644 --- a/common/spaces/space_primitives.test.ts +++ b/common/spaces/space_primitives.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; import { SpacePrimitives } from "./space_primitives.ts"; export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) { diff --git a/common/spaces/sync.test.ts b/common/spaces/sync.test.ts index 72c922c1..b04d2e89 100644 --- a/common/spaces/sync.test.ts +++ b/common/spaces/sync.test.ts @@ -1,6 +1,6 @@ import { SpaceSync, SyncStatusItem } from "./sync.ts"; import { DiskSpacePrimitives } from "./disk_space_primitives.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; Deno.test("Test store", async () => { const primaryPath = await Deno.makeTempDir(); diff --git a/common/template/render.test.ts b/common/template/render.test.ts index ea8f9690..7222c272 100644 --- a/common/template/render.test.ts +++ b/common/template/render.test.ts @@ -1,5 +1,5 @@ import { builtinFunctions } from "../../lib/builtin_query_functions.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { renderTemplate } from "./render.ts"; import { parseTemplate } from "./template_parser.ts"; diff --git a/common/template/template_parser.test.ts b/common/template/template_parser.test.ts index 4669aa54..c4954b2a 100644 --- a/common/template/template_parser.test.ts +++ b/common/template/template_parser.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { parseTemplate } from "./template_parser.ts"; Deno.test("Test template", () => { diff --git a/deno.json b/deno.json index 7ca69968..7032aa78 100644 --- a/deno.json +++ b/deno.json @@ -1,4 +1,15 @@ { + "name": "@silverbulletmd/silverbullet", + "version": "0.0.1", + "exports": { + "./syscalls": "./plug-api/syscalls.ts" + }, + "publish": { + "exclude": [ + "website", + "CHANGELOG.md" + ] + }, "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", @@ -59,7 +70,6 @@ "$common/": "./common/", "$lib/": "./lib/", "$sb/": "./plug-api/", - "$std/": "https://deno.land/std@0.189.0/", "$type/": "./type/", "@codemirror/autocomplete": "https://esm.sh/@codemirror/autocomplete@6.17.0?external=@codemirror/state,@codemirror/commands,@lezer/common,@codemirror/view,@codemirror/language&target=es2022", "@codemirror/commands": "https://esm.sh/@codemirror/commands@6.6.0?external=@codemirror/state,@codemirror/view,@codemirror/language,@lezer/common&target=es2022", @@ -83,6 +93,13 @@ "@lezer/markdown": "https://esm.sh/@lezer/markdown@1.3.0?external=@lezer/common,@codemirror/language,@lezer/highlight,@lezer/lr&target=es2022", "@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3", "@replit/codemirror-vim": "https://esm.sh/@replit/codemirror-vim@6.2.1?external=@codemirror/state,@codemirror/language,@codemirror/view,@codemirror/search,@codemirror/commands", + "@std/assert": "jsr:@std/assert@^1.0.1", + "@std/cli": "jsr:@std/cli@^1.0.1", + "@std/fs": "jsr:@std/fs@^1.0.0", + "@std/io": "jsr:@std/io@^0.224.3", + "@std/io/read-all": "jsr:@std/io@^0.224.3/read-all", + "@std/path": "jsr:@std/path@^1.0.2", + "@std/testing": "jsr:@std/testing@^0.225.3", "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.4/", "crelt": "https://esm.sh/crelt@1.0.6", "denosass": "https://deno.land/x/denosass@1.0.6/mod.ts", diff --git a/lib/asset_bundle/bundle.test.ts b/lib/asset_bundle/bundle.test.ts index 02730a34..da00aaca 100644 --- a/lib/asset_bundle/bundle.test.ts +++ b/lib/asset_bundle/bundle.test.ts @@ -1,5 +1,5 @@ import { AssetBundle } from "./bundle.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; Deno.test("Asset bundle", () => { const assetBundle = new AssetBundle(); diff --git a/lib/async.test.ts b/lib/async.test.ts index 71c4a2bb..092f06ce 100644 --- a/lib/async.test.ts +++ b/lib/async.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; import { batchRequests, PromiseQueue, sleep } from "./async.ts"; Deno.test("PromiseQueue test", async () => { diff --git a/lib/builtin_query_functions.test.ts b/lib/builtin_query_functions.test.ts index 75cd301d..ed7da5af 100644 --- a/lib/builtin_query_functions.test.ts +++ b/lib/builtin_query_functions.test.ts @@ -1,6 +1,6 @@ -import { describe, it } from "$std/testing/bdd.ts"; +import { describe, it } from "@std/testing/bdd"; import { builtinFunctions } from "./builtin_query_functions.ts"; -import { assertEquals, assertThrows } from "$std/testing/asserts.ts"; +import { assertEquals, assertThrows } from "@std/assert"; describe("replace()", () => { const { replace } = builtinFunctions; diff --git a/lib/cheap_yaml.test.ts b/lib/cheap_yaml.test.ts index 9424f39f..691f1ca8 100644 --- a/lib/cheap_yaml.test.ts +++ b/lib/cheap_yaml.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { determineTags, isTemplate } from "./cheap_yaml.ts"; Deno.test("cheap yaml", () => { diff --git a/lib/data/datastore.test.ts b/lib/data/datastore.test.ts index 1d6fd9c8..4a1f962b 100644 --- a/lib/data/datastore.test.ts +++ b/lib/data/datastore.test.ts @@ -3,7 +3,7 @@ import { IndexedDBKvPrimitives } from "../data/indexeddb_kv_primitives.ts"; import { cleanupEmptyObjects, DataStore } from "../data/datastore.ts"; import { DenoKvPrimitives } from "../data/deno_kv_primitives.ts"; import { KvPrimitives } from "../data/kv_primitives.ts"; -import { assertEquals, assertThrows } from "$std/testing/asserts.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts"; import { Query } from "../../plug-api/types.ts"; diff --git a/lib/data/kv_primitives.test.ts b/lib/data/kv_primitives.test.ts index 9c405838..6b0f8135 100644 --- a/lib/data/kv_primitives.test.ts +++ b/lib/data/kv_primitives.test.ts @@ -1,5 +1,5 @@ import { KvPrimitives } from "./kv_primitives.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { KV } from "../../plug-api/types.ts"; export async function allTests(db: KvPrimitives) { diff --git a/lib/data/mq.datastore.test.ts b/lib/data/mq.datastore.test.ts index 46b13ddc..9d458acd 100644 --- a/lib/data/mq.datastore.test.ts +++ b/lib/data/mq.datastore.test.ts @@ -1,9 +1,9 @@ import { DataStoreMQ } from "./mq.datastore.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { DenoKvPrimitives } from "./deno_kv_primitives.ts"; import { DataStore } from "./datastore.ts"; import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts"; -import { FakeTime } from "$std/testing/time.ts"; +import { FakeTime } from "@std/testing/time"; import type { MQMessage } from "../../plug-api/types.ts"; Deno.test("DataStore MQ", async () => { diff --git a/lib/limited_map.test.ts b/lib/limited_map.test.ts index e2d5f2c9..170e83d3 100644 --- a/lib/limited_map.test.ts +++ b/lib/limited_map.test.ts @@ -1,5 +1,5 @@ import { sleep } from "$lib/async.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { LimitedMap } from "./limited_map.ts"; Deno.test("limited map", async () => { diff --git a/lib/memory_cache.test.ts b/lib/memory_cache.test.ts index fcaf5e01..a43797f4 100644 --- a/lib/memory_cache.test.ts +++ b/lib/memory_cache.test.ts @@ -1,6 +1,6 @@ import { ttlCache } from "$lib/memory_cache.ts"; import { sleep } from "$lib/async.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; Deno.test("Memory cache", async () => { let calls = 0; diff --git a/lib/plugos/syscalls/fs.deno.test.ts b/lib/plugos/syscalls/fs.deno.test.ts index 8e7f3680..0e7ae78a 100644 --- a/lib/plugos/syscalls/fs.deno.test.ts +++ b/lib/plugos/syscalls/fs.deno.test.ts @@ -1,5 +1,5 @@ import { FileMeta } from "../../../plug-api/types.ts"; -import { assert } from "$std/testing/asserts.ts"; +import { assert } from "@std/assert"; import { path } from "../../deps_server.ts"; import fileSystemSyscalls from "./fs.deno.ts"; diff --git a/plug-api/lib/attribute.test.ts b/plug-api/lib/attribute.test.ts index 2e4cb4ef..0cb48526 100644 --- a/plug-api/lib/attribute.test.ts +++ b/plug-api/lib/attribute.test.ts @@ -1,7 +1,7 @@ import "$sb/lib/syscall_mock.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { extractAttributes } from "$sb/lib/attribute.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { renderToText } from "./tree.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/feed.test.ts b/plug-api/lib/feed.test.ts index d57d4dfc..84909953 100644 --- a/plug-api/lib/feed.test.ts +++ b/plug-api/lib/feed.test.ts @@ -1,6 +1,6 @@ import "$sb/lib/syscall_mock.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { extractFeedItems } from "$sb/lib/feed.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/json.test.ts b/plug-api/lib/json.test.ts index 17bc9161..e178f7d3 100644 --- a/plug-api/lib/json.test.ts +++ b/plug-api/lib/json.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { cleanupJSON, deepEqual, deepObjectMerge } from "./json.ts"; Deno.test("utils", () => { @@ -18,6 +18,9 @@ Deno.test("utils", () => { assertEquals(cleanupJSON({ a: [{ "a.b": 1 }] }), { a: [{ a: { b: 1 } }], }); - assertEquals(cleanupJSON(new Date("2023-05-13T12:30:00Z")), "2023-05-13T12:30:00.000Z"); + assertEquals( + cleanupJSON(new Date("2023-05-13T12:30:00Z")), + "2023-05-13T12:30:00.000Z", + ); assertEquals(cleanupJSON(new Date("2023-05-03T00:00:00Z")), "2023-05-03"); }); diff --git a/plug-api/lib/page_ref.test.ts b/plug-api/lib/page_ref.test.ts index 7348a4de..7871a015 100644 --- a/plug-api/lib/page_ref.test.ts +++ b/plug-api/lib/page_ref.test.ts @@ -1,9 +1,5 @@ import { encodePageRef, parsePageRef, validatePageName } from "./page_ref.ts"; -import { - assertEquals, - AssertionError, - assertThrows, -} from "$std/testing/asserts.ts"; +import { assertEquals, AssertionError, assertThrows } from "@std/assert"; Deno.test("Page utility functions", () => { // Base cases diff --git a/plug-api/lib/parser-query.test.ts b/plug-api/lib/parser-query.test.ts index aa281fff..b2f4377e 100644 --- a/plug-api/lib/parser-query.test.ts +++ b/plug-api/lib/parser-query.test.ts @@ -1,6 +1,6 @@ import { parse } from "$common/markdown_parser/parse_tree.ts"; import { AST, collectNodesOfType, parseTreeToAST } from "./tree.ts"; -import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; import { astToKvQuery } from "$sb/lib/parse-query.ts"; import { languageFor } from "$common/languages.ts"; diff --git a/plug-api/lib/query_expression.test.ts b/plug-api/lib/query_expression.test.ts index 39f31eb7..b8272cb7 100644 --- a/plug-api/lib/query_expression.test.ts +++ b/plug-api/lib/query_expression.test.ts @@ -1,5 +1,5 @@ import { evalQueryExpression } from "$sb/lib/query_expression.ts"; -import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; Deno.test("Test query expression evaluation", async () => { assertEquals( diff --git a/plug-api/lib/resolve.test.ts b/plug-api/lib/resolve.test.ts index fc593188..0210114f 100644 --- a/plug-api/lib/resolve.test.ts +++ b/plug-api/lib/resolve.test.ts @@ -4,7 +4,7 @@ import { resolvePath, rewritePageRefs, } from "$sb/lib/resolve.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { ParseTree, renderToText } from "./tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/syscall_mock.ts b/plug-api/lib/syscall_mock.ts index 75c6b96e..ed015399 100644 --- a/plug-api/lib/syscall_mock.ts +++ b/plug-api/lib/syscall_mock.ts @@ -1,5 +1,6 @@ import { YAML } from "../../lib/deps_server.ts"; +// @ts-ignore: syscall is a global function globalThis.syscall = (name: string, ...args: readonly any[]) => { switch (name) { case "yaml.parse": diff --git a/plug-api/lib/tree.test.ts b/plug-api/lib/tree.test.ts index 3ed289f4..f5b967e4 100644 --- a/plug-api/lib/tree.test.ts +++ b/plug-api/lib/tree.test.ts @@ -9,7 +9,7 @@ import { renderToText, replaceNodesMatching, } from "./tree.ts"; -import { assertEquals, assertNotEquals } from "$std/testing/asserts.ts"; +import { assertEquals, assertNotEquals } from "@std/assert"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/syscall.ts b/plug-api/syscall.ts index 0042d826..ae6aa293 100644 --- a/plug-api/syscall.ts +++ b/plug-api/syscall.ts @@ -1,16 +1,14 @@ -declare global { - function syscall(name: string, ...args: any[]): Promise; -} +// declare global { +// function syscall(name: string, ...args: any[]): Promise; +// } // This is the case when running tests only, so giving it a dummy syscall function if (typeof self === "undefined") { - // @ts-ignore: test - // deno-lint-ignore no-global-assign - self = { + (self as any) = { syscall: () => { throw new Error("Not implemented here"); }, }; } -export const syscall = globalThis.syscall; +export const syscall = (globalThis as any).syscall; diff --git a/plug-api/syscalls/code_widget.ts b/plug-api/syscalls/code_widget.ts index bfe47232..aea8ada8 100644 --- a/plug-api/syscalls/code_widget.ts +++ b/plug-api/syscalls/code_widget.ts @@ -10,6 +10,6 @@ export function render( } // Refresh all code widgets on the page that support it -export function refreshAll() { +export function refreshAll(): Promise { return syscall("codeWidget.refreshAll"); } diff --git a/plug-api/syscalls/debug.ts b/plug-api/syscalls/debug.ts index 6eea386f..e81a0f08 100644 --- a/plug-api/syscalls/debug.ts +++ b/plug-api/syscalls/debug.ts @@ -1,12 +1,12 @@ import { syscall } from "../syscall.ts"; -export function resetClient() { +export function resetClient(): Promise { return syscall("debug.resetClient"); } /** * Wipes the entire state KV store and the entire space KV store. */ -export function cleanup() { +export function cleanup(): Promise { return syscall("debug.cleanup"); } diff --git a/plug-api/syscalls/editor.ts b/plug-api/syscalls/editor.ts index c270df78..9e80f80f 100644 --- a/plug-api/syscalls/editor.ts +++ b/plug-api/syscalls/editor.ts @@ -19,7 +19,7 @@ export function getText(): Promise { * This updates the editor text, but in a minimal-diff way: * it compares the current editor text with the new text, and only sends the changes to the editor, thereby preserving cursor location */ -export function setText(newText: string) { +export function setText(newText: string): Promise { return syscall("editor.setText", newText); } @@ -183,36 +183,36 @@ export function vimEx(exCommand: string): Promise { } // Folding -export function fold() { +export function fold(): Promise { return syscall("editor.fold"); } -export function unfold() { +export function unfold(): Promise { return syscall("editor.unfold"); } -export function toggleFold() { +export function toggleFold(): Promise { return syscall("editor.toggleFold"); } -export function foldAll() { +export function foldAll(): Promise { return syscall("editor.foldAll"); } -export function unfoldAll() { +export function unfoldAll(): Promise { return syscall("editor.unfoldAll"); } // Undo/redo -export function undo() { +export function undo(): Promise { return syscall("editor.undo"); } -export function redo() { +export function redo(): Promise { return syscall("editor.redo"); } -export function openSearchPanel() { +export function openSearchPanel(): Promise { return syscall("editor.openSearchPanel"); } @@ -220,6 +220,6 @@ export function copyToClipboard(data: string | Blob): Promise { return syscall("editor.copyToClipboard", data); } -export function deleteLine() { +export function deleteLine(): Promise { return syscall("editor.deleteLine"); } diff --git a/plug-api/syscalls/event.ts b/plug-api/syscalls/event.ts index 296ad5e8..97d36150 100644 --- a/plug-api/syscalls/event.ts +++ b/plug-api/syscalls/event.ts @@ -14,7 +14,7 @@ export function dispatchEvent( }, timeout); } syscall("event.dispatch", eventName, data) - .then((r) => { + .then((r: any) => { if (timeouter !== -1) { clearTimeout(timeouter); } diff --git a/plug-api/syscalls/mq.ts b/plug-api/syscalls/mq.ts index 8537506e..56e67aba 100644 --- a/plug-api/syscalls/mq.ts +++ b/plug-api/syscalls/mq.ts @@ -1,19 +1,19 @@ import { syscall } from "../syscall.ts"; import type { MQStats } from "../types.ts"; -export function send(queue: string, body: any) { +export function send(queue: string, body: any): Promise { return syscall("mq.send", queue, body); } -export function batchSend(queue: string, bodies: any[]) { +export function batchSend(queue: string, bodies: any[]): Promise { return syscall("mq.batchSend", queue, bodies); } -export function ack(queue: string, id: string) { +export function ack(queue: string, id: string): Promise { return syscall("mq.ack", queue, id); } -export function batchAck(queue: string, ids: string[]) { +export function batchAck(queue: string, ids: string[]): Promise { return syscall("mq.batchAck", queue, ids); } diff --git a/plug-api/syscalls/system.ts b/plug-api/syscalls/system.ts index c4df4597..ada1ad90 100644 --- a/plug-api/syscalls/system.ts +++ b/plug-api/syscalls/system.ts @@ -39,7 +39,7 @@ export function applyAttributeExtractors( return syscall("system.applyAttributeExtractors", tags, text, tree); } -export function reloadPlugs() { +export function reloadPlugs(): Promise { return syscall("system.reloadPlugs"); } diff --git a/plugs/federation/util.test.ts b/plugs/federation/util.test.ts index 41dd27f6..29d1348a 100644 --- a/plugs/federation/util.test.ts +++ b/plugs/federation/util.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; import { federatedPathToLocalPath, wildcardPathToRegex } from "./util.ts"; Deno.test("Test wildcardPathToRegex", () => { diff --git a/plugs/index/plug_api.ts b/plugs/index/plug_api.ts index 8b9599ad..305875da 100644 --- a/plugs/index/plug_api.ts +++ b/plugs/index/plug_api.ts @@ -1,4 +1,9 @@ -import { KV, KvQuery, ObjectQuery, ObjectValue } from "../../plug-api/types.ts"; +import type { + KV, + KvQuery, + ObjectQuery, + ObjectValue, +} from "../../plug-api/types.ts"; import { ttlCache } from "$lib/memory_cache.ts"; import { system } from "$sb/syscalls.ts"; diff --git a/plugs/index/snippet_extractor.test.ts b/plugs/index/snippet_extractor.test.ts index 3b2471ec..a878ff29 100644 --- a/plugs/index/snippet_extractor.test.ts +++ b/plugs/index/snippet_extractor.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { extractSnippetAroundIndex } from "./snippet_extractor.ts"; Deno.test("SnippetExtractor", () => { diff --git a/plugs/markdown/html_render.test.ts b/plugs/markdown/html_render.test.ts index 3ae739b6..b624b0bc 100644 --- a/plugs/markdown/html_render.test.ts +++ b/plugs/markdown/html_render.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { renderHtml } from "./html_render.ts"; Deno.test("HTML Render", () => { diff --git a/plugs/markdown/markdown_render.test.ts b/plugs/markdown/markdown_render.test.ts index 9d04ebaf..0d4fe9a7 100644 --- a/plugs/markdown/markdown_render.test.ts +++ b/plugs/markdown/markdown_render.test.ts @@ -4,7 +4,7 @@ import { System } from "../../lib/plugos/system.ts"; import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts"; import { renderMarkdownToHtml } from "./markdown_render.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; Deno.test("Markdown render", async () => { const system = new System("server"); diff --git a/scripts/generate_fs_list.ts b/scripts/generate_fs_list.ts index a9f5b57e..6c99d533 100644 --- a/scripts/generate_fs_list.ts +++ b/scripts/generate_fs_list.ts @@ -1,5 +1,5 @@ -import { walk } from "$std/fs/walk.ts"; -import { resolve } from "$std/path/mod.ts"; +import { walk } from "@std/fs/walk"; +import { resolve } from "@std/path"; import { mime } from "mimetypes"; import { FileMeta } from "../plug-api/types.ts"; diff --git a/server/crypto.test.ts b/server/crypto.test.ts index 5f5b0d39..8689f893 100644 --- a/server/crypto.test.ts +++ b/server/crypto.test.ts @@ -1,6 +1,6 @@ import { sleep } from "$lib/async.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { JWTIssuer } from "./crypto.ts"; Deno.test("Test JWT crypto", async () => { diff --git a/server/db_backend.ts b/server/db_backend.ts index 47893725..b0fd10f5 100644 --- a/server/db_backend.ts +++ b/server/db_backend.ts @@ -1,7 +1,7 @@ import { DenoKvPrimitives } from "$lib/data/deno_kv_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { resolve } from "$std/path/mod.ts"; +import { resolve } from "@std/path"; /** * Environment variables: diff --git a/server/http_server.ts b/server/http_server.ts index 67d76d32..f9eaae6b 100644 --- a/server/http_server.ts +++ b/server/http_server.ts @@ -1,18 +1,19 @@ import { deleteCookie, getCookie, setCookie } from "hono/helper.ts"; import { cors } from "hono/middleware.ts"; import { type Context, Hono, type HonoRequest, validator } from "hono/mod.ts"; -import { AssetBundle } from "$lib/asset_bundle/bundle.ts"; -import { EndpointRequest, EndpointResponse, FileMeta } from "$sb/types.ts"; -import { ShellRequest } from "$type/rpc.ts"; -import { SpaceServer, SpaceServerConfig } from "./instance.ts"; -import { KvPrimitives } from "$lib/data/kv_primitives.ts"; +import type { AssetBundle } from "$lib/asset_bundle/bundle.ts"; +import type { EndpointRequest, EndpointResponse, FileMeta } from "$sb/types.ts"; +import type { ShellRequest } from "$type/rpc.ts"; +import { SpaceServer } from "./instance.ts"; +import type { SpaceServerConfig } from "./instance.ts"; +import type { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { renderMarkdownToHtml } from "../plugs/markdown/markdown_render.ts"; import { looksLikePathWithExtension, parsePageRef } from "$sb/lib/page_ref.ts"; import { base64Encode } from "$lib/crypto.ts"; -import * as path from "$std/path/mod.ts"; +import { basename, dirname, join } from "@std/path"; const authenticationExpirySeconds = 60 * 60 * 24 * 7; // 1 week @@ -600,10 +601,10 @@ export class HttpServer { } } - const filename = path.posix.basename(name, mdExt); + const filename = basename(name, mdExt); if (filename.trim() !== filename) { - const newName = path.posix.join( - path.posix.dirname(name), + const newName = join( + dirname(name), filename.trim(), ); return c.redirect(`/${newName}`); @@ -647,7 +648,7 @@ export class HttpServer { return c.text("Forbidden", 403); } - const filename = path.posix.basename(name, mdExt); + const filename = basename(name, mdExt); if (filename.trim() !== filename) { return c.text("Malformed filename", 400); } diff --git a/server/storage_backend.ts b/server/storage_backend.ts index caacf01e..613c77d8 100644 --- a/server/storage_backend.ts +++ b/server/storage_backend.ts @@ -1,6 +1,6 @@ import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts"; import { SpacePrimitives } from "$common/spaces/space_primitives.ts"; -import { resolve } from "$std/path/mod.ts"; +import { resolve } from "@std/path"; import { S3SpacePrimitives } from "$common/spaces/s3_space_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { ChunkedKvStoreSpacePrimitives } from "$common/spaces/chunked_datastore_space_primitives.ts"; diff --git a/web/change.test.ts b/web/change.test.ts index c55bef09..d842f0c1 100644 --- a/web/change.test.ts +++ b/web/change.test.ts @@ -1,5 +1,5 @@ import { rangeLength, rangesOverlap } from "./change.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; Deno.test("rangeLength", () => { assertEquals(rangeLength({ from: 4, to: 11 }), 7); diff --git a/web/fuse_search.test.ts b/web/fuse_search.test.ts index a4fc223f..a8056cf1 100644 --- a/web/fuse_search.test.ts +++ b/web/fuse_search.test.ts @@ -1,5 +1,5 @@ import { FilterOption } from "$lib/web.ts"; -import { assertEquals } from "$std/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { fuzzySearchAndSort } from "./fuse_search.ts"; Deno.test("testFuzzyFilter", () => {