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

Bugfix for issue #667 - devon npm setup ignores a given version #668

Merged
merged 4 commits into from
Jan 25, 2022

Conversation

fdcg
Copy link
Contributor

@fdcg fdcg commented Jan 5, 2022

No description provided.

Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@fdcg thanks for this great PR 👍
I did some minimal changes directly as constructive review.
For the download we should follow the new approach as commented in the review below.
Should I take over or would have have the chance/time to rework?

UPDATE: Did you also test my quickfix that has already been released?

doDevonCommand npm install -g "npm@${NPM_VERSION}"

else
local download_url="https://registry.npmjs.org/npm/-/npm-${software_version}.tgz"
local software_dir="${NODE_HOME}/node_modules/npm"
doInstall "${software_dir}" "${download_url}" "npm" "${software_version}"
Copy link
Member

Choose a reason for hiding this comment

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

this will not work as you have developed this PR for an older version of devonfw-ide and the function and download process has been improved and refactored. See: #641
So we should to put the URL into https://github.com/devonfw/ide-mirrors/ and change the arguments of doInstall (see other commandlets that have been refactored already).

Copy link
Member

Choose a reason for hiding this comment

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

As a quickfix, I changed the order of the parameters so it should already work, but we want to keep the download URLs out of our release as explained in #641

Copy link
Member

Choose a reason for hiding this comment

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

I have already added the according config to the ide-mirrors repo:
https://github.com/devonfw/ide-mirrors/tree/master/npm

Copy link
Member

Choose a reason for hiding this comment

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

so we could stip out the download_url (line 36) and change to:

doInstall "-" "${software_dir}" "npm" "${software_version}"

Comment on lines +39 to +58
if [ -f "${NODE_HOME}/npm" ]
then
rm "${NODE_HOME}/npm"
fi
if [ -f "${NODE_HOME}/npm.cmd" ]
then
rm "${NODE_HOME}/npm.cmd"
fi
if [ -f "${NODE_HOME}/npx" ]
then
rm "${NODE_HOME}/npx"
fi
if [ -f "${NODE_HOME}/npx.cmd" ]
then
rm "${NODE_HOME}/npx.cmd"
fi
cp "${software_dir}/bin/npm" "${NODE_HOME}"
cp "${software_dir}/bin/npm.cmd" "${NODE_HOME}"
cp "${software_dir}/bin/npx" "${NODE_HOME}"
cp "${software_dir}/bin/npx.cmd" "${NODE_HOME}"
Copy link
Member

Choose a reason for hiding this comment

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

Instead of removing and copying, I would prefer to create symlinks but due to windows limitations this does not seem to be an option. So I think there is no better solution than yours here that should always work (KISS).

Copy link
Member

Choose a reason for hiding this comment

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

For the record: the current approach could fail on Windows if a npm.cmd is currently running in parallel due to file locking.

hohwille added a commit to devonfw/ide-mirrors that referenced this pull request Jan 13, 2022
hohwille added a commit to devonfw/ide-mirrors that referenced this pull request Jan 13, 2022
@hohwille hohwille added this to the release:2021.12.005 milestone Jan 13, 2022
@hohwille hohwille added enhancement New feature or request npm node package manager setup related to the setup process of devonfw-ide (setup[.bat] and devon ... setup) update related to updating software or the entire devonfw-ide labels Jan 13, 2022
@hohwille hohwille linked an issue Jan 25, 2022 that may be closed by this pull request
@hohwille
Copy link
Member

@fdcg awesome. Thanks for updating this PR and testing on win.
Ready to be merged.

@hohwille hohwille merged commit 07d9407 into devonfw:master Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request npm node package manager setup related to the setup process of devonfw-ide (setup[.bat] and devon ... setup) update related to updating software or the entire devonfw-ide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

devon npm setup ignores a given version
2 participants