Skip to content

Commit 7ebd243

Browse files
committed
Fix cargo publish #689
1 parent 2b0ceb9 commit 7ebd243

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

.earthlyignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ Earthfile
88
*/Earthfile
99
*/node_modules
1010
node_modules
11+
*/assets_tmp
1112
.earthlyignore

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/atomicserver/installation.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ Get the binaries from the [releases page](https://github.com/atomicdata-dev/atom
2525
## 3. Install using cargo
2626

2727
```sh
28-
# Make sure pnpm is installed and available in path! https://pnpm.io/
29-
pnpm --version
3028
# Install from source using cargo, and add it to your path
3129
# If things go wrong, check out `Troubleshooting compiling from source:` below
3230
cargo install atomic-server --locked

server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name = "atomic-server"
99
readme = "./README.md"
1010
repository = "https://github.com/atomicdata-dev/atomic-server"
1111
version = "0.36.1"
12+
include = ["src/**/*", "Cargo.toml", "assets_tmp", "build.rs"]
1213

1314
[[bin]]
1415
name = "atomic-server"

server/build.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::time::SystemTime;
22

3-
use static_files::resource_dir;
4-
53
const JS_DIST_SOURCE: &str = "../browser/data-browser/dist";
64
const SRC_BROWSER: &str = "../browser/data-browser/src";
75
const BROWSER_ROOT: &str = "../browser/";
@@ -18,11 +16,16 @@ fn main() -> std::io::Result<()> {
1816

1917
if should_build() {
2018
build_js();
21-
// copy files to server folder
2219
dircpy::copy_dir(JS_DIST_SOURCE, JS_DIST_TMP)?;
2320
}
2421

25-
resource_dir(JS_DIST_TMP)
22+
if !std::path::Path::new(JS_DIST_TMP).exists() {
23+
p!("Could not find JS_DIST_TMP folder, copying JS_DIST_SOURCE");
24+
dircpy::copy_dir(JS_DIST_SOURCE, JS_DIST_TMP)?;
25+
}
26+
27+
// Makes the static files available for compilation
28+
static_files::resource_dir(JS_DIST_TMP)
2629
.build()
2730
.unwrap_or_else(|e| panic!("failed to open data browser assets from {JS_DIST_TMP}. {e}"));
2831

@@ -72,9 +75,12 @@ fn should_build() -> bool {
7275

7376
p!("No changes in JS source files, skipping JS build.");
7477
false
75-
} else {
76-
p!("No JS dist folder found, building...");
78+
} else if std::path::Path::new(SRC_BROWSER).exists() {
79+
p!("No JS dist folder found, but did find source folder, building...");
7780
true
81+
} else {
82+
p!("Could not find index.html in JS_DIST_TMP, assuming this is a `cargo publish` run. Skipping JS build.");
83+
false
7884
}
7985
}
8086

server/src/handlers/single_page_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub async fn single_page(
1010
appstate: actix_web::web::Data<AppState>,
1111
path: actix_web::web::Path<String>,
1212
) -> AtomicServerResult<HttpResponse> {
13-
let template = include_str!("../../../browser/data-browser/dist/index.html");
13+
let template = include_str!("../../assets_tmp/index.html");
1414
let subject = format!("{}/{}", appstate.store.get_server_url(), path);
1515
let meta_tags: MetaTags = if let Ok(resource) =
1616
appstate

0 commit comments

Comments
 (0)