Skip to content

Commit 76f0193

Browse files
committed
feat(dev): add gulp tasks
1 parent e3962b0 commit 76f0193

21 files changed

+231
-69
lines changed

.babelrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"es2015"
4+
],
5+
"plugins": [
6+
[ "babel-root-import" ]
7+
]
8+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc

-8
This file was deleted.

.eslintrc.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
env:
2+
node: true
3+
extends: 'vue'
4+
rules:
5+
indent:
6+
- warn
7+
- 2
8+
quotes:
9+
- error
10+
- single
11+
semi:
12+
- error
13+
- never
14+
no-unused-vars:
15+
- off

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
node_modules
2-
yarn.lock
3-
*.log
1+
*.log
2+
.DS_Store
3+
.vscode/
4+
node_modules/

.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.eslintrc
33
.gitignore
44
.travis.yml
5+
tools/gulp-tasks/
6+
gulpfile.babel.js

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stable

.travis.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@ node_js: stable
44
os:
55
- linux
66
- osx
7+
cache:
8+
directories:
9+
- ./node_modules
710
install:
8-
- npm install --no-optional
11+
- npm install
12+
- npm install -g gulp
13+
script:
14+
- gulp lint

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<a name="3.2.5"></a>
2+
## [3.2.5](https://github.com/QingWei-Li/docsify-cli/compare/v3.2.4...v3.2.5) (2017-03-23)
3+
4+
...

bin/docsify

+5-16
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ const updateNotifier = require('update-notifier')
99

1010
updateNotifier({ pkg: pkg }).notify()
1111

12-
const Locales = require('./locales')
12+
const Locales = require('../tools/locales')
1313
const y18n = new Locales()
1414

1515
require('yargonaut')
1616
.style('yellow', 'required')
1717
.helpStyle('green')
1818
.errorsStyle('red.bold')
1919

20-
var argv = require('yargs')
20+
var yargs = require('yargs')
2121
.usage(chalk.bold(y18n.__('usage') + ': docsify <init|serve> <path> [options]'))
2222
.command({
2323
command: 'init <path> [--local false] [--theme vue]',
2424
alias: 'i',
2525
desc: chalk.gray(y18n.__('init')),
26-
builder: (argv) => argv.options({
26+
builder: (yargs) => yargs.options({
2727
'local': {
2828
alias: 'l',
2929
default: false,
@@ -48,7 +48,7 @@ var argv = require('yargs')
4848
command: 'serve <path> [--open false] [--port 3000]',
4949
alias: 's',
5050
desc: chalk.gray(y18n.__('serve')),
51-
builder: (argv) => argv.options({
51+
builder: (yargs) => yargs.options({
5252
'open': {
5353
alias: 'o',
5454
default: false,
@@ -68,15 +68,6 @@ var argv = require('yargs')
6868
}),
6969
handler: (argv) => run.serve(argv.path, argv.open, argv.port)
7070
})
71-
.command({
72-
command: 'completion',
73-
alias: 'c',
74-
desc: chalk.gray(y18n.__('completion')),
75-
builder: {},
76-
handler: (argv) => {
77-
argv.showCompletionScript()
78-
}
79-
})
8071
.help()
8172
.option('help', {
8273
alias: 'h',
@@ -91,7 +82,5 @@ var argv = require('yargs')
9182
desc: chalk.gray(y18n.__('version')),
9283
group: chalk.green(y18n.__('group.globaloptions'))
9384
})
94-
.epilog(chalk.green(y18n.__('epilog')) + ':\n' +
95-
' https://QingWei-Li.github.io/docsify\n' +
96-
' https://QingWei-Li.github.io/docsify-cli\n')
85+
.epilog(chalk.gray(y18n.__('epilog')))
9786
.argv

bin/locales/en.json

-14
This file was deleted.

gulpfile.babel.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const gulp = require('gulp-help')(require('gulp'))
2+
const gulpStats = require('gulp-stats')
3+
4+
const Locales = require('./tools/locales')
5+
const y18n = new Locales()
6+
7+
gulpStats(gulp)
8+
9+
function loadTask(fileName, taskName) {
10+
const taskModule = require('./tools/gulp-tasks/' + fileName)
11+
const task = taskName ? taskModule[taskName] : taskModule
12+
return task(gulp)
13+
}
14+
15+
// hide this from 'gulp-help' as this is a helper for the gulp task 'bump'
16+
gulp.task('bump:pkg-version', false, [], loadTask('bump', 'bumpPkgVersion'), {})
17+
18+
gulp.task('bump',
19+
y18n.__('gulp.bump'),
20+
[],
21+
loadTask('bump', 'bump'),
22+
{
23+
aliases: ['b', 'B'],
24+
options: {
25+
'major': y18n.__('gulp.bump.major'),
26+
'minor': y18n.__('gulp.bump.minor'),
27+
'patch': y18n.__('gulp.bump.patch'),
28+
'prerelease': y18n.__('gulp.bump.prerelease')
29+
}
30+
})
31+
32+
gulp.task('changelog',
33+
y18n.__('gulp.changelog'),
34+
[],
35+
loadTask('changelog', 'conventional'),
36+
{ aliases: ['c', 'C'] })
37+
38+
gulp.task('lint',
39+
y18n.__('gulp.lint'),
40+
[],
41+
loadTask('lint', 'eslint'),
42+
{ aliases: ['l', 'L'] })
43+
44+
gulp.task('release',
45+
y18n.__('gulp.release'),
46+
[],
47+
loadTask('release', 'github'),
48+
{ aliases: ['r', 'R'] })

package.json

+38-18
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,66 @@
22
"name": "docsify-cli",
33
"version": "3.2.5",
44
"description": "A magical documentation generator.",
5-
"author": "qingwei-li <[email protected]> (https://github.com/QingWei-Li)",
5+
"author": {
6+
"name": "qingwei-li",
7+
"email": "[email protected]",
8+
"url": "https://github.com/QingWei-Li"
9+
},
610
"homepage": "https://github.com/QingWei-Li/docsify-cli#readme",
711
"repository": {
812
"type": "git",
913
"url": "git+https://github.com/QingWei-Li/docsify-cli.git"
1014
},
1115
"license": "MIT",
1216
"engines": {
13-
"node": ">= 4"
17+
"node": ">= 6",
18+
"npm": ">= 4"
1419
},
1520
"main": "bin/docsify",
1621
"bin": {
1722
"docsify": "bin/docsify"
1823
},
1924
"files": [
2025
"bin",
21-
"lib"
26+
"lib",
27+
"tools/locales"
2228
],
23-
"scripts": {
24-
"test": "eslint lib bin/docsify --fix"
25-
},
2629
"dependencies": {
27-
"chalk": "^1.1.0",
28-
"connect": "^3.5.0",
30+
"chalk": "^1.1.3",
31+
"connect": "^3.6.0",
2932
"connect-livereload": "^0.6.0",
30-
"cp-file": "^4.1.0",
31-
"docsify": ">=2",
32-
"fs-extra": "^2.0.0",
33-
"livereload": "^0.6.0",
33+
"cp-file": "^4.1.1",
34+
"docsify": ">=3",
35+
"fs-extra": "^2.1.2",
36+
"livereload": "^0.6.2",
3437
"open": "^0.0.5",
35-
"serve-static": "^1.11.1",
36-
"update-notifier": "^1.0.3",
38+
"serve-static": "^1.12.1",
39+
"update-notifier": "^2.1.0",
3740
"y18n": "^3.2.1",
3841
"yargonaut": "^1.1.2",
39-
"yargs": "^6.4.0"
42+
"yargs": "^7.0.2"
4043
},
4144
"devDependencies": {
42-
"eslint": "^3.10.2",
43-
"eslint-config-vue": "^2.0.1",
44-
"eslint-plugin-vue": "^1.0.0"
45+
"babel-core": "^6.18.2",
46+
"babel-preset-es2015": "^6.18.0",
47+
"babel-root-import": "^4.1.3",
48+
"chalk": "^1.1.3",
49+
"conventional-github-releaser": "^1.1.2",
50+
"cors": "^2.8.1",
51+
"eslint": "^3.18.0",
52+
"eslint-config-vue": "^2.0.2",
53+
"eslint-plugin-vue": "^2.0.1",
54+
"gulp": "^3.9.1",
55+
"gulp-bump": "^2.4.0",
56+
"gulp-connect": "^5.0.0",
57+
"gulp-conventional-changelog": "^1.1.0",
58+
"gulp-eslint": "^3.0.1",
59+
"gulp-help": "^1.6.1",
60+
"gulp-if": "^2.0.1",
61+
"gulp-load-plugins": "^1.3.0",
62+
"gulp-stats": "^0.0.4",
63+
"run-sequence": "^1.2.2",
64+
"yargs": "^7.0.2"
4565
},
4666
"keywords": [
4767
"docsify",

tools/gulp-tasks/bump.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
bump: (gulp) => (cb) => {
3+
const runSequence = require('run-sequence')
4+
const chalk = require('chalk')
5+
runSequence(
6+
'bump:pkg-version',
7+
(error) => {
8+
if (error) {
9+
console.log(chalk.magenta.bold('\n[bump]') + chalk.red.bold(' There was an issue bumping version:\n') + error.message)
10+
}
11+
cb(error)
12+
}
13+
)
14+
},
15+
bumpPkgVersion: (gulp) => () => {
16+
const $ = require('gulp-load-plugins')()
17+
const argv = require('yargs').argv
18+
return gulp.src('./package.json')
19+
.pipe($.if((Object.keys(argv).length === 2), $.bump()))
20+
.pipe($.if(argv.patch, $.bump()))
21+
.pipe($.if(argv.minor, $.bump({ type: 'minor' })))
22+
.pipe($.if(argv.major, $.bump({ type: 'major' })))
23+
.pipe($.if(argv.prerelease, $.bump({ type: 'prerelease' })))
24+
.pipe(gulp.dest('./'))
25+
}
26+
}

tools/gulp-tasks/changelog.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
conventional: (gulp) => () => {
3+
const conventionalChangelog = require('gulp-conventional-changelog')
4+
return gulp.src('./CHANGELOG.md')
5+
.pipe(conventionalChangelog({
6+
preset: 'angular',
7+
releaseCount: 0
8+
}))
9+
.pipe(gulp.dest('./'))
10+
}
11+
}

tools/gulp-tasks/lint.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
eslint: (gulp) => () => {
3+
const $ = require('gulp-load-plugins')()
4+
return gulp.src(['./lib/', './bin/docsify'])
5+
.pipe($.eslint())
6+
.pipe($.eslint.format())
7+
.pipe($.eslint.failAfterError())
8+
}
9+
}

tools/gulp-tasks/release.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
github: (gulp) => (done) => {
3+
const conventionalGithubReleaser = require('conventional-github-releaser')
4+
conventionalGithubReleaser({
5+
type: 'oauth',
6+
token: process.env.CONVENTIONAL_GITHUB_RELEASER_TOKEN
7+
}, {
8+
preset: 'angular'
9+
}, done)
10+
}
11+
}

bin/locales/de.json tools/locales/de.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
2-
"completion": "Drucke shell Vervollständigungsskript",
3-
"epilog": "Dokumentation",
42
"group.globaloptions": "Globale Optionen",
3+
"gulp.bump": "Erhöhe die SemVer patch des Pakets.",
4+
"gulp.bump.major": "Erhöhe die SemVer major des Pakets.",
5+
"gulp.bump.minor": "Erhöhe die SemVer minor des Pakets.",
6+
"gulp.bump.patch": "Erhöhe die SemVer patch des Pakets.",
7+
"gulp.bump.prerelease": "Erhöhe die SemVer prerelease des Pakets.",
8+
"gulp.changelog": "Generiere den CHANGELOG.",
9+
"gulp.lint": "Führe eslint aus.",
10+
"gulp.release": "Veröffentliche auf Github.",
511
"help": "Zeige Hilfe an",
612
"init": "Erzeuge neue Dokumentation.",
713
"init.local": "Kopiere docsify Dateien in lokale Ordner. Um explizit --local auf false zu setzen, kannst du --no-local verwenden.",

tools/locales/en.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"epilog": "Documentation\n\thttps://QingWei-Li.github.io/docsify\n\thttps://QingWei-Li.github.io/docsify-cli\n\nDevelopment:\n\t\"npm install\"\n\t\"gulp\" (for a list of available gulp tasks)\n",
3+
"group.globaloptions": "Global Options",
4+
"gulp.bump": "Bumps the package's SemVer patch.",
5+
"gulp.bump.major": "Bumps the package's SemVer major.",
6+
"gulp.bump.minor": "Bumps the package's SemVer minor.",
7+
"gulp.bump.patch": "Bumps the package's SemVer patch.",
8+
"gulp.bump.prerelease": "Bumps the package's SemVer prerelease.",
9+
"gulp.changelog": "Generates the CHANGELOG.",
10+
"gulp.lint": "Runs eslint.",
11+
"gulp.release": "Releases on Github.",
12+
"help": "Show help",
13+
"init": "Creates new docs",
14+
"init.local": "Copy docsify files to local. To explicitly set --local to false you may use --no-local.",
15+
"init.theme": "Theme file to be used.",
16+
"serve": "Run local server to preview site.",
17+
"serve.open": "Open docs in default browser. To explicitly set --open to false you may use --no-open.",
18+
"serve.port": "Listen port.",
19+
"usage": "Usage",
20+
"version": "Show version number"
21+
}

0 commit comments

Comments
 (0)