@@ -30,18 +30,43 @@ async function rESM(name) {
3030 return await import ( name ) ;
3131}
3232
33- // ─── Deps check ───────────────────────────────────────────────────────────────
33+ // ─── Deps check (isFirstLaunch.txt flag) ──────────────────────────────────────
34+ function getFirstLaunchPath ( ) {
35+ // In packaged app: use Program Files install dir or userData
36+ if ( app . isPackaged ) {
37+ // Try the app's install directory first
38+ const installDir = path . dirname ( app . getPath ( 'exe' ) ) ;
39+ const installFlag = path . join ( installDir , 'isFirstLaunch.txt' ) ;
40+ // If we can't write to install dir (permissions), fall back to userData
41+ try {
42+ fs . accessSync ( installDir , fs . constants . W_OK ) ;
43+ return installFlag ;
44+ } catch {
45+ return path . join ( app . getPath ( 'userData' ) , 'isFirstLaunch.txt' ) ;
46+ }
47+ }
48+ // Dev mode: use project root
49+ return path . join ( __dirname , 'isFirstLaunch.txt' ) ;
50+ }
51+
3452function isDepsInstalled ( ) {
35- if ( ! app . isPackaged ) return true ;
36- const marker = path . join ( MODULES_DIR , '.cc-installed' ) ;
37- if ( ! fs . existsSync ( marker ) ) return false ;
53+ const flagPath = getFirstLaunchPath ( ) ;
54+ if ( ! fs . existsSync ( flagPath ) ) return false ;
3855 try {
39- return fs . readFileSync ( marker , 'utf-8' ) . trim ( ) === app . getVersion ( ) ;
56+ const content = fs . readFileSync ( flagPath , 'utf-8' ) . trim ( ) ;
57+ return content === 'True' ;
4058 } catch { return false ; }
4159}
4260
4361function markDepsInstalled ( ) {
44- fs . writeFileSync ( path . join ( MODULES_DIR , '.cc-installed' ) , app . getVersion ( ) , 'utf-8' ) ;
62+ const flagPath = getFirstLaunchPath ( ) ;
63+ try {
64+ fs . writeFileSync ( flagPath , 'True' , 'utf-8' ) ;
65+ } catch ( e ) {
66+ // Fallback: write to userData if install dir is read-only
67+ const fallback = path . join ( app . getPath ( 'userData' ) , 'isFirstLaunch.txt' ) ;
68+ fs . writeFileSync ( fallback , 'True' , 'utf-8' ) ;
69+ }
4570}
4671
4772// ─── Setup window ─────────────────────────────────────────────────────────────
0 commit comments