aboutsummaryrefslogtreecommitdiffstats
path: root/main/npm/APKBUILD
blob: 01451299d42b3760712796b623dce0ab43cd56ac (plain) (blame)
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
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=npm
pkgver=7.9.0
pkgrel=1
pkgdesc="The package manager for JavaScript"
url="https://npm.community"
arch="noarch !mips64 !mips64el"  # limited by nodejs
license="Artistic-2.0"
depends="nodejs"
makedepends="bash"
replaces="nodejs-doc"  # for backward compatibility
subpackages="$pkgname-doc $pkgname-bash-completions:bashcomp"
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="ad59518cfa8990d61d662de6385489fa0f490f556d5de479890363feb74d8eadc3074e41c5899d09c94c15bc7661766eee20666fca97fac4178e6b26b9c7c6f7  npm-cli-7.9.0.tar.gz
44821978050194c126a9d3c0fb9df9204100d8e88c13a9aa8c0e74769f3a667ce605c1f37e053a658dde6ee8367cf71005ea3f1705b3a95700767bc041a28f15  reproducible-documentation-build.patch
92728357d9d03a40b275ba01980a569dc456f526a415edc22a4582162ff8dcafe8f32cb42f14bc93ea627f1ac9384a42abe2bcdfb8ed04c06491a27b1efc7e40  dont-check-for-last-version.patch
0aed63f6b541378d51794393bf70b6401c7bdbc8c1ebbf35fc8b91c8220fc5ab1753f577908b0dc24bdeaf4f9cabb3bb1a48329c2ac026aba1f479d6a53311d6  make-dont-install-deps.patch
bb0f40db679c4811531e0373cb133dc116cf0efe3e9b4619a73c6897ab440dd99c592fa4f682b72aaef311a231f5b02934b90f9aa538aadb106b49cb3f2ddd91  smoke-tests-npm-location.patch
6d0ce425061ffff1c5d7a42c9908f3382cd77abf81a9c30a62ff6fff1f0d02ff633b2bb090814aa619f7d2a51237b3da7f85d97d0f584e037639b60ccfaf0e96  npmrc"