diff --git a/.gitignore b/.gitignore index 22f3a5c..9e0b378 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ obj/ *.taskkey bin/ -*/node_modules/ +node_modules typings.json */typings/ deploy-gae-build-task/#task.json# diff --git a/README.md b/README.md index 2997441..26490ee 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,17 @@ Questions can be asked on StackOverflow - [PowerShell][PowerShell]: Installed by default on modern windows platforms. - [Node.js][Node]: Download and install from the website. - [npm][npm]: Installed along with Node.js. - - [TypeScript][TypeScript]: Install with `npm install -g typescript` - - [tfx][tfs-cli]: The tfs cli. Install with `npm install -g tfx-cli` - - [mocha][mocha]: A JavaScript test runner. `npm install -g mocha` - - [ts-node]: Used by mocha to run TypeScript directly. `npm install -g ts-node` - - [nyc][nyc]: The Istanbul code coverage tool. Install with `npm install -g nyc` + - [MSBuild][https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild?view=vs-2019]: Installed with Visual Studio. Visual Studio does not add MSBuild to the path. You can make msbuild resolve in powershell by doing this: + +``` +New-Alias vswhere "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" +$msbuildPath = (ls ((vswhere -latest -property InstallationPath) + "\MSBuild\*\Bin\MSBuild.exe"))[0].FullName +New-Alias msbuild $msbuildPath +``` ### Build Script -Execute build script `./build/BuildExtension.ps1`. It will download needed +Execute build script `npm run-script build`. It will download needed modules, build the common files and build tasks, and then package everything into `./bin/Google Cloud Tools.google-cloud-tfs-.vsix`. diff --git a/build/BuildExtension.ps1 b/build/BuildExtension.ps1 index 69086d3..c719893 100644 --- a/build/BuildExtension.ps1 +++ b/build/BuildExtension.ps1 @@ -1,18 +1,16 @@ -<## - # Copyright 2017 Google Inc. - # - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - ##> +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. [CmdletBinding()] Param( @@ -20,10 +18,14 @@ Param( [switch]$SkipInit, [switch]$SkipCompile, [switch]$SkipTest, + [switch]$SkipPackage, [string]$Publisher, [string]$Version ) +Set-StrictMode -Version 3.0 +$ErrorActionPreference = "Stop" +$env:PATH = "$PSScriptRoot\..\node_modules\.bin\;${env:PATH}" pushd (Join-Path $MyInvocation.MyCommand.Path ..) $functionsModule = Import-Module ./BuildFunctions.psm1 -PassThru -Verbose:$false -ArgumentList $VerbosePreference @@ -67,5 +69,4 @@ try { } } finally { popd - $functionsModule | Remove-Module -Verbose:$false } diff --git a/build/BuildFunctions.psm1 b/build/BuildFunctions.psm1 index 9d07fbc..eb40268 100644 --- a/build/BuildFunctions.psm1 +++ b/build/BuildFunctions.psm1 @@ -1,22 +1,23 @@ -<## - # Copyright 2017 Google Inc. - # - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - ##> +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + Param( $VerbosePreference ) +$env:PATH = "$PSScriptRoot\..\node_modules\.bin\;${env:PATH}" + function Initialize-All([string[]]$tasks) { Write-Host "Initialize modules and tasks" Initialize-PsTask "install-cloud-sdk-build-task" @@ -77,8 +78,9 @@ function Invoke-MochaTest([string]$task, [string]$reporter) { if ($reporter) { $nycArgs += "--reporter", $reporter } - Write-Verbose "Running: nyc $nycArgs" - nyc $nycArgs + + Write-Host "Running: nyc $nycArgs" + nyc @nycArgs if ($LASTEXITCODE -ne 0) { throw "mocha failed for task $task" @@ -178,7 +180,7 @@ function Merge-ExtensionPackage([string] $publisher, [string] $version) { $tfxArgs += "--overrides-file", $overridesFile } Write-Verbose "Running: tfx $tfxArgs" - tfx $tfxArgs + & tfx @tfxArgs if ($overridesFile) { rm $overridesFile } diff --git a/package.json b/package.json new file mode 100644 index 0000000..4498033 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "GoogleCloudPlatform.google-cloud-tfs", + "version": "0.0.9", + "description": "A collection of TFS build tasks to run Google Cloud Platform tools.", + "license": "Apache-2.0", + "author": "Google Cloud Tools", + "repository": "https://github.com/GoogleCloudPlatform/google-cloud-tfs.git", + "main": "run.js", + "dependencies": { + "typescript": "^3.6.4" + }, + "scripts": { + "build": "pwsh ./build/BuildExtension.ps1" + }, + "devDependencies": { + "typescript": "^3.6.4", + "tfx-cli": "^0.7", + "ts-node": "^8.4.1", + "@types/mocha": "^2.2.40", + "@types/mockery": "^1.4.29", + "@types/node": "^7.0.6", + "@types/q": "0.0.32", + "mocha": "^3.2.0", + "mockery": "^2.1.0", + "typemoq": "^2.0.1", + "nyc": "^14.1.1" + } +}