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