Skip to content

Commit c49ddbe

Browse files
authored
Merge pull request #641 from jpogran/gh-583-build-script-githubref
(GH-583) Change build script githubref and optimize build times
2 parents 2779666 + 3b3451d commit c49ddbe

File tree

3 files changed

+40
-34
lines changed

3 files changed

+40
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1010

1111
- (maint) Update facts view telemetry
1212
- ([GH-647](https://github.com/puppetlabs/puppet-vscode/issues/647)) Add Puppet Facts Welcome View
13+
- ([GH-583](https://github.com/puppetlabs/puppet-vscode/issues/583)) Optimize build script
1314

1415
## [0.26.0] - 2020-05-01
1516

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@
559559
"scripts": {
560560
"vscode:prepublish": "pwsh -file ./build.ps1 build",
561561
"compile": "tsc -p ./",
562-
"watch": "pwsh -file ./build.ps1 initial && tsc -watch -p ./",
562+
"build": "pwsh -file ./build.ps1",
563+
"watch": "npm run build && tsc -watch -p ./",
563564
"pretest": "npm run compile",
564565
"test": "node ./out/test/runtest.js"
565566
},

psakefile.ps1

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,45 @@ task Clean {
1616
}
1717
}
1818

19-
task VendorEditorServices {
20-
$githubref = $config.editorComponents.editorServices.githubref
21-
if ($config.editorComponents.editorServices.githubuser) {
22-
$githubuser = $config.editorComponents.editorServices.githubuser
23-
}
24-
else {
25-
$githubuser = 'lingua-pupuli'
26-
}
27-
if ($config.editorComponents.editorServices.githubrepo) {
28-
$githubrepo = $config.editorComponents.editorServices.githubrepo
19+
# "editorServices": {
20+
# "release": "0.26.0"
21+
# }
22+
# "editorServices": {
23+
# "release": "0.26.0"
24+
# "githubrepo": "puppet-editor-services",
25+
# "githubuser": "glennsarti"
26+
# }
27+
# "editorServices": {
28+
# "githubrepo": "puppet-editor-services",
29+
# "githubref": "glennsarti:spike-rearch-langserver"
30+
# },
31+
task VendorEditorServices -precondition { !(Test-Path (Join-Path $PSScriptRoot 'vendor/languageserver')) } {
32+
$githubrepo = $config.editorComponents.editorServices.githubrepo ?? 'puppet-editor-services'
33+
$githubuser = $config.editorComponents.editorServices.githubuser ?? 'puppetlabs'
34+
35+
if ($config.editorComponents.editorServices.release) {
36+
$releasenumber = $config.editorComponents.editorServices.release
37+
$uri = "https://github.com/${githubuser}/${githubrepo}/releases/download/${releasenumber}/puppet_editor_services_${releasenumber}.zip";
2938
}
3039
else {
31-
$githubrepo = 'puppet-editor-services'
40+
$githubref = $config.editorComponents.editorServices.githubref;
41+
if ($githubref -notcontains ':') {
42+
throw "Invalid githubref. Must be in user:branch format like glennsarti:spike-rearch-langserver"
43+
}
44+
$githubuser = $githubref.split(":")[0]
45+
$githubbranch = $githubref.split(":")[1]
46+
$uri = "https://github.com/${githubuser}/${githubrepo}/archive/${githubbranch}.zip"
3247
}
3348

3449
if ($config.editorComponents.editorServices.directory) {
3550
Copy-Item -Path $config.editorComponents.editorServices.directory -Destination $languageServerPath -Recurse -Force
36-
}elseif ($config.editorComponents.editorServices.release) {
37-
$releasenumber = $config.editorComponents.editorServices.release
38-
$uri = "https://github.com/${githubuser}/${githubrepo}/releases/download/${releasenumber}/puppet_editor_services_${releasenumber}.zip";
51+
}
52+
elseif ($config.editorComponents.editorServices.release) {
3953
Invoke-RestMethod -Uri $uri -OutFile $languageServerZip -ErrorAction Stop
4054
Expand-Archive -Path $languageServerZip -DestinationPath $languageServerPath -ErrorAction Stop
4155
Remove-Item -Path $languageServerZip -Force
4256
}
4357
elseif ($config.editorComponents.editorServices.githubref) {
44-
$githubref = $config.editorComponents.editorServices.githubref;
45-
$uri = "https://github.com/${githubuser}/${githubrepo}/archive/${githubref}.zip"
4658
Invoke-RestMethod -Uri $uri -OutFile $languageServerZip -ErrorAction Stop
4759
Expand-Archive -Path $languageServerZip -DestinationPath "$($languageServerPath)/tmp" -ErrorAction Stop
4860
Move-Item -Path (Join-Path $languageServerPath "tmp/$githubrepo-$githubref/*") -Destination $languageServerPath
@@ -54,19 +66,9 @@ task VendorEditorServices {
5466
}
5567
}
5668

57-
task VendorEditorSyntax {
58-
if ($config.editorComponents.editorSyntax.githubuser) {
59-
$githubuser = $config.editorComponents.editorSyntax.githubuser
60-
}
61-
else {
62-
$githubuser = 'lingua-pupuli'
63-
}
64-
if ($config.editorComponents.editorSyntax.githubrepo) {
65-
$githubrepo = $config.editorComponents.editorSyntax.githubrepo
66-
}
67-
else {
68-
$githubrepo = 'puppet-editor-syntax'
69-
}
69+
task VendorEditorSyntax -precondition { !(Test-Path (Join-Path $PSScriptRoot 'syntaxes/puppet.tmLanguage')) } {
70+
$githubrepo = $config.editorComponents.editorSyntax.githubrepo ?? 'puppet-editor-syntax'
71+
$githubuser = $config.editorComponents.editorSyntax.githubuser ?? 'puppetlabs'
7072

7173
if ($config.editorComponents.editorSyntax.directory) {
7274
$source = Join-Path ($config.editorComponents.editorSyntax.directory, 'syntaxes/puppet.tmLanguage')
@@ -89,7 +91,7 @@ task VendorEditorSyntax {
8991
Invoke-RestMethod -Uri $uri -OutFile $syntaxFilePath -ErrorAction Stop
9092
}
9193

92-
task VendorCytoscape {
94+
task VendorCytoscape -precondition { !(Test-Path (Join-Path $PSScriptRoot 'vendor\cytoscape')) } {
9395
$cyto = Join-Path $PSScriptRoot 'node_modules\cytoscape\dist'
9496
$vendorCytoPath = (Join-Path $PSScriptRoot 'vendor\cytoscape')
9597
Copy-Item -Path $cyto -Recurse -Destination $vendorCytoPath
@@ -103,10 +105,12 @@ task Bump {
103105
exec { npm version --no-git-tag-version $packageVersion }
104106
}
105107

106-
task Vendor -depends VendorEditorServices, VendorEditorSyntax, VendorCytoscape
108+
task Npm -precondition { !(Test-Path (Join-Path $PSScriptRoot 'node_modules')) } {
109+
exec { npm install }
110+
}
107111

108-
task Build -depends Clean, Vendor, CompileTypeScript
112+
task Vendor -depends VendorEditorServices, VendorEditorSyntax, VendorCytoscape
109113

110-
task Initial -depends Clean, Vendor
114+
task Build -depends Npm, Vendor, CompileTypeScript
111115

112116
task default -depends Build

0 commit comments

Comments
 (0)