Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: drop old interface and fix test code #58

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .directory

This file was deleted.

21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"root": true,
"env": {
"commonjs": true,
"es2021": true,
"node": true
},
"parserOptions": {
"ecmaVersion": "latest"
},
"extends": ["hexo"],
"overrides": [
{
"files": ["test/**"],
"extends": ["hexo", "hexo/test"]
}
],
"rules": {
"linebreak-style": ["error", "unix"]
}
}
48 changes: 48 additions & 0 deletions .github/workflows/install-pandoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

const { exec } = require('node:child_process');

const platform = process.env.runner_os;
let cmdStr = '';

const installPandoc = cmdStr => {
exec(
cmdStr.trim(),
{
cwd: process.cwd(),
env: process.env,
encoding: 'utf8',
timeout: 300000
},
(error, stdout, stderr) => {
console.log(`install stdout: ${stdout}`);
console.error(`install stderr: ${stderr}`);
if (error) {
console.error(`install error: ${error}`);
throw Error(`install error: ${error}`);
}
}
);
};

switch (String(platform).trim().toLowerCase()) {
case 'linux':
console.info(`Install pandoc for ${platform}`);
cmdStr = 'sudo apt install pandoc -y';
installPandoc(cmdStr);
break;
case 'windows':
console.info(`Install pandoc for ${platform}`);
cmdStr
= 'choco install -y --no-progress --timeout 270 pandoc';
installPandoc(cmdStr);
break;
case 'macos':
console.info(`Install pandoc for ${platform}`);
cmdStr = 'brew install pandoc';
installPandoc(cmdStr);
break;
default:
console.error(`Unsupport platform: ${platform}`);
throw Error(`Unsupport platform: ${platform}`);
}
46 changes: 46 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: linter

on:
push:
branches: ["master"]
paths:
- "lib/**"
- "test/**"
- ".github/workflows/linter.yml"
pull_request:
paths:
- "lib/**"
- "test/**"
- ".github/workflows/linter.yml"

env:
CI: true

jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "lts/*"

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install Dependencies
run: npm i

- name: Test
run: npm run lint
101 changes: 101 additions & 0 deletions .github/workflows/tester.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: tester

on:
push:
branches: ["master"]
paths:
- "lib/**"
- "test/**"
- "package.json"
- ".github/workflows/tester.yml"
pull_request:
paths:
- "lib/**"
- "test/**"
- "package.json"
- ".github/workflows/tester.yml"

env:
CI: true

jobs:
tester:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14, 16, 18]
fail-fast: false

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pandoc
env:
runner_os: ${{runner.os}}
run: node .github/workflows/install-pandoc.js

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install Dependencies
run: npm i

- name: Test
run: npm run test

coverage:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: ["lts/*"]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pandoc
env:
runner_os: ${{runner.os}}
run: node .github/workflows/install-pandoc.js

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install Dependencies
run: npm i

- name: Test
run: npm run test-cov

- uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
127 changes: 6 additions & 121 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Vim files
*.swo
*.swp

# Created by https://www.toptal.com/developers/gitignore/api/node,webstorm
# Edit at https://www.toptal.com/developers/gitignore?templates=node,webstorm
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# Logs
Expand Down Expand Up @@ -145,118 +141,7 @@ dist
# SvelteKit build / generate output
.svelte-kit

### WebStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### WebStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml

# End of https://www.toptal.com/developers/gitignore/api/node,webstorm
# End of https://www.toptal.com/developers/gitignore/api/node

.idea
.vscode
5 changes: 0 additions & 5 deletions .idea/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/hexo-renderer-pandoc.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

Loading