@@ -3,48 +3,20 @@ import {dirname} from "path";
33import fs from 'fs' ;
44import chalk from 'chalk' ;
55
6- import { getPlatformDetails } from "./utils.js" ;
6+ import { getPlatformDetails , patchTauriConfigWithMetricsHTML } from "./utils.js" ;
77import os from "os" ;
88
99const __filename = fileURLToPath ( import . meta. url ) ;
1010const __dirname = dirname ( __filename ) ;
1111
12- const METRIC_URL_FOR_STAGE = {
13- "dev" : "https://dev.phcode.dev/desktop-metrics.html" ,
14- "stage" : "https://staging.phcode.dev/desktop-metrics.html" ,
15- "production" : "https://phcode.dev/desktop-metrics.html"
16- } ;
17-
18- function _patchTauriConfigWithMetricsHTML ( tauriConf , metricsHTMLPageURL ) {
19- const window = tauriConf . tauri . windows [ 1 ] ;
20- if ( ! window . label === "healthData" ) {
21- throw new Error ( "Expected tauriConf.json- tauri.windows[1].label to be 'healthData'" ) ;
22- }
23- window . url = metricsHTMLPageURL ;
24- const metricsPageURL = new URL ( metricsHTMLPageURL )
25- const dangerousRemoteDomainIpcAccess = tauriConf . tauri . security . dangerousRemoteDomainIpcAccess ;
26- for ( let ipc of dangerousRemoteDomainIpcAccess ) {
27- if ( ipc . windows . includes ( "healthData" ) ) {
28- ipc . scheme = "https" ;
29- ipc . domain = metricsPageURL . host ;
30- }
31- }
32- }
33-
3412async function createDistReleaseConfig ( ) {
3513 const platform = getPlatformDetails ( ) . platform ;
3614 const tauriConfigPath = ( platform === "win" ) ? `${ __dirname } \\..\\src-tauri\\tauri.conf.json`
3715 : `${ __dirname } /../src-tauri/tauri.conf.json` ;
38- const phoenixConfigPath = ( platform === "win" ) ? `${ __dirname } \\...\\..\\phoenix\\dist\\config.json`
39- : `${ __dirname } /../../phoenix/dist/config.json` ;
4016 const tauriLocalConfigPath = ( platform === "win" ) ? `${ __dirname } \\..\\src-tauri\\tauri-local.conf.json`
4117 : `${ __dirname } /../src-tauri/tauri-local.conf.json` ;
4218 console . log ( "Reading Tauri config file: " , tauriConfigPath ) ;
4319 let configJson = JSON . parse ( fs . readFileSync ( tauriConfigPath ) ) ;
44- console . log ( "Reading Phoenix config file: " , phoenixConfigPath ) ;
45- let phoenixConfigJson = JSON . parse ( fs . readFileSync ( phoenixConfigPath ) ) ;
46- const phoenixStageInDist = phoenixConfigJson . config . environment ;
47- console . log ( "Phoenix stage in dist folder is: " , phoenixStageInDist ) ;
4820 console . log ( chalk . cyan ( "\n!Only creating executables. Creating msi, appimage and dmg installers are disabled in this build. If you want to create an installer, use: npm run tauri build manually after setting distDir in tauri conf!\n" ) ) ;
4921 configJson . tauri . bundle . active = false ;
5022 configJson . build . distDir = '../../phoenix/dist/' ;
@@ -54,14 +26,9 @@ async function createDistReleaseConfig() {
5426 } else {
5527 configJson . tauri . windows [ 0 ] . url = `phtauri://localhost/v${ phoenixVersion } /` ;
5628 }
57- const metricsURLToUse = METRIC_URL_FOR_STAGE [ phoenixStageInDist ] ;
58- if ( ! metricsURLToUse ) {
59- throw new Error ( "Unknown Phoenix stage(config.environment) in file " + phoenixConfigPath ) ;
60- }
61- _patchTauriConfigWithMetricsHTML ( configJson , metricsURLToUse ) ;
29+ patchTauriConfigWithMetricsHTML ( configJson ) ;
6230 console . log ( "Window Boot url is: " , configJson . tauri . windows [ 0 ] . url ) ;
6331 console . log ( "Writing new local config json " , tauriLocalConfigPath ) ;
64- console . log ( "Window Metrics url " , configJson . tauri . windows [ 1 ] . url ) ;
6532 fs . writeFileSync ( tauriLocalConfigPath , JSON . stringify ( configJson , null , 4 ) ) ;
6633}
6734
0 commit comments