Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

<!-- add new items here -->

## v0.3.0

- Move from Angular 16 to Angular 17. Due to Angular adding `/browser` to the output folder of the application builder, we can't support both versions simultaneously.
- Support simple binary expressions in default values, making it possible to e.g. write 10 MiB as `10 * 1024 * 1024` instead of `10485760`

## v0.2.1
Expand Down
134 changes: 111 additions & 23 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mdbook-angular"
version = "0.2.1"
version = "0.3.0"
edition = "2021"
authors = ["Bram Gotink <bram@bram.dev>"]
license = "EUPL-1.2"
Expand Down Expand Up @@ -56,10 +56,11 @@ semver = "1.0.18"

[target.'cfg(unix)'.dependencies]
libc = { version = "0.2.147", optional = true }
filetime = { version = "0.2", optional = true }

[features]
default = ["background"]
background = ["dep:libc"]
background = ["dep:libc", "dep:filetime"]

[dev-dependencies]
assert_cmd = "2.0.11"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build-scripts:playground": "esbuild --minify --format=esm --loader=js <src/js/playground-io.js >src/js/playground-io.min.js"
},
"devDependencies": {
"@angular/cli": "^16.2.0-next",
"@angular/cli": "^17.0.0",
"esbuild": "^0.18.12",
"express-check-in": "^0.1.2",
"husky": "8.0.3",
Expand Down
12 changes: 7 additions & 5 deletions src/angular/builder/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod utils;

use std::{collections::HashMap, fs};

use filetime::{set_file_mtime, FileTime};
use pathdiff::diff_paths;
use serde_json::json;
use utils as background;
Expand Down Expand Up @@ -79,13 +80,14 @@ pub(super) fn build(config: &Config, chapters: Vec<ChapterWithCodeBlocks>) -> Re
}

if is_running {
if !replacements
.iter()
.any(|replacement| replacement.made_changes_to_scripts)
if !replacements.is_empty()
&& !replacements
.iter()
.any(|replacement| replacement.made_changes_to_scripts)
{
// change one watched file to trigger a new build, as the HTML renderer
// has just wiped the target folder
Writer::Default.write_tsconfig(config)?;
set_file_mtime(root.join("code_0/code_0.ts"), FileTime::now())?;
}
} else {
background::start(config)?;
Expand All @@ -97,7 +99,7 @@ pub(super) fn build(config: &Config, chapters: Vec<ChapterWithCodeBlocks>) -> Re
.map(|replacement| {
(
replacement.script_basename.clone(),
format!("{}.js", &replacement.script_basename),
format!("browser/{}.js", &replacement.script_basename),
)
})
.collect();
Expand Down
10 changes: 8 additions & 2 deletions src/angular/builder/experimental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ pub(super) fn build(config: &Config, chapters: Vec<ChapterWithCodeBlocks>) -> Re

ng_build(root, PROJECT_NAME)?;

let scripts: HashMap<_, _> = fs::read_dir(&config.target_folder)?
let scripts: HashMap<_, _> = fs::read_dir(config.target_folder.join("browser"))?
.filter_map(Result::ok)
.filter_map(|entry| entry.file_name().to_str().map(ToOwned::to_owned))
.filter_map(|name| name.find('.').map(|idx| (name[0..idx].to_owned(), name)))
.filter_map(|mut name| {
let dot_idx = name.find('.')?;

let basename = name[0..dot_idx].to_owned();
name.insert_str(0, "browser/");
Some((basename, name))
})
.collect();

run_replacements(replacements, config, &scripts)?;
Expand Down
Loading