pake-cli 3.2.15 → 3.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +340 -323
- package/dist/cli.js +282 -74
- package/package.json +11 -9
- package/src-tauri/.cargo/config.toml +0 -11
- package/src-tauri/.pake/pake.json +5 -4
- package/src-tauri/.pake/tauri.conf.json +9 -7
- package/src-tauri/.pake/tauri.macos.conf.json +3 -4
- package/src-tauri/capabilities/default.json +2 -1
- package/src-tauri/gen/schemas/capabilities.json +1 -1
- package/src-tauri/src/app/config.rs +1 -0
- package/src-tauri/src/app/invoke.rs +27 -7
- package/src-tauri/src/app/window.rs +7 -0
- package/src-tauri/src/inject/event.js +524 -20
- package/src-tauri/src/util.rs +35 -18
- package/src-tauri/tauri.conf.json +3 -0
- package/src-tauri/tauri.macos.conf.json +0 -1
- package/src-tauri/gen/schemas/windows-schema.json +0 -2326
package/dist/cli.js
CHANGED
|
@@ -22,11 +22,12 @@ import sharp from 'sharp';
|
|
|
22
22
|
import * as psl from 'psl';
|
|
23
23
|
|
|
24
24
|
var name = "pake-cli";
|
|
25
|
-
var version = "3.2.
|
|
25
|
+
var version = "3.2.17";
|
|
26
26
|
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
|
|
27
27
|
var engines = {
|
|
28
|
-
node: ">=
|
|
28
|
+
node: ">=18.0.0"
|
|
29
29
|
};
|
|
30
|
+
var packageManager = "pnpm@10.15.0";
|
|
30
31
|
var bin = {
|
|
31
32
|
pake: "./dist/cli.js"
|
|
32
33
|
};
|
|
@@ -51,19 +52,20 @@ var files = [
|
|
|
51
52
|
"src-tauri"
|
|
52
53
|
];
|
|
53
54
|
var scripts = {
|
|
54
|
-
start: "
|
|
55
|
-
dev: "
|
|
56
|
-
build: "
|
|
57
|
-
"build:debug": "
|
|
58
|
-
"build:mac": "
|
|
55
|
+
start: "pnpm run dev",
|
|
56
|
+
dev: "pnpm run tauri dev",
|
|
57
|
+
build: "tauri build",
|
|
58
|
+
"build:debug": "tauri build --debug",
|
|
59
|
+
"build:mac": "tauri build --target universal-apple-darwin",
|
|
59
60
|
"build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
|
|
60
61
|
analyze: "cd src-tauri && cargo bloat --release --crates",
|
|
61
62
|
tauri: "tauri",
|
|
62
63
|
cli: "cross-env NODE_ENV=development rollup -c -w",
|
|
63
64
|
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
64
|
-
test: "
|
|
65
|
+
test: "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
65
66
|
format: "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
66
|
-
|
|
67
|
+
"format:check": "prettier --check . --ignore-unknown",
|
|
68
|
+
prepublishOnly: "pnpm run cli:build"
|
|
67
69
|
};
|
|
68
70
|
var type = "module";
|
|
69
71
|
var exports = "./dist/cli.js";
|
|
@@ -111,6 +113,7 @@ var packageJson = {
|
|
|
111
113
|
version: version,
|
|
112
114
|
description: description,
|
|
113
115
|
engines: engines,
|
|
116
|
+
packageManager: packageManager,
|
|
114
117
|
bin: bin,
|
|
115
118
|
repository: repository,
|
|
116
119
|
author: author,
|
|
@@ -344,7 +347,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
344
347
|
await fsExtra.copy(sourcePath, destPath);
|
|
345
348
|
}
|
|
346
349
|
}));
|
|
347
|
-
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, } = options;
|
|
350
|
+
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, } = options;
|
|
348
351
|
const { platform } = process;
|
|
349
352
|
// Set Windows parameters.
|
|
350
353
|
const tauriConfWindowOptions = {
|
|
@@ -360,6 +363,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
360
363
|
hide_on_close: hideOnClose,
|
|
361
364
|
incognito: incognito,
|
|
362
365
|
title: title || null,
|
|
366
|
+
enable_wasm: wasm,
|
|
363
367
|
};
|
|
364
368
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
|
365
369
|
tauriConf.productName = name;
|
|
@@ -435,9 +439,19 @@ StartupNotify=true
|
|
|
435
439
|
tauriConf.bundle.linux.deb.files = {
|
|
436
440
|
[`/usr/share/applications/${desktopFileName}`]: `assets/${desktopFileName}`,
|
|
437
441
|
};
|
|
438
|
-
const validTargets = [
|
|
442
|
+
const validTargets = [
|
|
443
|
+
'deb',
|
|
444
|
+
'appimage',
|
|
445
|
+
'rpm',
|
|
446
|
+
'deb-arm64',
|
|
447
|
+
'appimage-arm64',
|
|
448
|
+
'rpm-arm64',
|
|
449
|
+
];
|
|
450
|
+
const baseTarget = options.targets.includes('-arm64')
|
|
451
|
+
? options.targets.replace('-arm64', '')
|
|
452
|
+
: options.targets;
|
|
439
453
|
if (validTargets.includes(options.targets)) {
|
|
440
|
-
tauriConf.bundle.targets = [
|
|
454
|
+
tauriConf.bundle.targets = [baseTarget];
|
|
441
455
|
}
|
|
442
456
|
else {
|
|
443
457
|
logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
|
|
@@ -543,6 +557,15 @@ StartupNotify=true
|
|
|
543
557
|
await fsExtra.writeFile(injectFilePath, '');
|
|
544
558
|
}
|
|
545
559
|
tauriConf.pake.proxy_url = proxyUrl || '';
|
|
560
|
+
// Configure WASM support with required HTTP headers
|
|
561
|
+
if (wasm) {
|
|
562
|
+
tauriConf.app.security = {
|
|
563
|
+
headers: {
|
|
564
|
+
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
565
|
+
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
566
|
+
},
|
|
567
|
+
};
|
|
568
|
+
}
|
|
546
569
|
// Save config file.
|
|
547
570
|
const platformConfigPaths = {
|
|
548
571
|
win32: 'tauri.windows.conf.json',
|
|
@@ -579,6 +602,32 @@ class BaseBuilder {
|
|
|
579
602
|
getBuildTimeout() {
|
|
580
603
|
return 900000; // 15 minutes for all builds
|
|
581
604
|
}
|
|
605
|
+
async detectPackageManager() {
|
|
606
|
+
// 使用缓存避免重复检测
|
|
607
|
+
if (BaseBuilder.packageManagerCache) {
|
|
608
|
+
return BaseBuilder.packageManagerCache;
|
|
609
|
+
}
|
|
610
|
+
const { execa } = await import('execa');
|
|
611
|
+
// 优先使用pnpm(如果可用)
|
|
612
|
+
try {
|
|
613
|
+
await execa('pnpm', ['--version'], { stdio: 'ignore' });
|
|
614
|
+
logger.info('✺ Using pnpm for package management.');
|
|
615
|
+
BaseBuilder.packageManagerCache = 'pnpm';
|
|
616
|
+
return 'pnpm';
|
|
617
|
+
}
|
|
618
|
+
catch {
|
|
619
|
+
// pnpm不可用,回退到npm
|
|
620
|
+
try {
|
|
621
|
+
await execa('npm', ['--version'], { stdio: 'ignore' });
|
|
622
|
+
logger.info('✺ pnpm not available, using npm for package management.');
|
|
623
|
+
BaseBuilder.packageManagerCache = 'npm';
|
|
624
|
+
return 'npm';
|
|
625
|
+
}
|
|
626
|
+
catch {
|
|
627
|
+
throw new Error('Neither pnpm nor npm is available. Please install a package manager.');
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
582
631
|
async prepare() {
|
|
583
632
|
const tauriSrcPath = path.join(npmDirectory, 'src-tauri');
|
|
584
633
|
const tauriTargetPath = path.join(tauriSrcPath, 'target');
|
|
@@ -606,22 +655,23 @@ class BaseBuilder {
|
|
|
606
655
|
const rustProjectDir = path.join(tauriSrcPath, '.cargo');
|
|
607
656
|
const projectConf = path.join(rustProjectDir, 'config.toml');
|
|
608
657
|
await fsExtra.ensureDir(rustProjectDir);
|
|
609
|
-
//
|
|
610
|
-
const packageManager =
|
|
658
|
+
// 智能检测可用的包管理器
|
|
659
|
+
const packageManager = await this.detectPackageManager();
|
|
611
660
|
const registryOption = isChina
|
|
612
661
|
? ' --registry=https://registry.npmmirror.com'
|
|
613
662
|
: '';
|
|
614
|
-
|
|
663
|
+
// 根据包管理器类型设置依赖冲突解决选项
|
|
664
|
+
const peerDepsOption = packageManager === 'npm' ? ' --legacy-peer-deps' : '';
|
|
615
665
|
const timeout = this.getInstallTimeout();
|
|
616
666
|
const buildEnv = this.getBuildEnvironment();
|
|
617
667
|
if (isChina) {
|
|
618
|
-
logger.info(
|
|
668
|
+
logger.info(`✺ Located in China, using ${packageManager}/rsProxy CN mirror.`);
|
|
619
669
|
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
|
620
670
|
await fsExtra.copy(projectCnConf, projectConf);
|
|
621
|
-
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${
|
|
671
|
+
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption} --silent`, timeout, buildEnv);
|
|
622
672
|
}
|
|
623
673
|
else {
|
|
624
|
-
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${
|
|
674
|
+
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption} --silent`, timeout, buildEnv);
|
|
625
675
|
}
|
|
626
676
|
spinner.succeed(chalk.green('Package installed!'));
|
|
627
677
|
if (!tauriTargetPathExists) {
|
|
@@ -637,15 +687,17 @@ class BaseBuilder {
|
|
|
637
687
|
async buildAndCopy(url, target) {
|
|
638
688
|
const { name } = this.options;
|
|
639
689
|
await mergeConfig(url, this.options, tauriConfig);
|
|
690
|
+
// Detect available package manager
|
|
691
|
+
const packageManager = await this.detectPackageManager();
|
|
640
692
|
// Build app
|
|
641
693
|
const buildSpinner = getSpinner('Building app...');
|
|
642
|
-
// Let spinner run for a moment so user can see it, then stop before
|
|
694
|
+
// Let spinner run for a moment so user can see it, then stop before package manager command
|
|
643
695
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
644
696
|
buildSpinner.stop();
|
|
645
697
|
// Show static message to keep the status visible
|
|
646
698
|
logger.warn('✸ Building app...');
|
|
647
699
|
const buildEnv = this.getBuildEnvironment();
|
|
648
|
-
await shellExec(`cd "${npmDirectory}" && ${this.getBuildCommand()}`, this.getBuildTimeout(), buildEnv);
|
|
700
|
+
await shellExec(`cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`, this.getBuildTimeout(), buildEnv);
|
|
649
701
|
// Copy app
|
|
650
702
|
const fileName = this.getFileName();
|
|
651
703
|
const fileType = this.getFileType(target);
|
|
@@ -659,18 +711,48 @@ class BaseBuilder {
|
|
|
659
711
|
getFileType(target) {
|
|
660
712
|
return target;
|
|
661
713
|
}
|
|
662
|
-
|
|
714
|
+
/**
|
|
715
|
+
* 解析目标架构
|
|
716
|
+
*/
|
|
717
|
+
resolveTargetArch(requestedArch) {
|
|
718
|
+
if (requestedArch === 'auto' || !requestedArch) {
|
|
719
|
+
return process.arch;
|
|
720
|
+
}
|
|
721
|
+
return requestedArch;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* 获取Tauri构建目标
|
|
725
|
+
*/
|
|
726
|
+
getTauriTarget(arch, platform = process.platform) {
|
|
727
|
+
const platformMappings = BaseBuilder.ARCH_MAPPINGS[platform];
|
|
728
|
+
if (!platformMappings)
|
|
729
|
+
return null;
|
|
730
|
+
return platformMappings[arch] || null;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* 获取架构显示名称(用于文件名)
|
|
734
|
+
*/
|
|
735
|
+
getArchDisplayName(arch) {
|
|
736
|
+
return BaseBuilder.ARCH_DISPLAY_NAMES[arch] || arch;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* 构建基础构建命令
|
|
740
|
+
*/
|
|
741
|
+
buildBaseCommand(packageManager, configPath, target) {
|
|
663
742
|
const baseCommand = this.options.debug
|
|
664
|
-
?
|
|
665
|
-
:
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if (IS_MAC && this.options.targets === 'app') {
|
|
671
|
-
fullCommand += ' --bundles app';
|
|
743
|
+
? `${packageManager} run build:debug`
|
|
744
|
+
: `${packageManager} run build`;
|
|
745
|
+
const argSeparator = packageManager === 'npm' ? ' --' : '';
|
|
746
|
+
let fullCommand = `${baseCommand}${argSeparator} -c "${configPath}"`;
|
|
747
|
+
if (target) {
|
|
748
|
+
fullCommand += ` --target ${target}`;
|
|
672
749
|
}
|
|
673
|
-
|
|
750
|
+
return fullCommand;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* 获取构建特性列表
|
|
754
|
+
*/
|
|
755
|
+
getBuildFeatures() {
|
|
674
756
|
const features = ['cli-build'];
|
|
675
757
|
// Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
|
|
676
758
|
if (IS_MAC) {
|
|
@@ -679,6 +761,18 @@ class BaseBuilder {
|
|
|
679
761
|
features.push('macos-proxy');
|
|
680
762
|
}
|
|
681
763
|
}
|
|
764
|
+
return features;
|
|
765
|
+
}
|
|
766
|
+
getBuildCommand(packageManager = 'pnpm') {
|
|
767
|
+
// Use temporary config directory to avoid modifying source files
|
|
768
|
+
const configPath = path.join(npmDirectory, 'src-tauri', '.pake', 'tauri.conf.json');
|
|
769
|
+
let fullCommand = this.buildBaseCommand(packageManager, configPath);
|
|
770
|
+
// For macOS, use app bundles by default unless DMG is explicitly requested
|
|
771
|
+
if (IS_MAC && this.options.targets === 'app') {
|
|
772
|
+
fullCommand += ' --bundles app';
|
|
773
|
+
}
|
|
774
|
+
// Add features
|
|
775
|
+
const features = this.getBuildFeatures();
|
|
682
776
|
if (features.length > 0) {
|
|
683
777
|
fullCommand += ` --features ${features.join(',')}`;
|
|
684
778
|
}
|
|
@@ -705,87 +799,180 @@ class BaseBuilder {
|
|
|
705
799
|
return path.join(npmDirectory, this.getBasePath(), bundleDir, `${fileName}.${fileType}`);
|
|
706
800
|
}
|
|
707
801
|
}
|
|
802
|
+
BaseBuilder.packageManagerCache = null;
|
|
803
|
+
// 架构映射配置
|
|
804
|
+
BaseBuilder.ARCH_MAPPINGS = {
|
|
805
|
+
darwin: {
|
|
806
|
+
arm64: 'aarch64-apple-darwin',
|
|
807
|
+
x64: 'x86_64-apple-darwin',
|
|
808
|
+
universal: 'universal-apple-darwin',
|
|
809
|
+
},
|
|
810
|
+
win32: {
|
|
811
|
+
arm64: 'aarch64-pc-windows-msvc',
|
|
812
|
+
x64: 'x86_64-pc-windows-msvc',
|
|
813
|
+
},
|
|
814
|
+
linux: {
|
|
815
|
+
arm64: 'aarch64-unknown-linux-gnu',
|
|
816
|
+
x64: 'x86_64-unknown-linux-gnu',
|
|
817
|
+
},
|
|
818
|
+
};
|
|
819
|
+
// 架构名称映射(用于文件名生成)
|
|
820
|
+
BaseBuilder.ARCH_DISPLAY_NAMES = {
|
|
821
|
+
arm64: 'aarch64',
|
|
822
|
+
x64: 'x64',
|
|
823
|
+
universal: 'universal',
|
|
824
|
+
};
|
|
708
825
|
|
|
709
826
|
class MacBuilder extends BaseBuilder {
|
|
710
827
|
constructor(options) {
|
|
711
828
|
super(options);
|
|
829
|
+
// Store the original targets value for architecture selection
|
|
830
|
+
// For macOS, targets can be architecture names or format names
|
|
831
|
+
// Filter out non-architecture values
|
|
832
|
+
const validArchs = ['intel', 'apple', 'universal', 'auto', 'x64', 'arm64'];
|
|
833
|
+
this.buildArch = validArchs.includes(options.targets || '')
|
|
834
|
+
? options.targets
|
|
835
|
+
: 'auto';
|
|
712
836
|
// Use DMG by default for distribution
|
|
713
837
|
// Only create app bundles for testing to avoid user interaction
|
|
714
838
|
if (process.env.PAKE_CREATE_APP === '1') {
|
|
715
|
-
this.
|
|
839
|
+
this.buildFormat = 'app';
|
|
716
840
|
}
|
|
717
841
|
else {
|
|
718
|
-
this.
|
|
842
|
+
this.buildFormat = 'dmg';
|
|
719
843
|
}
|
|
844
|
+
// Set targets to format for Tauri
|
|
845
|
+
this.options.targets = this.buildFormat;
|
|
720
846
|
}
|
|
721
847
|
getFileName() {
|
|
722
848
|
const { name } = this.options;
|
|
723
849
|
// For app bundles, use simple name without version/arch
|
|
724
|
-
if (this.
|
|
850
|
+
if (this.buildFormat === 'app') {
|
|
725
851
|
return name;
|
|
726
852
|
}
|
|
727
853
|
// For DMG files, use versioned filename
|
|
728
854
|
let arch;
|
|
729
|
-
if (this.options.multiArch) {
|
|
855
|
+
if (this.buildArch === 'universal' || this.options.multiArch) {
|
|
730
856
|
arch = 'universal';
|
|
731
857
|
}
|
|
858
|
+
else if (this.buildArch === 'apple') {
|
|
859
|
+
arch = 'aarch64';
|
|
860
|
+
}
|
|
861
|
+
else if (this.buildArch === 'intel') {
|
|
862
|
+
arch = 'x64';
|
|
863
|
+
}
|
|
732
864
|
else {
|
|
733
|
-
|
|
865
|
+
// Auto-detect based on current architecture
|
|
866
|
+
arch = this.getArchDisplayName(this.resolveTargetArch(this.buildArch));
|
|
734
867
|
}
|
|
735
868
|
return `${name}_${tauriConfig.version}_${arch}`;
|
|
736
869
|
}
|
|
737
|
-
|
|
738
|
-
if (this.options.multiArch) {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
|
|
744
|
-
let fullCommand = `${baseCommand} --target universal-apple-darwin -c "${configPath}"`;
|
|
745
|
-
// Add features
|
|
746
|
-
const features = ['cli-build'];
|
|
747
|
-
// Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
|
|
748
|
-
const macOSVersion = this.getMacOSMajorVersion();
|
|
749
|
-
if (macOSVersion >= 23) {
|
|
750
|
-
features.push('macos-proxy');
|
|
751
|
-
}
|
|
752
|
-
if (features.length > 0) {
|
|
753
|
-
fullCommand += ` --features ${features.join(',')}`;
|
|
754
|
-
}
|
|
755
|
-
return fullCommand;
|
|
870
|
+
getActualArch() {
|
|
871
|
+
if (this.buildArch === 'universal' || this.options.multiArch) {
|
|
872
|
+
return 'universal';
|
|
873
|
+
}
|
|
874
|
+
else if (this.buildArch === 'apple') {
|
|
875
|
+
return 'arm64';
|
|
756
876
|
}
|
|
757
|
-
|
|
877
|
+
else if (this.buildArch === 'intel') {
|
|
878
|
+
return 'x64';
|
|
879
|
+
}
|
|
880
|
+
return this.resolveTargetArch(this.buildArch);
|
|
881
|
+
}
|
|
882
|
+
getBuildCommand(packageManager = 'pnpm') {
|
|
883
|
+
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
|
|
884
|
+
const actualArch = this.getActualArch();
|
|
885
|
+
const buildTarget = this.getTauriTarget(actualArch, 'darwin');
|
|
886
|
+
if (!buildTarget) {
|
|
887
|
+
throw new Error(`Unsupported architecture: ${actualArch} for macOS`);
|
|
888
|
+
}
|
|
889
|
+
let fullCommand = this.buildBaseCommand(packageManager, configPath, buildTarget);
|
|
890
|
+
// Add features
|
|
891
|
+
const features = this.getBuildFeatures();
|
|
892
|
+
if (features.length > 0) {
|
|
893
|
+
fullCommand += ` --features ${features.join(',')}`;
|
|
894
|
+
}
|
|
895
|
+
return fullCommand;
|
|
758
896
|
}
|
|
759
897
|
getBasePath() {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
898
|
+
const basePath = this.options.debug ? 'debug' : 'release';
|
|
899
|
+
const actualArch = this.getActualArch();
|
|
900
|
+
const target = this.getTauriTarget(actualArch, 'darwin');
|
|
901
|
+
return `src-tauri/target/${target}/${basePath}/bundle`;
|
|
763
902
|
}
|
|
764
903
|
}
|
|
765
904
|
|
|
766
905
|
class WinBuilder extends BaseBuilder {
|
|
767
906
|
constructor(options) {
|
|
768
907
|
super(options);
|
|
769
|
-
this.
|
|
908
|
+
this.buildFormat = 'msi';
|
|
909
|
+
// For Windows, targets can be architecture names or format names
|
|
910
|
+
// Filter out non-architecture values
|
|
911
|
+
const validArchs = ['x64', 'arm64', 'auto'];
|
|
912
|
+
this.buildArch = validArchs.includes(options.targets || '')
|
|
913
|
+
? this.resolveTargetArch(options.targets)
|
|
914
|
+
: this.resolveTargetArch('auto');
|
|
915
|
+
this.options.targets = this.buildFormat;
|
|
770
916
|
}
|
|
771
917
|
getFileName() {
|
|
772
918
|
const { name } = this.options;
|
|
773
|
-
const { arch } = process;
|
|
774
919
|
const language = tauriConfig.bundle.windows.wix.language[0];
|
|
775
|
-
|
|
920
|
+
const targetArch = this.getArchDisplayName(this.buildArch);
|
|
921
|
+
return `${name}_${tauriConfig.version}_${targetArch}_${language}`;
|
|
922
|
+
}
|
|
923
|
+
getBuildCommand(packageManager = 'pnpm') {
|
|
924
|
+
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
|
|
925
|
+
const buildTarget = this.getTauriTarget(this.buildArch, 'win32');
|
|
926
|
+
if (!buildTarget) {
|
|
927
|
+
throw new Error(`Unsupported architecture: ${this.buildArch} for Windows`);
|
|
928
|
+
}
|
|
929
|
+
let fullCommand = this.buildBaseCommand(packageManager, configPath, buildTarget);
|
|
930
|
+
// Add features
|
|
931
|
+
const features = this.getBuildFeatures();
|
|
932
|
+
if (features.length > 0) {
|
|
933
|
+
fullCommand += ` --features ${features.join(',')}`;
|
|
934
|
+
}
|
|
935
|
+
return fullCommand;
|
|
936
|
+
}
|
|
937
|
+
getBasePath() {
|
|
938
|
+
const basePath = this.options.debug ? 'debug' : 'release';
|
|
939
|
+
const target = this.getTauriTarget(this.buildArch, 'win32');
|
|
940
|
+
return `src-tauri/target/${target}/${basePath}/bundle/`;
|
|
776
941
|
}
|
|
777
942
|
}
|
|
778
943
|
|
|
779
944
|
class LinuxBuilder extends BaseBuilder {
|
|
780
945
|
constructor(options) {
|
|
781
946
|
super(options);
|
|
947
|
+
// Parse target format and architecture
|
|
948
|
+
const target = options.targets || 'deb';
|
|
949
|
+
if (target.includes('-arm64')) {
|
|
950
|
+
this.buildFormat = target.replace('-arm64', '');
|
|
951
|
+
this.buildArch = 'arm64';
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
this.buildFormat = target;
|
|
955
|
+
this.buildArch = this.resolveTargetArch('auto');
|
|
956
|
+
}
|
|
957
|
+
// Set targets to format for Tauri
|
|
958
|
+
this.options.targets = this.buildFormat;
|
|
782
959
|
}
|
|
783
960
|
getFileName() {
|
|
784
961
|
const { name, targets } = this.options;
|
|
785
962
|
const version = tauriConfig.version;
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
963
|
+
// Determine architecture display name
|
|
964
|
+
let arch;
|
|
965
|
+
if (this.buildArch === 'arm64') {
|
|
966
|
+
arch = targets === 'rpm' || targets === 'appimage' ? 'aarch64' : 'arm64';
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
// Auto-detect or default to current architecture
|
|
970
|
+
const resolvedArch = this.buildArch === 'x64' ? 'amd64' : this.buildArch;
|
|
971
|
+
arch = resolvedArch;
|
|
972
|
+
if (resolvedArch === 'arm64' &&
|
|
973
|
+
(targets === 'rpm' || targets === 'appimage')) {
|
|
974
|
+
arch = 'aarch64';
|
|
975
|
+
}
|
|
789
976
|
}
|
|
790
977
|
// The RPM format uses different separators and version number formats
|
|
791
978
|
if (targets === 'rpm') {
|
|
@@ -802,6 +989,28 @@ class LinuxBuilder extends BaseBuilder {
|
|
|
802
989
|
}
|
|
803
990
|
}
|
|
804
991
|
}
|
|
992
|
+
getBuildCommand(packageManager = 'pnpm') {
|
|
993
|
+
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
|
|
994
|
+
// Only add target if it's ARM64
|
|
995
|
+
const buildTarget = this.buildArch === 'arm64'
|
|
996
|
+
? this.getTauriTarget(this.buildArch, 'linux')
|
|
997
|
+
: undefined;
|
|
998
|
+
let fullCommand = this.buildBaseCommand(packageManager, configPath, buildTarget);
|
|
999
|
+
// Add features
|
|
1000
|
+
const features = this.getBuildFeatures();
|
|
1001
|
+
if (features.length > 0) {
|
|
1002
|
+
fullCommand += ` --features ${features.join(',')}`;
|
|
1003
|
+
}
|
|
1004
|
+
return fullCommand;
|
|
1005
|
+
}
|
|
1006
|
+
getBasePath() {
|
|
1007
|
+
const basePath = this.options.debug ? 'debug' : 'release';
|
|
1008
|
+
if (this.buildArch === 'arm64') {
|
|
1009
|
+
const target = this.getTauriTarget(this.buildArch, 'linux');
|
|
1010
|
+
return `src-tauri/target/${target}/${basePath}/bundle/`;
|
|
1011
|
+
}
|
|
1012
|
+
return super.getBasePath();
|
|
1013
|
+
}
|
|
805
1014
|
getFileType(target) {
|
|
806
1015
|
if (target === 'appimage') {
|
|
807
1016
|
return 'AppImage';
|
|
@@ -849,6 +1058,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
|
|
849
1058
|
installerLanguage: 'en-US',
|
|
850
1059
|
hideOnClose: true,
|
|
851
1060
|
incognito: false,
|
|
1061
|
+
wasm: false,
|
|
852
1062
|
};
|
|
853
1063
|
|
|
854
1064
|
async function checkUpdateTips() {
|
|
@@ -1068,7 +1278,7 @@ async function tryGetFavicon(url, appName) {
|
|
|
1068
1278
|
continue;
|
|
1069
1279
|
}
|
|
1070
1280
|
}
|
|
1071
|
-
spinner.warn(
|
|
1281
|
+
spinner.warn(`No favicon found for ${domain}. Using default.`);
|
|
1072
1282
|
return null;
|
|
1073
1283
|
}
|
|
1074
1284
|
catch (error) {
|
|
@@ -1271,9 +1481,7 @@ program
|
|
|
1271
1481
|
.addOption(new Option('--user-agent <string>', 'Custom user agent')
|
|
1272
1482
|
.default(DEFAULT_PAKE_OPTIONS.userAgent)
|
|
1273
1483
|
.hideHelp())
|
|
1274
|
-
.addOption(new Option('--targets <string>', '
|
|
1275
|
-
.default(DEFAULT_PAKE_OPTIONS.targets)
|
|
1276
|
-
.hideHelp())
|
|
1484
|
+
.addOption(new Option('--targets <string>', 'Build target: Linux: "deb", "rpm", "appimage", "deb-arm64", "rpm-arm64", "appimage-arm64"; Windows: "x64", "arm64"; macOS: "intel", "apple", "universal"').default(DEFAULT_PAKE_OPTIONS.targets))
|
|
1277
1485
|
.addOption(new Option('--app-version <string>', 'App version, the same as package.json version')
|
|
1278
1486
|
.default(DEFAULT_PAKE_OPTIONS.appVersion)
|
|
1279
1487
|
.hideHelp())
|
|
@@ -1302,6 +1510,9 @@ program
|
|
|
1302
1510
|
.addOption(new Option('--incognito', 'Launch app in incognito/private mode')
|
|
1303
1511
|
.default(DEFAULT_PAKE_OPTIONS.incognito)
|
|
1304
1512
|
.hideHelp())
|
|
1513
|
+
.addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
|
|
1514
|
+
.default(DEFAULT_PAKE_OPTIONS.wasm)
|
|
1515
|
+
.hideHelp())
|
|
1305
1516
|
.addOption(new Option('--installer-language <string>', 'Installer language')
|
|
1306
1517
|
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
|
|
1307
1518
|
.hideHelp())
|
|
@@ -1309,13 +1520,10 @@ program
|
|
|
1309
1520
|
.action(async (url, options) => {
|
|
1310
1521
|
await checkUpdateTips();
|
|
1311
1522
|
if (!url) {
|
|
1312
|
-
program.
|
|
1313
|
-
|
|
1314
|
-
.split('\n')
|
|
1315
|
-
.filter((line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line))
|
|
1316
|
-
.join('\n');
|
|
1523
|
+
program.help({
|
|
1524
|
+
error: false,
|
|
1317
1525
|
});
|
|
1318
|
-
|
|
1526
|
+
return;
|
|
1319
1527
|
}
|
|
1320
1528
|
log.setDefaultLevel('info');
|
|
1321
1529
|
if (options.debug) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pake-cli",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.17",
|
|
4
4
|
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=18.0.0"
|
|
7
7
|
},
|
|
8
|
+
"packageManager": "pnpm@10.15.0",
|
|
8
9
|
"bin": {
|
|
9
10
|
"pake": "./dist/cli.js"
|
|
10
11
|
},
|
|
@@ -29,19 +30,20 @@
|
|
|
29
30
|
"src-tauri"
|
|
30
31
|
],
|
|
31
32
|
"scripts": {
|
|
32
|
-
"start": "
|
|
33
|
-
"dev": "
|
|
34
|
-
"build": "
|
|
35
|
-
"build:debug": "
|
|
36
|
-
"build:mac": "
|
|
33
|
+
"start": "pnpm run dev",
|
|
34
|
+
"dev": "pnpm run tauri dev",
|
|
35
|
+
"build": "tauri build",
|
|
36
|
+
"build:debug": "tauri build --debug",
|
|
37
|
+
"build:mac": "tauri build --target universal-apple-darwin",
|
|
37
38
|
"build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
|
|
38
39
|
"analyze": "cd src-tauri && cargo bloat --release --crates",
|
|
39
40
|
"tauri": "tauri",
|
|
40
41
|
"cli": "cross-env NODE_ENV=development rollup -c -w",
|
|
41
42
|
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
42
|
-
"test": "
|
|
43
|
+
"test": "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
43
44
|
"format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
44
|
-
"
|
|
45
|
+
"format:check": "prettier --check . --ignore-unknown",
|
|
46
|
+
"prepublishOnly": "pnpm run cli:build"
|
|
45
47
|
},
|
|
46
48
|
"type": "module",
|
|
47
49
|
"exports": "./dist/cli.js",
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
[source.crates-io]
|
|
2
|
-
replace-with = 'rsproxy-sparse'
|
|
3
|
-
[source.rsproxy]
|
|
4
|
-
registry = "https://rsproxy.cn/crates.io-index"
|
|
5
|
-
[source.rsproxy-sparse]
|
|
6
|
-
registry = "sparse+https://rsproxy.cn/index/"
|
|
7
|
-
[registries.rsproxy]
|
|
8
|
-
index = "https://rsproxy.cn/crates.io-index"
|
|
9
|
-
[net]
|
|
10
|
-
git-fetch-with-cli = true
|
|
11
|
-
|
|
12
1
|
[env]
|
|
13
2
|
# Fix for macOS 26 Beta compatibility issues
|
|
14
3
|
# Forces use of compatible SDK when building on macOS 26 Beta
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"windows": [
|
|
3
3
|
{
|
|
4
|
-
"url": "https://
|
|
4
|
+
"url": "https://github.com",
|
|
5
5
|
"url_type": "web",
|
|
6
|
-
"hide_title_bar":
|
|
6
|
+
"hide_title_bar": true,
|
|
7
7
|
"fullscreen": false,
|
|
8
8
|
"width": 1200,
|
|
9
|
-
"height":
|
|
9
|
+
"height": 800,
|
|
10
10
|
"resizable": true,
|
|
11
11
|
"always_on_top": false,
|
|
12
12
|
"dark_mode": false,
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"disabled_web_shortcuts": false,
|
|
15
15
|
"hide_on_close": true,
|
|
16
16
|
"incognito": false,
|
|
17
|
-
"title": null
|
|
17
|
+
"title": null,
|
|
18
|
+
"enable_wasm": false
|
|
18
19
|
}
|
|
19
20
|
],
|
|
20
21
|
"user_agent": {
|