Skip to content

Commit

Permalink
Merge pull request #20 from thefrontside/tm/add-compiler-configs
Browse files Browse the repository at this point in the history
Make www a non-workspace
  • Loading branch information
taras authored Oct 6, 2024
2 parents 48b5bf3 + 4deea69 commit 038d475
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
26 changes: 22 additions & 4 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"tasks": {
"dev": "deno run -A --watch www/main.ts"
},
"imports": {
"effection": "npm:effection",
"effection": "npm:[email protected]",
"effection-www/": "https://raw.githubusercontent.com/thefrontside/effection/4982887c1677b847d256402e8709f2b1d49437e6/www/",
"revolution": "https://deno.land/x/[email protected]/mod.ts",
"revolution/jsx-runtime": "https://deno.land/x/[email protected]/jsx-runtime.ts",
"bdd": "jsr:@std/testing/bdd",
"expect": "jsr:@std/expect"
},
Expand All @@ -21,14 +27,26 @@
},
"lint": {
"rules": {
"exclude": ["prefer-const", "require-yield"]
"exclude": [
"prefer-const",
"require-yield"
]
}
},
"workspace": [
"./www",
"./deno-deploy",
"./task-buffer",
"./tinyexec",
"./websocket"
]
],
"deploy": {
"project": "aa1dbfaa-d7c1-49d7-b514-69e1d8344f95",
"exclude": [
"**/node_modules"
],
"include": [
"."
],
"entrypoint": "www/main.ts"
}
}
17 changes: 0 additions & 17 deletions www/deno.json

This file was deleted.

16 changes: 7 additions & 9 deletions www/hooks/use-package.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,19 @@ const DenoJson = z.object({
export const DEFAULT_MODULE_KEY = ".";

export function* usePackage(workspace: string): Operation<Package> {
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" } }),
const config: { private?: boolean } = yield* call(
async () =>
JSON.parse(await Deno.readTextFile(`${workspacePath}/deno.json`)),
);

const denoJson = DenoJson.parse(config.default);

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"));
Expand Down
17 changes: 13 additions & 4 deletions www/hooks/use-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ import { type Package, usePackage } from "./use-package.tsx";
import { PrivatePackageError } from "../errors.ts";

export function* usePackages(): Operation<Package[]> {
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);
}
});

console.log(`Found ${JSON.stringify(root?.default.workspace)}`);

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);
Expand Down
2 changes: 1 addition & 1 deletion www/main.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion www/routes/app.html.tsx
Original file line number Diff line number Diff line change
@@ -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 "../../deno-deploy/mod.ts";

import { useAbsoluteUrl } from "effection-www/plugins/rebase.ts";
import { Header } from "effection-www/components/header.tsx";
Expand Down
8 changes: 7 additions & 1 deletion www/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<JSXElement> {
return {
Expand All @@ -18,7 +19,12 @@ export function indexRoute(): SitemapRoute<JSXElement> {
pageTitle: "Contribs | Effection",
});

const packages = yield* usePackages();
let packages: Package[] = [];
try {
packages = yield* usePackages();
} catch (e) {
console.log("Could not read packages", e);
}

return (
<AppHTML>
Expand Down

0 comments on commit 038d475

Please sign in to comment.