diff --git a/.gitignore b/.gitignore index fffe48f..afcb5a4 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ coverage/ target/ release/ build/ +/bin/ # ========================== # Logs diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..c3c31be --- /dev/null +++ b/.npmignore @@ -0,0 +1,27 @@ +# Ignore Rust backend and build files +src-tauri/ +target/ +out/ +rustc_checker.py + +# Ignore local configuration and developer tools +.agents/ +.antigravitycli/ +.cargo_home/ +.codex/ +.rustup/ +.rustup_copy/ +.rustup_home/ +.vite-web/ +.env* +logs/ + +# Ignore documentation and guidelines +docs/ +BUILD_AND_RELEASE.md +CONTRIBUTING.md +TAURI_MIGRATION.md + +# Ignore installer scripts +install.sh +install.ps1 diff --git a/BUILD_AND_RELEASE.md b/BUILD_AND_RELEASE.md index bc18a0d..c879fd6 100644 --- a/BUILD_AND_RELEASE.md +++ b/BUILD_AND_RELEASE.md @@ -43,3 +43,19 @@ runs publish a GitHub Release. The updater requires a configured release endpoint, a public key in the Tauri config, and signed release artifacts. Exercise update installation against the published endpoint before promoting a release. + +## Publish to npm + +To publish the repository package to the npm registry as a public scoped package: + +1. **Log in to npm** (if not already logged in): + ```bash + npm login + ``` + +2. **Publish the package** (since `@pheem49/mint` is a scoped package, you must specify public access): + ```bash + npm publish --access public + ``` + +*Note: You must bump the version number in `package.json` before publishing a new version.* diff --git a/Cargo.toml b/Cargo.toml index 241a845..a8f02c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ resolver = "2" [workspace.package] -version = "1.6.0" +version = "1.6.2" edition = "2024" license = "AGPL-3.0-only" diff --git a/crates/mint-cli/src/main.rs b/crates/mint-cli/src/main.rs index 8b31376..75c1897 100644 --- a/crates/mint-cli/src/main.rs +++ b/crates/mint-cli/src/main.rs @@ -947,12 +947,36 @@ async fn launch_mint_target(target: String) -> Result<()> { println!( "{MINT}Launching Web App (vite) in background...{RESET} {DIM}(Vite Dev UI at http://localhost:9000){RESET}" ); - let project_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .parent() - .and_then(|p| p.parent()) - .ok_or_else(|| anyhow::anyhow!("Failed to find project root directory"))?; + let project_root = { + let mut found = None; + if let Ok(exe_path) = std::env::current_exe() { + let mut path = exe_path.parent(); + while let Some(p) = path { + if p.join("package.json").exists() { + found = Some(p.to_path_buf()); + break; + } + path = p.parent(); + } + } + if found.is_none() { + if let Ok(cwd) = std::env::current_dir() { + let mut path = Some(cwd.as_path()); + while let Some(p) = path { + if p.join("package.json").exists() { + found = Some(p.to_path_buf()); + break; + } + path = p.parent(); + } + } + } + found.ok_or_else(|| { + anyhow::anyhow!("Failed to find project root directory containing package.json") + })? + }; std::process::Command::new("npm") - .current_dir(project_root) + .current_dir(&project_root) .args(&["run", "dev:web"]) .stdout(std::process::Stdio::null()) .stderr(std::process::Stdio::null()) diff --git a/package.json b/package.json index 32fabe5..3e32ccd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pheem49/mint", - "version": "1.6.0", + "version": "1.6.2", "description": "A native Tauri desktop AI assistant with a Rust backend and React UI.", "scripts": { "dev:web": "vite --config vite.config.web.ts", @@ -24,29 +24,41 @@ "preview": "vite preview", "start": "tauri dev", "test": "cargo test -p mint-core -p mint-cli", - "cli": "cargo run -p mint-cli --" + "cli": "cargo run -p mint-cli --", + "postinstall": "cargo build -p mint-cli --release && mkdir -p bin && cp target/release/mint bin/mint" }, "keywords": [], + "repository": { + "type": "git", + "url": "git+https://github.com/Pheem49/Mint.git" + }, + "bugs": { + "url": "https://github.com/Pheem49/Mint/issues" + }, + "homepage": "https://github.com/Pheem49/Mint#readme", "author": { "name": "Pheem49", "email": "killerpheem13@gmail.com" }, "license": "AGPL-3.0-only", "type": "commonjs", + "bin": { + "mint": "src/bin/index.js" + }, "dependencies": { "@tauri-apps/api": "^2.0.0", - "pixi-live2d-display": "^0.4.0", - "pixi.js": "^6.5.10", - "react": "^19.2.5" - }, - "devDependencies": { - "@tauri-apps/cli": "^2.0.0", "@vitejs/plugin-react": "^6.0.1", "material-icon-theme": "^5.35.0", + "pixi-live2d-display": "^0.4.0", + "pixi.js": "^6.5.10", + "react": "^19.2.5", "react-dom": "^19.2.5", "typescript": "^6.0.3", "vite": "^8.0.10" }, + "devDependencies": { + "@tauri-apps/cli": "^2.0.0" + }, "overrides": { "gh-pages": "^5.0.0" } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 676a406..eb7d19c 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Mint", - "version": "1.6.0", + "version": "1.6.2", "identifier": "com.pheem49.mint", "build": { "beforeDevCommand": "npm run dev:desktop", diff --git a/src/bin/index.js b/src/bin/index.js new file mode 100644 index 0000000..add9e51 --- /dev/null +++ b/src/bin/index.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +const { spawn } = require('child_process'); +const path = require('path'); + +// ชี้ไปยังไฟล์ Rust Binary ที่คอมไพล์สำเร็จแล้วในเครื่องผู้ใช้ +const binaryPath = path.join(__dirname, '..', '..', 'bin', 'mint'); + +// สั่งทำงานไฟล์ Binary โดยส่งอาร์กิวเมนต์ทั้งหมดต่อเข้าไป +const child = spawn(binaryPath, process.argv.slice(2), { + stdio: 'inherit' +}); + +child.on('close', (code) => { + process.exit(code); +});