[node] Add support to pre-install npm packages (#763) - #767
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”),
|
Samruddhi Khandale (samruddhikhandale)
left a comment
There was a problem hiding this comment.
Thanks for taking the time in contributing this change, left some review comments!
| | 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.
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!
| ], | ||
| "default": "latest", | ||
| "description": "Version of NVM to install." | ||
| }, |
There was a problem hiding this comment.
Can we bump minor version for this Feature?
| "default": "latest", | ||
| "description": "Version of NVM to install." | ||
| }, | ||
| "npmInstallPackages": { |
There was a problem hiding this comment.
| "npmInstallPackages": { | |
| "packages": { |
| "type": "string", | ||
| "default": "", | ||
| "description": "Additional npm packages to install under the username env." | ||
| } |
There was a problem hiding this comment.
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.
| "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.
Can we expect this ^ input and update the install.sh file accordingly?
| 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.
| 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.
| 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
|
|
||
| if [ ! -z "${NPMINSTALLPACKAGES}" ]; then | ||
| su ${USERNAME} -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm use default && npm install -g ${NPMINSTALLPACKAGES}" | ||
| fi |
| 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.
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
| 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.
Can we add test scenarios to validate this new option? Thank you!
No description provided.