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

WIP: load oranda.toml as well #629

Draft
wants to merge 1 commit 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 Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ members = ["generate-css"]

[dependencies]
ammonia = "3"
axoasset = { version = "0.4.0", features = ["json-serde", "toml-edit"] }
axoasset = { version = "0.4.0", features = ["json-serde", "toml-serde", "toml-edit"] }
axocli = "0.1.0"
axoproject = { version = "0.4.6", default-features = false, features = ["cargo-projects", "npm-projects"] }
axum = "0.6.18"
Expand Down
38 changes: 0 additions & 38 deletions oranda.json
Original file line number Diff line number Diff line change
@@ -1,38 +0,0 @@
{
"build": {
"path_prefix": "oranda"
},
"styles": {
"theme": "axodark",
"favicon": "https://www.axo.dev/favicon.ico"
},
"marketing": {
"social": {
"image": "https://www.axo.dev/meta_small.jpeg",
"image_alt": "axo",
"twitter_account": "@axodotdev"
},
"analytics": {
"plausible": {
"domain": "opensource.axo.dev"
}
}
},
"components": {
"changelog": true,
"artifacts": {
"package_managers": {
"preferred": {
"npm": "npm install @axodotdev/oranda --save-dev"
},
"additional": {
"cargo": "cargo install oranda --locked --profile=dist",
"npx": "npx @axodotdev/oranda",
"binstall": "cargo binstall oranda",
"nix-env": "nix-env -i oranda",
"nix flake": "nix profile install github:axodotdev/oranda"
}
}
}
}
}
29 changes: 29 additions & 0 deletions oranda.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build]
path_prefix = "oranda"

[styles]
theme = "axodark"
favicon = "https://www.axo.dev/favicon.ico"

[marketing]
analytics = { plausible = { domain = "opensource.axo.dev" }}

[marketing.social]
image = "https://www.axo.dev/meta_small.jpeg"
image_alt = "axo"
twitter_account = "@axodotdev"



[components]
changelog = true

[components.artifacts.package_managers.preferred]
npm = "npm install @axodotdev/oranda --save-dev"
cargo = "cargo install oranda --locked --profile=dist"

[components.artifacts.package_managers.additional]
npx = "npx @axodotdev/oranda"
binstall = "cargo binstall oranda"
nix-env = "nix-env -i oranda"
"nix flake" = "nix profile install github:axodotdev/oranda"
30 changes: 20 additions & 10 deletions src/config/oranda_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@ pub struct OrandaLayer {

impl OrandaLayer {
pub fn load(config_path: &Utf8PathBuf) -> Result<Option<OrandaLayer>> {
let config_result = SourceFile::load_local(config_path.as_path());

match config_result {
Ok(config) => {
let data: OrandaLayer = config.deserialize_json()?;
Ok(Some(data))
}
Err(_) => {
tracing::debug!("No config found, using default values");
Ok(None)
let mut config_path = config_path.to_owned();
if config_path.extension() == Some("json") {
if config_path.exists() {
let config = SourceFile::load_local(config_path.as_path())?;
return Ok(Some(config.deserialize_json()?));
} else {
// Temporary hack
config_path.set_extension("toml");
}
}
if !config_path.exists() {
tracing::debug!("No config found, using default values");
return Ok(None);
}
if config_path.extension() == Some("toml") {
tracing::warn!("!!!Using toml config!!!!");
let config = SourceFile::load_local(config_path.as_path())?;
return Ok(Some(config.deserialize_toml()?));
}

tracing::debug!("No config found, using default values");
Ok(None)
}
}
Loading