diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..d76e8e5 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,34 @@ +on: + push: + branches: + - 'main' + paths: + - 'lib/**' + - 'demo/**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + all_but_latest: true + access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v2 + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: '20.x.x' + - name: Setup PNPM + uses: pnpm/action-setup@v2 + with: + version: 'latest' + run_install: | + - recursive: true + args: [--frozen-lockfile, --strict-peer-dependencies] + - name: Build + run: bash -x build_docs.sh + + diff --git a/build_docs.sh b/build_docs.sh new file mode 100644 index 0000000..5c74e59 --- /dev/null +++ b/build_docs.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env sh + +# This file is used to build and deploy the docs to the dist branch + +DIST_BRANCH="dist" +BASE_DIR="/home/runner/work/htmlmark" + +git stash && git stash clear + +echo "Building Started...." +cd demo || exit +pnpm build +cd .. || exit +echo "Building Completed." + + +echo "Deploying Started...." +mkdir -p "${BASE_DIR}""/temp" +mv docs "${BASE_DIR}""/temp" +rm -rf docs + +git fetch origin ${DIST_BRANCH} +git checkout ${DIST_BRANCH} + +cp -r "${BASE_DIR}"/temp/docs/* . + +curr_date=$(date) + +if [ -n "$(git status --porcelain)" ]; then + git add . + git -c user.name="Kiran Parajuli" \ + -c user.email="kiranparajuli589@gmail.com" \ + commit -m "Update the build code @ ""${curr_date}" + git push origin ${DIST_BRANCH} +fi + +rm -rf "${BASE_DIR}""/temp" +echo "Deploying Docs Has Completed!" diff --git a/lib/parser/index.js b/lib/parser/index.js index b3d1b99..e2f1feb 100644 --- a/lib/parser/index.js +++ b/lib/parser/index.js @@ -1,5 +1,5 @@ import { Parsers } from "../tokenizer/index.js" -import TOKENS from "../util/index.js" +import { TOKENS } from "../util/index.js" class Parser { diff --git a/rollup.config.js b/rollup.config.js index 6e769bd..456a891 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,20 +1,22 @@ -import { defineConfig } from "rollup" import fs from "fs" +import { defineConfig } from "rollup" + +const packageJsonContent = fs.readFileSync("./package.json").toString() -const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(fs.readFileSync("./package.json")).version +const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(packageJsonContent).version -console.info("building version:", version) +console.info("Building version:", version) const banner = `/** - * MDParser v${version} - a markdown parser + * HtmlMark v${version} - a markdown parser * Copyright (c) 2020-${new Date().getFullYear()}, Kiran Parajuli. (GNU Licensed) * https://github.com/kiranparajuli589/htmlmark */ /** * DO NOT EDIT THIS FILE - * The code in this file is generated from files in ./lib/ + * The code in this file is generated from files in ./lib/index.js */ ` diff --git a/scripts/build_demo.sh b/scripts/build_demo.sh deleted file mode 100644 index 9b184c7..0000000 --- a/scripts/build_demo.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -rm -rf docs/ -cd demo || exit -pnpm build