-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddmod
executable file
·48 lines (35 loc) · 1.19 KB
/
addmod
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
#!/usr/bin/env python3
#
# Shitty script to quick set up new packages
#
import os
import json
mod = {}
mod['name'] = input('Название модуля\n> ')
mod['desc'] = input('Краткое описание\n> ')
mod['main'] = input('Главный файл\n[index.js]> ') or 'index.js'
mod['deps'] = input('Зависимости\n[core.namespace]> ').split()
if not len(mod['deps']):
mod['deps'] = ['core.namespace']
modsuper = 'core.' + mod['name'].split('.')[0]
mod['before'] = input('Зависимое\n['+ modsuper +']> ').split()
if not len(mod['before']):
mod['before'] = [modsuper]
mod['deps_npm'] = input('Требуемые модули npm\n> ').split()
if not len(mod['deps_npm']):
mod['deps_npm'] = []
mod['deps_files'] = input('Требуемые файлы\n> ').split()
if not len(mod['deps_files']):
mod['deps_files'] = []
moddir = mod['name'].replace('.', '/', 1);
try:
os.mkdir('modules/' + moddir)
except:
pass
metafile = open('modules/' + moddir + '/module.json', 'w')
mainfile = open('modules/' + moddir + '/' + mod['main'], 'a')
metafile.write(json.dumps(mod, indent='\t', ensure_ascii=False))
mainfile.write('')
metafile.close()
mainfile.close()
print ('Готово!')