-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
193 lines (159 loc) · 5.57 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
var gulp = require('gulp');
var del = require('del');
let es = require('event-stream');
let fs = require('fs')
var { spawnSync } = require('child_process');
// gulp.task('cleanSite', function(callback) {
function cleanSite(callback) {
del.sync("_site/**/*.*");
del.sync("_site");
callback();
return;
// });
}
// gulp.task('cleanMetadata', function(callback) {
function cleanMetadata(callback) {
del.sync([
"api/**/*.yml",
"!api/toc.yml"]);
callback();
return;
// });
}
// gulp.task('cleanObj', function(callback) {
function cleanObj(callback) {
del.sync("obj/**/*");
del.sync("obj");
del.sync("src/obj/**/*");
del.sync("src/obj");
del.sync("src/IgniteUI.Blazor*.dll");
callback();
return;
// });
}
// gulp.task('clean', gulp.series('cleanSite', 'cleanMetadata', 'cleanObj'));
exports.clean = clean = gulp.series(cleanSite, cleanMetadata, cleanObj);
function copyIndex(callback) {
console.log("copying ./doc/index.md to ./api/index.md");
gulp.src(['./doc/index.md'])
.pipe(gulp.dest('./api'))
.on("end", function() {
callback();
return;
});
}
function copyBlazorSource(callback) {
console.log("copying ./app/**/IgniteUI.Blazor*.* to ./src/IgniteUI.Blazor*.*");
gulp.src([
'./app/bin/Debug/net6.0/IgniteUI.Blazor*.*'
// './app/bin/Debug/net6.0/IgniteUI.Blazor.dll',
// './app/bin/Debug/net6.0/IgniteUI.Blazor.Documents.Core.dll',
// './app/bin/Debug/net6.0/IgniteUI.Blazor.Documents.Excel.dll',
])
.pipe(es.map(function(file, fileCallback) {
console.log("copying " + file.dirname + '/' + file.basename);
fileCallback(null, file);
}))
.pipe(gulp.dest('./src'))
.on("end", function() {
callback();
return;
});
}
exports.copyBlazorSource = copyBlazorSource;
function verifyBlazorSource(callback) {
let srcFiles = [
'./src/IgniteUI.Blazor.dll',
'./src/IgniteUI.Blazor.xml',
'./src/IgniteUI.Blazor.Documents.Core.dll',
'./src/IgniteUI.Blazor.Documents.Core.xml',
'./src/IgniteUI.Blazor.Documents.Excel.dll',
'./src/IgniteUI.Blazor.Documents.Excel.xml',
]
var filesMissing = [];
for (const filePath of srcFiles) {
if (fs.existsSync(filePath)) {
console.log("found: " + filePath);
} else {
console.log("missing: " + filePath);
filesMissing.push(filePath);
}
}
if (filesMissing.length > 0) {
throw new Error("Cannot build while these files are missing: \n" + filesMissing.join('\n') + "\n>>> Check if you build Blazor app from in the `app` folder <<<");
}
if (callback)
callback();
}
exports.verifyBlazorSource = verifyBlazorSource;
function buildFrom(docfxJSON, callback) {
console.log("build " + docfxJSON);
verifyBlazorSource();
var response = spawnSync("docfx", [docfxJSON], { stdio: 'inherit' });
if (response.status != 0)
{
console.log('Exiting docfx with Error code: ' + response.status);
}
else {
console.log("docfx complete");
}
callback();
return;
}
// gulp.task('buildAPI', gulp.series('clean', function(callback) {
// buildFrom("docfx-build.json", callback);
// }));
// gulp.task('buildDOC', gulp.series(function(callback) {
// buildFrom("docfx-run.json", callback);
// }));
function buildAPI(callback) {
buildFrom("docfx-build.json", callback);
}
exports.buildAPI = buildAPI;
function buildDOC(callback) {
buildFrom("docfx-run.json", callback);
}
exports.buildDOC = buildDOC;
exports.run = gulp.series(updateIndex, copyIndex, buildDOC);
exports.build = gulp.series(clean, updateIndex, copyIndex, copyBlazorSource, buildAPI);
// gulp.task('default', gulp.series('run'));
function updateIndex(callback) {
let jsonFile = fs.readFileSync("index-links.json", "utf8");
let jsonLinks = JSON.parse(jsonFile);
// console.log(jsonLinks);
jsonLinks = jsonLinks.sort((a, b) => a.api > b.api ? 1 : -1);
var tableMarkdown = "";
tableMarkdown += "API Component | Resources \n"
tableMarkdown += "-------------------- | ------------------- \n"
for (const info of jsonLinks) {
// [IgbTreemap](IgniteUI.Blazor.Controls.IgbTreemap.html) | [Docs & Examples](https://www.infragistics.com/products/ignite-ui-blazor/blazor/components/charts/types/treemap-chart)
var api = info.api;
if (api.indexOf(".") < 0) {
api = "IgniteUI.Blazor.Controls." + api;
}
api += ".html";
var row = "";
row += "[" + info.api + "]" + "(" + api + ") | ";
var mdLinks = [];
for (const link of info.links) {
var mdLink = "[" + (link.text === undefined ? "Docs & Examples" : link.text) + "]";
mdLink += "(https://www.infragistics.com/products/ignite-ui-blazor/blazor/components" + link.url + ")";
mdLinks.push(mdLink);
}
row += mdLinks.join(" <br> ");
tableMarkdown += row + "\n";
}
// console.log(tableMarkdown);
var indexFiles = ["./index.md", "./doc/index.md"];
for (const filePath of indexFiles) {
let indexFile = fs.readFileSync(filePath, "utf8");
var tableStart = indexFile.indexOf("<!-- auto-gen-table-start -->") + 29;
var tableEnd = indexFile.indexOf("<!-- auto-gen-table-end -->");
var output = indexFile.substring(0, tableStart) + "\n" + tableMarkdown + indexFile.substring(tableEnd);;
// console.log(output);
fs.writeFileSync(filePath, output);
}
if (callback)
callback();
}
exports.updateIndex = updateIndex;