Skip to content

Commit aff1ef1

Browse files
authored
Remove Deno package support from workspaces (#1087)
* Remove Deno package support from workspaces Since effectionx only uses Node/PNPM, remove the unused Deno package implementation to simplify the codebase. Changes: - Delete lib/package/deno.ts (Deno package implementation) - Update lib/package/mod.ts to only export Node package - Simplify lib/workspaces/mod.ts to only support PNPM monorepos - Update use-deno-doc.tsx to import DenoJsonSchema from lib/deno-json.ts * fix: apply lint prefer-let rule to workspaces module
1 parent d7870b2 commit aff1ef1

File tree

4 files changed

+15
-252
lines changed

4 files changed

+15
-252
lines changed

www/hooks/use-deno-doc.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { regex } from "arktype";
1212

1313
import { exportHash, extract } from "../components/type/markdown.tsx";
1414
import { operations } from "../context/fetch.ts";
15-
import { DenoJsonSchema } from "../lib/package/deno.ts";
15+
import { DenoJsonSchema } from "../lib/deno-json.ts";
1616
import { useDescription } from "./use-description-parse.tsx";
1717

1818
// Matches npm/jsr specifiers like @std/testing/bdd or lodash/fp

www/lib/package/deno.ts

Lines changed: 0 additions & 202 deletions
This file was deleted.

www/lib/package/mod.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export type { Package, PackageManifest, Ref } from "./types.ts";
2-
export { createDenoPackage, type DenoJson, DenoJsonSchema } from "./deno.ts";
32
export {
43
createNodePackage,
54
type PackageJson,

www/lib/workspaces/mod.ts

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import type { Operation } from "effection";
2-
import { until } from "effection";
1+
import { existsSync } from "node:fs";
32
import { resolve } from "@std/path";
43
import { parse as parseYaml } from "@std/yaml";
4+
import type { Operation } from "effection";
5+
import { until } from "effection";
56
import z from "zod";
6-
import { existsSync } from "node:fs";
77

8-
import type { Workspaces } from "./types.ts";
9-
import type { Package, Ref } from "../package/types.ts";
10-
import { createDenoPackage, DenoJsonSchema } from "../package/deno.ts";
11-
import { createNodePackage } from "../package/node.ts";
128
import { useClone } from "../clones.ts";
9+
import { createNodePackage } from "../package/node.ts";
10+
import type { Package, Ref } from "../package/types.ts";
11+
import type { Workspaces } from "./types.ts";
1312

1413
export type { Workspaces } from "./types.ts";
1514

@@ -20,21 +19,6 @@ const PnpmWorkspaceSchema = z.object({
2019
packages: z.array(z.string()),
2120
});
2221

23-
/**
24-
* Detect workspace type by checking for deno.json or pnpm-workspace.yaml.
25-
*/
26-
function detectWorkspaceType(
27-
rootPath: string,
28-
): "deno" | "node" | null {
29-
if (existsSync(`${rootPath}/deno.json`)) {
30-
return "deno";
31-
}
32-
if (existsSync(`${rootPath}/pnpm-workspace.yaml`)) {
33-
return "node";
34-
}
35-
return null;
36-
}
37-
3822
/**
3923
* Check if a path represents a hidden/internal package that should be excluded.
4024
* Hidden packages start with "." (e.g., ".internal")
@@ -88,19 +72,10 @@ function* expandPatterns(
8872
return dirs;
8973
}
9074

91-
/**
92-
* Get workspace patterns from a Deno monorepo (from deno.json workspace field).
93-
*/
94-
function* getDenoPatterns(rootPath: string): Operation<string[]> {
95-
let content = yield* until(Deno.readTextFile(`${rootPath}/deno.json`));
96-
let denoJson = DenoJsonSchema.parse(JSON.parse(content));
97-
return denoJson.workspace ?? [];
98-
}
99-
10075
/**
10176
* Get workspace patterns from a Node/PNPM monorepo.
10277
*/
103-
function* getNodePatterns(rootPath: string): Operation<string[]> {
78+
function* getWorkspacePatterns(rootPath: string): Operation<string[]> {
10479
let content = yield* until(
10580
Deno.readTextFile(`${rootPath}/pnpm-workspace.yaml`),
10681
);
@@ -111,27 +86,25 @@ function* getNodePatterns(rootPath: string): Operation<string[]> {
11186

11287
/**
11388
* Create a Workspaces instance for a given repository.
89+
* Currently only supports PNPM monorepos.
11490
*
11591
* @param nameWithOwner - GitHub repo in "owner/repo" format
11692
*/
11793
export function* useWorkspaces(nameWithOwner: string): Operation<Workspaces> {
11894
let rootPath = yield* useClone(nameWithOwner);
119-
let type = detectWorkspaceType(rootPath);
12095

121-
if (!type) {
96+
if (!existsSync(`${rootPath}/pnpm-workspace.yaml`)) {
12297
throw new Error(
123-
`Could not detect workspace type for ${nameWithOwner}. ` +
124-
`Expected deno.json or pnpm-workspace.yaml at root.`,
98+
`Could not find pnpm-workspace.yaml for ${nameWithOwner}. ` +
99+
`Only PNPM monorepos are currently supported.`,
125100
);
126101
}
127102

128103
let url = `https://github.com/${nameWithOwner}`;
129104
let refName = "main";
130105

131-
// Get workspace patterns based on type
132-
let patterns = type === "deno"
133-
? yield* getDenoPatterns(rootPath)
134-
: yield* getNodePatterns(rootPath);
106+
// Get workspace patterns from pnpm-workspace.yaml
107+
let patterns = yield* getWorkspacePatterns(rootPath);
135108

136109
// Expand patterns to actual directories
137110
let workspaceDirs = yield* expandPatterns(rootPath, patterns);
@@ -143,13 +116,6 @@ export function* useWorkspaces(nameWithOwner: string): Operation<Workspaces> {
143116
url: `${url}/tree/${refName}/${workspacePath}`,
144117
});
145118

146-
// Create package factory based on type
147-
let createPackage = type === "deno"
148-
? (path: string, name: string, workspacePath: string, ref: Ref) =>
149-
createDenoPackage(path, name, workspacePath, ref)
150-
: (path: string, name: string, workspacePath: string, ref: Ref) =>
151-
createNodePackage(path, name, workspacePath, ref);
152-
153119
// Build lookup caches lazily
154120
let packagesByWorkspace: Map<string, Package> | undefined;
155121
let packagesByName: Map<string, Package> | undefined;
@@ -165,7 +131,7 @@ export function* useWorkspaces(nameWithOwner: string): Operation<Workspaces> {
165131
let workspaceName = workspacePath.split("/").pop()!;
166132
let ref = createRef(workspacePath);
167133

168-
let pkg = createPackage(fullPath, workspaceName, workspacePath, ref);
134+
let pkg = createNodePackage(fullPath, workspaceName, workspacePath, ref);
169135
packagesByWorkspace.set(workspaceName, pkg);
170136

171137
// Get package name for the name lookup

0 commit comments

Comments
 (0)