diff --git a/bin/builders/common.ts b/bin/builders/common.ts index b081e35..06b2d19 100644 --- a/bin/builders/common.ts +++ b/bin/builders/common.ts @@ -37,6 +37,25 @@ export async function mergeTauriConfig( transparent, resizable, }; + // Package name is valid ? + // for Linux, package name must be a-z, 0-9 or "-", not allow to A-Z and other + if (process.platform === "linux") { + const reg = new RegExp(/[0-9]*[a-z]+[0-9]*\-?[0-9]*[a-z]*[0-9]*\-?[0-9]*[a-z]*[0-9]*/); + if (!reg.test(name) || reg.exec(name)[0].length != name.length) { + logger.error("package name is illegal, it must be lowercase letters, numbers, dashes, and it must contain the lowercase letters.") + logger.error("E.g com-123-xxx, 123pan, pan123,weread, we-read"); + process.exit(); + } + } + if (process.platform === "win32" || process.platform === "darwin" ) { + const reg = new RegExp(/([0-9]*[a-zA-Z]+[0-9]*)+/); + if (!reg.test(name) || reg.exec(name)[0].length != name.length) { + logger.error("package name is illegal, it must be letters, numbers, and it must contain the letters") + logger.error("E.g 123pan,123Pan Pan123,weread, WeRead, WERead"); + process.exit(); + } + } + Object.assign(tauriConf.tauri.windows[0], { url, ...tauriConfWindowOptions }); tauriConf.package.productName = name; diff --git a/dist/cli.js b/dist/cli.js index 0415c56..468a13b 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1632,6 +1632,24 @@ function mergeTauriConfig(url, options, tauriConf) { transparent, resizable, }; + // Package name is valid ? + // for Linux, package name must be a-z, 0-9 or "-", not allow to A-Z and other + if (process.platform === "linux") { + const reg = new RegExp(/[0-9]*[a-z]+[0-9]*\-?[0-9]*[a-z]*[0-9]*\-?[0-9]*[a-z]*[0-9]*/); + if (!reg.test(name) || reg.exec(name)[0].length != name.length) { + logger.error("package name is illegal, it must be lowercase letters, numbers, dashes, and it must contain the lowercase letters."); + logger.error("E.g com-123-xxx, 123pan, pan123,weread, we-read"); + process.exit(); + } + } + if (process.platform === "win32" || process.platform === "darwin") { + const reg = new RegExp(/([0-9]*[a-zA-Z]+[0-9]*)+/); + if (!reg.test(name) || reg.exec(name)[0].length != name.length) { + logger.error("package name is illegal, it must be letters, numbers, and it must contain the letters"); + logger.error("E.g 123pan,123Pan Pan123,weread, WeRead, WERead"); + process.exit(); + } + } Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions)); tauriConf.package.productName = name; tauriConf.tauri.bundle.identifier = identifier; @@ -2209,7 +2227,7 @@ var scripts = { tauri: "tauri", cli: "rollup -c rollup.config.js --watch", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", - "cli:publish": "npm run cli:build && npm publish" + prepublishOnly: "npm run cli:build" }; var type = "module"; var exports = "./dist/pake.js"; diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d829449..0489c7d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -22,6 +22,8 @@ image = "0.24.5" home = "0.5" tauri-utils = "1.2.1" tauri-plugin-window-state = { git = "https://github.com/tauri-apps/tauri-plugin-window-state", branch = "dev"} + +[target.'cfg(target_os = "linux")'.dependencies] webkit2gtk = "0.18.0" # webbrowser = "0.8.2" # wry = "0.23.4" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0ac2093..2fce32d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -9,51 +9,32 @@ use app::{get_menu, menu_event_handle}; pub fn run_app() { let system_tray = get_system_tray(); + let (pake_config, tauri_config) = get_pake_config(); + let data_dir = get_data_dir(tauri_config); #[cfg(target_os = "macos")] - { - let (pake_config, _) = get_pake_config(); + let tauri_app = { let menu = get_menu(); tauri::Builder::default() .menu(menu) .on_menu_event(menu_event_handle) - .system_tray(system_tray) - .on_system_tray_event(system_tray_handle) - .plugin(tauri_plugin_window_state::Builder::default().build()) - .invoke_handler(tauri::generate_handler![]) - .setup(|app| { - let _window = get_window(app, pake_config, std::path::PathBuf::new()); - #[cfg(feature = "devtools")] - { - app.get_window("pake").unwrap().open_devtools(); - } - Ok(()) - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } + }; #[cfg(any(target_os = "linux", target_os = "windows"))] - { - let (pake_config, tauri_config) = get_pake_config(); - let data_dir = get_data_dir(tauri_config); - // let menu = get_menu(); - tauri::Builder::default() - // .menu(menu) - // .on_menu_event(menu_event_handle) - .system_tray(system_tray) - .on_system_tray_event(system_tray_handle) - .plugin(tauri_plugin_window_state::Builder::default().build()) - .invoke_handler(tauri::generate_handler![]) - .setup(|app| { - let _window = get_window(app, pake_config, data_dir); - #[cfg(feature = "devtools")] - { - app.get_window("pake").unwrap().open_devtools(); - } - Ok(()) - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } + let tauri_app = tauri::Builder::default(); + tauri_app + .system_tray(system_tray) + .on_system_tray_event(system_tray_handle) + .plugin(tauri_plugin_window_state::Builder::default().build()) + .invoke_handler(tauri::generate_handler![]) + .setup(|app| { + let _window = get_window(app, pake_config, data_dir); + #[cfg(feature = "devtools")] + { + _window.open_devtools(); + } + Ok(()) + }) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } fn main() {