Skip to content

Add experimental support for pnpm and yarn#160

Merged
ncalteen merged 3 commits intomainfrom
ncalteen/pnpm-yarn-support
Mar 3, 2025
Merged

Add experimental support for pnpm and yarn#160
ncalteen merged 3 commits intomainfrom
ncalteen/pnpm-yarn-support

Conversation

@ncalteen
Copy link
Copy Markdown
Collaborator

@ncalteen ncalteen commented Mar 3, 2025

This PR adds experimental support for pnpm and yarn.

Depending on the package manager and version, the invocation of the tsx command that drives @github/local-action is invoked differently.

Package Manager Version Command
npm Any npm exec
pnpm Any pnpm dlx
yarn <= 3 yarn exec
yarn >= 4 yarn dlx

Alongside this, yarn PnP support is implemented via unplugging any modules stubbed by @github/local-action and "re-plugging" after completion of the action run.

@ncalteen ncalteen self-assigned this Mar 3, 2025
Copilot AI review requested due to automatic review settings March 3, 2025 19:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR introduces experimental support for pnmp and yarn by adjusting how the action command is executed based on the package manager. Key changes include:

  • Updating the run command logic in src/commands/run.ts to handle different package manager invocations.
  • Adding new tests in tests/utils/package.test.ts and updating the jest configuration.
  • Implementing yarn unplugging and re-plugging logic alongside adjustments in dependency path resolving.

Reviewed Changes

File Description
tests/utils/package.test.ts New tests added for verifying the ESM package detection function.
src/commands/run.ts Extensive modifications to support conditional dependency resolution, including unplugging/re-plugging for yarn.
jest.config.ts Updated coverage ignore patterns to exclude additional files.
src/utils/package.ts Minor update: adding an istanbul-ignore comment before directory pop.
fixtures/fs.ts Added mocks for existsSync and readFileSync to support tests.
tests/commands/run.test.ts Tests for the run command were completely removed.

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

tests/commands/run.test.ts:1

  • The removal of tests in tests/commands/run.test.ts appears to decrease the coverage for the run command functionality. Consider adding tests to validate the behavior of action() after these experimental changes.
import { jest } from '@jest/globals'

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 3, 2025

🦙 MegaLinter status: ❌ ERROR

Descriptor Linter Files Fixed Errors Elapsed time
✅ ACTION actionlint 4 0 0.07s
✅ JAVASCRIPT prettier 11 0 0.83s
✅ JSON npm-package-json-lint yes no 0.83s
✅ JSON prettier 26 0 1.92s
✅ MARKDOWN markdownlint 9 0 1.86s
✅ REPOSITORY checkov yes no 25.35s
✅ REPOSITORY gitleaks yes no 2.08s
✅ REPOSITORY git_diff yes no 0.06s
✅ REPOSITORY grype yes no 24.84s
✅ REPOSITORY secretlint yes no 1.2s
❌ REPOSITORY trivy yes 1 11.65s
✅ REPOSITORY trivy-sbom yes no 1.26s
✅ REPOSITORY trufflehog yes no 29.81s
✅ TYPESCRIPT prettier 70 0 3.99s
✅ YAML prettier 22 0 1.55s
✅ YAML yamllint 22 0 0.99s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@ncalteen ncalteen requested a review from Copilot March 3, 2025 19:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR introduces experimental support for pnpm and yarn by adjusting how the action command is invoked based on the package manager and its version. Key changes include:

  • Updating the command invocation logic in src/commands/run.ts to accommodate npm, pnpm, and yarn.
  • Modifying tests, changelog, and configuration files to reflect the new behavior.
  • Removing the tests/commands/run.test.ts file, potentially affecting test coverage of the run command.

Reviewed Changes

File Description
tests/utils/package.test.ts Added tests for the isESM utility function.
CHANGELOG.md Updated changelog to document experimental support for pnpm and yarn.
src/commands/run.ts Revised logic for determining module paths and handling different package managers.
jest.config.ts Expanded coveragePathIgnorePatterns to include new and modified files.
README.md Updated reference to the changelog.
src/utils/package.ts Minor update to add a missing istanbul ignore comment.
fixtures/fs.ts Extended mocks to include existsSync and readFileSync functions.
tests/commands/run.test.ts Entire test file removed, affecting test coverage for run command.

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

CHANGELOG.md:5

  • The package manager name 'pnmp' appears to be a typo; it should be 'pnpm' to match the proper name and usage in the code.
This version adds **experimental** support for [pnmp](https://pnpm.io/) and

tests/commands/run.test.ts:1

  • The removal of this test file reduces coverage for the run command behavior. Please ensure that critical scenarios remain adequately tested.
Entire file removed

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

@ncalteen ncalteen changed the title Add experimental support for pnmp and yarn Add experimental support for pnpm and yarn Mar 3, 2025
@ncalteen ncalteen merged commit 213fcc2 into main Mar 3, 2025
@ncalteen ncalteen deleted the ncalteen/pnpm-yarn-support branch March 3, 2025 19:15
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