Skip to content

cover Deno workspaces in setup-github-actions#106

Merged
LadyBluenotes merged 6 commits intomainfrom
deno-workspaces-pr
Mar 31, 2026
Merged

cover Deno workspaces in setup-github-actions#106
LadyBluenotes merged 6 commits intomainfrom
deno-workspaces-pr

Conversation

@LadyBluenotes
Copy link
Copy Markdown
Member

@LadyBluenotes LadyBluenotes commented Mar 30, 2026

Summary

  • add Deno workspace support to readWorkspacePatterns, including deno.json and deno.jsonc
  • handle JSONC comments and trailing commas so Deno workspace config parses cleanly without a new dependency
  • expand coverage across workspace parsing, project context resolution, and setup-github-actions so Deno monorepos resolve their workspace root and monorepo paths correctly

Summary by CodeRabbit

  • New Features

    • Added support for Deno monorepo configuration (deno.json / deno.jsonc) for workspace pattern detection.
    • GitHub Actions setup now writes workflows to the monorepo root with correct workspace-aware path substitutions.
  • Bug Fixes

    • Improved handling of mixed npm/Deno workspace configs and more robust JSONC parsing with clearer warnings on parse/read failures.
  • Tests

    • Added tests covering Deno workspace detection and workflow writing behavior.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 30, 2026

View your CI Pipeline Execution ↗ for commit b8266e3

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-31 23:03:04 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 30, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@tanstack/intent@106

commit: b8266e3

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07911424-1c1d-4aab-a257-a28c6a3584ba

📥 Commits

Reviewing files that changed from the base of the PR and between bd5d731 and b8266e3.

📒 Files selected for processing (1)
  • packages/intent/src/workspace-patterns.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/intent/src/workspace-patterns.ts

📝 Walkthrough

Walkthrough

Adds JSONC/lenient JSON parsing and Deno workspace (deno.json / deno.jsonc) detection to workspace pattern resolution, updates workspace-aware GitHub Actions setup to write workflows at the monorepo root, and adds tests and a changeset documenting the change.

Changes

Cohort / File(s) Summary
Changesets
\.changeset/spicy-laws-burn.md
Added a patch-level changeset entry describing Deno monorepo setup coverage for @tanstack/intent.
Workspace pattern logic
packages/intent/src/workspace-patterns.ts
Added JSONC/lenient JSON helpers (stripJsonCommentsAndTrailingCommas, readJsonFile), updated readWorkspacePatterns to prefer package.json workspaces but also detect/parse deno.json/deno.jsonc (JSONC), extract Deno workspace patterns, and log warnings on read/parse failures with file path context.
Tests
packages/intent/tests/...
packages/intent/tests/project-context.test.ts, packages/intent/tests/setup.test.ts, packages/intent/tests/workspace-patterns.test.ts
Added tests covering: Deno workspace detection in project context resolution, workflow writing to the monorepo root when invoked from a workspace package (with Deno workspace present), reading workspace patterns from deno.json/deno.jsonc (including JSONC comments), precedence of package.json over Deno config, and logging on invalid Deno config parsing.

Sequence Diagram

sequenceDiagram
    participant Setup as runSetupGithubActions
    participant Context as resolveProjectContext
    participant Patterns as readWorkspacePatterns
    participant FS as FileSystem

    Setup->>Context: request context from workspace package
    Context->>Patterns: request workspace patterns
    Patterns->>FS: check `package.json`
    FS-->>Patterns: return `workspaces` (if present)
    Patterns->>FS: check `deno.jsonc` / `deno.json` (if needed)
    FS-->>Patterns: return JSONC content
    Patterns->>Patterns: strip comments / trailing commas, parse, extract `workspace`
    Patterns-->>Context: return resolved workspace patterns + root path
    Context-->>Setup: provide workspaceRoot and patterns
    Setup->>FS: write workflows to `<workspaceRoot>/.github/workflows/`
    FS-->>Setup: confirm workflow files written
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nibble comments from JSONC,

I hop the workspace root with glee,
Workflows scattered, now unite,
Deno roots glowing in moonlight,
A tiny rabbit cheers: "We see!"

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is missing the required template sections (Changes, Checklist, and Release Impact) and instead provides only a summary of changes without following the specified structure. Rewrite the description using the required template with 🎯 Changes, ✅ Checklist (with Contributing guide and test steps), and 🚀 Release Impact sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'cover Deno workspaces in setup-github-actions' is concise and clearly summarizes the main objective of the PR: adding Deno workspace support to the setup-github-actions tool.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch deno-workspaces-pr

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/intent/tests/setup.test.ts (1)

349-360: Minor: usePackageJsonWorkspaces flag is overwritten.

The test passes usePackageJsonWorkspaces: true to createMonorepo, but then immediately overwrites the generated package.json (which would have included workspaces) with one that has no workspaces field. Consider omitting the flag or using false to make the test setup clearer.

Suggested cleanup
   it('writes workflows to the Deno workspace root from a workspace package', () => {
     const monoRoot = createMonorepo({
-      usePackageJsonWorkspaces: true,
       packages: [
         { name: 'router', hasSkills: true },
         { name: 'start', hasSkills: true },
       ],
     })
+
+    // Overwrite root package.json to remove pnpm-workspace.yaml-based detection
+    // so the test relies solely on deno.jsonc for workspace resolution.
+    writeFileSync(
+      join(monoRoot, 'package.json'),
+      JSON.stringify({ name: 'root', private: true }, null, 2),
+    )
+    rmSync(join(monoRoot, 'pnpm-workspace.yaml'), { force: true })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/intent/tests/setup.test.ts` around lines 349 - 360, The test
currently passes usePackageJsonWorkspaces: true to createMonorepo but then
immediately overwrites the generated package.json with writeFileSync, removing
the workspaces field; either remove the flag (usePackageJsonWorkspaces) or set
it to false when calling createMonorepo, or stop overwriting package.json so the
workspaces generated by createMonorepo remain; update the call site using
createMonorepo and/or the subsequent writeFileSync to ensure package.json
content reflects the intended test setup.
packages/intent/src/workspace-patterns.ts (1)

67-77: Consider handling unclosed block comments gracefully.

If a block comment is opened but never closed (e.g., /* unterminated), the loop exits without error and parsing continues with potentially malformed JSON. This is unlikely to cause issues since JSON.parse will fail anyway, but you could optionally emit a more descriptive warning.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/intent/src/workspace-patterns.ts` around lines 67 - 77, The
block-comment handling loop that checks for "/*" and advances index until "*/"
can run off the end of the input without notice; inside the branch that starts
with if (char === '/' && next === '*') modify the logic to detect EOF after the
inner while (i.e., when index >= source.length) and handle it explicitly: either
emit a descriptive warning (e.g., console.warn with the offending snippet and
position) or throw a SyntaxError so callers get a clear message instead of
continuing to parse malformed JSON; use the existing variables (source, index,
char, next) to build the message and ensure the code still advances/returns
correctly after handling the unclosed comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/intent/src/workspace-patterns.ts`:
- Around line 67-77: The block-comment handling loop that checks for "/*" and
advances index until "*/" can run off the end of the input without notice;
inside the branch that starts with if (char === '/' && next === '*') modify the
logic to detect EOF after the inner while (i.e., when index >= source.length)
and handle it explicitly: either emit a descriptive warning (e.g., console.warn
with the offending snippet and position) or throw a SyntaxError so callers get a
clear message instead of continuing to parse malformed JSON; use the existing
variables (source, index, char, next) to build the message and ensure the code
still advances/returns correctly after handling the unclosed comment.

In `@packages/intent/tests/setup.test.ts`:
- Around line 349-360: The test currently passes usePackageJsonWorkspaces: true
to createMonorepo but then immediately overwrites the generated package.json
with writeFileSync, removing the workspaces field; either remove the flag
(usePackageJsonWorkspaces) or set it to false when calling createMonorepo, or
stop overwriting package.json so the workspaces generated by createMonorepo
remain; update the call site using createMonorepo and/or the subsequent
writeFileSync to ensure package.json content reflects the intended test setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 641d45c9-9dc4-445a-8a47-08965e6c242e

📥 Commits

Reviewing files that changed from the base of the PR and between 2f29aa2 and bd5d731.

📒 Files selected for processing (5)
  • .changeset/spicy-laws-burn.md
  • packages/intent/src/workspace-patterns.ts
  • packages/intent/tests/project-context.test.ts
  • packages/intent/tests/setup.test.ts
  • packages/intent/tests/workspace-patterns.test.ts

- Always parse deno.json as JSONC (Deno supports comments in both extensions)
- Fix trailing comma stripping when followed by comments before closing brackets
- Detect unterminated block comments with descriptive error
- Distinguish I/O vs parse errors in warning messages
- Simplify pkg.workspaces type handling with optional chaining

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff. The Deno workspace detection is well-structured and follows existing patterns. I pushed one commit with targeted improvements:

  • Always parse deno.json as JSONC — Deno officially supports comments in both deno.json and deno.jsonc, so the JSONC stripping should always apply. The stripping function is a no-op on valid JSON, so this is safe.
  • Fix trailing comma + comment interaction — The trailing comma lookahead now skips over line and block comments, fixing a case where valid JSONC like "item", // comment\n] would fail to parse.
  • Detect unterminated block comments — Throws a descriptive SyntaxError instead of passing garbled output to JSON.parse.
  • Distinguish I/O vs parse errors — All three catch blocks now say "failed to read" for filesystem errors and "failed to parse" for syntax errors, across pnpm, package.json, and Deno config blocks.
  • Simplify pkg.workspaces access — Replaced verbose type guard with typed local variable and optional chaining.

All 41 tests pass.

@LadyBluenotes LadyBluenotes merged commit 6261e78 into main Mar 31, 2026
5 checks passed
@LadyBluenotes LadyBluenotes deleted the deno-workspaces-pr branch March 31, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants