Skip to content

Commit

Permalink
separate rai from lib (#48)
Browse files Browse the repository at this point in the history
resolves #40
  • Loading branch information
wydengyre authored Jan 29, 2024
1 parent 21700f9 commit 9e61e17
Show file tree
Hide file tree
Showing 29 changed files with 58 additions and 36 deletions.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
},
"files": {
"include": ["cf/**/*.ts", "cf/**/*.json","lib/**/*.ts", "lib/**/*.json", "tools/**/*.ts"],
"include": ["rai/**/*.ts", "rai/**/*.json", "server/**/*.ts", "server/**/*.json", "cf/**/*.ts", "cf/**/*.json", "tools/**/*.ts"],
"ignore": ["cf/.wrangler"]
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions cf/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../lib/tsconfig.json",
"extends": "../server/tsconfig.json",
"compilerOptions": {
"types": ["@cloudflare/workers-types"]
},
"include": ["*.ts"],
"exclude": ["*.test.ts"]
"exclude": ["*.test.ts", "declarations.d.ts"]
}
2 changes: 1 addition & 1 deletion cf/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"compilerOptions": {
"types": ["node"]
},
"include": ["*.test.ts", "../lib/declarations.d.ts"],
"include": ["*.test.ts", "declarations.d.ts"],
"exclude": []
}
2 changes: 1 addition & 1 deletion cf/worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getPodcastFromFeed } from "@podverse/podcast-feed-parser";
import { createServerAdapter } from "@whatwg-node/server";
import { Router, RouterType, error, json } from "itty-router";
import { UnstableDevWorker, unstable_dev } from "wrangler";
import genresJson from "../lib/test/generi.json" with { type: "json" };
import genresJson from "../rai/test/generi.json" with { type: "json" };
import feedJson from "./test/lastoriaingiallo.json" with { type: "json" };
import expectedJson from "./test/lastoriaingiallo.parsed.json" with {
type: "json",
Expand Down
4 changes: 2 additions & 2 deletions cf/worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mkFetchHandler } from "../lib/handler.js";
import * as logger from "../lib/logger.js";
import { mkFetchHandler } from "../server/handler.js";
import * as logger from "../server/logger.js";

export default (<ExportedHandler<Env>>{
fetch: (request, env, _ctx) => {
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@
"check": "npm run lint && npm run typecheck",
"ci": "npm run build-podcast && npm run ci-check && npm run test",
"ci-check": "npm run ci-lint && npm run typecheck",
"ci-lint": "biome ci cf lib",
"ci-lint": "biome ci rai server cf tools",
"deploy": "wrangler -c cf/wrangler.toml --env prod deploy",
"deploy-preview": "wrangler -c cf/wrangler.toml deploy --dry-run --outdir '../dist'",
"dev": "wrangler -c cf/wrangler.toml dev",
"lint": "biome check --apply cf lib tools",
"test": "npm run test-lib && npm run test-cf",
"lint": "biome check --apply rai server cf tools",
"test": "npm run test-rai && npm run test-server && npm run test-cf",
"test-cf": "tsx --tsconfig ./cf/tsconfig.json --test 'cf/**/*.test.ts'",
"test-cf-only": "tsx --tsconfig ./cf/tsconfig.json --test --test-only 'cf/**/*.test.ts'",
"test-lib": "tsx --tsconfig ./lib/tsconfig.json --test 'lib/**/*.test.ts'",
"test-lib-only": "tsx --tsconfig ./lib/tsconfig.json --test --test-only 'lib/**/*.test.ts'",
"typecheck": "concurrently \"npm run typecheck-lib\" \"npm run typecheck-cf\" \"npm run typecheck-tools\"",
"test-server": "tsx --tsconfig ./server/tsconfig.json --test 'server/**/*.test.ts'",
"test-server-only": "tsx --tsconfig ./server/tsconfig.json --test --test-only 'server/**/*.test.ts'",
"test-rai": "tsx --tsconfig ./rai/tsconfig.json --test 'rai/**/*.test.ts'",
"test-rai-only": "tsx --tsconfig ./rai/tsconfig.json --test --test-only 'rai/**/*.test.ts'",
"typecheck": "concurrently \"npm run typecheck-rai\" \"npm run typecheck-server\" \"npm run typecheck-cf\" \"npm run typecheck-tools\"",
"//": "the output from typecheck can be hard to read, so we run them serially to make it easier",
"typecheck-serial": "npm run typecheck-lib && npm run typecheck-cf && npm run typecheck-tools",
"typecheck-serial": "npm run typecheck-rai && npm run typecheck-server && npm run typecheck-cf && npm run typecheck-tools",
"typecheck-cf": "npm run typecheck-cf-prod && npm run typecheck-cf-test",
"typecheck-cf-prod": "tsc --project cf/tsconfig.json",
"typecheck-cf-test": "tsc --project cf/tsconfig.test.json",
"typecheck-lib": "npm run typecheck-lib-prod && npm run typecheck-lib-test",
"typecheck-lib-prod": "tsc --project lib/tsconfig.json",
"typecheck-lib-test": "tsc --project lib/tsconfig.test.json",
"typecheck-server": "npm run typecheck-server-prod && npm run typecheck-server-test",
"typecheck-server-prod": "tsc --project server/tsconfig.json",
"typecheck-server-test": "tsc --project server/tsconfig.test.json",
"typecheck-rai": "npm run typecheck-rai-prod && npm run typecheck-rai-test",
"typecheck-rai-prod": "tsc --project rai/tsconfig.json",
"typecheck-rai-test": "tsc --project rai/tsconfig.test.json",
"typecheck-tools": "tsc --project tools/tsconfig.json"
},
"author": "",
Expand Down
1 change: 1 addition & 0 deletions rai/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "@podverse/podcast-feed-parser";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 server/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "@podverse/podcast-feed-parser";
14 changes: 7 additions & 7 deletions lib/feed-handler.test.ts → server/feed-handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { json } from "itty-router";
import { feedHandler } from "./feed-handler.js";
import { FetchWithErr, NotOk, OkResponse } from "./fetch.js";
import * as logger from "./logger.js";
import genresJson from "./test/generi.json";
import feedJson from "./test/lastoriaingiallo.json";
import expectedJson from "./test/lastoriaingiallo.parsed.json" with {
import { FetchWithErr, NotOk, OkResponse } from "../rai/fetch.js";
import genresJson from "../rai/test/generi.json";
import feedJson from "../rai/test/lastoriaingiallo.json";
import expectedJson from "../rai/test/lastoriaingiallo.parsed.json" with {
type: "json",
};
import { parseFeed } from "./test/parse-feed.js";
import { parseFeed } from "../rai/test/parse-feed.js";
import { feedHandler } from "./feed-handler.js";
import * as logger from "./logger.js";

test("feed-handler", async (t) => {
await t.test(rssFeedSuccess);
Expand Down
4 changes: 2 additions & 2 deletions lib/feed-handler.ts → server/feed-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createResponse } from "itty-router";
import { convertFeed } from "./feed.js";
import { FetchWithErr, NotOk } from "./fetch.js";
import { convertFeed } from "../rai/feed.js";
import { FetchWithErr, NotOk } from "../rai/fetch.js";
import { Logger } from "./logger.js";

export { Config, feedHandler };
Expand Down
4 changes: 2 additions & 2 deletions lib/genres.test.ts → server/genres.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { json } from "itty-router";
import { FetchWithErr, NotOk, OkResponse } from "./fetch.js";
import { FetchWithErr, NotOk, OkResponse } from "../rai/fetch.js";
import genresJson from "../rai/test/generi.json" with { type: "json" };
import { genresHtml } from "./genres.js";
import genresJson from "./test/generi.json" with { type: "json" };

test("genres", async (t) => {
await t.test(genresHtmlSuccess);
Expand Down
2 changes: 1 addition & 1 deletion lib/genres.ts → server/genres.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { FetchWithErr } from "./fetch.js";
import { FetchWithErr } from "../rai/fetch.js";

export { Conf, genresHtml };

Expand Down
12 changes: 6 additions & 6 deletions lib/handler.test.ts → server/handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { error, json } from "itty-router";
import { mkFetchHandler } from "./handler.js";
import * as logger from "./logger.js";
import genresJson from "./test/generi.json";
import feedJson from "./test/lastoriaingiallo.json";
import expectedJson from "./test/lastoriaingiallo.parsed.json" with {
import genresJson from "../rai/test/generi.json";
import feedJson from "../rai/test/lastoriaingiallo.json";
import expectedJson from "../rai/test/lastoriaingiallo.parsed.json" with {
type: "json",
};
import { parseFeed } from "./test/parse-feed.js";
import { parseFeed } from "../rai/test/parse-feed.js";
import { mkFetchHandler } from "./handler.js";
import * as logger from "./logger.js";

test("handler", async (t) => {
await t.test(indexSuccess);
Expand Down
2 changes: 1 addition & 1 deletion lib/handler.ts → server/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router, createResponse, error, html, text } from "itty-router";
import { mkFetchWithErr } from "../rai/fetch.js";
import { feedHandler } from "./feed-handler.js";
import { mkFetchWithErr } from "./fetch.js";
import { genresHtml } from "./genres.js";
import { Logger } from "./logger.js";

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../rai/tsconfig.json",
"include": ["*.ts"],
"exclude": ["*.test.ts", "declarations.d.ts"]
}
9 changes: 9 additions & 0 deletions server/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["node"]
},
"include": ["*.test.ts", "declarations.d.ts"],
"exclude": []
}

0 comments on commit 9e61e17

Please sign in to comment.