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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ Also:
linux-x64-gnu 25.4 MB. Each must stay under 30,000,000 bytes; the release
stops above that.
- **`calyx app.js app.css` is gone.** `calyx dist` runs an app from its
folder, and `calyx --bundle` packs one that has an `index.html`. A bundle
made before this release is not replaced by mistake.
folder, and `calyx --bundle` packs one that has an `index.html`. It
replaces a bundle Sepal made, from this release or an earlier one (dev
keeps one in `node_modules/.sepal`, for the app's name and icon in the
Dock), and still never one it did not make.
- **Relative `fetch` URLs resolve against `http://app.localhost/`**, the
page's address, and the host answers that origin from the app folder:
`GET` and `HEAD`, a content type by extension, a 404 for a missing file
Expand Down
8 changes: 6 additions & 2 deletions crates/host/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ pub fn bundle_macos(dist: &Path, out: &Path, host: &Path) -> Result<PathBuf, Str
let resources = contents.join("Resources");
if bundle.exists() {
// `name` comes from a config file and `out` from the command line. Together
// they can name any application on the machine, so only replace our own.
if !resources.join("index.html").is_file() {
// they can name any application on the machine, so only replace our own:
// `app.json` next to the page, or next to the one script the app was
// before 0.3 (dev keeps a bundle like that in node_modules/.sepal).
let ours = resources.join("app.json").is_file()
&& (resources.join("index.html").is_file() || resources.join("app.js").is_file());
if !ours {
return Err(format!(
"{} exists and was not built by Sepal; not replacing it",
bundle.display()
Expand Down
24 changes: 24 additions & 0 deletions crates/host/tests/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ fn bundles_the_counter_example() {
assert!(!bundle.join("stale.txt").exists());
}

/// A bundle from before apps were web builds (0.2.0-alpha.0 and earlier:
/// `app.js` and `app.css` where `index.html` is now) is Sepal's too. Dev
/// keeps one in `node_modules/.sepal`; refused, dev ran the bare host, and
/// the Dock said "calyx".
#[test]
fn replaces_a_bundle_from_before_index_html() {
let dir = scratch("old-layout");
let host = fake_host(&dir);
let old = dir.join("Counter.app/Contents");
fs::create_dir_all(old.join("MacOS")).unwrap();
fs::create_dir_all(old.join("Resources")).unwrap();
fs::write(old.join("MacOS/Counter"), "an older calyx").unwrap();
for file in ["app.js", "app.css", "app.json"] {
fs::write(old.join("Resources").join(file), "").unwrap();
}

bundle_macos(counter_dist(), &dir, &host).unwrap();
assert!(old.join("Resources/index.html").is_file());
assert!(
!old.join("Resources/app.js").exists(),
"the old app went with its bundle"
);
}

#[test]
fn never_replaces_an_app_it_did_not_build() {
let dir = scratch("foreign");
Expand Down
Loading