Skip to content

Commit 0330977

Browse files
authored
DYN-7143 Skip install for npm packages which are already up-to-date (#15316)
1 parent df3a852 commit 0330977

File tree

4 files changed

+60
-12
lines changed

4 files changed

+60
-12
lines changed

src/DynamoCoreWpf/DynamoCoreWpf.csproj

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222
</PropertyGroup>
2323

2424
<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
25+
<PropertyGroup>
26+
<PackageVersion>1.0.19</PackageVersion>
27+
<PackageName>SplashScreen</PackageName>
28+
</PropertyGroup>
29+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command echo ($(SolutionDir)\pkgexist.ps1 $(PackageName) $(PackageVersion))" ConsoleToMSBuild="true">
30+
<Output TaskParameter="ConsoleOutput" PropertyName="ShouldInstall" />
31+
</Exec>
32+
<Message Text="Skipping Install for $(PackageName) $(PackageVersion), package up to date." Condition="!$(ShouldInstall)" Importance="high" />
2533
<!--This command updates the npm registry configuration if necessary-->
26-
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" />
34+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" Condition="$(ShouldInstall)"/>
2735
<!--This command gets a specific splash screen build from npm-->
28-
<Exec Command="npm pack @dynamods/splash-screen@1.0.19" />
36+
<Exec Command="npm pack @dynamods/splash-screen@$(PackageVersion)" Condition="$(ShouldInstall)"/>
2937
</Target>
3038

31-
<Target Name="ExtractTGZFile" DependsOnTargets="NpmRunBuild" BeforeTargets="BeforeBuild">
39+
<Target Name="ExtractTGZFile" DependsOnTargets="NpmRunBuild" BeforeTargets="BeforeBuild" Condition="$(ShouldInstall)">
3240
<!--Locates the .tgz files-->
3341
<ItemGroup>
3442
<TGZFiles Include="./dynamods-splash-screen-*.tgz" />
@@ -50,13 +58,21 @@
5058

5159

5260
<Target Name="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
61+
<PropertyGroup>
62+
<PackageVersion>1.0.14</PackageVersion>
63+
<PackageName>DynamoHome</PackageName>
64+
</PropertyGroup>
65+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command echo ($(SolutionDir)\pkgexist.ps1 $(PackageName) $(PackageVersion))" ConsoleToMSBuild="true">
66+
<Output TaskParameter="ConsoleOutput" PropertyName="ShouldInstall" />
67+
</Exec>
68+
<Message Text="Skipping Install for $(PackageName) $(PackageVersion), package up to date." Condition="!$(ShouldInstall)" Importance="high"></Message>
5369
<!--This command updates the npm registry configuration if necessary-->
54-
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" />
70+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" Condition="$(ShouldInstall)"/>
5571
<!--Download a specific build of the Dynamo Home package from npm-->
56-
<Exec Command="npm pack @dynamods/[email protected]" />
72+
<Exec Command="npm pack @dynamods/[email protected]" Condition="$(ShouldInstall)"/>
5773
</Target>
5874

59-
<Target Name="ExtractTGZFileDynamoHome" DependsOnTargets="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
75+
<Target Name="ExtractTGZFileDynamoHome" DependsOnTargets="NpmRunBuildHomePage" BeforeTargets="BeforeBuild" Condition="$(ShouldInstall)">
6076
<!--Locate the .tgz files for the Dynamo Home package-->
6177
<ItemGroup>
6278
<TGZFilesDynamoHome Include="./dynamods-dynamo-home-*.tgz" />

src/LibraryViewExtensionWebView2/LibraryViewExtensionWebView2.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616
</PropertyGroup>
1717

1818
<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
19+
<PropertyGroup>
20+
<PackageVersion>1.0.5</PackageVersion>
21+
<PackageName>LibrarieJS</PackageName>
22+
</PropertyGroup>
23+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command echo ($(SolutionDir)\pkgexist.ps1 $(PackageName) $(PackageVersion))" ConsoleToMSBuild="true">
24+
<Output TaskParameter="ConsoleOutput" PropertyName="ShouldInstall" />
25+
</Exec>
26+
<Message Text="Skipping Install for $(PackageName) $(PackageVersion), package up to date." Condition="!$(ShouldInstall)" Importance="high"></Message>
1927
<!--This command updates the npm registry configuration if necessary-->
20-
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" />
28+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" Condition="$(ShouldInstall)"/>
2129
<!--This command gets a specific build of the notifcation center from npm-->
22-
<Exec Command="npm pack @dynamods/librariejs@1.0.5" />
30+
<Exec Command="npm pack @dynamods/librariejs@$(PackageVersion)" Condition="$(ShouldInstall)"/>
2331
</Target>
2432

25-
<Target Name="ExtractTGZFile" BeforeTargets="BeforeBuild">
33+
<Target Name="ExtractTGZFile" BeforeTargets="BeforeBuild" Condition="$(ShouldInstall)">
2634
<!--Locates the .tgz files-->
2735
<ItemGroup>
2836
<TGZFiles Include="./dynamods-librariejs-*.tgz" />

src/Notifications/Notifications.csproj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515
</PropertyGroup>
1616

1717
<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
18+
<PropertyGroup>
19+
<PackageVersion>0.0.29</PackageVersion>
20+
<PackageName>NotificationCenter</PackageName>
21+
</PropertyGroup>
22+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command echo ($(SolutionDir)\pkgexist.ps1 $(PackageName) $(PackageVersion))" ConsoleToMSBuild="true">
23+
<Output TaskParameter="ConsoleOutput" PropertyName="ShouldInstall" />
24+
</Exec>
25+
<Message Text="Skipping Install for $(PackageName) $(PackageVersion), package up to date." Condition="!$(ShouldInstall)" Importance="high"></Message>
26+
1827
<!--This command updates the npm registry configuration if necessary-->
19-
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" />
28+
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" Condition="$(ShouldInstall)"/>
2029
<!--This command gets a specific build of the notifcation center from npm-->
21-
<Exec Command="npm pack @dynamods/notifications-center@0.0.29" />
30+
<Exec Command="npm pack @dynamods/notifications-center@$(PackageVersion)" Condition="$(ShouldInstall)"/>
2231
</Target>
2332

24-
<Target Name="ExtractTGZFile" BeforeTargets="BeforeBuild">
33+
<Target Name="ExtractTGZFile" BeforeTargets="BeforeBuild" Condition="$(ShouldInstall)">
2534
<!--Locates the .tgz files-->
2635
<ItemGroup>
2736
<TGZFiles Include="./dynamods-notifications-center-*.tgz" />

src/pkgexist.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$pkgname=$args[0]
2+
$pkgver=$args[1]
3+
4+
If ((-Not (Test-Path .\Packages\$pkgname)) -Or (-Not (Test-Path .\Packages\$pkgname\package.json))) {
5+
echo true
6+
return
7+
}
8+
9+
$currver=(Get-Content .\Packages\$pkgname\package.json | ConvertFrom-Json).version
10+
If ($currver -ne $pkgver) {
11+
echo true
12+
}
13+
else {
14+
echo false
15+
}

0 commit comments

Comments
 (0)