Add Elixir and Phoenix framework module

This commit is contained in:
Han Ngo 2017-07-08 12:29:03 +07:00
parent f236344fc8
commit 1a34574498
6 changed files with 224 additions and 0 deletions

57
modules/elixir/README.md Normal file
View file

@ -0,0 +1,57 @@
Elixir
=============
Defines [Elixir][1] aliases.
Aliases
-------
- `i`='iex' runs interactive elixir
- `ips`='iex -S mix phoenix.server' runs iex in phoenix app
- `ism`='iex -S mix' runs iex in current elixir package
- `m`='mix' runs the default task
- `mr`='mix run' runs the given file or expression
- `mrnh`='mix run --no-halt' does not halt the system after running the command
- `mrl`='mix release' build an executable release (require [distillery](https://github.com/bitwalker/distillery))
- `mt`='mix test' runs a project's tests
- `mts`='mix test --stale' runs only tests which reference modules that changed since the last `test --stale`
- `mx`='mix xref' performs cross reference checks
- `mn`='mix new' creates a new Elixir project
- `mns`='mix new --sup' creates a new Elixir project with a supervision tree
- `mat`='mix app.tree' prints the application tree
- `mab`='mix archive.build' archives this project into a .ez file
- `mai`='mix archive.install' installs an archive locally
- `mc`='mix compile' compiles source files
- `mcv`='mix compile --verbose' compiles source files with verbose mode
- `mcx`='mix compile.xref' performs remote dispatch checking
- `mcr`='mix credo' analyze static code
- `mcrs`='mix credo --strict'
- `mdc`='mix deps.compile' compiles dependencies
- `mdg`='mix deps.get' gets all out of date dependencies
- `mdt`='mix deps.tree' prints the dependency tree
- `mdu`='mix deps.update' updates the given dependencies
- `mdua`='mix deps.update --all' updates all dependencies
- `mdun`='mix deps.unlock' unlocks the given dependencies
- `mduu`='mix deps.unlock --unused' unlocks unused dependencies
- `mdgc`='mix do deps.get, deps.compile' get all dependencies then compiles them
- `meb`='mix escript.build' builds an escript for the project
- `mho`='mix hex.outdated' shows outdated Hex deps for the current projects
- `mlh`='mix local.hex' installs Hex locally
Authors
-------
*The authors of this module should be contacted via the [issue tracker][2].*
- [Han Ngo](https://github.com/tieubao)
[1]: https://elixir-lang.org
[2]: https://github.com/sorin-ionescu/prezto/issues

53
modules/elixir/alias.zsh Normal file
View file

@ -0,0 +1,53 @@
#
# Defines Mix Elixir aliases.
#
# Authors:
# Han Ngo <nntruonghan@gmail.com>
#
# IEx
alias i='iex'
alias ips='iex -S mix phoenix.server'
alias ism='iex -S mix'
# Mix
alias m='mix'
alias mr='mix run'
alias mrnh='mix run --no-halt'
alias mrl='mix release'
alias mt='mix test'
alias mts='mix test --stale'
alias mtw='mix test.watch'
alias mx='mix xref'
alias mn='mix new'
alias mns='mix new --sup'
alias mat='mix app.tree'
alias mab='mix archive.build'
alias mai='mix archive.install'
alias mc='mix compile'
alias mcv='mix compile --verbose'
alias mcx='mix compile.xref'
alias mcr='mix credo'
alias mcrs='mix credo --strict'
alias mdc='mix deps.compile'
alias mdg='mix deps.get'
alias mdu='mix deps.update'
alias mdt='mix deps.tree'
alias mdua='mix deps.update --all'
alias mdun='mix deps.unlock'
alias mduu='mix deps.unlock --unused'
alias mdgc='mix do deps.get, deps.compile'
alias meb='mix escript.build'
alias mho='mix hex.outdated'
alias mlh='mix local.hex'
mncd() {
arg="$*"
mix new "$arg";cd "$arg";
}

14
modules/elixir/init.zsh Normal file
View file

@ -0,0 +1,14 @@
#
# Defines Elixir aliases.
#
# Authors:
# Han Ngo <nntruonghan@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[elixir] )); then
return 1
fi
# Source module files.
source "${0:h}/alias.zsh"

45
modules/phoenix/README.md Normal file
View file

@ -0,0 +1,45 @@
Phoenix Framework
=============
Defines [Elixir Phoenix][1] aliases.
Aliases
-------
- `mpn`='mix phoenix.new'
- `mpr`='mix phoenix.routes'
- `mps`='mix phoenix.server'
- `mpgc`='mix phoenix.gen.channel' generates a Phoenix channel
- `mpgh`='mix phoenix.gen.html' generates controller, views, and context for an HTML resource
- `mpgj`='mix phoenix.gen.json' generates controller, views, and context for a JSON resource
- `mpgm`='mix phoenix.gen.model' generates an Ecto model in your Phoenix application
- `mpgs`='mix phoenix.gen.secret' generates a secret
- `mec`='mix ecto.create' creates the repository storage
- `med`='mix ecto.drop' drops the repository storage
- `mem`='mix ecto.migrate' runs the repository migrations
- `megm`='mix ecto.gen.migration' generates a new migration for the repo
- `merb`='mix ecto.rollback' rolls back the repository migrations
- `mecm`='mix do ecto.create, ecto.migrate' creates the repository storage then start migration
- `kd`='kiex default' sets default elixir version with specific version
- `ki`='kiex install' installs a known release or branch
- `kl`='kiex list' lists installed versions
- `klb`='kiex list branches' lists current branches
- `klk`='kiex list known' lists known releases
- `klr`='kiex list releases' lists known releases
- `ks`='kiex shell' uses sub-shell with specific elixir version
- `ksu`='kiex selfupdate' upgrades kiex
- `ku`='kiex use' use specific elixir version
Authors
-------
*The authors of this module should be contacted via the [issue tracker][2].*
- [Han Ngo](https://github.com/tieubao)
[1]: http://www.phoenixframework.org
[2]: https://github.com/sorin-ionescu/prezto/issues

38
modules/phoenix/alias.zsh Normal file
View file

@ -0,0 +1,38 @@
#
# Defines Mix Elixir & Phoenix aliases.
#
# Authors:
# Han Ngo <nntruonghan@gmail.com>
#
# Mix Phoenix
alias mpn='mix phoenix.new'
alias mpr='mix phoenix.routes'
alias mps='mix phoenix.server'
alias mpgc='mix phoenix.gen.channel'
alias mpgh='mix phoenix.gen.html'
alias mpgj='mix phoenix.gen.json'
alias mpgm='mix phoenix.gen.model'
alias mpgs='mix phoenix.gen.secret'
# Mix Ecto
alias mec='mix ecto.create'
alias med='mix ecto.drop'
alias mem='mix ecto.migrate'
alias megm='mix ecto.gen.migration'
alias merb='mix ecto.rollback'
alias mers='mix ecto.reset'
alias mes='mix ecto.setup'
alias mecm='mix do ecto.create, ecto.migrate'
# Kiex - Elixir Version Manager: https://github.com/taylor/kiex
alias kd='kiex default'
alias ki='kiex install'
alias kl='kiex list'
alias klb='kiex list branches'
alias klk='kiex list known'
alias klr='kiex list releases'
alias ks='kiex shell'
alias ksu='kiex selfupdate'
alias ku='kiex use'

17
modules/phoenix/init.zsh Normal file
View file

@ -0,0 +1,17 @@
#
# Defines Mix Phoenix aliases.
#
# Authors:
# Han Ngo <nntruonghan@gmail.com>
#
# Load dependencies.
pmodload 'elixir'
# Return if requirements are not found.
if (( ! $+commands[mix phoenix.new] )); then
return 1
fi
# Source module files.
source "${0:h}/alias.zsh"