Skip to content

Conversation

fry69
Copy link

@fry69 fry69 commented Sep 5, 2025

Addresses #239

This is a first attempt for supporting Deno and deno.json/deno.jsonc files. The main motivation is to add support for Deno in changesets.

Disclaimer: This code was written by Google Jules, but reviewed by me. At first glance it looks promising. Please comment.

Jules wrote the pull request message below:


Description

This pull request adds comprehensive support for Deno workspaces to manypkg. The primary motivation is to enable Deno support in downstream tools like changesets, which rely on manypkg's CLI for workspace analysis.

What this PR does:

  • Adds a DenoTool: Implements a new tool for detecting and parsing Deno workspaces based on deno.json or deno.jsonc files.
  • Enables the fix command for Deno: The manypkg fix command now works correctly for Deno projects.
    • The writePackage utility is now tool-aware and correctly writes changes to deno.json and deno.jsonc files.
    • The install utility is also Deno-aware and functions as a no-op to prevent errors during the fix workflow.
  • Improves Dependency Logic:
    • The dependency parsing logic has been made more robust to correctly handle complex dependency URLs, such as those from CDNs with query parameters.
    • The fixing logic for EXTERNAL_MISMATCH and INTERNAL_MISMATCH checks has been refactored to be protocol-agnostic and correctly reconstruct import specifiers.
  • Adapts All Relevant Checks: All applicable checks now work correctly with Deno's dependency model, while non-applicable checks are skipped.
  • Updates CLI run command: The run command correctly uses deno task to execute scripts in Deno projects.
  • Enhances Test Coverage:
    • Adds a new end-to-end test that verifies manypkg fix correctly modifies a deno.jsonc file on the filesystem.
    • Adds a new unit test to validate the improved dependency parsing for complex URLs.
    • All tests now pass, ensuring the new functionality is correct and does not introduce regressions.

Adds support for Deno monorepos to the `get-packages` tool.

This is achieved by:
- Adding a `DenoTool` to `@manypkg/tools` that can read and parse `deno.json` and `deno.jsonc` files.
- Using the `jsonc-parser` library to handle JSON with comments.
- Updating `@manypkg/find-root` to include the new `DenoTool` in the default tool detection.
- Adding a test case to verify the new functionality.
Adds support for Deno monorepos to the `get-packages` tool.

This is achieved by:
- Adding a `DenoTool` to `@manypkg/tools` that can read and parse `deno.json` and `deno.jsonc` files.
- Adding a new `expandDenoPackageGlobs` function to correctly find Deno packages within a monorepo.
- Using the `jsonc-parser` library to handle JSON with comments.
- Updating `@manypkg/find-root` to include the new `DenoTool` in the default tool detection.
- Adding a test case to verify the new functionality.
Copy link

changeset-bot bot commented Sep 5, 2025

⚠️ No Changeset found

Latest commit: 7326401

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@fry69 fry69 force-pushed the feat/deno-support branch from 486485c to d3e7c47 Compare September 5, 2025 12:29
google-labs-jules bot and others added 6 commits September 5, 2025 14:15
This commit expands the tests for Deno configuration files (`deno.json` and `deno.jsonc`) to ensure they can handle complex scenarios.

A new test fixture `complex-deno` has been added, which includes a `deno.jsonc` file with:
- Comments
- Complex import aliases (jsr:, npm:, https:)
- Various other Deno-specific properties

The test case verifies that the `getPackages` function correctly parses this complex configuration and that the returned data is valid.
This commit expands the tests for Deno configuration files (`deno.json` and `deno.jsonc`) to ensure they can handle complex scenarios, including multi-package workspaces.

A new test fixture `complex-deno` has been added, which includes a `deno.jsonc` file with:
- Comments
- Complex import aliases (jsr:, npm:, https:)
- Various other Deno-specific properties

The test fixture has been refactored to represent a multi-package workspace, with the complex configuration distributed among the sub-packages.

The test case verifies that the `getPackages` function correctly parses this complex configuration and that the returned data is valid for all packages in the workspace.
The DenoTool and expandDenoGlobs files contained redundant logic for finding `deno.json` and `deno.jsonc` files. This change abstracts this logic into new `findDenoConfig` and `findDenoConfigSync` helper functions in `utils.ts`.

The following files were updated to use the new helper functions:
- `packages/tools/src/DenoTool.ts`
- `packages/tools/src/expandDenoGlobs.ts`

This refactoring simplifies the code and makes it more maintainable without changing the functionality. All tests pass after the changes.
@fry69 fry69 marked this pull request as ready for review September 5, 2025 14:54
@fry69 fry69 marked this pull request as draft September 5, 2025 18:51
google-labs-jules bot and others added 8 commits September 6, 2025 05:13
This change adds support for deno to the manypkg cli. It updates the `run` command to work with deno projects. It also adds the ability to parse dependencies from the `imports` field in `deno.json` and `deno.jsonc` files.
This commit introduces support for Deno workspaces in the manypkg command-line tool.

The key changes include:
- Refactoring the `run` command logic to be tool-agnostic and support `deno task`.
- Enhancing the `writePackage` utility to correctly detect and write changes to `deno.json` and `deno.jsonc` files.
- Updating the `install` command to be a no-op for Deno, with an explanatory message, as Deno's dependency management differs from Node.js package managers.
- Adding tests to verify the new Deno functionality for the `run` and `writePackage` commands.
This commit introduces support for Deno workspaces in the `manypkg check` command. It makes the following checks Deno-aware:
- EXTERNAL_MISMATCH
- INTERNAL_MISMATCH
- INVALID_PACKAGE_NAME
- UNSORTED_DEPENDENCIES

To achieve this, the codebase was refactored to make the checks "tool-aware". The `Package` object now includes a `tool` property, so that each check can inspect the tool type and apply the correct logic for either Deno or Node.js-based projects.

All `Tool` implementations (`DenoTool`, `YarnTool`, etc.) have been updated to attach the `tool` object to the packages they produce.
Copy link

socket-security bot commented Sep 6, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedjsonc-parser@​3.3.110010010083100

View full report

fry69 and others added 2 commits September 6, 2025 13:45
Moves the DenoJSON type from the tools package to a separate file and exports it from the package's entry point. This allows other packages to import the type using a package-based import instead of a relative path.

This change also adds the @manypkg/tools package as a devDependency to the @manypkg/cli package and updates the import statement in the corresponding test file.
google-labs-jules bot and others added 5 commits September 6, 2025 12:09
This commit updates all remaining cross-package relative imports for the DenoJSON type to use the package-based import from @manypkg/tools.

This change is a follow-up to the previous refactoring and ensures that all cross-package references for this type are consistent with monorepo best practices.
This commit refactors the core types to use a discriminated union for `PackageJSON` and `DenoJSON` in the `Package` interface.

A type guard function `isDenoPackage` has been introduced to safely narrow the type of `packageJson` based on the `tool.type` property. This eliminates the need for unsafe type assertions like `as DenoJSON` throughout the codebase.

All relevant files have been updated to use the new type guard, improving type safety and code readability.
This commit fixes all the TypeScript errors that were reported by `tsc`.

The main changes are:
- Moved the `isDenoPackage` and `isNodePackage` type guards to `packages/tools/src/Tool.ts` to break a circular dependency.
- Updated the test helper `getFakeWS` to return a more specific type to help with type inference in test files.
- Used the `isNodePackage` type guard in all the places where Node.js specific properties were accessed on the `packageJson` object.
Copy link

socket-security bot commented Sep 6, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@fry69 fry69 force-pushed the feat/deno-support branch from 1b7cda0 to 7d79e88 Compare September 6, 2025 13:42
@fry69 fry69 force-pushed the feat/deno-support branch from 6f88bdc to 10d5908 Compare September 6, 2025 14:13
google-labs-jules bot and others added 9 commits September 7, 2025 06:26
This commit introduces the necessary changes to make the `manypkg fix` command fully functional for Deno workspaces.

The key changes include:

- **`writePackage` for Deno:** The `writePackage` utility in the CLI is now tool-aware. It can detect Deno packages and correctly write changes to `deno.json` or `deno.jsonc` files. This unblocks the `fix` command.

- **Deno-aware `install`:** The `install` utility is now Deno-aware and functions as a no-op for Deno projects, preventing errors during the `fix` workflow.

- **Robust Dependency Fixing:** The fixing logic for `EXTERNAL_MISMATCH` and `INTERNAL_MISMATCH` checks has been refactored. It no longer makes unsafe assumptions about the dependency protocol and correctly reconstructs the import specifier.

- **Improved Dependency Parsing:** The regular expression for parsing Deno dependencies has been improved to correctly handle complex URLs from CDNs, especially those with query parameters.

- **Enhanced Test Coverage:** A new end-to-end test has been added to verify that `manypkg fix` works correctly on a Deno project. A unit test for parsing complex dependency URLs has also been added.
This commit refactors the `Package` type in `@manypkg/tools` to be a generic type, `Package<T>`, where `T` can be either `PackageJSON` or `DenoJSON`. This change allows for more specific and type-safe handling of Node.js and Deno packages throughout the codebase.

The main changes are:
- The `Package` interface in `packages/tools/src/Tool.ts` is now generic.
- The `isDenoPackage` and `isNodePackage` type guards have been updated to work with the new generic type.
- All package creation sites and type annotations have been updated to use the new generic `Package<T>` type.

This refactoring eliminates the need for ugly type casts and assertions like `as any` and `& { packageJson: PackageJSON }`, which were previously necessary due to the union type on the `packageJson` property. The codebase is now more type-safe and easier to maintain.
@fry69 fry69 marked this pull request as ready for review September 7, 2025 11:03
@Andarist
Copy link
Collaborator

@fry69 to be fair, I just don't have a lot of bandwidth to handle a PR like this. I can try to take a look in here to answer you or if you ping me (feel free to do so from time to time if I don't respond within a couple of days). I don't promise anything though.

Could you just tell what is the exact scope of the Deno support you'd like to see in manypkg? What doesn't work today at all and what you would like to get fixed? I mean, I get that deno.json is just not handled at all - that's a given. But I'd like to understand better what kind of tasks you'd like to use manypkg for in combination with Deno

@fry69
Copy link
Author

fry69 commented Sep 12, 2025

My motivation is to get some kind of changesets support for Deno working.

With some distance I now see that the bottom up approach and trying to get manypkg working with Deno quirks is probably not the way. Currently I am thinking about a Deno specific fork/replacement for changesets.

I will not further pursue this route and close this pull request. Thank you for your time.

@fry69 fry69 closed this Sep 12, 2025
@Andarist
Copy link
Collaborator

FWIW, to support Deno in Changesets, it would probably make sense to add Deno support to @manypkg/get-packages. With this in place, one could add native Deno support in Changesets

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