-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.ts
94 lines (87 loc) · 2.25 KB
/
util.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
import * as fs from 'fs';
interface TemplateVariableDefinition {
name: string,
description: string,
output: {
root: string,
sub: string,
}
}
type TemplateVariableDefinitions = TemplateVariableDefinition[];
export const templateVariableDefinitions: TemplateVariableDefinitions = [
{
"name": '#Component#',
"description": 'Pascal Case, leading underscore for subcomponents',
"output": {
"root": 'Widget',
"sub": '_WidgetSubwidget',
},
},
{
"name": '#COMPONENT#',
"description": 'Constant Case, leading underscore for subcomponents',
"output": {
"root": 'WIDGET',
"sub": '_WIDGET_SUBWIDGET',
},
},
{
"name": "#ComponentBare#",
"description": "Pascal Case, no leading underscore for subcomponents",
"output": {
"root": "Widget",
"sub": "WidgetSubwidget",
},
},
{
"name": "#COMPONENT_BARE#",
"description": "Constant Case, no leading underscore for subcomponents",
"output": {
"root": "WIDGET",
"sub": "WIDGET_SUBWIDGET",
},
},
{
"name": "#ComponentShort#",
"description": "Pascal Case, no parent prefix for subcomponents",
"output": {
"root": "Widget",
"sub": "Subwidget",
},
},
{
"name": "#COMPONENT_SHORT#",
"description": "Constant Case, no parent prefix for subcomponents",
"output": {
"root": "WIDGET",
"sub": "SUBWIDGET",
},
},
{
"name": "#component#",
"description": "BEM Case, subcomponent as element relative to parent",
"output": {
"root": "widget",
"sub": "widget__subwidget",
},
},
{
"name": "#component:block#",
"description": "BEM Case, subcomponent as new block",
"output": {
"root": "widget",
"sub": "widget-subwidget",
},
},
];
const _directoryStructure: Record<string, string> = {};
const templatePath = './_templates/components/#Component#';
const templateFiles = fs.readdirSync( templatePath, 'utf8' );
templateFiles.forEach( ( templateFile ) => {
const fullPath = `${templatePath}/${templateFile}`;
// TODO: Recursion
if ( fs.lstatSync( fullPath ).isFile() ) {
_directoryStructure[fullPath] = fs.readFileSync( fullPath, 'utf8' );
}
} );
export const directoryStructure = _directoryStructure;