File yarn.spec of Package yarn
%define realname yarn
%define realver 1.22.22
%define srcext tar.gz
# Common info
Name: %{realname}
Version: %{realver}
Release: %{?extraver:0.}1%{?dist}
License: BSD-2-Clause
Group: Development/Languages/NodeJS
URL: https://classic.yarnpkg.com/lang/en/
Summary: Fast, reliable, and secure dependency management
# Install-time parameters
Requires: nodejs(engine)
Provides: nodejs-%{realname} = %{version}
Provides: npm(%{realname}) = %{version}
# Build-time parameters
BuildArch: noarch
Source: https://yarnpkg.com/downloads/%{realver}/%{realname}-v%{realver}.%{srcext}
%description
Yarn is a package manager for your code. It allows you to use and share code
with other developers from around the world. Yarn does this quickly, securely,
and reliably so you don't ever have to worry.
%prep
%setup -q -n %{realname}-v%{realver}
%install
%{__install} -d -m0755 %{buildroot}%{_datadir}/node_modules
%{__cp} -r %{_builddir}/%{realname}-v%{realver} %{buildroot}%{_datadir}/node_modules/yarn
%{__install} -d -m0755 %{buildroot}%{_bindir}
%{__ln_s} ../share/node_modules/yarn/bin/yarn.js %{buildroot}%{_bindir}/yarn
%{__ln_s} ../share/node_modules/yarn/bin/yarn.js %{buildroot}%{_bindir}/yarnpkg
# Fix shebang
%{__sed} -i '1 s|^.* node$|#!%{_bindir}/node|' \
%{buildroot}%{_datadir}/node_modules/yarn/bin/yarn.js \
%{buildroot}%{_datadir}/node_modules/yarn/bin/yarnpkg \
%{buildroot}%{_datadir}/node_modules/yarn/lib/cli.js
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license %{_datadir}/node_modules/yarn/LICENSE
%doc %{_datadir}/node_modules/yarn/README.md
%{_bindir}/yarn
%{_bindir}/yarnpkg
%dir %{_datadir}/node_modules
%{_datadir}/node_modules/yarn/
%changelog