Skip to content

Commit

Permalink
Merge branch 'tw93:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlntin authored Jan 8, 2023
2 parents c13bf97 + 0fd9c67 commit a382264
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 255 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build Contribute List
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/editorconfig-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check if the codebase matches the EditorConfig rules
name: Check EditorConfig

on:
push:
Expand Down
21 changes: 1 addition & 20 deletions .github/workflows/pake_build.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: build
name: Build App
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "V*"
workflow_dispatch:

jobs:
build:
Expand Down Expand Up @@ -66,24 +65,6 @@ jobs:
run: |
npm run build:all-windows
# - name: Create Release and Upload Release Asset
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# tag_name: ${{ github.ref }}
# name: Release ${{ github.ref }}
# body: TODO New Release.
# draft: false
# prerelease: false
# files: |
# output/*/*.*

# - uses: ncipollo/release-action@v1
# if: startsWith(github.ref, 'refs/tags/v')
# with:
# allowUpdates: true
# artifacts: "output/*/*.*"
# token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/rust-code-quality-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check, test and format the Rust part of codebase
name: Check Rust Code

on:
push:
Expand Down Expand Up @@ -40,9 +40,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: >
libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev
libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
version: 1.0
- name: Run unit & integration tests with nextest
run: cargo hack --feature-powerset nextest run
Expand All @@ -69,9 +67,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: >
libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev
libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
version: 1.0
- name: Run all-features code quality checks
run: cargo hack --feature-powerset --no-dev-deps clippy
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,28 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
<sub><b>Dengju Deng</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Fechin">
<img src="https://avatars.githubusercontent.com/u/2541482?v=4" width="90;" alt="Fechin"/>
<br />
<sub><b>Fechin</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/princemaple">
<img src="https://avatars.githubusercontent.com/u/1329716?v=4" width="90;" alt="princemaple"/>
<br />
<sub><b>Po Chen</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/houhoz">
<img src="https://avatars.githubusercontent.com/u/19684376?v=4" width="90;" alt="houhoz"/>
<br />
<sub><b>Hyzhao</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/liusishan">
<img src="https://avatars.githubusercontent.com/u/33129823?v=4" width="90;" alt="liusishan"/>
Expand Down
1 change: 1 addition & 0 deletions app.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ chatgpt,ChatGPT,ChatGPT,https://chat.openai.com/chat
flomo,Flomo,浮墨,https://v.flomoapp.com/mine
qwerty,Qwerty,Qwerty,https://qwerty.kaiyi.cool/
zlibrary,ZLibrary,ZLibrary,https://zlib.cydiar.com/
tableconvert,TableConvert,TableConvert,https://tableconvert.com/
lizhi,LiZhi,李志,https://lizhi.turkyden.com/?from=pake
weread,WeRead,微信阅读,https://weread.qq.com/
16 changes: 8 additions & 8 deletions bin/builders/LinuxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,36 @@ export default class LinuxBuilder implements IBuilder {
const { name } = options;

await mergeTauriConfig(url, options, tauriConf);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "";
await shellExec(`cd ${npmDirectory} && npm install && npm run build`);

let arch: string;
if (process.arch === "x64") {
arch = "amd64";
} else {
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`);
await fs.copyFile(appPath, distPath);
await 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`);
await fs.copyFile(appImagePath, distAppPath);
await 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: string,packageType: string, packageName: string) {
getBuildAppPath(npmDirectory: string, packageType: string, packageName: string) {
return path.join(
npmDirectory,
'src-tauri/target/release/bundle/',
packageType,
packageName
);
}
}
}
20 changes: 8 additions & 12 deletions bin/builders/MacBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class MacBuilder implements IBuilder {
// TODO 国内有可能会超时
await 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);
}
}
Expand All @@ -40,15 +40,11 @@ export default class MacBuilder implements IBuilder {

await mergeTauriConfig(url, options, tauriConf);

const _ = await 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 的打包,而非当前系统的包
await 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`);
await fs.copyFile(appPath, distPath);
await fs.unlink(appPath);
Expand All @@ -57,10 +53,10 @@ export default class MacBuilder implements IBuilder {
logger.success('You can find the app installer in', distPath);
}

getBuildedAppPath(npmDirectory: string, dmgName: string) {
getBuildAppPath(npmDirectory: string, dmgName: string) {
return path.join(
npmDirectory,
'src-tauri/target/release/bundle/dmg',
'src-tauri/target/universal-apple-darwin/release/bundle/dmg',
dmgName
);
}
Expand Down
10 changes: 4 additions & 6 deletions bin/builders/WinBulider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { checkRustInstalled, installRust } from '@/helpers/rust.js';
import { PakeAppOptions } from '@/types.js';
import { IBuilder } from './base.js';
import { shellExec } from '@/utils/shell.js';
// @ts-expect-error 加上resolveJsonModule rollup会打包报错
// import tauriConf from '../../src-tauri/tauri.windows.conf.json';
// @ts-expect-error
import tauriConf from './tauriConf.js';

import { fileURLToPath } from 'url';
import logger from '@/options/logger.js';
import { mergeTauriConfig } from './common.js';
import { npmDirectory } from '@/utils/dir.js';
Expand Down Expand Up @@ -47,19 +45,19 @@ export default class WinBuilder implements IBuilder {

await mergeTauriConfig(url, options, tauriConf);

const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
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`);
await fs.copyFile(appPath, distPath);
await fs.unlink(appPath);
logger.success('Build success!');
logger.success('You can find the app installer in', distPath);
}

getBuildedAppPath(npmDirectory: string, dmgName: string) {
getBuildAppPath(npmDirectory: string, dmgName: string) {
return path.join(
npmDirectory,
'src-tauri/target/release/bundle/msi',
Expand Down
4 changes: 2 additions & 2 deletions bin/builders/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function mergeTauriConfig(
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();
}
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export async function mergeTauriConfig(
break;
}
}

let bundleConf = {tauri: {bundle: tauriConf.tauri.bundle}};
await fs.writeFile(
configPath,
Expand Down
7 changes: 3 additions & 4 deletions bin/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { program } from 'commander';
import log from 'loglevel';
import chalk from 'chalk';
import { DEFAULT_PAKE_OPTIONS } from './defaults.js';
import { PakeCliOptions } from './types.js';
import { validateNumberInput, validateUrlInput } from './utils/validate.js';
Expand All @@ -9,7 +8,6 @@ import BuilderFactory from './builders/BuilderFactory.js';
import { checkUpdateTips } from './helpers/updater.js';
// @ts-expect-error
import packageJson from '../package.json';
import logger from './options/logger.js';

program.version(packageJson.version).description('A cli application can package a web page to desktop application.');

Expand All @@ -25,7 +23,8 @@ program
.option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
.action(async (url: string, options: PakeCliOptions) => {
checkUpdateTips();

await checkUpdateTips();

if (!url) {
// 直接 pake 不需要出现url提示
Expand All @@ -42,7 +41,7 @@ program

const appOptions = await handleInputOptions(options, url);

builder.build(url, appOptions);
await builder.build(url, appOptions);
});

program.parse();
37 changes: 0 additions & 37 deletions bin/options/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,6 @@ 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 {
Expand Down
Loading

0 comments on commit a382264

Please sign in to comment.