@pisell/common 1.0.55 → 1.0.57

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/CHANGELOG.md CHANGED
@@ -1,428 +1,8 @@
1
1
  # @pisell/common
2
2
 
3
- ## 1.0.55
3
+ ## 1.0.57
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [dc0f1ef331]
8
- - @pisell/utils@1.0.54
9
-
10
- ## 1.0.54
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [130012734]
15
- - @pisell/utils@1.0.53
16
-
17
- ## 1.0.53
18
-
19
- ### Patch Changes
20
-
21
- - Updated dependencies [3c3397ee1]
22
- - @pisell/utils@1.0.52
23
-
24
- ## 1.0.52
25
-
26
- ### Patch Changes
27
-
28
- - Updated dependencies [7f75442c8]
29
- - @pisell/utils@1.0.51
30
-
31
- ## 3.0.12
32
-
33
- ### Patch Changes
34
-
35
- - Updated dependencies [734dcb08d]
36
- - @pisell/utils@3.0.1
37
-
38
- ## 3.0.10
39
-
40
- ### Patch Changes
41
-
42
- - Updated dependencies [f15c3be02]
43
- - @pisell/utils@1.0.44
44
-
45
- ## 3.0.9
46
-
47
- ### Patch Changes
48
-
49
- - Updated dependencies [2f57417ac]
50
- - @pisell/utils@1.0.43
51
-
52
- ## 3.0.8
53
-
54
- ## 1.0.51
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies [1dd3694e4]
59
- - @pisell/utils@1.0.50
60
-
61
- ## 1.0.50
62
-
63
- ### Patch Changes
64
-
65
- - Updated dependencies [d4e39d968]
66
- - @pisell/utils@1.0.49
67
-
68
- ## 1.0.49
69
-
70
- ### Patch Changes
71
-
72
- - Updated dependencies [4650ca88a]
73
- - @pisell/utils@1.0.48
74
-
75
- ## 1.0.48
76
-
77
- ### Patch Changes
78
-
79
- - Updated dependencies [3ca04e31c]
80
- - @pisell/utils@1.0.47
81
-
82
- ## 1.0.47
83
-
84
- ### Patch Changes
85
-
86
- - Updated dependencies [301a686d8]
87
- - @pisell/utils@1.0.46
88
-
89
- ## 1.0.46
90
-
91
- ### Patch Changes
92
-
93
- - Updated dependencies [6733b2d5c]
94
- - @pisell/utils@1.0.45
95
-
96
- ## 1.0.45
97
-
98
- ### Patch Changes
99
-
100
- - Updated dependencies [a09f3e360]
101
- - @pisell/utils@1.0.44
102
-
103
- ## 1.0.44
104
-
105
- ### Patch Changes
106
-
107
- - f4db8d9a3: build:增加上传代码前的包版本检查
108
-
109
- ## 1.0.43
110
-
111
- ### Patch Changes
112
-
113
- - 740ab6b52: s
114
-
115
- ## 1.0.42
116
-
117
- ### Patch Changes
118
-
119
- - Updated dependencies [6f57a4d88]
120
- - @pisell/utils@1.0.43
121
-
122
- ## 1.0.41
123
-
124
- ### Patch Changes
125
-
126
- - Updated dependencies [0267536f]
127
- - @pisell/utils@1.0.42
128
-
129
- ## 1.0.40
130
-
131
- ### Patch Changes
132
-
133
- - Updated dependencies [f3ed6fa4]
134
- - @pisell/utils@1.0.41
135
-
136
- ## 1.0.39
137
-
138
- ### Patch Changes
139
-
140
- - Updated dependencies [b848ae9a]
141
- - @pisell/utils@1.0.40
142
-
143
- ## 1.0.38
144
-
145
- ### Patch Changes
146
-
147
- - Updated dependencies [8640a624]
148
- - @pisell/utils@1.0.39
149
-
150
- ## 1.0.37
151
-
152
- ### Patch Changes
153
-
154
- - Updated dependencies [27cdd90e]
155
- - @pisell/utils@1.0.38
156
-
157
- ## 1.0.36
158
-
159
- ### Patch Changes
160
-
161
- - Updated dependencies [30136d51]
162
- - @pisell/utils@1.0.37
163
-
164
- ## 1.0.35
165
-
166
- ### Patch Changes
167
-
168
- - Updated dependencies [a694c37e]
169
- - @pisell/utils@1.0.36
170
-
171
- ## 1.0.34
172
-
173
- ### Patch Changes
174
-
175
- - Updated dependencies [11c9a831]
176
- - @pisell/utils@1.0.35
177
-
178
- ## 1.0.33
179
-
180
- ### Patch Changes
181
-
182
- - Updated dependencies [881303a5]
183
- - @pisell/utils@1.0.34
184
-
185
- ## 1.0.32
186
-
187
- ### Patch Changes
188
-
189
- - Updated dependencies [fb6b699f]
190
- - @pisell/utils@1.0.33
191
-
192
- ## 1.0.31
193
-
194
- ### Patch Changes
195
-
196
- - Updated dependencies [bf60f3ca]
197
- - @pisell/utils@1.0.32
198
-
199
- ## 1.0.30
200
-
201
- ### Patch Changes
202
-
203
- - Updated dependencies [f7f80d68]
204
- - @pisell/utils@1.0.31
205
-
206
- ## 1.0.29
207
-
208
- ### Patch Changes
209
-
210
- - Updated dependencies [d41cf764]
211
- - @pisell/utils@1.0.30
212
-
213
- ## 1.0.28
214
-
215
- ### Patch Changes
216
-
217
- - Updated dependencies [f10f984b]
218
- - @pisell/utils@1.0.29
219
-
220
- ## 1.0.27
221
-
222
- ### Patch Changes
223
-
224
- - Updated dependencies [1d22e943]
225
- - @pisell/utils@1.0.28
226
-
227
- ## 1.0.26
228
-
229
- ### Patch Changes
230
-
231
- - Updated dependencies [a45e6cd5]
232
- - @pisell/utils@1.0.27
233
-
234
- ## 1.0.25
235
-
236
- ### Patch Changes
237
-
238
- - Updated dependencies [961d44f7]
239
- - @pisell/utils@1.0.26
240
-
241
- ## 1.0.24
242
-
243
- ### Patch Changes
244
-
245
- - Updated dependencies [10083f21]
246
- - @pisell/utils@1.0.25
247
-
248
- ## 1.0.26
249
-
250
- ### Patch Changes
251
-
252
- - Updated dependencies [8dc07315]
253
- - Updated dependencies [678cac4f]
254
- - @pisell/utils@1.0.29
255
-
256
- ## 1.0.25
257
-
258
- ### Patch Changes
259
-
260
- - Updated dependencies [532f075e]
261
- - @pisell/utils@1.0.28
262
-
263
- ## 1.0.24
264
-
265
- ### Patch Changes
266
-
267
- - Updated dependencies [77f985d0]
268
- - @pisell/utils@1.0.25
269
-
270
- ## 1.0.23
271
-
272
- ### Patch Changes
273
-
274
- - Updated dependencies [315258e3]
275
- - @pisell/utils@1.0.24
276
-
277
- ## 1.0.22
278
-
279
- ### Patch Changes
280
-
281
- - Updated dependencies [fdc8fae]
282
- - @pisell/utils@1.0.23
283
-
284
- ## 1.0.21
285
-
286
- ### Patch Changes
287
-
288
- - Updated dependencies [bbd6503]
289
- - @pisell/utils@1.0.22
290
-
291
- ## 1.0.20
292
-
293
- ### Patch Changes
294
-
295
- - Updated dependencies [d000328]
296
- - @pisell/utils@1.0.21
297
-
298
- ## 1.0.19
299
-
300
- ### Patch Changes
301
-
302
- - Updated dependencies [b879dad]
303
- - @pisell/utils@1.0.20
304
-
305
- ## 1.0.18
306
-
307
- ### Patch Changes
308
-
309
- - Updated dependencies [67d2110]
310
- - @pisell/utils@1.0.19
311
-
312
- ## 1.0.17
313
-
314
- ### Patch Changes
315
-
316
- - Updated dependencies [770c6cb]
317
- - @pisell/utils@1.0.18
318
-
319
- ## 1.0.16
320
-
321
- ### Patch Changes
322
-
323
- - Updated dependencies [443a959]
324
- - @pisell/utils@1.0.17
325
-
326
- ## 1.0.15
327
-
328
- ### Patch Changes
329
-
330
- - Updated dependencies [32fd732]
331
- - @pisell/utils@1.0.16
332
-
333
- ## 1.0.14
334
-
335
- ### Patch Changes
336
-
337
- - Updated dependencies [0f0601e]
338
- - @pisell/utils@1.0.15
339
-
340
- ## 1.0.13
341
-
342
- ### Patch Changes
343
-
344
- - Updated dependencies [bf50fb5]
345
- - @pisell/utils@1.0.14
346
-
347
- ## 1.0.12
348
-
349
- ### Patch Changes
350
-
351
- - Updated dependencies [b41ebaf]
352
- - @pisell/utils@1.0.13
353
-
354
- ## 1.0.11
355
-
356
- ### Patch Changes
357
-
358
- - Updated dependencies [e1a659c]
359
- - @pisell/utils@1.0.12
360
-
361
- ## 1.0.10
362
-
363
- ### Patch Changes
364
-
365
- - Updated dependencies [64ce1de]
366
- - @pisell/utils@1.0.11
367
-
368
- ## 1.0.9
369
-
370
- ### Patch Changes
371
-
372
- - Updated dependencies [eef8cdb]
373
- - @pisell/utils@1.0.10
374
-
375
- ## 1.0.8
376
-
377
- ### Patch Changes
378
-
379
- - Updated dependencies [ab61ee2]
380
- - @pisell/utils@1.0.9
381
-
382
- ## 1.0.7
383
-
384
- ### Patch Changes
385
-
386
- - Updated dependencies [88d5ebc]
387
- - @pisell/utils@1.0.8
388
-
389
- ## 1.0.6
390
-
391
- ### Patch Changes
392
-
393
- - Updated dependencies [abf14c2]
394
- - @pisell/utils@1.0.7
395
-
396
- ## 1.0.5
397
-
398
- ### Patch Changes
399
-
400
- - Updated dependencies [179b7e0]
401
- - @pisell/utils@1.0.6
402
-
403
- ## 1.0.4
404
-
405
- ### Patch Changes
406
-
407
- - Updated dependencies [1bd9790]
408
- - @pisell/utils@1.0.5
409
-
410
- ## 1.0.3
411
-
412
- ### Patch Changes
413
-
414
- - Updated dependencies
415
- - @pisell/utils@1.0.3
416
-
417
- ## 1.0.2
418
-
419
- ### Patch Changes
420
-
421
- - Updated dependencies
422
- - @pisell/utils@1.0.2
423
-
424
- ## 1.0.1
425
-
426
- ### Patch Changes
427
-
428
- - 测试更新包
7
+ - Updated dependencies [e99e4ea03]
8
+ - @pisell/utils@1.0.56
package/es/bin/pisell.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import("../../es/script/index.js");
2
+ import("../script/index.js");
@@ -48,6 +48,11 @@ var outPathMap = {
48
48
  prod: '../data/release/project/saas_home',
49
49
  release: '../data/release/project/saas_home',
50
50
  pre: '../data/release/project/saas_home'
51
+ },
52
+ docs: {
53
+ prod: '../data/release/project/docs',
54
+ release: '../data/release/project/docs',
55
+ pre: '../data/release/project/docs'
51
56
  }
52
57
  };
53
58
  var isSsrMap = {
@@ -56,6 +61,7 @@ var isSsrMap = {
56
61
  my_pisel_pc_v2: true,
57
62
  my_pisel_h5_v2: true,
58
63
  xzero: false,
64
+ docs: false,
59
65
  saas_admin: false,
60
66
  saas_shop: false,
61
67
  saas_kds: false,
@@ -173,7 +173,7 @@ function _init() {
173
173
  if (_fileName === 'admin') {
174
174
  _fileName = 'my_pisell_v2';
175
175
  }
176
- if (['xzero', 'saas_admin', 'saas_shop', 'saas_kds', 'saas_ads', 'saas_home'].includes(_fileName)) {
176
+ if (['xzero', 'docs', 'saas_admin', 'saas_shop', 'saas_kds', 'saas_ads', 'saas_home'].includes(_fileName)) {
177
177
  _context.next = 42;
178
178
  break;
179
179
  }
@@ -125,7 +125,7 @@ var UploadCode = /*#__PURE__*/function () {
125
125
  }
126
126
 
127
127
  // pisell2.0正式环境使用亚马逊服务器
128
- if (this.env === 'prod' && this.projectName === 'admin') {
128
+ if (this.env === 'prod' && ['admin', 'docs'].includes(this.projectName)) {
129
129
  serverConfig = serverConfigMap.aws.service[this.env];
130
130
  serverConfig.privateKey = fs.readFileSync('../../../pem/pisell-pro.pem');
131
131
  }
@@ -73,7 +73,7 @@ var getGitCurrentBranch = /*#__PURE__*/function () {
73
73
  * monorepo项目名称
74
74
  * @type {string[]}
75
75
  */
76
- var monorepoProjectNameArr = ['admin', 'my_pisell_v2'];
76
+ var monorepoProjectNameArr = ['admin', 'my_pisell_v2', 'docs'];
77
77
 
78
78
  /**
79
79
  * @Title: 获取本地lm_config.json配置信息
package/lib/bin/pisell.js CHANGED
@@ -23,4 +23,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  ));
24
24
 
25
25
  // src/bin/pisell.js
26
- import("../../es/script/index.js");
26
+ import("../script/index.js");
@@ -74,6 +74,11 @@ var outPathMap = {
74
74
  prod: "../data/release/project/saas_home",
75
75
  release: "../data/release/project/saas_home",
76
76
  pre: "../data/release/project/saas_home"
77
+ },
78
+ docs: {
79
+ prod: "../data/release/project/docs",
80
+ release: "../data/release/project/docs",
81
+ pre: "../data/release/project/docs"
77
82
  }
78
83
  };
79
84
  var isSsrMap = {
@@ -82,6 +87,7 @@ var isSsrMap = {
82
87
  my_pisel_pc_v2: true,
83
88
  my_pisel_h5_v2: true,
84
89
  xzero: false,
90
+ docs: false,
85
91
  saas_admin: false,
86
92
  saas_shop: false,
87
93
  saas_kds: false,
@@ -153,9 +153,15 @@ async function init() {
153
153
  if (_fileName === "admin") {
154
154
  _fileName = "my_pisell_v2";
155
155
  }
156
- if (!["xzero", "saas_admin", "saas_shop", "saas_kds", "saas_ads", "saas_home"].includes(
157
- _fileName
158
- )) {
156
+ if (![
157
+ "xzero",
158
+ "docs",
159
+ "saas_admin",
160
+ "saas_shop",
161
+ "saas_kds",
162
+ "saas_ads",
163
+ "saas_home"
164
+ ].includes(_fileName)) {
159
165
  await (0, import_aws.uploadStaticToOSS)(_fileName);
160
166
  }
161
167
  }
@@ -90,13 +90,18 @@ var UploadCode = class {
90
90
  if (this.env === "prod") {
91
91
  serverConfig = this.setConfig(serverConfigMap["prod3"]);
92
92
  }
93
- if (this.env === "prod" && ["xzero", "saas_admin", "saas_shop", "saas_kds", "saas_ads", "saas_home"].includes(
94
- this.projectName
95
- )) {
93
+ if (this.env === "prod" && [
94
+ "xzero",
95
+ "saas_admin",
96
+ "saas_shop",
97
+ "saas_kds",
98
+ "saas_ads",
99
+ "saas_home"
100
+ ].includes(this.projectName)) {
96
101
  serverConfig = serverConfigMap.aws.service[this.env];
97
102
  serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
98
103
  }
99
- if (this.env === "prod" && this.projectName === "admin") {
104
+ if (this.env === "prod" && ["admin", "docs"].includes(this.projectName)) {
100
105
  serverConfig = serverConfigMap.aws.service[this.env];
101
106
  serverConfig.privateKey = fs.readFileSync("../../../pem/pisell-pro.pem");
102
107
  }
@@ -57,7 +57,7 @@ var getGitCurrentBranch = async () => {
57
57
  const v = await $`git symbolic-ref --short HEAD`;
58
58
  return v.stdout;
59
59
  };
60
- var monorepoProjectNameArr = ["admin", "my_pisell_v2"];
60
+ var monorepoProjectNameArr = ["admin", "my_pisell_v2", "docs"];
61
61
  var getServerConfig = async (project) => {
62
62
  console.log(project, "project");
63
63
  if (monorepoProjectNameArr.includes(project)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/common",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
4
4
  "sideEffects": [
5
5
  "*.less"
6
6
  ],
@@ -20,7 +20,7 @@
20
20
  "archiver": "^5.3.1",
21
21
  "dotenv": "^16.0.3",
22
22
  "ssh2": "^1.13.0",
23
- "@pisell/utils": "1.0.54"
23
+ "@pisell/utils": "1.0.56"
24
24
  },
25
25
  "devDependencies": {
26
26
  "father": "^4.1.6"
@@ -47,6 +47,7 @@
47
47
  },
48
48
  "scripts": {
49
49
  "build": "father build",
50
+ "build:tsdown": "tsdown",
50
51
  "dev": "father dev",
51
52
  "docs:build": "dumi build",
52
53
  "doctor": "father doctor",
package/src/bin/pisell.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import('../../es/script/index.js');
3
+ import('../script/index.js');
@@ -49,6 +49,11 @@ const outPathMap = {
49
49
  release: '../data/release/project/saas_home',
50
50
  pre: '../data/release/project/saas_home',
51
51
  },
52
+ docs: {
53
+ prod: '../data/release/project/docs',
54
+ release: '../data/release/project/docs',
55
+ pre: '../data/release/project/docs',
56
+ },
52
57
  };
53
58
 
54
59
  const isSsrMap = {
@@ -57,6 +62,7 @@ const isSsrMap = {
57
62
  my_pisel_pc_v2: true,
58
63
  my_pisel_h5_v2: true,
59
64
  xzero: false,
65
+ docs: false,
60
66
  saas_admin: false,
61
67
  saas_shop: false,
62
68
  saas_kds: false,
@@ -147,9 +147,15 @@ async function init() {
147
147
  _fileName = 'my_pisell_v2';
148
148
  }
149
149
  if (
150
- !['xzero', 'saas_admin', 'saas_shop', 'saas_kds', 'saas_ads', 'saas_home'].includes(
151
- _fileName
152
- )
150
+ ![
151
+ 'xzero',
152
+ 'docs',
153
+ 'saas_admin',
154
+ 'saas_shop',
155
+ 'saas_kds',
156
+ 'saas_ads',
157
+ 'saas_home',
158
+ ].includes(_fileName)
153
159
  ) {
154
160
  // 上传oss
155
161
  await uploadStaticToOSS(_fileName);
@@ -96,16 +96,21 @@ class UploadCode {
96
96
 
97
97
  if (
98
98
  this.env === 'prod' &&
99
- ['xzero', 'saas_admin', 'saas_shop', 'saas_kds', 'saas_ads', 'saas_home'].includes(
100
- this.projectName
101
- )
99
+ [
100
+ 'xzero',
101
+ 'saas_admin',
102
+ 'saas_shop',
103
+ 'saas_kds',
104
+ 'saas_ads',
105
+ 'saas_home',
106
+ ].includes(this.projectName)
102
107
  ) {
103
108
  serverConfig = serverConfigMap.aws.service[this.env];
104
109
  serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
105
110
  }
106
111
 
107
112
  // pisell2.0正式环境使用亚马逊服务器
108
- if (this.env === 'prod' && this.projectName === 'admin') {
113
+ if (this.env === 'prod' && ['admin', 'docs'].includes(this.projectName)) {
109
114
  serverConfig = serverConfigMap.aws.service[this.env];
110
115
  serverConfig.privateKey = fs.readFileSync('../../../pem/pisell-pro.pem');
111
116
  }
@@ -28,7 +28,7 @@ const getGitCurrentBranch = async () => {
28
28
  * monorepo项目名称
29
29
  * @type {string[]}
30
30
  */
31
- const monorepoProjectNameArr = ['admin', 'my_pisell_v2'];
31
+ const monorepoProjectNameArr = ['admin', 'my_pisell_v2', 'docs'];
32
32
 
33
33
  /**
34
34
  * @Title: 获取本地lm_config.json配置信息
@@ -36,11 +36,11 @@ const monorepoProjectNameArr = ['admin', 'my_pisell_v2'];
36
36
  * @Author: Zsj
37
37
  */
38
38
  const getServerConfig = async (project) => {
39
- console.log(project,'project')
39
+ console.log(project, 'project');
40
40
  if (monorepoProjectNameArr.includes(project)) {
41
- return await JSON.parse(fs.readFileSync('../../../lm_config.json', 'utf8'))
41
+ return await JSON.parse(fs.readFileSync('../../../lm_config.json', 'utf8'));
42
42
  }
43
- return await JSON.parse(fs.readFileSync('../lm_config.json', 'utf8'))
43
+ return await JSON.parse(fs.readFileSync('../lm_config.json', 'utf8'));
44
44
  };
45
45
 
46
46
  /**
@@ -106,7 +106,7 @@ const serverUpload = (conn, { localPath, remotePath }) => {
106
106
  }
107
107
  console.log('上传成功');
108
108
  resolve(conn);
109
- },
109
+ }
110
110
  );
111
111
  });
112
112
  });
@@ -117,7 +117,10 @@ const serverUpload = (conn, { localPath, remotePath }) => {
117
117
  * @Describe:
118
118
  * @Author: Zsj
119
119
  */
120
- const serverUnpack = (conn, { path, fileName, fullFileName, changelog, env }) => {
120
+ const serverUnpack = (
121
+ conn,
122
+ { path, fileName, fullFileName, changelog, env }
123
+ ) => {
121
124
  if (!conn) return Promise.reject('未连接服务器');
122
125
  // 文件全名
123
126
  return new Promise((resolve, reject) => {
@@ -139,7 +142,7 @@ const serverUnpack = (conn, { path, fileName, fullFileName, changelog, env }) =>
139
142
  sh deleteOldVersion.sh
140
143
  exit
141
144
  ${env === 'prod' ? 'exit' : ''}
142
- `,
145
+ `
143
146
  // 打开到path
144
147
  // 解压 1.0.0.zip 文件到 1.0.0 移动dist中内容到 1.0.0内 删除dist
145
148
  // 删除1.0.0.zip
@@ -184,7 +187,7 @@ const releaseProject = (conn, { path, fileName, isSSR, env }) => {
184
187
  ${isSSR ? 'pm2 restart server.js' : ''}
185
188
  exit
186
189
  ${env === 'prod' ? 'exit' : ''}
187
- `,
190
+ `
188
191
  // 打开到path
189
192
  // 复制pre-master到next-master
190
193
  // 删除pre-master
@@ -251,7 +254,7 @@ const createFeishuMessageContent = (contentArr) => {
251
254
  { tag: 'text', text: `${item.key}: ` },
252
255
  { tag: 'text', text: `${item.value}` },
253
256
  ];
254
- }),
257
+ })
255
258
  );
256
259
  };
257
260
 
@@ -265,7 +268,7 @@ const getNonExcludedPackages = (excludedPackages) => {
265
268
  };
266
269
 
267
270
  const nonExcludedPackages = Object.keys(dependencies).filter(
268
- (packageName) => !excludedPackages.includes(packageName),
271
+ (packageName) => !excludedPackages.includes(packageName)
269
272
  );
270
273
  return nonExcludedPackages;
271
274
  };
@@ -0,0 +1,93 @@
1
+ import { defineConfig } from 'tsdown';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ const ENTRY = ['src/**/*.{js,ts,tsx,jsx}', '!src/**/*.d.ts'];
6
+ const JS_RE = /((?<!\.d)\.ts|\.(jsx?|tsx))$/;
7
+
8
+ // 递归遍历目录获取所有文件
9
+ function listFilesRecursive(dir: string, ignores: string[] = []): string[] {
10
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
11
+ const files: string[] = [];
12
+
13
+ for (const e of entries) {
14
+ const abs = path.join(dir, e.name);
15
+ const base = path.basename(abs);
16
+ if (ignores.includes(base)) continue;
17
+
18
+ if (e.isDirectory()) {
19
+ files.push(...listFilesRecursive(abs, ignores));
20
+ } else {
21
+ files.push(abs);
22
+ }
23
+ }
24
+
25
+ return files;
26
+ }
27
+
28
+ // 确保目录存在
29
+ function ensureDir(dir: string) {
30
+ if (!fs.existsSync(dir)) {
31
+ fs.mkdirSync(dir, { recursive: true });
32
+ }
33
+ }
34
+
35
+ const srcDir = path.resolve(__dirname, 'src');
36
+
37
+ // Plugin factory to copy non-JS files to output directory
38
+ function createCopyAssetsPlugin(outDir: string) {
39
+ return {
40
+ name: 'copy-assets',
41
+ buildEnd() {
42
+ const files = listFilesRecursive(srcDir, []);
43
+ for (const file of files) {
44
+ // 如果不匹配 JS_RE,则直接复制文件
45
+ if (!JS_RE.test(file)) {
46
+ const rel = path.relative(srcDir, file);
47
+ const dest = path.join(outDir, rel);
48
+ ensureDir(path.dirname(dest));
49
+ fs.copyFileSync(file, dest);
50
+ }
51
+ }
52
+ },
53
+ };
54
+ }
55
+
56
+ const ASSET_EXTERNAL_RE =
57
+ /\.(css|less|sass|scss|styl|png|jpg|jpeg|gif|svg|webp|bmp|ico|woff2?|ttf|eot)$/;
58
+
59
+ export default defineConfig([
60
+ {
61
+ entry: ENTRY,
62
+ format: 'esm',
63
+ outDir: 'es',
64
+ target: 'es6',
65
+ dts: true,
66
+ clean: true,
67
+ unbundle: true,
68
+ external: [ASSET_EXTERNAL_RE],
69
+ plugins: [createCopyAssetsPlugin(path.resolve(__dirname, 'es'))],
70
+ skipNodeModulesBundle: true,
71
+ outExtensions: () => ({
72
+ js: '.js',
73
+ dts: '.d.ts',
74
+ }),
75
+ },
76
+ {
77
+ entry: ENTRY,
78
+ format: 'cjs',
79
+ outDir: 'lib',
80
+ target: 'es6',
81
+ dts: true,
82
+ clean: true,
83
+ unbundle: true,
84
+ external: [ASSET_EXTERNAL_RE],
85
+ plugins: [createCopyAssetsPlugin(path.resolve(__dirname, 'lib'))],
86
+ fixedExtension: false,
87
+ skipNodeModulesBundle: true,
88
+ outExtensions: () => ({
89
+ js: '.js',
90
+ dts: '.d.ts',
91
+ }),
92
+ },
93
+ ]);