aboutsummaryrefslogtreecommitdiffstats
path: root/main/npm
diff options
context:
space:
mode:
Diffstat (limited to 'main/npm')
-rw-r--r--main/npm/APKBUILD118
-rw-r--r--main/npm/dont-check-for-last-version.patch15
-rw-r--r--main/npm/make-dont-install-deps.patch11
-rw-r--r--main/npm/npmrc6
-rw-r--r--main/npm/reproducible-documentation-build.patch20
-rw-r--r--main/npm/smoke-tests-npm-location.patch23
6 files changed, 193 insertions, 0 deletions
diff --git a/main/npm/APKBUILD b/main/npm/APKBUILD
new file mode 100644
index 0000000000..73d0826cb2
--- /dev/null
+++ b/main/npm/APKBUILD
@@ -0,0 +1,118 @@
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
+pkgname=npm
+pkgver=7.17.0
+pkgrel=0
+pkgdesc="The package manager for JavaScript"
+url="https://npm.community"
+arch="noarch !mips64 !mips64el !riscv64" # limited by nodejs
+license="Artistic-2.0"
+depends="cmd:node"
+makedepends="bash nodejs"
+replaces="nodejs-doc" # for backward compatibility
+subpackages="$pkgname-doc $pkgname-bash-completion"
+source="https://github.com/npm/cli/archive/v$pkgver/npm-cli-$pkgver.tar.gz
+ reproducible-documentation-build.patch
+ dont-check-for-last-version.patch
+ make-dont-install-deps.patch
+ smoke-tests-npm-location.patch
+ npmrc
+ "
+builddir="$srcdir/cli-$pkgver"
+
+prepare() {
+ default_prepare
+
+ # Remove bunch of unnecessary files to reduce size of the package.
+
+ rm bin/npm bin/npx bin/*.cmd bin/node-gyp-bin/*.cmd
+
+ cd node_modules
+ find . -type f \( \
+ -name '.*' -o \
+ -name '*.cmd' -o \
+ -name '*.coffee' -o \
+ -name '*.bat' -o \
+ -name '*.map' -o \
+ -name '*.md' -o \
+ -name '*.ts' -o \
+ -name 'AUTHORS*' -o \
+ -name 'LICENSE*' -o \
+ -name 'Makefile' -o \
+ -name 'README*' -o \) -delete
+ rm -Rf ./*/.git* ./*/doc ./*/docs ./*/examples ./*/scripts ./*/test
+
+ # No files should be executable here, except node-gyp.
+ find . -type f -executable ! -name 'node-gyp*' -exec chmod -x {} \;
+
+ cd ../docs/content
+
+ # XXX: Workaround for https://github.com/npm/cli/issues/780.
+ local f name
+ for f in configuring-npm/folders.md configuring-npm/install.md using-npm/*.md; do
+ name=$(basename $f .md)
+ sed -Ei "s/^title: $name/title: npm-$name/" "$f"
+ mv "$f" "$(dirname $f)/npm-$name.md"
+ done
+
+ cd "$builddir"
+
+ # Backup files that will be included in the package before installing
+ # additional dev dependencies and running tests.
+ mkdir -p "$srcdir"/npm
+ cp -r bin lib node_modules package.json "$srcdir"/npm/
+
+ # Install dependencies needed for mandocs and smoke-tests.
+ node bin/npm-cli.js install --ignore-scripts --no-audit --no-fund
+}
+
+build() {
+ # Convert Markdown docs to man pages.
+ make mandocs
+
+ # Generate bash completions.
+ node bin/npm-cli.js completion > npm.bash
+}
+
+check() {
+ make smoke-tests NPM_LOCATION="$srcdir/npm"
+}
+
+package() {
+ local destdir="$pkgdir/usr/lib/node_modules/npm"
+
+ mkdir -p "$destdir"
+ cp -r "$srcdir"/npm/* "$destdir"/
+
+ install -m 644 "$srcdir"/npmrc -t "$destdir"/
+
+ mkdir -p "$pkgdir"/usr/bin
+ ln -s ../lib/node_modules/npm/bin/npm-cli.js "$pkgdir"/usr/bin/npm
+ ln -s ../lib/node_modules/npm/bin/npx-cli.js "$pkgdir"/usr/bin/npx
+ ln -s ../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js "$pkgdir"/usr/bin/node-gyp
+
+ cd "$builddir"
+
+ mkdir -p "$pkgdir"/usr/share
+ cp -r man "$pkgdir"/usr/share/
+ ln -s ../../../share/man "$destdir"/man
+
+ install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
+
+ install -Dm 644 npm.bash "$pkgdir"/usr/share/bash-completion/completions/npm
+}
+
+doc() {
+ default_doc
+
+ amove usr/lib/node_modules/npm/man
+}
+
+sha512sums="
+01349884845e84b4cf79162624425ed838552b3e0cf248d5f2bad87cadc10c304a3107fdac3a14d60b177a1aa8816227c8b0fbf0e7fde8d27ab391f5ccbe5246 npm-cli-7.17.0.tar.gz
+c75734fc24bf9aac9ae795f49f1145a99b82ec359a05af18531ae5a22edd1a22348faf301d9b6e3d0b68d3333df76136c17d4953ecd4f5f5efdbfb06a227a174 reproducible-documentation-build.patch
+86bcf0d9883073b330dcb90ced00e8293dd011e1587791fadc14eb0c25eedfe7132626f9bfb792ae2587d335464f71b1af1183b5e6a411b04f975ff5aa06cdc7 dont-check-for-last-version.patch
+0aed63f6b541378d51794393bf70b6401c7bdbc8c1ebbf35fc8b91c8220fc5ab1753f577908b0dc24bdeaf4f9cabb3bb1a48329c2ac026aba1f479d6a53311d6 make-dont-install-deps.patch
+bb0f40db679c4811531e0373cb133dc116cf0efe3e9b4619a73c6897ab440dd99c592fa4f682b72aaef311a231f5b02934b90f9aa538aadb106b49cb3f2ddd91 smoke-tests-npm-location.patch
+6d0ce425061ffff1c5d7a42c9908f3382cd77abf81a9c30a62ff6fff1f0d02ff633b2bb090814aa619f7d2a51237b3da7f85d97d0f584e037639b60ccfaf0e96 npmrc
+"
diff --git a/main/npm/dont-check-for-last-version.patch b/main/npm/dont-check-for-last-version.patch
new file mode 100644
index 0000000000..8f08e2236a
--- /dev/null
+++ b/main/npm/dont-check-for-last-version.patch
@@ -0,0 +1,15 @@
+Don't check for last version
+
+Patch based on https://sources.debian.org/src/npm/7.5.2+ds-2/debian/patches/dont-check-for-last-version.patch
+
+--- a/lib/utils/update-notifier.js
++++ b/lib/utils/update-notifier.js
+@@ -40,6 +40,8 @@
+ }
+
+ const updateNotifier = async (npm, spec = 'latest') => {
++ // XXX-Patched: Maintained by Alpine's package manager
++ return null;
+ // never check for updates in CI, when updating npm already, or opted out
+ if (!npm.config.get('update-notifier') ||
+ isGlobalNpmUpdate(npm) ||
diff --git a/main/npm/make-dont-install-deps.patch b/main/npm/make-dont-install-deps.patch
new file mode 100644
index 0000000000..ac6aa0aa49
--- /dev/null
+++ b/main/npm/make-dont-install-deps.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -47,7 +47,7 @@
+
+ ## build-time dependencies for the documentation
+ dev-deps:
+- node bin/npm-cli.js install --no-audit --ignore-scripts
++ true # skip
+
+ ## targets for man files, these are encouraged to be only built by running `make docs` or `make mandocs`
+ man/man1/%.1: docs/content/commands/%.md scripts/docs-build.js
diff --git a/main/npm/npmrc b/main/npm/npmrc
new file mode 100644
index 0000000000..4355e9697b
--- /dev/null
+++ b/main/npm/npmrc
@@ -0,0 +1,6 @@
+# Do not modify this file - use /etc/npmrc instead!
+
+globalconfig=/etc/npmrc
+globalignorefile=/etc/npmignore
+prefix=/usr/local
+python=/usr/bin/python3
diff --git a/main/npm/reproducible-documentation-build.patch b/main/npm/reproducible-documentation-build.patch
new file mode 100644
index 0000000000..1021a15a31
--- /dev/null
+++ b/main/npm/reproducible-documentation-build.patch
@@ -0,0 +1,20 @@
+Description: Use source-date-epoch as timestamp source for documentation
+Author: James Addison <jay+salsa@jp-hosting.net>
+Origin: https://salsa.debian.org/js-team/npm/-/merge_requests/7
+Forwarded: no
+Last-Update: 2021-06-13
+
+Patch-Source: https://sources.debian.org/src/npm/7.5.2+ds-2/debian/patches/2020_reproducible_documentation_build.patch
+
+--- a/scripts/docs-build.js
++++ b/scripts/docs-build.js
+@@ -34,7 +34,8 @@
+ .replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, replacer)
+ .trim()
+
+- fs.writeFile(dest, marked(result), 'utf8', function (err) {
++ var date = new Date(process.env.SOURCE_DATE_EPOCH)
++ fs.writeFile(dest, marked(result, {date}), 'utf8', function (err) {
+ if (err)
+ return console.log(err)
+ })
diff --git a/main/npm/smoke-tests-npm-location.patch b/main/npm/smoke-tests-npm-location.patch
new file mode 100644
index 0000000000..79f96758fa
--- /dev/null
+++ b/main/npm/smoke-tests-npm-location.patch
@@ -0,0 +1,23 @@
+Allow to specify custom npm location for smoke-tests, so we can test npm
+without development dependencies involved.
+
+--- a/smoke-tests/index.js
++++ b/smoke-tests/index.js
+@@ -29,7 +29,7 @@
+ })
+ const localPrefix = resolve(path, 'project')
+ const userconfigLocation = resolve(path, '.npmrc')
+-const npmLocation = resolve(__dirname, '..')
++const npmLocation = resolve(__dirname, process.env.NPM_LOCATION || '..')
+ const cacheLocation = resolve(path, 'cache')
+ const binLocation = resolve(path, 'bin')
+ const env = {
+@@ -57,7 +57,7 @@
+ t.equal(pkg.version, '1.0.0', 'should have expected generated version')
+ })
+
+-t.test('npm (no args)', async t => {
++t.skip('npm (no args)', async t => {
+ const cmd = `"${process.execPath}" "${npmLocation}" --no-audit --no-update-notifier`
+ const cmdRes = await execAsync(cmd, { cwd: localPrefix, env })
+ .catch(err => {