From 8ae35955595345a09164281df70c0f50eb1f28fa Mon Sep 17 00:00:00 2001 From: EnumDev Date: Thu, 8 May 2025 17:15:34 +0300 Subject: [PATCH] Initial Commit --- .compilation-options | 1 + pkg.info | 10 ++++++ source.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .compilation-options create mode 100644 pkg.info create mode 100644 source.sh diff --git a/.compilation-options b/.compilation-options new file mode 100644 index 0000000..9c7aafe --- /dev/null +++ b/.compilation-options @@ -0,0 +1 @@ +ARCH=any diff --git a/pkg.info b/pkg.info new file mode 100644 index 0000000..84d632f --- /dev/null +++ b/pkg.info @@ -0,0 +1,10 @@ +name: npm +description: Package Manager for JavaScript +version: 11.2.0 +url: https://www.npmjs.com/ +license: Artistic-2.0 +architecture: any +depends: ["node-gyp","nodejs","nodejs-nopt"] +optional_depends: ["git"] +make_depends: ["git"] +type: source diff --git a/source.sh b/source.sh new file mode 100644 index 0000000..fd678e2 --- /dev/null +++ b/source.sh @@ -0,0 +1,72 @@ +# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package +# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE +# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT + +# +# Source script mostly copied from Arch Linux +# + +REPO="https://github.com/npm/cli.git" + +# The prepare function is executed in the root of the temp directory +# This function is used for downloading files and putting them into the correct location +prepare() { + git clone --single-branch --branch "v${BPM_PKG_VERSION}" "$REPO" "$BPM_SOURCE" +} + +# The build function is executed in the source directory +# This function is used to compile the source code +build() { + node scripts/resetdeps.js +} + +# The check function is executed in the source directory +# This function is used to run tests to verify the package has been compiled correctly +check() { + # Windows shims test failure + mv test/bin/windows-shims.js{,.bak} + node . run test --ignore-scripts -- --no-coverage + mv test/bin/windows-shims.js{.bak,} +} + +# The package function is executed in the source directory +# This function is used to move the compiled files into the output directory +package() { + mod_dir=/usr/lib/node_modules/npm + + install -d "$BPM_OUTPUT"/usr/share/{bash-completion/completions,licenses/npm} + ln -s "$mod_dir"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/npm/LICENSE + + node . install -g --prefix="${BPM_OUTPUT}/usr" "$(node . pack --ignore-scripts | tail -1)" + node . completion > "$BPM_OUTPUT"/usr/share/bash-completion/completions/npm + echo 'globalconfig=/etc/npmrc' > "$BPM_OUTPUT"/$mod_dir/npmrc + + cd "$BPM_OUTPUT"/"$mod_dir" + # Remove superfluous scripts + rm -r {bin/{node-gyp-bin,np{m,x}{,.{cmd,ps1}}},node_modules/.bin} + + # Experimental dedup + rm -r node_modules/{node-gyp,nopt,semver} + + #cd man + ## Workaround for https://github.com/npm/cli/issues/780 + #local name page sec title + #for page in man5/folders.5 man5/install.5 man7/*.7; do + # sec=${page##*.} + # name=$(basename "$page" ."$sec") + # title=${name@U} + + # sed -Ei "s/^\.TH \"$title\"/.TH \"NPM-$title\"/" "$page" + # mv "$page" "${page/\///npm-}" + #done + + #gzip man?/* + + # Support both `man` and `npm help` + #local dest sec_dir + #for sec_dir in man?; do + # dest="$BPM_OUTPUT"/usr/share/man/$sec_dir + # install -d "$dest" + # ln -r -s "$sec_dir"/* "$dest" + #done +}