-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLivefile
86 lines (69 loc) · 2.55 KB
/
Livefile
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
# REQUIRES ############################
# OPTIONS #############################
option \cmd, \c, \String, 'command to use (with the `cmd` task)'
option \github, \g, \Boolean, ''
option \id, \p, \Int, 'project id'
option \list, \l, \Boolean, 'list all command of a project'
option \release, \r, \Boolean, ''
option \watch, \w, \Boolean, '(only for dev mode)'
# GLOBAL ##############################
global.cfg = {}
# FUNCTIONS ###########################
execute = (opts, tsk) !->
require! { './core/config', './core/tasker' }
cfg <<<< config.cfg
[cfg.dest, cfg.release, cfg.github] = switch
| opts.github => [cfg.dest_path.github, yes, yes]
| opts.release => [cfg.dest_path.release, yes, no ]
| _ => [cfg.dest_path.debug, no, no ]
tasker[tsk] opts
# TEST ################################
task \wasm, '', !->
#
require! './core/builder'
#
builder.wasm-pack builder.final-cb
#
# TASKS ###############################
task \all, 'compile all active projects', (opts) !->
execute opts, \all
task \clean, 'remove `dist`', (opts) !->
execute opts, \clean
task \cmd, 'execute a command in a project', (opts) !->
execute ({} <<< opts <<< {github: no, release: no}), \command
task \compile, 'compile one project (USE PROJECT ID!)', (opts) !->
execute ({} <<< opts <<< {github: no}), \compile #, release: no}), \compile
task \create, 'create a new project', (opts) !->
execute opts, \create
task \esm, '', !->
require! { 'fs-extra': fse, 'prelude-ls': { List, Str } }
excluded = <[ esm cookies local-storage ]>
predicate = (file) ->
splt = file.split \.
splt.0 not in excluded and splt.1 is \ls
exported = []
data = ''
exporting = -> "\n``export { #{exported.join ', '} }``"
extract-export = (line) ->
if line == /^export/
splt = line.split ' '
if splt.1 is \class then splt.2 else splt.1
|> (.replace '\r' '')
|> Str.camelize
|> exported.push
line.substring 7
else line
for file in fse.readdirSync \./utils when predicate file
console.log "including '#file'..."
a = fse.readFileSync "./utils/#file", \utf-8
|> Str.lines
|> List.map extract-export
|> Str.unlines
|> (++ '\n\n')
|> (data ++=)
fse.writeFileSync \./utils/esm.ls, (data ++ exporting!)
console.log 'utils exported as ESM'
task \list, 'list all projects actually available', (_) !->
execute {}, \list
task \serve, 'launch the server to get access to the projects', (opts) !->
execute ({} <<< opts <<< {github: no}), \serve #, release: no}), \serve