-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
8,994 additions
and
1 deletion.
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
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,78 @@ | ||
/*jshint esversion: 6 */ | ||
|
||
import { series, watch } from "gulp"; | ||
import { remove } from "fs-extra"; | ||
import { readFileSync } from "fs"; | ||
import {load as yamlLoad} from "yaml-js"; | ||
import generator from "@antora/site-generator-default"; | ||
import browserSync from "browser-sync"; | ||
|
||
const filename = "antora-playbook.yml"; | ||
const server = browserSync.create(); | ||
const args = ["--playbook", filename]; | ||
|
||
//Watch Paths | ||
function watchGlobs() { | ||
let json_content = readFileSync(`${__dirname}/${filename}`, "UTF-8"); | ||
let yaml_content = yamlLoad(json_content); | ||
let dirs = yaml_content.content.sources.map(source => [ | ||
`${source.url}/**/**.yml`, | ||
`${source.url}/**/**.adoc`, | ||
`${source.url}/**/**.hbs` | ||
]); | ||
dirs.push(["antora-playbook.yml"]); | ||
dirs = [].concat(...dirs); | ||
console.log(dirs); | ||
return dirs; | ||
} | ||
|
||
const siteWatch = () => watch(watchGlobs(), series(build, reload)); | ||
|
||
const removeSite = done => remove("build", done); | ||
const removeCache = done => remove(".cache", done); | ||
|
||
function build(done) { | ||
generator(args, process.env) | ||
.then(() => { | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
done(); | ||
}); | ||
} | ||
|
||
function workshopSite(done){ | ||
generator(["--pull", "--stacktrace","--playbook","antora-playbook.yml"], process.env) | ||
.then(() => { | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
done(); | ||
}); | ||
} | ||
|
||
function reload(done) { | ||
server.reload(); | ||
done(); | ||
} | ||
|
||
function serve(done) { | ||
server.init({ | ||
server: { | ||
baseDir: "./build/site" | ||
} | ||
}); | ||
done(); | ||
} | ||
|
||
const _build = build; | ||
export { _build as build }; | ||
const _clean = series(removeSite, removeCache); | ||
export { _clean as clean }; | ||
const _default = series(_clean, build, serve, siteWatch); | ||
export { _default as default }; | ||
//build workshop docs | ||
const _wsite = series(_clean, workshopSite); | ||
export { _wsite as workshopSite }; |
Oops, something went wrong.