-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
109 lines (89 loc) · 3.49 KB
/
index.ts
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
import {HandlebarsTemplate, Options} from "./extension/model";
import {extApplyTemplate} from "./extension/apply-template";
import {extReadIndex} from "./extension/read-index";
import {extReadAsciidoc} from "./extension/read-asciidoctor";
import {extConvertToHtml} from "./extension/convert-to-html";
import {extConvertToJson} from "./extension/convert-to-json";
import {extConvertToRss} from "./extension/convert-to-rss";
import {extConvertToBlogList} from "./extension/convert-to-blog-list";
import {extConvertToBlogPage} from "./extension/convert-to-blog-page";
import {extFileExist} from "./extension/file-exist";
import {extFilesExist} from "./extension/files-exist";
import {extHighlightCode} from "./extension/highlight-code";
import {extReadHtml} from "./extension/read-html";
import {Transform} from "stream";
import {extConvertToSitemap} from "./extension/convert-to-sitemap";
const defaultOptions: Options = {
path: '../../../',
modeDev: true,
metadata: {
rss: 'src/metadata/rss.json',
blog: 'src/metadata/blog.json',
html: 'src/metadata/html.json',
sitemap: 'src/metadata/sitemap.json'
},
dirNames: ['training/', 'blog/']
};
export class DevMindGulpBuilder {
constructor(givenOptions?: Options) {
this.options = defaultOptions;
this.options.modeDev = !(process.env.NODE_ENV && process.env.NODE_ENV === 'prod');
if (givenOptions) {
this.options.path = givenOptions.path || defaultOptions.path;
if (givenOptions.metadata) {
this.options.metadata.rss = givenOptions.metadata.rss || defaultOptions.metadata.rss;
this.options.metadata.blog = givenOptions.metadata.blog || defaultOptions.metadata.blog;
this.options.metadata.html = givenOptions.metadata.html || defaultOptions.metadata.html;
this.options.metadata.sitemap = givenOptions.metadata.sitemap || defaultOptions.metadata.sitemap;
}
if(givenOptions.dirNames) {
this.options.dirNames = givenOptions.dirNames;
}
}
}
private readonly options: Options;
applyTemplate(handlebarsTemplateFile: string, partials: Array<HandlebarsTemplate>) {
return extApplyTemplate(this.options, handlebarsTemplateFile, partials);
}
convertToHtml(): Transform {
return extConvertToHtml();
}
convertToJson(filename: string): Transform {
return extConvertToJson(filename);
}
convertToRss(filename: string): Transform {
return extConvertToRss(this.options, filename);
}
convertToSitemap(): Transform {
return extConvertToSitemap(this.options);
}
convertToBlogList(handlebarsTemplateFile: string,
partials: Array<HandlebarsTemplate>,
filename: string,
nbArticleMax: number): Transform {
return extConvertToBlogList(this.options, handlebarsTemplateFile, partials, filename, nbArticleMax);
}
convertToBlogPage(handlebarsTemplateFile: string,
partials: Array<HandlebarsTemplate>,
blogIndexFile: string): Transform {
return extConvertToBlogPage(this.options, handlebarsTemplateFile, partials, blogIndexFile);
}
fileExist(filePath: string): boolean {
return extFileExist(filePath);
}
filesExist(): Transform {
return extFilesExist(this.options);
}
highlightCode(selector): Transform {
return extHighlightCode(selector);
}
readAsciidoc(): Transform {
return extReadAsciidoc(this.options);
}
readHtml(): Transform {
return extReadHtml(this.options);
}
readIndex(): Transform {
return extReadIndex();
}
}