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

Conversation

filipeotero
Copy link
Contributor

@filipeotero filipeotero commented Dec 5, 2022

Purpose

This PR is to avoid installing all the npm dependencies of the Notification Center and Splash Screen.

  • Use of npm pack instead of npm install
  • Extract the downloaded .tgz file
  • Update the assembly path of the files
  • Update the .gitignore for the new files

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

@QilongTang

FYIs

@RobertGlobant20

@filipeotero filipeotero changed the title Dyn 5405 npm pack dependencies DYN-5405 npm pack dependencies Dec 5, 2022
@@ -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

@@ -14,16 +14,33 @@
</PropertyGroup>

<Target Name="NpmRunBuild" BeforeTargets="BeforeBuild">
<Exec Command="npm install --prefix ./ @dynamods/splash-screen@latest" />
<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 Name="ExtractTGZFile" BeforeTargets="BeforeBuild">
<ItemGroup>
<TGZFiles Include="./*.tgz" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets all the files that contain the .tgz suffix

</ItemGroup>

<ItemGroup>
<Reversed Include="@(TGZFiles->Reverse())" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverts the order of the found files

</ItemGroup>

<PropertyGroup>
<Last>%(TGZFiles.Identity)</Last>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gets the last one

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

<Exec Command="tar -xzf $(Last)"></Exec>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracts the selected file

Copy link
Contributor

@QilongTang QilongTang left a comment

Choose a reason for hiding this comment

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

No doubt this would work, but I have some concern.

  1. If we want to specify the npm package version, similar to versioned Nuget package. If we stick to latest, it seems hard to get the exact package
  2. If we want to clean up the legacy npm package.

Just two thoughts I would like team to think over

@filipeotero
Copy link
Contributor Author

No doubt this would work, but I have some concern.

  1. If we want to specify the npm package version, similar to versioned Nuget package. If we stick to latest, it seems hard to get the exact package
  2. If we want to clean up the legacy npm package.

Just two thoughts I would like team to think over

1 - If we delete it after being extracted, maybe it won't be an issue since we will not maintain the files locally.

@reddyashish
Copy link
Contributor

The self-service job is running in a loop and the build is failing. Converting this to draft to unblock the jobs.

@reddyashish reddyashish marked this pull request as draft December 7, 2022 13:31
@filipeotero
Copy link
Contributor Author

We are getting this message from the self-service job:

18:27:12    tar -xzf c:\WorkspaceDynamo\src\DynamoCoreWpf\.\dynamods-splash-screen-1.0.5.tgz
18:27:13    'tar' is not recognized as an internal or external command,
18:27:13    operable program or batch file.
18:27:13  c:\WorkspaceDynamo\src\DynamoCoreWpf\DynamoCoreWpf.csproj(38,9): error MSB3073: The command "tar -xzf c:\WorkspaceDynamo\src\DynamoCoreWpf\.\dynamods-splash-screen-1.0.5.tgz" exited with code 9009.

Looks like there is no libarchive or something else to extract the tgz file.
Any ideas on how we can extract the file?

@QilongTang @reddyashish @RobertGlobant20

@QilongTang
Copy link
Contributor

@filipeotero Should we include this dll in the repo, is that enought to leverage it?

@filipeotero filipeotero marked this pull request as ready for review December 12, 2022 14:33
@filipeotero filipeotero marked this pull request as draft December 12, 2022 15:05
@mjkkirschner
Copy link
Member

mjkkirschner commented Dec 14, 2022

@filipeotero @avidit (not sure what investigation you did of the builder image) but
two thoughts:

I see that the above document that @filipeotero linked says:
You can call these tools from servercore images as well. - I believe Abi verified tar was present - so yep thats confusing.

In addition, have you considered using powershell? (which we know works on the builder image)
https://scatteredcode.net/download-and-extract-gzip-tar-with-powershell/

🤦 ... the end of that post, if I had read far enough uses a 7zip powershell commandlet.

@mjkkirschner
Copy link
Member

one more thought - if 7zip turns out to be the best solution, another approach is to add it to the builder image - this is nice because we add it for all our jobs that use that image, not just dynamo, in addition it makes it very unlikely we would distribute it - worth checking with legal if that makes things simpler.

@filipeotero
Copy link
Contributor Author

Hi @mjkkirschner, I'm using VS 2019.
What about using the nuget package as you mentioned? I didn't try it yet but if it works we won't need to include binaries, right?

@mjkkirschner
Copy link
Member

we don't need to include the binaries, but we still need to reference it and still need to go through legal.

@avidit
Copy link
Contributor

avidit commented Dec 15, 2022

@avidit (not sure what investigation you did of the builder image)

@mjkkirschner I ran docker run -it --rm mcr.microsoft.com/powershell:lts-windowsservercore-1909 tar --version and the output was bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.5.f-ipp

@avidit avidit closed this Dec 15, 2022
@avidit avidit reopened this Dec 15, 2022
@filipeotero
Copy link
Contributor Author

@mjkkirschner I submitted a new commit that deletes the binaries and references the nuget package. Also, I'm still trying to reach the legal team about using 7zip. Thanks!

@filipeotero
Copy link
Contributor Author

@QilongTang Just to let you know, we have to wait for the EngOps to catch up before we merge this. https://jira.autodesk.com/browse/ESC-34251

<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!

Copy link
Contributor

@QilongTang QilongTang left a comment

Choose a reason for hiding this comment

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

LGTM but with one concern commented

@sm6srw
Copy link
Contributor

sm6srw commented Feb 2, 2023

@filipeotero I think we can get this PR ready for merging again. The BRE pipeline have been using VS2022 now for a couple of days.

@filipeotero
Copy link
Contributor Author

@zeusongit Just to let you know, this PR is ready to be merged after the checks are completed. Thanks!

@zeusongit zeusongit merged commit 2cec940 into DynamoDS:master Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants