-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfractal.config.js
248 lines (227 loc) · 7.19 KB
/
fractal.config.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
'use strict';
/*
* Require the path module
*/
const path = require('path');
const fs = require('fs');
/*
* Require the Fractal module
*/
const fractal = module.exports = require('@frctl/fractal').create();
const mandelbrot = require('@frctl/mandelbrot');
// create a new instance with custom config options
const ASCTheme = mandelbrot({
skin: {
name: 'blue',
accent: '#0C2340',
complement: '#F15A22',
links: '#D3430D',
},
lang: "en-US",
panels: ["notes", "html", "resources", "view"],
nav: ['search', 'docs', 'components', 'information'],
navigation: 'split',
favicon: 'favicon.ico',
styles: [
'default',
// for simple overrides
'/college-dls/theme/theme.css'
],
scripts: [
'default',
// for simple overrides
'/college-dls/theme/theme.js',
'/college-dls/theme/color-modes.js',
],
information: [
{
label: 'Version',
value: require('./package.json').version
},
{
label: 'Built on',
value: new Date(),
type: 'time',
format: (value) => {
return value.toLocaleDateString('en');
}
},
{
label: 'Project',
value: '',
format: (value) => {
const homepage = require('./package.json').homepage
const val = '<a href="' + homepage + '">github</a>';
return val
}
}
]
});
ASCTheme.addLoadPath(__dirname + '/public/theme/overrides');
const hbs = require('@frctl/handlebars')({
helpers: {
uppercase: function(str) {
return str.toUpperCase();
},
each_upto: function(ary, max, options) {
if(!ary || ary.length == 0)
return options.inverse(this);
var result = [ ];
for(var i = 0; i < max && i < ary.length; ++i)
result.push(options.fn(ary[i]));
return result.join('');
}
}
/* other configuration options here */
});
fractal.components.engine(hbs);
/*
* Give your project a title.
*/
// keep title empty so we can display BG logo
fractal.set('project.title', 'College Design Language System');
fractal.set('project.verison', 'v0.9.0');
fractal.set('project.author', 'Academic Strategic Communications <[email protected]>');
// tell Fractal to use the configured theme by default
fractal.web.theme(ASCTheme);
/*
* Tell Fractal where to look for components.
*/
fractal.components.set('path', path.join(__dirname, 'components'));
/*
* Tell Fractal where to look for documentation pages.
*/
fractal.docs.set('path', path.join(__dirname, 'docs'));
// Define potential Statuses for documentation pages.
fractal.docs.set('statuses', {
draft: {
label: "Draft",
description: "This documentation is not complete",
color: "#FF4136"
},
published: {
label: "Published",
description: "Documentation complete",
color: "#2ECC40"
}
});
/*
* Tell the Fractal web preview plugin where to look for static assets.
*/
fractal.web.set('static.path', path.join(__dirname, '/public'));
fractal.web.set('static.mount', '/college-dls');
/*
* Tell the Fractal where to output the build files.
*/
fractal.web.set('builder.dest', path.join(__dirname, 'dist'));
/* change the "assets" tab to the present file type */
fractal.components.set('resources', {
scss: {
label: 'SCSS',
match: ['**/*.scss']
},
css: {
label: 'CSS',
match: ['**/*.css']
},
other: {
label: 'Other Assets',
match: ['**/*', '!**/*.scss', '!**.css']
}
});
// Define potential Statuses for components.
fractal.components.set('statuses', {
prototype: {
label: "Prototype",
description: "Do not implement",
color: "#FF4136"
},
wip: {
label: "WIP",
description: "Work in progress. Implement with caution",
color: "#FFDC00"
},
ready: {
label: "Ready",
description: "Ready to implement",
color: "#2ECC40"
},
exported: {
label: "Exported",
description: "Exported to the working project",
color: "#01FF70"
}
});
fractal.components.set('default.status', 'prototype');
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// UTSA Custom CLI Commands
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ :
// LIST COMPONENTS
// FUTURE: add [opts] to list components by status [prototype, wip, ready, exported]
// USAGE: fractal list, fractal list clean
const list = (opt='json') => {
if (opt == 'clean') {
console.log('they want it clean', opt);
for (let item of fractal.components.flatten()) {
console.log(`Title: ${item.title} \n Path: ${item.path} \n Status: ${item.status.label} \n`);
}
}
else {
const sourcemap = {};
for (let item of fractal.components.flatten()) {
sourcemap[item.handle] = {path: item.path, ctx: item.context, title: item.title}
}
console.log(JSON.stringify(sourcemap));
}
}
fractal.cli.command('list [opt]', (args, done) => {
list(args.opt);
done();
}, {description: "List components"}
);
// ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ : ~ :
// CREATE COMPONENTS
// USAGE: fractal create yourCompName
// MAKE SURE: you are IN the directory where you want to create your component
const create = (comp) => {
const createFile = (compPath, compContent, fileType) => {
try {
fs.writeFileSync(compPath, compContent);
console.log('SUCCESS: '+ fileType +' file created');
}
catch (error) {
console.error('ERROR: ', error);
}
}
const componentPath = process.cwd() + '/' + comp;
// 1st create directory structure, then create starter files
try {
// Do not create the component directory if it already exists
if (!fs.existsSync(componentPath)) {
// If the directory was created, now create the starter files
if (fs.mkdirSync(componentPath, { recursive: true })) {
console.log('SUCCESS: Component directory created.');
const compFile = componentPath + '/' + comp;
const hbsFile = compFile + '.hbs';
const configFile = compFile + '.config.json';
const scssFile = compFile + '.scss';
const notesFile = compFile + '.readme.md';
createFile(hbsFile, '{{placeholder}}', 'Handlebars');
createFile(configFile, '{"title": "' + comp + ' Component", "context": {"placeholder": "Success"}}', 'Config');
createFile(scssFile, '', 'Sass');
createFile(notesFile, '# ' + comp.toUpperCase(), 'Readme');
}
}
else {
console.error('ERROR: That component directory already EXISTS!');
}
}
catch (error) {
console.error('Error: ', error);
}
}
fractal.cli.command("create <req> [opt]", (args, done) => {
create(args.req);
done();
}, {description: "Create a new component"});