-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·47 lines (38 loc) · 1 KB
/
index.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
#!/usr/bin/env node
import inquirer from 'inquirer'
import fs from 'fs'
function createEntity() {
const entityName = process.argv[3]
const entityTemplate = `
import type { EntitySchema } from '@metaid/metaid'
const ${entityName}Schema: EntitySchema = {
name: '${entityName}',
nodeName: '', // the name of the brfc node
versions: [
{
version: 1,
id: "", // the brfc id of the node
body: [ // the body of the brfc node
]
}
]
}
export default ${entityName}Schema
`
let useDir
// 1. determine if user has src folder
if (fs.existsSync('./src')) {
if (!fs.existsSync('./src/metaid-entities')) {
fs.mkdirSync('./src/metaid-entities')
}
useDir = './src/metaid-entities'
} else {
if (!fs.existsSync('./metaid-entities')) {
fs.mkdirSync('./metaid-entities')
}
useDir = './metaid-entities'
}
fs.writeFileSync(`${useDir}/${entityName}.entity.ts`, entityTemplate)
console.log(`🚀 ${entityName}.entity.ts created! 🚀`)
}
createEntity()