增加递归拷贝功能
This commit is contained in:
9
bin/README.md
vendored
9
bin/README.md
vendored
@@ -119,4 +119,13 @@ url 为你需要打包的网页链接 🔗或者本地html文件,必须提供
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
--system-tray-icon <value>
|
--system-tray-icon <value>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### [copy-iter-file]
|
||||||
|
|
||||||
|
递归拷贝,当url为本地文件路径时候,若开启该选项,则将url路径文件所在文件夹以及所有子文件都拷贝到pake静态文件夹,默认不开启
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--copy-iter-file
|
||||||
```
|
```
|
||||||
9
bin/README_EN.md
vendored
9
bin/README_EN.md
vendored
@@ -119,3 +119,12 @@ The notification tray icon is only valid when the notification tray is displayed
|
|||||||
```shell
|
```shell
|
||||||
--system-tray-icon <value>
|
--system-tray-icon <value>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### [copy-iter-file]
|
||||||
|
|
||||||
|
Recursive copy, when the url is a local file path, if this option is enabled, the folder where the url path file is located and all sub-files are copied to the pake static folder, which is not enabled by default
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--copy-iter-file
|
||||||
|
```
|
||||||
|
|||||||
34
bin/builders/common.ts
vendored
34
bin/builders/common.ts
vendored
@@ -2,9 +2,11 @@ import { PakeAppOptions } from '@/types.js';
|
|||||||
import prompts from 'prompts';
|
import prompts from 'prompts';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
|
import fs2 from 'fs-extra';
|
||||||
import { npmDirectory } from '@/utils/dir.js';
|
import { npmDirectory } from '@/utils/dir.js';
|
||||||
import logger from '@/options/logger.js';
|
import logger from '@/options/logger.js';
|
||||||
|
|
||||||
|
|
||||||
export async function promptText(message: string, initial?: string) {
|
export async function promptText(message: string, initial?: string) {
|
||||||
const response = await prompts({
|
const response = await prompts({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -31,7 +33,7 @@ export async function mergeTauriConfig(
|
|||||||
showMenu,
|
showMenu,
|
||||||
showSystemTray,
|
showSystemTray,
|
||||||
systemTrayIcon,
|
systemTrayIcon,
|
||||||
// iter_copy_file,
|
iterCopyFile,
|
||||||
identifier,
|
identifier,
|
||||||
name,
|
name,
|
||||||
} = options;
|
} = options;
|
||||||
@@ -65,16 +67,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 });
|
||||||
// 判断一下url类型,是文件还是网站
|
// 判断一下url类型,是文件还是网站
|
||||||
// 如果是文件,则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下(待做)
|
// 如果是文件,并且开启了递归拷贝功能,则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下,否则只拷贝单个文件。
|
||||||
|
|
||||||
// const src_exists = await fs.stat("src")
|
|
||||||
// .then(() => true)
|
|
||||||
// .catch(() => false);
|
|
||||||
// if (!src_exists) {
|
|
||||||
// fs.mkdir("src")
|
|
||||||
// } else {
|
|
||||||
// fs.rm
|
|
||||||
// }
|
|
||||||
const url_exists = await fs.stat(url)
|
const url_exists = await fs.stat(url)
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
@@ -82,9 +76,23 @@ export async function mergeTauriConfig(
|
|||||||
logger.warn("you input may a local file");
|
logger.warn("you input may a local file");
|
||||||
tauriConf.pake.windows[0].url_type = "local";
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
const file_name = path.basename(url);
|
const file_name = path.basename(url);
|
||||||
// const dir_name = path.dirname(url);
|
const dir_name = path.dirname(url);
|
||||||
const url_path = path.join(npmDirectory,"dist/", file_name);
|
if (!iterCopyFile) {
|
||||||
await fs.copyFile(url, url_path);
|
const url_path = path.join(npmDirectory,"dist/", file_name);
|
||||||
|
await fs.copyFile(url, url_path);
|
||||||
|
} else {
|
||||||
|
const old_dir = path.join(npmDirectory,"dist/");
|
||||||
|
const new_dir = path.join(npmDirectory,"dist_bak/");
|
||||||
|
fs.rename(old_dir, new_dir);
|
||||||
|
fs2.copy(dir_name, old_dir);
|
||||||
|
// 将dist_bak里面的cli.js和about_pake.html拷贝回去
|
||||||
|
const cli_path = path.join(new_dir, "cli.js")
|
||||||
|
const cli_path_target = path.join(old_dir, "cli.js")
|
||||||
|
const about_pake_path = path.join(new_dir, "about_pake.html");
|
||||||
|
const about_patk_path_target = path.join(new_dir, "about_pake.html")
|
||||||
|
fs.copyFile(cli_path, cli_path_target);
|
||||||
|
fs.copyFile(about_pake_path, about_patk_path_target);
|
||||||
|
}
|
||||||
tauriConf.pake.windows[0].url = file_name;
|
tauriConf.pake.windows[0].url = file_name;
|
||||||
tauriConf.pake.windows[0].url_type = "local";
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
6
bin/cli.ts
vendored
6
bin/cli.ts
vendored
@@ -27,13 +27,13 @@ program
|
|||||||
.option('--show-menu', 'show menu in app', DEFAULT_PAKE_OPTIONS.showMenu)
|
.option('--show-menu', 'show menu in app', DEFAULT_PAKE_OPTIONS.showMenu)
|
||||||
.option('--show-system-tray', 'show system tray in app', DEFAULT_PAKE_OPTIONS.showSystemTray)
|
.option('--show-system-tray', 'show system tray in app', DEFAULT_PAKE_OPTIONS.showSystemTray)
|
||||||
.option('--system-tray-icon <string>', 'custom system tray icon', DEFAULT_PAKE_OPTIONS.systemTrayIcon)
|
.option('--system-tray-icon <string>', 'custom system tray icon', DEFAULT_PAKE_OPTIONS.systemTrayIcon)
|
||||||
|
.option('--iter-copy-file',
|
||||||
|
'copy all static file to pake app when url is a local file',
|
||||||
|
DEFAULT_PAKE_OPTIONS.iterCopyFile)
|
||||||
.option(
|
.option(
|
||||||
'--targets <string>',
|
'--targets <string>',
|
||||||
'only for linux, default is "deb", option "appaimge" or "all"(deb & appimage)',
|
'only for linux, default is "deb", option "appaimge" or "all"(deb & appimage)',
|
||||||
DEFAULT_PAKE_OPTIONS.targets)
|
DEFAULT_PAKE_OPTIONS.targets)
|
||||||
// .option('--iter-copy-file',
|
|
||||||
// 'copy all static file to pake app when url is a static file',
|
|
||||||
// DEFAULT_PAKE_OPTIONS.iter_copy_file)
|
|
||||||
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
||||||
.action(async (url: string, options: PakeCliOptions) => {
|
.action(async (url: string, options: PakeCliOptions) => {
|
||||||
checkUpdateTips();
|
checkUpdateTips();
|
||||||
|
|||||||
2
bin/defaults.ts
vendored
2
bin/defaults.ts
vendored
@@ -11,7 +11,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
showMenu: false,
|
showMenu: false,
|
||||||
showSystemTray: false,
|
showSystemTray: false,
|
||||||
targets: 'deb',
|
targets: 'deb',
|
||||||
// iter_copy_file: false,
|
iterCopyFile: false,
|
||||||
systemTrayIcon: '',
|
systemTrayIcon: '',
|
||||||
debug: false,
|
debug: false,
|
||||||
};
|
};
|
||||||
|
|||||||
5
bin/types.ts
vendored
5
bin/types.ts
vendored
@@ -32,8 +32,9 @@ export interface PakeCliOptions {
|
|||||||
/** 托盘图标, Windows、Linux默认和应用图标共用一样的,MacOS需要提别提供, 格式为png或者ico */
|
/** 托盘图标, Windows、Linux默认和应用图标共用一样的,MacOS需要提别提供, 格式为png或者ico */
|
||||||
systemTrayIcon: string;
|
systemTrayIcon: string;
|
||||||
|
|
||||||
// /** 递归拷贝,当url为本地文件路径时候,将文件所在文件夹下面的所有子文件都拷贝到pake静态文件夹,默认不开启 */
|
// /** 递归拷贝,当url为本地文件路径时候,若开启该选项,则将url路径文件所在文件夹以及所有子文件都拷贝到pake静态文件夹,默认不开启 */
|
||||||
// iter_copy_file: false;
|
iterCopyFile: false;
|
||||||
|
|
||||||
// 包输出产物,对linux用户有效,默认为deb,可选appimage, 或者all(即同时输出deb和all);
|
// 包输出产物,对linux用户有效,默认为deb,可选appimage, 或者all(即同时输出deb和all);
|
||||||
targets: string;
|
targets: string;
|
||||||
|
|
||||||
|
|||||||
42
dist/cli.js
vendored
42
dist/cli.js
vendored
@@ -7,6 +7,7 @@ import fs from 'fs';
|
|||||||
import prompts from 'prompts';
|
import prompts from 'prompts';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs$1 from 'fs/promises';
|
import fs$1 from 'fs/promises';
|
||||||
|
import fs2 from 'fs-extra';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@@ -52,7 +53,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
|||||||
showMenu: false,
|
showMenu: false,
|
||||||
showSystemTray: false,
|
showSystemTray: false,
|
||||||
targets: 'deb',
|
targets: 'deb',
|
||||||
// iter_copy_file: false,
|
iterCopyFile: false,
|
||||||
systemTrayIcon: '',
|
systemTrayIcon: '',
|
||||||
debug: false,
|
debug: false,
|
||||||
};
|
};
|
||||||
@@ -1636,9 +1637,7 @@ function promptText(message, initial) {
|
|||||||
}
|
}
|
||||||
function mergeTauriConfig(url, options, tauriConf) {
|
function mergeTauriConfig(url, options, tauriConf) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { width, height, fullscreen, transparent, resizable, userAgent, showMenu, showSystemTray, systemTrayIcon,
|
const { width, height, fullscreen, transparent, resizable, userAgent, showMenu, showSystemTray, systemTrayIcon, iterCopyFile, identifier, name, } = options;
|
||||||
// iter_copy_file,
|
|
||||||
identifier, name, } = options;
|
|
||||||
const tauriConfWindowOptions = {
|
const tauriConfWindowOptions = {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@@ -1668,14 +1667,6 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|||||||
Object.assign(tauriConf.pake.windows[0], Object.assign({ url }, tauriConfWindowOptions));
|
Object.assign(tauriConf.pake.windows[0], Object.assign({ url }, tauriConfWindowOptions));
|
||||||
// 判断一下url类型,是文件还是网站
|
// 判断一下url类型,是文件还是网站
|
||||||
// 如果是文件,则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下(待做)
|
// 如果是文件,则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下(待做)
|
||||||
// const src_exists = await fs.stat("src")
|
|
||||||
// .then(() => true)
|
|
||||||
// .catch(() => false);
|
|
||||||
// if (!src_exists) {
|
|
||||||
// fs.mkdir("src")
|
|
||||||
// } else {
|
|
||||||
// fs.rm
|
|
||||||
// }
|
|
||||||
const url_exists = yield fs$1.stat(url)
|
const url_exists = yield fs$1.stat(url)
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
@@ -1683,9 +1674,24 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|||||||
logger.warn("you input may a local file");
|
logger.warn("you input may a local file");
|
||||||
tauriConf.pake.windows[0].url_type = "local";
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
const file_name = path.basename(url);
|
const file_name = path.basename(url);
|
||||||
// const dir_name = path.dirname(url);
|
const dir_name = path.dirname(url);
|
||||||
const url_path = path.join(npmDirectory, "dist/", file_name);
|
if (!iterCopyFile) {
|
||||||
yield fs$1.copyFile(url, url_path);
|
const url_path = path.join(npmDirectory, "dist/", file_name);
|
||||||
|
yield fs$1.copyFile(url, url_path);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const old_dir = path.join(npmDirectory, "dist/");
|
||||||
|
const new_dir = path.join(npmDirectory, "dist_bak/");
|
||||||
|
fs$1.rename(old_dir, new_dir);
|
||||||
|
fs2.copy(dir_name, old_dir);
|
||||||
|
// 将dist_bak里面的cli.js和about_pake.html拷贝回去
|
||||||
|
const cli_path = path.join(new_dir, "cli.js");
|
||||||
|
const cli_path_target = path.join(old_dir, "cli.js");
|
||||||
|
const about_pake_path = path.join(new_dir, "about_pake.html");
|
||||||
|
const about_patk_path_target = path.join(new_dir, "about_pake.html");
|
||||||
|
fs$1.copyFile(cli_path, cli_path_target);
|
||||||
|
fs$1.copyFile(about_pake_path, about_patk_path_target);
|
||||||
|
}
|
||||||
tauriConf.pake.windows[0].url = file_name;
|
tauriConf.pake.windows[0].url = file_name;
|
||||||
tauriConf.pake.windows[0].url_type = "local";
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
}
|
}
|
||||||
@@ -2454,6 +2460,7 @@ var dependencies = {
|
|||||||
chalk: "^5.1.2",
|
chalk: "^5.1.2",
|
||||||
commander: "^9.4.1",
|
commander: "^9.4.1",
|
||||||
"file-type": "^18.0.0",
|
"file-type": "^18.0.0",
|
||||||
|
"fs-extra": "^11.1.0",
|
||||||
"is-url": "^1.2.4",
|
"is-url": "^1.2.4",
|
||||||
loglevel: "^1.8.1",
|
loglevel: "^1.8.1",
|
||||||
ora: "^6.1.2",
|
ora: "^6.1.2",
|
||||||
@@ -2468,6 +2475,7 @@ var devDependencies = {
|
|||||||
"@rollup/plugin-json": "^5.0.1",
|
"@rollup/plugin-json": "^5.0.1",
|
||||||
"@rollup/plugin-terser": "^0.1.0",
|
"@rollup/plugin-terser": "^0.1.0",
|
||||||
"@rollup/plugin-typescript": "^9.0.2",
|
"@rollup/plugin-typescript": "^9.0.2",
|
||||||
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/is-url": "^1.2.30",
|
"@types/is-url": "^1.2.30",
|
||||||
"@types/page-icon": "^0.3.4",
|
"@types/page-icon": "^0.3.4",
|
||||||
"@types/prompts": "^2.4.1",
|
"@types/prompts": "^2.4.1",
|
||||||
@@ -2520,10 +2528,8 @@ program
|
|||||||
.option('--show-menu', 'show menu in app', DEFAULT_PAKE_OPTIONS.showMenu)
|
.option('--show-menu', 'show menu in app', DEFAULT_PAKE_OPTIONS.showMenu)
|
||||||
.option('--show-system-tray', 'show system tray in app', DEFAULT_PAKE_OPTIONS.showSystemTray)
|
.option('--show-system-tray', 'show system tray in app', DEFAULT_PAKE_OPTIONS.showSystemTray)
|
||||||
.option('--system-tray-icon <string>', 'custom system tray icon', DEFAULT_PAKE_OPTIONS.systemTrayIcon)
|
.option('--system-tray-icon <string>', 'custom system tray icon', DEFAULT_PAKE_OPTIONS.systemTrayIcon)
|
||||||
|
.option('--iter-copy-file', 'copy all static file to pake app when url is a local file', DEFAULT_PAKE_OPTIONS.iterCopyFile)
|
||||||
.option('--targets <string>', 'only for linux, default is "deb", option "appaimge" or "all"(deb & appimage)', DEFAULT_PAKE_OPTIONS.targets)
|
.option('--targets <string>', 'only for linux, default is "deb", option "appaimge" or "all"(deb & appimage)', DEFAULT_PAKE_OPTIONS.targets)
|
||||||
// .option('--iter-copy-file',
|
|
||||||
// 'copy all static file to pake app when url is a static file',
|
|
||||||
// DEFAULT_PAKE_OPTIONS.iter_copy_file)
|
|
||||||
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
||||||
.action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
|
.action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
checkUpdateTips();
|
checkUpdateTips();
|
||||||
|
|||||||
559
dist/index.html
vendored
559
dist/index.html
vendored
File diff suppressed because one or more lines are too long
@@ -52,6 +52,7 @@
|
|||||||
"chalk": "^5.1.2",
|
"chalk": "^5.1.2",
|
||||||
"commander": "^9.4.1",
|
"commander": "^9.4.1",
|
||||||
"file-type": "^18.0.0",
|
"file-type": "^18.0.0",
|
||||||
|
"fs-extra": "^11.1.0",
|
||||||
"is-url": "^1.2.4",
|
"is-url": "^1.2.4",
|
||||||
"loglevel": "^1.8.1",
|
"loglevel": "^1.8.1",
|
||||||
"ora": "^6.1.2",
|
"ora": "^6.1.2",
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
"@rollup/plugin-json": "^5.0.1",
|
"@rollup/plugin-json": "^5.0.1",
|
||||||
"@rollup/plugin-terser": "^0.1.0",
|
"@rollup/plugin-terser": "^0.1.0",
|
||||||
"@rollup/plugin-typescript": "^9.0.2",
|
"@rollup/plugin-typescript": "^9.0.2",
|
||||||
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/is-url": "^1.2.30",
|
"@types/is-url": "^1.2.30",
|
||||||
"@types/page-icon": "^0.3.4",
|
"@types/page-icon": "^0.3.4",
|
||||||
"@types/prompts": "^2.4.1",
|
"@types/prompts": "^2.4.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user