pake-cli 3.11.0 → 3.11.1
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/dist/cli.js +41 -28
- package/dist/test-local.html +1 -0
- package/package.json +27 -16
- package/src-tauri/Cargo.lock +1 -1
- package/src-tauri/Cargo.toml +1 -1
- package/src-tauri/src/app/window.rs +11 -41
- package/src-tauri/tauri.conf.json +1 -1
- package/src-tauri/icons/testapp.icns +0 -0
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import * as psl from 'psl';
|
|
|
22
22
|
import { InvalidArgumentError, program as program$1, Option } from 'commander';
|
|
23
23
|
|
|
24
24
|
var name = "pake-cli";
|
|
25
|
-
var version = "3.11.
|
|
25
|
+
var version = "3.11.1";
|
|
26
26
|
var description = "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。";
|
|
27
27
|
var engines = {
|
|
28
28
|
node: ">=18.0.0"
|
|
@@ -682,7 +682,15 @@ Terminal=false
|
|
|
682
682
|
// Avoid copying if source and destination are the same
|
|
683
683
|
const absoluteDestPath = path.resolve(iconPath);
|
|
684
684
|
if (resolvedIconPath !== absoluteDestPath) {
|
|
685
|
-
|
|
685
|
+
try {
|
|
686
|
+
await fsExtra.copy(resolvedIconPath, iconPath);
|
|
687
|
+
}
|
|
688
|
+
catch (error) {
|
|
689
|
+
if (!(error instanceof Error &&
|
|
690
|
+
error.message.includes('Source and destination must not be the same'))) {
|
|
691
|
+
throw error;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
686
694
|
}
|
|
687
695
|
}
|
|
688
696
|
if (updateIconPath) {
|
|
@@ -796,13 +804,20 @@ class BaseBuilder {
|
|
|
796
804
|
this.options = options;
|
|
797
805
|
}
|
|
798
806
|
getBuildEnvironment() {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
807
|
+
if (!IS_MAC) {
|
|
808
|
+
return undefined;
|
|
809
|
+
}
|
|
810
|
+
const currentPath = process.env.PATH || '';
|
|
811
|
+
const systemToolsPath = '/usr/bin';
|
|
812
|
+
const buildPath = currentPath.startsWith(`${systemToolsPath}:`)
|
|
813
|
+
? currentPath
|
|
814
|
+
: `${systemToolsPath}:${currentPath}`;
|
|
815
|
+
return {
|
|
816
|
+
CFLAGS: '-fno-modules',
|
|
817
|
+
CXXFLAGS: '-fno-modules',
|
|
818
|
+
MACOSX_DEPLOYMENT_TARGET: '14.0',
|
|
819
|
+
PATH: buildPath,
|
|
820
|
+
};
|
|
806
821
|
}
|
|
807
822
|
getInstallTimeout() {
|
|
808
823
|
// Windows needs more time due to native compilation and antivirus scanning
|
|
@@ -834,6 +849,21 @@ class BaseBuilder {
|
|
|
834
849
|
}
|
|
835
850
|
}
|
|
836
851
|
}
|
|
852
|
+
async copyFileWithSamePathGuard(sourcePath, destinationPath) {
|
|
853
|
+
if (path.resolve(sourcePath) === path.resolve(destinationPath)) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
try {
|
|
857
|
+
await fsExtra.copy(sourcePath, destinationPath, { overwrite: true });
|
|
858
|
+
}
|
|
859
|
+
catch (error) {
|
|
860
|
+
if (error instanceof Error &&
|
|
861
|
+
error.message.includes('Source and destination must not be the same')) {
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
throw error;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
837
867
|
async prepare() {
|
|
838
868
|
const tauriSrcPath = path.join(npmDirectory, 'src-tauri');
|
|
839
869
|
const tauriTargetPath = path.join(tauriSrcPath, 'target');
|
|
@@ -879,7 +909,7 @@ class BaseBuilder {
|
|
|
879
909
|
if (isChina) {
|
|
880
910
|
logger.info(`✺ Located in China, using ${packageManager}/rsProxy CN mirror.`);
|
|
881
911
|
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
|
882
|
-
await
|
|
912
|
+
await this.copyFileWithSamePathGuard(projectCnConf, projectConf);
|
|
883
913
|
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`, timeout, { ...buildEnv, CI: 'true' });
|
|
884
914
|
}
|
|
885
915
|
else {
|
|
@@ -898,7 +928,7 @@ class BaseBuilder {
|
|
|
898
928
|
usedMirror = true;
|
|
899
929
|
try {
|
|
900
930
|
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
|
901
|
-
await
|
|
931
|
+
await this.copyFileWithSamePathGuard(projectCnConf, projectConf);
|
|
902
932
|
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`, timeout, { ...buildEnv, CI: 'true' });
|
|
903
933
|
retrySpinner.succeed(chalk.green('Package installed with CN mirror!'));
|
|
904
934
|
}
|
|
@@ -1034,33 +1064,21 @@ class BaseBuilder {
|
|
|
1034
1064
|
message.includes('appimage tool failed') ||
|
|
1035
1065
|
message.includes('strip tool'));
|
|
1036
1066
|
}
|
|
1037
|
-
/**
|
|
1038
|
-
* 解析目标架构
|
|
1039
|
-
*/
|
|
1040
1067
|
resolveTargetArch(requestedArch) {
|
|
1041
1068
|
if (requestedArch === 'auto' || !requestedArch) {
|
|
1042
1069
|
return process.arch;
|
|
1043
1070
|
}
|
|
1044
1071
|
return requestedArch;
|
|
1045
1072
|
}
|
|
1046
|
-
/**
|
|
1047
|
-
* 获取Tauri构建目标
|
|
1048
|
-
*/
|
|
1049
1073
|
getTauriTarget(arch, platform = process.platform) {
|
|
1050
1074
|
const platformMappings = BaseBuilder.ARCH_MAPPINGS[platform];
|
|
1051
1075
|
if (!platformMappings)
|
|
1052
1076
|
return null;
|
|
1053
1077
|
return platformMappings[arch] || null;
|
|
1054
1078
|
}
|
|
1055
|
-
/**
|
|
1056
|
-
* 获取架构显示名称(用于文件名)
|
|
1057
|
-
*/
|
|
1058
1079
|
getArchDisplayName(arch) {
|
|
1059
1080
|
return BaseBuilder.ARCH_DISPLAY_NAMES[arch] || arch;
|
|
1060
1081
|
}
|
|
1061
|
-
/**
|
|
1062
|
-
* 构建基础构建命令
|
|
1063
|
-
*/
|
|
1064
1082
|
buildBaseCommand(packageManager, configPath, target) {
|
|
1065
1083
|
const baseCommand = this.options.debug
|
|
1066
1084
|
? `${packageManager} run build:debug`
|
|
@@ -1077,9 +1095,6 @@ class BaseBuilder {
|
|
|
1077
1095
|
}
|
|
1078
1096
|
return fullCommand;
|
|
1079
1097
|
}
|
|
1080
|
-
/**
|
|
1081
|
-
* 获取构建特性列表
|
|
1082
|
-
*/
|
|
1083
1098
|
getBuildFeatures() {
|
|
1084
1099
|
const features = ['cli-build'];
|
|
1085
1100
|
// Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
|
|
@@ -1188,7 +1203,6 @@ class BaseBuilder {
|
|
|
1188
1203
|
}
|
|
1189
1204
|
}
|
|
1190
1205
|
BaseBuilder.packageManagerCache = null;
|
|
1191
|
-
// 架构映射配置
|
|
1192
1206
|
BaseBuilder.ARCH_MAPPINGS = {
|
|
1193
1207
|
darwin: {
|
|
1194
1208
|
arm64: 'aarch64-apple-darwin',
|
|
@@ -1204,7 +1218,6 @@ BaseBuilder.ARCH_MAPPINGS = {
|
|
|
1204
1218
|
x64: 'x86_64-unknown-linux-gnu',
|
|
1205
1219
|
},
|
|
1206
1220
|
};
|
|
1207
|
-
// 架构名称映射(用于文件名生成)
|
|
1208
1221
|
BaseBuilder.ARCH_DISPLAY_NAMES = {
|
|
1209
1222
|
arm64: 'aarch64',
|
|
1210
1223
|
x64: 'x64',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<html><body><h1>Hello Pake</h1></body></html>
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pake-cli",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
7
7
|
},
|
|
8
|
+
"packageManager": "pnpm@10.26.2",
|
|
8
9
|
"bin": {
|
|
9
10
|
"pake": "./dist/cli.js"
|
|
10
11
|
},
|
|
@@ -28,6 +29,22 @@
|
|
|
28
29
|
"dist",
|
|
29
30
|
"src-tauri"
|
|
30
31
|
],
|
|
32
|
+
"scripts": {
|
|
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",
|
|
38
|
+
"analyze": "cd src-tauri && cargo bloat --release --crates",
|
|
39
|
+
"tauri": "tauri",
|
|
40
|
+
"cli": "cross-env NODE_ENV=development rollup -c -w",
|
|
41
|
+
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
42
|
+
"test": "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
43
|
+
"format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
44
|
+
"format:check": "prettier --check . --ignore-unknown",
|
|
45
|
+
"update": "pnpm update --verbose && cd src-tauri && cargo update",
|
|
46
|
+
"prepublishOnly": "pnpm run cli:build"
|
|
47
|
+
},
|
|
31
48
|
"type": "module",
|
|
32
49
|
"exports": "./dist/cli.js",
|
|
33
50
|
"license": "MIT",
|
|
@@ -69,19 +86,13 @@
|
|
|
69
86
|
"typescript": "^5.9.3",
|
|
70
87
|
"vitest": "^4.0.18"
|
|
71
88
|
},
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"cli": "cross-env NODE_ENV=development rollup -c -w",
|
|
81
|
-
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
82
|
-
"test": "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
83
|
-
"format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
84
|
-
"format:check": "prettier --check . --ignore-unknown",
|
|
85
|
-
"update": "pnpm update --verbose && cd src-tauri && cargo update"
|
|
89
|
+
"pnpm": {
|
|
90
|
+
"overrides": {
|
|
91
|
+
"sharp": "^0.34.5"
|
|
92
|
+
},
|
|
93
|
+
"onlyBuiltDependencies": [
|
|
94
|
+
"esbuild",
|
|
95
|
+
"sharp"
|
|
96
|
+
]
|
|
86
97
|
}
|
|
87
|
-
}
|
|
98
|
+
}
|
package/src-tauri/Cargo.lock
CHANGED
package/src-tauri/Cargo.toml
CHANGED
|
@@ -79,7 +79,7 @@ fn open_requested_window(
|
|
|
79
79
|
tauri_config,
|
|
80
80
|
WindowBuildOptions {
|
|
81
81
|
label: &label,
|
|
82
|
-
url: WebviewUrl::External(
|
|
82
|
+
url: WebviewUrl::External(target_url.clone()),
|
|
83
83
|
visible: true,
|
|
84
84
|
new_window_features: Some(features),
|
|
85
85
|
},
|
|
@@ -369,50 +369,20 @@ fn build_window(
|
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
if let Some(features) = new_window_features {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
let url_str = url.as_str();
|
|
378
|
-
|
|
379
|
-
// Always allow same-origin navigation
|
|
380
|
-
if url_str.starts_with("http://localhost") || url_str.starts_with("http://127.0.0.1") {
|
|
381
|
-
return true;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// Check for OAuth/authentication domains
|
|
385
|
-
let auth_patterns = [
|
|
386
|
-
"accounts.google.com",
|
|
387
|
-
"login.microsoftonline.com",
|
|
388
|
-
"github.com/login",
|
|
389
|
-
"appleid.apple.com",
|
|
390
|
-
"facebook.com",
|
|
391
|
-
"twitter.com",
|
|
392
|
-
];
|
|
393
|
-
|
|
394
|
-
let auth_paths = ["/oauth/", "/auth/", "/authorize", "/login"];
|
|
395
|
-
|
|
396
|
-
// Allow if matches auth patterns
|
|
397
|
-
for pattern in &auth_patterns {
|
|
398
|
-
if url_str.contains(pattern) {
|
|
399
|
-
#[cfg(debug_assertions)]
|
|
400
|
-
println!("Allowing OAuth navigation to: {}", url_str);
|
|
401
|
-
return true;
|
|
402
|
-
}
|
|
372
|
+
// window_features() crashes on macOS; only apply on other platforms.
|
|
373
|
+
#[cfg(target_os = "macos")]
|
|
374
|
+
{
|
|
375
|
+
let _ = features;
|
|
376
|
+
window_builder = window_builder.focused(true);
|
|
403
377
|
}
|
|
404
378
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
println!("Allowing auth path navigation to: {}", url_str);
|
|
409
|
-
return true;
|
|
410
|
-
}
|
|
379
|
+
#[cfg(not(target_os = "macos"))]
|
|
380
|
+
{
|
|
381
|
+
window_builder = window_builder.window_features(features).focused(true);
|
|
411
382
|
}
|
|
383
|
+
}
|
|
412
384
|
|
|
413
|
-
|
|
414
|
-
true
|
|
415
|
-
});
|
|
385
|
+
window_builder = window_builder.on_navigation(|_| true);
|
|
416
386
|
|
|
417
387
|
window_builder.build()
|
|
418
388
|
}
|
|
Binary file
|