fixup some bug for pake-cli

This commit is contained in:
Pake-Actions
2023-04-11 10:33:28 +08:00
parent 26a008ad89
commit 7653eb77ed
4 changed files with 2294 additions and 2302 deletions

View File

@@ -66,6 +66,8 @@ export async function mergeTauriConfig(
// logger.warn(JSON.stringify(tauriConf.pake.windows, null, 4)); // logger.warn(JSON.stringify(tauriConf.pake.windows, null, 4));
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions }); Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
// 判断一下url类型是文件还是网站 // 判断一下url类型是文件还是网站
// 如果是文件并且开启了递归拷贝功能则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下否则只拷贝单个文件。 // 如果是文件并且开启了递归拷贝功能则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下否则只拷贝单个文件。
@@ -171,22 +173,13 @@ export async function mergeTauriConfig(
} }
// 处理targets 暂时只对linux开放 // 处理targets 暂时只对linux开放
if (process.platform === "linux") {
if (options.targets.length > 0) {
if (options.targets === "deb" || options.targets === "appimage" || options.targets === "all") {
tauriConf.tauri.bundle.targets = [options.targets];
}
}
} else {
tauriConf.tauri.bundle.targets = ["deb"];
}
tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
// 删除映射关系
if (process.platform === "linux") { if (process.platform === "linux") {
delete tauriConf.tauri.bundle.deb.files; delete tauriConf.tauri.bundle.deb.files;
if (["all", "deb", "appimage"].includes(options.targets)) {
tauriConf.tauri.bundle.targets = [options.targets];
} else {
logger.warn("targets must be 'all', 'deb', 'appimage', we will use default 'all'");
}
} }
// 处理应用图标 // 处理应用图标
@@ -299,7 +292,7 @@ export async function mergeTauriConfig(
pakeConfigPath, pakeConfigPath,
Buffer.from(JSON.stringify(tauriConf.pake, null, 4), 'utf-8') Buffer.from(JSON.stringify(tauriConf.pake, null, 4), 'utf-8')
); );
logger.info("tauri config", JSON.stringify(tauriConf.build));
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf)); let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
delete tauriConf2.pake; delete tauriConf2.pake;
delete tauriConf2.tauri.bundle; delete tauriConf2.tauri.bundle;

View File

@@ -7,6 +7,7 @@ import LinuxConf from '../../src-tauri/tauri.linux.conf.json';
let tauriConf = { let tauriConf = {
package: CommonConf.package, package: CommonConf.package,
tauri: CommonConf.tauri, tauri: CommonConf.tauri,
build: CommonConf.build,
pake: pakeConf pake: pakeConf
} }
switch (process.platform) { switch (process.platform) {

3
bin/utils/shell.ts vendored
View File

@@ -1,8 +1,9 @@
import shelljs from "shelljs"; import shelljs from "shelljs";
import { npmDirectory } from "./dir.js";
export function shellExec(command: string) { export function shellExec(command: string) {
return new Promise<number>((resolve, reject) => { return new Promise<number>((resolve, reject) => {
shelljs.exec(command, { async: true, silent: false }, (code) => { shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory}, (code) => {
if (code === 0) { if (code === 0) {
resolve(0); resolve(0);
} else { } else {

25
dist/cli.js vendored
View File

@@ -1669,6 +1669,8 @@ function mergeTauriConfig(url, options, tauriConf) {
} }
// logger.warn(JSON.stringify(tauriConf.pake.windows, null, 4)); // logger.warn(JSON.stringify(tauriConf.pake.windows, null, 4));
Object.assign(tauriConf.pake.windows[0], Object.assign({ url }, tauriConfWindowOptions)); Object.assign(tauriConf.pake.windows[0], Object.assign({ url }, tauriConfWindowOptions));
tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
// 判断一下url类型是文件还是网站 // 判断一下url类型是文件还是网站
// 如果是文件并且开启了递归拷贝功能则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下否则只拷贝单个文件。 // 如果是文件并且开启了递归拷贝功能则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下否则只拷贝单个文件。
const url_exists = yield fs$1.stat(url) const url_exists = yield fs$1.stat(url)
@@ -1763,21 +1765,14 @@ function mergeTauriConfig(url, options, tauriConf) {
} }
} }
// 处理targets 暂时只对linux开放 // 处理targets 暂时只对linux开放
if (process.platform === "linux") {
if (options.targets.length > 0) {
if (options.targets === "deb" || options.targets === "appimage" || options.targets === "all") {
tauriConf.tauri.bundle.targets = [options.targets];
}
}
}
else {
tauriConf.tauri.bundle.targets = ["deb"];
}
tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
// 删除映射关系
if (process.platform === "linux") { if (process.platform === "linux") {
delete tauriConf.tauri.bundle.deb.files; delete tauriConf.tauri.bundle.deb.files;
if (["all", "deb", "appimage"].includes(options.targets)) {
tauriConf.tauri.bundle.targets = [options.targets];
}
else {
logger.warn("targets must be 'all', 'deb', 'appimage', we will use default 'all'");
}
} }
// 处理应用图标 // 处理应用图标
const exists = yield fs$1.stat(options.icon) const exists = yield fs$1.stat(options.icon)
@@ -1883,6 +1878,7 @@ function mergeTauriConfig(url, options, tauriConf) {
yield fs$1.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf, null, 4), 'utf-8')); yield fs$1.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf, null, 4), 'utf-8'));
const pakeConfigPath = path.join(npmDirectory, 'src-tauri/pake.json'); const pakeConfigPath = path.join(npmDirectory, 'src-tauri/pake.json');
yield fs$1.writeFile(pakeConfigPath, Buffer.from(JSON.stringify(tauriConf.pake, null, 4), 'utf-8')); yield fs$1.writeFile(pakeConfigPath, Buffer.from(JSON.stringify(tauriConf.pake, null, 4), 'utf-8'));
logger.info("tauri config", JSON.stringify(tauriConf.build));
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf)); let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
delete tauriConf2.pake; delete tauriConf2.pake;
delete tauriConf2.tauri.bundle; delete tauriConf2.tauri.bundle;
@@ -2013,7 +2009,7 @@ function handleOptions(options, url) {
function shellExec(command) { function shellExec(command) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
shelljs.exec(command, { async: true, silent: false }, (code) => { shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory }, (code) => {
if (code === 0) { if (code === 0) {
resolve(0); resolve(0);
} }
@@ -2257,6 +2253,7 @@ var LinuxConf = {
let tauriConf = { let tauriConf = {
package: CommonConf.package, package: CommonConf.package,
tauri: CommonConf.tauri, tauri: CommonConf.tauri,
build: CommonConf.build,
pake: pakeConf pake: pakeConf
}; };
switch (process.platform) { switch (process.platform) {