From 06db338a15cf1e3f1d3f576884456a830371b6d6 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Mon, 22 May 2023 04:38:24 -0400 Subject: [PATCH] Upgrade node to v18 (LTS) (#16589) --- .devcontainer/Dockerfile | 6 ------ .devcontainer/devcontainer.json | 2 +- .nvmrc | 2 +- script/bootstrap | 16 ++++++++++++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4703666d12..26ee55e660 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,9 +5,3 @@ ENV \ DEBIAN_FRONTEND=noninteractive \ DEVCONTAINER=true \ PATH=$PATH:./node_modules/.bin - -# Install nvm -COPY .nvmrc /tmp/.nvmrc -RUN \ - su vscode -c \ - "source /usr/local/share/nvm/nvm.sh && nvm install $(cat /tmp/.nvmrc) 2>&1" \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3c53eacb7e..d4af4fbeba 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "context": ".." }, "appPort": "8124:8123", - "postCreateCommand": "script/bootstrap", + "postStartCommand": "script/bootstrap", "containerEnv": { "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" }, diff --git a/.nvmrc b/.nvmrc index b6a7d89c68..3c032078a4 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16 +18 diff --git a/script/bootstrap b/script/bootstrap index 581fd6c371..f18b75d2b8 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash -i # Resolve all frontend dependencies that the application requires to develop. # Stop on errors @@ -6,5 +6,17 @@ set -e cd "$(dirname "$0")/.." +# Install/upgrade node when inside devcontainer +if [[ -n "$DEVCONTAINER" ]]; then + nodeCurrent=$(nvm version default || echo "") + nodeLatest=$(nvm version-remote "$(cat .nvmrc)") + if [[ -z "$nodeCurrent" ]]; then + nvm install + elif [[ "$nodeCurrent" != "$nodeLatest" ]]; then + nvm install --reinstall-packages-from="$nodeCurrent" --default + nvm uninstall "$nodeCurrent" + fi +fi + # Install node modules -yarn install \ No newline at end of file + yarn install