From f39531216ca3fc14bf017df4226f2c3eb15915f6 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 14 Jul 2017 20:21:29 +0200 Subject: [PATCH] U4-10006 - fix npm/node issues --- .../Umbraco.Build/Build-UmbracoDocs.ps1 | 14 +++-- .../Umbraco.Build/Get-UmbracoBuildEnv.ps1 | 51 ++++++++++--------- .../Modules/Umbraco.Build/Umbraco.Build.psm1 | 20 +++++--- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 b/build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 index e9ee79408c..41b261ea55 100644 --- a/build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 +++ b/build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 @@ -24,17 +24,22 @@ function Build-UmbracoDocs Write-Host "Build UI documentation" - push-location "$src\Umbraco.Web.UI.Client" + # get a temp clean path (will be restored) $p = $env:path - $env:path = $uenv.NpmPath + ";" + $uenv.NodePath + ";" + $env:path - - write "cache clean" > $tmp\belle-docs.log + $nodePath = $uenv.NodePath + $gitExe = (get-command git).Source + $gitPath = [System.IO.Path]::GetDirectoryName($gitExe) + $env:path = "$nodePath;$gitPath" + + push-location "$src\Umbraco.Web.UI.Client" + write "" > $tmp\belle-docs.log &npm cache clean --quiet >> $tmp\belle-docs.log 2>&1 &npm install --quiet >> $tmp\belle-docs.log 2>&1 &npm install -g grunt-cli --quiet >> $tmp\belle-docs.log 2>&1 #&npm install -g bower --quiet >> $tmp\belle.log 2>&1 #&grunt build --buildversion=$version.Release >> $tmp\belle.log 2>&1 &grunt --gruntfile "$src/Umbraco.Web.UI.Client/gruntfile.js" docs >> $tmp\belle-docs.log 2>&1 + pop-location # fixme - should we filter the log to find errors? #get-content .\build.tmp\belle-docs.log | %{ if ($_ -match "build") { write $_}} @@ -45,7 +50,6 @@ function Build-UmbracoDocs (Get-Content $indexPath).Replace("location.href.replace(rUrl, indexFile)", "'$baseUrl'") ` | Set-Content $indexPath - pop-location $env:path = $p # zip diff --git a/build/Modules/Umbraco.Build/Get-UmbracoBuildEnv.ps1 b/build/Modules/Umbraco.Build/Get-UmbracoBuildEnv.ps1 index 7cc45947d6..2ec4b3f592 100644 --- a/build/Modules/Umbraco.Build/Get-UmbracoBuildEnv.ps1 +++ b/build/Modules/Umbraco.Build/Get-UmbracoBuildEnv.ps1 @@ -104,30 +104,31 @@ function Get-UmbracoBuildEnv Remove-File "$path\node-v6.9.1-win-x86.7z" } - # ensure we have npm - $npm = "$path\npm.*" - $getNpm = $true - if (test-path $npm) - { - $getNpm = $false - $tmpNpm = ls "$path\npm.*" | sort -property Name -descending | select -first 1 - if ($tmpNpm.CreationTime -lt [DateTime]::Now.AddDays(-$cache)) - { - $getNpm = $true - } - else - { - $npm = $tmpNpm.ToString() - } - } - if ($getNpm) - { - Write-Host "Download Npm..." - &$nuget install npm -OutputDirectory $path -Verbosity quiet - $npm = ls "$path\npm.*" | sort -property Name -descending | select -first 1 - $npm.CreationTime = [DateTime]::Now - $npm = $npm.ToString() - } + # note: why? node already brings everything we need! + ## ensure we have npm + #$npm = "$path\npm.*" + #$getNpm = $true + #if (test-path $npm) + #{ + # $getNpm = $false + # $tmpNpm = ls "$path\npm.*" | sort -property Name -descending | select -first 1 + # if ($tmpNpm.CreationTime -lt [DateTime]::Now.AddDays(-$cache)) + # { + # $getNpm = $true + # } + # else + # { + # $npm = $tmpNpm.ToString() + # } + #} + #if ($getNpm) + #{ + # Write-Host "Download Npm..." + # &$nuget install npm -OutputDirectory $path -Verbosity quiet + # $npm = ls "$path\npm.*" | sort -property Name -descending | select -first 1 + # $npm.CreationTime = [DateTime]::Now + # $npm = $npm.ToString() + #} # find visual studio # will not work on VSO but VSO does not need it @@ -175,7 +176,7 @@ function Get-UmbracoBuildEnv $uenv | add-member -memberType NoteProperty -name VsWhere -value $vswhere $uenv | add-member -memberType NoteProperty -name Semver -value $semver $uenv | add-member -memberType NoteProperty -name NodePath -value $node - $uenv | add-member -memberType NoteProperty -name NpmPath -value $npm + #$uenv | add-member -memberType NoteProperty -name NpmPath -value $npm return $uenv } diff --git a/build/Modules/Umbraco.Build/Umbraco.Build.psm1 b/build/Modules/Umbraco.Build/Umbraco.Build.psm1 index db968cdbe1..b2c147343d 100644 --- a/build/Modules/Umbraco.Build/Umbraco.Build.psm1 +++ b/build/Modules/Umbraco.Build/Umbraco.Build.psm1 @@ -80,24 +80,28 @@ function Compile-Belle Write-Host ">> Compile Belle" Write-Host "Logging to $tmp\belle.log" - - push-location "$($uenv.SolutionRoot)\src\Umbraco.Web.UI.Client" - $p = $env:path - $env:path = $uenv.NpmPath + ";" + $uenv.NodePath + ";" + $env:path - write "cache clean" > $tmp\belle.log + # get a temp clean path (will be restored) + $p = $env:path + $nodePath = $uenv.NodePath + $gitExe = (get-command git).Source + $gitPath = [System.IO.Path]::GetDirectoryName($gitExe) + $env:path = "$nodePath;$gitPath" + + push-location "$($uenv.SolutionRoot)\src\Umbraco.Web.UI.Client" + write "" > $tmp\belle.log &npm cache clean --quiet >> $tmp\belle.log 2>&1 &npm install --quiet >> $tmp\belle.log 2>&1 &npm install -g grunt-cli --quiet >> $tmp\belle.log 2>&1 &npm install -g bower --quiet >> $tmp\belle.log 2>&1 &grunt build --buildversion=$version.Release >> $tmp\belle.log 2>&1 + pop-location # fixme - should we filter the log to find errors? #get-content .\build.tmp\belle.log | %{ if ($_ -match "build") { write $_}} - - pop-location - $env:path = $p + # restore path + $env:path = $p # setting node_modules folder to hidden # used to prevent VS13 from crashing on it while loading the websites project