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

DYN-5405 npm pack dependencies #13599

Merged
merged 33 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b5c7f5b
build and extract files
filipeotero Dec 1, 2022
c076159
splash screen config
filipeotero Dec 1, 2022
6bda01b
build files notification center
filipeotero Dec 2, 2022
a6db514
Merge branch 'master' into DYN-5405-NpmPack-Dependencies
filipeotero Dec 2, 2022
3d09dbf
Files configuration
filipeotero Dec 2, 2022
97429db
remove test code
filipeotero Dec 2, 2022
48ce289
adding comments
filipeotero Dec 5, 2022
8a2989a
removing the the file after extracting
filipeotero Dec 5, 2022
bd7d9ad
retrigger checks
filipeotero Dec 6, 2022
0afb7c2
Inserting depends on target property
filipeotero Dec 7, 2022
471b449
full file path
filipeotero Dec 7, 2022
84a494e
Adding commands to test self-service job
filipeotero Dec 12, 2022
5bf01d2
adding tar.exe file in the project
filipeotero Dec 12, 2022
55edca1
x64 executable
filipeotero Dec 12, 2022
001a36d
tar from libarchive
filipeotero Dec 12, 2022
5586842
retrigger checks
filipeotero Dec 13, 2022
fe8afdf
including 7zip
filipeotero Dec 13, 2022
bdd8b32
adding 7zip NotificationCenter
filipeotero Dec 13, 2022
cafaa98
adding extra messages and -v for the tar command
filipeotero Dec 14, 2022
a71d7a9
Removing 7zip binaries and adding nuget package
filipeotero Dec 15, 2022
1553821
show executables from system 32
filipeotero Dec 16, 2022
a4264d5
print hostnamo and %path%
filipeotero Dec 16, 2022
6ca6ec6
printing dir \a
filipeotero Dec 16, 2022
2fa4149
printing sysnative folder
filipeotero Jan 4, 2023
0f5f464
set PreferredToolArchitecture to x64
filipeotero Jan 6, 2023
7545c4a
testing tar again
filipeotero Jan 10, 2023
12d1979
update html string
filipeotero Jan 10, 2023
8b88494
Removing 7zip from ignore file
filipeotero Jan 10, 2023
6138bd2
adding subfolders depending on the name of the packages
filipeotero Jan 12, 2023
3280714
fix unit test
filipeotero Jan 12, 2023
a76c2e5
retrigger checks
filipeotero Jan 13, 2023
2199c34
Merge branch 'master' into DYN-5405-NpmPack-Dependencies
filipeotero Feb 2, 2023
b41bc1f
merge from master
filipeotero Feb 2, 2023
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
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ test/core/customast/test.txt
test/core/files/test.png
test/core/migration/writetext.txt
logo.png
/src/Notifications/node_modules
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the old folder hierarchy

/src/Notifications/package.json
/src/Notifications/package-lock.json
/src/Notifications/.npm-cache
/src/DynamoCoreWpf/node_modules
/src/DynamoCoreWpf/package-lock.json
/src/DynamoCoreWpf/package.json
/src/DynamoCoreWpf/.npm-cache
/src/DynamoCoreWpf/package
dynamods-splash-screen-*.tgz
/src/Notifications/package
/src/Notifications/dynamods-notifications-center-*.tgz
2 changes: 1 addition & 1 deletion extern/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# override specific package dlls#
###################
!*.dll
!*.dll
43 changes: 37 additions & 6 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,50 @@
<DocumentationFile>$(OutputPath)\DynamoCoreWpf.XML</DocumentationFile>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>

<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
<Exec Command="npm install --prefix ./ @dynamods/splash-screen@latest" />
<!--This command gets the latest build from the splash screen-->
<Exec Command="npm pack @dynamods/splash-screen@latest" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first step is to download the .tgz file

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you add inline comments, you should be able to use <!-- comment -->

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we clean up none latest versioned npm package?

</Target>
<ItemGroup>
<None Remove="node_modules\%40dynamods\splash-screen\build\index.bundle.js" />
<None Remove="node_modules\%40dynamods\splash-screen\build\index.html" />

<Target Name="ExtractTGZFile" DependsOnTargets="NpmRunBuild" BeforeTargets="BeforeBuild">
<!--Locates the .tgz files-->
<ItemGroup>
<TGZFiles Include="./dynamods-splash-screen-*.tgz" />
</ItemGroup>

<!--Reverse the order of the files to get the higher version-->
<ItemGroup>
<Reversed Include="@(TGZFiles-&gt;Reverse())" />
</ItemGroup>

<PropertyGroup>
<Last>%(TGZFiles.Filename)</Last>
</PropertyGroup>

<!--Extracts the file to /package-->
<Exec Command="tar -xzf $(MSBuildProjectDirectory)\$(Last).tgz"></Exec>

<!--Deletes the tgz file-->
<Delete Files="$(MSBuildProjectDirectory)\$(Last).tgz" />
</Target>


<ItemGroup>
<PackageReference Include="7-Zip.StandaloneConsole.x64" Version="22.1.0" />
</ItemGroup>


<ItemGroup>
<None Remove="package\build\index.bundle.js" />
<None Remove="package\build\index.html" />
<None Remove="Views\SplashScreen\WebApp\splashScreenBackground.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="node_modules\@dynamods\splash-screen\build\index.bundle.js" />
<EmbeddedResource Include="node_modules\@dynamods\splash-screen\build\index.html" />
<EmbeddedResource Include="package\build\index.bundle.js" />
<EmbeddedResource Include="package\build\index.html" />
Copy link
Contributor

@QilongTang QilongTang Jan 11, 2023

Choose a reason for hiding this comment

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

If there is no need for a specific package name, to me it means that we would only support a single npm package per project. Do we need to specify the folder name during unzipping? I would like to think about if a project depending on two or more npm package, does the current structure work in that setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is not necessary to specify the folder name during unzipping. By default, the folder created is called package. We can create folders named properly using the --directory argument from tar.

Copy link
Contributor

Choose a reason for hiding this comment

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

@filipeotero Understood, my point is that if in the future DynamoCoreWpf is depending on multiple npm packages, they will all be unzipped to the package folder and the index.html will be overwriting each other. If possible, I would love to have the dir specified to prevent that case from happening, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I will do that!

<EmbeddedResource Include="Views\SplashScreen\WebApp\splashScreenBackground.png" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace Dynamo.UI.Views
public partial class SplashScreen : Window
{
// These are hardcoded string and should only change when npm package structure changed or image path changed
private static readonly string htmlEmbeddedFile = "Dynamo.Wpf.node_modules._dynamods.splash_screen.build.index.html";
private static readonly string jsEmbeddedFile = "Dynamo.Wpf.node_modules._dynamods.splash_screen.build.index.bundle.js";
private static readonly string htmlEmbeddedFile = "Dynamo.Wpf.package.build.index.html";
private static readonly string jsEmbeddedFile = "Dynamo.Wpf.package.build.index.bundle.js";
private static readonly string backgroundImage = "Dynamo.Wpf.Views.SplashScreen.WebApp.splashScreenBackground.png";
private static readonly string imageFileExtension = "png";

Expand Down Expand Up @@ -261,7 +261,7 @@ protected override async void OnContentRendered(EventArgs e)
webView.CoreWebView2.Settings.IsZoomControlEnabled = false;

var assembly = Assembly.GetExecutingAssembly();

using (Stream stream = assembly.GetManifestResourceStream(htmlEmbeddedFile))
using (StreamReader reader = new StreamReader(stream))
{
Expand Down
4 changes: 2 additions & 2 deletions src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class NotificationCenterController
private static readonly int notificationPopupVerticalOffset = 5;
private static readonly int limitOfMonthsFilterNotifications = 6;

private static readonly string htmlEmbeddedFile = "Dynamo.Notifications.node_modules._dynamods.notifications_center.build.index.html";
private static readonly string jsEmbeddedFile = "Dynamo.Notifications.node_modules._dynamods.notifications_center.build.index.bundle.js";
private static readonly string htmlEmbeddedFile = "Dynamo.Notifications.package.build.index.html";
private static readonly string jsEmbeddedFile = "Dynamo.Notifications.package.build.index.bundle.js";
private static readonly string NotificationCenterButtonName = "notificationsButton";
internal DirectoryInfo webBrowserUserDataFolder;

Expand Down
41 changes: 33 additions & 8 deletions src/Notifications/Notifications.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
Expand All @@ -10,18 +10,43 @@
<AssemblyName>Notifications</AssemblyName>
</PropertyGroup>

<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
<Exec Command="npm install --prefix ./ @dynamods/notifications-center@latest" />
</Target>
<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
<!--This command gets the latest build from the notifcation center-->
<Exec Command="npm pack @dynamods/notifications-center@latest" />
</Target>

<Target Name="ExtractTGZFile" BeforeTargets="BeforeBuild">
<!--Locates the .tgz files-->
<ItemGroup>
<TGZFiles Include="./dynamods-notifications-center-*.tgz" />
</ItemGroup>

<!--Reverse the order of the files to get the higher version-->
<ItemGroup>
<Reversed Include="@(TGZFiles-&gt;Reverse())" />
</ItemGroup>

<!--Gets the last one-->
<PropertyGroup>
<Last>%(TGZFiles.Filename)</Last>
</PropertyGroup>

<!--Extracts the file to /package-->
<Exec Command="tar -xzf $(MSBuildProjectDirectory)\$(Last).tgz"></Exec>

<!--Deletes the tgz file-->
<Delete Files=" $(MSBuildProjectDirectory)\$(Last).tgz" />
</Target>


<ItemGroup>
<None Remove="node_modules\%40dynamods\package.json" />
<None Remove="node_modules\%40dynamods\README.md" />
<None Remove="package\package.json" />
<None Remove="package\README.md" />
<None Remove="View\NotificationUI.xaml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="node_modules\@dynamods\notifications-center\build\index.bundle.js" />
<EmbeddedResource Include="node_modules\@dynamods\notifications-center\build\index.html" />
<EmbeddedResource Include="package\build\index.bundle.js" />
<EmbeddedResource Include="package\build\index.html" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void PressNotificationButtonAndShowPopup()
public void ValidateNotificationsUIEmbededFiles()
{
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x=>x.ManifestModule.Name.Contains("Notifications.dll"));
var htmlFile = "Dynamo.Notifications.node_modules._dynamods.notifications_center.build.index.html";
var htmlFile = "Dynamo.Notifications.package.build.index.html";

var mainJstag = "mainJs";

Expand Down