aboutsummaryrefslogtreecommitdiffstats
path: root/main/npm/APKBUILD
blob: 73d0826cb236384a227f4ab0b8652d3ef650d9c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
"