🎨 Unified code style
This commit is contained in:
19
bin/helpers/merge.ts
vendored
19
bin/helpers/merge.ts
vendored
@@ -5,11 +5,7 @@ import { npmDirectory } from '@/utils/dir';
|
||||
import logger from '@/options/logger';
|
||||
import { PakeAppOptions, PlatformMap } from '@/types';
|
||||
|
||||
export async function mergeConfig(
|
||||
url: string,
|
||||
options: PakeAppOptions,
|
||||
tauriConf: any,
|
||||
) {
|
||||
export async function mergeConfig(url: string, options: PakeAppOptions, tauriConf: any) {
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
@@ -61,7 +57,7 @@ export async function mergeConfig(
|
||||
|
||||
const filesToCopyBack = ['cli.js', 'about_pake.html'];
|
||||
await Promise.all(
|
||||
filesToCopyBack.map((file) =>
|
||||
filesToCopyBack.map(file =>
|
||||
fsExtra.copy(path.join(distBakDir, file), path.join(distDir, file)),
|
||||
),
|
||||
);
|
||||
@@ -72,8 +68,7 @@ export async function mergeConfig(
|
||||
} else {
|
||||
tauriConf.pake.windows[0].url_type = 'web';
|
||||
// Set the secure domain for calling window.__TAURI__ to the application domain that has been set.
|
||||
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess[0].domain =
|
||||
new URL(url).hostname;
|
||||
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = new URL(url).hostname;
|
||||
}
|
||||
|
||||
const platformMap: PlatformMap = {
|
||||
@@ -95,7 +90,8 @@ export async function mergeConfig(
|
||||
delete tauriConf.tauri.bundle.deb.files;
|
||||
const validTargets = ['all', 'deb', 'appimage'];
|
||||
if (validTargets.includes(options.targets)) {
|
||||
tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
||||
tauriConf.tauri.bundle.targets =
|
||||
options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
||||
} else {
|
||||
logger.warn(
|
||||
`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`,
|
||||
@@ -165,9 +161,7 @@ export async function mergeConfig(
|
||||
trayIconPath = `png/${name.toLowerCase()}${iconExt}`;
|
||||
await fsExtra.copy(systemTrayIcon, trayIcoPath);
|
||||
} else {
|
||||
logger.warn(
|
||||
`✼ System tray icon must be .ico or .png, but you provided ${iconExt}.`,
|
||||
);
|
||||
logger.warn(`✼ System tray icon must be .ico or .png, but you provided ${iconExt}.`);
|
||||
logger.warn(`✼ Default system tray icon will be used.`);
|
||||
}
|
||||
} catch {
|
||||
@@ -192,7 +186,6 @@ export async function mergeConfig(
|
||||
const pakeConfigPath = path.join(npmDirectory, 'src-tauri/pake.json');
|
||||
await fsExtra.writeJson(pakeConfigPath, tauriConf.pake, { spaces: 4 });
|
||||
|
||||
|
||||
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
||||
delete tauriConf2.pake;
|
||||
delete tauriConf2.tauri.bundle;
|
||||
|
||||
6
bin/helpers/rust.ts
vendored
6
bin/helpers/rust.ts
vendored
@@ -1,13 +1,13 @@
|
||||
import chalk from "chalk";
|
||||
import chalk from 'chalk';
|
||||
import shelljs from 'shelljs';
|
||||
|
||||
import { getSpinner } from "@/utils/info";
|
||||
import { getSpinner } from '@/utils/info';
|
||||
import { IS_WIN } from '@/utils/platform';
|
||||
import { shellExec } from '@/utils/shell';
|
||||
import { isChinaDomain } from '@/utils/ip';
|
||||
|
||||
export async function installRust() {
|
||||
const isInChina = await isChinaDomain("sh.rustup.rs");
|
||||
const isInChina = await isChinaDomain('sh.rustup.rs');
|
||||
const rustInstallScriptForMac = isInChina
|
||||
? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh'
|
||||
: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
|
||||
|
||||
6
bin/helpers/tauriConfig.ts
vendored
6
bin/helpers/tauriConfig.ts
vendored
@@ -7,10 +7,10 @@ import LinuxConf from '../../src-tauri/tauri.linux.conf.json';
|
||||
const platformConfigs = {
|
||||
win32: WinConf,
|
||||
darwin: MacConf,
|
||||
linux: LinuxConf
|
||||
linux: LinuxConf,
|
||||
};
|
||||
|
||||
const {platform} = process;
|
||||
const { platform } = process;
|
||||
// @ts-ignore
|
||||
const platformConfig = platformConfigs[platform];
|
||||
|
||||
@@ -21,7 +21,7 @@ let tauriConfig = {
|
||||
},
|
||||
package: CommonConf.package,
|
||||
build: CommonConf.build,
|
||||
pake: pakeConf
|
||||
pake: pakeConf,
|
||||
};
|
||||
|
||||
export default tauriConfig;
|
||||
|
||||
Reference in New Issue
Block a user