-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate-genres.js
111 lines (98 loc) · 1.86 KB
/
generate-genres.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
/* eslint-disable @typescript-eslint/no-var-requires */
/* This script file generates music genres, and prepares them for translation */
const { inspect } = require('util')
const fs = require('fs')
const prettier = require('prettier')
const path = require('path')
let prettierConfig
;(async () => {
prettierConfig = await prettier.resolveConfig(
path.resolve(__dirname, '../.prettierrc.js')
)
})()
const result = genres()
.sort()
.map((genre) => {
return {
raw: genre,
t: `${genre}`
}
})
const dir = `${__dirname}/../src/generated`
fs.mkdirSync(dir, { recursive: true })
const file = fs.createWriteStream(`${dir}/genres.js`)
const data = `
import { t } from '@lingui/macro'
export function genres(){
const data = ${inspect(result, { maxArrayLength: null }).replace(
/t: '(?<name>.*)'/g,
't: t`$<name>`'
)}
return data
}`
const formatted = prettier.format(data, {
...prettierConfig,
parser: 'babel'
})
file.write(formatted)
file.end()
function genres() {
return [
'Pop',
'Rock',
'Punk',
'Punk Rock',
'Progressive Rock',
'Metal',
'Heavy Metal',
'Alternative Rock',
'Gospel',
'Trap',
'Hard Rock',
'Hardcore',
'Instrumental',
'Folk',
'Dance',
'Country',
'Rhythm And Blues',
'Garage',
'Grime',
'Gangsta Rap',
'Soul',
'House',
'Techno',
'Jungle',
'Ambient',
'Trance',
'Freestyle',
'Drum And Bass',
'Funk',
'Funky',
'Minimal',
'Disco',
'Reggae',
'Electronic',
'Electro',
'Breakbeat',
'Swing',
'World',
'Tech House',
'Progressive House',
'Indie',
'Deep House',
'Deep Techno',
'Grunge',
'New Wave',
'Salsa',
'Reggaeton',
'Ska',
'K-pop',
'Classical',
'Rap',
'Hip Hop',
'Latin',
'Jazz',
'Blues',
'Psychedelic Rock'
]
}