-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphoenix.py
101 lines (91 loc) · 3.18 KB
/
phoenix.py
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
## @file
## @brief Phoenix/Elixir stack
# from metaL import *
from elixir import *
class phModule(lxModule):
def init_apt(self):
super().init_apt()
self.apt // 'nodejs' // 'inotify-tools'
self.apt.sync()
def init_mk(self):
super().init_mk()
self.mk.all //\
'$(MIX) phx.server'
self.mk.repl.drop() //\
'$(IEX) -S $(MIX) phx.server'
self.mk.sync()
def init_readme_install(self):
return super().init_readme_install() //\
'* https://hexdocs.pm/phoenix/installation.html'
def init_readme_tutorial(self):
return super().init_readme_tutorial() //\
(D('### Phoenix') //
D() //
'* Pete Corey [Minimum Viable Phoenix](http://www.petecorey.com/blog/2019/05/20/minimum-viable-phoenix/)' //
'* José Valim [GOTO 2016 Phoenix a Web Framework for the New Web](https://www.youtube.com/watch?v=bk3icU8iIto)' //
'* Elixir School [Plug](https://elixirschool.com/ru/lessons/specifics/plug/) /ru/' //
D()
)
# `/mix.exs`
def init_elixir_mix(self):
super().init_elixir_mix()
self.mix.deps //\
'{:phoenix, "~> 1.5"},' //\
'{:jason, "~> 1.2"},' //\
'{:plug_cowboy, "~> 2.4"},'
self.mix.sync()
def init_elixir(self):
super().init_elixir()
self.ex.mod //\
(S('def start(mode,opt) do', 'end') //
'IO.puts("module:<#{__MODULE__}> mode:<#{mode}> opt:<#{opt}>")' //
'{:ok, self()}'
)
self.ex.sync()
self.init_elixir_web()
def init_elixir_web(self):
#
self.mix.application //\
f'mod: {{{self:m}.Application, []}},'
#
self.ex.endpoint = Section('endpoint')
self.ex // self.ex.endpoint
self.ex.endpoint //\
(S(f'defmodule {self:m}.Endpoint do', 'end') // '')
#
self.mix.sync()
self.ex.sync()
def init_config(self):
super().init_config()
#
self.config.lx = Dir('config')
self.diroot // self.config.lx
self.config.lx.sync()
#
self.config.lx.config = exsFile('config')
self.config.lx // self.config.lx.config
self.config.lx.config //\
(D() // 'use Mix.Config') //\
(D() //
'config :phoenix, :json_library, Jason' //
'# config :phoenix, :serve_endpoints, true'
) //\
(D() //
'# config :exsync, extra_extensions: []' //
'# config :exsync, src_monitor: false'
) //\
(D() // 'import_config "#{Mix.env()}.exs"')
#
self.config.lx.dev = exsFile('dev')
self.config.lx // self.config.lx.dev
self.config.lx.dev //\
(D() // S('use Mix.Config')) //\
(D() //
(S(f"config :{self:l}, {self:m}.Endpoint,") //
f'url: [host: "{self.config.host}"],' //
f'http: [port: {self.config.port}],' //
'server: true'
))
#
self.config.lx.config.sync()
self.config.lx.dev.sync()