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

Update node modules installation check to npm exclusively #14

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

franciszekjob
Copy link
Collaborator

@franciszekjob franciszekjob commented Mar 21, 2024

This PR restricts listing installed node modules to npm only. At the same time it fixes the issue which marke node modules as installed even if they were not present.

Before:
The check to verify packages was performed using different package managers.

After:
Now we use only npm to determine the presence of node modules. npm is included with node so there's no risk that user won't have it.

Copy link

vercel bot commented Mar 21, 2024

@franciszekjob is attempting to deploy a commit to the software-mansion Team on Vercel.

To accomplish this, @franciszekjob needs to request access to the Team.

Afterwards, an owner of the Team is required to accept their membership request.

If you're already a member of the respective Vercel Team, make sure that your Personal Vercel Account is connected to your GitHub account.

Comment on lines 84 to 89
const isTreeVerified = await checkIfCLIInstalled(
`yarn check --verify-tree --cwd ${getAppRootFolder()}`
);
const isIntegrityChecked = await checkIfCLIInstalled(
`yarn check --integrity --cwd ${getAppRootFolder()}`
);
Copy link
Member

Choose a reason for hiding this comment

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

The yarn check command is deprecated and highly discouraged by the official yarn documentation
image

https://classic.yarnpkg.com/lang/en/docs/cli/check/

It also says that

The switches --integrity and --verify-tree are mutually exclusive.

so i'm not sure whether we should use both of these at the same time

I'm starting to lean on just using npm list for every package manager check as it's unlikely a user wouldn't have npm installed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, should I implement it the way it relies only on npm list then?

Copy link
Member

Choose a reason for hiding this comment

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

The docs suggest using https://classic.yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-check-files instead. Maybe try yarn install --check-files first if that isn't good enough fallback to npm list.

Copy link
Collaborator Author

@franciszekjob franciszekjob Mar 21, 2024

Choose a reason for hiding this comment

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

yarn install --check-files installs node modules as well, which is an unwanted behavior in this case. Maybe for now we can exclusively use npm for all cases? npm would then become a requirement for RN IDE

Copy link
Member

Choose a reason for hiding this comment

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

i think npm is always installed with node either way so its okay to assume everybody has npm installed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fine

@franciszekjob franciszekjob changed the title Fix node modules installation detection (yarn) Change modules installation checking Mar 22, 2024
@franciszekjob franciszekjob changed the title Change modules installation checking Change node modules installation checking Mar 22, 2024
@franciszekjob franciszekjob changed the title Change node modules installation checking Update node modules installation check to npm exclusively Mar 22, 2024
Copy link
Member

@kacperkapusciak kacperkapusciak left a comment

Choose a reason for hiding this comment

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

lgtm, should work

@franciszekjob franciszekjob merged commit f8339f8 into main Mar 22, 2024
1 of 2 checks passed
@kmagiera kmagiera deleted the @franciszekjob/fix-issue-2 branch April 2, 2024 08:38
kmagiera added a commit that referenced this pull request Apr 2, 2024
This PR removes code responsible for node_modules checks.

These checks have been buggy and caused many projects to report issues
while not giving a lot of value. Specifically, yarn-base projects would
occasionally fail the check (maybe due to packages that were
incompatible with node). On the other hand, we couldn't use
project-specific package manager to perform this check because for
example yarn wouldn't report a problem even when node_modules folder
didn't exist (see #14)

We may want to revisit this in the future but it'd need to provide some
additional values such as:
1) verifying if node_modules are in sync with current package.json and
lock files – the old implementation only checked the existence of
node_modules
2) the command should be fast, such that we can perform this
verification at different moments, for example when we suspect someone
should re-run install command (i.e. they checkout a different branch
with changes to lockfiles)
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