Skip to content

Commit

Permalink
🎉 Hello, Joe!
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri committed Aug 4, 2024
0 parents commit 1114482
Show file tree
Hide file tree
Showing 13 changed files with 2,899 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
push:
branches:
- master
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: "26.0.2"
gleam-version: "1.4.0-rc1"
rebar3-version: "3"
# elixir-version: "1.15.4"
- run: gleam deps download
- run: gleam test
- run: gleam format --check src test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.beam
*.ez
/build
erl_crash.dump
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# squirrel

[![Package Version](https://img.shields.io/hexpm/v/squirrel)](https://hex.pm/packages/squirrel)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/squirrel/)

```gleam
import squirrel
pub fn main() {
// TODO: An example of the project in use
}
```

Further documentation can be found at <https://hexdocs.pm/squirrel>.

## Development

```sh
gleam run # Run the project
gleam test # Run the tests
```
17 changes: 17 additions & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name = "squirrel"
version = "0.1.0"
description = "🐿️ Type safe SQL in Gleam"
licences = ["Apache-2.0"]
repository = { type = "github", user = "giacomocavalieri", repo = "squirrel" }

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
simplifile = ">= 2.0.1 and < 3.0.0"
eval = ">= 1.0.0 and < 2.0.0"
gleam_json = ">= 1.0.0 and < 2.0.0"
mug = ">= 1.1.0 and < 2.0.0"
glam = ">= 2.0.1 and < 3.0.0"
justin = ">= 1.0.1 and < 2.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
26 changes: 26 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file was generated by Gleam
# You typically do not need to edit this file

packages = [
{ name = "eval", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "eval", source = "hex", outer_checksum = "264DAF4B49DF807F303CA4A4E4EBC012070429E40BE384C58FE094C4958F9BDA" },
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
{ name = "glam", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glam", source = "hex", outer_checksum = "66EC3BCD632E51EED029678F8DF419659C1E57B1A93D874C5131FE220DFAD2B2" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
{ name = "gleam_stdlib", version = "0.39.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "2D7DE885A6EA7F1D5015D1698920C9BAF7241102836CE0C3837A4F160128A9C4" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" },
{ name = "mug", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "mug", source = "hex", outer_checksum = "85A61E67A7A8C25F4460D9CBEF1C09C68FC06ABBC6FF893B0A1F42AE01CBB546" },
{ name = "simplifile", version = "2.0.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "5FFEBD0CAB39BDD343C3E1CCA6438B2848847DC170BA2386DF9D7064F34DF000" },
{ name = "thoas", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "E38697EDFFD6E91BD12CEA41B155115282630075C2A727E7A6B2947F5408B86A" },
]

[requirements]
eval = { version = ">= 1.0.0 and < 2.0.0" }
glam = { version = ">= 2.0.1 and < 3.0.0" }
gleam_json = { version = ">= 1.0.0 and < 2.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
justin = { version = ">= 1.0.1 and < 2.0.0" }
mug = { version = ">= 1.1.0 and < 2.0.0" }
simplifile = { version = ">= 2.0.1 and < 3.0.0" }
24 changes: 24 additions & 0 deletions src/squirrel.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import gleam/list
import simplifile
import squirrel/internal/database/postgres
import squirrel/internal/query

// TODO LIST:
// - [ ] How does one decide where the query goes?
// - [ ] How do I deal with duplicate names then?
// - [ ] Make a nice CLI tool
// - [ ] How does one connect to the db?
//

/// Entry point for the `squirrel` CLI.
///
pub fn main() {
let assert Ok(queries) =
"<path-to-sql-file>"
|> query.from_file

let assert Ok(queries) = postgres.main(queries)

use query <- list.each(queries)
simplifile.append(query.to_function(query) <> "\n\n", to: "<output-file>")
}
Loading

0 comments on commit 1114482

Please sign in to comment.