Skip to content

Commit

Permalink
Merge pull request #6 from MicroAppJS/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zyao89 committed Dec 31, 2019
2 parents 75979af + 8c94e63 commit f9006bd
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 37 deletions.
24 changes: 0 additions & 24 deletions .circleci/config.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Coveralls
on:
pull_request:
branches:
- master
- develop
push:
branches:
- master
- develop
jobs:
install-and-coveralls:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@master

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: install
run: yarn --network-timeout 600000

- name: yarn add coveralls
run: |
yarn add -D coveralls
yarn run test --coverage && cat ./coverage/lcov.info
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GitHub Actions Build and Deploy
name: Build and Deploy
on:
push:
branches:
Expand All @@ -13,6 +13,7 @@ jobs:
- name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@master
env:
GAID: ${{ secrets.GAID }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/.vuepress/dist
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

适配集成 vuepress 配置. 用于 `@micro-app/cli` 的插件.

[![Github Actions Coveralls][Github-Actions-Coveralls]][Github-Actions-Coveralls-url]
[![Coverage Status][Coverage-img]][Coverage-url]
[![CircleCI][CircleCI-img]][CircleCI-url]
[![NPM Version][npm-img]][npm-url]
[![NPM Download][download-img]][download-url]

[Github-Actions-Coveralls]: https://github.com/MicroAppJS/plugin-vuepress/workflows/Coveralls/badge.svg
[Github-Actions-Coveralls-url]: https://github.com/MicroAppJS/plugin-vuepress
[Coverage-img]: https://coveralls.io/repos/github/MicroAppJS/plugin-vuepress/badge.svg?branch=master
[Coverage-url]: https://coveralls.io/github/MicroAppJS/plugin-vuepress?branch=master
[CircleCI-img]: https://circleci.com/gh/MicroAppJS/plugin-vuepress/tree/master.svg?style=svg
[CircleCI-url]: https://circleci.com/gh/MicroAppJS/plugin-vuepress/tree/master
[npm-img]: https://img.shields.io/npm/v/@micro-app/plugin-vuepress.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@micro-app/plugin-vuepress
[download-img]: https://img.shields.io/npm/dm/@micro-app/plugin-vuepress.svg?style=flat-square
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/config/blog/blog-config.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 专属配置
# 高级配置

博客专属配置,只适用于博客类型的配置。
博客高级配置,只适用于博客类型的配置。

## Usage

Expand Down
2 changes: 2 additions & 0 deletions micro-app.vuepress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ module.exports = {
},
],

GAID: process.env.GAID || false,

deploy: {
repo: 'git@github.com:MicroAppJS/plugin-vuepress.git',
branch: 'gh-pages',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@micro-app/cli": "^0.3.0-alpha.2",
"@types/jest": "^24.0.24",
"babel-eslint": "^10.0.3",
"coveralls": "^3.0.9",
"eslint": "^5.16.0",
"eslint-config-2o3t": "^1.1.17",
"jest": "^24.9.0"
Expand Down
10 changes: 7 additions & 3 deletions src/commands/deploy/github.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

module.exports = function(api, argv, opts) {
// TODO 增加部署 github 脚本
// 增加部署 github 脚本
// https://github.com/marketplace/actions/deploy-to-github-pages
// https://github.com/JamesIves/github-pages-deploy-action/blob/dev/src/constants.ts
const logger = api.logger;

// logger.info('[VuePress > Deploy > Github]', '我正在努力实现!💪');
Expand All @@ -19,8 +21,10 @@ module.exports = function(api, argv, opts) {
logger.throw('[VuePress > Deploy > Github]', 'deploy.repo must be string!');
}

const token = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN || 'git';

if (repo && !repo.includes(':')) {
repo = `git@github.com:${repo}.git`;
repo = `${token}@github.com:${repo}.git`;
}

const path = require('path');
Expand Down Expand Up @@ -94,7 +98,7 @@ module.exports = function(api, argv, opts) {
// # if you are deploying to https://<USERNAME>.github.io/<REPO>
// # git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages

let branch = deployOpts.branch || 'gh-pages';
let branch = deployOpts.branch || process.env.BRANCH || 'gh-pages';
if (branch && branch !== 'master') {
branch = `master:${branch}`;
}
Expand Down
14 changes: 11 additions & 3 deletions theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (options, ctx) => {
? themeConfig.summaryLength
: 200,
pwa: themeConfig.pwa !== false,
redirect: themeConfig.redirect !== false,
redirect: themeConfig.redirect === undefined ? true : themeConfig.redirect,
});

const vuepressDir = ctx.vuepressDir;
Expand Down Expand Up @@ -132,13 +132,21 @@ function registerPlugins(plugins, ctx) {
}
if (isLocales) {
if (themeConfig.redirect) {
plugins.push([ 'redirect', {
const redirectOpts = themeConfig.redirect === true ? {
// 提供多语言重定向功能
// 它会自动从 `/foo/bar/` 定向到 `/:locale/foo/bar/`,如果对应的页面存在
locales: true,
}]);
} : themeConfig.redirect;
plugins.push([ 'redirect', redirectOpts ]);
}
}

const GAID = themeConfig.GAID;
if (GAID && typeof GAID === 'string') {
plugins.push([ '@vuepress/google-analytics', {
ga: GAID, // UA-00000000-0 项目生成后生成的 ID 值
}]);
}
plugins.push('@vuepress/medium-zoom');
plugins.push('@vuepress/back-to-top');
// 流程图
Expand Down

0 comments on commit f9006bd

Please sign in to comment.