Skip to content

Commit

Permalink
Add local dev env.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfchase committed Oct 31, 2023
1 parent 1f61568 commit dc0c7d3
Show file tree
Hide file tree
Showing 4 changed files with 8,994 additions and 1 deletion.
2 changes: 1 addition & 1 deletion workshop/antora-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ site:
start_page: fraud-detection-workshop::index.adoc
content:
sources:
- url: ./../
- url: ./..
start_path: workshop/docs
asciidoc:
attributes:
Expand Down
78 changes: 78 additions & 0 deletions workshop/gulpfile.babel.js
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 };
Loading

0 comments on commit dc0c7d3

Please sign in to comment.