-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.js
More file actions
37 lines (34 loc) · 814 Bytes
/
build.js
File metadata and controls
37 lines (34 loc) · 814 Bytes
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
const path = require('node:path');
const fs = require('node:fs');
const _ = require('lodash');
const s = require('underscore.string');
const list = require('./sensitive-fields');
// and we also want to add a prefixed AND affixed `_field` and `_input`
const arr = [...list];
for (const key of arr) {
for (const str of ['field', 'input']) {
list.push(`${str}_${key}`, `${key}_${str}`);
}
}
const fields = _.uniq(
_.reduce(
list,
(memo, str) => {
memo.push(
s.titleize(str),
s.camelize(str),
s.camelize(str).toLowerCase(),
s.camelize(str).toUpperCase(),
s.underscored(str),
s.humanize(str)
);
return memo;
},
[]
)
);
fs.writeFileSync(
path.join(__dirname, 'index.json'),
JSON.stringify(fields, null, 2),
'utf8'
);