Browse Source

Use npm script to build & publish demo

pull/682/head
Vitaly Puzrin 4 years ago
parent
commit
8d6461d7e0
  1. 35
      Makefile
  2. 4
      package.json
  3. 29
      support/build_demo.js

35
Makefile

@ -3,39 +3,14 @@ PATH := ./node_modules/.bin:${PATH}
NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
REMOTE_NAME ?= origin
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut -b -6) master)
GITHUB_PROJ := https://github.com//markdown-it/${NPM_PACKAGE}
demo: lint
rm -rf ./demo
mkdir ./demo
./support/demodata.js > ./support/demo_template/sample.json
pug ./support/demo_template/index.pug --pretty \
--obj ./support/demo_template/sample.json \
--out ./demo
stylus -u autoprefixer-stylus \
< ./support/demo_template/index.styl \
> ./demo/index.css
rm -rf ./support/demo_template/sample.json
browserify ./ -s markdownit > ./demo/markdown-it.js
browserify ./support/demo_template/index.js > ./demo/index.js
cp ./support/demo_template/README.md ./demo/
gh-demo: demo
touch ./demo/.nojekyll
cd ./demo \
&& git init . \
&& git add . \
&& git commit -m "Auto-generate demo" \
&& git remote add origin git@github.com:markdown-it/markdown-it.github.io.git \
&& git push --force origin master
rm -rf ./demo
demo:
npm run demo
gh-demo:
npm run gh-demo
lint:
npm run lint

4
package.json

@ -21,7 +21,9 @@
"coverage": "npm run test && nyc report --reporter html",
"report-coveralls": "nyc report --reporter=text-lcov | coveralls",
"doc": "node support/build_doc.js",
"gh-doc": "npm run doc && gh-pages -d apidoc -f"
"gh-doc": "npm run doc && gh-pages -d apidoc -f",
"demo": "npm run lint && node support/build_demo.js",
"gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git"
},
"files": [
"index.js",

29
support/build_demo.js

@ -0,0 +1,29 @@
#!/usr/bin/env node
'use strict';
/* eslint-env es6 */
const shell = require('shelljs');
shell.rm('-rf', 'demo');
shell.mkdir('demo');
shell.exec('support/demodata.js > support/demo_template/sample.json');
shell.exec('node_modules/.bin/pug support/demo_template/index.pug --pretty \
--obj support/demo_template/sample.json \
--out demo');
shell.exec('node_modules/.bin/stylus -u autoprefixer-stylus \
< support/demo_template/index.styl \
> demo/index.css');
shell.rm('-rf', 'support/demo_template/sample.json');
shell.exec('node_modules/.bin/browserify ./ -s markdownit \
> demo/markdown-it.js');
shell.exec('node_modules/.bin/browserify support/demo_template/index.js \
> demo/index.js');
shell.cp('support/demo_template/README.md', 'demo/');
Loading…
Cancel
Save