Skip to content

Commit

Permalink
✨ 2.0.7-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed Jun 16, 2023
1 parent eac6f28 commit 25e29f8
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 37 deletions.
22 changes: 2 additions & 20 deletions bin/builders/common.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
import { PakeAppOptions } from '@/types.js';
import { PakeAppOptions,TauriConfig } from '@/types.js';
import prompts from 'prompts';
import path from 'path';
import fs from 'fs/promises';
import fs2 from 'fs-extra';
import {TauriConfig} from 'tauri/src/types';

import { npmDirectory } from '@/utils/dir.js';
import logger from '@/options/logger.js';

type DangerousRemoteDomainIpAccess = {
domain: string;
windows: string[];
enableTauriAPI: boolean;
schema?: string;
plugins?: string[];
}

// https://tauri.app/v1/api/config/#remotedomainaccessscope
type NextTauriConfig = TauriConfig & {
tauri: {
security: {
dangerousRemoteDomainIpcAccess?: DangerousRemoteDomainIpAccess[]
}
}
}


export async function promptText(message: string, initial?: string) {
const response = await prompts({
Expand All @@ -36,7 +18,7 @@ export async function promptText(message: string, initial?: string) {
return response.content;
}

function setSecurityConfigWithUrl(tauriConfig: NextTauriConfig, url: string) {
function setSecurityConfigWithUrl(tauriConfig: TauriConfig, url: string) {
const myURL = new URL(url);
const hostname = myURL.hostname;
tauriConfig.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = hostname;
Expand Down
152 changes: 152 additions & 0 deletions bin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,155 @@ export interface PakeCliOptions {
export interface PakeAppOptions extends PakeCliOptions {
identifier: string;
}

export interface TauriBuildConfig {
/**
* the path to the app's dist dir
* this path must contain your index.html file
*/
distDir: string
/**
* the app's dev server URL, or the path to the directory containing an index.html to open
*/
devPath: string
/**
* a shell command to run before `tauri dev` kicks in
*/
beforeDevCommand?: string
/**
* a shell command to run before `tauri build` kicks in
*/
beforeBuildCommand?: string
withGlobalTauri?: boolean
}

type DangerousRemoteDomainIpAccess = {
domain: string;
windows: string[];
enableTauriAPI: boolean;
schema?: string;
plugins?: string[];
}

/**
* Tauri configuration
*/
export interface TauriConfig {
/**
* build/dev configuration
*/
build: TauriBuildConfig
/**
* the context of the current `tauri dev` or `tauri build`
*/
ctx: {
/**
* whether we're building for production or not
*/
prod?: boolean
/**
* whether we're running on the dev environment or not
*/
dev?: boolean
/**
* the target of the compilation (see `rustup target list`)
*/
target?: string
/**
* whether the app should be built on debug mode or not
*/
debug?: boolean
/**
* defines we should exit the `tauri dev` process if a Rust code error is found
*/
exitOnPanic?: boolean
}
/**
* tauri root configuration object
*/
tauri: {
/**
* the embedded server configuration
*/
embeddedServer: {
/**
* whether we should use the embedded-server or the no-server mode
*/
active?: boolean
/**
* the embedded server port number or the 'random' string to generate one at runtime
*/
port?: number | 'random' | undefined
}
/**
* tauri bundler configuration
*/
bundle: {
/**
* whether we should build your app with tauri-bundler or plain `cargo build`
*/
active?: boolean
/**
* the bundle targets, currently supports ["deb", "osx", "msi", "appimage", "dmg"] or "all"
*/
targets?: string | string[]
/**
* the app's identifier
*/
identifier: string
/**
* the app's icons
*/
icon: string[]
/**
* app resources to bundle
* each resource is a path to a file or directory
* glob patterns are supported
*/
resources?: string[]
externalBin?: string[]
copyright?: string
category?: string
shortDescription?: string
longDescription?: string
deb?: {
depends?: string[]
useBootstrapper?: boolean
}
osx?: {
frameworks?: string[]
minimumSystemVersion?: string
license?: string
useBootstrapper?: boolean
}
exceptionDomain?: string
}
allowlist: {
all: boolean
[index: string]: boolean
}
window: {
title: string
width?: number
height?: number
resizable?: boolean
fullscreen?: boolean
}
security: {
csp?: string,
dangerousRemoteDomainIpcAccess?: DangerousRemoteDomainIpAccess[]
}
inliner: {
active?: boolean
}
}
plugins?: {
[name: string]: {
[key: string]: any
}
}
/**
* Whether or not to enable verbose logging
*/
verbose?: boolean
}
4 changes: 2 additions & 2 deletions bin/utils/ip_addr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function isChinaDomain(domain: string): Promise<boolean> {
return await isChinaIP(ip, domain);
} catch (error) {
// 域名无法解析,返回false
logger.info(`${domain} can't be parse, is not in China!`);
logger.info(`${domain} can't be parse!`);
return false;
}
}
Expand All @@ -46,7 +46,7 @@ async function isChinaIP(ip: string, domain: string): Promise<boolean> {
return delay > 500;
} catch (error) {
// 命令执行出错,返回false
logger.info(`ping ${domain} failed!, is not in China!`);
logger.info(`ping ${domain} failed!`);
return false;
}
}
Expand Down
21 changes: 11 additions & 10 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import path from 'path';
import fs$1 from 'fs/promises';
import fs2 from 'fs-extra';
import chalk from 'chalk';
import URL from 'node:url';
import crypto from 'crypto';
import axios from 'axios';
import { fileTypeFromBuffer } from 'file-type';
Expand All @@ -35,6 +34,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */


function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
Expand Down Expand Up @@ -1641,7 +1642,8 @@ function promptText(message, initial) {
});
}
function setSecurityConfigWithUrl(tauriConfig, url) {
const { hostname } = URL.parse(url);
const myURL = new URL(url);
const hostname = myURL.hostname;
tauriConfig.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = hostname;
}
function mergeTauriConfig(url, options, tauriConf) {
Expand Down Expand Up @@ -2056,7 +2058,7 @@ function isChinaDomain(domain) {
}
catch (error) {
// 域名无法解析,返回false
logger.info(`${domain} can't be parse, is not in China!`);
logger.info(`${domain} can't be parse!`);
return false;
}
});
Expand All @@ -2071,7 +2073,7 @@ function isChinaIP(ip, domain) {
}
catch (error) {
// 命令执行出错,返回false
logger.info(`ping ${domain} failed!, is not in China!`);
logger.info(`ping ${domain} failed!`);
return false;
}
});
Expand Down Expand Up @@ -2124,7 +2126,7 @@ var tauri$3 = {
active: false
},
systemTray: {
iconPath: "png/icon_512.png",
iconPath: "png/weread_512.png",
iconAsTemplate: true
},
allowlist: {
Expand Down Expand Up @@ -2545,7 +2547,7 @@ class BuilderFactory {
}

var name = "pake-cli";
var version = "2.0.6";
var version = "2.0.7-beta3";
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";
var engines = {
node: ">=16.0.0"
Expand Down Expand Up @@ -2591,11 +2593,11 @@ var type = "module";
var exports = "./dist/pake.js";
var license = "MIT";
var dependencies = {
"@tauri-apps/api": "^1.2.0",
"@tauri-apps/cli": "^1.2.3",
"@tauri-apps/api": "^1.4.0",
"@tauri-apps/cli": "1.3.1",
axios: "^1.1.3",
chalk: "^5.1.2",
commander: "^9.4.1",
commander: "^11.0.0",
"file-type": "^18.0.0",
"fs-extra": "^11.1.0",
"is-url": "^1.2.4",
Expand All @@ -2620,7 +2622,6 @@ var devDependencies = {
"@types/tmp": "^0.2.3",
"@types/update-notifier": "^6.0.1",
"app-root-path": "^3.1.0",
concurrently: "^7.5.0",
"cross-env": "^7.0.3",
rollup: "^3.3.0",
tslib: "^2.4.1",
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pake-cli",
"version": "2.0.6",
"version": "2.0.7-beta3",
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。",
"engines": {
"node": ">=16.0.0"
Expand Down Expand Up @@ -47,10 +47,10 @@
"license": "MIT",
"dependencies": {
"@tauri-apps/api": "^1.4.0",
"@tauri-apps/cli": "^1.4.0",
"@tauri-apps/cli": "1.3.1",
"axios": "^1.1.3",
"chalk": "^5.1.2",
"commander": "^9.4.1",
"commander": "^11.0.0",
"file-type": "^18.0.0",
"fs-extra": "^11.1.0",
"is-url": "^1.2.4",
Expand All @@ -75,10 +75,8 @@
"@types/tmp": "^0.2.3",
"@types/update-notifier": "^6.0.1",
"app-root-path": "^3.1.0",
"concurrently": "^7.5.0",
"cross-env": "^7.0.3",
"rollup": "^3.3.0",
"tauri": "^0.15.0",
"tslib": "^2.4.1",
"typescript": "^4.9.3"
}
Expand Down

0 comments on commit 25e29f8

Please sign in to comment.