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

feat(core): add install modes #2913

Merged
merged 7 commits into from
Jul 18, 2021
Merged

Conversation

ylemkimon
Copy link
Contributor

@ylemkimon ylemkimon commented May 21, 2021

What's the problem this PR addresses?

As a Yarn user, I want to be able to update the Yarn lock file to match my package.json file(s) without needing to download all dependencies.

From and fixes #2908.

How did you fix it?

Added a CLI flag --mode that, when set to update-lockfile, changes the install to only fetch packages without a checksum (newly added entries) and skip the link step.

This can be used in dependency management tools such as Renovate (#2908) and Dependabot (dependabot/dependabot-core#1297).

I've tested this PR with Renovate in https://github.com/ylemkimon/KaTeX/pulls and it successfully updates the checksum.

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

If true, Yarn will only fetch packages of which checksum doesn't exist
and skip the link step during the install.
@roni-frantchi
Copy link

Thanks for the PR @ylemkimon !
Really need this one to get our Renovate to play ball with our Yarn 2 bump.

@arcanis any chance you could please help us push this one forward?...

@arcanis
Copy link
Member

arcanis commented Jul 6, 2021

I didn't forget this PR! Sorry for the delay, I'll look into it this week.

@arcanis
Copy link
Member

arcanis commented Jul 18, 2021

I reworked the configuration option to rather be a CLI option - this prevents issues when using env definitions and cloning git repositories (since their installs would then inherit the mode, which isn't intended). It also plays a little better with skip-builds, since using both at the same time wouldn't have made sense. Apart from that it should be good to go, thanks!

packages/plugin-essentials/sources/commands/install.ts Outdated Show resolved Hide resolved
packages/yarnpkg-core/sources/Project.ts Outdated Show resolved Hide resolved
.yarn/versions/fa5cc541.yml Outdated Show resolved Hide resolved
@ylemkimon
Copy link
Contributor Author

@arcanis Thank you for the review! The reasoning behind a configuration was that it could applied to commands other than install that uses project.install(). Would something like a global CLI option be possible?

@arcanis
Copy link
Member

arcanis commented Jul 18, 2021

Would something like a global CLI option be possible?

No, our only global option is --cwd and it's already a bit impractical 😅 Plus in general we tend to prefer explicit over implicit. However --mode could be added to yarn add/up/remove if needed.

@ylemkimon
Copy link
Contributor Author

I've added --mode to add, remove, up, and dedupe.

@arcanis arcanis merged commit d132132 into yarnpkg:master Jul 18, 2021
@merceyz merceyz changed the title feat(core): add updateLockfileOnly configuration feat(core): add install modes Jul 18, 2021
arcanis added a commit that referenced this pull request Jul 18, 2023
**What's the problem this PR addresses?**
<!-- Describe the rationale of your PR. -->
<!-- Link all issues that it closes. (Closes/Resolves #xxxx.) -->

While reviewing #5509, I noticed
that the `--mode` flag wasn't passed to `yarn up --recursive`.

The issue started in #2913, when
the flag was originally introduced.

**How did you fix it?**
<!-- A detailed description of your implementation. -->

Made it pass `--mode` to `yarn up --recursive` and added tests.

**Checklist**
<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [X] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [X] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [X] I will check that all automated PR checks pass before the PR gets
reviewed.

---------

Co-authored-by: Maël Nison <nison.mael@gmail.com>
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.

[Feature] Lock file only updates (skip modules install)
4 participants