diff --git a/package.json b/package.json index a9491fc..311069d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "deploy": "wrangler publish", "dev:miniflare": "cross-env NODE_ENV=development wrangler --env dev dev --port 9999 --live-reload", "typecheck": "tsc", - "test": "vitest --config vitest.config.ts run" + "test": "vitest --config test/vitest.config.ts run" }, "dependencies": { "@cfworker/base64url": "^1.12.5", diff --git a/index.test.ts b/test/index.test.ts similarity index 97% rename from index.test.ts rename to test/index.test.ts index 633eb88..41f90b3 100644 --- a/index.test.ts +++ b/test/index.test.ts @@ -1,15 +1,15 @@ import { afterAll, describe, expect, test } from "vitest"; -import { SHA256_PREFIX_LEN, getSHA256 } from "./src/user"; -import { TagsList } from "./src/router"; -import { Env } from "."; -import { RegistryTokens } from "./src/token"; -import { RegistryAuthProtocolTokenPayload } from "./src/auth"; -import { registries } from "./src/registry/registry"; -import { RegistryHTTPClient } from "./src/registry/http"; +import { SHA256_PREFIX_LEN, getSHA256 } from "../src/user"; +import { TagsList } from "../src/router"; +import { Env } from ".."; +import { RegistryTokens } from "../src/token"; +import { RegistryAuthProtocolTokenPayload } from "../src/auth"; +import { registries } from "../src/registry/registry"; +import { RegistryHTTPClient } from "../src/registry/http"; import { encode } from "@cfworker/base64url"; -import { ManifestSchema } from "./src/manifest"; -import { limit } from "./src/chunk"; -import worker from "./index"; +import { ManifestSchema } from "../src/manifest"; +import { limit } from "../src/chunk"; +import worker from "../index"; import { createExecutionContext, env, waitOnExecutionContext } from "cloudflare:test"; async function generateManifest(name: string): Promise { diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..1ea79c3 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,13 @@ +{ + "include": ["vitest.config.ts"], + "compilerOptions": { + "strict": true, + "module": "esnext", + "target": "esnext", + "lib": ["esnext"], + "moduleResolution": "bundler", + "noEmit": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true + } +} diff --git a/vitest.config.ts b/test/vitest.config.ts similarity index 100% rename from vitest.config.ts rename to test/vitest.config.ts diff --git a/wrangler.test.toml b/test/wrangler.test.toml similarity index 53% rename from wrangler.test.toml rename to test/wrangler.test.toml index f1426c6..20d8ad8 100644 --- a/wrangler.test.toml +++ b/test/wrangler.test.toml @@ -1,7 +1,7 @@ name = "r2-registry" workers_dev = true -main = "./index.ts" +main = "../index.ts" compatibility_date = "2024-09-09" compatibility_flags = ["nodejs_compat"] @@ -13,19 +13,9 @@ r2_buckets = [ [env.production.vars] JWT_REGISTRY_TOKENS_PUBLIC_KEY = "" - -# Secrets: -# USERNAME/PASSWORD if you want username/password based auth - - -## Dev - For local dev using `npx wrangler dev` [env.dev] r2_buckets = [{ binding = "REGISTRY", bucket_name = "r2-image-registry-dev" }] [env.dev.vars] -# REGISTRIES_JSON = "[{ \"registry\": \"http://localhost:9999\", \"password_env\": \"PASSWORD\", \"username\": \"hello\" }]" USERNAME = "hello" PASSWORD = "world" -# The necessary secrets are: -# Setup those secrets on .dev.vars in the root of the project -# diff --git a/tsconfig.json b/tsconfig.json index d9b6b99..b6e3127 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { "extends": "./tsconfig.base.json", - "include": ["src/**/*.ts", "*.ts"], - "exclude": ["src/**/*.js", "dist/**/*.ts"] + "include": ["src/**/*.ts", "index.ts", "test/index.test.ts"], + "exclude": ["src/**/*.js", "dist/**/*.ts", "test/vitest.config.ts"] }