Skip to content

Commit

Permalink
Fix templates/config.yaml extension bug and release cli 0.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden committed Sep 3, 2024
1 parent bf83259 commit c70ff21
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [0.10.1] - 2024-09-03

## Fixed

- Fix bug where `templates/config.yaml` extension property is always
prepended by a period `.`. The property is now considered the full
extension.

## [0.10.0] - 2024-08-28

## Changed
Expand Down Expand Up @@ -161,6 +169,7 @@
- `sync` subcommand support to sync with latest Tinted Theming schemes
- `build` subcommand to trigger theme template build

[0.10.1]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.10.0...v0.10.1
[0.10.0]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.5...v0.10.0
[0.9.5]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.3...v0.9.5
[0.9.4]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.3...v0.9.4
Expand Down
2 changes: 1 addition & 1 deletion 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 THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ limitations under the License.
#### Used by

- [tinted-builder 0.6.0](https://github.com/tinted-theming/tinted-builder-rust)
- [tinted-builder-rust 0.10.0](https://github.com/tinted-theming/tinted-builder-rust)
- [tinted-builder-rust 0.10.1](https://github.com/tinted-theming/tinted-builder-rust)
- [ribboncurls 0.2.1](https://github.com/tinted-theming/ribboncurls)

```
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Build all the schemes for a base16 or tinted repo'

runs:
using: 'docker'
image: 'docker://ghcr.io/tinted-theming/tinted-builder-rust:v0.10.0'
image: 'docker://ghcr.io/tinted-theming/tinted-builder-rust:v0.10.1'
args:
- build
- .
Expand Down
2 changes: 1 addition & 1 deletion tinted-builder-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tinted-builder-rust"
version = "0.10.0"
version = "0.10.1"
edition = "2021"
authors = ["Jamy Golden <code@jamygolden.com>", "Tinted Theming <tintedtheming@proton.me>"]
license = "MIT OR Apache-2.0"
Expand Down
23 changes: 11 additions & 12 deletions tinted-builder-rust/src/operations/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ fn get_theme_template_path(theme_template_path: &Path) -> Result<PathBuf> {
/// * `output_dir` - A reference to a `PathBuf` representing the directory where the output file will be written.
/// * `scheme_path` - A reference to a `Path` representing the file path to the scheme file.
/// * `system` - The `SchemeSystem` that the scheme file should match.
/// * `extension` - A string slice representing the file extension for the generated theme file.
/// * `explicit_extension` - A string slice representing the file extension for the generated theme
/// file. The parameter is named "explict" extension because it includes the "dot" or lack thereof
///
/// # Returns
///
Expand Down Expand Up @@ -216,7 +217,7 @@ fn generate_theme(
output_dir: &PathBuf,
scheme_path: &Path,
system: SchemeSystem,
extension: &str,
explicit_extension: &str,
) -> Result<()> {
let scheme_file_type = SchemeFileType::new(scheme_path)?;
let scheme_path = scheme_file_type
Expand Down Expand Up @@ -247,10 +248,10 @@ fn generate_theme(
let template = Template::new(template_content.to_string(), scheme.clone());
let output = template.render()?;
let output_path = output_dir.join(format!(
"{}-{}.{}",
"{}-{}{}",
&scheme_inner.system,
scheme_file_type.get_file_stem().unwrap_or_default(),
extension
explicit_extension
));

if !output_path.exists() {
Expand All @@ -274,11 +275,9 @@ fn generate_themes_for_config(
schemes_filetypes: &[SchemeFileType],
is_quiet: bool,
) -> Result<()> {
let extension = config_value
.extension
.as_str()
.strip_prefix('.')
.unwrap_or(config_value.extension.as_str());
// "explicit" extension because it contains the entire extension including (or excluding) the
// period
let explicit_extension = config_value.extension.as_str();
let template_path = theme_template_path.join(format!("templates/{}.mustache", config_name));
let template_content = read_to_string(&template_path).context(format!(
"Mustache template missing: {}",
Expand Down Expand Up @@ -349,21 +348,21 @@ fn generate_themes_for_config(
&output_path,
&scheme_path,
scheme_system,
extension,
explicit_extension,
)?;
}

if !is_quiet {
println!(
"Successfully generated \"{}\" themes for \"{}\" at \"{}/*.{}\"",
"Successfully generated \"{}\" themes for \"{}\" at \"{}/*{}\"",
supported_systems
.iter()
.map(|item| item.as_str().to_string())
.collect::<Vec<String>>()
.join(", "),
config_name,
output_path.display(),
extension,
explicit_extension,
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
base24-template:
extension: .md
extension: -custom-extension
output: output-themes
supported-systems: [base24]
9 changes: 6 additions & 3 deletions tinted-builder-rust/tests/operation_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ fn test_operation_build_base24() -> Result<()> {
let schemes_path = template_theme_path.join("schemes");
let scheme_file_path = schemes_path.join(format!("{}.yaml", &scheme_name));
let themes_path = template_theme_path.join("output-themes");
let rendered_theme_path = themes_path.join(format!("base24-{}.md", &scheme_name));
let output_extension = "-custom-extension";
let rendered_theme_path =
themes_path.join(format!("base24-{}{}", &scheme_name, &output_extension));
let (
base24_config_file_content,
base24_scheme_file_content,
Expand Down Expand Up @@ -311,8 +313,9 @@ fn test_operation_build_base24() -> Result<()> {
assert!(
stdout.contains(
format!(
"Successfully generated \"base24\" themes for \"base24-template\" at \"{}/*.md\"",
themes_path.display()
"Successfully generated \"base24\" themes for \"base24-template\" at \"{}/*{}\"",
themes_path.display(),
output_extension
)
.as_str()
),
Expand Down

0 comments on commit c70ff21

Please sign in to comment.