@esmx/core 3.0.0-rc.60 → 3.0.0-rc.63

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.
@@ -1,18 +1,18 @@
1
1
  import type { Esmx } from './core';
2
2
 
3
3
  /**
4
- * 软件包打包配置接口。
5
- * 用于将服务的构建产物打包成标准的 npm .tgz 格式软件包。
4
+ * Package configuration interface.
5
+ * Used to package build artifacts into standard npm .tgz format packages.
6
6
  *
7
- * 特点:
8
- * - **标准化**:使用 npm 标准的 .tgz 打包格式
9
- * - **完整性**:包含模块的源代码、类型声明和配置文件等所有必要文件
10
- * - **兼容性**:与 npm 生态系统完全兼容,支持标准的包管理工作流
7
+ * Features:
8
+ * - **Standardization**: Uses npm standard .tgz packaging format
9
+ * - **Completeness**: Contains all necessary files including module source code, type declarations, and configuration files
10
+ * - **Compatibility**: Fully compatible with npm ecosystem, supporting standard package management workflows
11
11
  *
12
- * 使用场景:
13
- * - 模块打包发布
14
- * - 版本发布管理
15
- * - CI/CD 流程集成
12
+ * Use Cases:
13
+ * - Module packaging and publishing
14
+ * - Version release management
15
+ * - CI/CD process integration
16
16
  *
17
17
  * @example
18
18
  * ```ts
@@ -21,7 +21,7 @@ import type { Esmx } from './core';
21
21
  *
22
22
  * export default {
23
23
  * modules: {
24
- * // 配置需要导出的模块
24
+ * // Configure modules to export
25
25
  * exports: [
26
26
  * 'root:src/components/button.vue',
27
27
  * 'root:src/utils/format.ts',
@@ -29,22 +29,22 @@ import type { Esmx } from './core';
29
29
  * 'pkg:vue-router'
30
30
  * ]
31
31
  * },
32
- * // 打包配置
32
+ * // Packaging configuration
33
33
  * pack: {
34
- * // 启用打包功能
34
+ * // Enable packaging functionality
35
35
  * enable: true,
36
36
  *
37
- * // 同时输出多个版本
37
+ * // Output multiple versions simultaneously
38
38
  * outputs: [
39
39
  * 'dist/versions/latest.tgz',
40
40
  * 'dist/versions/1.0.0.tgz'
41
41
  * ],
42
42
  *
43
- * // 自定义 package.json
43
+ * // Customize package.json
44
44
  * packageJson: async (esmx, pkg) => {
45
45
  * pkg.name = '@your-scope/your-app';
46
46
  * pkg.version = '1.0.0';
47
- * // 添加构建脚本
47
+ * // Add build scripts
48
48
  * pkg.scripts = {
49
49
  * "prepare": "npm run build",
50
50
  * "build": "npm run build:dts && npm run build:ssr",
@@ -54,21 +54,21 @@ import type { Esmx } from './core';
54
54
  * return pkg;
55
55
  * },
56
56
  *
57
- * // 打包前准备
57
+ * // Pre-packaging preparation
58
58
  * onBefore: async (esmx, pkg) => {
59
- * // 添加必要文件
60
- * await fs.writeFile('dist/README.md', '# Your App\n\n模块导出说明...');
61
- * // 执行类型检查
59
+ * // Add necessary files
60
+ * await fs.writeFile('dist/README.md', '# Your App\n\nModule export description...');
61
+ * // Execute type checking
62
62
  * await runTypeCheck();
63
63
  * },
64
64
  *
65
- * // 打包后处理
65
+ * // Post-packaging processing
66
66
  * onAfter: async (esmx, pkg, file) => {
67
- * // 发布到私有 npm 镜像源
67
+ * // Publish to private npm registry
68
68
  * await publishToRegistry(file, {
69
69
  * registry: 'https://npm.your-registry.com/'
70
70
  * });
71
- * // 或部署到静态服务器
71
+ * // Or deploy to static server
72
72
  * await uploadToServer(file, 'https://static.example.com/packages');
73
73
  * }
74
74
  * }
@@ -77,31 +77,31 @@ import type { Esmx } from './core';
77
77
  */
78
78
  export interface PackConfig {
79
79
  /**
80
- * 是否启用打包功能。
81
- * 启用后会将构建产物打包成标准的 npm .tgz 格式软件包。
80
+ * Whether to enable packaging functionality.
81
+ * When enabled, build artifacts will be packaged into standard npm .tgz format packages.
82
82
  * @default false
83
83
  */
84
84
  enable?: boolean;
85
85
 
86
86
  /**
87
- * 指定输出的软件包文件路径。
88
- * 支持以下配置方式:
89
- * - string: 单个输出路径,如 'dist/versions/my-app.tgz'
90
- * - string[]: 多个输出路径,用于同时生成多个版本
91
- * - boolean: true 时使用默认路径 'dist/client/versions/latest.tgz'
87
+ * Specify the output package file path.
88
+ * Supports the following configuration methods:
89
+ * - string: Single output path, e.g., 'dist/versions/my-app.tgz'
90
+ * - string[]: Multiple output paths for generating multiple versions simultaneously
91
+ * - boolean: When true, uses default path 'dist/client/versions/latest.tgz'
92
92
  *
93
93
  * @example
94
94
  * ```ts
95
- * // 单个输出
95
+ * // Single output
96
96
  * outputs: 'dist/app.tgz'
97
97
  *
98
- * // 多个版本
98
+ * // Multiple versions
99
99
  * outputs: [
100
100
  * 'dist/versions/latest.tgz',
101
101
  * 'dist/versions/1.0.0.tgz'
102
102
  * ]
103
103
  *
104
- * // 使用默认路径
104
+ * // Use default path
105
105
  * outputs: true
106
106
  * ```
107
107
  *
@@ -110,34 +110,34 @@ export interface PackConfig {
110
110
  outputs?: string | string[] | boolean;
111
111
 
112
112
  /**
113
- * package.json 处理函数。
114
- * 在打包前调用,用于自定义 package.json 的内容。
113
+ * package.json processing function.
114
+ * Called before packaging to customize the content of package.json.
115
115
  *
116
- * 常见用途:
117
- * - 修改包名和版本号
118
- * - 添加或更新依赖项
119
- * - 添加自定义字段
120
- * - 配置发布相关信息
116
+ * Common use cases:
117
+ * - Modify package name and version
118
+ * - Add or update dependencies
119
+ * - Add custom fields
120
+ * - Configure publishing related information
121
121
  *
122
- * @param esmx - Esmx 实例
123
- * @param pkgJson - 原始的 package.json 内容
124
- * @returns 处理后的 package.json 内容
122
+ * @param esmx - Esmx instance
123
+ * @param pkgJson - Original package.json content
124
+ * @returns Processed package.json content
125
125
  *
126
126
  * @example
127
127
  * ```ts
128
128
  * packageJson: async (esmx, pkg) => {
129
- * // 设置包信息
129
+ * // Set package information
130
130
  * pkg.name = 'my-app';
131
131
  * pkg.version = '1.0.0';
132
- * pkg.description = '我的应用';
132
+ * pkg.description = 'My Application';
133
133
  *
134
- * // 添加依赖
134
+ * // Add dependencies
135
135
  * pkg.dependencies = {
136
136
  * 'vue': '^3.0.0',
137
137
  * 'express': '^4.17.1'
138
138
  * };
139
139
  *
140
- * // 添加发布配置
140
+ * // Add publishing configuration
141
141
  * pkg.publishConfig = {
142
142
  * registry: 'https://registry.example.com'
143
143
  * };
@@ -152,29 +152,29 @@ export interface PackConfig {
152
152
  ) => Promise<Record<string, any>>;
153
153
 
154
154
  /**
155
- * 打包前的钩子函数。
156
- * 在生成 .tgz 文件之前调用,用于执行准备工作。
155
+ * Pre-packaging hook function.
156
+ * Called before generating .tgz file to execute preparation work.
157
157
  *
158
- * 常见用途:
159
- * - 添加额外的文件(READMELICENSE 等)
160
- * - 执行测试或构建验证
161
- * - 生成文档或元数据
162
- * - 清理临时文件
158
+ * Common use cases:
159
+ * - Add additional files (README, LICENSE, etc.)
160
+ * - Execute tests or build validation
161
+ * - Generate documentation or metadata
162
+ * - Clean up temporary files
163
163
  *
164
- * @param esmx - Esmx 实例
165
- * @param pkgJson - 处理后的 package.json 内容
164
+ * @param esmx - Esmx instance
165
+ * @param pkgJson - Processed package.json content
166
166
  *
167
167
  * @example
168
168
  * ```ts
169
169
  * onBefore: async (esmx, pkg) => {
170
- * // 添加文档
170
+ * // Add documentation
171
171
  * await fs.writeFile('dist/README.md', '# My App');
172
172
  * await fs.writeFile('dist/LICENSE', 'MIT License');
173
173
  *
174
- * // 执行测试
174
+ * // Execute tests
175
175
  * await runTests();
176
176
  *
177
- * // 生成文档
177
+ * // Generate documentation
178
178
  * await generateDocs();
179
179
  * }
180
180
  * ```
@@ -182,34 +182,34 @@ export interface PackConfig {
182
182
  onBefore?: (esmx: Esmx, pkgJson: Record<string, any>) => Promise<void>;
183
183
 
184
184
  /**
185
- * 打包后的钩子函数。
186
- * .tgz 文件生成后调用,用于处理打包产物。
185
+ * Post-packaging hook function.
186
+ * Called after .tgz file is generated to handle packaging artifacts.
187
187
  *
188
- * 常见用途:
189
- * - 发布到 npm 仓库(公共或私有)
190
- * - 上传到静态资源服务器
191
- * - 执行版本管理
192
- * - 触发 CI/CD 流程
188
+ * Common use cases:
189
+ * - Publish to npm registry (public or private)
190
+ * - Upload to static asset server
191
+ * - Execute version management
192
+ * - Trigger CI/CD processes
193
193
  *
194
- * @param esmx - Esmx 实例
195
- * @param pkgJson - 最终的 package.json 内容
196
- * @param file - 生成的 .tgz 文件内容
194
+ * @param esmx - Esmx instance
195
+ * @param pkgJson - Final package.json content
196
+ * @param file - Generated .tgz file content
197
197
  *
198
198
  * @example
199
199
  * ```ts
200
200
  * onAfter: async (esmx, pkg, file) => {
201
- * // 发布到 npm 私有仓库
201
+ * // Publish to npm private registry
202
202
  * await publishToRegistry(file, {
203
203
  * registry: 'https://registry.example.com'
204
204
  * });
205
205
  *
206
- * // 上传到静态资源服务器
206
+ * // Upload to static asset server
207
207
  * await uploadToServer(file, 'https://assets.example.com/packages');
208
208
  *
209
- * // 创建版本标签
209
+ * // Create version tag
210
210
  * await createGitTag(pkg.version);
211
211
  *
212
- * // 触发部署流程
212
+ * // Trigger deployment process
213
213
  * await triggerDeploy(pkg.version);
214
214
  * }
215
215
  * ```
@@ -222,34 +222,34 @@ export interface PackConfig {
222
222
  }
223
223
 
224
224
  /**
225
- * PackConfig 配置解析后的内部接口。
226
- * 将用户配置标准化,设置默认值,便于框架内部使用。
225
+ * Internal interface after PackConfig configuration is parsed.
226
+ * Standardizes user configuration, sets default values, for internal framework use.
227
227
  *
228
- * 主要处理:
229
- * - 确保所有可选字段都有默认值
230
- * - 统一输出路径格式
231
- * - 标准化回调函数
228
+ * Main processing:
229
+ * - Ensure all optional fields have default values
230
+ * - Unify output path format
231
+ * - Standardize callback functions
232
232
  */
233
233
  export interface ParsedPackConfig {
234
234
  /**
235
- * 是否启用打包功能。
236
- * 解析后总是有确定的布尔值。
235
+ * Whether to enable packaging functionality.
236
+ * Always has a definite boolean value after parsing.
237
237
  * @default false
238
238
  */
239
239
  enable: boolean;
240
240
 
241
241
  /**
242
- * 解析后的输出文件路径列表。
243
- * 将所有输出格式统一转换为字符串数组:
244
- * - 布尔值 true → ['dist/client/versions/latest.tgz']
245
- * - 字符串 → [输入的字符串]
246
- * - 字符串数组保持不变
242
+ * Parsed output file path list.
243
+ * Converts all output formats uniformly to string arrays:
244
+ * - Boolean true → ['dist/client/versions/latest.tgz']
245
+ * - String → [input string]
246
+ * - String array remains unchanged
247
247
  */
248
248
  outputs: string[];
249
249
 
250
250
  /**
251
- * 标准化的 package.json 处理函数。
252
- * 未配置时使用默认函数,保持原始内容不变。
251
+ * Standardized package.json processing function.
252
+ * Uses default function when not configured, keeping original content unchanged.
253
253
  */
254
254
  packageJson: (
255
255
  esmx: Esmx,
@@ -257,14 +257,14 @@ export interface ParsedPackConfig {
257
257
  ) => Promise<Record<string, any>>;
258
258
 
259
259
  /**
260
- * 标准化的打包前钩子函数。
261
- * 未配置时使用空函数。
260
+ * Standardized pre-packaging hook function.
261
+ * Uses empty function when not configured.
262
262
  */
263
263
  onBefore: (esmx: Esmx, pkgJson: Record<string, any>) => Promise<void>;
264
264
 
265
265
  /**
266
- * 标准化的打包后钩子函数。
267
- * 未配置时使用空函数。
266
+ * Standardized post-packaging hook function.
267
+ * Uses empty function when not configured.
268
268
  */
269
269
  onAfter: (
270
270
  esmx: Esmx,