Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing corepack usage from else clause #11299

Merged
merged 15 commits into from
Jan 16, 2025

Conversation

thavaahariharangit
Copy link
Contributor

@thavaahariharangit thavaahariharangit commented Jan 14, 2025

What are you trying to accomplish?

Removing corepack usage from else clause.

        if Dependabot::Experiments.enabled?(:enable_corepack_for_npm_and_yarn)
          package_manager_run_command(NpmPackageManager::NAME, command, fingerprint: fingerprint)
        else
          Dependabot::SharedHelpers.run_shell_command(
            "npm #{command}",
            fingerprint: "npm #{fingerprint}"
          )
        end

if the corepack is enabled we can use corepack in the command otherwise it's not necessary to use corepack.

Anything you want to highlight for special attention from reviewers?

usage of core pack is forcing package.json to have packageManager version specified. But this is not a npm requirement.

For example packageManger specification in package.json

{
   ...
   "dependencies": {
      "your-dependency": "^1.0.0"
   },
   "packageManager": "[email protected]"
}
2025/01/14 14:57:26 WARN NPM : /usr/lib/node_modules/corepack/dist/lib/corepack.cjs:22090
  throw new UsageError(`No version specified for ${raw2} in "packageManager" of ${source}`);
  ^

UsageError: No version specified for npm in "packageManager" of package.json
  at parseSpec (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:22090:13)
  at loadSpec (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:22164:11)
  at async Engine.findProjectSpec (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:22354:22)
  at async Engine.executePackageManagerRequest (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:22410:24)
  at async Object.runMain (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:23102:5) {
  clipanion: { type: 'usage' }
}

How will you know you've accomplished your goal?

Ran the cli and ensured that there is no need for packageManager version specified in given packages.json

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@thavaahariharangit thavaahariharangit requested a review from a team as a code owner January 14, 2025 15:41
@thavaahariharangit thavaahariharangit marked this pull request as draft January 14, 2025 16:07
@thavaahariharangit thavaahariharangit marked this pull request as ready for review January 15, 2025 15:38
@thavaahariharangit thavaahariharangit merged commit 6a4f8be into main Jan 16, 2025
68 checks passed
@thavaahariharangit thavaahariharangit deleted the harry/removing-corepack-from-else-clause branch January 16, 2025 18:42
thavaahariharangit added a commit that referenced this pull request Jan 16, 2025
thavaahariharangit added a commit that referenced this pull request Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants