UNPKG

1.14 kBJavaScriptView Raw
1const map = require('lodash/map');
2const kebabCase = require('lodash/kebabCase');
3const flatten = require('lodash/flatten');
4
5const behaviorHelpSections = (app) => {
6 if (!app.behaviorals) return [];
7
8 const desc = 'Description not provided.';
9
10 const mainTitle = {
11 header: 'Behaviors',
12 content: `${app.appName} supports the following objects that tweaks the \
13scaffolding behavior.`
14 };
15
16 const behaviorals = map(app.behaviorals, ({
17 name, description, values, optionName
18 }) => {
19 const behavioralName = optionName;
20 const behavioralTitle = {
21 header: name,
22 content: description || desc
23 };
24 const behavioralSections = map(values, ({ name, description, options }) => {
25 return [{
26 header: name,
27 content: `{italic --${kebabCase(behavioralName)}=${name}} \
28${description || desc}`
29 }, {
30 optionList: map(options, (option) => {
31 return { ...option, name: kebabCase(option.name) };
32 })
33 }];
34 });
35 return [mainTitle, behavioralTitle, ...flatten(behavioralSections)];
36 });
37
38 return flatten(behaviorals);
39};
40
41module.exports = behaviorHelpSections;