CLI support set app version

This commit is contained in:
Tw93
2024-12-23 20:35:13 +08:00
parent 712e830006
commit 7a02d8fb71
8 changed files with 31 additions and 4 deletions

8
bin/README.md vendored
View File

@@ -127,6 +127,14 @@ Sets whether the window is always at the top level, defaults to `false`.
--always-on-top --always-on-top
``` ```
#### [app-version]
Set the version number of the packaged application to be consistent with the naming format of version in package.json, defaulting to `1.0.0`.
```shell
--app-version <string>
```
#### [dark-mode] #### [dark-mode]
Force Mac to package applications using dark mode, default is `false`. Force Mac to package applications using dark mode, default is `false`.

8
bin/README_CN.md vendored
View File

@@ -127,6 +127,14 @@ pake [url] [options]
--always-on-top --always-on-top
``` ```
#### [app-version]
设置打包应用的版本号,和 package.json 里面 version 命名格式一致,默认为 `1.0.0`。
```shell
--app-version <string>
```
#### [dark-mode] #### [dark-mode]
强制 Mac 打包应用使用黑暗模式,默认为 `false`。 强制 Mac 打包应用使用黑暗模式,默认为 `false`。

1
bin/cli.ts vendored
View File

@@ -38,6 +38,7 @@ program
.addOption( .addOption(
new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(), new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(),
) )
.addOption(new Option('--app-version <string>', 'App version, the same as package.json version').default(DEFAULT.appVersion).hideHelp())
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT.alwaysOnTop).hideHelp()) .addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT.alwaysOnTop).hideHelp())
.addOption(new Option('--dark-mode', 'Force Mac app to use dark mode').default(DEFAULT.darkMode).hideHelp()) .addOption(new Option('--dark-mode', 'Force Mac app to use dark mode').default(DEFAULT.darkMode).hideHelp())
.addOption( .addOption(

1
bin/defaults.ts vendored
View File

@@ -8,6 +8,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
resizable: true, resizable: true,
hideTitleBar: false, hideTitleBar: false,
alwaysOnTop: false, alwaysOnTop: false,
appVersion: '1.0.0',
darkMode: false, darkMode: false,
disabledWebShortcuts: false, disabledWebShortcuts: false,
activationShortcut: '', activationShortcut: '',

View File

@@ -14,6 +14,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
fullscreen, fullscreen,
hideTitleBar, hideTitleBar,
alwaysOnTop, alwaysOnTop,
appVersion,
darkMode, darkMode,
disabledWebShortcuts, disabledWebShortcuts,
activationShortcut, activationShortcut,
@@ -47,6 +48,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
tauriConf.productName = name; tauriConf.productName = name;
tauriConf.identifier = identifier; tauriConf.identifier = identifier;
tauriConf.version = appVersion;
if (platform == 'win32') { if (platform == 'win32') {
tauriConf.bundle.windows.wix.language[0] = installerLanguage; tauriConf.bundle.windows.wix.language[0] = installerLanguage;

3
bin/types.ts vendored
View File

@@ -27,6 +27,9 @@ export interface PakeCliOptions {
// Enable windows always on top, default false // Enable windows always on top, default false
alwaysOnTop: boolean; alwaysOnTop: boolean;
// App version, the same as package.json version, default 1.0.0
appVersion: string;
// Force Mac to use dark mode, default false // Force Mac to use dark mode, default false
darkMode: boolean; darkMode: boolean;

10
dist/cli.js vendored
View File

@@ -20,7 +20,7 @@ import * as psl from 'psl';
import isUrl from 'is-url'; import isUrl from 'is-url';
var name = "pake-cli"; var name = "pake-cli";
var version$1 = "3.0.3"; var version$1 = "3.1.0";
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。"; var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
var engines = { var engines = {
node: ">=16.0.0" node: ">=16.0.0"
@@ -70,7 +70,7 @@ var dependencies = {
"@tauri-apps/api": "^1.6.0", "@tauri-apps/api": "^1.6.0",
"@tauri-apps/cli": "^2.1.0", "@tauri-apps/cli": "^2.1.0",
axios: "^1.7.9", axios: "^1.7.9",
chalk: "^5.4.0", chalk: "^5.4.1",
commander: "^11.1.0", commander: "^11.1.0",
"file-type": "^18.7.0", "file-type": "^18.7.0",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
@@ -426,7 +426,7 @@ async function combineFiles(files, output) {
} }
async function mergeConfig(url, options, tauriConf) { async function mergeConfig(url, options, tauriConf) {
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, } = options; const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, } = options;
const { platform } = process; const { platform } = process;
// Set Windows parameters. // Set Windows parameters.
const tauriConfWindowOptions = { const tauriConfWindowOptions = {
@@ -443,6 +443,8 @@ async function mergeConfig(url, options, tauriConf) {
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions }); Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.productName = name; tauriConf.productName = name;
tauriConf.identifier = identifier; tauriConf.identifier = identifier;
console.log('tauriConf appVersion>>>>>>>>>>>>>>>>>>>>>>>', appVersion);
tauriConf.version = appVersion;
if (platform == 'win32') { if (platform == 'win32') {
tauriConf.bundle.windows.wix.language[0] = installerLanguage; tauriConf.bundle.windows.wix.language[0] = installerLanguage;
} }
@@ -773,6 +775,7 @@ const DEFAULT_PAKE_OPTIONS = {
resizable: true, resizable: true,
hideTitleBar: false, hideTitleBar: false,
alwaysOnTop: false, alwaysOnTop: false,
appVersion: '1.0.0',
darkMode: false, darkMode: false,
disabledWebShortcuts: false, disabledWebShortcuts: false,
activationShortcut: '', activationShortcut: '',
@@ -974,6 +977,7 @@ program
.option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch) .option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch)
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp()) .addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp())
.addOption(new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT_PAKE_OPTIONS.targets).hideHelp()) .addOption(new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT_PAKE_OPTIONS.targets).hideHelp())
.addOption(new Option('--app-version <string>', 'App version, the same as package.json version').default(DEFAULT_PAKE_OPTIONS.appVersion).hideHelp())
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT_PAKE_OPTIONS.alwaysOnTop).hideHelp()) .addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT_PAKE_OPTIONS.alwaysOnTop).hideHelp())
.addOption(new Option('--dark-mode', 'Force Mac app to use dark mode').default(DEFAULT_PAKE_OPTIONS.darkMode).hideHelp()) .addOption(new Option('--dark-mode', 'Force Mac app to use dark mode').default(DEFAULT_PAKE_OPTIONS.darkMode).hideHelp())
.addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts') .addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')

View File

@@ -1,6 +1,6 @@
{ {
"name": "pake-cli", "name": "pake-cli",
"version": "3.0.4", "version": "3.1.0",
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。", "description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。",
"engines": { "engines": {
"node": ">=16.0.0" "node": ">=16.0.0"