Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create InvokeBuild script #61

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions coc-powershell.build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

param(
[string]$EditorServicesRepoPath = $null
)

#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.0.0"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a newer version we can put here


# Grab package.json data which is used throughout the build.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we don't use these variables anywhere except to log... The logging is still useful, but maybe change this comment

$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
$script:IsPreviewExtension = $script:PackageJson.name -like "*preview*" -or $script:PackageJson.displayName -like "*preview*"
Write-Host "`n### Extension Version: $($script:PackageJson.version) Extension Name: $($script:PackageJson.name)`n" -ForegroundColor Green

#region Restore tasks

task Restore RestoreNodeModules, RestorePowerShellEditorServices, RestoreSnippets

task RestoreNodeModules {
if(-not (Test-Path "$PSScriptRoot/node_modules")){
Write-Host "`n### Restoring coc-powershell dependencies`n" -ForegroundColor Green

# When in a CI build use the --loglevel=error parameter so that
# package install warnings don't cause PowerShell to throw up
$logLevelParam = if ($env:TF_BUILD) { "--loglevel=error" } else { "" }
exec { & npm install $logLevelParam }
}
}

#endregion
#region Clean tasks

task Clean {
Write-Host "`n### Cleaning coc-powershell`n" -ForegroundColor Green
Remove-Item .\PowerShellEditorServices -Recurse -Force -ErrorAction Ignore
Remove-Item .\Snippets -Recurse -Force -ErrorAction Ignore
Remove-Item .\out -Recurse -Force -ErrorAction Ignore
Remove-Item -Force -Recurse node_modules -ErrorAction Ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this Remove-Item's parameter position is messing with my ocd compared to the others lol

}

task CleanAll Clean

#endregion
#region Build tasks

task Build Restore, {
Write-Host "`n### Building coc-powershell" -ForegroundColor Green
exec { & npm run compile }
}

task RestoreSnippets {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this into the restore region

# If PowerShellEditorServices isn't downloaded, download the latest?
# TODO
if(-not (Test-Path "$PSScriptRoot/Snippets")){
Write-Host Restoring Snippets...
& "$PSScriptRoot/downloadSnippets.ps1"
}
}

task RestorePowerShellEditorServices {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this into the restore region

# If PowerShellEditorServices isn't downloaded, download the latest?
# TODO
if(-not (Test-Path "$PSScriptRoot/PowerShellEditorServices")){
Write-Host Restoring PowerShellEditorServices...
& "$PSScriptRoot/downloadPSES.ps1"
}
}

task BuildAll RestorePowerShellEditorServices, Build

#endregion
#
# The set of tasks for a release
task Release Clean, Build, Test
# The default task is to run the entire CI build
task . CleanAll, BuildAll