@browsersync/bslive 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +30 -2
- package/bin.js +3 -2
- package/bslive/Cargo.toml +16 -1
- package/bslive/build.rs +1 -1
- package/bslive/src/lib.rs +120 -4
- package/bsnext/Cargo.toml +21 -0
- package/bsnext/src/main.rs +110 -0
- package/crates/bsnext_client/Cargo.toml +8 -0
- package/crates/bsnext_client/build.rs +53 -0
- package/crates/bsnext_client/dist/index.js +6493 -0
- package/crates/bsnext_client/generated/dto.ts +116 -0
- package/crates/bsnext_client/generated/schema.ts +187 -0
- package/crates/bsnext_client/index.html +14 -0
- package/crates/bsnext_client/package-lock.json +2059 -0
- package/crates/bsnext_client/package.json +25 -0
- package/crates/bsnext_client/src/lib.rs +1 -0
- package/crates/bsnext_client/style.css +3 -0
- package/crates/bsnext_client/ts/console.ts +25 -0
- package/crates/bsnext_client/ts/index.ts +73 -0
- package/crates/bsnext_client/tsconfig.json +16 -0
- package/crates/bsnext_core/Cargo.toml +43 -0
- package/crates/bsnext_core/src/dir_loader.rs +230 -0
- package/crates/bsnext_core/src/dto.rs +281 -0
- package/crates/bsnext_core/src/handlers/mod.rs +1 -0
- package/crates/bsnext_core/src/handlers/proxy.rs +95 -0
- package/crates/bsnext_core/src/lib.rs +11 -0
- package/crates/bsnext_core/src/meta/mod.rs +5 -0
- package/crates/bsnext_core/src/not_found/mod.rs +2 -0
- package/crates/bsnext_core/src/not_found/not_found.html +20 -0
- package/crates/bsnext_core/src/not_found/not_found_service.rs +41 -0
- package/crates/bsnext_core/src/not_found/route_list.rs +49 -0
- package/crates/bsnext_core/src/panic_handler.rs +32 -0
- package/crates/bsnext_core/src/raw_loader.rs +226 -0
- package/crates/bsnext_core/src/server/actor.rs +92 -0
- package/crates/bsnext_core/src/server/error.rs +41 -0
- package/crates/bsnext_core/src/server/handler_change.rs +85 -0
- package/crates/bsnext_core/src/server/handler_listen.rs +157 -0
- package/crates/bsnext_core/src/server/handler_patch.rs +42 -0
- package/crates/bsnext_core/src/server/handler_routes_updated.rs +27 -0
- package/crates/bsnext_core/src/server/handler_stop.rs +38 -0
- package/crates/bsnext_core/src/server/mod.rs +10 -0
- package/crates/bsnext_core/src/server/router/mod.rs +112 -0
- package/crates/bsnext_core/src/server/router/tests.rs +204 -0
- package/crates/bsnext_core/src/server/signals.rs +11 -0
- package/crates/bsnext_core/src/server/state.rs +19 -0
- package/crates/bsnext_core/src/servers_supervisor/actor.rs +199 -0
- package/crates/bsnext_core/src/servers_supervisor/file_changed_handler.rs +41 -0
- package/crates/bsnext_core/src/servers_supervisor/get_servers_handler.rs +23 -0
- package/crates/bsnext_core/src/servers_supervisor/input_changed_handler.rs +21 -0
- package/crates/bsnext_core/src/servers_supervisor/mod.rs +6 -0
- package/crates/bsnext_core/src/servers_supervisor/start_handler.rs +82 -0
- package/crates/bsnext_core/src/servers_supervisor/stop_handler.rs +26 -0
- package/crates/bsnext_core/src/ws/mod.rs +164 -0
- package/crates/bsnext_example/Cargo.toml +10 -0
- package/crates/bsnext_example/src/basic.rs +51 -0
- package/crates/bsnext_example/src/lib.rs +26 -0
- package/crates/bsnext_example/src/lit.rs +37 -0
- package/crates/bsnext_example/src/md.rs +18 -0
- package/crates/bsnext_fs/Cargo.toml +22 -0
- package/crates/bsnext_fs/src/actor.rs +122 -0
- package/crates/bsnext_fs/src/buffered_debounce.rs +166 -0
- package/crates/bsnext_fs/src/filter.rs +30 -0
- package/crates/bsnext_fs/src/inner_fs_event_handler.rs +94 -0
- package/crates/bsnext_fs/src/lib.rs +141 -0
- package/crates/bsnext_fs/src/remove_path_handler.rs +46 -0
- package/crates/bsnext_fs/src/stop_handler.rs +15 -0
- package/crates/bsnext_fs/src/stream.rs +167 -0
- package/crates/bsnext_fs/src/test/mod.rs +213 -0
- package/crates/bsnext_fs/src/watch_path_handler.rs +67 -0
- package/crates/bsnext_fs/src/watcher.rs +348 -0
- package/crates/bsnext_input/Cargo.toml +22 -0
- package/crates/bsnext_input/src/input_test/mod.rs +151 -0
- package/crates/bsnext_input/src/lib.rs +153 -0
- package/crates/bsnext_input/src/md.rs +541 -0
- package/crates/bsnext_input/src/paths.rs +64 -0
- package/crates/bsnext_input/src/route.rs +185 -0
- package/crates/bsnext_input/src/route_manifest.rs +186 -0
- package/crates/bsnext_input/src/server_config.rs +88 -0
- package/crates/bsnext_input/src/target.rs +7 -0
- package/crates/bsnext_input/src/watch_opt_test/mod.rs +68 -0
- package/crates/bsnext_input/src/yml.rs +1 -0
- package/crates/bsnext_output/Cargo.toml +16 -0
- package/crates/bsnext_output/src/json.rs +11 -0
- package/crates/bsnext_output/src/lib.rs +25 -0
- package/crates/bsnext_output/src/pretty.rs +147 -0
- package/crates/bsnext_resp/Cargo.toml +13 -0
- package/crates/bsnext_resp/src/js/snippet.html +1 -0
- package/crates/bsnext_resp/src/js/ws.js +1 -0
- package/crates/bsnext_resp/src/lib.rs +79 -0
- package/crates/bsnext_system/Cargo.toml +29 -0
- package/crates/bsnext_system/src/args.rs +43 -0
- package/crates/bsnext_system/src/lib.rs +227 -0
- package/crates/bsnext_system/src/monitor.rs +241 -0
- package/crates/bsnext_system/src/monitor_any_watchables.rs +127 -0
- package/crates/bsnext_system/src/start_kind/snapshots/bsnext_system__start_kind__start_from_paths__test__test-2.snap +11 -0
- package/crates/bsnext_system/src/start_kind/snapshots/bsnext_system__start_kind__start_from_paths__test__test.snap +29 -0
- package/crates/bsnext_system/src/start_kind/start_from_example.rs +49 -0
- package/crates/bsnext_system/src/start_kind/start_from_inputs.rs +67 -0
- package/crates/bsnext_system/src/start_kind/start_from_paths.rs +51 -0
- package/crates/bsnext_system/src/start_kind.rs +56 -0
- package/crates/bsnext_system/src/startup.rs +51 -0
- package/crates/bsnext_tracing/Cargo.toml +10 -0
- package/crates/bsnext_tracing/src/lib.rs +89 -0
- package/examples/basic/input.yml +5 -0
- package/examples/basic/public/index.html +15 -0
- package/examples/basic/public/reset.css +52 -0
- package/examples/basic/public/script.js +1 -0
- package/examples/basic/public/styles.css +3 -0
- package/examples/kitchen-sink/a-file.md +1 -0
- package/examples/kitchen-sink/api/1.json +1 -0
- package/examples/kitchen-sink/api/2.json +3 -0
- package/examples/kitchen-sink/app.js +1 -0
- package/examples/kitchen-sink/input.html +185 -0
- package/examples/kitchen-sink/input.yml +133 -0
- package/examples/kitchen-sink/styles-2.css +3 -0
- package/examples/lit/index.html +21 -0
- package/examples/lit/input.yml +5 -0
- package/examples/lit/lit.js +82 -0
- package/examples/lit/package-lock.json +62 -0
- package/examples/lit/package.json +15 -0
- package/examples/md-single/frontmatter.md +35 -0
- package/examples/md-single/md-single.md +35 -0
- package/examples/openai/.nvm +1 -0
- package/examples/openai/build.mjs +21 -0
- package/examples/openai/index.html +13 -0
- package/examples/openai/input.yml +59 -0
- package/examples/openai/package-lock.json +720 -0
- package/examples/openai/package.json +21 -0
- package/examples/openai/src/index.js +21 -0
- package/examples/openai/sse/01.txt +8 -0
- package/examples/proxy-simple/input.yml +9 -0
- package/examples/single/input.yaml +26 -0
- package/index.d.ts +2 -0
- package/index.js +2 -1
- package/package.json +17 -17
- package/run.sh +6 -0
package/Cargo.toml
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
|
-
workspace.members = [
|
|
1
|
+
workspace.members = [
|
|
2
|
+
"bslive",
|
|
3
|
+
"bsnext",
|
|
4
|
+
"crates/*"
|
|
5
|
+
]
|
|
2
6
|
workspace.resolver = "2"
|
|
3
7
|
|
|
4
8
|
[workspace.dependencies]
|
|
5
|
-
|
|
9
|
+
clap = { version = "4.5.3", features = ["derive"] }
|
|
10
|
+
axum = { version = "0.7.4", features = ["ws"] }
|
|
11
|
+
tokio = { version = "1", features = ["full"] }
|
|
12
|
+
tokio-stream = { version = "0.1.15", features = ["sync"] }
|
|
13
|
+
futures = "0.3.30"
|
|
14
|
+
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
|
|
15
|
+
tower = { version = "0.4.13" }
|
|
16
|
+
tower-http = { version = "0.5.0", features = ['trace', 'fs', 'compression-full', 'decompression-full', 'catch-panic', 'cors', 'timeout'] }
|
|
17
|
+
tracing = "0.1.40"
|
|
18
|
+
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
|
|
19
|
+
actix = "0.13.1"
|
|
20
|
+
actix-rt = "2.9.0"
|
|
21
|
+
anyhow = "1.0.69"
|
|
22
|
+
serde = { version = "1.0.152", features = ["derive"] }
|
|
23
|
+
serde_yaml = "0.9.33"
|
|
24
|
+
serde_json = "1.0.115"
|
|
25
|
+
thiserror = "1.0.58"
|
|
26
|
+
bytes = "1.6.0"
|
|
27
|
+
http = "1.1.0"
|
|
28
|
+
http-body-util = "0.1.1"
|
|
29
|
+
typeshare = "1"
|
|
30
|
+
random_word = { version = "0.4.3", features = ["en"] }
|
|
31
|
+
toml = { version = "0.8.12" }
|
|
32
|
+
mime_guess = "2.0.4"
|
|
33
|
+
tempfile = "3.10.1"
|
package/bin.js
CHANGED
package/bslive/Cargo.toml
CHANGED
|
@@ -7,10 +7,25 @@ version = "0.0.0"
|
|
|
7
7
|
crate-type = ["cdylib"]
|
|
8
8
|
|
|
9
9
|
[dependencies]
|
|
10
|
+
bsnext_core = { path = "../crates/bsnext_core" }
|
|
11
|
+
bsnext_input = { path = "../crates/bsnext_input" }
|
|
12
|
+
bsnext_fs = { path = "../crates/bsnext_fs" }
|
|
13
|
+
bsnext_tracing = { path = "../crates/bsnext_tracing" }
|
|
14
|
+
bsnext_system = { path = "../crates/bsnext_system" }
|
|
15
|
+
bsnext_output = { path = "../crates/bsnext_output" }
|
|
16
|
+
|
|
17
|
+
clap = { workspace = true }
|
|
18
|
+
tokio = { workspace = true }
|
|
19
|
+
tracing = { workspace = true }
|
|
20
|
+
actix = { workspace = true }
|
|
21
|
+
actix-rt = { workspace = true }
|
|
22
|
+
anyhow = { workspace = true }
|
|
23
|
+
serde = { workspace = true }
|
|
24
|
+
serde_json = { workspace = true }
|
|
25
|
+
|
|
10
26
|
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
11
27
|
napi = { version = "2.12.2", default-features = false, features = ["napi4", "tokio_rt", "tokio_full"] }
|
|
12
28
|
napi-derive = "2.12.2"
|
|
13
|
-
tokio = { workspace = true }
|
|
14
29
|
|
|
15
30
|
[build-dependencies]
|
|
16
31
|
napi-build = "2.0.1"
|
package/bslive/build.rs
CHANGED
package/bslive/src/lib.rs
CHANGED
|
@@ -3,12 +3,128 @@
|
|
|
3
3
|
#[macro_use]
|
|
4
4
|
extern crate napi_derive;
|
|
5
5
|
|
|
6
|
+
use actix::Actor;
|
|
7
|
+
use std::env::current_dir;
|
|
8
|
+
use std::io::Write;
|
|
9
|
+
use std::path::PathBuf;
|
|
6
10
|
use std::time::Duration;
|
|
11
|
+
|
|
12
|
+
use clap::Parser;
|
|
13
|
+
|
|
14
|
+
use bsnext_core::dto::ExternalEvents;
|
|
15
|
+
use bsnext_output::{OutputWriter, Writers};
|
|
16
|
+
use bsnext_system::args::Args;
|
|
17
|
+
use bsnext_system::start_kind::StartKind;
|
|
18
|
+
use bsnext_system::startup::{DidStart, StartupResult};
|
|
19
|
+
use bsnext_system::{BsSystem, Start};
|
|
20
|
+
use bsnext_tracing::{init_tracing, OutputFormat};
|
|
21
|
+
use tokio::sync::{mpsc, oneshot};
|
|
7
22
|
use tokio::time::sleep;
|
|
8
23
|
|
|
9
24
|
#[napi]
|
|
10
|
-
async fn start(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
async fn start(_args: Vec<String>) -> napi::bindgen_prelude::Result<i32> {
|
|
26
|
+
eprintln!("async not supported yet");
|
|
27
|
+
sleep(Duration::from_secs(2)).await;
|
|
28
|
+
Ok(32)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Launch in a blocking way
|
|
32
|
+
#[napi]
|
|
33
|
+
fn start_sync(args: Vec<String>) -> napi::bindgen_prelude::Result<i32> {
|
|
34
|
+
let sys = actix_rt::System::new();
|
|
35
|
+
println!("sync args {:?}", args);
|
|
36
|
+
std::env::set_var("RUST_LIB_BACKTRACE", "0");
|
|
37
|
+
let result = sys.block_on(async move {
|
|
38
|
+
match main_sync(args).await {
|
|
39
|
+
Ok(_) => 0,
|
|
40
|
+
Err(e) => {
|
|
41
|
+
eprintln!("{:?}", e);
|
|
42
|
+
1
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Ok(result)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async fn main_sync(args: Vec<String>) -> Result<(), anyhow::Error> {
|
|
50
|
+
let cwd = PathBuf::from(current_dir().unwrap().to_string_lossy().to_string());
|
|
51
|
+
let args = Args::parse_from(&args);
|
|
52
|
+
let format_clone = args.format;
|
|
53
|
+
|
|
54
|
+
init_tracing(args.log_level, args.format);
|
|
55
|
+
tracing::trace!(?args);
|
|
56
|
+
|
|
57
|
+
let (tx, rx) = oneshot::channel();
|
|
58
|
+
let (startup_oneshot_sender, startup_oneshot_receiver) = oneshot::channel::<StartupResult>();
|
|
59
|
+
let (events_sender, mut events_receiver) = mpsc::channel::<ExternalEvents>(1);
|
|
60
|
+
|
|
61
|
+
let system = BsSystem::new();
|
|
62
|
+
let sys_addr = system.start();
|
|
63
|
+
|
|
64
|
+
let start_kind = StartKind::from_args(args);
|
|
65
|
+
|
|
66
|
+
let start = Start {
|
|
67
|
+
kind: start_kind,
|
|
68
|
+
cwd: Some(cwd),
|
|
69
|
+
ack: tx,
|
|
70
|
+
events_sender,
|
|
71
|
+
startup_oneshot_sender,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
sys_addr.do_send(start);
|
|
75
|
+
|
|
76
|
+
match startup_oneshot_receiver.await {
|
|
77
|
+
Ok(Ok(DidStart::Started)) => tracing::info!("started..."),
|
|
78
|
+
Ok(Err(e)) => return Err(e.into()),
|
|
79
|
+
Err(e) => return Err(e.into()),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
let events_handler = tokio::spawn(async move {
|
|
83
|
+
let events = vec![];
|
|
84
|
+
let stdout = &mut std::io::stdout();
|
|
85
|
+
let printer = match format_clone {
|
|
86
|
+
None | Some(OutputFormat::Normal) => Writers::Pretty,
|
|
87
|
+
Some(OutputFormat::Json) => Writers::Json,
|
|
88
|
+
};
|
|
89
|
+
while let Some(evt) = events_receiver.recv().await {
|
|
90
|
+
match printer.handle_event(stdout, &evt) {
|
|
91
|
+
Ok(_v) => {}
|
|
92
|
+
Err(e) => tracing::error!("could not write to stdout {e}"),
|
|
93
|
+
}
|
|
94
|
+
match stdout.flush() {
|
|
95
|
+
Ok(_) => {}
|
|
96
|
+
Err(e) => tracing::error!("could not flush {e}"),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
events
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
match rx.await {
|
|
103
|
+
Ok(_) => {
|
|
104
|
+
tracing::info!("servers ended");
|
|
105
|
+
}
|
|
106
|
+
Err(e) => {
|
|
107
|
+
// dropped? this is ok
|
|
108
|
+
tracing::trace!(?e, "");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
match events_handler.await {
|
|
113
|
+
Ok(v) => {
|
|
114
|
+
tracing::info!(?v, "events seen");
|
|
115
|
+
let errors = v
|
|
116
|
+
.iter()
|
|
117
|
+
.filter(|e| matches!(e, ExternalEvents::StartupFailed(..)))
|
|
118
|
+
.collect::<Vec<_>>();
|
|
119
|
+
if !errors.is_empty() {
|
|
120
|
+
tracing::info!("stopped for the following reasons");
|
|
121
|
+
for msg in errors {
|
|
122
|
+
tracing::error!(?msg);
|
|
123
|
+
}
|
|
124
|
+
return Err(anyhow::anyhow!("exited..."));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
Err(e) => tracing::error!(?e),
|
|
128
|
+
}
|
|
129
|
+
Ok(())
|
|
14
130
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "bsnext"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
|
|
6
|
+
[dependencies]
|
|
7
|
+
bsnext_core = { path = "../crates/bsnext_core" }
|
|
8
|
+
bsnext_input = { path = "../crates/bsnext_input" }
|
|
9
|
+
bsnext_fs = { path = "../crates/bsnext_fs" }
|
|
10
|
+
bsnext_tracing = { path = "../crates/bsnext_tracing" }
|
|
11
|
+
bsnext_system = { path = "../crates/bsnext_system" }
|
|
12
|
+
bsnext_output = { path = "../crates/bsnext_output" }
|
|
13
|
+
|
|
14
|
+
clap = { workspace = true }
|
|
15
|
+
tokio = { workspace = true }
|
|
16
|
+
tracing = { workspace = true }
|
|
17
|
+
actix = { workspace = true }
|
|
18
|
+
actix-rt = { workspace = true }
|
|
19
|
+
anyhow = { workspace = true }
|
|
20
|
+
serde = { workspace = true }
|
|
21
|
+
serde_json = { workspace = true }
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
use actix::Actor;
|
|
2
|
+
use std::env::current_dir;
|
|
3
|
+
use std::io::Write;
|
|
4
|
+
use std::path::PathBuf;
|
|
5
|
+
|
|
6
|
+
use bsnext_core::dto::ExternalEvents;
|
|
7
|
+
use bsnext_output::{OutputWriter, Writers};
|
|
8
|
+
use bsnext_system::args::Args;
|
|
9
|
+
use bsnext_system::start_kind::StartKind;
|
|
10
|
+
use bsnext_system::startup::{DidStart, StartupResult};
|
|
11
|
+
use bsnext_system::{BsSystem, Start};
|
|
12
|
+
use bsnext_tracing::{init_tracing, OutputFormat};
|
|
13
|
+
use clap::Parser;
|
|
14
|
+
use tokio::sync::{mpsc, oneshot};
|
|
15
|
+
|
|
16
|
+
#[actix_rt::main]
|
|
17
|
+
async fn main() -> Result<(), anyhow::Error> {
|
|
18
|
+
std::env::set_var("RUST_LIB_BACKTRACE", "0");
|
|
19
|
+
let cwd = PathBuf::from(current_dir().unwrap().to_string_lossy().to_string());
|
|
20
|
+
let args = Args::parse();
|
|
21
|
+
let format_clone = args.format;
|
|
22
|
+
|
|
23
|
+
init_tracing(args.log_level, args.format);
|
|
24
|
+
tracing::trace!(?args);
|
|
25
|
+
|
|
26
|
+
let (tx, rx) = oneshot::channel();
|
|
27
|
+
let (startup_oneshot_sender, startup_oneshot_receiver) = oneshot::channel::<StartupResult>();
|
|
28
|
+
let (events_sender, mut events_receiver) = mpsc::channel::<ExternalEvents>(1);
|
|
29
|
+
|
|
30
|
+
let system = BsSystem::new();
|
|
31
|
+
let sys_addr = system.start();
|
|
32
|
+
|
|
33
|
+
let start_kind = StartKind::from_args(args);
|
|
34
|
+
|
|
35
|
+
let start = Start {
|
|
36
|
+
kind: start_kind,
|
|
37
|
+
cwd: Some(cwd),
|
|
38
|
+
ack: tx,
|
|
39
|
+
events_sender,
|
|
40
|
+
startup_oneshot_sender,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
sys_addr.do_send(start);
|
|
44
|
+
|
|
45
|
+
match startup_oneshot_receiver.await? {
|
|
46
|
+
Ok(DidStart::Started) => tracing::info!("started..."),
|
|
47
|
+
Err(e) => return Err(e.into()),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
let events_handler = tokio::spawn(async move {
|
|
51
|
+
let events = vec![];
|
|
52
|
+
let stdout = &mut std::io::stdout();
|
|
53
|
+
let printer = match format_clone {
|
|
54
|
+
None | Some(OutputFormat::Normal) => Writers::Pretty,
|
|
55
|
+
Some(OutputFormat::Json) => Writers::Json,
|
|
56
|
+
};
|
|
57
|
+
while let Some(evt) = events_receiver.recv().await {
|
|
58
|
+
match printer.handle_event(stdout, &evt) {
|
|
59
|
+
Ok(_v) => {}
|
|
60
|
+
Err(e) => tracing::error!("could not write to stdout {e}"),
|
|
61
|
+
}
|
|
62
|
+
match stdout.flush() {
|
|
63
|
+
Ok(_) => {}
|
|
64
|
+
Err(e) => tracing::error!("could not flush {e}"),
|
|
65
|
+
};
|
|
66
|
+
// let as_evt = ExternalEvent {
|
|
67
|
+
// level: EventLevel::External,
|
|
68
|
+
// fields: evt,
|
|
69
|
+
// };
|
|
70
|
+
// let json = serde_json::to_string_pretty(&as_evt).unwrap();
|
|
71
|
+
// println!("{json}");
|
|
72
|
+
// match handle_event(stdout, &evt) {
|
|
73
|
+
// Ok(_) => {
|
|
74
|
+
// events.push(evt);
|
|
75
|
+
// }
|
|
76
|
+
// Err(e) => tracing::error!("could not write to stdout {e}"),
|
|
77
|
+
// }
|
|
78
|
+
}
|
|
79
|
+
events
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
match rx.await {
|
|
83
|
+
Ok(_) => {
|
|
84
|
+
tracing::info!("servers ended");
|
|
85
|
+
}
|
|
86
|
+
Err(e) => {
|
|
87
|
+
// dropped? this is ok
|
|
88
|
+
tracing::trace!(?e, "");
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
match events_handler.await {
|
|
93
|
+
Ok(v) => {
|
|
94
|
+
tracing::info!(?v, "events seen");
|
|
95
|
+
let errors = v
|
|
96
|
+
.iter()
|
|
97
|
+
.filter(|e| matches!(e, ExternalEvents::StartupFailed(..)))
|
|
98
|
+
.collect::<Vec<_>>();
|
|
99
|
+
if !errors.is_empty() {
|
|
100
|
+
tracing::info!("stopped for the following reasons");
|
|
101
|
+
for msg in errors {
|
|
102
|
+
tracing::error!(?msg);
|
|
103
|
+
}
|
|
104
|
+
return Err(anyhow::anyhow!("exited..."));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
Err(e) => tracing::error!(?e),
|
|
108
|
+
}
|
|
109
|
+
Ok(())
|
|
110
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
use std::env::current_dir;
|
|
2
|
+
use std::io::Write;
|
|
3
|
+
use std::process::Command;
|
|
4
|
+
use std::{env, io};
|
|
5
|
+
|
|
6
|
+
fn main() {
|
|
7
|
+
if env::var("CI").is_ok() {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
let curr = current_dir().expect("current dir");
|
|
11
|
+
let root = curr
|
|
12
|
+
.parent()
|
|
13
|
+
.expect("parent")
|
|
14
|
+
.parent()
|
|
15
|
+
.expect("parent 2")
|
|
16
|
+
.to_path_buf();
|
|
17
|
+
let output = Command::new("typeshare")
|
|
18
|
+
.args([
|
|
19
|
+
"crates/bsnext_core",
|
|
20
|
+
"--lang=typescript",
|
|
21
|
+
"--output-file=crates/bsnext_client/generated/dto.ts",
|
|
22
|
+
])
|
|
23
|
+
.current_dir(&root)
|
|
24
|
+
.output()
|
|
25
|
+
.expect("build types");
|
|
26
|
+
|
|
27
|
+
io::stdout().write_all(&output.stdout).unwrap();
|
|
28
|
+
io::stderr().write_all(&output.stderr).unwrap();
|
|
29
|
+
|
|
30
|
+
assert!(output.status.success());
|
|
31
|
+
|
|
32
|
+
let output = Command::new("npm")
|
|
33
|
+
.args(["run", "schema"])
|
|
34
|
+
.current_dir(root.join("crates").join("bsnext_client"))
|
|
35
|
+
.output()
|
|
36
|
+
.expect("build schema");
|
|
37
|
+
|
|
38
|
+
io::stdout().write_all(&output.stdout).unwrap();
|
|
39
|
+
io::stderr().write_all(&output.stderr).unwrap();
|
|
40
|
+
|
|
41
|
+
assert!(output.status.success());
|
|
42
|
+
|
|
43
|
+
let output = Command::new("npm")
|
|
44
|
+
.args(["run", "build"])
|
|
45
|
+
.current_dir(root.join("crates").join("bsnext_client"))
|
|
46
|
+
.output()
|
|
47
|
+
.expect("sh command failed to start");
|
|
48
|
+
|
|
49
|
+
io::stdout().write_all(&output.stdout).unwrap();
|
|
50
|
+
io::stderr().write_all(&output.stderr).unwrap();
|
|
51
|
+
|
|
52
|
+
assert!(output.status.success());
|
|
53
|
+
}
|