Skip to content

Commit

Permalink
chore(docs): fix docs building process
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiahdz committed Nov 5, 2019
1 parent 11a339c commit 88b37d6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
54 changes: 31 additions & 23 deletions Makefile
Expand Up @@ -22,7 +22,7 @@ misc_mandocs = $(shell find docs/content/using-npm -name '*.md' \

mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs)

all: doc
all: docs

latest:
@echo "Installing latest published npm"
Expand All @@ -39,57 +39,69 @@ dev: install
link: uninstall
node bin/npm-cli.js link -f

clean: markedclean marked-manclean doc-clean
clean: markedclean marked-manclean docs-clean
rm -rf npmrc
node bin/npm-cli.js cache clean --force

uninstall:
node bin/npm-cli.js rm npm -g -f

doc: $(mandocs)
mandocs: $(mandocs)

htmldocs:
cd docs && node ../bin/npm-cli.js install && \
node ../bin/npm-cli.js run build:static echo>&2 && \
rm -rf node_modules .cache public/*js public/*json public/404* public/page-data public/manifest*
find docs/public -name '*.html' -exec \
node scripts/docs-build.js {} \;

docs: mandocs htmldocs

markedclean:
rm -rf node_modules/marked node_modules/.bin/marked .building_marked

marked-manclean:
rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man

docclean: doc-clean
doc-clean:
docsclean: docs-clean
docs-clean:
rm -rf \
.building_marked \
.building_marked-man \
man
man \
docs/node_modules \
docs/public \
docs/.cache

## build-time tools for the documentation
build-doc-tools := node_modules/.bin/marked \
node_modules/.bin/marked-man

# use `npm install marked-man` for this to work.
man/man1/npm-README.1: README.md scripts/doc-build.sh package.json $(build-doc-tools)
man/man1/npm-README.1: README.md scripts/docs-build.js package.json $(build-doc-tools)
@[ -d man/man1 ] || mkdir -p man/man1
scripts/doc-build.sh $< $@
node scripts/docs-build.js $< $@

man/man1/%.1: docs/content/cli-commands/%.md scripts/doc-build.sh package.json $(build-doc-tools)
man/man1/%.1: docs/content/cli-commands/%.md scripts/docs-build.js package.json $(build-doc-tools)
@[ -d man/man1 ] || mkdir -p man/man1
scripts/doc-build.sh $< $@
node scripts/docs-build.js $< $@

man/man1/npx.1: node_modules/libnpx/libnpx.1
cat $< | sed s/libnpx/npx/ > $@

man/man5/npm-json.5: man/man5/package.json.5
cp $< $@

man/man5/npm-global.5: man/man5/folders.5
man/man5/npm-global.5: man/man5/foslders.5
cp $< $@

man/man5/%.5: docs/content/configuring-npm/%.md scripts/doc-build.sh package.json $(build-doc-tools)
man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js package.json $(build-doc-tools)
@[ -d man/man5 ] || mkdir -p man/man5
scripts/doc-build.sh $< $@
node scripts/docs-build.js $< $@

man/man7/%.7: docs/content/using-npm/%.md scripts/doc-build.sh package.json $(build-doc-tools)
man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js package.json $(build-doc-tools)
@[ -d man/man7 ] || mkdir -p man/man7
scripts/doc-build.sh $< $@
node scripts/docs-build.js $< $@

marked: node_modules/.bin/marked

Expand All @@ -101,11 +113,7 @@ marked-man: node_modules/.bin/marked-man
node_modules/.bin/marked-man:
node bin/npm-cli.js install marked-man --no-global --no-timing --no-save

doc: man

man: $(cli_docs)

test: doc
test: docs
node bin/npm-cli.js test

tag:
Expand All @@ -117,17 +125,17 @@ ls-ok:
gitclean:
git clean -fd

publish: gitclean ls-ok link doc-clean doc
publish: gitclean ls-ok link docs-clean docs
@git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true
git push origin $(BRANCH) &&\
git push origin --tags &&\
node bin/npm-cli.js publish --tag=$(PUBLISHTAG)

release: gitclean ls-ok markedclean marked-manclean doc-clean doc
release: gitclean ls-ok markedclean marked-manclean docs-clean doc
node bin/npm-cli.js prune --production --no-save
@bash scripts/release.sh

sandwich:
@[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13)

.PHONY: all latest install dev link doc clean uninstall test man doc-clean docclean release ls-ok realclean
.PHONY: all latest install dev link doc clean uninstall test man docs-clean docclean release ls-ok realclean
8 changes: 5 additions & 3 deletions docs/package.json
Expand Up @@ -3,6 +3,11 @@
"description": "npm cli docs",
"version": "0.1.0",
"author": "Tanya Brassie <tanyabrassie@tanyascmachine2.home>",
"license": "Artistic-2.0",
"repository": {
"type": "git",
"url": "https://github.com/npm/cli"
},
"dependencies": {
"babel-plugin-styled-components": "^1.10.6",
"eslint": "^6.3.0",
Expand Down Expand Up @@ -33,10 +38,7 @@
"develop": "gatsby develop",
"start": "npm run develop",
"build": "gatsby build",
"build:clean": "rm -rf node_modules .cache public/*js public/*json public/404* public/page-data public/manifest*",
"prebuild:static": "rm -rf public && npm i",
"build:static": "GATSBY_IS_STATIC=true gatsby build --prefix-paths",
"postbuild:static": "npm run build:clean",
"serve": "gatsby serve"
}
}
6 changes: 1 addition & 5 deletions package.json
Expand Up @@ -290,12 +290,8 @@
"tar-stream": "^2.1.0"
},
"scripts": {
"docs:man": "make -j4 doc",
"docs:html": "cd docs && npm run build:static",
"docs:create": "npm run docs:man && npm run docs:html",
"dumpconf": "env | grep npm | sort | uniq",
"prepublishOnly": "npm run docs:html",
"prepare": "node bin/npm-cli.js rebuild && node bin/npm-cli.js --no-audit --no-timing prune --prefix=. --no-global && rimraf test/*/*/node_modules && npm run docs:man",
"prepare": "node bin/npm-cli.js rebuild && node bin/npm-cli.js --no-audit --no-timing prune --prefix=. --no-global && rimraf test/*/*/node_modules && make -j4 mandocs",
"preversion": "bash scripts/update-authors.sh && git add AUTHORS && git commit -m \"update AUTHORS\" || true",
"licenses": "licensee --production --errors-only",
"tap": "tap -J --timeout 300 --no-esm",
Expand Down

0 comments on commit 88b37d6

Please sign in to comment.