mac命令行默认打通用包

This commit is contained in:
Tw93
2023-01-06 18:57:54 +08:00
parent d681ea8964
commit 0d941bd73f
12 changed files with 78 additions and 215 deletions

119
dist/cli.js vendored
View File

@@ -1646,7 +1646,7 @@ function mergeTauriConfig(url, options, tauriConf) {
const reg = new RegExp(/([0-9]*[a-zA-Z]+[0-9]*)+/);
if (!reg.test(name) || reg.exec(name)[0].length != name.length) {
logger.error("package name is illegal it must be letters, numbers, and it must contain the letters");
logger.error("E.g 123pan,123Pan Pan123,weread, WeRead, WERead");
logger.error("E.g 123pan,123Pan,Pan123,weread,WeRead,WERead");
process.exit();
}
}
@@ -1752,38 +1752,6 @@ 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);
// }
// }
function downloadIcon(iconUrl) {
return __awaiter(this, void 0, void 0, function* () {
let iconResponse;
@@ -1861,8 +1829,8 @@ function checkRustInstalled() {
var tauri$3 = {
windows: [
{
url: "https://weread.qq.com/",
transparent: true,
url: "https://baidu.com",
transparent: false,
fullscreen: false,
width: 1200,
height: 780,
@@ -1874,21 +1842,40 @@ var tauri$3 = {
},
updater: {
active: false
},
bundle: {
icon: [
"/Users/tw93/www/pake/src-tauri/icons/icon.icns"
],
identifier: "pake-bb6e08",
active: true,
category: "DeveloperTool",
copyright: "",
externalBin: [
],
longDescription: "",
macOS: {
entitlements: null,
exceptionDomain: "",
frameworks: [
],
providerShortName: null,
signingIdentity: null
},
resources: [
],
shortDescription: "",
targets: [
"dmg"
]
}
};
var build = {
devPath: "../dist",
distDir: "../dist",
beforeBuildCommand: "",
beforeDevCommand: ""
};
var CommonConf = {
"package": {
productName: "WeRead",
productName: "baidu",
version: "1.0.0"
},
tauri: tauri$3,
build: build
tauri: tauri$3
};
var tauri$2 = {
@@ -1931,9 +1918,9 @@ var WinConf = {
var tauri$1 = {
bundle: {
icon: [
"icons/weread.icns"
"/Users/tw93/www/pake/src-tauri/icons/icon.icns"
],
identifier: "com.tw93.weread",
identifier: "pake-bb6e08",
active: true,
category: "DeveloperTool",
copyright: "",
@@ -2038,7 +2025,7 @@ class MacBuilder {
yield installRust();
}
else {
log.error('Error: Pake need Rust to package your webapp!!!');
log.error('Error: Pake need Rust to package your webapp!');
process.exit(2);
}
});
@@ -2048,16 +2035,10 @@ class MacBuilder {
log.debug('PakeAppOptions', options);
const { name } = options;
yield mergeTauriConfig(url, options, tauriConf);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "x64";
if (process.arch === "arm64") {
arch = "aarch64";
}
else {
arch = process.arch;
}
const dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`;
const appPath = this.getBuildedAppPath(npmDirectory, dmgName);
//这里直接使用 universal-apple-darwin 的打包,而非当前系统的包
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
const dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
const appPath = this.getBuildAppPath(npmDirectory, dmgName);
const distPath = path.resolve(`${name}.dmg`);
yield fs.copyFile(appPath, distPath);
yield fs.unlink(appPath);
@@ -2065,8 +2046,8 @@ class MacBuilder {
logger.success('You can find the app installer in', distPath);
});
}
getBuildedAppPath(npmDirectory, dmgName) {
return path.join(npmDirectory, 'src-tauri/target/release/bundle/dmg', dmgName);
getBuildAppPath(npmDirectory, dmgName) {
return path.join(npmDirectory, 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', dmgName);
}
}
@@ -2102,7 +2083,7 @@ class WinBuilder {
const language = tauriConf.tauri.bundle.windows.wix.language[0];
const arch = process.arch;
const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;
const appPath = this.getBuildedAppPath(npmDirectory, msiName);
const appPath = this.getBuildAppPath(npmDirectory, msiName);
const distPath = path.resolve(`${name}.msi`);
yield fs.copyFile(appPath, distPath);
yield fs.unlink(appPath);
@@ -2110,7 +2091,7 @@ class WinBuilder {
logger.success('You can find the app installer in', distPath);
});
}
getBuildedAppPath(npmDirectory, dmgName) {
getBuildAppPath(npmDirectory, dmgName) {
return path.join(npmDirectory, 'src-tauri/target/release/bundle/msi', dmgName);
}
}
@@ -2144,7 +2125,7 @@ class LinuxBuilder {
const { name } = options;
yield mergeTauriConfig(url, options, tauriConf);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "";
let arch;
if (process.arch === "x64") {
arch = "amd64";
}
@@ -2152,21 +2133,21 @@ class LinuxBuilder {
arch = process.arch;
}
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
const appPath = this.getBuildAppPath(npmDirectory, "deb", debName);
const distPath = path.resolve(`${name}.deb`);
yield fs.copyFile(appPath, distPath);
yield fs.unlink(appPath);
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
const appImagePath = this.getBuildAppPath(npmDirectory, "appimage", appImageName);
const distAppPath = path.resolve(`${name}.AppImage`);
yield fs.copyFile(appImagePath, distAppPath);
yield fs.unlink(appImagePath);
logger.success('Build success!');
logger.success('You can find the deb app installer in', distPath);
logger.success('You can find the Appimage app installer in', distAppPath);
logger.success('You can find the AppImage app installer in', distAppPath);
});
}
getBuildedAppPath(npmDirectory, packageType, packageName) {
getBuildAppPath(npmDirectory, packageType, packageName) {
return path.join(npmDirectory, 'src-tauri/target/release/bundle/', packageType, packageName);
}
}
@@ -2187,7 +2168,7 @@ class BuilderFactory {
}
var name = "pake-cli";
var version = "1.0.1";
var version = "1.2.0";
var description = "🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App 🤱🏻 A simple way to make any web page a desktop application using Rust.";
var engines = {
node: "^14.13 || >=16.0.0"
@@ -2303,7 +2284,7 @@ program
.option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
.action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
checkUpdateTips();
yield checkUpdateTips();
if (!url) {
// 直接 pake 不需要出现url提示
program.help();
@@ -2315,6 +2296,6 @@ program
const builder = BuilderFactory.create();
yield builder.prepare();
const appOptions = yield handleOptions(options, url);
builder.build(url, appOptions);
yield builder.build(url, appOptions);
}));
program.parse();