update pake-cli to 2.0.0-alpha2

This commit is contained in:
Tlntin
2023-04-10 21:57:29 +08:00
parent 567d6a8c41
commit 5379ce634d
16 changed files with 243 additions and 193 deletions

39
bin/options/icon.ts vendored
View File

@@ -22,7 +22,7 @@ export async function handleIcon(options: PakeAppOptions, url: string) {
}
export async function getDefaultIcon() {
logger.info('You haven\'t provided an app icon, so the default icon will be used. To assign a custom icon, please use the --icon option.')
logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)')
let iconPath = 'src-tauri/icons/icon.icns';
if (IS_WIN) {
iconPath = 'src-tauri/png/icon_256.ico';
@@ -33,6 +33,43 @@ export async function getDefaultIcon() {
return path.join(npmDirectory, iconPath);
}
// export async function getIconFromPageUrl(url: string) {
// const icon = await pageIcon(url);
// console.log(icon);
// if (icon.ext === '.ico') {
// const a = await ICO.parse(icon.data);
// icon.data = Buffer.from(a[0].buffer);
// }
// const iconDir = (await dir()).path;
// const iconPath = path.join(iconDir, `/icon.icns`);
// const out = png2icons.createICNS(icon.data, png2icons.BILINEAR, 0);
// await fs.writeFile(iconPath, out);
// return iconPath;
// }
// export async function getIconFromMacosIcons(name: string) {
// const data = {
// query: name,
// filters: 'approved:true',
// hitsPerPage: 10,
// page: 1,
// };
// const res = await axios.post('https://p1txh7zfb3-2.algolianet.com/1/indexes/macOSicons/query?x-algolia-agent=Algolia%20for%20JavaScript%20(4.13.1)%3B%20Browser', data, {
// headers: {
// 'x-algolia-api-key': '0ba04276e457028f3e11e38696eab32c',
// 'x-algolia-application-id': 'P1TXH7ZFB3',
// },
// });
// if (!res.data.hits.length) {
// return '';
// } else {
// return downloadIcon(res.data.hits[0].icnsUrl);
// }
// }
export async function downloadIcon(iconUrl: string) {
let iconResponse;
try {