From 8d6461d7e05293bf3bf390c010f2ce76a92dda67 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Tue, 19 May 2020 22:40:30 +0300 Subject: [PATCH] Use npm script to build & publish demo --- Makefile | 35 +++++------------------------------ package.json | 4 +++- support/build_demo.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 31 deletions(-) create mode 100644 support/build_demo.js diff --git a/Makefile b/Makefile index ef0902a..7dfa01e 100644 --- a/Makefile +++ b/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 diff --git a/package.json b/package.json index 444f562..eddf7ba 100644 --- a/package.json +++ b/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", diff --git a/support/build_demo.js b/support/build_demo.js new file mode 100644 index 0000000..96ebfbe --- /dev/null +++ b/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/');