@bobfrankston/msger 0.1.126 → 0.1.128

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.
Binary file
Binary file
Binary file
@@ -1,34 +1,7 @@
1
- use std::fs;
2
- use std::path::Path;
3
-
4
1
  fn main() {
5
- // Read parent package.json
6
- let package_json_path = Path::new("../package.json");
7
-
8
- if package_json_path.exists() {
9
- let content = fs::read_to_string(package_json_path)
10
- .expect("Failed to read package.json");
11
-
12
- // Parse JSON to extract version
13
- if let Some(version_line) = content.lines().find(|line| line.contains("\"version\"")) {
14
- // Extract version value (simple string parsing)
15
- if let Some(start) = version_line.find('"') {
16
- if let Some(colon) = version_line[start+1..].find(':') {
17
- let after_colon = &version_line[start+colon+2..];
18
- if let Some(quote_start) = after_colon.find('"') {
19
- if let Some(quote_end) = after_colon[quote_start+1..].find('"') {
20
- let version = &after_colon[quote_start+1..quote_start+1+quote_end];
21
- println!("cargo:rustc-env=NPM_VERSION={}", version);
22
- println!("cargo:rerun-if-changed=../package.json");
23
- println!("cargo:rerun-if-changed=src/template.html");
24
- return;
25
- }
26
- }
27
- }
28
- }
29
- }
30
- }
31
-
32
- // Fallback to Cargo version if package.json not found
33
- println!("cargo:rustc-env=NPM_VERSION={}", env!("CARGO_PKG_VERSION"));
2
+ // Version is now read at runtime from package.json, not embedded at build time
3
+ // Just set up rebuild triggers for template changes
4
+ println!("cargo:rerun-if-changed=src/template.html");
5
+ println!("cargo:rerun-if-changed=src/msger-api.js");
6
+ println!("cargo:rerun-if-changed=src/main.rs");
34
7
  }
@@ -164,7 +164,40 @@ struct MessageBoxResult {
164
164
  }
165
165
 
166
166
  fn default_title() -> String {
167
- format!("msger {}", env!("NPM_VERSION"))
167
+ // Read version from package.json at runtime (not embedded at build time)
168
+ let version = get_package_version().unwrap_or_else(|| "unknown".to_string());
169
+ format!("msger {}", version)
170
+ }
171
+
172
+ fn get_package_version() -> Option<String> {
173
+ // Read ../package.json relative to executable
174
+ let exe_path = std::env::current_exe().ok()?;
175
+ let exe_dir = exe_path.parent()?;
176
+
177
+ // Try multiple possible locations for package.json
178
+ let possible_paths = vec![
179
+ exe_dir.join("../package.json"), // Development: bin/../package.json
180
+ exe_dir.join("../../package.json"), // Installed globally: lib/node_modules/@bobfrankston/msger/package.json
181
+ exe_dir.join("../../../package.json"), // node_modules structure
182
+ ];
183
+
184
+ for path in possible_paths {
185
+ if let Ok(content) = std::fs::read_to_string(&path) {
186
+ // Simple JSON parsing - just extract version field
187
+ if let Some(version_line) = content.lines().find(|line| line.contains("\"version\"")) {
188
+ if let Some(start) = version_line.find("\":") {
189
+ let after_colon = &version_line[start+2..].trim_start();
190
+ if let Some(quote_start) = after_colon.find('"') {
191
+ if let Some(quote_end) = after_colon[quote_start+1..].find('"') {
192
+ return Some(after_colon[quote_start+1..quote_start+1+quote_end].to_string());
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }
199
+
200
+ None
168
201
  }
169
202
 
170
203
  fn default_width() -> i32 {
@@ -716,7 +749,7 @@ fn main() {
716
749
  is_maximized,
717
750
  is_fullscreen,
718
751
  is_always_on_top,
719
- env!("NPM_VERSION")
752
+ get_package_version().unwrap_or_else(|| "unknown".to_string())
720
753
  );
721
754
 
722
755
  // Show the info in an alert
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/msger",
3
- "version": "0.1.126",
3
+ "version": "0.1.128",
4
4
  "description": "Fast, lightweight, cross-platform message box - Rust-powered alternative to msgview",
5
5
  "type": "module",
6
6
  "main": "./index.js",