|
| 1 | +import {fileURLToPath} from "url"; |
| 2 | +import {dirname} from "path"; |
| 3 | +import fs from 'fs'; |
| 4 | +import chalk from 'chalk'; |
| 5 | + |
| 6 | +import {getPlatformDetails, patchTauriConfigWithMetricsHTML} from "./utils.js"; |
| 7 | +import os from "os"; |
| 8 | + |
| 9 | +const __filename = fileURLToPath(import.meta.url); |
| 10 | +const __dirname = dirname(__filename); |
| 11 | + |
| 12 | +async function createDistReleaseConfig() { |
| 13 | + const platform = getPlatformDetails().platform; |
| 14 | + const tauriConfigPath = (platform === "win") ? `${__dirname}\\..\\src-tauri\\tauri.conf.json` |
| 15 | + : `${__dirname}/../src-tauri/tauri.conf.json`; |
| 16 | + const tauriLocalConfigPath = (platform === "win") ? `${__dirname}\\..\\src-tauri\\tauri-local.conf.json` |
| 17 | + : `${__dirname}/../src-tauri/tauri-local.conf.json`; |
| 18 | + console.log("Reading Tauri config file: ", tauriConfigPath); |
| 19 | + let configJson = JSON.parse(fs.readFileSync(tauriConfigPath)); |
| 20 | + console.log(chalk.cyan("\n!Updates and signing is disabled while creating msi, appimage and dmg installers. If you want to sign, use tauri build commands directly.\n")); |
| 21 | + configJson.tauri.bundle.active = true; |
| 22 | + configJson.tauri.updater.active = false; |
| 23 | + configJson.build.distDir = '../../phoenix/dist/'; |
| 24 | + const phoenixVersion = configJson.package.version; |
| 25 | + if(os.platform() === 'win32'){ |
| 26 | + configJson.tauri.windows[0].url = `https://phtauri.localhost/v${phoenixVersion}/`; |
| 27 | + } else { |
| 28 | + configJson.tauri.windows[0].url = `phtauri://localhost/v${phoenixVersion}/`; |
| 29 | + } |
| 30 | + patchTauriConfigWithMetricsHTML(configJson); |
| 31 | + console.log("Window Boot url is: ", configJson.tauri.windows[0].url); |
| 32 | + console.log("Writing new local config json ", tauriLocalConfigPath); |
| 33 | + fs.writeFileSync(tauriLocalConfigPath, JSON.stringify(configJson, null, 4)); |
| 34 | +} |
| 35 | + |
| 36 | +await createDistReleaseConfig(); |
0 commit comments