Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
erl_crash.dump
*.ez
plum_mail-*.tar

src/glance/config.gleam
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gleamlang/gleam:0.12.1
FROM gleamlang/gleam:0.13.2

# NOTE these two should not be needed if using the midas container
WORKDIR /opt/app
Expand All @@ -7,8 +7,9 @@ RUN mix local.hex --force && mix local.rebar --force
COPY . .
RUN mix deps.get
# NOTE there is a bug which means gleam_otp is not compiling properly
RUN gleam build && mix compile
# Unsure why this step is necessay with compilation orders with Gleam + Mix
RUN mix test --no-start --exclude test
# TODO
# RUN mix deps.compile env && gleam build && mix compile
# # Unsure why this step is necessay with compilation orders with Gleam + Mix
# RUN mix test --no-start --exclude test

CMD ["./bin/start"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ This app uses the container stack.
```
heroku stack:set -a did-glance container
```


gleam build-stuff providers
escript provide env env.spec
4 changes: 4 additions & 0 deletions env/.formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
8 changes: 8 additions & 0 deletions env/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/_build/
/deps/
/doc/
/gen/
/.fetch
erl_crash.dump
*.ez
plum_mail-*.tar
1 change: 1 addition & 0 deletions env/gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = "env"
28 changes: 28 additions & 0 deletions env/lib/mix/tasks/compiler/env.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Mix.Tasks.Compile.Env do
use Mix.Task.Compiler

def run(_args) do
# case Mix.shell().cmd(
# # "gleam compile-package --src /opt/app/provider --name provider --out /opt/app/src/provider"
# "gleam build /opt/app/provider"
# ) do
# 0 -> {:ok, []}
# status -> exit(status)
# end
IO.inspect(:code.all_loaded())

# root = Application.app_dir(:glance)
root = System.cwd()

Path.wildcard(root <> "/src/**/*.env")
|> Enum.each(fn file ->
contents =
File.read!(file)
|> :[email protected]()

File.write(String.replace(file, ".env", ".gleam"), contents)
end)

:ok
end
end
28 changes: 28 additions & 0 deletions env/mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Env.MixProject do
use Mix.Project

def project do
[
app: :env,
version: "0.1.0",
elixir: "~> 1.11",
start_permanent: Mix.env() == :prod,
erlc_paths: ["src", "gen"],
compilers: [:gleam | Mix.compilers()],
deps: deps()
]
end

def application do
[
extra_applications: [:logger]
]
end

defp deps do
[
{:mix_gleam, "~> 0.1.0"},
{:gleam_stdlib, "~> 0.13.0"}
]
end
end
4 changes: 4 additions & 0 deletions env/mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%{
"gleam_stdlib": {:hex, :gleam_stdlib, "0.13.0", "604a40e0fbe6c688651a5ad5e892913ed314ab626d18d361a7fd8bf367907551", [:rebar3], [], "hexpm", "35a005f4daca2775687e46f4e20cec799563a698a16f8bcc0cf281522ad717f1"},
"mix_gleam": {:hex, :mix_gleam, "0.1.0", "a0cee5d30de865124a32ca6cd53b64c3e2ac57f12adf6e47b88fb673f47c716e", [:mix], [], "hexpm", "9ff518e6aab444c7f2e74038f9383020ef89810cf1f4402911f33b202ffd72e7"},
}
30 changes: 30 additions & 0 deletions env/src/gleam/env.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

// escript gleam_providers "gleam/env" "filename"
// generate "escript fof"
// call already running
// This is useful as is.
// Can generate from .spec.json
// Do mix deps.compile
// Have a providers compiler
// Load up all modules called provider
// Find extension from provider
// Read all files and pass them to the generate module
// gleam_providers as a package
// compile deps
// When running the mix task, it should have all deps
// called gleam@provider@something
// Mix gleam.provide json_schema "foo.com"
// Help with the rust, hash in to map of already defined
// but return no error in that case.

// Mix compilers -> escripts -> extension

// provide gleam/env
// Do the hard thing and call external BUT I have to do rust and a syntax

// Take the module
// search for a function and pass the arguments
// make it into a thing you blat down on it's own
// better than external OS command
// gleam/provider/csv.derive("foo.text") (foo.com)
// How to add dependency to escript, just looks like a function call
8 changes: 8 additions & 0 deletions env/test/env_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule EnvTest do
use ExUnit.Case
doctest Env

test "greets the world" do
assert Env.hello() == :world
end
end
1 change: 1 addition & 0 deletions env/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{application,gleam_providers,
[{applications,[kernel,stdlib,elixir,logger,mix_gleam,
gleam_stdlib]},
{description,"gleam_providers"},
{modules,['Elixir.GleamProviders.CLI',csv]},
{registered,[]},
{vsn,"0.1.0"}]}.
Empty file.
1 change: 1 addition & 0 deletions gleam_providers/_build/dev/lib/gleam_stdlib/ebin
5 changes: 5 additions & 0 deletions gleam_providers/_build/dev/lib/gleam_stdlib/mix.rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{erl_opts,[debug_info]}.
{src_dirs,["src","gen/src"]}.
{profiles,[{test,[{src_dirs,["src","test","gen/src","gen/test"]}]}]}.
{deps,[]}.
{overrides,[]}.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
6 changes: 6 additions & 0 deletions gleam_providers/_build/dev/lib/mix_gleam/ebin/mix_gleam.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{application,mix_gleam,
[{applications,[kernel,stdlib,elixir]},
{description,"Compile Gleam code with mix"},
{modules,['Elixir.Mix.Tasks.Compile.Gleam']},
{registered,[]},
{vsn,"0.1.0"}]}.
Empty file.
Binary file added gleam_providers/deps/gleam_stdlib/.hex
Binary file not shown.
Binary file not shown.
205 changes: 205 additions & 0 deletions gleam_providers/deps/gleam_stdlib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Changelog

## v0.13.0 - 2021-01-13

- The `int` module gains the `absolute_value`, `sum` and `product` functions.
- The `float` module gains the `sum` and `product` functions.
- The `result` module gains the `lazy_or`, `lazy_unwrap`, and `replace_error` functions.
- The `bool` module gains the `nand`, `nor`, `exclusive_nor`, and `exclusive_or` functions.
- The `bit_builder` module gains the `from_string_builder` function.
- The `list` modules gains the `index_fold`, `permutations`, and `try_fold` functions.
- Breaking change in `queue.from_list`. The head element in the list becomes the first element in the queue.
- Fix `queue.pop_back` and `queue.pop_front`

## v0.12.0 - 2020-11-04

- The `function` module gains `curry2` to `curry6`.
- The `list` module gains the `each`, and `partition` functions.
- The `int` and `float` modules gain the `negate` function.
- The `int` module gains the `to_float` function.
- The `result` module gains the `all` function.
- The `dynamic` module gains the `option`, `result` and `typed_result`
functions.
- The `uri` module gains the `percent_encode` and `percent_decode` functions.
- The `os` module gains the `erlang_timestamp` function.
- The `iterator` module gains the `append`, `flatten`, `flat_map`, `step`,
and `find` functions.

## v0.11.0 - 2020-08-22

- Fix `uri.parse_query` to handle the case where query parameters are present
without a value.
- The types for `list.find_map` have been relaxed.
- The `dynamic.typed_list` argument label has changed from `containing` to
`of`.
- The `dynamic` module gains the `any` function.
- The `bit_builder` module gains the `from_string` function.
- The `list` module gains the `key_set` and `unzip` function.
- The `function` module gains the `rescue` function.
- The `float` module gains the `power`, `square_root`, and `absolute_value`
functions.

## v0.10.1 - 2020-07-01

- Fix `dynamic.string` to check that binary contains only utf8 characters.

## v0.10.0 - 2020-06-30

- `bit_string` module created with `from_string`, `byte_size`, `append`,
`part`, `to_string`, `is_utf8`, `int_to_u32` and `int_from_u32` functions.
- The `bit_builder` module has been introduced with `prepend`, `append`,
`prepend_builder`, `append_builder`, `prepend_string`, `append_string`,
`concat`, `from_bit_string`, `to_bit_string`, and `byte_size` functions.
- The `iodata` module has been renamed to `string_builder`.
- `os` module created with `get_env`, `insert_env`, `delete_env` and
`system_time`.
- The `string` module gains the `split_once` and `utf_codepoint` functions.
- The `dynamic` module gains the `bit_string` function.
- The `uri` module gains the `origin` and `merge` function.
- The `io.debug` function returns the printed term.
- The `dynamic.list` function has been renamed to `dynamic.typed_list`.
- The `dynamic.opaque_list` function has been renamed to `dynamic.list`.
- The `dynamic.tuple2_of` function has been renamed to `dynamic.typed_tuple2`.
- The `list.traverse` function has been renamed to `list.try_map`.
- The `list.traverse` first argument gains the label `over`.
- The `option` module gains the the `map`, `flatten`, `then` and `or`
functions.
- The `result` module gains the the `or` function.
- Created the `regex` module with the `from_string`, `compile`, `check`,
`split` and `scan` functions.
- The `list` module gains the the `pop`, `pop_map` and `key_pop` functions.
- `base` module created with `encode64`, `decode64`, `url_encode64` and
`url_decode64`.

## v0.9.0 - 2020-05-26

- Created the `iterator` module with the `unfold`, `repeatedly`, `repeat`,
`from_list`, `fold`, `run`, `to_list`, `take`, `drop`, `map`, `filter`,
`cycle`, and `range` functions.
- Created the `set` module with the `new`, `insert`, `delete`, `to_list`,
`from_list`, `fold`, `take`, `union`, `intersection`, and `contains`
functions.
- Created the `io` module with the `print`, `println`, and `debug` functions.
- Created the `queue` module with the `new`, `from_list`, `to_list`,
`is_empty`, `length`, `push_back`, `push_front`, `pop_back`, `pop_front`,
`reverse`, `is_logically_equal`, and `is_equal` functions.
- Created the `option` module containing the `Option` type and the `is_some`
and `is_none` functions.
- Created the `option` module containing the `Option` type and the `is_some`,
`is_none`, `to_result`, `from_result` and `unwrap` functions.
- Removed the `Option` alias and the `none` function from the `result` module.
- The `result` module gains the `nil_error` function.
- The `string` module gains `trim`, `trim_left`, `trim_right`, `starts_with`,
`ends_with`, `slice`, `pad_left`, `pad_right` `drop_left`, `drop_right`,
`pop_grapheme` and `to_graphemes' functions.
- `uri` module created with `parse`, `parse_query`, `path_segments`,
`query_to_string` and `to_string`.
- The `dynamic` module gains the `map`, `opaque_list`, `tuple2`, and
`tuple2_of` functions.
- The `list` module gains the `filter_map` function.
- The `list.contains` label `has` has been changed to `any`.
- The `list.sort` label `sort_by` has been changed to `by`.
- The `list.fold`'s first argument gained the label `over`.
- The `map.fold`'s first argument gained the label `over`.
- The `map.take`'s `drop` arguement has been changed to `keeping`.

## v0.8.0 - 2020-04-28

- The error type for `atom.from_string` has been renamed to `FromStringError`.
- The `string` module gains `contains` and `repeat` functions.
- The `expect` module has been renamed to `should`. Functions in the module
starting with `is_` have been changed to `be_`.
- The `string.replace` and `iodata.replace` `all` arguement label has been
changed to `each`.
- The `string` module gains `is_empty`, `join` and `concat` functions.
- The `int` module gains `is_even` and `is_odd` functions.
- The `list.length` function now accepts a labelled argument.
- The `list.length` function now accepts a labelled argument.
- The the second argument of `bool.compare`, `float.compare`, `int.compare`,
and `order.compare` now have the label `with`.
- The `dynamic.unsafe_coerce` function now only accepts Dynamic data.
- The `dynamic` decoder functions no longer print the entire value in their
error messages, to avoid large errors.

## v0.7.0 - 2020-03-03

- The `result` module gains an `Option` type alias.
- The `function` module has been created with `identity`, `compose`, and
`flip` functions.
- The error type of `list.find_map` is now `Nil`.
- The labels for `list.split` are now `split(list: _, at: _)`.

## v0.6.0 - 2019-12-23

- Syntax has been updated for Gleam v0.6.0.
- The `dynamic` module gains an `element` for decoding tuples.

## v0.5.0 - 2019-12-16

- Syntax has been updated for Gleam v0.5.
- Labels have been added to functions throughout the stdlib.
- `map.fetch` has been renamed to `map.get` and `map.put` to `map.insert`.
- `list.find` has been renamed `list.find_map` and a new `list.find` has been
introduced.
- The `pair` module gains the `map_first`, and `map_second` functions.
- The `pair.Pair` type has been replaced with a 2 element anonymous struct.
- The `triple` module has been removed.
- The `string` module gains the `compare` function.
- The `float` module gains the `max`, and `min` functions.
- The `int` module gains the `max`, and `min` functions.
- The `Any` type and module have been renamed to `Dynamic`.

## v0.4.0 - 2019-09-19

- Syntax has been updated for Gleam v0.4.
- The `map_dict` module has been renamed to `map`.
- `list:sort` now requires a compare function as comparison operators
now only work on Ints.
- `list:sort`'s performance has been slightly optimised.
- The `float` module gains a `compare` function.
- `any.tuple` has been renamed `any.pair`.
- The `tuple` module has been renamed to `pair` and has a `Pair` type.
- `pair.fetch` has been replaced with `list.key_find`.
- `triple` module has been created with type `Triple`.
- The error type for `float.parse`, `int.parse`, `list.head`, `list.tail`,
`list.find`, `list.at`, `map.fetch`, and `map.update` is now `Nil`.

## v0.3.1 - 2019-08-08

- `result:map_error` has been relaxed to allow mapping to a different error
type.

## v0.3.0 - 2019-06-25

- The `map_dict` module gains a `fold` function.
- All modules moved under the `std` namespace.
- The `http` module has been split out into the `gleam_http` package.

## v0.2.0 - 2019-05-11

- Library renamed to `gleam_stdlib`.
- The `map_dict` module gains `update`, `merge` and `delete` functions.
- The `bool` module gains a `compare` function.
- The `int` module gains a `compare` function.
- The `list` module gains `range`, `repeat`, `split`, `split_while` and
`strict_zip` functions.

## v0.1.2 - 2019-04-25

- The `list` module gains `at`, `all`, `any`, `index_map`, `intersperse`,
`sort`, `unique`, and `zip` functions.
- `map_dict:Map` renamed to `map_dict:MapDict`.
- The `map_dict` module gains `drop`, and `take` functions.
- The `str` module gains `append` function and loses `from_int`, `parse_int`,
`from_float`, `parse_float`, and `base_from_int`.
- `int` module created with `parse`, `to_string`, and `to_base_string`.
- `float` module created with `ceiling`, `floor`, `round`, `truncate`,
`parse`, and `to_string`.

## v0.1.1 - 2019-04-17

- Included missing gleam.toml in hex package.

## v0.1.0 - 2019-04-15

- Initial release!
Loading