pake-cli 3.2.0-beta11 → 3.2.0-beta15
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 +223 -63
- package/package.json +9 -9
- package/src-tauri/.pake/pake.json +2 -2
- package/src-tauri/.pake/tauri.conf.json +4 -4
- package/src-tauri/.pake/tauri.macos.conf.json +2 -2
- package/src-tauri/Cargo.lock +57 -27
- package/src-tauri/Cargo.toml +2 -2
- package/src-tauri/gen/schemas/acl-manifests.json +1 -1
- package/src-tauri/gen/schemas/desktop-schema.json +222 -0
- package/src-tauri/gen/schemas/macOS-schema.json +222 -0
- package/src-tauri/.pake/icons/githubcustomtraypng.icns +0 -0
- package/src-tauri/.pake/icons/githubcustomtraytest.icns +0 -0
- package/src-tauri/.pake/icons/githubsystemtraytest.icns +0 -0
- package/src-tauri/.pake/icons/testfix.icns +0 -0
- package/src-tauri/.pake/icons/twi.icns +0 -0
- package/src-tauri/.pake/icons/twitter.icns +0 -0
- package/src-tauri/.pake/icons/twitter1.icns +0 -0
- package/src-tauri/.pake/icons/twitter3.icns +0 -0
- package/src-tauri/.pake/icons/twitter4.icns +0 -0
- package/src-tauri/.pake/icons/twitter5.icns +0 -0
- package/src-tauri/.pake/icons/twitterapp.icns +0 -0
- package/src-tauri/.pake/icons/twittercustomtray.icns +0 -0
- package/src-tauri/.pake/icons/twitterfinal.icns +0 -0
- package/src-tauri/.pake/icons/twitteroptimized.icns +0 -0
- package/src-tauri/.pake/icons/twittertest.icns +0 -0
- package/src-tauri/.pake/icons/wk.icns +0 -0
- package/src-tauri/.pake/icons/wk1.icns +0 -0
- package/src-tauri/.pake/png/githubcustomtraypng.png +0 -0
- package/src-tauri/.pake/png/twi_tray.png +0 -0
- package/src-tauri/.pake/png/twitter5_tray.png +0 -0
- package/src-tauri/.pake/png/twittercustomtray.png +0 -0
- package/src-tauri/.pake/png/twitterfinal_tray.png +0 -0
- package/src-tauri/.pake/png/twitteroptimized_tray.png +0 -0
package/dist/cli.js
CHANGED
|
@@ -17,10 +17,12 @@ import updateNotifier from 'update-notifier';
|
|
|
17
17
|
import axios from 'axios';
|
|
18
18
|
import { dir } from 'tmp-promise';
|
|
19
19
|
import { fileTypeFromBuffer } from 'file-type';
|
|
20
|
+
import icongen from 'icon-gen';
|
|
21
|
+
import sharp from 'sharp';
|
|
20
22
|
import * as psl from 'psl';
|
|
21
23
|
|
|
22
24
|
var name = "pake-cli";
|
|
23
|
-
var version$1 = "3.2.0-
|
|
25
|
+
var version$1 = "3.2.0-beta15";
|
|
24
26
|
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
|
|
25
27
|
var engines = {
|
|
26
28
|
node: ">=16.0.0"
|
|
@@ -69,19 +71,20 @@ var type = "module";
|
|
|
69
71
|
var exports = "./dist/cli.js";
|
|
70
72
|
var license = "MIT";
|
|
71
73
|
var dependencies = {
|
|
72
|
-
"@tauri-apps/api": "^2.
|
|
73
|
-
"@tauri-apps/cli": "^2.
|
|
74
|
+
"@tauri-apps/api": "^2.8.0",
|
|
75
|
+
"@tauri-apps/cli": "^2.8.1",
|
|
74
76
|
axios: "^1.11.0",
|
|
75
|
-
chalk: "^5.
|
|
77
|
+
chalk: "^5.6.0",
|
|
76
78
|
commander: "^11.1.0",
|
|
77
79
|
execa: "^9.6.0",
|
|
78
80
|
"file-type": "^18.7.0",
|
|
79
81
|
"fs-extra": "^11.3.1",
|
|
82
|
+
"icon-gen": "^5.0.0",
|
|
80
83
|
loglevel: "^1.9.2",
|
|
81
84
|
ora: "^8.2.0",
|
|
82
|
-
"pake-cli": "file:.yalc/pake-cli",
|
|
83
85
|
prompts: "^2.4.2",
|
|
84
86
|
psl: "^1.15.0",
|
|
87
|
+
sharp: "^0.33.5",
|
|
85
88
|
"tmp-promise": "^3.0.3",
|
|
86
89
|
"update-notifier": "^7.3.1"
|
|
87
90
|
};
|
|
@@ -92,16 +95,15 @@ var devDependencies = {
|
|
|
92
95
|
"@rollup/plugin-replace": "^6.0.2",
|
|
93
96
|
"@rollup/plugin-terser": "^0.4.4",
|
|
94
97
|
"@types/fs-extra": "^11.0.4",
|
|
95
|
-
"@types/node": "^20.19.
|
|
98
|
+
"@types/node": "^20.19.11",
|
|
96
99
|
"@types/page-icon": "^0.3.6",
|
|
97
100
|
"@types/prompts": "^2.4.9",
|
|
98
|
-
"@types/psl": "^1.11.0",
|
|
99
101
|
"@types/tmp": "^0.2.6",
|
|
100
102
|
"@types/update-notifier": "^6.0.8",
|
|
101
103
|
"app-root-path": "^3.1.0",
|
|
102
104
|
"cross-env": "^7.0.3",
|
|
103
|
-
prettier: "^3.
|
|
104
|
-
rollup: "^4.46.
|
|
105
|
+
prettier: "^3.6.2",
|
|
106
|
+
rollup: "^4.46.3",
|
|
105
107
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
106
108
|
tslib: "^2.8.1",
|
|
107
109
|
typescript: "^5.9.2"
|
|
@@ -319,13 +321,14 @@ const currentModulePath = fileURLToPath(import.meta.url);
|
|
|
319
321
|
const npmDirectory = path.join(path.dirname(currentModulePath), '..');
|
|
320
322
|
const tauriConfigDirectory = path.join(npmDirectory, 'src-tauri', '.pake');
|
|
321
323
|
|
|
322
|
-
async function shellExec(command, timeout = 300000) {
|
|
324
|
+
async function shellExec(command, timeout = 300000, env) {
|
|
323
325
|
try {
|
|
324
326
|
const { exitCode } = await execa(command, {
|
|
325
327
|
cwd: npmDirectory,
|
|
326
|
-
stdio: 'inherit',
|
|
328
|
+
stdio: ['inherit', 'pipe', 'inherit'], // Hide stdout verbose, keep stderr
|
|
327
329
|
shell: true,
|
|
328
330
|
timeout,
|
|
331
|
+
env: env ? { ...process.env, ...env } : process.env,
|
|
329
332
|
});
|
|
330
333
|
return exitCode;
|
|
331
334
|
}
|
|
@@ -412,11 +415,11 @@ async function installRust() {
|
|
|
412
415
|
const spinner = getSpinner('Downloading Rust...');
|
|
413
416
|
try {
|
|
414
417
|
await shellExec(IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac);
|
|
415
|
-
spinner.succeed(chalk.green('Rust installed successfully!'));
|
|
418
|
+
spinner.succeed(chalk.green('✔ Rust installed successfully!'));
|
|
416
419
|
}
|
|
417
420
|
catch (error) {
|
|
418
|
-
|
|
419
|
-
|
|
421
|
+
spinner.fail(chalk.red('✕ Rust installation failed!'));
|
|
422
|
+
console.error(error.message);
|
|
420
423
|
process.exit(1);
|
|
421
424
|
}
|
|
422
425
|
}
|
|
@@ -634,7 +637,6 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
634
637
|
};
|
|
635
638
|
const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
|
|
636
639
|
const bundleConf = { bundle: tauriConf.bundle };
|
|
637
|
-
console.log('pakeConfig', tauriConf.pake);
|
|
638
640
|
await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
|
|
639
641
|
const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
|
|
640
642
|
await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
|
|
@@ -648,6 +650,19 @@ class BaseBuilder {
|
|
|
648
650
|
constructor(options) {
|
|
649
651
|
this.options = options;
|
|
650
652
|
}
|
|
653
|
+
getBuildEnvironment() {
|
|
654
|
+
return IS_MAC ? {
|
|
655
|
+
'CFLAGS': '-fno-modules',
|
|
656
|
+
'CXXFLAGS': '-fno-modules',
|
|
657
|
+
'MACOSX_DEPLOYMENT_TARGET': '14.0'
|
|
658
|
+
} : undefined;
|
|
659
|
+
}
|
|
660
|
+
getInstallTimeout() {
|
|
661
|
+
return process.platform === 'win32' ? 600000 : 300000;
|
|
662
|
+
}
|
|
663
|
+
getBuildTimeout() {
|
|
664
|
+
return 300000; // 5 minutes for build process
|
|
665
|
+
}
|
|
651
666
|
async prepare() {
|
|
652
667
|
const tauriSrcPath = path.join(npmDirectory, 'src-tauri');
|
|
653
668
|
const tauriTargetPath = path.join(tauriSrcPath, 'target');
|
|
@@ -675,21 +690,20 @@ class BaseBuilder {
|
|
|
675
690
|
const rustProjectDir = path.join(tauriSrcPath, '.cargo');
|
|
676
691
|
const projectConf = path.join(rustProjectDir, 'config.toml');
|
|
677
692
|
await fsExtra.ensureDir(rustProjectDir);
|
|
678
|
-
//
|
|
693
|
+
// 统一使用npm,简单可靠
|
|
679
694
|
const packageManager = 'npm';
|
|
680
|
-
const registryOption = isChina
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
const timeout = process.platform === 'win32' ? 600000 : 300000;
|
|
695
|
+
const registryOption = isChina ? ' --registry=https://registry.npmmirror.com' : '';
|
|
696
|
+
const legacyPeerDeps = ' --legacy-peer-deps'; // 解决dependency conflicts
|
|
697
|
+
const timeout = this.getInstallTimeout();
|
|
698
|
+
const buildEnv = this.getBuildEnvironment();
|
|
685
699
|
if (isChina) {
|
|
686
700
|
logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
|
|
687
701
|
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
|
688
702
|
await fsExtra.copy(projectCnConf, projectConf);
|
|
689
|
-
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}`, timeout);
|
|
703
|
+
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${legacyPeerDeps} --silent`, timeout, buildEnv);
|
|
690
704
|
}
|
|
691
705
|
else {
|
|
692
|
-
await shellExec(`cd "${npmDirectory}" && ${packageManager} install`, timeout);
|
|
706
|
+
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${legacyPeerDeps} --silent`, timeout, buildEnv);
|
|
693
707
|
}
|
|
694
708
|
spinner.succeed(chalk.green('Package installed!'));
|
|
695
709
|
if (!tauriTargetPathExists) {
|
|
@@ -706,9 +720,14 @@ class BaseBuilder {
|
|
|
706
720
|
const { name } = this.options;
|
|
707
721
|
await mergeConfig(url, this.options, tauriConfig);
|
|
708
722
|
// Build app
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
await
|
|
723
|
+
const buildSpinner = getSpinner('Building app...');
|
|
724
|
+
// Let spinner run for a moment so user can see it, then stop before npm command
|
|
725
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
726
|
+
buildSpinner.stop();
|
|
727
|
+
// Show static message to keep the status visible
|
|
728
|
+
logger.warn('✸ Building app...');
|
|
729
|
+
const buildEnv = this.getBuildEnvironment();
|
|
730
|
+
await shellExec(`cd "${npmDirectory}" && ${this.getBuildCommand()}`, this.getBuildTimeout(), buildEnv);
|
|
712
731
|
// Copy app
|
|
713
732
|
const fileName = this.getFileName();
|
|
714
733
|
const fileType = this.getFileType(target);
|
|
@@ -898,60 +917,202 @@ async function checkUpdateTips() {
|
|
|
898
917
|
});
|
|
899
918
|
}
|
|
900
919
|
|
|
901
|
-
|
|
920
|
+
// Constants
|
|
921
|
+
const ICON_CONFIG = {
|
|
922
|
+
minFileSize: 100,
|
|
923
|
+
downloadTimeout: 10000,
|
|
924
|
+
supportedFormats: ['png', 'ico', 'jpeg', 'jpg', 'webp'],
|
|
925
|
+
whiteBackground: { r: 255, g: 255, b: 255 },
|
|
926
|
+
};
|
|
927
|
+
// API Configuration
|
|
928
|
+
const API_TOKENS = {
|
|
929
|
+
// cspell:disable-next-line
|
|
930
|
+
logoDev: ['pk_JLLMUKGZRpaG5YclhXaTkg', 'pk_Ph745P8mQSeYFfW2Wk039A'],
|
|
931
|
+
// cspell:disable-next-line
|
|
932
|
+
brandfetch: ['1idqvJC0CeFSeyp3Yf7', '1idej-yhU_ThggIHFyG'],
|
|
933
|
+
};
|
|
934
|
+
/**
|
|
935
|
+
* Adds white background to transparent icons only
|
|
936
|
+
*/
|
|
937
|
+
async function preprocessIcon(inputPath) {
|
|
938
|
+
try {
|
|
939
|
+
const metadata = await sharp(inputPath).metadata();
|
|
940
|
+
if (metadata.channels !== 4)
|
|
941
|
+
return inputPath; // No transparency
|
|
942
|
+
const { path: tempDir } = await dir();
|
|
943
|
+
const outputPath = path.join(tempDir, 'icon-with-background.png');
|
|
944
|
+
await sharp({
|
|
945
|
+
create: {
|
|
946
|
+
width: metadata.width || 512,
|
|
947
|
+
height: metadata.height || 512,
|
|
948
|
+
channels: 3,
|
|
949
|
+
background: ICON_CONFIG.whiteBackground,
|
|
950
|
+
},
|
|
951
|
+
})
|
|
952
|
+
.composite([{ input: inputPath }])
|
|
953
|
+
.png()
|
|
954
|
+
.toFile(outputPath);
|
|
955
|
+
return outputPath;
|
|
956
|
+
}
|
|
957
|
+
catch (error) {
|
|
958
|
+
logger.warn(`Failed to add background to icon: ${error.message}`);
|
|
959
|
+
return inputPath;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Converts icon to platform-specific format
|
|
964
|
+
*/
|
|
965
|
+
async function convertIconFormat(inputPath, appName) {
|
|
966
|
+
try {
|
|
967
|
+
if (!(await fsExtra.pathExists(inputPath)))
|
|
968
|
+
return null;
|
|
969
|
+
const { path: outputDir } = await dir();
|
|
970
|
+
const platformOutputDir = path.join(outputDir, 'converted-icons');
|
|
971
|
+
await fsExtra.ensureDir(platformOutputDir);
|
|
972
|
+
const processedInputPath = await preprocessIcon(inputPath);
|
|
973
|
+
const iconName = appName.toLowerCase();
|
|
974
|
+
// Generate platform-specific format
|
|
975
|
+
if (IS_WIN) {
|
|
976
|
+
await icongen(processedInputPath, platformOutputDir, {
|
|
977
|
+
report: false,
|
|
978
|
+
ico: { name: `${iconName}_256`, sizes: [256] },
|
|
979
|
+
});
|
|
980
|
+
return path.join(platformOutputDir, `${iconName}_256.ico`);
|
|
981
|
+
}
|
|
982
|
+
if (IS_LINUX) {
|
|
983
|
+
const outputPath = path.join(platformOutputDir, `${iconName}_512.png`);
|
|
984
|
+
await fsExtra.copy(processedInputPath, outputPath);
|
|
985
|
+
return outputPath;
|
|
986
|
+
}
|
|
987
|
+
// macOS
|
|
988
|
+
await icongen(processedInputPath, platformOutputDir, {
|
|
989
|
+
report: false,
|
|
990
|
+
icns: { name: iconName, sizes: [16, 32, 64, 128, 256, 512, 1024] },
|
|
991
|
+
});
|
|
992
|
+
const outputPath = path.join(platformOutputDir, `${iconName}.icns`);
|
|
993
|
+
return (await fsExtra.pathExists(outputPath)) ? outputPath : null;
|
|
994
|
+
}
|
|
995
|
+
catch (error) {
|
|
996
|
+
logger.warn(`Icon format conversion failed: ${error.message}`);
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
async function handleIcon(options, url) {
|
|
902
1001
|
if (options.icon) {
|
|
903
1002
|
if (options.icon.startsWith('http')) {
|
|
904
1003
|
return downloadIcon(options.icon);
|
|
905
1004
|
}
|
|
906
|
-
|
|
907
|
-
|
|
1005
|
+
return path.resolve(options.icon);
|
|
1006
|
+
}
|
|
1007
|
+
// Try to get favicon from website if URL is provided
|
|
1008
|
+
if (url && url.startsWith('http') && options.name) {
|
|
1009
|
+
const faviconPath = await tryGetFavicon(url, options.name);
|
|
1010
|
+
if (faviconPath)
|
|
1011
|
+
return faviconPath;
|
|
1012
|
+
}
|
|
1013
|
+
logger.info('✼ No icon provided, using default icon.');
|
|
1014
|
+
const iconPath = IS_WIN
|
|
1015
|
+
? 'src-tauri/png/icon_256.ico'
|
|
1016
|
+
: IS_LINUX
|
|
1017
|
+
? 'src-tauri/png/icon_512.png'
|
|
1018
|
+
: 'src-tauri/icons/icon.icns';
|
|
1019
|
+
return path.join(npmDirectory, iconPath);
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Generates icon service URLs for a domain
|
|
1023
|
+
*/
|
|
1024
|
+
function generateIconServiceUrls(domain) {
|
|
1025
|
+
const logoDevUrls = API_TOKENS.logoDev
|
|
1026
|
+
.sort(() => Math.random() - 0.5)
|
|
1027
|
+
.map(token => `https://img.logo.dev/${domain}?token=${token}&format=png&size=256`);
|
|
1028
|
+
const brandfetchUrls = API_TOKENS.brandfetch
|
|
1029
|
+
.sort(() => Math.random() - 0.5)
|
|
1030
|
+
.map(key => `https://cdn.brandfetch.io/${domain}/w/400/h/400?c=${key}`);
|
|
1031
|
+
return [
|
|
1032
|
+
...logoDevUrls,
|
|
1033
|
+
...brandfetchUrls,
|
|
1034
|
+
`https://logo.clearbit.com/${domain}?size=256`,
|
|
1035
|
+
`https://logo.uplead.com/${domain}`,
|
|
1036
|
+
`https://www.google.com/s2/favicons?domain=${domain}&sz=256`,
|
|
1037
|
+
`https://favicon.is/${domain}`,
|
|
1038
|
+
`https://icons.duckduckgo.com/ip3/${domain}.ico`,
|
|
1039
|
+
`https://icon.horse/icon/${domain}`,
|
|
1040
|
+
`https://${domain}/favicon.ico`,
|
|
1041
|
+
`https://www.${domain}/favicon.ico`,
|
|
1042
|
+
`https://${domain}/apple-touch-icon.png`,
|
|
1043
|
+
`https://${domain}/apple-touch-icon-precomposed.png`,
|
|
1044
|
+
];
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Attempts to fetch favicon from website
|
|
1048
|
+
*/
|
|
1049
|
+
async function tryGetFavicon(url, appName) {
|
|
1050
|
+
try {
|
|
1051
|
+
const domain = new URL(url).hostname;
|
|
1052
|
+
const spinner = getSpinner(`Fetching icon from ${domain}...`);
|
|
1053
|
+
const serviceUrls = generateIconServiceUrls(domain);
|
|
1054
|
+
for (const serviceUrl of serviceUrls) {
|
|
1055
|
+
try {
|
|
1056
|
+
const faviconPath = await downloadIcon(serviceUrl, false);
|
|
1057
|
+
if (!faviconPath)
|
|
1058
|
+
continue;
|
|
1059
|
+
const convertedPath = await convertIconFormat(faviconPath, appName);
|
|
1060
|
+
if (convertedPath) {
|
|
1061
|
+
spinner.succeed(chalk.green('Icon fetched and converted successfully!'));
|
|
1062
|
+
return convertedPath;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
catch {
|
|
1066
|
+
continue;
|
|
1067
|
+
}
|
|
908
1068
|
}
|
|
1069
|
+
spinner.warn(`✼ No favicon found for ${domain}. Using default.`);
|
|
1070
|
+
return null;
|
|
909
1071
|
}
|
|
910
|
-
|
|
911
|
-
logger.warn(
|
|
912
|
-
|
|
913
|
-
? 'src-tauri/png/icon_256.ico'
|
|
914
|
-
: IS_LINUX
|
|
915
|
-
? 'src-tauri/png/icon_512.png'
|
|
916
|
-
: 'src-tauri/icons/icon.icns';
|
|
917
|
-
return path.join(npmDirectory, iconPath);
|
|
1072
|
+
catch (error) {
|
|
1073
|
+
logger.warn(`Failed to fetch favicon: ${error.message}`);
|
|
1074
|
+
return null;
|
|
918
1075
|
}
|
|
919
1076
|
}
|
|
920
|
-
|
|
921
|
-
|
|
1077
|
+
/**
|
|
1078
|
+
* Downloads icon from URL
|
|
1079
|
+
*/
|
|
1080
|
+
async function downloadIcon(iconUrl, showSpinner = true) {
|
|
922
1081
|
try {
|
|
923
|
-
const
|
|
1082
|
+
const response = await axios.get(iconUrl, {
|
|
924
1083
|
responseType: 'arraybuffer',
|
|
1084
|
+
timeout: ICON_CONFIG.downloadTimeout,
|
|
925
1085
|
});
|
|
926
|
-
const iconData =
|
|
927
|
-
if (!iconData)
|
|
1086
|
+
const iconData = response.data;
|
|
1087
|
+
if (!iconData || iconData.byteLength < ICON_CONFIG.minFileSize)
|
|
928
1088
|
return null;
|
|
929
|
-
}
|
|
930
1089
|
const fileDetails = await fileTypeFromBuffer(iconData);
|
|
931
|
-
if (!fileDetails) {
|
|
1090
|
+
if (!fileDetails || !ICON_CONFIG.supportedFormats.includes(fileDetails.ext)) {
|
|
932
1091
|
return null;
|
|
933
1092
|
}
|
|
934
|
-
|
|
935
|
-
let iconPath = `${tempPath}/icon.${fileDetails.ext}`;
|
|
936
|
-
// Fix this for linux
|
|
937
|
-
if (IS_LINUX) {
|
|
938
|
-
iconPath = 'png/linux_temp.png';
|
|
939
|
-
await fsExtra.outputFile(`${npmDirectory}/src-tauri/${iconPath}`, iconData);
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
await fsExtra.outputFile(iconPath, iconData);
|
|
943
|
-
}
|
|
944
|
-
await fsExtra.outputFile(iconPath, iconData);
|
|
945
|
-
spinner.succeed(chalk.green('Icon downloaded successfully!'));
|
|
946
|
-
return iconPath;
|
|
1093
|
+
return await saveIconFile(iconData, fileDetails.ext);
|
|
947
1094
|
}
|
|
948
1095
|
catch (error) {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
return null;
|
|
1096
|
+
if (showSpinner && !(error.response?.status === 404)) {
|
|
1097
|
+
throw error;
|
|
952
1098
|
}
|
|
953
|
-
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Saves icon file to temporary location
|
|
1104
|
+
*/
|
|
1105
|
+
async function saveIconFile(iconData, extension) {
|
|
1106
|
+
const buffer = Buffer.from(iconData);
|
|
1107
|
+
if (IS_LINUX) {
|
|
1108
|
+
const iconPath = 'png/linux_temp.png';
|
|
1109
|
+
await fsExtra.outputFile(`${npmDirectory}/src-tauri/${iconPath}`, buffer);
|
|
1110
|
+
return iconPath;
|
|
954
1111
|
}
|
|
1112
|
+
const { path: tempPath } = await dir();
|
|
1113
|
+
const iconPath = `${tempPath}/icon.${extension}`;
|
|
1114
|
+
await fsExtra.outputFile(iconPath, buffer);
|
|
1115
|
+
return iconPath;
|
|
955
1116
|
}
|
|
956
1117
|
|
|
957
1118
|
// Extracts the domain from a given URL.
|
|
@@ -1040,7 +1201,7 @@ async function handleOptions(options, url) {
|
|
|
1040
1201
|
name,
|
|
1041
1202
|
identifier: getIdentifier(url),
|
|
1042
1203
|
};
|
|
1043
|
-
appOptions.icon = await handleIcon(appOptions);
|
|
1204
|
+
appOptions.icon = await handleIcon(appOptions, url);
|
|
1044
1205
|
return appOptions;
|
|
1045
1206
|
}
|
|
1046
1207
|
|
|
@@ -1157,7 +1318,6 @@ program
|
|
|
1157
1318
|
log.setLevel('debug');
|
|
1158
1319
|
}
|
|
1159
1320
|
const appOptions = await handleOptions(options, url);
|
|
1160
|
-
log.debug('PakeAppOptions', appOptions);
|
|
1161
1321
|
const builder = BuilderProvider.create(appOptions);
|
|
1162
1322
|
await builder.prepare();
|
|
1163
1323
|
await builder.build(url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pake-cli",
|
|
3
|
-
"version": "3.2.0-
|
|
3
|
+
"version": "3.2.0-beta15",
|
|
4
4
|
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -49,19 +49,20 @@
|
|
|
49
49
|
"exports": "./dist/cli.js",
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@tauri-apps/api": "^2.
|
|
53
|
-
"@tauri-apps/cli": "^2.
|
|
52
|
+
"@tauri-apps/api": "^2.8.0",
|
|
53
|
+
"@tauri-apps/cli": "^2.8.1",
|
|
54
54
|
"axios": "^1.11.0",
|
|
55
|
-
"chalk": "^5.
|
|
55
|
+
"chalk": "^5.6.0",
|
|
56
56
|
"commander": "^11.1.0",
|
|
57
57
|
"execa": "^9.6.0",
|
|
58
58
|
"file-type": "^18.7.0",
|
|
59
59
|
"fs-extra": "^11.3.1",
|
|
60
|
+
"icon-gen": "^5.0.0",
|
|
60
61
|
"loglevel": "^1.9.2",
|
|
61
62
|
"ora": "^8.2.0",
|
|
62
|
-
"pake-cli": "file:.yalc/pake-cli",
|
|
63
63
|
"prompts": "^2.4.2",
|
|
64
64
|
"psl": "^1.15.0",
|
|
65
|
+
"sharp": "^0.33.5",
|
|
65
66
|
"tmp-promise": "^3.0.3",
|
|
66
67
|
"update-notifier": "^7.3.1"
|
|
67
68
|
},
|
|
@@ -72,16 +73,15 @@
|
|
|
72
73
|
"@rollup/plugin-replace": "^6.0.2",
|
|
73
74
|
"@rollup/plugin-terser": "^0.4.4",
|
|
74
75
|
"@types/fs-extra": "^11.0.4",
|
|
75
|
-
"@types/node": "^20.19.
|
|
76
|
+
"@types/node": "^20.19.11",
|
|
76
77
|
"@types/page-icon": "^0.3.6",
|
|
77
78
|
"@types/prompts": "^2.4.9",
|
|
78
|
-
"@types/psl": "^1.11.0",
|
|
79
79
|
"@types/tmp": "^0.2.6",
|
|
80
80
|
"@types/update-notifier": "^6.0.8",
|
|
81
81
|
"app-root-path": "^3.1.0",
|
|
82
82
|
"cross-env": "^7.0.3",
|
|
83
|
-
"prettier": "^3.
|
|
84
|
-
"rollup": "^4.46.
|
|
83
|
+
"prettier": "^3.6.2",
|
|
84
|
+
"rollup": "^4.46.3",
|
|
85
85
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
86
86
|
"tslib": "^2.8.1",
|
|
87
87
|
"typescript": "^5.9.2"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"windows": [
|
|
3
3
|
{
|
|
4
|
-
"url": "https://
|
|
4
|
+
"url": "https://tw93.fun",
|
|
5
5
|
"url_type": "web",
|
|
6
6
|
"hide_title_bar": false,
|
|
7
7
|
"fullscreen": false,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"windows": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
|
|
24
24
|
},
|
|
25
25
|
"system_tray": {
|
|
26
|
-
"macos":
|
|
26
|
+
"macos": true,
|
|
27
27
|
"linux": true,
|
|
28
28
|
"windows": true
|
|
29
29
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"productName": "
|
|
3
|
-
"identifier": "com.pake.
|
|
2
|
+
"productName": "Twi",
|
|
3
|
+
"identifier": "com.pake.bebe89",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"app": {
|
|
6
6
|
"withGlobalTauri": true
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"bundle": {
|
|
12
12
|
"icon": [
|
|
13
|
-
"/
|
|
13
|
+
"/private/var/folders/v3/4mpcxc0564j9qhpf8jpf6r_r0000gp/T/tmp-99301-geMsHaoeoBvZ/converted-icons/twi.icns"
|
|
14
14
|
],
|
|
15
15
|
"active": true,
|
|
16
16
|
"macOS": {},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dmg"
|
|
19
19
|
],
|
|
20
20
|
"resources": [
|
|
21
|
-
"icons/
|
|
21
|
+
"icons/twi.icns"
|
|
22
22
|
]
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bundle": {
|
|
3
3
|
"icon": [
|
|
4
|
-
"/
|
|
4
|
+
"/private/var/folders/v3/4mpcxc0564j9qhpf8jpf6r_r0000gp/T/tmp-99301-geMsHaoeoBvZ/converted-icons/twi.icns"
|
|
5
5
|
],
|
|
6
6
|
"active": true,
|
|
7
7
|
"macOS": {},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dmg"
|
|
10
10
|
],
|
|
11
11
|
"resources": [
|
|
12
|
-
"icons/
|
|
12
|
+
"icons/twi.icns"
|
|
13
13
|
]
|
|
14
14
|
}
|
|
15
15
|
}
|