Skip to content

Commit

Permalink
Add SQLite Database
Browse files Browse the repository at this point in the history
  • Loading branch information
onelson committed Mar 1, 2021
1 parent 72154ea commit 56f6bb5
Show file tree
Hide file tree
Showing 13 changed files with 578 additions and 153 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.env
_data
node_modules/
/.ignore
108 changes: 104 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ license = "Apache-2.0/MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-web = "3.3.2"
actix-files = "0.4.1"
actix-web = "3.3.2"
askama = { version = "0.10.5", features = ["with-actix-web"] }
askama_actix = "0.11.1"
byteorder = "1.3.4"
chrono = "0.4.19"
dotenv = { version = "0.15.0", optional = true }
env_logger = "0.8.2"
git2 = "0.13.12"
glob = "0.3.0"
log = "0.4.11"
rusqlite = { version = "0.24.2", features = ["serde_json", "chrono", "bundled"] }
semver = { version = "0.11.0", features = ["serde"] }
serde = { version = "1.0", features = [ "derive" ] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.9.2"
structopt = "0.3.21"
thiserror = "1.0.23"
glob = "0.3.0"

[dev-dependencies]
tempdir = "0.3.7"
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: cargo watch -i _data -x run
web: cargo watch -i _data -x 'run -- run'
38 changes: 22 additions & 16 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ pub fn parse_args() -> Opt {
}

#[derive(StructOpt)]
pub struct Opt {
pub enum Command {
Run(RunOpt),
BackfillDb,
}

#[derive(StructOpt)]
pub struct RunOpt {
#[structopt(
long,
env = "ESTUARY_BASE_URL",
help = "The public url for the service."
)]
base_url: String,

#[structopt(
long,
parse(from_os_str),
env = "ESTUARY_INDEX_DIR",
help = "A directory to store the package index git repo."
)]
pub index_dir: PathBuf,

#[structopt(
long,
parse(from_os_str),
Expand All @@ -50,7 +48,17 @@ pub struct Opt {

#[structopt(long, default_value = "7878", env = "ESTUARY_HTTP_PORT")]
pub http_port: u16,
}

#[derive(StructOpt)]
pub struct Opt {
#[structopt(
long,
parse(from_os_str),
env = "ESTUARY_INDEX_DIR",
help = "A directory to store the package index data."
)]
pub index_dir: PathBuf,
#[structopt(
long,
parse(from_os_str),
Expand All @@ -59,9 +67,11 @@ pub struct Opt {
help = "Path to `git`."
)]
pub git_bin: PathBuf,
#[structopt(subcommand)]
pub cmd: Command,
}

impl Opt {
impl RunOpt {
/// Public getter for the `base_url` field.
///
/// Mainly this just ensures there are no trailing slashes in there.
Expand Down Expand Up @@ -89,30 +99,26 @@ mod tests {

#[test]
fn test_base_url_trims_trailing_slashes() {
let opt = Opt {
let opt = RunOpt {
// weird
base_url: "http://example.com/////".to_string(),
index_dir: Default::default(),
crate_dir: Default::default(),
download_url: None,
http_host: "".to_string(),
http_port: 0,
git_bin: Default::default(),
};

assert_eq!("http://example.com", opt.base_url());
}

#[test]
fn test_download_url_default() {
let opt = Opt {
let opt = RunOpt {
base_url: "http://example.com".to_string(),
index_dir: Default::default(),
crate_dir: Default::default(),
download_url: None,
http_host: "".to_string(),
http_port: 0,
git_bin: Default::default(),
};

assert_eq!(
Expand Down
Loading

0 comments on commit 56f6bb5

Please sign in to comment.