Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
refactor(deps): move all npm:, jsr:, https://deno.land and htt…
Browse files Browse the repository at this point in the history
…ps://esm.sh` imports to `deps/`
  • Loading branch information
miguelrk committed Jun 26, 2024
1 parent bc5e8ad commit 20fede3
Show file tree
Hide file tree
Showing 53 changed files with 126 additions and 107 deletions.
52 changes: 22 additions & 30 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"exclude": [
"_fresh/",
"**/_fresh/*"
],
"exclude": ["**/_fresh/*"],
"lock": false,
"tasks": {
"cache:deps": "deno cache **/deps/**/*.ts",
Expand All @@ -14,34 +11,30 @@
"release": "deno run --allow-run --allow-read tasks/release.ts",
"cov": "deno coverage ./cov/ --lcov --exclude='test.ts|testdata' > cov.lcov"
},
"unstable": [
"cron",
"kv"
],
"unstable": ["cron", "kv", "temporal"],
"lint": {
"exclude": [
"./lib/deps/"
],
"rules": {
"tags": [
"fresh",
"recommended"
]
}
},
"test": {
"exclude": [
"./templates"
]
"exclude": ["./lib/deps/"],
"rules": { "tags": ["fresh", "recommended"] }
},
"test": { "exclude": ["./templates"] },
"fmt": { "lineWidth": 100 },
"compilerOptions": {
"jsx": "react-jsx",
// NOTE: alias "preact" is not being resolved for deno.json(c) of monorepo
// therefore we use react here (this is not needed withing the individual
// projects e.g. under templates/crm/deno.json, since "preact" resolves properly)
// see https://github.com/denoland/deno/issues/20582#issuecomment-1751454928
"jsxImportSource": "https://esm.sh/[email protected]"
"lib": ["dom", "dom.asynciterable", "deno.ns"],
"jsx": "precompile",
"jsxImportSource": "preact",
"jsxImportSourceTypes": "preact/compat",
"jsxPrecompileSkipElements": [
"a",
"img",
"source",
"body",
"html",
"head",
"title",
"link",
"style",
"meta"
]
},
"imports": {
"@/": "./",
Expand All @@ -51,7 +44,6 @@
"react": "npm:[email protected]/compat",
"react-dom": "npm:[email protected]/compat",
"@preact/signals": "npm:@preact/[email protected]",
"@preact/signals-core": "npm:@preact/[email protected]",
"std/": "https://deno.land/[email protected]/"
"@preact/signals-core": "npm:@preact/[email protected]"
}
}
2 changes: 1 addition & 1 deletion lib/apis/create-api/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO: implement tests from https://github.com/johannschopplich/unrested/blob/main/test/index.test.ts
import { assertEquals, assertExists } from "../../deps/std/assert.ts";
import { assertEquals, assertExists } from "../../deps/@std/assert.ts";
import { auth } from "./auth/mod.ts";
import { createApi } from "./mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion lib/apis/jsonplaceholder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals, assertExists } from "../deps/std/assert.ts";
import { assertEquals, assertExists } from "../deps/@std/assert.ts";
import { jsonplaceholder } from "./jsonplaceholder.ts";

Deno.test("[apis] jsonplaceholder", async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/dev/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// adapted from https://github.com/denoland/fresh/blob/main/src/dev/cli.ts
import { type FreshConfig } from "fresh/server.ts";
import { manifest } from "fresh/src/dev/mod.ts";
import { join, toFileUrl } from "../../deps/std/path.ts";
import { join, toFileUrl } from "../../deps/@std/path.ts";

const [cmd, configURL] = Deno.args;

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/netzo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run

import { load } from "../deps/@std/dotenv.ts";
import { parse, semverGreaterThanOrEquals } from "../deps/semver/mod.ts";
import { load } from "../deps/std/dotenv.ts";
import { error } from "../plugins/utils.ts";
import { parseArgs } from "./src/args.ts";
import deploySubcommand from "./src/subcommands/deploy.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/args.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse } from "../../deps/std/flags.ts";
import { parse } from "../../deps/@std/flags.ts";

export function parseArgs(args: string[]) {
const parsed = parse(args, {
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/subcommands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {
Paginated,
Project,
} from "../../../deps/@netzo/api/mod.ts";
import { exists } from "../../../deps/std/fs.ts";
import { fromFileUrl, globToRegExp, isGlob, normalize } from "../../../deps/std/path.ts";
import { exists } from "../../../deps/@std/fs.ts";
import { fromFileUrl, globToRegExp, isGlob, normalize } from "../../../deps/@std/path.ts";
import { Spinner, wait } from "../../../deps/wait/mod.ts";
// vendored x/[email protected] to silence deprecated API warnings (Deno>=1.4)
import { question } from "../../../deps/question/mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/utils/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, toFileUrl } from "../../../deps/std/path.ts";
import { resolve, toFileUrl } from "../../../deps/@std/path.ts";

/**
* Parses the entrypoint to a URL.
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/utils/info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from "../../../deps/std/path.ts";
import { join } from "../../../deps/@std/path.ts";
import { getVersions } from "../subcommands/upgrade.ts";

export function getConfigPaths() {
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/utils/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { fromFileUrl, resolve } from "../../../deps/std/path.ts";
export { fromFileUrl, resolve } from "../../../deps/@std/path.ts";
export { APIError } from "./api.ts";
export { parseEntrypoint } from "./entrypoint.ts";
export { walk } from "./walk.ts";
4 changes: 2 additions & 2 deletions lib/cli/src/utils/netzo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isBinary } from "npm:[email protected]";
import { feathers } from "../../../deps/@feathersjs/feathers.ts";
import { socketio } from "../../../deps/@feathersjs/socketio-client.ts";
import { Project, ProjectAssetsFile } from "../../../deps/@netzo/api/mod.ts";
import { encodeBase64 } from "../../../deps/@std/encoding.ts";
import { isBinary } from "../../../deps/istextorbinary.ts";
import { io } from "../../../deps/socket.io-client.ts";
import { encodeBase64 } from "../../../deps/std/encoding.ts";

export const createClient = async ({
apiKey = Deno.env.get("NETZO_API_KEY")!,
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/utils/walk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, normalize } from "../../../deps/std/path.ts";
import { join, normalize } from "../../../deps/@std/path.ts";
import type { ManifestEntry, ManifestEntryDirectory } from "./netzo.ts";

/** Calculate git object hash, like `git hash-object` does. */
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/tests/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, assertEquals, assertStringIncludes } from "../../deps/std/assert.ts";
import { assert, assertEquals, assertStringIncludes } from "../../deps/@std/assert.ts";
import { netzo, output } from "./utils.ts";

Deno.test("help command list", async () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/database/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertExists } from "../deps/std/assert.ts";
import { assertExists } from "../deps/@std/assert.ts";
import { database } from "./mod.ts";

const db = database({ url: "http://localhost:8080" });
Expand Down
2 changes: 1 addition & 1 deletion lib/database/mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// IMPORTANT: requires importing createClient from /web and not from root nor /node
// see https://github.com/tursodatabase/libsql-client-ts/issues/138#issuecomment-1921954374
import { IS_BROWSER } from "fresh/runtime.ts";
import { createClient } from "npm:/@libsql/client@0.6.0";
import { createClient } from "../deps/@libsql/client.ts";
import { drizzle } from "../deps/drizzle-orm/libsql.ts";
import { drizzle as drizzleSqliteProxy } from "../deps/drizzle-orm/sqlite-proxy.ts";
import type { DrizzleConfig } from "../deps/drizzle-orm/utils.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/datastore/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertExists } from "../deps/std/assert.ts";
import { assertExists } from "../deps/@std/assert.ts";
import { datastore } from "./mod.ts";

const ds = datastore({ kv: await Deno.openKv(":memory:") });
Expand Down
2 changes: 1 addition & 1 deletion lib/datastore/mod.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mingo from "npm:[email protected]";
import { mingo } from "../deps/mingo.ts";
import { monotonicFactory } from "../deps/ulid.ts";

export const ulid = monotonicFactory();
Expand Down
1 change: 1 addition & 0 deletions lib/deps/@libsql/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:/@libsql/[email protected]";
1 change: 1 addition & 0 deletions lib/deps/@mdx-js/mdx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:@mdx-js/[email protected]";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/deps/@std/fmt/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "jsr:@std/[email protected]/colors";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/deps/@types/hast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:@types/[email protected]";
1 change: 1 addition & 0 deletions lib/deps/deep-parse-json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/flat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/istextorbinary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/mdast-util-mdxjs-esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/mingo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as mingo } from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/remark-frontmatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as remarkFrontmatter } from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/remark-gfm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as remarkGfm } from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/ts-morph.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:[email protected]";
1 change: 1 addition & 0 deletions lib/deps/unist-util-visit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "npm:[email protected]";
2 changes: 1 addition & 1 deletion lib/plugins/database/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// deno-lint-ignore-file no-explicit-any
import type { Plugin, PluginRoute } from "fresh/server.ts";
import { createClient } from "npm:@libsql/[email protected]";
import { database as createDatabase } from "../../database/mod.ts";
import { createClient } from "../../deps/@libsql/client.ts";
import { eq, getTableColumns, SQL, sql } from "../../deps/drizzle-orm/mod.ts";
import { SQLiteTable } from "../../deps/drizzle-orm/sqlite-core.ts";
import { DrizzleConfig } from "../../deps/drizzle-orm/utils.ts";
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/datastore/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Plugin, PluginRoute } from "fresh/server.ts";
import { deepParseJson } from "npm:[email protected]";
import { unflatten } from "npm:[email protected]";
import { datastore as createDatastore } from "../../datastore/mod.ts";
import { deepParseJson } from "../../deps/deep-parse-json.ts";
import { unflatten } from "../../deps/flat.ts";
import { apiKeyAuthentication, cors } from "../middleware.ts";
import { parseRequestBody, RESPONSES } from "../utils.ts";

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/environments/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// deno-lint-ignore-file no-explicit-any
import { load } from "jsr:@std/dotenv";
import { netzo } from "../../apis/netzo.ts";
import { load } from "../../deps/@std/dotenv.ts";
import type { Project } from "../types.ts";
import { logInfo, LOGS } from "../utils.ts";

Expand Down
18 changes: 9 additions & 9 deletions lib/plugins/mdx/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type PluginRoute } from "fresh/server.ts";
import { compile } from "npm:@mdx-js/mdx";
import { Root } from "npm:@types/[email protected]";
import { type MdxjsEsm } from "npm:[email protected]";
import { default as remarkFrontmatter } from "npm:[email protected]";
import { default as remarkGfm } from "npm:[email protected]";
import { Project } from "npm:[email protected]";
import { visit } from "npm:[email protected]";
import { walk } from "../../deps/std/fs.ts";
import { join, toFileUrl } from "../../deps/std/path.ts";
import { compile } from "../../deps/@mdx-js/mdx.ts";
import { walk } from "../../deps/@std/fs.ts";
import { join, toFileUrl } from "../../deps/@std/path.ts";
import { Root } from "../../deps/@types/hast.ts";
import { type MdxjsEsm } from "../../deps/mdast-util-mdxjs-esm.ts";
import { remarkFrontmatter } from "../../deps/remark-frontmatter.ts";
import { remarkGfm } from "../../deps/remark-gfm.ts";
import { Project } from "../../deps/ts-morph.ts";
import { visit } from "../../deps/unist-util-visit.ts";

export async function scanForMDXFiles(directory: string): Promise<string[]> {
const files: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/unocss/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { JSX, options as preactOptions, VNode } from "preact";
import { UnoGenerator, type UserConfig } from "../../deps/@unocss/core.ts";
import type { Theme } from "../../deps/@unocss/preset-uno.ts";
// IMPORTANT: import from @std/fs/exists directly to avoid Deno leaking to client
import { existsSync } from "../../deps/@std/fs/exists.ts";
import { minify } from "../../deps/csso.ts";
import { existsSync } from "../../deps/std/fs/exists.ts";
import type { NetzoState } from "../../mod.ts";
import { logInfo } from "../utils.ts";

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// adapted from https://github.com/oaarnikoivu/shadcn-virtualized-combobox
// @deno-types="npm:@types/[email protected]"

import { blue, bold, green, red, white, yellow } from "https://deno.land/[email protected]/fmt/colors.ts";
import { blue, bold, green, red, white, yellow } from "../deps/@std/fmt/colors.ts";
import type { Project } from "./types.ts";

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertExists } from "../deps/std/assert.ts";
import { assertExists } from "../deps/@std/assert.ts";
import { storage } from "./mod.ts";

const db = storage();
Expand Down
57 changes: 28 additions & 29 deletions tests/fixture-plugins-mdx/deno.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"exclude": ["**/_fresh/*"],
"lock": false,
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
Expand All @@ -9,38 +10,36 @@
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
]
}
"unstable": ["cron", "kv", "temporal"],
"lint": { "rules": { "tags": ["fresh", "recommended"] } },
"fmt": { "lineWidth": 100 },
"compilerOptions": {
"lib": ["dom", "dom.asynciterable", "deno.ns"],
"jsx": "precompile",
"jsxImportSource": "preact",
"jsxImportSourceTypes": "preact/compat",
"jsxPrecompileSkipElements": [
"a",
"img",
"source",
"body",
"html",
"head",
"title",
"link",
"style",
"meta"
]
},
"exclude": [
"**/_fresh/*"
],
"imports": {
"@/": "./",
"netzo/": "../../lib/",
"fresh/": "https://deno.land/x/[email protected]/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"preact-render-to-string": "https://esm.sh/*[email protected]",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
"@preact/signals-core": "https://esm.sh/*@preact/[email protected]",
"react": "https://esm.sh/[email protected]/compat",
"react-dom": "https://esm.sh/[email protected]/compat",
"std/": "https://deno.land/[email protected]/",
"react/jsx-runtime": "https://esm.sh/[email protected]/compat",
"tailwindcss": "npm:[email protected]",
"tailwindcss/": "npm:/[email protected]/",
"tailwindcss/plugin": "npm:/[email protected]/plugin.js",
"$std/": "https://deno.land/[email protected]/"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"nodeModulesDir": true
"preact": "npm:[email protected]",
"react": "npm:[email protected]/compat",
"react-dom": "npm:[email protected]/compat",
"@preact/signals": "npm:@preact/[email protected]",
"@preact/signals-core": "npm:@preact/[email protected]",
"@std/dotenv": "jsr:@std/[email protected]"
}
}
2 changes: 1 addition & 1 deletion tests/fixture-plugins-mdx/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
import dev from "fresh/dev.ts";
import config from "./fresh.config.ts";

import "$std/dotenv/load.ts";
import "@std/dotenv/load";

await dev(import.meta.url, "./main.ts", config);
2 changes: 1 addition & 1 deletion tests/fixture-plugins-mdx/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />

import "$std/dotenv/load.ts";
import "@std/dotenv/load";

import { start } from "fresh/server.ts";
import config from "./fresh.config.ts";
Expand Down
Loading

0 comments on commit 20fede3

Please sign in to comment.