npm

Details
Source
FROM scratch AS build
ARG VERSION
COPY --from=stagex/core-musl . /
COPY --from=stagex/core-busybox . /
ADD fetch/npm-${VERSION}.tgz .
WORKDIR /package
ADD *.patch .
ENV DESTDIR=/rootfs
RUN --network=none <<-EOF
	patch -p1 < dont-check-for-last-version.patch
	rm bin/npm bin/npx bin/*.cmd
	rm README.md
	rm -rf docs
	cd node_modules
	find . -type f \( \
		-name '.*' -o \
		-name '*.cmd' -o \
		-name '*.bat' -o \
		-name '*.map' -o \
		-name '*.md' -o \
		\( -name '*.ts' -a ! -name '*.d.ts' \) -o \
		-name 'AUTHORS*' -o \
		-name 'LICENSE*' -o \
		-name 'license' -o \
		-name 'Makefile' -o \
		-name 'README*' -o \
		-name 'readme.markdown' \) -delete
	rm -rf ./*/.git* ./*/doc ./*/docs ./*/examples ./*/scripts ./*/test
	rm -rf ./node-gyp/gyp/.git*
	# No files should be executable here, except node-gyp.
	find . -type f -executable ! -name 'node-gyp*' -exec chmod -x {} \;
	cd /package
	destdir="usr/lib/node_modules/npm"
	mkdir -p $DESTDIR/$destdir
	cp -R ./* $DESTDIR/$destdir
	cd $DESTDIR
	mkdir -p usr/bin
	ln -s ../lib/node_modules/npm/bin/npm-cli.js usr/bin/npm
	ln -s ../lib/node_modules/npm/bin/npx-cli.js usr/bin/npx
	ln -s ../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js usr/bin/node-gyp
	mkdir -p usr/share/licenses/npm
	mv ${destdir}/LICENSE usr/share/licenses/npm/
	install -D -m644 "$destdir"/lib/utils/completion.sh \
	usr/share/bash-completion/completions/npm
EOF
FROM stagex/core-filesystem AS package
COPY --from=build /rootfs/ /