Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SQLite Database #26

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
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