@meng-xi/vite-plugin 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en.md +150 -0
- package/README.md +84 -138
- package/dist/common/index.cjs +1 -0
- package/dist/common/index.d.cts +109 -0
- package/dist/common/index.d.mts +109 -0
- package/dist/common/index.d.ts +109 -0
- package/dist/common/index.mjs +1 -0
- package/dist/factory/index.cjs +1 -0
- package/dist/factory/index.d.cts +260 -0
- package/dist/factory/index.d.mts +260 -0
- package/dist/factory/index.d.ts +260 -0
- package/dist/factory/index.mjs +1 -0
- package/dist/index.cjs +1 -3
- package/dist/index.d.cts +7 -282
- package/dist/index.d.mts +7 -282
- package/dist/index.d.ts +7 -282
- package/dist/index.mjs +1 -3
- package/dist/logger/index.cjs +1 -0
- package/dist/logger/index.d.cts +1 -0
- package/dist/logger/index.d.mts +1 -0
- package/dist/logger/index.d.ts +1 -0
- package/dist/logger/index.mjs +1 -0
- package/dist/plugins/index.cjs +1 -0
- package/dist/plugins/index.d.cts +210 -0
- package/dist/plugins/index.d.mts +210 -0
- package/dist/plugins/index.d.ts +210 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/shared/vite-plugin.B3PARlU9.d.cts +119 -0
- package/dist/shared/vite-plugin.B3PARlU9.d.mts +119 -0
- package/dist/shared/vite-plugin.B3PARlU9.d.ts +119 -0
- package/dist/shared/vite-plugin.BT1oHRKK.cjs +1 -0
- package/dist/shared/vite-plugin.BTKhc7n7.cjs +3 -0
- package/dist/shared/vite-plugin.BZqhBDYR.mjs +1 -0
- package/dist/shared/vite-plugin.Bn8mcCzy.cjs +3 -0
- package/dist/shared/vite-plugin.CY2ydccp.mjs +3 -0
- package/dist/shared/vite-plugin.CiHfwMiN.d.cts +91 -0
- package/dist/shared/vite-plugin.CiHfwMiN.d.mts +91 -0
- package/dist/shared/vite-plugin.CiHfwMiN.d.ts +91 -0
- package/dist/shared/vite-plugin.ClHiVXD6.mjs +1 -0
- package/dist/shared/vite-plugin.DSRKYuae.mjs +3 -0
- package/dist/shared/vite-plugin.DrSzERYS.cjs +1 -0
- package/dist/shared/vite-plugin.UkE7CdSe.d.cts +43 -0
- package/dist/shared/vite-plugin.UkE7CdSe.d.mts +43 -0
- package/dist/shared/vite-plugin.UkE7CdSe.d.ts +43 -0
- package/package.json +72 -57
- package/dist/plugins/copyFile/index.d.ts +0 -44
- package/dist/plugins/copyFile/index.mjs +0 -43
- package/dist/plugins/copyFile/type.d.ts +0 -47
- package/dist/plugins/copyFile/type.mjs +0 -0
- package/dist/plugins/injectIco/index.d.ts +0 -74
- package/dist/plugins/injectIco/index.mjs +0 -82
- package/dist/plugins/injectIco/type.d.ts +0 -115
- package/dist/plugins/injectIco/type.mjs +0 -0
package/README-en.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
**English** | [中文](./README.md)
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://github.com/MengXi-Studio/vite-plugin">
|
|
5
|
+
<img alt="梦曦工作室 Logo" width="215" src="https://github.com/MengXi-Studio/vite-plugin/blob/master/packages/docs/src/public/logo.svg">
|
|
6
|
+
</a>
|
|
7
|
+
<br>
|
|
8
|
+
<h1>@meng-xi/vite-plugin</h1>
|
|
9
|
+
|
|
10
|
+
[](LICENSE) [](https://www.npmjs.com/package/@meng-xi/vite-plugin)
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
> - This is a toolkit that provides practical plugins for Vite, helping developers simplify the build process and improve development efficiency.
|
|
16
|
+
> - Extends Vite build process functionality, providing automated processing solutions for common build tasks.
|
|
17
|
+
> - All plugins support detailed configuration options, allowing customization based on project needs to meet different usage scenarios.
|
|
18
|
+
> - Plugins provide error handling mechanisms to ensure build processes can catch errors, improving build reliability.
|
|
19
|
+
> - Adopts modular design, plugins can be used individually or in combination, flexibly responding to different project needs.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
Start reading the [documentation](https://mengxi-studio.github.io/vite-plugin/).
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
29
|
+
Install `@meng-xi/vite-plugin` using a package manager:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Using npm
|
|
33
|
+
npm install @meng-xi/vite-plugin --save-dev
|
|
34
|
+
|
|
35
|
+
# Using yarn
|
|
36
|
+
yarn add @meng-xi/vite-plugin --save-dev
|
|
37
|
+
|
|
38
|
+
# Using pnpm
|
|
39
|
+
pnpm add @meng-xi/vite-plugin --save-dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Basic Usage
|
|
43
|
+
|
|
44
|
+
Import and use the plugins in your Vite configuration file:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { defineConfig } from 'vite'
|
|
48
|
+
import { copyFile, injectIco } from '@meng-xi/vite-plugin'
|
|
49
|
+
|
|
50
|
+
export default defineConfig({
|
|
51
|
+
plugins: [
|
|
52
|
+
// Copy file plugin
|
|
53
|
+
copyFile({
|
|
54
|
+
sourceDir: 'src/assets',
|
|
55
|
+
targetDir: 'dist/assets'
|
|
56
|
+
}),
|
|
57
|
+
|
|
58
|
+
// Inject icon plugin
|
|
59
|
+
injectIco({
|
|
60
|
+
base: '/assets'
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Import All
|
|
67
|
+
|
|
68
|
+
You can also use default import to import all plugins:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { defineConfig } from 'vite'
|
|
72
|
+
import vitePlugin from '@meng-xi/vite-plugin'
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [
|
|
76
|
+
// Copy file plugin
|
|
77
|
+
vitePlugin.copyFile({
|
|
78
|
+
sourceDir: 'src/assets',
|
|
79
|
+
targetDir: 'dist/assets'
|
|
80
|
+
}),
|
|
81
|
+
|
|
82
|
+
// Inject icon plugin
|
|
83
|
+
vitePlugin.injectIco({
|
|
84
|
+
base: '/assets'
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Plugin Details
|
|
91
|
+
|
|
92
|
+
### copyFile Plugin
|
|
93
|
+
|
|
94
|
+
Used to copy files or directories to specified locations after Vite build is completed.
|
|
95
|
+
|
|
96
|
+
**Configuration Options**:
|
|
97
|
+
|
|
98
|
+
- `sourceDir`: Source directory path (required)
|
|
99
|
+
- `targetDir`: Target directory path (required)
|
|
100
|
+
- `overwrite`: Whether to overwrite existing files, default is `true`
|
|
101
|
+
- `recursive`: Whether to recursively copy subdirectories, default is `true`
|
|
102
|
+
- `verbose`: Whether to output detailed logs, default is `true`
|
|
103
|
+
- `enabled`: Whether to enable the plugin, default is `true`
|
|
104
|
+
|
|
105
|
+
### injectIco Plugin
|
|
106
|
+
|
|
107
|
+
Used to inject website icon links into the head of HTML files during the Vite build process.
|
|
108
|
+
|
|
109
|
+
**Configuration Options**:
|
|
110
|
+
|
|
111
|
+
- `base`: Base path for icon files
|
|
112
|
+
- `url`: Complete URL for the icon
|
|
113
|
+
- `link`: Custom complete link tag HTML
|
|
114
|
+
- `icons`: Custom icon array
|
|
115
|
+
- `verbose`: Whether to output detailed logs, default is `true`
|
|
116
|
+
- `enabled`: Whether to enable the plugin, default is `true`
|
|
117
|
+
- `copyOptions`: Icon file copying configuration
|
|
118
|
+
|
|
119
|
+
## Contribution
|
|
120
|
+
|
|
121
|
+
Welcome to contribute to `@meng-xi/vite-plugin`. Here are the steps to contribute code:
|
|
122
|
+
|
|
123
|
+
1. Fork the project: Fork this project on GitHub.
|
|
124
|
+
2. Clone the code: Clone the forked project to your local machine.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/your-username/vite-plugin.git
|
|
128
|
+
cd vite-plugin
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
3. Create a new branch: Create a new feature branch based on the `master` branch.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git checkout -b feature/your-feature
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
4. Commit changes: Ensure your code passes tests and commit your changes with clear commit messages.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
git add .
|
|
141
|
+
git commit -m "feat: add your feature description"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
5. Push changes: Push your local branch to GitHub.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git push origin feature/your-feature
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
6. Create a PR: Create a Pull Request on GitHub and wait for review.
|
package/README.md
CHANGED
|
@@ -1,138 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
>
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
- `sourceDir`:源目录路径(必填)
|
|
87
|
-
- `targetDir`:目标目录路径(必填)
|
|
88
|
-
- `overwrite`:是否覆盖已存在的文件,默认为 `true`
|
|
89
|
-
- `recursive`:是否递归复制子目录,默认为 `true`
|
|
90
|
-
- `verbose`:是否输出详细日志,默认为 `true`
|
|
91
|
-
- `enabled`:是否启用插件,默认为 `true`
|
|
92
|
-
|
|
93
|
-
### injectIco 插件
|
|
94
|
-
|
|
95
|
-
用于在 Vite 构建过程中注入网站图标链接到 HTML 文件的头部。
|
|
96
|
-
|
|
97
|
-
**配置选项**:
|
|
98
|
-
|
|
99
|
-
- `base`:图标文件的基础路径
|
|
100
|
-
- `url`:图标的完整 URL
|
|
101
|
-
- `link`:自定义的完整 link 标签 HTML
|
|
102
|
-
- `icons`:自定义图标数组
|
|
103
|
-
- `verbose`:是否输出详细日志,默认为 `true`
|
|
104
|
-
- `enabled`:是否启用插件,默认为 `true`
|
|
105
|
-
- `copyOptions`:图标文件复制配置
|
|
106
|
-
|
|
107
|
-
## 贡献
|
|
108
|
-
|
|
109
|
-
欢迎为 `@meng-xi/vite-plugin` 贡献代码。以下是贡献代码的步骤:
|
|
110
|
-
|
|
111
|
-
1. Fork 项目:在 GitHub 上 Fork 此项目。
|
|
112
|
-
2. 克隆代码:将 Fork 后的项目克隆到您的本地机器。
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
git clone https://github.com/your-username/vite-plugin.git
|
|
116
|
-
cd vite-plugin
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
3. 创建新分支:基于 `master` 分支创建一个新的功能分支。
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
git checkout -b feature/your-feature
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
4. 提交变更:确保您的代码通过了测试,并使用清晰的提交消息提交您的变更。
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
git add .
|
|
129
|
-
git commit -m "feat: add your feature description"
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
5. Push 变更:将您的本地分支推送到 GitHub。
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
git push origin feature/your-feature
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
6. 创建 PR:在 GitHub 上创建一个 Pull Request,并等待审核。
|
|
1
|
+
**中文** | [English](./README-en.md)
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://github.com/MengXi-Studio/vite-plugin">
|
|
5
|
+
<img alt="梦曦工作室 Logo" width="215" src="https://github.com/MengXi-Studio/vite-plugin/blob/master/packages/docs/src/public/logo.svg">
|
|
6
|
+
</a>
|
|
7
|
+
<br>
|
|
8
|
+
<h1>@meng-xi/vite-plugin</h1>
|
|
9
|
+
|
|
10
|
+
[](LICENSE) [](https://www.npmjs.com/package/@meng-xi/vite-plugin)
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
## 简介
|
|
16
|
+
|
|
17
|
+
`@meng-xi/vite-plugin` 是一个为 Vite 提供实用插件的工具包,帮助开发者简化构建流程,提高开发效率。
|
|
18
|
+
|
|
19
|
+
## 特性
|
|
20
|
+
|
|
21
|
+
- **增强 Vite 构建流程**:提供实用插件集合,扩展 Vite 功能,简化构建过程中的常见任务,提高开发效率
|
|
22
|
+
- **模块化插件架构**:采用模块化设计,插件可单独使用或组合使用,灵活应对不同项目需求
|
|
23
|
+
- **高度可配置**:所有功能支持详细配置选项,可根据项目需求自定义行为,满足多样化场景
|
|
24
|
+
- **环境感知能力**:支持根据构建环境条件执行插件功能,智能控制不同环境下的行为
|
|
25
|
+
- **详细日志输出**:提供可选的详细日志,帮助开发者了解执行过程,便于调试和问题排查
|
|
26
|
+
- **类型安全**:完全使用 TypeScript 开发,提供完整类型定义,确保使用过程中的类型安全
|
|
27
|
+
- **无缝集成**:与 Vite 构建流程无缝集成,无需复杂配置即可快速启用
|
|
28
|
+
- **优化开发体验**:简化常见构建任务,减少手动操作,让开发者专注于核心业务逻辑
|
|
29
|
+
|
|
30
|
+
## 文档
|
|
31
|
+
|
|
32
|
+
开始阅读[文档地址](https://mengxi-studio.github.io/vite-plugin/)。
|
|
33
|
+
|
|
34
|
+
## 安装
|
|
35
|
+
|
|
36
|
+
使用包管理器安装 `@meng-xi/vite-plugin`:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# 使用 npm
|
|
40
|
+
npm install @meng-xi/vite-plugin --save-dev
|
|
41
|
+
|
|
42
|
+
# 使用 yarn
|
|
43
|
+
yarn add @meng-xi/vite-plugin --save-dev
|
|
44
|
+
|
|
45
|
+
# 使用 pnpm
|
|
46
|
+
pnpm add @meng-xi/vite-plugin --save-dev
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 更新日志
|
|
50
|
+
|
|
51
|
+
[CHANGELOG](https://github.com/MengXi-Studio/vite-plugin/releases)
|
|
52
|
+
|
|
53
|
+
## 如何贡献
|
|
54
|
+
|
|
55
|
+
欢迎为 `@meng-xi/vite-plugin` 贡献代码。以下是贡献代码的步骤:
|
|
56
|
+
|
|
57
|
+
1. Fork 项目:在 GitHub 上 Fork 此项目。
|
|
58
|
+
2. 克隆代码:将 Fork 后的项目克隆到您的本地机器。
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/your-username/vite-plugin.git
|
|
62
|
+
cd vite-plugin
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
3. 创建新分支:基于 `master` 分支创建一个新的功能分支。
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git checkout -b feature/your-feature
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
4. 提交变更:确保您的代码通过了测试,并使用清晰的提交消息提交您的变更。
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git add .
|
|
75
|
+
git commit -m "feat: add your feature description"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
5. Push 变更:将您的本地分支推送到 GitHub。
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git push origin feature/your-feature
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
6. 创建 PR:在 GitHub 上创建一个 Pull Request,并等待审核。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const index=require("../shared/vite-plugin.DrSzERYS.cjs"),validation=require("../shared/vite-plugin.BTKhc7n7.cjs");require("fs"),require("path"),exports.checkSourceExists=index.checkSourceExists,exports.copySourceToTarget=index.copySourceToTarget,exports.ensureTargetDir=index.ensureTargetDir,exports.readDirRecursive=index.readDirRecursive,exports.readFileSync=index.readFileSync,exports.shouldUpdateFile=index.shouldUpdateFile,exports.writeFileContent=index.writeFileContent,exports.Validator=validation.Validator,exports.deepMerge=validation.deepMerge;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export { V as Validator } from '../shared/vite-plugin.CiHfwMiN.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 复制操作的选项接口
|
|
5
|
+
*/
|
|
6
|
+
interface CopyOptions {
|
|
7
|
+
/**
|
|
8
|
+
* 是否支持递归复制
|
|
9
|
+
*/
|
|
10
|
+
recursive: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 是否覆盖同名文件
|
|
13
|
+
*/
|
|
14
|
+
overwrite: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 是否启用增量复制
|
|
17
|
+
*/
|
|
18
|
+
incremental?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 并行处理的最大文件数
|
|
21
|
+
*/
|
|
22
|
+
parallelLimit?: number;
|
|
23
|
+
/**
|
|
24
|
+
* 是否跳过空目录
|
|
25
|
+
*/
|
|
26
|
+
skipEmptyDirs?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 复制结果接口
|
|
30
|
+
*/
|
|
31
|
+
interface CopyResult {
|
|
32
|
+
/**
|
|
33
|
+
* 复制的文件数量
|
|
34
|
+
*/
|
|
35
|
+
copiedFiles: number;
|
|
36
|
+
/**
|
|
37
|
+
* 跳过的文件数量
|
|
38
|
+
*/
|
|
39
|
+
skippedFiles: number;
|
|
40
|
+
/**
|
|
41
|
+
* 复制的目录数量
|
|
42
|
+
*/
|
|
43
|
+
copiedDirs: number;
|
|
44
|
+
/**
|
|
45
|
+
* 总执行时间(毫秒)
|
|
46
|
+
*/
|
|
47
|
+
executionTime: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 检查源文件是否存在
|
|
52
|
+
* @param sourcePath 源文件路径
|
|
53
|
+
* @throws 当源文件不存在或无法访问时抛出异常
|
|
54
|
+
*/
|
|
55
|
+
declare function checkSourceExists(sourcePath: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* 创建目标目录
|
|
58
|
+
* @param targetPath 目标目录路径
|
|
59
|
+
* @throws 当无法创建目标目录时抛出异常
|
|
60
|
+
*/
|
|
61
|
+
declare function ensureTargetDir(targetPath: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* 读取目录内容
|
|
64
|
+
* @param dirPath 目录路径
|
|
65
|
+
* @param recursive 是否递归读取
|
|
66
|
+
* @returns 文件和目录列表
|
|
67
|
+
*/
|
|
68
|
+
declare function readDirRecursive(dirPath: string, recursive: boolean): Promise<string[]>;
|
|
69
|
+
/**
|
|
70
|
+
* 检查文件是否需要更新
|
|
71
|
+
* @param sourceFile 源文件路径
|
|
72
|
+
* @param targetFile 目标文件路径
|
|
73
|
+
* @returns 是否需要更新
|
|
74
|
+
*/
|
|
75
|
+
declare function shouldUpdateFile(sourceFile: string, targetFile: string): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* 执行文件复制操作
|
|
78
|
+
* @param sourcePath 源文件或目录路径
|
|
79
|
+
* @param targetPath 目标文件或目录路径
|
|
80
|
+
* @param options 复制选项
|
|
81
|
+
* @returns 复制结果
|
|
82
|
+
* @throws 当复制过程中出现错误时抛出异常
|
|
83
|
+
*/
|
|
84
|
+
declare function copySourceToTarget(sourcePath: string, targetPath: string, options: CopyOptions): Promise<CopyResult>;
|
|
85
|
+
/**
|
|
86
|
+
* 写入文件内容
|
|
87
|
+
* @param filePath 文件路径
|
|
88
|
+
* @param content 文件内容
|
|
89
|
+
* @throws 当写入过程中出现错误时抛出异常
|
|
90
|
+
*/
|
|
91
|
+
declare function writeFileContent(filePath: string, content: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* 同步读取文件内容
|
|
94
|
+
* @param filePath 文件路径
|
|
95
|
+
* @returns 文件内容字符串
|
|
96
|
+
* @throws 当读取过程中出现错误时抛出异常
|
|
97
|
+
*/
|
|
98
|
+
declare function readFileSync(filePath: string): string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 深度合并对象
|
|
102
|
+
*
|
|
103
|
+
* @param target 目标对象
|
|
104
|
+
* @param sources 源对象列表
|
|
105
|
+
* @returns 合并后的对象
|
|
106
|
+
*/
|
|
107
|
+
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
108
|
+
|
|
109
|
+
export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export { V as Validator } from '../shared/vite-plugin.CiHfwMiN.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 复制操作的选项接口
|
|
5
|
+
*/
|
|
6
|
+
interface CopyOptions {
|
|
7
|
+
/**
|
|
8
|
+
* 是否支持递归复制
|
|
9
|
+
*/
|
|
10
|
+
recursive: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 是否覆盖同名文件
|
|
13
|
+
*/
|
|
14
|
+
overwrite: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 是否启用增量复制
|
|
17
|
+
*/
|
|
18
|
+
incremental?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 并行处理的最大文件数
|
|
21
|
+
*/
|
|
22
|
+
parallelLimit?: number;
|
|
23
|
+
/**
|
|
24
|
+
* 是否跳过空目录
|
|
25
|
+
*/
|
|
26
|
+
skipEmptyDirs?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 复制结果接口
|
|
30
|
+
*/
|
|
31
|
+
interface CopyResult {
|
|
32
|
+
/**
|
|
33
|
+
* 复制的文件数量
|
|
34
|
+
*/
|
|
35
|
+
copiedFiles: number;
|
|
36
|
+
/**
|
|
37
|
+
* 跳过的文件数量
|
|
38
|
+
*/
|
|
39
|
+
skippedFiles: number;
|
|
40
|
+
/**
|
|
41
|
+
* 复制的目录数量
|
|
42
|
+
*/
|
|
43
|
+
copiedDirs: number;
|
|
44
|
+
/**
|
|
45
|
+
* 总执行时间(毫秒)
|
|
46
|
+
*/
|
|
47
|
+
executionTime: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 检查源文件是否存在
|
|
52
|
+
* @param sourcePath 源文件路径
|
|
53
|
+
* @throws 当源文件不存在或无法访问时抛出异常
|
|
54
|
+
*/
|
|
55
|
+
declare function checkSourceExists(sourcePath: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* 创建目标目录
|
|
58
|
+
* @param targetPath 目标目录路径
|
|
59
|
+
* @throws 当无法创建目标目录时抛出异常
|
|
60
|
+
*/
|
|
61
|
+
declare function ensureTargetDir(targetPath: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* 读取目录内容
|
|
64
|
+
* @param dirPath 目录路径
|
|
65
|
+
* @param recursive 是否递归读取
|
|
66
|
+
* @returns 文件和目录列表
|
|
67
|
+
*/
|
|
68
|
+
declare function readDirRecursive(dirPath: string, recursive: boolean): Promise<string[]>;
|
|
69
|
+
/**
|
|
70
|
+
* 检查文件是否需要更新
|
|
71
|
+
* @param sourceFile 源文件路径
|
|
72
|
+
* @param targetFile 目标文件路径
|
|
73
|
+
* @returns 是否需要更新
|
|
74
|
+
*/
|
|
75
|
+
declare function shouldUpdateFile(sourceFile: string, targetFile: string): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* 执行文件复制操作
|
|
78
|
+
* @param sourcePath 源文件或目录路径
|
|
79
|
+
* @param targetPath 目标文件或目录路径
|
|
80
|
+
* @param options 复制选项
|
|
81
|
+
* @returns 复制结果
|
|
82
|
+
* @throws 当复制过程中出现错误时抛出异常
|
|
83
|
+
*/
|
|
84
|
+
declare function copySourceToTarget(sourcePath: string, targetPath: string, options: CopyOptions): Promise<CopyResult>;
|
|
85
|
+
/**
|
|
86
|
+
* 写入文件内容
|
|
87
|
+
* @param filePath 文件路径
|
|
88
|
+
* @param content 文件内容
|
|
89
|
+
* @throws 当写入过程中出现错误时抛出异常
|
|
90
|
+
*/
|
|
91
|
+
declare function writeFileContent(filePath: string, content: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* 同步读取文件内容
|
|
94
|
+
* @param filePath 文件路径
|
|
95
|
+
* @returns 文件内容字符串
|
|
96
|
+
* @throws 当读取过程中出现错误时抛出异常
|
|
97
|
+
*/
|
|
98
|
+
declare function readFileSync(filePath: string): string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 深度合并对象
|
|
102
|
+
*
|
|
103
|
+
* @param target 目标对象
|
|
104
|
+
* @param sources 源对象列表
|
|
105
|
+
* @returns 合并后的对象
|
|
106
|
+
*/
|
|
107
|
+
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
108
|
+
|
|
109
|
+
export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent };
|