Skip to content

Commit 0e1e57d

Browse files
committed
🎨 Format Optimization
1 parent eabdfc2 commit 0e1e57d

File tree

14 files changed

+92
-78
lines changed

14 files changed

+92
-78
lines changed

bin/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Ensure that your Node.js version is 18.0 or higher (e.g., 18.20.2). Avoid using `sudo` for the installation. If you encounter permission issues with npm, refer to [How to fix npm throwing error without sudo](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo).
66

77
```bash
8-
npm install pake-cli -g
8+
npm install pake-cli -g
99
```
1010

1111
## Considerations for Windows & Linux Users
@@ -40,14 +40,15 @@ npm install pake-cli -g
4040
## Usage
4141

4242
### Development
43+
4344
The `DEFAULT_DEV_PAKE_OPTIONS` configuration in `bin/defaults.ts` can be modified at development time to match the `pake-cli` configuration description.
4445

4546
```typescript
46-
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & {url: string} = {
47+
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & { url: string } = {
4748
...DEFAULT_PAKE_OPTIONS,
4849
url: 'https://weread.qq.com',
4950
name: 'Weread',
50-
}
51+
};
5152
```
5253

5354
then
@@ -129,7 +130,6 @@ screen.
129130
--fullscreen
130131
```
131132

132-
133133
#### [activation-shortcut]
134134

135135
Set the activation shortcut for the application. Default is ` `, it does not take effect, you can customize the activation shortcut with the following commands, e.g. `CmdOrControl+Shift+P`, use can refer to [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers).
@@ -221,7 +221,7 @@ Enable recursive copying. When the URL is a local file path, enabling this optio
221221

222222
#### [inject]
223223

224-
Using `inject`, you can inject local absolute and relative path `css` and `js` files into the page you specify the `url` to customize it. For example, an adblock script that can be applied to any web page, or a `css` that optimizes the `UI` of a page, you can write it once to customize it. would only need to write the `app` once to generalize it to any other page.
224+
Using `inject`, you can inject local absolute and relative path `css` and `js` files into the page you specify the `url` to customize it. For example, an adblock script that can be applied to any web page, or a `css` that optimizes the `UI` of a page, you can write it once to customize it. would only need to write the `app` once to generalize it to any other page.
225225

226226
```shell
227227
--inject ./tools/style.css,./tools/hotkey.js
@@ -248,4 +248,3 @@ The typed package has dev-tools for debugging, in addition to outputting more lo
248248
## Conclusion
249249

250250
After completing the above steps, your application should be successfully packaged. Please note that the packaging process may take some time depending on your system configuration and network conditions. Be patient, and once the packaging is complete, you can find the application installer in the specified directory.
251-

bin/README_CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
请确保您的 Node.js 版本为 18 或更高版本(例如 18.7)。请避免使用 `sudo` 进行安装。如果 npm 报告权限问题,请参考 [如何在不使用 sudo 的情况下修复 npm 报错](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo)
66

77
```bash
8-
npm install pake-cli -g
8+
npm install pake-cli -g
99
```
1010

1111
## Windows/Linux 注意事项
@@ -44,11 +44,11 @@ npm install pake-cli -g
4444
开发时可以修改 `bin/defaults.ts``DEFAULT_DEV_PAKE_OPTIONS` 配置,配置项和 `pake-cli` 配置说明保持一致
4545

4646
```typescript
47-
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & {url: string} = {
47+
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & { url: string } = {
4848
...DEFAULT_PAKE_OPTIONS,
4949
url: 'https://weread.qq.com',
5050
name: 'Weread',
51-
}
51+
};
5252
```
5353

5454
之后运行

bin/cli.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ ${green('| __/ (_| | < __/')} ${yellow('https://github.com/tw93/pake')}
1818
${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with Rust.')}
1919
`;
2020

21-
program
22-
.addHelpText('beforeAll', logo)
23-
.usage(`[url] [options]`)
24-
.showHelpAfterError();
21+
program.addHelpText('beforeAll', logo).usage(`[url] [options]`).showHelpAfterError();
2522

2623
program
2724
.argument('[url]', 'The web URL you want to package', validateUrlInput)
@@ -37,12 +34,24 @@ program
3734
.option('--inject [injects...]', 'Injection of .js or .css Files', DEFAULT.inject)
3835
.option('--debug', 'Debug build and more output', DEFAULT.debug)
3936
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT.userAgent).hideHelp())
40-
.addOption(new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp())
37+
.addOption(
38+
new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(),
39+
)
4140
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT.alwaysOnTop).hideHelp())
42-
.addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts').default(DEFAULT.disabledWebShortcuts).hideHelp())
43-
.addOption(new Option('--safe-domain [domains...]', 'Domains that Require Security Configuration').default(DEFAULT.safeDomain).hideHelp())
41+
.addOption(
42+
new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
43+
.default(DEFAULT.disabledWebShortcuts)
44+
.hideHelp(),
45+
)
46+
.addOption(
47+
new Option('--safe-domain [domains...]', 'Domains that Require Security Configuration')
48+
.default(DEFAULT.safeDomain)
49+
.hideHelp(),
50+
)
4451
.addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT.showSystemTray).hideHelp())
45-
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT.systemTrayIcon).hideHelp())
52+
.addOption(
53+
new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT.systemTrayIcon).hideHelp(),
54+
)
4655
.version(packageJson.version, '-v, --version', 'Output the current version')
4756
.action(async (url: string, options: PakeCliOptions) => {
4857
await checkUpdateTips();

bin/dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import log from 'loglevel';
2-
import {DEFAULT_DEV_PAKE_OPTIONS} from './defaults';
2+
import { DEFAULT_DEV_PAKE_OPTIONS } from './defaults';
33
import handleInputOptions from './options/index';
44
import BuilderProvider from './builders/BuilderProvider';
55

@@ -14,4 +14,4 @@ async function startBuild() {
1414
await builder.start(DEFAULT_DEV_PAKE_OPTIONS.url);
1515
}
1616

17-
startBuild();
17+
startBuild();

bin/helpers/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
197197
logger.error('The injected file must be in either CSS or JS format.');
198198
return;
199199
}
200-
const files = inject.map(filepath => path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath));
200+
const files = inject.map(filepath => (path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath)));
201201
tauriConf.pake.inject = files;
202202
await combineFiles(files, injectFilePath);
203203
} else {

bin/helpers/rust.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import { isChinaDomain } from '@/utils/ip';
99
export async function installRust() {
1010
const isActions = process.env.GITHUB_ACTIONS;
1111
const isInChina = await isChinaDomain('sh.rustup.rs');
12-
const rustInstallScriptForMac = isInChina && !isActions
13-
? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh'
14-
: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
12+
const rustInstallScriptForMac =
13+
isInChina && !isActions
14+
? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh'
15+
: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
1516
const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup';
1617

1718
const spinner = getSpinner('Downloading Rust...');

bin/options/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ function isValidName(name: string, platform: NodeJS.Platform): boolean {
2020
return !!name && reg.test(name);
2121
}
2222

23-
export default async function handleOptions(
24-
options: PakeCliOptions,
25-
url: string,
26-
): Promise<PakeAppOptions> {
23+
export default async function handleOptions(options: PakeCliOptions, url: string): Promise<PakeAppOptions> {
2724
const { platform } = process;
2825
const isActions = process.env.GITHUB_ACTIONS;
2926
let name = options.name;

bin/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface PakeCliOptions {
4242
// Tray icon, default same as app icon for Windows and Linux, macOS requires separate png or ico
4343
systemTrayIcon: string;
4444

45-
// Recursive copy, when url is a local file path, if this option is enabled, the url path file and all its subfiles will be copied to the pake static file folder, default off
45+
// Recursive copy, when url is a local file path, if this option is enabled, the url path file and all its subFiles will be copied to the pake static file folder, default off
4646
useLocalFile: false;
4747

4848
// Multi arch, supports both Intel and M1 chips, only for Mac

bin/utils/combine.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ export default async function combineFiles(files: string[], output: string) {
44
const contents = files.map(file => {
55
const fileContent = fs.readFileSync(file);
66
if (file.endsWith('.css')) {
7-
return "window.addEventListener('DOMContentLoaded', (_event) => { const css = `" + fileContent + "`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });";
7+
return (
8+
"window.addEventListener('DOMContentLoaded', (_event) => { const css = `" +
9+
fileContent +
10+
"`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });"
11+
);
812
}
9-
10-
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + " });";
13+
14+
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + ' });';
1115
});
1216
fs.writeFileSync(output, contents.join('\n'));
1317
return files;
14-
}
18+
}

bin/utils/dir.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ const currentModulePath = fileURLToPath(import.meta.url);
77
// Resolve the parent directory of the current module
88
export const npmDirectory = path.join(path.dirname(currentModulePath), '..');
99

10-
export const tauriConfigDirectory = process.env.NODE_ENV === 'development' ? path.join(npmDirectory, 'src-tauri', '.pake') : path.join(npmDirectory, 'src-tauri');
10+
export const tauriConfigDirectory =
11+
process.env.NODE_ENV === 'development'
12+
? path.join(npmDirectory, 'src-tauri', '.pake')
13+
: path.join(npmDirectory, 'src-tauri');

0 commit comments

Comments
 (0)