cover Deno workspaces in setup-github-actions#106
Conversation
|
View your CI Pipeline Execution ↗ for commit b8266e3
☁️ Nx Cloud last updated this comment at |
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/intent/tests/setup.test.ts (1)
349-360: Minor:usePackageJsonWorkspacesflag is overwritten.The test passes
usePackageJsonWorkspaces: truetocreateMonorepo, but then immediately overwrites the generatedpackage.json(which would have includedworkspaces) with one that has no workspaces field. Consider omitting the flag or usingfalseto 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 sinceJSON.parsewill 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
📒 Files selected for processing (5)
.changeset/spicy-laws-burn.mdpackages/intent/src/workspace-patterns.tspackages/intent/tests/project-context.test.tspackages/intent/tests/setup.test.tspackages/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>
KyleAMathews
left a comment
There was a problem hiding this comment.
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.jsonas JSONC — Deno officially supports comments in bothdeno.jsonanddeno.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
SyntaxErrorinstead of passing garbled output toJSON.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.workspacesaccess — Replaced verbose type guard with typed local variable and optional chaining.
All 41 tests pass.
Summary
Summary by CodeRabbit
New Features
Bug Fixes
Tests