@ionyx-apps/cli 0.1.9 → 0.2.1

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/bin/ionyx.exe CHANGED
Binary file
@@ -3,12 +3,14 @@ name = "my-ionyx-app"
3
3
  version = "0.1.0"
4
4
  edition = "2021"
5
5
 
6
+ [workspace]
7
+
6
8
  [[bin]]
7
9
  name = "my-ionyx-app"
8
10
  path = "main.rs"
9
11
 
10
12
  [dependencies]
11
- ionyx = { git = "https://github.com/ionyx-apps/ionyx", branch = "quantum" }
13
+ ionyx = { path = "../../../../../../src-ionyx" }
12
14
  anyhow = "1.0"
13
15
 
14
16
  [profile.release]
@@ -0,0 +1,105 @@
1
+ use std::borrow::Cow;
2
+ use wry::http::{Request, Response, StatusCode};
3
+ use std::path::Path;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
7
+
8
+ // Configuration'dan frontendDist path'ini oku
9
+ fn get_frontend_dist_path() -> String {
10
+ // Önce Ionyx config dosyasını okumaya çalış
11
+ if let Ok(config_content) = std::fs::read_to_string("ionyx.config.toml") {
12
+ for line in config_content.lines() {
13
+ if line.trim().starts_with("frontendDist") {
14
+ if let Some(path) = line.split('=').nth(1) {
15
+ return path.trim().trim_matches('"').to_string();
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ // Varsayılan path
22
+ "../frontend/dist".to_string()
23
+ }
24
+
25
+ // Release modunda frontend/dist içindeki dosyaları binary'ye gömer.
26
+ // Configuration'dan dinamik path okur.
27
+ #[cfg(not(debug_assertions))]
28
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("../frontend/dist");
29
+
30
+ pub struct CustomProtocolHandler;
31
+
32
+ impl CustomProtocolHandler {
33
+ pub fn new() -> Self {
34
+ Self
35
+ }
36
+
37
+ pub fn handle_request(&self, request: Request<Vec<u8>>) -> Response<Cow<'static, [u8]>> {
38
+ let path = request.uri().path();
39
+
40
+ // Debug modunda (npm run dev açıkken) bu handler'ın işi yok aslında,
41
+ // WebView doğrudan localhost'a gitmeli. Ama bir şekilde buraya düşerse
42
+ // 404 yerine temiz bir hata dönüyoruz.
43
+ if cfg!(debug_assertions) {
44
+ return Response::builder()
45
+ .status(StatusCode::NOT_FOUND)
46
+ .header("Content-Type", "text/plain")
47
+ .body(Cow::Borrowed(&b"Debug mode: Assets are served from Vite (localhost:5173)"[..]))
48
+ .unwrap();
49
+ }
50
+
51
+ // Release modunda gömülü dosyaları işle
52
+ #[cfg(not(debug_assertions))]
53
+ {
54
+ let clean_path = path.trim_start_matches('/');
55
+ let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
56
+
57
+ match EMBEDDED_ASSETS.get_file(file_path) {
58
+ Some(file) => {
59
+ let content_type = Self::get_content_type(file_path);
60
+ Response::builder()
61
+ .status(StatusCode::OK)
62
+ .header("Content-Type", content_type)
63
+ .body(Cow::Borrowed(file.contents()))
64
+ .unwrap()
65
+ }
66
+ None => {
67
+ // SPA (Single Page Application) desteği: Dosya bulunamazsa index.html'i dön
68
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
69
+ Response::builder()
70
+ .status(StatusCode::OK)
71
+ .header("Content-Type", "text/html")
72
+ .body(Cow::Borrowed(index_file.contents()))
73
+ .unwrap()
74
+ } else {
75
+ Response::builder()
76
+ .status(StatusCode::NOT_FOUND)
77
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
78
+ .unwrap()
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ // Burası teknik olarak unreachable ancak derleyiciyi tatmin etmek için
85
+ #[cfg(debug_assertions)]
86
+ Response::builder().status(StatusCode::NOT_FOUND).body(Cow::Borrowed(&b"Not Found"[..])).unwrap()
87
+ }
88
+
89
+ fn get_content_type(file_path: &str) -> &'static str {
90
+ let path = std::path::Path::new(file_path);
91
+ match path.extension().and_then(|s| s.to_str()) {
92
+ Some("html") => "text/html",
93
+ Some("css") => "text/css",
94
+ Some("js") => "application/javascript",
95
+ Some("json") => "application/json",
96
+ Some("svg") => "image/svg+xml",
97
+ Some("png") => "image/png",
98
+ Some("jpg") | Some("jpeg") => "image/jpeg",
99
+ Some("gif") => "image/gif",
100
+ Some("woff") => "font/woff",
101
+ Some("woff2") => "font/woff2",
102
+ _ => "application/octet-stream",
103
+ }
104
+ }
105
+ }
@@ -3,12 +3,14 @@ name = "my-ionyx-app"
3
3
  version = "0.1.0"
4
4
  edition = "2021"
5
5
 
6
+ [workspace]
7
+
6
8
  [[bin]]
7
9
  name = "my-ionyx-app"
8
10
  path = "main.rs"
9
11
 
10
12
  [dependencies]
11
- ionyx = { git = "https://github.com/ionyx-apps/ionyx", branch = "quantum" }
13
+ ionyx = { path = "../../../../../../src-ionyx" }
12
14
  anyhow = "1.0"
13
15
 
14
16
  [profile.release]
@@ -0,0 +1,105 @@
1
+ use std::borrow::Cow;
2
+ use wry::http::{Request, Response, StatusCode};
3
+ use std::path::Path;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
7
+
8
+ // Configuration'dan frontendDist path'ini oku
9
+ fn get_frontend_dist_path() -> String {
10
+ // Önce Ionyx config dosyasını okumaya çalış
11
+ if let Ok(config_content) = std::fs::read_to_string("ionyx.config.toml") {
12
+ for line in config_content.lines() {
13
+ if line.trim().starts_with("frontendDist") {
14
+ if let Some(path) = line.split('=').nth(1) {
15
+ return path.trim().trim_matches('"').to_string();
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ // Varsayılan path
22
+ "../frontend/dist".to_string()
23
+ }
24
+
25
+ // Release modunda frontend/dist içindeki dosyaları binary'ye gömer.
26
+ // Configuration'dan dinamik path okur.
27
+ #[cfg(not(debug_assertions))]
28
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("../frontend/dist");
29
+
30
+ pub struct CustomProtocolHandler;
31
+
32
+ impl CustomProtocolHandler {
33
+ pub fn new() -> Self {
34
+ Self
35
+ }
36
+
37
+ pub fn handle_request(&self, request: Request<Vec<u8>>) -> Response<Cow<'static, [u8]>> {
38
+ let path = request.uri().path();
39
+
40
+ // Debug modunda (npm run dev açıkken) bu handler'ın işi yok aslında,
41
+ // WebView doğrudan localhost'a gitmeli. Ama bir şekilde buraya düşerse
42
+ // 404 yerine temiz bir hata dönüyoruz.
43
+ if cfg!(debug_assertions) {
44
+ return Response::builder()
45
+ .status(StatusCode::NOT_FOUND)
46
+ .header("Content-Type", "text/plain")
47
+ .body(Cow::Borrowed(&b"Debug mode: Assets are served from Vite (localhost:5173)"[..]))
48
+ .unwrap();
49
+ }
50
+
51
+ // Release modunda gömülü dosyaları işle
52
+ #[cfg(not(debug_assertions))]
53
+ {
54
+ let clean_path = path.trim_start_matches('/');
55
+ let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
56
+
57
+ match EMBEDDED_ASSETS.get_file(file_path) {
58
+ Some(file) => {
59
+ let content_type = Self::get_content_type(file_path);
60
+ Response::builder()
61
+ .status(StatusCode::OK)
62
+ .header("Content-Type", content_type)
63
+ .body(Cow::Borrowed(file.contents()))
64
+ .unwrap()
65
+ }
66
+ None => {
67
+ // SPA (Single Page Application) desteği: Dosya bulunamazsa index.html'i dön
68
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
69
+ Response::builder()
70
+ .status(StatusCode::OK)
71
+ .header("Content-Type", "text/html")
72
+ .body(Cow::Borrowed(index_file.contents()))
73
+ .unwrap()
74
+ } else {
75
+ Response::builder()
76
+ .status(StatusCode::NOT_FOUND)
77
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
78
+ .unwrap()
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ // Burası teknik olarak unreachable ancak derleyiciyi tatmin etmek için
85
+ #[cfg(debug_assertions)]
86
+ Response::builder().status(StatusCode::NOT_FOUND).body(Cow::Borrowed(&b"Not Found"[..])).unwrap()
87
+ }
88
+
89
+ fn get_content_type(file_path: &str) -> &'static str {
90
+ let path = std::path::Path::new(file_path);
91
+ match path.extension().and_then(|s| s.to_str()) {
92
+ Some("html") => "text/html",
93
+ Some("css") => "text/css",
94
+ Some("js") => "application/javascript",
95
+ Some("json") => "application/json",
96
+ Some("svg") => "image/svg+xml",
97
+ Some("png") => "image/png",
98
+ Some("jpg") | Some("jpeg") => "image/jpeg",
99
+ Some("gif") => "image/gif",
100
+ Some("woff") => "font/woff",
101
+ Some("woff2") => "font/woff2",
102
+ _ => "application/octet-stream",
103
+ }
104
+ }
105
+ }
@@ -51,6 +51,11 @@ pub async fn copy_template(project_name: &str, dest_path: &str, template: &str)
51
51
  if Path::new(&backend_cargo_path).exists() {
52
52
  let mut content = fs::read_to_string(&backend_cargo_path)?;
53
53
  content = content.replace("my-ionyx-app", project_name);
54
+ // Use Git dependency for generated projects
55
+ content = content.replace(
56
+ "ionyx = { path = \"../../../../../../src-ionyx\" }",
57
+ "ionyx = { git = \"https://github.com/ionyx-apps/ionyx\", branch = \"quantum\" }"
58
+ );
54
59
  fs::write(&backend_cargo_path, content)?;
55
60
  }
56
61