Skip to content

Commit 0886910

Browse files
committed
Initial commit
0 parents  commit 0886910

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+13405
-0
lines changed

.credo.exs

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# This file contains the configuration for Credo and you are probably reading
2+
# this after creating it with `mix credo.gen.config`.
3+
#
4+
# If you find anything wrong or unclear in this file, please report an
5+
# issue on GitHub: https://github.com/rrrene/credo/issues
6+
#
7+
%{
8+
#
9+
# You can have as many configs as you like in the `configs:` field.
10+
configs: [
11+
%{
12+
#
13+
# Run any exec using `mix credo -C <name>`. If no exec name is given
14+
# "default" is used.
15+
#
16+
name: "default",
17+
#
18+
# These are the files included in the analysis:
19+
files: %{
20+
#
21+
# You can give explicit globs or simply directories.
22+
# In the latter case `**/*.{ex,exs}` will be used.
23+
#
24+
included: ["lib/", "src/", "web/", "apps/"],
25+
excluded: [~r"/_build/", ~r"/deps/"]
26+
},
27+
#
28+
# If you create your own checks, you must specify the source files for
29+
# them here, so they can be loaded by Credo before running the analysis.
30+
#
31+
requires: [],
32+
#
33+
# If you want to enforce a style guide and need a more traditional linting
34+
# experience, you can change `strict` to `true` below:
35+
#
36+
strict: false,
37+
#
38+
# If you want to use uncolored output by default, you can change `color`
39+
# to `false` below:
40+
#
41+
color: true,
42+
#
43+
# You can customize the parameters of any check by adding a second element
44+
# to the tuple.
45+
#
46+
# To disable a check put `false` as second element:
47+
#
48+
# {Credo.Check.Design.DuplicatedCode, false}
49+
#
50+
checks: [
51+
{Credo.Check.Consistency.ExceptionNames},
52+
{Credo.Check.Consistency.LineEndings},
53+
{Credo.Check.Consistency.ParameterPatternMatching},
54+
{Credo.Check.Consistency.SpaceAroundOperators},
55+
{Credo.Check.Consistency.SpaceInParentheses},
56+
{Credo.Check.Consistency.TabsOrSpaces},
57+
58+
# For some checks, like AliasUsage, you can only customize the priority
59+
# Priority values are: `low, normal, high, higher`
60+
#
61+
{Credo.Check.Design.AliasUsage, priority: :low},
62+
63+
# For others you can set parameters
64+
65+
# If you don't want the `setup` and `test` macro calls in ExUnit tests
66+
# or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just
67+
# set the `excluded_macros` parameter to `[:schema, :setup, :test]`.
68+
#
69+
{Credo.Check.Design.DuplicatedCode, excluded_macros: []},
70+
71+
# You can also customize the exit_status of each check.
72+
# If you don't want TODO comments to cause `mix credo` to fail, just
73+
# set this value to 0 (zero).
74+
#
75+
{Credo.Check.Design.TagTODO, exit_status: 2},
76+
{Credo.Check.Design.TagFIXME},
77+
78+
{Credo.Check.Readability.FunctionNames},
79+
{Credo.Check.Readability.LargeNumbers},
80+
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
81+
{Credo.Check.Readability.ModuleAttributeNames},
82+
{Credo.Check.Readability.ModuleDoc},
83+
{Credo.Check.Readability.ModuleNames},
84+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs},
85+
{Credo.Check.Readability.ParenthesesInCondition},
86+
{Credo.Check.Readability.PredicateFunctionNames},
87+
{Credo.Check.Readability.PreferImplicitTry},
88+
{Credo.Check.Readability.RedundantBlankLines},
89+
{Credo.Check.Readability.StringSigils},
90+
{Credo.Check.Readability.TrailingBlankLine},
91+
{Credo.Check.Readability.TrailingWhiteSpace},
92+
{Credo.Check.Readability.VariableNames},
93+
{Credo.Check.Readability.Semicolons},
94+
{Credo.Check.Readability.SpaceAfterCommas},
95+
96+
{Credo.Check.Refactor.DoubleBooleanNegation},
97+
{Credo.Check.Refactor.CondStatements},
98+
{Credo.Check.Refactor.CyclomaticComplexity},
99+
{Credo.Check.Refactor.FunctionArity},
100+
{Credo.Check.Refactor.LongQuoteBlocks},
101+
{Credo.Check.Refactor.MatchInCondition},
102+
{Credo.Check.Refactor.NegatedConditionsInUnless},
103+
{Credo.Check.Refactor.NegatedConditionsWithElse},
104+
{Credo.Check.Refactor.Nesting},
105+
{Credo.Check.Refactor.PipeChainStart},
106+
{Credo.Check.Refactor.UnlessWithElse},
107+
108+
{Credo.Check.Warning.BoolOperationOnSameValues},
109+
{Credo.Check.Warning.IExPry},
110+
{Credo.Check.Warning.IoInspect},
111+
{Credo.Check.Warning.LazyLogging},
112+
{Credo.Check.Warning.OperationOnSameValues},
113+
{Credo.Check.Warning.OperationWithConstantResult},
114+
{Credo.Check.Warning.UnusedEnumOperation},
115+
{Credo.Check.Warning.UnusedFileOperation},
116+
{Credo.Check.Warning.UnusedKeywordOperation},
117+
{Credo.Check.Warning.UnusedListOperation},
118+
{Credo.Check.Warning.UnusedPathOperation},
119+
{Credo.Check.Warning.UnusedRegexOperation},
120+
{Credo.Check.Warning.UnusedStringOperation},
121+
{Credo.Check.Warning.UnusedTupleOperation},
122+
{Credo.Check.Warning.RaiseInsideRescue},
123+
124+
# Controversial and experimental checks (opt-in, just remove `, false`)
125+
#
126+
{Credo.Check.Refactor.ABCSize, false},
127+
{Credo.Check.Refactor.AppendSingleItem, false},
128+
{Credo.Check.Refactor.VariableRebinding, false},
129+
{Credo.Check.Warning.MapGetUnsafePass, false},
130+
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
131+
132+
# Deprecated checks (these will be deleted after a grace period)
133+
#
134+
{Credo.Check.Readability.Specs, false},
135+
{Credo.Check.Warning.NameRedeclarationByAssignment, false},
136+
{Credo.Check.Warning.NameRedeclarationByCase, false},
137+
{Credo.Check.Warning.NameRedeclarationByDef, false},
138+
{Credo.Check.Warning.NameRedeclarationByFn, false},
139+
140+
# Custom checks can be created using `mix credo.gen.check`.
141+
#
142+
]
143+
}
144+
]
145+
}

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{ex,eex,exs,ts,tsx,json}]
12+
indent_style = space
13+
indent_size = 2

.env

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# These environment variables are set and only used during development
2+
# and building production tarball.
3+
4+
# Host used in development
5+
export CADET_HOST=0.0.0.0
6+
7+
# Hostname of production server
8+
export CADET_PROD_HOST=https://sourceacademy.comp.nus.edu.sg/
9+
10+
# Port which Phoenix should be serving from in development
11+
export CADET_SERVER_PORT=4000
12+
13+
# Port which Webpack should be serving from in development
14+
export CADET_WEBPACK_PORT=4001
15+
16+
# Webpack entry filename
17+
export CADET_WEBPACK_ENTRY=app

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# App artifacts
2+
/_build
3+
/db
4+
/deps
5+
/*.ez
6+
/priv/static
7+
8+
# Generated on crash by the VM
9+
erl_crash.dump
10+
11+
# Files matching config/*.secret.exs pattern contain sensitive
12+
# data and you should not commit them into version control.
13+
#
14+
# Alternatively, you may comment the line below and commit the
15+
# secrets files as long as you replace their contents by environment
16+
# variables.
17+
/config/*.secret.exs

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.rulers": [80],
4+
"tslint.enable": true,
5+
"tslint.run": "onSave",
6+
"tslint.autoFixOnSave": true,
7+
"tslint.nodePath": "./frontend/node_modules",
8+
"typescript.tsdk": "./frontend/node_modules/typescript/lib"
9+
}

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Cadet
2+
3+
Cadet is the web application powering Source Academy.
4+
5+
### System Requirements
6+
7+
1. Elixir 1.4
8+
1. Erlang/OTP 20.1
9+
1. Recent stable NodeJS version (>= 6.0)
10+
1. PostgreSQL (>= 9.6)
11+
12+
**Important Note** Unlike the other three, Erlang/OTP version requirement is EXACT in order
13+
for the generated server binaries to be able to run in production.
14+
15+
Ensure that the following command produces 20.1 as its output.
16+
```
17+
erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell
18+
```
19+
20+
Read DEVELOPING.md for more in-depth guide to setup development environment.
21+
22+
### Getting Started
23+
24+
1. Install Elixir dependencies using `mix deps get`
25+
1. Initialise database using `mix ecto.setup`
26+
1. Run the server using `mix phx.server`
27+
1. Run the unit tests using `mix test`
28+
29+
### License
30+
MIT

config/config.exs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file is responsible for configuring your application
2+
# and its dependencies with the aid of the Mix.Config module.
3+
#
4+
# This configuration file is loaded before any dependency and
5+
# is restricted to this project.
6+
use Mix.Config
7+
8+
# General application configuration
9+
config :cadet,
10+
ecto_repos: [Cadet.Repo]
11+
12+
# Configures the endpoint
13+
config :cadet, CadetWeb.Endpoint,
14+
url: [host: "localhost"],
15+
secret_key_base: "ueV6EWi+7MCMcJH/WZZVKPZbQxFix7tF1Xv9ajD4AN4jLowHbdUX33rmKWPvEEgz",
16+
render_errors: [view: CadetWeb.ErrorView, accepts: ~w(html json)],
17+
pubsub: [name: Cadet.PubSub,
18+
adapter: Phoenix.PubSub.PG2]
19+
20+
# Configures Elixir's Logger
21+
config :logger, :console,
22+
format: "$time $metadata[$level] $message\n",
23+
metadata: [:request_id]
24+
25+
# Import environment specific config. This must remain at the bottom
26+
# of this file so it overrides the configuration defined above.
27+
import_config "#{Mix.env}.exs"

config/dev.exs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use Mix.Config
2+
3+
config :cadet, environment: :dev
4+
5+
# For development, we disable any cache and enable
6+
# debugging and code reloading.
7+
#
8+
# The watchers configuration can be used to run external
9+
# watchers to your application. For example, we use it
10+
# with brunch.io to recompile .js and .css sources.
11+
config :cadet, CadetWeb.Endpoint,
12+
http: [port: 4000],
13+
debug_errors: true,
14+
code_reloader: true,
15+
check_origin: false,
16+
watchers: [
17+
node: [
18+
"scripts/start.js",
19+
cd: Path.expand("../frontend", __DIR__)
20+
]
21+
]
22+
23+
# ## SSL Support
24+
#
25+
# In order to use HTTPS in development, a self-signed
26+
# certificate can be generated by running the following
27+
# command from your terminal:
28+
#
29+
# openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem
30+
#
31+
# The `http:` config above can be replaced with:
32+
#
33+
# https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"],
34+
#
35+
# If desired, both `http:` and `https:` keys can be
36+
# configured to run both http and https servers on
37+
# different ports.
38+
39+
# Watch static and templates for browser reloading.
40+
config :cadet, CadetWeb.Endpoint,
41+
live_reload: [
42+
patterns: [
43+
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
44+
~r{priv/gettext/.*(po)$},
45+
~r{lib/cadet_web/views/.*(ex)$},
46+
~r{lib/cadet_web/templates/.*(eex)$}
47+
]
48+
]
49+
50+
# Do not include metadata nor timestamps in development logs
51+
config :logger, :console, format: "[$level] $message\n"
52+
53+
# Set a higher stacktrace during development. Avoid configuring such
54+
# in production as building large stacktraces may be expensive.
55+
config :phoenix, :stacktrace_depth, 20
56+
57+
# Configure your database
58+
config :cadet, Cadet.Repo,
59+
adapter: Ecto.Adapters.Postgres,
60+
username: "postgres",
61+
password: "postgres",
62+
database: "cadet_dev",
63+
hostname: "localhost",
64+
pool_size: 10

config/prod.exs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use Mix.Config
2+
3+
# For production, we often load configuration from external
4+
# sources, such as your system environment. For this reason,
5+
# you won't find the :http configuration below, but set inside
6+
# CadetWeb.Endpoint.init/2 when load_from_system_env is
7+
# true. Any dynamic configuration should be done there.
8+
#
9+
# Don't forget to configure the url host to something meaningful,
10+
# Phoenix uses this information when generating URLs.
11+
#
12+
# Finally, we also include the path to a cache manifest
13+
# containing the digested version of static files. This
14+
# manifest is generated by the mix phx.digest task
15+
# which you typically run after static files are built.
16+
config :cadet, CadetWeb.Endpoint,
17+
load_from_system_env: true,
18+
url: [host: "example.com", port: 80],
19+
cache_static_manifest: "priv/static/cache_manifest.json"
20+
21+
# Do not print debug messages in production
22+
config :logger, level: :info
23+
24+
# ## SSL Support
25+
#
26+
# To get SSL working, you will need to add the `https` key
27+
# to the previous section and set your `:url` port to 443:
28+
#
29+
# config :cadet, CadetWeb.Endpoint,
30+
# ...
31+
# url: [host: "example.com", port: 443],
32+
# https: [:inet6,
33+
# port: 443,
34+
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
35+
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
36+
#
37+
# Where those two env variables return an absolute path to
38+
# the key and cert in disk or a relative path inside priv,
39+
# for example "priv/ssl/server.key".
40+
#
41+
# We also recommend setting `force_ssl`, ensuring no data is
42+
# ever sent via http, always redirecting to https:
43+
#
44+
# config :cadet, CadetWeb.Endpoint,
45+
# force_ssl: [hsts: true]
46+
#
47+
# Check `Plug.SSL` for all available options in `force_ssl`.
48+
49+
# ## Using releases
50+
#
51+
# If you are doing OTP releases, you need to instruct Phoenix
52+
# to start the server for all endpoints:
53+
#
54+
# config :phoenix, :serve_endpoints, true
55+
#
56+
# Alternatively, you can configure exactly which server to
57+
# start per endpoint:
58+
#
59+
# config :cadet, CadetWeb.Endpoint, server: true
60+
#
61+
62+
# Finally import the config/prod.secret.exs
63+
# which should be versioned separately.
64+
import_config "prod.secret.exs"

0 commit comments

Comments
 (0)