Skip to content

Commit

Permalink
feat(dev): add gulp tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jrappen committed Mar 24, 2017
1 parent e3962b0 commit 76f0193
Show file tree
Hide file tree
Showing 21 changed files with 231 additions and 69 deletions.
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
"es2015"
],
"plugins": [
[ "babel-root-import" ]
]
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

15 changes: 15 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
env:
node: true
extends: 'vue'
rules:
indent:
- warn
- 2
quotes:
- error
- single
semi:
- error
- never
no-unused-vars:
- off
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
yarn.lock
*.log
*.log
.DS_Store
.vscode/
node_modules/
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.eslintrc
.gitignore
.travis.yml
tools/gulp-tasks/
gulpfile.babel.js
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stable
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ node_js: stable
os:
- linux
- osx
cache:
directories:
- ./node_modules
install:
- npm install --no-optional
- npm install
- npm install -g gulp
script:
- gulp lint
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<a name="3.2.5"></a>
## [3.2.5](https://github.com/QingWei-Li/docsify-cli/compare/v3.2.4...v3.2.5) (2017-03-23)

...
21 changes: 5 additions & 16 deletions bin/docsify
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ const updateNotifier = require('update-notifier')

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

const Locales = require('./locales')
const Locales = require('../tools/locales')
const y18n = new Locales()

require('yargonaut')
.style('yellow', 'required')
.helpStyle('green')
.errorsStyle('red.bold')

var argv = require('yargs')
var yargs = require('yargs')
.usage(chalk.bold(y18n.__('usage') + ': docsify <init|serve> <path> [options]'))
.command({
command: 'init <path> [--local false] [--theme vue]',
alias: 'i',
desc: chalk.gray(y18n.__('init')),
builder: (argv) => argv.options({
builder: (yargs) => yargs.options({
'local': {
alias: 'l',
default: false,
Expand All @@ -48,7 +48,7 @@ var argv = require('yargs')
command: 'serve <path> [--open false] [--port 3000]',
alias: 's',
desc: chalk.gray(y18n.__('serve')),
builder: (argv) => argv.options({
builder: (yargs) => yargs.options({
'open': {
alias: 'o',
default: false,
Expand All @@ -68,15 +68,6 @@ var argv = require('yargs')
}),
handler: (argv) => run.serve(argv.path, argv.open, argv.port)
})
.command({
command: 'completion',
alias: 'c',
desc: chalk.gray(y18n.__('completion')),
builder: {},
handler: (argv) => {
argv.showCompletionScript()
}
})
.help()
.option('help', {
alias: 'h',
Expand All @@ -91,7 +82,5 @@ var argv = require('yargs')
desc: chalk.gray(y18n.__('version')),
group: chalk.green(y18n.__('group.globaloptions'))
})
.epilog(chalk.green(y18n.__('epilog')) + ':\n' +
' https://QingWei-Li.github.io/docsify\n' +
' https://QingWei-Li.github.io/docsify-cli\n')
.epilog(chalk.gray(y18n.__('epilog')))
.argv
14 changes: 0 additions & 14 deletions bin/locales/en.json

This file was deleted.

48 changes: 48 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const gulp = require('gulp-help')(require('gulp'))
const gulpStats = require('gulp-stats')

const Locales = require('./tools/locales')
const y18n = new Locales()

gulpStats(gulp)

function loadTask(fileName, taskName) {
const taskModule = require('./tools/gulp-tasks/' + fileName)
const task = taskName ? taskModule[taskName] : taskModule
return task(gulp)
}

// hide this from 'gulp-help' as this is a helper for the gulp task 'bump'
gulp.task('bump:pkg-version', false, [], loadTask('bump', 'bumpPkgVersion'), {})

gulp.task('bump',
y18n.__('gulp.bump'),
[],
loadTask('bump', 'bump'),
{
aliases: ['b', 'B'],
options: {
'major': y18n.__('gulp.bump.major'),
'minor': y18n.__('gulp.bump.minor'),
'patch': y18n.__('gulp.bump.patch'),
'prerelease': y18n.__('gulp.bump.prerelease')
}
})

gulp.task('changelog',
y18n.__('gulp.changelog'),
[],
loadTask('changelog', 'conventional'),
{ aliases: ['c', 'C'] })

gulp.task('lint',
y18n.__('gulp.lint'),
[],
loadTask('lint', 'eslint'),
{ aliases: ['l', 'L'] })

gulp.task('release',
y18n.__('gulp.release'),
[],
loadTask('release', 'github'),
{ aliases: ['r', 'R'] })
56 changes: 38 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,66 @@
"name": "docsify-cli",
"version": "3.2.5",
"description": "A magical documentation generator.",
"author": "qingwei-li <cinwell.li@gmail.com> (https://github.com/QingWei-Li)",
"author": {
"name": "qingwei-li",
"email": "cinwell.li@gmail.com",
"url": "https://github.com/QingWei-Li"
},
"homepage": "https://github.com/QingWei-Li/docsify-cli#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/QingWei-Li/docsify-cli.git"
},
"license": "MIT",
"engines": {
"node": ">= 4"
"node": ">= 6",
"npm": ">= 4"
},
"main": "bin/docsify",
"bin": {
"docsify": "bin/docsify"
},
"files": [
"bin",
"lib"
"lib",
"tools/locales"
],
"scripts": {
"test": "eslint lib bin/docsify --fix"
},
"dependencies": {
"chalk": "^1.1.0",
"connect": "^3.5.0",
"chalk": "^1.1.3",
"connect": "^3.6.0",
"connect-livereload": "^0.6.0",
"cp-file": "^4.1.0",
"docsify": ">=2",
"fs-extra": "^2.0.0",
"livereload": "^0.6.0",
"cp-file": "^4.1.1",
"docsify": ">=3",
"fs-extra": "^2.1.2",
"livereload": "^0.6.2",
"open": "^0.0.5",
"serve-static": "^1.11.1",
"update-notifier": "^1.0.3",
"serve-static": "^1.12.1",
"update-notifier": "^2.1.0",
"y18n": "^3.2.1",
"yargonaut": "^1.1.2",
"yargs": "^6.4.0"
"yargs": "^7.0.2"
},
"devDependencies": {
"eslint": "^3.10.2",
"eslint-config-vue": "^2.0.1",
"eslint-plugin-vue": "^1.0.0"
"babel-core": "^6.18.2",
"babel-preset-es2015": "^6.18.0",
"babel-root-import": "^4.1.3",
"chalk": "^1.1.3",
"conventional-github-releaser": "^1.1.2",
"cors": "^2.8.1",
"eslint": "^3.18.0",
"eslint-config-vue": "^2.0.2",
"eslint-plugin-vue": "^2.0.1",
"gulp": "^3.9.1",
"gulp-bump": "^2.4.0",
"gulp-connect": "^5.0.0",
"gulp-conventional-changelog": "^1.1.0",
"gulp-eslint": "^3.0.1",
"gulp-help": "^1.6.1",
"gulp-if": "^2.0.1",
"gulp-load-plugins": "^1.3.0",
"gulp-stats": "^0.0.4",
"run-sequence": "^1.2.2",
"yargs": "^7.0.2"
},
"keywords": [
"docsify",
Expand Down
26 changes: 26 additions & 0 deletions tools/gulp-tasks/bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
bump: (gulp) => (cb) => {
const runSequence = require('run-sequence')
const chalk = require('chalk')
runSequence(
'bump:pkg-version',
(error) => {
if (error) {
console.log(chalk.magenta.bold('\n[bump]') + chalk.red.bold(' There was an issue bumping version:\n') + error.message)
}
cb(error)
}
)
},
bumpPkgVersion: (gulp) => () => {
const $ = require('gulp-load-plugins')()
const argv = require('yargs').argv
return gulp.src('./package.json')
.pipe($.if((Object.keys(argv).length === 2), $.bump()))
.pipe($.if(argv.patch, $.bump()))
.pipe($.if(argv.minor, $.bump({ type: 'minor' })))
.pipe($.if(argv.major, $.bump({ type: 'major' })))
.pipe($.if(argv.prerelease, $.bump({ type: 'prerelease' })))
.pipe(gulp.dest('./'))
}
}
11 changes: 11 additions & 0 deletions tools/gulp-tasks/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
conventional: (gulp) => () => {
const conventionalChangelog = require('gulp-conventional-changelog')
return gulp.src('./CHANGELOG.md')
.pipe(conventionalChangelog({
preset: 'angular',
releaseCount: 0
}))
.pipe(gulp.dest('./'))
}
}
9 changes: 9 additions & 0 deletions tools/gulp-tasks/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
eslint: (gulp) => () => {
const $ = require('gulp-load-plugins')()
return gulp.src(['./lib/', './bin/docsify'])
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError())
}
}
11 changes: 11 additions & 0 deletions tools/gulp-tasks/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
github: (gulp) => (done) => {
const conventionalGithubReleaser = require('conventional-github-releaser')
conventionalGithubReleaser({
type: 'oauth',
token: process.env.CONVENTIONAL_GITHUB_RELEASER_TOKEN
}, {
preset: 'angular'
}, done)
}
}
10 changes: 8 additions & 2 deletions bin/locales/de.json → tools/locales/de.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"completion": "Drucke shell Vervollständigungsskript",
"epilog": "Dokumentation",
"group.globaloptions": "Globale Optionen",
"gulp.bump": "Erhöhe die SemVer patch des Pakets.",
"gulp.bump.major": "Erhöhe die SemVer major des Pakets.",
"gulp.bump.minor": "Erhöhe die SemVer minor des Pakets.",
"gulp.bump.patch": "Erhöhe die SemVer patch des Pakets.",
"gulp.bump.prerelease": "Erhöhe die SemVer prerelease des Pakets.",
"gulp.changelog": "Generiere den CHANGELOG.",
"gulp.lint": "Führe eslint aus.",
"gulp.release": "Veröffentliche auf Github.",
"help": "Zeige Hilfe an",
"init": "Erzeuge neue Dokumentation.",
"init.local": "Kopiere docsify Dateien in lokale Ordner. Um explizit --local auf false zu setzen, kannst du --no-local verwenden.",
Expand Down
21 changes: 21 additions & 0 deletions tools/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"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",
"group.globaloptions": "Global Options",
"gulp.bump": "Bumps the package's SemVer patch.",
"gulp.bump.major": "Bumps the package's SemVer major.",
"gulp.bump.minor": "Bumps the package's SemVer minor.",
"gulp.bump.patch": "Bumps the package's SemVer patch.",
"gulp.bump.prerelease": "Bumps the package's SemVer prerelease.",
"gulp.changelog": "Generates the CHANGELOG.",
"gulp.lint": "Runs eslint.",
"gulp.release": "Releases on Github.",
"help": "Show help",
"init": "Creates new docs",
"init.local": "Copy docsify files to local. To explicitly set --local to false you may use --no-local.",
"init.theme": "Theme file to be used.",
"serve": "Run local server to preview site.",
"serve.open": "Open docs in default browser. To explicitly set --open to false you may use --no-open.",
"serve.port": "Listen port.",
"usage": "Usage",
"version": "Show version number"
}
Loading

0 comments on commit 76f0193

Please sign in to comment.