This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
131 lines (117 loc) · 4.38 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"use strict";
// Load plugins
const gulp = require('gulp');
const { spawn } = require('child_process');
const { exec } = require('child_process');
const shell = require('gulp-shell');
const connect = require('gulp-connect-php');
const gulpSass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync');
// Build Jekyll site (but do not compile CSS)
function jekyll (gulpCallBack){
const jekyll = spawn('jekyll', ['build', '--trace'], {stdio: 'inherit'});
jekyll.on('exit', function(code) {
gulpCallBack(code === 0 ? null : 'ERROR: Jekyll process exited with code: '+code);
});
}
// Extract Methods RDF from .gsheet with Methods.sparql
function ext_methods (gulpCallBack){
const methods = exec('tarql ~/repos/uxmd/_data/etl/Methods.sparql > ~/repos/uxmd/_data/etl/Methods.ttl', {stdio: 'inherit'});
methods.on('exit', function(code) {
gulpCallBack(code === 0 ? null : 'ERROR: Methods Tarql process exited with code: '+code);
});
}
// Extract WebResources RDF from .gsheet with WebResources.sparql
function ext_resources (gulpCallBack){
const resources = exec('tarql ~/repos/uxmd/_data/etl/WebResources.sparql > ~/repos/uxmd/_data/etl/WebResources.ttl', {stdio: 'inherit'});
resources.on('exit', function(code) {
gulpCallBack(code === 0 ? null : 'ERROR: Resources Tarql process exited with code: '+code);
});
}
// Load UXM Ontology to Fuseki (replace everything in dataset)
function load_ontology (gulpCallBack){
const ontology = exec('s-put http://localhost:3030/UXM default ~/repos/uxmd/_data/etl/UXMethods.owl', {stdio: 'inherit'});
ontology.on('exit', function(code) {
gulpCallBack(code === 0 ? null : 'ERROR: UXM Ontology SOH process exited with code: '+code);
});
}
// Load Methods data to Fuseki
function load_methods (gulpCallBack){
const methods = exec('s-post http://localhost:3030/UXM default ~/repos/uxmd/_data/etl/Methods.ttl', {stdio: 'inherit'});
methods.on('exit', function(code) {
gulpCallBack(code === 0 ? null : 'ERROR: Methods SOH process exited with code: '+code);
});
}
// Load WebResources data to Fuseki
function load_resources (gulpCallBack){
const resources = exec('s-post http://localhost:3030/UXM default ~/repos/uxmd/_data/etl/WebResources.ttl', {stdio: 'inherit'});
resources.on('exit', function(code) {
gulpCallBack(code === 0 ? null : 'ERROR: Resources SOH process exited with code: '+code);
});
}
// SASS
function sass() {
return gulp.src('_sass/style.scss')
.pipe(sourcemaps.init())
.pipe(gulpSass({
outputStyle: 'compressed' // compressed, expanded
})
.on('error', gulpSass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('_site/css'))
.pipe(browserSync.stream());
}
// Start Browsersync with PHP
function php() {
connect.server({
base: './_site'
},function (){
browserSync({
proxy: '127.0.0.1:8000',
notify: false,
port: 3333
});
});
}
// BrowserSync reload
function reload (done) {
browserSync.reload({
});
done();
}
// Watch Jekyll files
function watch() {
gulp.watch("_sass/*.scss", sass);
gulp.watch(
[
"**/*.html",
"!_site/**/*.html",
"js/*.js",
"serviceworker.js",
"**/*.md",
"_config.yml",
"!_data/**"
],
gulp.series(jekyll, reload)
);
}
// Watch ontology
function watch_data() {
gulp.watch(
"_data/etl/UXMethods.owl",
gulp.series(load_ontology, load_methods, load_resources, jekyll, reload)
);
}
// Export tasks
// `gulp` builds UI from MD & SPARQL endpoint data and watches for changes to .md and template files. Fuseki must be running.
// USE FOR: any work on app.
exports.default = gulp.series(jekyll, sass, gulp.parallel(watch, php));
// `gulp etl` runs Tarql extraction, loads ontology & data into Fuseki, and watches for changes to the ontology. Fuseki must be running.
// USE FOR: updating data, iterating ontology.
exports.etl = gulp.series(ext_methods, ext_resources, load_ontology, load_methods, load_resources, watch_data);
// `gulp update` runs Tarql extraction and loads ontology & data into Fuseki.
// USE FOR: updating data from Google Sheets sources only
exports.update = gulp.series(ext_methods, ext_resources, load_ontology, load_methods, load_resources, jekyll, reload);