From 12ba3061216043b298cc10d165c718647482f7b8 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 26 Feb 2021 20:06:24 +0500 Subject: [PATCH] [ubuntu] Add lerna (#2763) * Add lerna to linux images * Add a comment about netlify-cli * remove Node.js tests from Tools.Tests.ps1 * fix tabs * revert empty lines * fix code style --- images/linux/scripts/installers/nodejs.sh | 24 ++++++++--- images/linux/scripts/tests/Node.Tests.ps1 | 14 +++++++ images/linux/scripts/tests/Tools.Tests.ps1 | 14 +------ images/linux/toolsets/toolset-1604.json | 44 ++++++++++++++++++++- images/linux/toolsets/toolset-1804.json | 44 ++++++++++++++++++++- images/linux/toolsets/toolset-2004.json | 46 ++++++++++++++++++++++ 6 files changed, 166 insertions(+), 20 deletions(-) create mode 100644 images/linux/scripts/tests/Node.Tests.ps1 diff --git a/images/linux/scripts/installers/nodejs.sh b/images/linux/scripts/installers/nodejs.sh index 3bee08f1f..020662f3b 100644 --- a/images/linux/scripts/installers/nodejs.sh +++ b/images/linux/scripts/installers/nodejs.sh @@ -4,14 +4,28 @@ ## Desc: Installs Node.js LTS and related tooling (Gulp, Grunt) ################################################################################ +# Source the helpers for use with the script +source $HELPER_SCRIPTS/install.sh + # Install LTS Node.js and related build tools curl -sL https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-install | bash -s -- -ny - ~/n/bin/n lts -npm install -g grunt gulp n parcel-bundler typescript newman vercel -npm install -g --save-dev webpack webpack-cli +# Install node modules +node_modules=$(get_toolset_value '.node_modules[].name') -# Install the Netlify CLI using --unsafe-perm=true options to avoid permission issues -npm install -g --unsafe-perm=true netlify-cli +# remove commenting out of this line as nmp migrated to v7 +# npm install -g $node_modules + +# TODO: workaround for Netlify CLI with npm6. Remove 19-28 and uncomment 17 if migration to npm7 compelted +for module in $node_modules; do + echo "Installing node module $module" + if [ $module = "netlify-cli" ];then + # Install the Netlify CLI using --unsafe-perm=true options to avoid permission issues + npm install -g --unsafe-perm=true $module + else + npm install -g $module + fi +done echo "Creating the symlink for [now] command to vercel CLI" ln -s /usr/local/bin/vercel /usr/local/bin/now @@ -26,4 +40,4 @@ apt-get update # Install yarn apt-get install -y --no-install-recommends yarn -invoke_tests "Tools" "Node.js" +invoke_tests "Node" "Node.js" diff --git a/images/linux/scripts/tests/Node.Tests.ps1 b/images/linux/scripts/tests/Node.Tests.ps1 new file mode 100644 index 000000000..06790bdf1 --- /dev/null +++ b/images/linux/scripts/tests/Node.Tests.ps1 @@ -0,0 +1,14 @@ +Describe "Node.js" { + $binaries = @("node") + $module_commands = (Get-ToolsetContent).node_modules | ForEach-Object { $_.command } + $testCases = $binaries + $module_commands | ForEach-Object { @{NodeCommand = $_} } + + It "" -TestCases $testCases { + param ( + [string] $NodeCommand + ) + + "$NodeCommand --version" | Should -ReturnZeroExitCode + } +} + diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 60372d9cc..d35c7f634 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -313,18 +313,6 @@ Describe "Containers" -Skip:(Test-IsUbuntu16) { } } -Describe "Node.js" { - $testCases = @("node", "grunt", "gulp", "webpack", "parcel", "yarn", "newman", "netlify", "vercel", "now") | ForEach-Object { @{NodeCommand = $_} } - - It "" -TestCases $testCases { - param ( - [string] $NodeCommand - ) - - "$NodeCommand --version" | Should -ReturnZeroExitCode - } -} - Describe "nvm" { It "nvm" { "source /etc/skel/.nvm/nvm.sh && nvm --version" | Should -ReturnZeroExitCode @@ -364,4 +352,4 @@ Describe "Ruby" { "gem list -i '^$gemName$'" | Should -MatchCommandOutput "true" } } -} \ No newline at end of file +} diff --git a/images/linux/toolsets/toolset-1604.json b/images/linux/toolsets/toolset-1604.json index 9774f6566..8c93b4ee8 100644 --- a/images/linux/toolsets/toolset-1604.json +++ b/images/linux/toolsets/toolset-1604.json @@ -277,5 +277,47 @@ "8.0" ] }, - "rubygems": [] + "rubygems": [], + "node_modules": [ + { + "name": "grunt", + "command": "grunt" + }, + { + "name": "gulp", + "command": "gulp" + }, + { + "name": "n", + "command": "n" + }, + { + "name": "parcel-bundler", + "command": "parcel" + }, + { + "name": "typescript", + "command": "tsc" + }, + { + "name": "newman", + "command": "newman" + }, + { + "name": "vercel", + "command": "vercel" + }, + { + "name": "webpack", + "command": "webpack" + }, + { + "name": "webpack-cli", + "command": "webpack-cli" + }, + { + "name": "netlify-cli", + "command": "netlify" + } + ] } diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 2259d9386..f001f1a2c 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -280,5 +280,47 @@ "8.0" ] }, - "rubygems": [] + "rubygems": [], + "node_modules": [ + { + "name": "grunt", + "command": "grunt" + }, + { + "name": "gulp", + "command": "gulp" + }, + { + "name": "n", + "command": "n" + }, + { + "name": "parcel-bundler", + "command": "parcel" + }, + { + "name": "typescript", + "command": "tsc" + }, + { + "name": "newman", + "command": "newman" + }, + { + "name": "vercel", + "command": "vercel" + }, + { + "name": "webpack", + "command": "webpack" + }, + { + "name": "webpack-cli", + "command": "webpack-cli" + }, + { + "name": "netlify-cli", + "command": "netlify" + } + ] } diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 67f1c31fa..3766233dc 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -259,5 +259,51 @@ }, "rubygems": [ {"name": "fastlane"} + ], + "node_modules": [ + { + "name": "grunt", + "command": "grunt" + }, + { + "name": "gulp", + "command": "gulp" + }, + { + "name": "n", + "command": "n" + }, + { + "name": "parcel-bundler", + "command": "parcel" + }, + { + "name": "typescript", + "command": "tsc" + }, + { + "name": "newman", + "command": "newman" + }, + { + "name": "vercel", + "command": "vercel" + }, + { + "name": "webpack", + "command": "webpack" + }, + { + "name": "webpack-cli", + "command": "webpack-cli" + }, + { + "name": "netlify-cli", + "command": "netlify" + }, + { + "name": "lerna", + "command": "lerna" + } ] }