refactor: support proxy option

This commit is contained in:
jeasonnow
2024-07-30 16:54:36 +08:00
parent a631e117ca
commit 5752996f89
7 changed files with 17 additions and 3 deletions

1
bin/cli.ts vendored
View File

@@ -33,6 +33,7 @@ program
.option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT.multiArch)
.option('--inject [injects...]', 'Injection of .js or .css Files', DEFAULT.inject)
.option('--debug', 'Debug build and more output', DEFAULT.debug)
.option('--proxy-url', "Proxy URL", DEFAULT.proxyUrl)
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT.userAgent).hideHelp())
.addOption(
new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(),

1
bin/defaults.ts vendored
View File

@@ -16,6 +16,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
targets: 'deb',
useLocalFile: false,
systemTrayIcon: '',
proxyUrl: "",
debug: false,
inject: [],
safeDomain: [],

View File

@@ -24,6 +24,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
name,
resizable = true,
inject,
proxyUrl,
} = options;
const { platform } = process;
@@ -189,6 +190,8 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
await fsExtra.writeFile(injectFilePath, '');
}
tauriConf.pake.proxy_url = proxyUrl || "";
// Save config file.
const platformConfigPaths: PlatformMap = {
win32: 'tauri.windows.conf.json',

3
bin/types.ts vendored
View File

@@ -59,6 +59,9 @@ export interface PakeCliOptions {
/* the domain that can use ipc or tauri javascript sdk */
safeDomain: string[];
// Proxy
proxyUrl: string;
}
export interface PakeAppOptions extends PakeCliOptions {