Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.log
.DS_Store
node_modules
yarn.lock
*.log
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
sudo: false
language: node_js
node_js: stable
git:
depth: 10
128 changes: 79 additions & 49 deletions bin/docsify
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,57 +1,87 @@
#!/usr/bin/env node

var program = require('commander')
var updateNotifier = require('update-notifier')
var run = require('../src')
var pkg = require('../package.json')
'use strict'

const pkg = require('../package.json')
const cliVersion = pkg.version
const updateNotifier = require('update-notifier')
const Y18n = require('y18n')
const run = require('../src')

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

program
.version(require('../package.json').version)
const y18n = Y18n({
directory: '../locales',
updateFiles: false
})

program
.usage('init [options] <relative path>')
.command('init [path .]')
.alias('i')
.description('create new docs')
.option('-l, --local', 'copy docsify to local (default: false)', false)
.option('-t, --theme [vue|buble|dark|pure]', 'theme file (default: vue)', 'vue')
.on('--help', function () {
console.log('\tExamples:\n')
console.log('\t\tdocsify i')
console.log('\t\tdocsify init')
console.log('\t\tdocsify init -l')
console.log('\t\tdocsify init --local')
console.log('\t\tdocsify init -t buble')
console.log('\t\tdocsify init -t dark')
console.log('\t\tdocsify init --theme pure')
console.log('\t\tdocsify init -l -t buble')
console.log('\t\tdocsify init --local -t dark')
console.log('\t\tdocsify init --local --theme pure')
console.log('\t\tdocsify init "./docs"')
console.log('\t\tdocsify init -l "./docs"')
console.log('\t\tdocsify init -l -t buble "./docs"')
console.log('\t\tdocsify init -l -t dark "./docs"')
console.log('\t\tdocsify init -l -t pure "./docs"')
})
.action(run.init)
require('yargonaut')
.style('yellow', 'required')
.helpStyle('green')
.errorsStyle('red.bold')

program
.usage('serve [options] <relative path>')
.command('serve [path .]')
.alias('s')
.description('run serve to preview')
.option('-p, --port [port 3000]', 'listen port', 3000)
.on('--help', function () {
console.log('\tExamples:\n')
console.log('\t\tdocsify s')
console.log('\t\tdocsify serve')
console.log('\t\tdocsify serve -p 8080')
console.log('\t\tdocsify serve --port 8080')
var argv = require('yargs')
.usage('Usage: $0 <command> [options]', {
'init': {
desc: 'create new docs',
short: 'i'
},
'serve': {
desc: 'run serve to preview',
short: 's'
}
})
.action(run.serve)

program.parse(process.argv)

if (!program.args.length) program.help()
.command({
command: 'init <path> [--local] [--theme vue]',
alias: 'i',
desc: 'create new docs',
builder: (yargs) => return yargs
.option('l', {
alias: 'local',
type: 'boolean',
default: false,
desc: 'Copy docsify files to local. Default is false.'
})
.option('t', {
alias: 'theme',
type: 'string',
default: 'vue',
choices: ['vue', 'buble', 'dark', 'pure'],
desc: 'Theme file to be used.'
}),
handler: (argv) => run.init
})
.command({
command: 'serve <path> [--port 3000]',
alias: 's',
desc: 'run serve to preview',
builder: (yargs) => return yargs
.option('p', {
alias: 'port',
type: integer,
default: 3000,
desc: 'listen port'
}),
handler: (argv) => run.serve
})
.option('h', {
alias: 'help',
type: 'boolean',
desc: 'Show help'
})
.option('v', {
alias: 'version',
type: 'boolean',
desc: 'Show version number'
})
.help('help')
.version(cliVersion, 'version', 'Show version number')
.example('docsify init --local "./docs"')
.epilog('Read more about docsify on:\n' +
'\thttps://QingWei-Li.github.io/docsify\n' +
'\thttps://QingWei-Li.github.io/docsify-cli')
.showHelpOnFail(false, 'Something went wrong! Run --help')
.updateStrings(function (obj) {
y18n.updateLocale(obj)
})
.argv
17 changes: 17 additions & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Commands:": "Befehle:",
"Options:": "Optionen:",
"Examples:": "Beispiele:",
"boolean": "boolean",
"count": "Zähler",
"string": "string",
"number": "Zahl",
"array": "array",
"required": "erforderlich",
"default:": "Standard:",
"choices:": "Möglichkeiten:",
"aliases:": "Aliase:",
"Invalid values:": "Unzulässige Werte:",
"Show help": "Hilfe anzeigen",
"Show version number": "Version anzeigen"
}
17 changes: 17 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Commands:": "Commands:",
"Options:": "Options:",
"Examples:": "Examples:",
"boolean": "boolean",
"count": "count",
"string": "string",
"number": "number",
"array": "array",
"required": "required",
"default:": "default:",
"choices:": "choices:",
"aliases:": "aliases:",
"Invalid values:": "Invalid values:",
"Show help": "Show help",
"Show version number": "Show version number"
}
16 changes: 16 additions & 0 deletions locales/zh_CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Commands:": "命令:",
"Options:": "选项:",
"Examples:": "示例:",
"boolean": "布尔",
"count": "计数",
"string": "字符串",
"number": "数字",
"array": "数组",
"required": "必需",
"default:": "默认值:",
"choices:": "可选值:",
"Invalid values:": "无效的选项值:",
"Show help": "显示帮助信息",
"Show version number": "显示版本号"
}
52 changes: 29 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
"name": "docsify-cli",
"version": "3.0.2",
"description": "A magical documentation generator.",
"author": "qingwei-li <cinwell.li@gmail.com> (https://github.com/QingWei-Li)",
"contributors": [
"Johannes Rappen (https://github.com/jrappen)"
],
"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"
},
"main": "bin/docsify",
"bin": {
"docsify": "bin/docsify"
Expand All @@ -11,40 +24,33 @@
"src"
],
"scripts": {
"test": "eslint src bin/docsify --fix"
"lint": "eslint src bin/docsify --fix"
},
"engines": {
"node": ">= 4"
},
"keywords": [
"docsify",
"doc",
"docs",
"documentation",
"creator",
"generator",
"cli"
],
"author": "qingwei-li <cinwell.li@gmail.com> (https://github.com/QingWei-Li)",
"homepage": "https://github.com/QingWei-Li/docsify-cli",
"repository": {
"type": "git",
"url": "https://github.com/QingWei-Li/docsify-cli.git"
},
"license": "MIT",
"dependencies": {
"commander": "^2.9.0",
"chalk": "^1.1.0",
"connect": "^3.5.0",
"connect-livereload": "^0.6.0",
"cp-file": "^4.1.0",
"docsify": ">=2",
"livereload": "^0.6.0",
"serve-static": "^1.11.1",
"update-notifier": "^1.0.3"
"update-notifier": "^1.0.3",
"y18n": "^3.2.1",
"yargonaut": "^1.1.2",
"yargs": "^6.4.0"
},
"devDependencies": {
"eslint": "^3.10.2",
"eslint-config-vue": "^2.0.1",
"eslint-plugin-vue": "^1.0.0"
}
},
"keywords": [
"docsify",
"doc",
"docs",
"documentation",
"creator",
"generator",
"cli"
]
}
8 changes: 4 additions & 4 deletions src/serve.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var chalk = require('chalk')
var serveStatic = require('serve-static')
var connect = require('connect')
var livereload = require('connect-livereload')
var lrserver = require('livereload')
var util = require('./util')

var green = util.green
var exist = util.exist
var resolve = util.resolve

Expand All @@ -13,7 +13,7 @@ module.exports = function (path, option) {
var indexFile = resolve(path, 'index.html')

if (!exist(indexFile)) {
console.log(`\nplease run ${green('init')} before.\n`)
console.log('\nplease run ' + chalk.bgWhite('docsify ' + chalk.green.bold('init')) + ' before.\n')
process.exit(0)
}

Expand All @@ -27,7 +27,7 @@ module.exports = function (path, option) {
}).watch(path)

console.log('\n')
console.log(`Serve ${green(`${path}`)}`)
console.log(`Listening at ${green(`http://localhost:${option.port}`)}`)
console.log('Serving ' + chalk.inverse(`${path}`))
console.log('Listening at ' + chalk.blue.underline('http://localhost:' + chalk.bgWhite(`${option.port}`)))
console.log('\n')
}
4 changes: 0 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ exports.exist = function (path) {
}
return undefined
}

exports.green = function (str) {
return '\u001B[32m' + str + '\u001B[39m'
}