Skip to content

Commit 3b07361

Browse files
committed
(GH-583) Change build script to github format
This commit changes the part of the buildscript that vendors the specified release of the puppet-editor-services project when a custom git ref is used, which is a branch on a github remote to use. Previously the config was: ``` "editorServices": { "githubuser": "glennsarti", "githubrepo": "puppet-editor-services", "githubref": "spike-rearch-langserver" } ``` This has been changed to: ``` "editorServices": { "githubrepo": "puppet-editor-services", "githubref": "glennsarti:spike-rearch-langserver" }, ``` This allows someone to copy paste the githubref from the Github page or the terminal into the config to user without extra changes. This also streamlines the code that parses the config into a less complicated statement block.
1 parent 2779666 commit 3b07361

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

psakefile.ps1

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

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+
# },
1931
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
29-
}
30-
else {
31-
$githubrepo = 'puppet-editor-services'
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";
38+
}else{
39+
$githubref = $config.editorComponents.editorServices.githubref;
40+
if($githubref -notcontains ':'){
41+
throw "Invalid githubref. Must be in user:branch format like glennsarti:spike-rearch-langserver"
42+
}
43+
$githubuser = $githubref.split(":")[0]
44+
$githubbranch = $githubref.split(":")[1]
45+
$uri = "https://github.com/${githubuser}/${githubrepo}/archive/${githubbranch}.zip"
3246
}
3347

3448
if ($config.editorComponents.editorServices.directory) {
3549
Copy-Item -Path $config.editorComponents.editorServices.directory -Destination $languageServerPath -Recurse -Force
3650
}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";
3951
Invoke-RestMethod -Uri $uri -OutFile $languageServerZip -ErrorAction Stop
4052
Expand-Archive -Path $languageServerZip -DestinationPath $languageServerPath -ErrorAction Stop
4153
Remove-Item -Path $languageServerZip -Force
4254
}
4355
elseif ($config.editorComponents.editorServices.githubref) {
44-
$githubref = $config.editorComponents.editorServices.githubref;
45-
$uri = "https://github.com/${githubuser}/${githubrepo}/archive/${githubref}.zip"
4656
Invoke-RestMethod -Uri $uri -OutFile $languageServerZip -ErrorAction Stop
4757
Expand-Archive -Path $languageServerZip -DestinationPath "$($languageServerPath)/tmp" -ErrorAction Stop
4858
Move-Item -Path (Join-Path $languageServerPath "tmp/$githubrepo-$githubref/*") -Destination $languageServerPath
@@ -103,9 +113,13 @@ task Bump {
103113
exec { npm version --no-git-tag-version $packageVersion }
104114
}
105115

116+
task Npm {
117+
exec { npm install }
118+
}
119+
106120
task Vendor -depends VendorEditorServices, VendorEditorSyntax, VendorCytoscape
107121

108-
task Build -depends Clean, Vendor, CompileTypeScript
122+
task Build -depends Clean, Npm, Vendor, CompileTypeScript
109123

110124
task Initial -depends Clean, Vendor
111125

0 commit comments

Comments
 (0)