Skip to content

Drop NPM < 7 support, SCL support and use a relative cache directory#87

Open
ekohl wants to merge 4 commits intotheforeman:masterfrom
ekohl:drop-scl
Open

Drop NPM < 7 support, SCL support and use a relative cache directory#87
ekohl wants to merge 4 commits intotheforeman:masterfrom
ekohl:drop-scl

Conversation

@ekohl
Copy link
Copy Markdown
Member

@ekohl ekohl commented Dec 24, 2025

See individual commits for details.

%prep
mkdir -p %{npm_cache_dir}
for tgz in %{sources}; do
echo $tgz | grep -q registry.npmjs.org || npm cache add --cache %{npm_cache_dir} $tgz
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While it does not hurt to keep this logic, I'd suggest removing it and adding all sources to the cache as --offline hard fails if the package is missing from the cache.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That will lead to much bigger cache tarballs that we need to include in our git tree, which blows it up over time. It's already bad, but that makes it way worse. See #68 / https://community.theforeman.org/t/trimming-foreman-packaging-branches/29189/7 for details but the tl;dr is that I saw a 31% reduction in the cache filesize on the specific package I tested.

Copy link
Copy Markdown
Member Author

@ekohl ekohl Apr 7, 2026

Choose a reason for hiding this comment

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

And since I perhaps missed it: you do need the tarball with the cached responses because that's how NPM works. That should not be added to NPM's cache. I'll admit it's not easy to read due to the ||. It effectively comes down to:

if [[ $tgz != *registry.npmjs.org* ]]; then
  npm cache add --cache %{npm_cache_dir} $tgz
fi

But I don't know if you can use bashisms in RPM.

Comment on lines 25 to +39
@@ -36,7 +36,7 @@ done
%setup -T -q -a {{{PROVIDES.length}}} -D -n %{npm_cache_dir}

%build
npm install {{{LEGACY_PEER_DEPS}}}--offline --cache %{npm_cache_dir} --package-lock false --omit optional --install-strategy shallow %{npm_name}@%{version}
npm install {{{LEGACY_PEER_DEPS}}}--offline --cache %{_builddir}/%{npm_cache_dir} --package-lock false --omit optional --install-strategy shallow %{npm_name}@%{version}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we define npm_cache_path once as a full path relative to builddir?

%define npm_cache_path %{_builddir}/npm_cache_dir

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Possibly, I didn't investigate too deeply.

Copy link
Copy Markdown
Member

@ogajduse ogajduse left a comment

Choose a reason for hiding this comment

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

I am very new to this project, but from what I've seen, there is a portion of breaking changes. Do you plan to release a new major version?

@ekohl
Copy link
Copy Markdown
Member Author

ekohl commented Feb 23, 2026

I am very new to this project, but from what I've seen, there is a portion of breaking changes. Do you plan to release a new major version?

Yes, this is IMHO major version material.

@nadjaheitmann
Copy link
Copy Markdown

What is the state of this PR? I have used it to generate theforeman/foreman-packaging#13080 and IMHO, it looks good. It would be nice to continue here as ALL nodejs packages in foreman-packaging still have the SCL logic included.

@ekohl ekohl changed the title Drop NPM < 6 support, SCL support and use a relative cache directory Drop NPM < 7 support, SCL support and use a relative cache directory Apr 7, 2026
@nadjaheitmann
Copy link
Copy Markdown

@ogajduse Do you mind taking another look?

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.

3 participants