Skip to content

Commit

Permalink
🐛 fix build app
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed Aug 28, 2023
1 parent 49a045c commit a5d36f4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bin/helpers/merge.ts
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
25 changes: 14 additions & 11 deletions script/build_with_app_config.js → 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
Expand Down Expand Up @@ -86,35 +86,36 @@ switch (os.platform()) {
break;
}


updateIconFile(platformVariables.iconPath, platformVariables.defaultIconPath);

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);
}
Expand Down Expand Up @@ -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));

Expand All @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions 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;

Expand Down

0 comments on commit a5d36f4

Please sign in to comment.