diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts index c7438aa79..334f6ab7b 100644 --- a/bin/helpers/merge.ts +++ b/bin/helpers/merge.ts @@ -5,7 +5,7 @@ import { npmDirectory } from '@/utils/dir'; import combineFiles from '@/utils/combine'; import logger from '@/options/logger'; import { PakeAppOptions, PlatformMap } from '@/types'; -import { tauriConfigDirectory } from '../utils/dir'; +import { tauriConfigDirectory } from '@/utils/dir'; export async function mergeConfig(url: string, options: PakeAppOptions, tauriConf: any) { const { diff --git a/package.json b/package.json index bfe2225e4..48ea867d1 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build": "npm run tauri build --release", "build:debug": "npm run tauri build -- --debug", "build:mac": "npm run tauri build -- --target universal-apple-darwin", - "build:config": "chmod +x ./script/build_with_app_config.js && node ./script/build_with_app_config.js", + "build:config": "chmod +x script/app_config.mjs && node script/app_config.mjs", "analyze": "cd src-tauri && cargo bloat --release --crates", "tauri": "tauri", "cli": "rollup -c rollup.config.js --watch", diff --git a/script/build_with_app_config.js b/script/app_config.mjs similarity index 87% rename from script/build_with_app_config.js rename to script/app_config.mjs index 6d8ba9ef1..d4baff716 100755 --- a/script/build_with_app_config.js +++ b/script/app_config.mjs @@ -1,11 +1,11 @@ -import { writeFileSync, existsSync, copyFileSync, readFileSync } from 'fs'; -import os from 'os'; +import pakeJson from '../src-tauri/pake.json' assert { type: 'json' }; +import tauriJson from '../src-tauri/tauri.conf.json' assert { type: 'json' }; +import windowsJson from '../src-tauri/tauri.windows.conf.json' assert { type: 'json' }; +import macosJson from '../src-tauri/tauri.macos.conf.json' assert { type: 'json' }; +import linuxJson from '../src-tauri/tauri.linux.conf.json' assert { type: 'json' }; -const pakeJson = JSON.parse(readFileSync('../src-tauri/pake.json', 'utf-8')); -const tauriJson = JSON.parse(readFileSync('../src-tauri/tauri.conf.json', 'utf-8')); -const windowsJson = JSON.parse(readFileSync('../src-tauri/tauri.windows.conf.json', 'utf-8')); -const macosJson = JSON.parse(readFileSync('../src-tauri/tauri.macos.conf.json', 'utf-8')); -const linuxJson = JSON.parse(readFileSync('../src-tauri/tauri.linux.conf.json', 'utf-8')); +import { writeFileSync, existsSync, copyFileSync } from 'fs'; +import os from 'os'; const desktopEntry = `[Desktop Entry] Encoding=UTF-8 @@ -86,6 +86,7 @@ switch (os.platform()) { break; } + updateIconFile(platformVariables.iconPath, platformVariables.defaultIconPath); updatePlatformConfig(platformConfig, platformVariables); @@ -93,28 +94,28 @@ updatePlatformConfig(platformConfig, platformVariables); save(); function validate() { - if ('URL' in process.env === false) { + if (!('URL' in process.env)) { console.log('URL is not set'); process.exit(1); } console.log(`URL: ${process.env.URL}`); - if ('NAME' in process.env === false) { + if (!('NAME' in process.env)) { console.log('NAME is not set'); process.exit(1); } console.log(`NAME: ${process.env.NAME}`); - if ('TITLE' in process.env === false) { + if (!('TITLE' in process.env)) { console.log('TITLE is not set'); process.exit(1); } console.log(`TITLE: ${process.env.TITLE}`); - if ('NAME_ZH' in process.env === false) { + if (!('NAME_ZH' in process.env)) { console.log('NAME_ZH is not set'); process.exit(1); } @@ -147,6 +148,7 @@ function updatePlatformConfig(platformConfig, platformVariables) { } function save() { + writeFileSync(variables.pakeConfigPath, JSON.stringify(pakeJson, null, 2)); writeFileSync(variables.tauriConfigPath, JSON.stringify(tauriJson, null, 2)); @@ -156,6 +158,7 @@ function save() { writeFileSync(variables.macos.configFilePath, JSON.stringify(macosJson, null, 2)); writeFileSync(variables.windows.configFilePath, JSON.stringify(windowsJson, null, 2)); + } function updateDesktopEntry() { diff --git a/script/build_with_pake_cli.js b/script/build_with_pake_cli.js index 9df1e77c4..e9273f576 100644 --- a/script/build_with_pake_cli.js +++ b/script/build_with_pake_cli.js @@ -1,8 +1,6 @@ import shelljs from 'shelljs'; import axios from 'axios'; import fs from 'fs'; -import { fileURLToPath } from 'url'; -import { dirname } from 'path'; const { exec, cd, mv } = shelljs;