-
Notifications
You must be signed in to change notification settings - Fork 302
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
[node] Add support to pre-install npm packages (#763) #767
base: main
Are you sure you want to change the base?
Conversation
@hpe-ykoehler please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time in contributing this change, left some review comments!
@@ -19,6 +19,7 @@ Installs Node.js, nvm, yarn, pnpm, and needed dependencies. | |||
| nodeGypDependencies | Install dependencies to compile native node modules (node-gyp)? | boolean | true | | |||
| nvmInstallPath | The path where NVM will be installed. | string | /usr/local/share/nvm | | |||
| nvmVersion | Version of NVM to install. | string | latest | | |||
| npmInstallPackages | NPM Packages to install in the user global environment. | string | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this PR is merged, https://github.com/devcontainers/action will run automatically ; which opens a PR that updates the README file based on devcontainer-feature.json
and NOTES.md
.
Hence, can we revert the changes to this file to avoid merge conflicts? Thanks!
@@ -36,6 +36,11 @@ | |||
], | |||
"default": "latest", | |||
"description": "Version of NVM to install." | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we bump minor
version for this Feature?
"version": "1.3.1", |
@@ -36,6 +36,11 @@ | |||
], | |||
"default": "latest", | |||
"description": "Version of NVM to install." | |||
}, | |||
"npmInstallPackages": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"npmInstallPackages": { | |
"packages": { |
"npmInstallPackages": { | ||
"type": "string", | ||
"default": "", | ||
"description": "Additional npm packages to install under the username env." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have another PR #768 which is trying to do a similar thing for the Python Feature. Hence, trying to make both of these in sync.
"npmInstallPackages": { | ||
"type": "string", | ||
"default": "", | ||
"description": "Additional npm packages to install under the username env." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Additional npm packages to install under the username env." | |
"description": "Optional comma separated list of NPM packages to install" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expect this ^ input and update the install.sh
file accordingly?
@@ -270,4 +271,8 @@ rm -rf /var/lib/apt/lists/* | |||
mkdir -p "${NVM_DIR}/versions" | |||
chmod -R g+rw "${NVM_DIR}/versions" | |||
|
|||
if [ ! -z "${NPMINSTALLPACKAGES}" ]; then | |||
su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -270,4 +271,8 @@ rm -rf /var/lib/apt/lists/* | |||
mkdir -p "${NVM_DIR}/versions" | |||
chmod -R g+rw "${NVM_DIR}/versions" | |||
|
|||
if [ ! -z "${NPMINSTALLPACKAGES}" ]; then | |||
su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" | |
npm install -g ${NPMINSTALLPACKAGES}" |
I don't think we'd need other commands. Example
Line 235 in 0af6bc9
npm install -g pnpm |
@@ -270,4 +271,8 @@ rm -rf /var/lib/apt/lists/* | |||
mkdir -p "${NVM_DIR}/versions" | |||
chmod -R g+rw "${NVM_DIR}/versions" | |||
|
|||
if [ ! -z "${NPMINSTALLPACKAGES}" ]; then | |||
su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" | |||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a possibility that we might run into #702 issue.
Hence, can we move
Lines 232 to 234 in 0af6bc9
[ ! -z "$http_proxy" ] && npm set proxy="$http_proxy" | |
[ ! -z "$https_proxy" ] && npm set https-proxy="$https_proxy" | |
[ ! -z "$no_proxy" ] && npm set noproxy="$no_proxy" |
if [ ! -z "${NPMINSTALLPACKAGES}" ]; then | ||
su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can we wrap npm install
within 👇
if type npm > /dev/null 2>&1; then
npm install -g xyz
else
echo "Skip installing additional packages because npm is missing"
fi
if [ ! -z "${NPMINSTALLPACKAGES}" ]; then | ||
su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" | ||
fi | ||
|
||
echo "Done!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test scenarios to validate this new option? Thank you!
No description provided.