-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gitignore): add all source files
- Loading branch information
1 parent
3757c2b
commit 61ee9f4
Showing
4 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
node_modules | ||
coverage/ | ||
dist | ||
docs | ||
/coverage | ||
/dist | ||
/docs | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict' | ||
|
||
const documentation = require('documentation') | ||
const glob = require('glob') | ||
const fs = require('fs-extra') | ||
const pify = require('pify') | ||
const chalk = require('chalk') | ||
const vinyl = require('vinyl-fs') | ||
const streamArray = require('stream-array') | ||
|
||
const utils = require('../utils') | ||
const introTmpl = require('../config/intro-template.md') | ||
|
||
function generateDescription (pkg) { | ||
let example | ||
try { | ||
example = fs.readFileSync(utils.getPathToExample()) | ||
} catch (err) { | ||
console.log(chalk.yellow('Warning: No `example.js` found in the root directory.')) | ||
} | ||
|
||
return introTmpl(pkg.name, pkg.repository.url, example) | ||
} | ||
|
||
function getOpts (pkg) { | ||
const opts = { | ||
github: true | ||
} | ||
const configFile = utils.getPathToDocsConfig() | ||
if (fs.existsSync(configFile)) { | ||
opts.config = configFile | ||
} else { | ||
opts.toc = [{ | ||
name: 'Intro', | ||
description: generateDescription(pkg) | ||
}] | ||
} | ||
|
||
return opts | ||
} | ||
|
||
function writeDocs (output) { | ||
const docsPath = utils.getPathToDocs() | ||
return fs.ensureDir(docsPath) | ||
.then(() => new Promise((resolve, reject) => { | ||
streamArray(output) | ||
.pipe(vinyl.dest(docsPath)) | ||
.once('error', reject) | ||
.once('end', resolve) | ||
})) | ||
} | ||
|
||
function build (ctx) { | ||
return Promise.all([ | ||
utils.getPkg(), | ||
pify(glob)('./src/**/*.js', { | ||
cwd: process.cwd() | ||
}) | ||
]).then((res) => { | ||
const pkg = res[0] | ||
const files = res[1] | ||
|
||
return documentation.build(files, getOpts(pkg)) | ||
.then((docs) => documentation.formats.html(docs, { | ||
theme: require.resolve('clean-documentation-theme'), | ||
version: pkg.version, | ||
name: pkg.name | ||
})) | ||
.then(writeDocs) | ||
}) | ||
} | ||
|
||
module.exports = build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const Listr = require('listr') | ||
|
||
const utils = require('../utils') | ||
const clean = require('../clean') | ||
const publish = require('./publish') | ||
const build = require('./build') | ||
|
||
const TASKS = new Listr([{ | ||
title: 'Clean ./docs', | ||
task: () => clean('docs') | ||
}, { | ||
title: 'Generating documentation', | ||
task: build | ||
}, { | ||
title: 'Publish to GitHub Pages', | ||
task: publish, | ||
enabled: (ctx) => ctx.publish | ||
}], utils.getListrConfig()) | ||
|
||
module.exports = TASKS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict' | ||
|
||
const ghPages = require('gh-pages') | ||
const pify = require('pify') | ||
const os = require('os') | ||
const path = require('path') | ||
|
||
const utils = require('../utils') | ||
|
||
function publish (ctx) { | ||
return utils.getPkg().then((pkg) => { | ||
return pify(ghPages.publish.bind(ghPages))('docs', { | ||
message: 'chore: update documentation', | ||
clone: path.join(os.tmpdir(), 'aegir-gh-pages-cache', pkg.name) | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = publish |