-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/cargo/reqwest-0.12.4
- Loading branch information
Showing
12 changed files
with
512 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,9 @@ name: CI | |
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
pull_request: | ||
branches: | ||
- master | ||
- main | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "asphalt" | ||
version = "0.4.2" | ||
version = "0.5.0" | ||
edition = "2021" | ||
license = "MIT" | ||
authors = ["Jack T <[email protected]>"] | ||
|
@@ -32,20 +32,23 @@ lto = "thin" | |
# Config for 'cargo dist' | ||
[workspace.metadata.dist] | ||
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) | ||
cargo-dist-version = "0.12.0" | ||
cargo-dist-version = "0.13.2" | ||
# CI backends to support | ||
ci = ["github"] | ||
# The installers to generate for each app | ||
installers = [] | ||
# Target platforms to build apps for (Rust target-triple syntax) | ||
targets = [ | ||
"aarch64-apple-darwin", | ||
"x86_64-apple-darwin", | ||
"x86_64-unknown-linux-gnu", | ||
"x86_64-pc-windows-msvc", | ||
"aarch64-apple-darwin", | ||
"x86_64-apple-darwin", | ||
"x86_64-unknown-linux-gnu", | ||
"x86_64-pc-windows-msvc", | ||
] | ||
# Publish jobs to run in CI | ||
pr-run-mode = "skip" | ||
# The archive format to use for windows builds (defaults .zip) | ||
windows-archive = ".zip" | ||
# The archive format to use for non-windows builds (defaults .tar.xz) | ||
unix-archive = ".zip" | ||
# Checksums to generate for each App | ||
checksum = "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use crate::{config::StyleType, LockFile}; | ||
|
||
mod flat; | ||
mod nested; | ||
|
||
pub fn generate_lua( | ||
lockfile: &LockFile, | ||
strip_dir: &str, | ||
style: &StyleType, | ||
) -> anyhow::Result<String> { | ||
match style { | ||
StyleType::Flat => flat::generate_lua(lockfile, strip_dir), | ||
StyleType::Nested => nested::generate_lua(lockfile, strip_dir), | ||
} | ||
} | ||
|
||
pub fn generate_ts( | ||
lockfile: &LockFile, | ||
strip_dir: &str, | ||
output_dir: &str, | ||
style: &StyleType, | ||
) -> anyhow::Result<String> { | ||
match style { | ||
StyleType::Flat => flat::generate_ts(lockfile, strip_dir, output_dir), | ||
StyleType::Nested => nested::generate_ts(lockfile, strip_dir, output_dir), | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::collections::BTreeMap; | ||
|
||
use crate::{FileEntry, LockFile}; | ||
|
||
fn test_lockfile() -> LockFile { | ||
let mut entries = BTreeMap::new(); | ||
entries.insert( | ||
"assets/foo.png".to_string(), | ||
FileEntry { | ||
asset_id: 1, | ||
hash: "a".to_string(), | ||
}, | ||
); | ||
entries.insert( | ||
"assets/bar/baz.png".to_string(), | ||
FileEntry { | ||
asset_id: 2, | ||
hash: "b".to_string(), | ||
}, | ||
); | ||
LockFile { entries } | ||
} | ||
|
||
#[test] | ||
fn generate_lua() { | ||
let lockfile = test_lockfile(); | ||
|
||
let lua = super::flat::generate_lua(&lockfile, "assets").unwrap(); | ||
assert_eq!(lua, "return {\n\t[\"/bar/baz.png\"] = \"rbxassetid://2\",\n\t[\"/foo.png\"] = \"rbxassetid://1\"\n}"); | ||
} | ||
|
||
#[test] | ||
fn generate_ts() { | ||
let lockfile = test_lockfile(); | ||
|
||
let ts = super::flat::generate_ts(&lockfile, "assets", "assets").unwrap(); | ||
assert_eq!(ts, "declare const assets: {\n\t\"/bar/baz.png\": string,\n\t\"/foo.png\": string\n}\nexport = assets"); | ||
} | ||
|
||
#[test] | ||
fn generate_lua_nested() { | ||
let lockfile = test_lockfile(); | ||
|
||
let lua = super::nested::generate_lua(&lockfile, "assets").unwrap(); | ||
assert_eq!( | ||
lua, | ||
"return {\n bar = {\n [\"baz.png\"] = \"rbxassetid://2\",\n },\n [\"foo.png\"] = \"rbxassetid://1\",\n}"); | ||
} | ||
|
||
#[test] | ||
fn generate_ts_nested() { | ||
let lockfile = test_lockfile(); | ||
|
||
let ts = super::nested::generate_ts(&lockfile, "assets", "assets").unwrap(); | ||
assert_eq!( | ||
ts, | ||
"declare const assets: {\n bar: {\n \"baz.png\": \"rbxassetid://2\",\n },\n \"foo.png\": \"rbxassetid://1\",\n}\nexport = assets"); | ||
} | ||
} |
Oops, something went wrong.