diff --git a/images/macos/provision/core/node.sh b/images/macos/provision/core/node.sh index 29be8ac8..d9136e17 100644 --- a/images/macos/provision/core/node.sh +++ b/images/macos/provision/core/node.sh @@ -1,11 +1,6 @@ #!/bin/bash -e -o pipefail source ~/utils/utils.sh -node_modules=( - appcenter-cli - newman -) - if is_Less_Catalina; then echo Installing the latest Node JS 8... TMP_FILE=/tmp/node-v8.17.0.pkg @@ -14,33 +9,19 @@ if is_Less_Catalina; then sudo installer -pkg "${TMP_FILE}" -target / rm -rf "${TMP_FILE}" sudo chown -R $USER "/usr/local/lib/node_modules" - - echo Installing NPM 3.x.x... - npm install -g npm@3 - - # This step is required to install App Center CLI - echo Installing Omelette... - npm install -g omelette@0.4.14 - - echo Installing App Center CLI... - npm install -g appcenter-cli@^1.0.0 else # Install Node.js 14 for macOS >= 10.15 brew_smart_install "node@14" brew link node@14 --force - - for module in ${node_modules[@]}; do - echo "Install $module" - npm install -g $module - done fi echo Installing yarn... curl -o- -L https://yarnpkg.com/install.sh | bash -if is_Less_BigSur; then - echo "Install node-gyp" - npm install -g node-gyp -fi +npm_global_packages=$(get_toolset_value '.npm.global_packages[].name') +for module in ${npm_global_packages[@]}; do + echo "Install $module" + npm install -g $module +done invoke_tests "Node" "Node.js" diff --git a/images/macos/tests/Node.Tests.ps1 b/images/macos/tests/Node.Tests.ps1 index 36c85a2a..d2759adb 100644 --- a/images/macos/tests/Node.Tests.ps1 +++ b/images/macos/tests/Node.Tests.ps1 @@ -51,14 +51,12 @@ Describe "nvm" { } } -Describe "AppCenterCLI" { - It "App Center CLI" { - "appcenter --version" | Should -ReturnZeroExitCode +Describe "Global NPM Packages" { + $globalNpmPackages = Get-ToolsetValue "npm.global_packages" + $globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } } + + It "" -TestCases $globalNpmPackagesWithTests { + $Test | Should -ReturnZeroExitCode } } -Describe "Newman" -Skip:($os.IsHighSierra -or $os.IsMojave) { - It "Newman" { - "newman --version" | Should -ReturnZeroExitCode - } -} diff --git a/images/macos/toolsets/toolset-10.13.json b/images/macos/toolsets/toolset-10.13.json index e2af2366..48bd440a 100644 --- a/images/macos/toolsets/toolset-10.13.json +++ b/images/macos/toolsets/toolset-10.13.json @@ -209,6 +209,14 @@ {"name": "Pester"}, {"name": "PSScriptAnalyzer"} ], + "npm": { + "global_packages": [ + { "name": "npm@3" }, + { "name": "omelette@0.4.14" }, + { "name": "appcenter-cli@^1.0.0", "test": "appcenter --version" }, + { "name": "node-gyp" } + ] + }, "brew": { "common_packages": [ "aliyun-cli", diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index fdef00fd..3dedb345 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -230,6 +230,14 @@ {"name": "Pester"}, {"name": "PSScriptAnalyzer"} ], + "npm": { + "global_packages": [ + { "name": "npm@3" }, + { "name": "omelette@0.4.14" }, + { "name": "appcenter-cli@^1.0.0", "test": "appcenter --version" }, + { "name": "node-gyp" } + ] + }, "brew": { "common_packages": [ "aliyun-cli", diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index 1f9bd21e..746bb66d 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -182,6 +182,13 @@ {"name": "Pester"}, {"name": "PSScriptAnalyzer"} ], + "npm": { + "global_packages": [ + { "name": "appcenter-cli", "test": "appcenter --version" }, + { "name": "newman", "test": "newman --version" }, + { "name": "node-gyp" } + ] + }, "brew": { "common_packages": [ "aliyun-cli", diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index bc6b615e..f2922699 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -130,6 +130,12 @@ {"name": "Pester"}, {"name": "PSScriptAnalyzer"} ], + "npm": { + "global_packages": [ + { "name": "appcenter-cli", "test": "appcenter --version" }, + { "name": "newman", "test": "newman --version" } + ] + }, "brew": { "common_packages": [ "aliyun-cli",