-
Notifications
You must be signed in to change notification settings - Fork 13
/
start.js
78 lines (69 loc) · 2.23 KB
/
start.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
import {
writeHTML,
isFolderExists,
generateTemplateName,
} from 'markup-generator';
import {
generateHtmlFullTemplateHackernoon,
generateReactFullTemplateHackernoon,
generateHtmlFullTemplateRecipes,
generateFrontHackernoon,
} from './src';
import { printMessage } from './src/domain/helper-methods/cli';
import { deliver } from './src/domain/deliver/deliver';
import { MESSAGE_HTML_FULL_TEMPLATE2 } from './src/domain/deliver/deliver.constants';
import {
hackernoonContent,
FULL_SOURCE,
nomoretogoContent,
frontMarkdownHackernoon,
} from './src/domain/content-source';
// TODO add more messages here, and finally replace messages in our methods
const MESSAGE_REACT_FULL_TEMPLATE =
'The FullTemplate has been parsed successfully';
// const MESSAGE_REACT_CONTENT = 'The Content has been parsed successfully';
// connection to source files moved into /domain/content-source/index.js
const markdown = hackernoonContent;
// console.log('-----');
// console.log(frontMarkdownHackernoon);
isFolderExists('./generated');
isFolderExists('./tests/_generated');
export const modes = {
full: () => {
const hackernoonFullTemplate = generateHtmlFullTemplateHackernoon(markdown);
deliver(
hackernoonFullTemplate,
'hackernoon-full-template',
MESSAGE_HTML_FULL_TEMPLATE2,
);
},
reactFull: () => {
const fullContent = generateReactFullTemplateHackernoon(markdown);
// TODO replace this three rows on deliver function
const fileName = generateTemplateName('FullTemplate', 'js');
writeHTML(fileName, fullContent, 'generated', '');
printMessage(MESSAGE_REACT_FULL_TEMPLATE, 'green2');
},
recipesFull: () => {
const markdownRecipes = nomoretogoContent;
const recipesFullTemplate =
generateHtmlFullTemplateRecipes(markdownRecipes);
deliver(
recipesFullTemplate,
'recipes-full-template',
MESSAGE_HTML_FULL_TEMPLATE2,
);
},
hackernnonFront: () => {
// const markdownRecipes = nomoretogoContent;
const HNFrontFullTemplate = generateFrontHackernoon(
frontMarkdownHackernoon,
);
deliver(
HNFrontFullTemplate,
'frontmatter-full-template',
MESSAGE_HTML_FULL_TEMPLATE2,
);
},
};
modes[process.env.PARSE ?? 'full'](FULL_SOURCE);