Skip to content

Commit 3b3451d

Browse files
committed
(maint) Optimize build script network calls
This commit optimizes the build script to only pull dependencies like npm packages or puppet-editor-services if their files are not present. It also changes the vs code launch.json to use the optimized build path, which reduces build time when running under the Extension Host.
1 parent 3b07361 commit 3b3451d

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
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: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@ task Clean {
2424
# "githubrepo": "puppet-editor-services",
2525
# "githubuser": "glennsarti"
2626
# }
27-
# "editorServices": {
27+
# "editorServices": {
2828
# "githubrepo": "puppet-editor-services",
2929
# "githubref": "glennsarti:spike-rearch-langserver"
3030
# },
31-
task VendorEditorServices {
31+
task VendorEditorServices -precondition { !(Test-Path (Join-Path $PSScriptRoot 'vendor/languageserver')) } {
3232
$githubrepo = $config.editorComponents.editorServices.githubrepo ?? 'puppet-editor-services'
3333
$githubuser = $config.editorComponents.editorServices.githubuser ?? 'puppetlabs'
3434

35-
if($config.editorComponents.editorServices.release){
35+
if ($config.editorComponents.editorServices.release) {
3636
$releasenumber = $config.editorComponents.editorServices.release
3737
$uri = "https://github.com/${githubuser}/${githubrepo}/releases/download/${releasenumber}/puppet_editor_services_${releasenumber}.zip";
38-
}else{
38+
}
39+
else {
3940
$githubref = $config.editorComponents.editorServices.githubref;
40-
if($githubref -notcontains ':'){
41+
if ($githubref -notcontains ':') {
4142
throw "Invalid githubref. Must be in user:branch format like glennsarti:spike-rearch-langserver"
4243
}
4344
$githubuser = $githubref.split(":")[0]
@@ -47,7 +48,8 @@ task VendorEditorServices {
4748

4849
if ($config.editorComponents.editorServices.directory) {
4950
Copy-Item -Path $config.editorComponents.editorServices.directory -Destination $languageServerPath -Recurse -Force
50-
}elseif ($config.editorComponents.editorServices.release) {
51+
}
52+
elseif ($config.editorComponents.editorServices.release) {
5153
Invoke-RestMethod -Uri $uri -OutFile $languageServerZip -ErrorAction Stop
5254
Expand-Archive -Path $languageServerZip -DestinationPath $languageServerPath -ErrorAction Stop
5355
Remove-Item -Path $languageServerZip -Force
@@ -64,19 +66,9 @@ task VendorEditorServices {
6466
}
6567
}
6668

67-
task VendorEditorSyntax {
68-
if ($config.editorComponents.editorSyntax.githubuser) {
69-
$githubuser = $config.editorComponents.editorSyntax.githubuser
70-
}
71-
else {
72-
$githubuser = 'lingua-pupuli'
73-
}
74-
if ($config.editorComponents.editorSyntax.githubrepo) {
75-
$githubrepo = $config.editorComponents.editorSyntax.githubrepo
76-
}
77-
else {
78-
$githubrepo = 'puppet-editor-syntax'
79-
}
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'
8072

8173
if ($config.editorComponents.editorSyntax.directory) {
8274
$source = Join-Path ($config.editorComponents.editorSyntax.directory, 'syntaxes/puppet.tmLanguage')
@@ -99,7 +91,7 @@ task VendorEditorSyntax {
9991
Invoke-RestMethod -Uri $uri -OutFile $syntaxFilePath -ErrorAction Stop
10092
}
10193

102-
task VendorCytoscape {
94+
task VendorCytoscape -precondition { !(Test-Path (Join-Path $PSScriptRoot 'vendor\cytoscape')) } {
10395
$cyto = Join-Path $PSScriptRoot 'node_modules\cytoscape\dist'
10496
$vendorCytoPath = (Join-Path $PSScriptRoot 'vendor\cytoscape')
10597
Copy-Item -Path $cyto -Recurse -Destination $vendorCytoPath
@@ -113,14 +105,12 @@ task Bump {
113105
exec { npm version --no-git-tag-version $packageVersion }
114106
}
115107

116-
task Npm {
108+
task Npm -precondition { !(Test-Path (Join-Path $PSScriptRoot 'node_modules')) } {
117109
exec { npm install }
118110
}
119111

120112
task Vendor -depends VendorEditorServices, VendorEditorSyntax, VendorCytoscape
121113

122-
task Build -depends Clean, Npm, Vendor, CompileTypeScript
123-
124-
task Initial -depends Clean, Vendor
114+
task Build -depends Npm, Vendor, CompileTypeScript
125115

126116
task default -depends Build

0 commit comments

Comments
 (0)