Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |

Copy link
Copy Markdown
Member

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!


## Customizations

Expand Down
5 changes: 5 additions & 0 deletions src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
],
"default": "latest",
"description": "Version of NVM to install."
},

Copy link
Copy Markdown
Member

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?

"npmInstallPackages": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"npmInstallPackages": {
"packages": {

"type": "string",
"default": "",
"description": "Additional npm packages to install under the username env."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Additional npm packages to install under the username env."
"description": "Optional comma separated list of NPM packages to install"

Copy link
Copy Markdown
Member

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?

}

Copy link
Copy Markdown
Member

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.

},
"customizations": {
Expand Down
5 changes: 5 additions & 0 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
export NODE_VERSION="${VERSION:-"lts"}"
export NVM_VERSION="${NVMVERSION:-"latest"}"
export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}"
export NPM_INSTALL_PACKAGES="${NPMINSTALLPACKAGES:-""}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export NPM_INSTALL_PACKAGES="${NPMINSTALLPACKAGES:-""}"
export PACKAGES="${PACKAGES:-""}"

INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}"

# Comma-separated list of node versions to be installed (with nvm)
Expand Down Expand Up @@ -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}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
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

npm install -g pnpm

fi

Copy link
Copy Markdown
Member

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

[ ! -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"
outside of the condition block so that it can be consumed by both?


Copy link
Copy Markdown
Member

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

echo "Done!"

Copy link
Copy Markdown
Member

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!