summaryrefslogtreecommitdiff
path: root/deps/npm/scripts
diff options
context:
space:
mode:
authorRuy Adorno <ruyadorno@hotmail.com>2019-11-05 14:55:08 -0500
committerRich Trott <rtrott@gmail.com>2019-11-09 20:13:43 -0800
commit4b97c3addb246274cd7e8432edd537e0bdf60b63 (patch)
tree9f859239c3b38b04ddc58ee736bf6b2caf6008a5 /deps/npm/scripts
parent5f9794ea9aaaf5597974a65460e1f3069f68475f (diff)
downloadandroid-node-v8-4b97c3addb246274cd7e8432edd537e0bdf60b63.tar.gz
android-node-v8-4b97c3addb246274cd7e8432edd537e0bdf60b63.tar.bz2
android-node-v8-4b97c3addb246274cd7e8432edd537e0bdf60b63.zip
deps: update npm to 6.13.0
PR-URL: https://github.com/nodejs/node/pull/30271 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'deps/npm/scripts')
-rwxr-xr-xdeps/npm/scripts/doc-build.sh67
-rw-r--r--deps/npm/scripts/docs-build.js26
-rwxr-xr-xdeps/npm/scripts/index-build.js58
3 files changed, 26 insertions, 125 deletions
diff --git a/deps/npm/scripts/doc-build.sh b/deps/npm/scripts/doc-build.sh
deleted file mode 100755
index a37a5e2618..0000000000
--- a/deps/npm/scripts/doc-build.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env bash
-
-if [[ $DEBUG != "" ]]; then
- set -x
-fi
-set -o errexit
-set -o pipefail
-
-src=$1
-dest=$2
-name=$(basename ${src%.*})
-date=$(date -u +'%Y-%m-%d %H:%M:%S')
-version=$(node bin/npm-cli.js -v)
-
-mkdir -p $(dirname $dest)
-
-html_replace_tokens () {
- local url=$1
- sed "s|@NAME@|$name|g" \
- | sed "s|@DATE@|$date|g" \
- | sed "s|@URL@|$url|g" \
- | sed "s|@VERSION@|$version|g" \
- | perl -p -e 's/<h1([^>]*)>([^\(]*\([0-9]\)) -- (.*?)<\/h1>/<h1>\2<\/h1> <p>\3<\/p>/g' \
- | perl -p -e 's/npm-npm/npm/g' \
- | perl -p -e 's/([^"-])(npm-)?README(?!\.html)(\(1\))?/\1<a href="..\/..\/doc\/README.html">README<\/a>/g' \
- | perl -p -e 's/<title><a href="[^"]+README.html">README<\/a><\/title>/<title>README<\/title>/g' \
- | perl -p -e 's/([^"-])([^\(> ]+)(\(1\))/\1<a href="..\/cli\/\2.html">\2\3<\/a>/g' \
- | perl -p -e 's/([^"-])([^\(> ]+)(\(3\))/\1<a href="..\/api\/\2.html">\2\3<\/a>/g' \
- | perl -p -e 's/([^"-])([^\(> ]+)(\(5\))/\1<a href="..\/files\/\2.html">\2\3<\/a>/g' \
- | perl -p -e 's/([^"-])([^\(> ]+)(\(7\))/\1<a href="..\/misc\/\2.html">\2\3<\/a>/g' \
- | perl -p -e 's/\([1357]\)<\/a><\/h1>/<\/a><\/h1>/g' \
- | (if [ $(basename $(dirname $dest)) == "doc" ]; then
- perl -p -e 's/ href="\.\.\// href="/g'
- else
- cat
- fi)
-}
-
-man_replace_tokens () {
- sed "s|@VERSION@|$version|g" \
- | perl -p -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(1\)/npm help \2/g' \
- | perl -p -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(([57])\)/npm help \3 \2/g' \
- | perl -p -e 's/(npm\\-)?([a-zA-Z\\\.\-]*)\(3\)/npm apihelp \2/g' \
- | perl -p -e 's/npm\(1\)/npm help npm/g' \
- | perl -p -e 's/npm\(3\)/npm apihelp npm/g'
-}
-
-case $dest in
- *.[1357])
- ./node_modules/.bin/marked-man --roff $src \
- | man_replace_tokens > $dest
- exit $?
- ;;
- *.html)
- url=${dest/html\//}
- (cat html/dochead.html && \
- cat $src | ./node_modules/.bin/marked &&
- cat html/docfoot.html)\
- | html_replace_tokens $url \
- > $dest
- exit $?
- ;;
- *)
- echo "Invalid destination type: $dest" >&2
- exit 1
- ;;
-esac
diff --git a/deps/npm/scripts/docs-build.js b/deps/npm/scripts/docs-build.js
new file mode 100644
index 0000000000..f6b87ae9d0
--- /dev/null
+++ b/deps/npm/scripts/docs-build.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+
+var fs = require('fs')
+var marked = require('marked-man')
+var npm = require('../lib/npm.js')
+var args = process.argv.slice(2)
+var src = args[0]
+var dest = args[1] || src
+
+fs.readFile(src, 'utf8', function (err, data) {
+ if (err) return console.log(err)
+
+ var result = data.replace(/@VERSION@/g, npm.version)
+ .replace(/---([\s\S]+)---/g, '')
+ .replace(/(npm-)?([a-zA-Z\\.-]*)\(1\)/g, 'npm help $2')
+ .replace(/(npm-)?([a-zA-Z\\.-]*)\((5|7)\)/g, 'npm help $2')
+ .replace(/npm(1)/g, 'npm help npm')
+ .replace(/\[([^\]]+)\]\(\/cli-commands\/([^)]+)\)/g, 'npm help $2')
+ .replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, 'npm help $2')
+ .replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, 'npm help $2')
+ .trim()
+
+ fs.writeFile(dest, marked(result), 'utf8', function (err) {
+ if (err) return console.log(err)
+ })
+})
diff --git a/deps/npm/scripts/index-build.js b/deps/npm/scripts/index-build.js
deleted file mode 100755
index e782716d77..0000000000
--- a/deps/npm/scripts/index-build.js
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env node
-var fs = require('fs')
-var path = require('path')
-var root = path.resolve(__dirname, '..')
-var glob = require('glob')
-var conversion = { 'cli': 1, 'api': 3, 'files': 5, 'misc': 7 }
-
-glob(root + '/{README.md,doc/*/*.md}', function (er, files) {
- if (er) throw er
-
- output(files.map(function (f) {
- var b = path.basename(f)
- if (b === 'README.md') return [0, b]
- if (b === 'index.md') return null
- var s = conversion[path.basename(path.dirname(f))]
- return [s, f]
- }).filter(function (f) {
- return f
- }).sort(function (a, b) {
- return (a[0] === b[0])
- ? (path.basename(a[1]) === 'npm.md' ? -1
- : path.basename(b[1]) === 'npm.md' ? 1
- : a[1] > b[1] ? 1 : -1)
- : a[0] - b[0]
- }))
-})
-
-function output (files) {
- console.log(
- 'npm-index(7) -- Index of all npm documentation\n' +
- '==============================================\n')
-
- writeLines(files, 0)
- writeLines(files, 1, 'Command Line Documentation', 'Using npm on the command line')
- writeLines(files, 3, 'API Documentation', 'Using npm in your Node programs')
- writeLines(files, 5, 'Files', 'File system structures npm uses')
- writeLines(files, 7, 'Misc', 'Various other bits and bobs')
-}
-
-function writeLines (files, sxn, heading, desc) {
- if (heading) {
- console.log('## %s\n\n%s\n', heading, desc)
- }
- files.filter(function (f) {
- return f[0] === sxn
- }).forEach(writeLine)
-}
-
-function writeLine (sd) {
- var sxn = sd[0] || 1
- var doc = sd[1]
- var d = path.basename(doc, '.md')
-
- var content = fs.readFileSync(doc, 'utf8').split('\n')[0].split('-- ')[1]
-
- console.log('### %s(%d)\n', d, sxn)
- console.log(content + '\n')
-}