-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dev
executable file
·53 lines (43 loc) · 1.82 KB
/
dev
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
#!/usr/bin/env python3
import argparse
import os
from subprocess import call
import sys
parser = argparse.ArgumentParser(prog='./dev')
subparsers = parser.add_subparsers(metavar='<command>', title='commands')
DOCKER_RUN = ['docker', 'run', '--init', '-it', '--rm', '-v',
os.getcwd() + ':/src:cached', '-w=/src', 'node:18.16.0-alpine']
def start(args, remaining):
call(DOCKER_RUN + ['yarn', 'install'])
call(DOCKER_RUN + ['yarn', 'run', 'generate:watch'])
parser_start = subparsers.add_parser('start',
help='initialize the development environment')
parser_start.set_defaults(func=start)
def format(args, remaining):
call(DOCKER_RUN + ['yarn', 'run', 'format'])
parser_format = subparsers.add_parser('format', help='format the code')
parser_format.set_defaults(func=format)
def lint(args, remaining):
call(DOCKER_RUN + ['yarn', 'run', 'lint'])
parser_lint = subparsers.add_parser('lint', help='lint the code')
parser_lint.set_defaults(func=lint)
def sh(args, remaining):
call(DOCKER_RUN + ['sh'])
parser_sh = subparsers.add_parser('sh', help='bring up a shell')
parser_sh.set_defaults(func=sh)
def yarn(args, remaining):
call(DOCKER_RUN + ['yarn'] + remaining or [])
parser_yarn = subparsers.add_parser('yarn', help='run a yarn command')
parser_yarn.set_defaults(func=yarn)
def generate(args, remaining):
call(DOCKER_RUN + ['yarn', 'run',
'generate' + (':watch' if args.watch else '')])
parser_generate = subparsers.add_parser('generate', help='generate the themes')
parser_generate.add_argument('-w', '--watch', action='store_true',
help='watch for file changes, and regenerate')
parser_generate.set_defaults(func=generate)
if len(sys.argv) > 1:
args, remaining = parser.parse_known_args()
args.func(args, remaining)
else:
parser.print_help()