@pisell/common 1.0.56 → 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,440 +1,8 @@
1
1
  # @pisell/common
2
2
 
3
- ## 1.0.56
3
+ ## 1.0.57
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [05e94afdcd]
8
- - @pisell/utils@1.0.55
9
-
10
- ## 1.0.55
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [dc0f1ef331]
15
- - @pisell/utils@1.0.54
16
-
17
- ## 1.0.54
18
-
19
- ### Patch Changes
20
-
21
- - Updated dependencies [130012734]
22
- - @pisell/utils@1.0.53
23
-
24
- ## 1.0.53
25
-
26
- ### Patch Changes
27
-
28
- - Updated dependencies [3c3397ee1]
29
- - @pisell/utils@1.0.52
30
-
31
- ## 1.0.52
32
-
33
- ### Patch Changes
34
-
35
- - Updated dependencies [7f75442c8]
36
- - @pisell/utils@1.0.51
37
-
38
- ## 3.0.12
39
-
40
- ### Patch Changes
41
-
42
- - cf72095e7: update
43
-
44
- ## 3.0.9
45
-
46
- ### Patch Changes
47
-
48
- - ab5a8d1df: 新增 saas_home 项目路径并更新相关逻辑
49
-
50
- ## 3.0.10
51
-
52
- ### Patch Changes
53
-
54
- - Updated dependencies [f15c3be02]
55
- - @pisell/utils@1.0.44
56
-
57
- ## 3.0.9
58
-
59
- ### Patch Changes
60
-
61
- - Updated dependencies [2f57417ac]
62
- - @pisell/utils@1.0.43
63
-
64
- ## 3.0.8
65
-
66
- ## 1.0.51
67
-
68
- ### Patch Changes
69
-
70
- - Updated dependencies [1dd3694e4]
71
- - @pisell/utils@1.0.50
72
-
73
- ## 1.0.50
74
-
75
- ### Patch Changes
76
-
77
- - Updated dependencies [d4e39d968]
78
- - @pisell/utils@1.0.49
79
-
80
- ## 1.0.49
81
-
82
- ### Patch Changes
83
-
84
- - Updated dependencies [4650ca88a]
85
- - @pisell/utils@1.0.48
86
-
87
- ## 1.0.48
88
-
89
- ### Patch Changes
90
-
91
- - Updated dependencies [3ca04e31c]
92
- - @pisell/utils@1.0.47
93
-
94
- ## 1.0.47
95
-
96
- ### Patch Changes
97
-
98
- - Updated dependencies [301a686d8]
99
- - @pisell/utils@1.0.46
100
-
101
- ## 1.0.46
102
-
103
- ### Patch Changes
104
-
105
- - Updated dependencies [6733b2d5c]
106
- - @pisell/utils@1.0.45
107
-
108
- ## 1.0.45
109
-
110
- ### Patch Changes
111
-
112
- - Updated dependencies [a09f3e360]
113
- - @pisell/utils@1.0.44
114
-
115
- ## 1.0.44
116
-
117
- ### Patch Changes
118
-
119
- - f4db8d9a3: build:增加上传代码前的包版本检查
120
-
121
- ## 1.0.43
122
-
123
- ### Patch Changes
124
-
125
- - 740ab6b52: s
126
-
127
- ## 1.0.42
128
-
129
- ### Patch Changes
130
-
131
- - Updated dependencies [6f57a4d88]
132
- - @pisell/utils@1.0.43
133
-
134
- ## 1.0.41
135
-
136
- ### Patch Changes
137
-
138
- - Updated dependencies [0267536f]
139
- - @pisell/utils@1.0.42
140
-
141
- ## 1.0.40
142
-
143
- ### Patch Changes
144
-
145
- - Updated dependencies [f3ed6fa4]
146
- - @pisell/utils@1.0.41
147
-
148
- ## 1.0.39
149
-
150
- ### Patch Changes
151
-
152
- - Updated dependencies [b848ae9a]
153
- - @pisell/utils@1.0.40
154
-
155
- ## 1.0.38
156
-
157
- ### Patch Changes
158
-
159
- - Updated dependencies [8640a624]
160
- - @pisell/utils@1.0.39
161
-
162
- ## 1.0.37
163
-
164
- ### Patch Changes
165
-
166
- - Updated dependencies [27cdd90e]
167
- - @pisell/utils@1.0.38
168
-
169
- ## 1.0.36
170
-
171
- ### Patch Changes
172
-
173
- - Updated dependencies [30136d51]
174
- - @pisell/utils@1.0.37
175
-
176
- ## 1.0.35
177
-
178
- ### Patch Changes
179
-
180
- - Updated dependencies [a694c37e]
181
- - @pisell/utils@1.0.36
182
-
183
- ## 1.0.34
184
-
185
- ### Patch Changes
186
-
187
- - Updated dependencies [11c9a831]
188
- - @pisell/utils@1.0.35
189
-
190
- ## 1.0.33
191
-
192
- ### Patch Changes
193
-
194
- - Updated dependencies [881303a5]
195
- - @pisell/utils@1.0.34
196
-
197
- ## 1.0.32
198
-
199
- ### Patch Changes
200
-
201
- - Updated dependencies [fb6b699f]
202
- - @pisell/utils@1.0.33
203
-
204
- ## 1.0.31
205
-
206
- ### Patch Changes
207
-
208
- - Updated dependencies [bf60f3ca]
209
- - @pisell/utils@1.0.32
210
-
211
- ## 1.0.30
212
-
213
- ### Patch Changes
214
-
215
- - Updated dependencies [f7f80d68]
216
- - @pisell/utils@1.0.31
217
-
218
- ## 1.0.29
219
-
220
- ### Patch Changes
221
-
222
- - Updated dependencies [d41cf764]
223
- - @pisell/utils@1.0.30
224
-
225
- ## 1.0.28
226
-
227
- ### Patch Changes
228
-
229
- - Updated dependencies [f10f984b]
230
- - @pisell/utils@1.0.29
231
-
232
- ## 1.0.27
233
-
234
- ### Patch Changes
235
-
236
- - Updated dependencies [1d22e943]
237
- - @pisell/utils@1.0.28
238
-
239
- ## 1.0.26
240
-
241
- ### Patch Changes
242
-
243
- - Updated dependencies [a45e6cd5]
244
- - @pisell/utils@1.0.27
245
-
246
- ## 1.0.25
247
-
248
- ### Patch Changes
249
-
250
- - Updated dependencies [961d44f7]
251
- - @pisell/utils@1.0.26
252
-
253
- ## 1.0.24
254
-
255
- ### Patch Changes
256
-
257
- - Updated dependencies [10083f21]
258
- - @pisell/utils@1.0.25
259
-
260
- ## 1.0.26
261
-
262
- ### Patch Changes
263
-
264
- - Updated dependencies [8dc07315]
265
- - Updated dependencies [678cac4f]
266
- - @pisell/utils@1.0.29
267
-
268
- ## 1.0.25
269
-
270
- ### Patch Changes
271
-
272
- - Updated dependencies [532f075e]
273
- - @pisell/utils@1.0.28
274
-
275
- ## 1.0.24
276
-
277
- ### Patch Changes
278
-
279
- - Updated dependencies [77f985d0]
280
- - @pisell/utils@1.0.25
281
-
282
- ## 1.0.23
283
-
284
- ### Patch Changes
285
-
286
- - Updated dependencies [315258e3]
287
- - @pisell/utils@1.0.24
288
-
289
- ## 1.0.22
290
-
291
- ### Patch Changes
292
-
293
- - Updated dependencies [fdc8fae]
294
- - @pisell/utils@1.0.23
295
-
296
- ## 1.0.21
297
-
298
- ### Patch Changes
299
-
300
- - Updated dependencies [bbd6503]
301
- - @pisell/utils@1.0.22
302
-
303
- ## 1.0.20
304
-
305
- ### Patch Changes
306
-
307
- - Updated dependencies [d000328]
308
- - @pisell/utils@1.0.21
309
-
310
- ## 1.0.19
311
-
312
- ### Patch Changes
313
-
314
- - Updated dependencies [b879dad]
315
- - @pisell/utils@1.0.20
316
-
317
- ## 1.0.18
318
-
319
- ### Patch Changes
320
-
321
- - Updated dependencies [67d2110]
322
- - @pisell/utils@1.0.19
323
-
324
- ## 1.0.17
325
-
326
- ### Patch Changes
327
-
328
- - Updated dependencies [770c6cb]
329
- - @pisell/utils@1.0.18
330
-
331
- ## 1.0.16
332
-
333
- ### Patch Changes
334
-
335
- - Updated dependencies [443a959]
336
- - @pisell/utils@1.0.17
337
-
338
- ## 1.0.15
339
-
340
- ### Patch Changes
341
-
342
- - Updated dependencies [32fd732]
343
- - @pisell/utils@1.0.16
344
-
345
- ## 1.0.14
346
-
347
- ### Patch Changes
348
-
349
- - Updated dependencies [0f0601e]
350
- - @pisell/utils@1.0.15
351
-
352
- ## 1.0.13
353
-
354
- ### Patch Changes
355
-
356
- - Updated dependencies [bf50fb5]
357
- - @pisell/utils@1.0.14
358
-
359
- ## 1.0.12
360
-
361
- ### Patch Changes
362
-
363
- - Updated dependencies [b41ebaf]
364
- - @pisell/utils@1.0.13
365
-
366
- ## 1.0.11
367
-
368
- ### Patch Changes
369
-
370
- - Updated dependencies [e1a659c]
371
- - @pisell/utils@1.0.12
372
-
373
- ## 1.0.10
374
-
375
- ### Patch Changes
376
-
377
- - Updated dependencies [64ce1de]
378
- - @pisell/utils@1.0.11
379
-
380
- ## 1.0.9
381
-
382
- ### Patch Changes
383
-
384
- - Updated dependencies [eef8cdb]
385
- - @pisell/utils@1.0.10
386
-
387
- ## 1.0.8
388
-
389
- ### Patch Changes
390
-
391
- - Updated dependencies [ab61ee2]
392
- - @pisell/utils@1.0.9
393
-
394
- ## 1.0.7
395
-
396
- ### Patch Changes
397
-
398
- - Updated dependencies [88d5ebc]
399
- - @pisell/utils@1.0.8
400
-
401
- ## 1.0.6
402
-
403
- ### Patch Changes
404
-
405
- - Updated dependencies [abf14c2]
406
- - @pisell/utils@1.0.7
407
-
408
- ## 1.0.5
409
-
410
- ### Patch Changes
411
-
412
- - Updated dependencies [179b7e0]
413
- - @pisell/utils@1.0.6
414
-
415
- ## 1.0.4
416
-
417
- ### Patch Changes
418
-
419
- - Updated dependencies [1bd9790]
420
- - @pisell/utils@1.0.5
421
-
422
- ## 1.0.3
423
-
424
- ### Patch Changes
425
-
426
- - Updated dependencies
427
- - @pisell/utils@1.0.3
428
-
429
- ## 1.0.2
430
-
431
- ### Patch Changes
432
-
433
- - Updated dependencies
434
- - @pisell/utils@1.0.2
435
-
436
- ## 1.0.1
437
-
438
- ### Patch Changes
439
-
440
- - 测试更新包
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.56",
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.55"
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
+ ]);