From b8a5486e415cbc029d78167bfd9fbc42e3e48bdd Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 18:03:54 -0400 Subject: [PATCH 01/17] Added compiler options for deno deploy --- www/deno.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/deno.json b/www/deno.json index afd0424..0f034d1 100644 --- a/www/deno.json +++ b/www/deno.json @@ -5,6 +5,11 @@ "tasks": { "dev": "deno run -A --watch main.ts" }, + "compilerOptions": { + "jsx": "react", + "jsxFactory": "React.createElement", + "jsxFragmentFactory": "React.Fragment" + }, "private": true, "imports": { "effection": "npm:effection@3.0.3", From 36ff98ffe6d67a8a506c9546c37a7ee44b1a9c9c Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 19:29:27 -0400 Subject: [PATCH 02/17] Updated JSX config to use revolution --- www/deno.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/www/deno.json b/www/deno.json index 0f034d1..66e3937 100644 --- a/www/deno.json +++ b/www/deno.json @@ -6,9 +6,8 @@ "dev": "deno run -A --watch main.ts" }, "compilerOptions": { - "jsx": "react", - "jsxFactory": "React.createElement", - "jsxFragmentFactory": "React.Fragment" + "jsx": "react-jsx", + "jsxImportSource": "revolution" }, "private": true, "imports": { From 0fbfac40d4fd1a746392f49a2fc185a2f8d9b596 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 19:35:33 -0400 Subject: [PATCH 03/17] try to log the error --- www/hooks/use-packages.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/www/hooks/use-packages.ts b/www/hooks/use-packages.ts index 12ef55a..bdf6a8c 100644 --- a/www/hooks/use-packages.ts +++ b/www/hooks/use-packages.ts @@ -3,12 +3,17 @@ import { type Package, usePackage } from "./use-package.tsx"; import { PrivatePackageError } from "../errors.ts"; export function* usePackages(): Operation { - const root = yield* call(() => - import("../../deno.json", { with: { type: "json" } }) - ); + const root = yield* call(async () => { + try { + const denoJson = await import("../../deno.json", { with: { type: "json" } }) + return denoJson; + } catch (e) { + console.error(e); + } + }); const workspaces: Package[] = []; - for (let workspace of root.default.workspace) { + for (let workspace of root?.default?.workspace ?? []) { try { const pkg = yield* usePackage(workspace); workspaces.push(pkg); From 2055a6d4ce59907fa14c05358c8158846b803205 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 20:30:26 -0400 Subject: [PATCH 04/17] Move entrypoint to root --- deno.json | 9 +++++++-- www/main.ts => main.ts | 6 +++--- www/deno.json | 21 --------------------- www/routes/app.html.tsx | 2 +- 4 files changed, 11 insertions(+), 27 deletions(-) rename www/main.ts => main.ts (86%) delete mode 100644 www/deno.json diff --git a/deno.json b/deno.json index 328e734..bae31cc 100644 --- a/deno.json +++ b/deno.json @@ -1,8 +1,14 @@ { + "tasks": { + "dev": "deno run -A --watch main.ts" + }, "imports": { "effection": "npm:effection", "bdd": "jsr:@std/testing/bdd", - "expect": "jsr:@std/expect" + "expect": "jsr:@std/expect", + "revolution": "https://deno.land/x/revolution@0.6.0/mod.ts", + "revolution/jsx-runtime": "https://deno.land/x/revolution@0.6.0/jsx-runtime.ts", + "effection-www/": "https://raw.githubusercontent.com/thefrontside/effection/4982887c1677b847d256402e8709f2b1d49437e6/www/" }, "compilerOptions": { "lib": [ @@ -25,7 +31,6 @@ } }, "workspace": [ - "./www", "./deno-deploy", "./task-buffer", "./tinyexec", diff --git a/www/main.ts b/main.ts similarity index 86% rename from www/main.ts rename to main.ts index f6479b6..6e28e5f 100644 --- a/www/main.ts +++ b/main.ts @@ -8,9 +8,9 @@ import { twindPlugin } from "effection-www/plugins/twind.ts"; import { etagPlugin } from "effection-www/plugins/etag.ts"; import { rebasePlugin } from "effection-www/plugins/rebase.ts"; -import { assetsRoute } from "./routes/assets-route.ts"; -import { indexRoute } from "./routes/index.tsx"; -import { packageRoute } from "./routes/package.tsx"; +import { assetsRoute } from "./www/routes/assets-route.ts"; +import { indexRoute } from "./www/routes/index.tsx"; +import { packageRoute } from "./www/routes/package.tsx"; // Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts if (import.meta.main) { diff --git a/www/deno.json b/www/deno.json deleted file mode 100644 index 66e3937..0000000 --- a/www/deno.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@effection-contrib/www", - "exports": "./main.ts", - "version": "0.1.0", - "tasks": { - "dev": "deno run -A --watch main.ts" - }, - "compilerOptions": { - "jsx": "react-jsx", - "jsxImportSource": "revolution" - }, - "private": true, - "imports": { - "effection": "npm:effection@3.0.3", - "effection-www/": "https://raw.githubusercontent.com/thefrontside/effection/4982887c1677b847d256402e8709f2b1d49437e6/www/", - "@std/assert": "jsr:@std/assert@1", - "revolution": "https://deno.land/x/revolution@0.6.0/mod.ts", - "revolution/jsx-runtime": "https://deno.land/x/revolution@0.6.0/jsx-runtime.ts", - "@effection-contrib/deno-deploy": "../deno-deploy/mod.ts" - } -} diff --git a/www/routes/app.html.tsx b/www/routes/app.html.tsx index 06ad5a7..81ef52d 100644 --- a/www/routes/app.html.tsx +++ b/www/routes/app.html.tsx @@ -1,6 +1,6 @@ import type { Operation } from "effection"; import type { JSXChild, JSXElement } from "revolution"; -import { useDenoDeploy } from "@effection-contrib/deno-deploy"; +import { useDenoDeploy } from "jsr:@effection-contrib/deno-deploy@0.1.0"; import { useAbsoluteUrl } from "effection-www/plugins/rebase.ts"; import { Header } from "effection-www/components/header.tsx"; From 2a44048a772356768d25336ea60b091f0ce2eecc Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 20:34:43 -0400 Subject: [PATCH 05/17] Use relative path for deno deploy --- main.ts | 2 +- www/hooks/use-packages.ts | 4 +++- www/routes/app.html.tsx | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index 6e28e5f..76c9492 100644 --- a/main.ts +++ b/main.ts @@ -1,6 +1,6 @@ import { main, suspend } from "effection"; import { createRevolution } from "revolution"; -import { initDenoDeploy } from "@effection-contrib/deno-deploy"; +import { initDenoDeploy } from "./deno-deploy/mod.ts"; import { config } from "effection-www/tailwind.config.ts"; import { route, sitemapPlugin } from "effection-www/plugins/sitemap.ts"; diff --git a/www/hooks/use-packages.ts b/www/hooks/use-packages.ts index bdf6a8c..9c3ed0e 100644 --- a/www/hooks/use-packages.ts +++ b/www/hooks/use-packages.ts @@ -5,7 +5,9 @@ import { PrivatePackageError } from "../errors.ts"; export function* usePackages(): Operation { const root = yield* call(async () => { try { - const denoJson = await import("../../deno.json", { with: { type: "json" } }) + const denoJson = await import("../../deno.json", { + with: { type: "json" }, + }); return denoJson; } catch (e) { console.error(e); diff --git a/www/routes/app.html.tsx b/www/routes/app.html.tsx index 81ef52d..2c977f2 100644 --- a/www/routes/app.html.tsx +++ b/www/routes/app.html.tsx @@ -1,6 +1,6 @@ import type { Operation } from "effection"; import type { JSXChild, JSXElement } from "revolution"; -import { useDenoDeploy } from "jsr:@effection-contrib/deno-deploy@0.1.0"; +import { useDenoDeploy } from "../../deno-deploy/mod.ts"; import { useAbsoluteUrl } from "effection-www/plugins/rebase.ts"; import { Header } from "effection-www/components/header.tsx"; From fa415bd45e457c0f0697fe6551354fa694e20d0f Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 20:40:14 -0400 Subject: [PATCH 06/17] Added deno.json with deploy config --- deno.json | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index bae31cc..de28527 100644 --- a/deno.json +++ b/deno.json @@ -27,7 +27,10 @@ }, "lint": { "rules": { - "exclude": ["prefer-const", "require-yield"] + "exclude": [ + "prefer-const", + "require-yield" + ] } }, "workspace": [ @@ -35,5 +38,13 @@ "./task-buffer", "./tinyexec", "./websocket" - ] -} + ], + "deploy": { + "project": "aa1dbfaa-d7c1-49d7-b514-69e1d8344f95", + "exclude": [ + "**/node_modules" + ], + "include": ["**/"], + "entrypoint": "main.ts" + } +} \ No newline at end of file From d8f6300fe0328e2fd569d4cf59db047c0c5fae91 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 20:41:30 -0400 Subject: [PATCH 07/17] Updated format to match output --- deno.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deno.json b/deno.json index de28527..008eedf 100644 --- a/deno.json +++ b/deno.json @@ -44,7 +44,9 @@ "exclude": [ "**/node_modules" ], - "include": ["**/"], + "include": [ + "**/" + ], "entrypoint": "main.ts" } } \ No newline at end of file From 27f8b5867f698d95115704e9996b03d5efa7fe55 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 20:46:34 -0400 Subject: [PATCH 08/17] Added all projects explicitely --- deno.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/deno.json b/deno.json index 008eedf..bde6f5e 100644 --- a/deno.json +++ b/deno.json @@ -42,10 +42,17 @@ "deploy": { "project": "aa1dbfaa-d7c1-49d7-b514-69e1d8344f95", "exclude": [ + "**/node_modules", "**/node_modules" ], "include": [ - "**/" + "deno.json", + "./deno-deploy/", + "./task-buffer/", + "./tinyexec/", + "./websocket/", + "./www", + "./main.ts" ], "entrypoint": "main.ts" } From cb5d1dfd91c355224b0afa36c703346ef2576a51 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 21:38:03 -0400 Subject: [PATCH 09/17] Include everything --- deno.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/deno.json b/deno.json index bde6f5e..bd5c299 100644 --- a/deno.json +++ b/deno.json @@ -42,17 +42,10 @@ "deploy": { "project": "aa1dbfaa-d7c1-49d7-b514-69e1d8344f95", "exclude": [ - "**/node_modules", "**/node_modules" ], "include": [ - "deno.json", - "./deno-deploy/", - "./task-buffer/", - "./tinyexec/", - "./websocket/", - "./www", - "./main.ts" + "." ], "entrypoint": "main.ts" } From a373168d8d22fe4552d4f5f054262d44076fd151 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:21:44 -0400 Subject: [PATCH 10/17] Read directory properly --- deno.json | 2 +- www/hooks/use-package.tsx | 7 ++----- www/hooks/use-packages.ts | 2 ++ www/routes/index.tsx | 8 +++++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/deno.json b/deno.json index bd5c299..2f3a35e 100644 --- a/deno.json +++ b/deno.json @@ -49,4 +49,4 @@ ], "entrypoint": "main.ts" } -} \ No newline at end of file +} diff --git a/www/hooks/use-package.tsx b/www/hooks/use-package.tsx index f012680..045c98a 100644 --- a/www/hooks/use-package.tsx +++ b/www/hooks/use-package.tsx @@ -35,13 +35,10 @@ const DenoJson = z.object({ export const DEFAULT_MODULE_KEY = "."; export function* usePackage(workspace: string): Operation { - const workspacePath = resolve( - import.meta.dirname ?? "", - `../../${workspace}`, - ); + const workspacePath = resolve(Deno.cwd(), workspace); const config: { default: unknown } = yield* call( - () => import(`../../${workspace}/deno.json`, { with: { type: "json" } }), + () => import(`${workspacePath}/deno.json`, { with: { type: "json" } }), ); const denoJson = DenoJson.parse(config.default); diff --git a/www/hooks/use-packages.ts b/www/hooks/use-packages.ts index 9c3ed0e..723b341 100644 --- a/www/hooks/use-packages.ts +++ b/www/hooks/use-packages.ts @@ -14,6 +14,8 @@ export function* usePackages(): Operation { } }); + console.log(`Found ${JSON.stringify(root?.default.workspace)}`); + const workspaces: Package[] = []; for (let workspace of root?.default?.workspace ?? []) { try { diff --git a/www/routes/index.tsx b/www/routes/index.tsx index 0dba332..910edba 100644 --- a/www/routes/index.tsx +++ b/www/routes/index.tsx @@ -2,6 +2,7 @@ import type { SitemapRoute } from "effection-www/plugins/sitemap.ts"; import type { JSXElement } from "revolution"; import { usePackages } from "../hooks/use-packages.ts"; import { useAppHtml } from "./app.html.tsx"; +import { Package } from "../hooks/use-package.tsx"; export function indexRoute(): SitemapRoute { return { @@ -18,7 +19,12 @@ export function indexRoute(): SitemapRoute { pageTitle: "Contribs | Effection", }); - const packages = yield* usePackages(); + let packages: Package[] = []; + try { + packages = yield* usePackages(); + } catch (e) { + console.log("Could not read packages", e); + } return ( From 2454f6a119877310b879092d3f190521a22a1c01 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:28:52 -0400 Subject: [PATCH 11/17] Do not rely on module import for parsing json files --- www/hooks/use-package.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/hooks/use-package.tsx b/www/hooks/use-package.tsx index 045c98a..81b94f0 100644 --- a/www/hooks/use-package.tsx +++ b/www/hooks/use-package.tsx @@ -38,10 +38,10 @@ export function* usePackage(workspace: string): Operation { const workspacePath = resolve(Deno.cwd(), workspace); const config: { default: unknown } = yield* call( - () => import(`${workspacePath}/deno.json`, { with: { type: "json" } }), + async () => JSON.parse(await Deno.readTextFile(`${workspacePath}/deno.json`)), ); - const denoJson = DenoJson.parse(config.default); + const denoJson = DenoJson.parse(config); if (denoJson.private === true) { throw new PrivatePackageError(workspace); From 392767b41d8e724809a60de2cf2af80daa8555e7 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:31:04 -0400 Subject: [PATCH 12/17] Trigger redeploy PR From a9fdf7dbd369c799a048baf1eed18b15f54638f0 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:31:44 -0400 Subject: [PATCH 13/17] Fix formatting --- www/hooks/use-package.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/hooks/use-package.tsx b/www/hooks/use-package.tsx index 81b94f0..e25ab6d 100644 --- a/www/hooks/use-package.tsx +++ b/www/hooks/use-package.tsx @@ -38,7 +38,8 @@ export function* usePackage(workspace: string): Operation { const workspacePath = resolve(Deno.cwd(), workspace); const config: { default: unknown } = yield* call( - async () => JSON.parse(await Deno.readTextFile(`${workspacePath}/deno.json`)), + async () => + JSON.parse(await Deno.readTextFile(`${workspacePath}/deno.json`)), ); const denoJson = DenoJson.parse(config); From 24299a248aaf4e223da599b1904e0cccb9920642 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:33:43 -0400 Subject: [PATCH 14/17] Try bumping again From 615bdfba5491b0860704f84e85f528f9ad5a497c Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:36:25 -0400 Subject: [PATCH 15/17] Move entrypoint back to www --- deno.json | 2 +- main.ts => www/main.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename main.ts => www/main.ts (100%) diff --git a/deno.json b/deno.json index 2f3a35e..cf4f026 100644 --- a/deno.json +++ b/deno.json @@ -47,6 +47,6 @@ "include": [ "." ], - "entrypoint": "main.ts" + "entrypoint": "www/main.ts" } } diff --git a/main.ts b/www/main.ts similarity index 100% rename from main.ts rename to www/main.ts From 7dace5e85c40d67667636915f5f96ff661dfc9d2 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:55:17 -0400 Subject: [PATCH 16/17] Moved entrypoint back to www --- deno.json | 10 +++++----- www/hooks/use-package.tsx | 10 +++++----- www/main.ts | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/deno.json b/deno.json index cf4f026..88eeeb9 100644 --- a/deno.json +++ b/deno.json @@ -1,14 +1,14 @@ { "tasks": { - "dev": "deno run -A --watch main.ts" + "dev": "deno run -A --watch www/main.ts" }, "imports": { - "effection": "npm:effection", - "bdd": "jsr:@std/testing/bdd", - "expect": "jsr:@std/expect", + "effection": "npm:effection@3.0.3", + "effection-www/": "https://raw.githubusercontent.com/thefrontside/effection/4982887c1677b847d256402e8709f2b1d49437e6/www/", "revolution": "https://deno.land/x/revolution@0.6.0/mod.ts", "revolution/jsx-runtime": "https://deno.land/x/revolution@0.6.0/jsx-runtime.ts", - "effection-www/": "https://raw.githubusercontent.com/thefrontside/effection/4982887c1677b847d256402e8709f2b1d49437e6/www/" + "bdd": "jsr:@std/testing/bdd", + "expect": "jsr:@std/expect" }, "compilerOptions": { "lib": [ diff --git a/www/hooks/use-package.tsx b/www/hooks/use-package.tsx index e25ab6d..ba261e5 100644 --- a/www/hooks/use-package.tsx +++ b/www/hooks/use-package.tsx @@ -37,17 +37,17 @@ export const DEFAULT_MODULE_KEY = "."; export function* usePackage(workspace: string): Operation { const workspacePath = resolve(Deno.cwd(), workspace); - const config: { default: unknown } = yield* call( + const config: { private?: boolean } = yield* call( async () => JSON.parse(await Deno.readTextFile(`${workspacePath}/deno.json`)), ); - - const denoJson = DenoJson.parse(config); - - if (denoJson.private === true) { + + if (config.private === true) { throw new PrivatePackageError(workspace); } + const denoJson = DenoJson.parse(config); + const readme = yield* call(async () => { try { return await Deno.readTextFile(join(workspacePath, "README.md")); diff --git a/www/main.ts b/www/main.ts index 76c9492..f446d75 100644 --- a/www/main.ts +++ b/www/main.ts @@ -1,6 +1,6 @@ import { main, suspend } from "effection"; import { createRevolution } from "revolution"; -import { initDenoDeploy } from "./deno-deploy/mod.ts"; +import { initDenoDeploy } from "../deno-deploy/mod.ts"; import { config } from "effection-www/tailwind.config.ts"; import { route, sitemapPlugin } from "effection-www/plugins/sitemap.ts"; @@ -8,9 +8,9 @@ import { twindPlugin } from "effection-www/plugins/twind.ts"; import { etagPlugin } from "effection-www/plugins/etag.ts"; import { rebasePlugin } from "effection-www/plugins/rebase.ts"; -import { assetsRoute } from "./www/routes/assets-route.ts"; -import { indexRoute } from "./www/routes/index.tsx"; -import { packageRoute } from "./www/routes/package.tsx"; +import { assetsRoute } from "./routes/assets-route.ts"; +import { indexRoute } from "./routes/index.tsx"; +import { packageRoute } from "./routes/package.tsx"; // Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts if (import.meta.main) { From 4deea691b33a3c3b6fa36ebc409b0c8dc04990b6 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 5 Oct 2024 22:56:35 -0400 Subject: [PATCH 17/17] Fix format --- www/hooks/use-package.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/hooks/use-package.tsx b/www/hooks/use-package.tsx index ba261e5..8d3491e 100644 --- a/www/hooks/use-package.tsx +++ b/www/hooks/use-package.tsx @@ -41,7 +41,7 @@ export function* usePackage(workspace: string): Operation { async () => JSON.parse(await Deno.readTextFile(`${workspacePath}/deno.json`)), ); - + if (config.private === true) { throw new PrivatePackageError(workspace); }