w-dwdata-hub 1.0.0

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.
Files changed (135) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +168 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +16 -0
  9. package/dist/w-dwdata-hub.umd.js +7 -0
  10. package/dist/w-dwdata-hub.umd.js.map +1 -0
  11. package/docs/WDwdataHub.mjs.html +136 -0
  12. package/docs/decodeEntities.mjs.html +129 -0
  13. package/docs/extractDivContent.mjs.html +147 -0
  14. package/docs/fetchAiNewsAggregator.mjs.html +155 -0
  15. package/docs/fetchAisixiang.mjs.html +1038 -0
  16. package/docs/fetchCnyes.mjs.html +260 -0
  17. package/docs/fetchGuancha.mjs.html +1007 -0
  18. package/docs/fetchHackerNews.mjs.html +189 -0
  19. package/docs/fetchMoneydj.mjs.html +251 -0
  20. package/docs/fetchMops.mjs.html +385 -0
  21. package/docs/fetchRSS.mjs.html +160 -0
  22. package/docs/fetchStatementdog.mjs.html +213 -0
  23. package/docs/fetchTaifex.mjs.html +513 -0
  24. package/docs/fetchTpex3insti.mjs.html +278 -0
  25. package/docs/fetchTpexMargin.mjs.html +248 -0
  26. package/docs/fetchTpexStock.mjs.html +199 -0
  27. package/docs/fetchTwDataHoliday.mjs.html +236 -0
  28. package/docs/fetchTwseMargin.mjs.html +253 -0
  29. package/docs/fetchTwseStock.mjs.html +188 -0
  30. package/docs/fetchTwseT86.mjs.html +208 -0
  31. package/docs/fetchWithRetry.mjs.html +376 -0
  32. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  33. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  34. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  35. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  36. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  37. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  38. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  39. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  43. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  44. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  45. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  46. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  47. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  48. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  49. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  50. package/docs/getOptFetch.mjs.html +185 -0
  51. package/docs/global.html +22649 -0
  52. package/docs/htmlToMarkdown.mjs.html +168 -0
  53. package/docs/index.html +84 -0
  54. package/docs/isYmd.mjs.html +114 -0
  55. package/docs/parseIntComma.mjs.html +100 -0
  56. package/docs/safeFilename.mjs.html +102 -0
  57. package/docs/scripts/collapse.js +39 -0
  58. package/docs/scripts/commonNav.js +28 -0
  59. package/docs/scripts/linenumber.js +25 -0
  60. package/docs/scripts/nav.js +12 -0
  61. package/docs/scripts/polyfill.js +4 -0
  62. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  63. package/docs/scripts/prettify/lang-css.js +2 -0
  64. package/docs/scripts/prettify/prettify.js +28 -0
  65. package/docs/scripts/search.js +99 -0
  66. package/docs/styles/jsdoc.css +776 -0
  67. package/docs/styles/prettify.css +80 -0
  68. package/docs/toDatetimeUTC8.mjs.html +143 -0
  69. package/docs/toRocDate.mjs.html +107 -0
  70. package/g.mjs +73 -0
  71. package/package.json +31 -0
  72. package/script.txt +17 -0
  73. package/src/WDwdataHub.mjs +64 -0
  74. package/src/decodeEntities.mjs +57 -0
  75. package/src/extractDivContent.mjs +75 -0
  76. package/src/fetchAiNewsAggregator.mjs +83 -0
  77. package/src/fetchAisixiang.mjs +966 -0
  78. package/src/fetchCnyes.mjs +188 -0
  79. package/src/fetchGuancha.mjs +935 -0
  80. package/src/fetchHackerNews.mjs +117 -0
  81. package/src/fetchMoneydj.mjs +179 -0
  82. package/src/fetchMops.mjs +313 -0
  83. package/src/fetchRSS.mjs +88 -0
  84. package/src/fetchStatementdog.mjs +141 -0
  85. package/src/fetchTaifex.mjs +441 -0
  86. package/src/fetchTpex3insti.mjs +206 -0
  87. package/src/fetchTpexMargin.mjs +176 -0
  88. package/src/fetchTpexStock.mjs +127 -0
  89. package/src/fetchTwDataHoliday.mjs +164 -0
  90. package/src/fetchTwseMargin.mjs +181 -0
  91. package/src/fetchTwseStock.mjs +116 -0
  92. package/src/fetchTwseT86.mjs +136 -0
  93. package/src/fetchWithRetry.mjs +304 -0
  94. package/src/getOptFetch.mjs +113 -0
  95. package/src/htmlToMarkdown.mjs +96 -0
  96. package/src/isYmd.mjs +42 -0
  97. package/src/parseIntComma.mjs +28 -0
  98. package/src/safeFilename.mjs +30 -0
  99. package/src/toDatetimeUTC8.mjs +71 -0
  100. package/src/toRocDate.mjs +35 -0
  101. package/test/WDwdataHub.test.mjs +63 -0
  102. package/test/decodeEntities.test.mjs +42 -0
  103. package/test/extractDivContent.test.mjs +48 -0
  104. package/test/fetchAiNewsAggregator.test.mjs +79 -0
  105. package/test/fetchAisixiang.test.mjs +225 -0
  106. package/test/fetchCnyes.test.mjs +61 -0
  107. package/test/fetchGuancha.test.mjs +190 -0
  108. package/test/fetchHackerNews.test.mjs +78 -0
  109. package/test/fetchMoneydj.test.mjs +82 -0
  110. package/test/fetchMops.test.mjs +106 -0
  111. package/test/fetchRSS.test.mjs +85 -0
  112. package/test/fetchStatementdog.test.mjs +69 -0
  113. package/test/fetchTaifex.test.mjs +99 -0
  114. package/test/fetchTpex3insti.test.mjs +90 -0
  115. package/test/fetchTpexMargin.test.mjs +94 -0
  116. package/test/fetchTpexStock.test.mjs +68 -0
  117. package/test/fetchTwDataHoliday.test.mjs +100 -0
  118. package/test/fetchTwseMargin.test.mjs +81 -0
  119. package/test/fetchTwseStock.test.mjs +80 -0
  120. package/test/fetchTwseT86.test.mjs +76 -0
  121. package/test/fetchWithRetry.test.mjs +174 -0
  122. package/test/htmlToMarkdown.test.mjs +71 -0
  123. package/test/isYmd.test.mjs +56 -0
  124. package/test/parseIntComma.test.mjs +38 -0
  125. package/test/safeFilename.test.mjs +35 -0
  126. package/test/toDatetimeUTC8.test.mjs +65 -0
  127. package/test/toRocDate.test.mjs +38 -0
  128. package/test/tools/encodeBig5.mjs +80 -0
  129. package/test/tools/fixtures.mjs +539 -0
  130. package/test/tools/hasChrome.mjs +39 -0
  131. package/test/tools/serverForTest.mjs +397 -0
  132. package/toolg/addVersion.mjs +4 -0
  133. package/toolg/cleanFolder.mjs +5 -0
  134. package/toolg/gDistRollup.mjs +49 -0
  135. package/toolg/modifyReadme.mjs +4 -0
@@ -0,0 +1,397 @@
1
+ import http from 'http'
2
+ import encodeBig5 from './encodeBig5.mjs'
3
+ import * as fx from './fixtures.mjs'
4
+
5
+
6
+ /**
7
+ * 啟動本機測試用HTTP伺服器
8
+ *
9
+ * 各路由以官方API之實際路徑與回應格式提供固定內容, 令測試不需連線外部網站即可驗證抓取與解析;
10
+ * 另提供通用路由供fetchWithRetry之重試、逾時與編碼行為斷言
11
+ *
12
+ * 通用路由:
13
+ * /json/ok 回200 JSON;
14
+ * /json/bad 回200但內容非JSON;
15
+ * /status/:code 回指定HTTP狀態碼;
16
+ * /flaky/:code?n=2 前n次回指定狀態碼其後回200 JSON(可由/flaky/reset歸零);
17
+ * /text/big5 回Big5編碼文字;
18
+ * /slow?ms=100 延遲後回200 JSON;
19
+ * /echo 回請求方法與標頭之JSON
20
+ *
21
+ * @returns {Promise} 回傳Promise,resolve回傳{port,url,close,getCount}物件,其中url為由路徑組出完整網址之函數,close為關閉伺服器之async函數,getCount為取得指定路徑請求次數之函數
22
+ * @example
23
+ *
24
+ * import serverForTest from './tools/serverForTest.mjs'
25
+ *
26
+ * let svr = await serverForTest()
27
+ * console.log(svr.url('/json/ok'))
28
+ * // => 'http://127.0.0.1:54321/json/ok'
29
+ * await svr.close()
30
+ *
31
+ */
32
+ function serverForTest() {
33
+ return new Promise((resolve) => {
34
+
35
+ //counts, 記錄各路徑之請求次數, 供斷言重試次數與翻頁次數
36
+ let counts = {}
37
+
38
+ //flakyCount, /flaky/:code之已回應失敗次數
39
+ let flakyCount = 0
40
+
41
+ let server = http.createServer(async (req, res) => {
42
+
43
+ let u = new URL(req.url, 'http://127.0.0.1')
44
+ let pathname = u.pathname
45
+ let qs = u.searchParams
46
+
47
+ //count
48
+ counts[pathname] = (counts[pathname] || 0) + 1
49
+
50
+ let sendJson = (code, obj) => {
51
+ let body = typeof obj === 'string' ? obj : JSON.stringify(obj)
52
+ res.writeHead(code, { 'Content-Type': 'application/json; charset=utf-8' })
53
+ res.end(body)
54
+ }
55
+ let sendText = (code, text, contentType = 'text/plain; charset=utf-8') => {
56
+ res.writeHead(code, { 'Content-Type': contentType })
57
+ res.end(text)
58
+ }
59
+ let sendHtml = (code, html) => {
60
+ sendText(code, html, 'text/html; charset=utf-8')
61
+ }
62
+ let sendBig5 = (code, text) => {
63
+ let buf = encodeBig5(text)
64
+ res.writeHead(code, { 'Content-Type': 'text/csv; charset=big5', 'Content-Length': buf.length })
65
+ res.end(buf)
66
+ }
67
+
68
+ //===== 通用路由 =====
69
+
70
+ if (pathname === '/json/ok') {
71
+ sendJson(200, { ok: true, value: 1 })
72
+ return
73
+ }
74
+ if (pathname === '/json/bad') {
75
+ sendJson(200, '<html><body>維護中</body></html>')
76
+ return
77
+ }
78
+ if (pathname === '/flaky/reset') {
79
+ flakyCount = 0
80
+ sendJson(200, { ok: true })
81
+ return
82
+ }
83
+ if (pathname.startsWith('/flaky/')) {
84
+ let code = parseInt(pathname.split('/')[2], 10)
85
+ let n = parseInt(qs.get('n') || '1', 10)
86
+ if (flakyCount < n) {
87
+ flakyCount++
88
+ res.writeHead(code, { 'Content-Type': 'text/plain' })
89
+ res.end('flaky')
90
+ return
91
+ }
92
+ sendJson(200, { ok: true, failed: flakyCount })
93
+ return
94
+ }
95
+ if (pathname.startsWith('/status/')) {
96
+ let code = parseInt(pathname.split('/')[2], 10)
97
+ res.writeHead(code, { 'Content-Type': 'text/plain' })
98
+ res.end(`status ${code}`)
99
+ return
100
+ }
101
+ if (pathname === '/text/big5') {
102
+ sendBig5(200, '中文測試,Big5編碼')
103
+ return
104
+ }
105
+ if (pathname === '/slow') {
106
+ let ms = parseInt(qs.get('ms') || '100', 10)
107
+ await new Promise((resolve) => setTimeout(resolve, ms))
108
+ sendJson(200, { ok: true })
109
+ return
110
+ }
111
+ if (pathname === '/echo') {
112
+ sendJson(200, { method: req.method, headers: req.headers })
113
+ return
114
+ }
115
+
116
+ //===== AI News Aggregator =====
117
+
118
+ if (pathname === '/ai-news/latest-24h.json') {
119
+ sendJson(200, fx.aiNews)
120
+ return
121
+ }
122
+
123
+ //===== RSS =====
124
+
125
+ if (pathname === '/rss/feed.xml') {
126
+ sendText(200, fx.rssXml, 'application/rss+xml; charset=utf-8')
127
+ return
128
+ }
129
+
130
+ //===== Hacker News =====
131
+
132
+ if (pathname === '/hn/newstories.json') {
133
+ sendJson(200, fx.hnNewStories)
134
+ return
135
+ }
136
+ if (pathname.startsWith('/hn/item/')) {
137
+ let id = pathname.split('/')[3].replace('.json', '')
138
+ sendJson(200, fx.hnItems[id] || null)
139
+ return
140
+ }
141
+
142
+ //===== 鉅亨網 =====
143
+
144
+ if (pathname === '/cnyes/newslist') {
145
+ let page = parseInt(qs.get('page') || '1', 10)
146
+ sendJson(200, page === 1 ? fx.cnyesPage1 : fx.cnyesPageEmpty)
147
+ return
148
+ }
149
+
150
+ //===== 財報狗 =====
151
+
152
+ if (pathname === '/statementdog/news/latest') {
153
+ sendHtml(200, fx.statementdogHtml)
154
+ return
155
+ }
156
+ if (pathname === '/statementdog-fallback/news/latest') {
157
+ sendHtml(200, fx.statementdogFallbackHtml)
158
+ return
159
+ }
160
+ if (pathname === '/statementdog-empty/news/latest') {
161
+ sendHtml(200, fx.statementdogEmptyHtml)
162
+ return
163
+ }
164
+
165
+ //===== MoneyDJ =====
166
+
167
+ if (pathname === '/moneydj/newsreallist.aspx') {
168
+ let index1 = parseInt(qs.get('index1') || '1', 10)
169
+ if (index1 === 1) {
170
+ sendHtml(200, fx.moneydjPage1Html)
171
+ }
172
+ else if (index1 === 2) {
173
+ sendHtml(200, fx.moneydjPage2Html)
174
+ }
175
+ else {
176
+ sendHtml(200, fx.moneydjEmptyHtml)
177
+ }
178
+ return
179
+ }
180
+ if (pathname === '/moneydj-empty/newsreallist.aspx') {
181
+ sendHtml(200, fx.moneydjEmptyHtml)
182
+ return
183
+ }
184
+ if (pathname === '/moneydj-flaky/newsreallist.aspx') {
185
+ //第1頁一律失敗, 供斷言單頁失敗時跳過該頁而不中斷整體抓取
186
+ let index1 = parseInt(qs.get('index1') || '1', 10)
187
+ if (index1 === 1) {
188
+ sendText(404, 'not found')
189
+ return
190
+ }
191
+ sendHtml(200, fx.moneydjPage2Html)
192
+ return
193
+ }
194
+
195
+ //===== 證交所 =====
196
+
197
+ if (pathname === '/exchangeReport/STOCK_DAY') {
198
+ //查詢日期早於資料起始日時, 證交所回stat非OK
199
+ if ((qs.get('date') || '') < '20100101') {
200
+ sendJson(200, { stat: '查詢日期小於99年1月4日,請重新查詢!' })
201
+ return
202
+ }
203
+ sendJson(200, fx.twseStockDay)
204
+ return
205
+ }
206
+ if (pathname === '/exchangeReport/MI_INDEX') {
207
+ sendJson(200, fx.twseMiIndex)
208
+ return
209
+ }
210
+ if (pathname === '/rwd/zh/marginTrading/MI_MARGN') {
211
+ sendJson(200, fx.twseMargin)
212
+ return
213
+ }
214
+ if (pathname === '/rwd/zh/fund/T86') {
215
+ sendJson(200, fx.twseT86)
216
+ return
217
+ }
218
+
219
+ //===== 櫃買中心 =====
220
+
221
+ if (pathname === '/web/stock/aftertrading/daily_close_quotes/stk_quote_result.php') {
222
+ sendJson(200, fx.tpexStock)
223
+ return
224
+ }
225
+ if (pathname === '/web/stock/margin_trading/margin_balance/margin_bal_result.php') {
226
+ sendJson(200, fx.tpexMargin)
227
+ return
228
+ }
229
+ if (pathname === '/bad-shape/web/stock/margin_trading/margin_balance/margin_bal_result.php') {
230
+ sendJson(200, fx.tpexMarginBadShape)
231
+ return
232
+ }
233
+ if (pathname === '/web/stock/3insti/daily_trade/3itrade_hedge_result.php') {
234
+ sendJson(200, fx.tpex3insti)
235
+ return
236
+ }
237
+ if (pathname === '/bad-shape/web/stock/3insti/daily_trade/3itrade_hedge_result.php') {
238
+ sendJson(200, fx.tpex3instiBadShape)
239
+ return
240
+ }
241
+
242
+ //===== 期交所 =====
243
+
244
+ if (pathname === '/cht/3/futDataDown') {
245
+ sendBig5(200, fx.taifexFuturesCsv)
246
+ return
247
+ }
248
+ if (pathname === '/cht/3/futContractsDateDown') {
249
+ sendBig5(200, fx.taifexInstitutionalCsv)
250
+ return
251
+ }
252
+ if (pathname === '/cht/3/pcRatioDown') {
253
+ sendBig5(200, fx.taifexPcRatioCsv)
254
+ return
255
+ }
256
+ if (pathname === '/no-data/cht/3/futDataDown' ||
257
+ pathname === '/no-data/cht/3/futContractsDateDown' ||
258
+ pathname === '/no-data/cht/3/pcRatioDown') {
259
+ //非交易日時期交所回僅有表頭之CSV
260
+ sendBig5(200, '交易日期,契約')
261
+ return
262
+ }
263
+
264
+ //===== 公開資訊觀測站 =====
265
+
266
+ if (pathname === '/mops/page') {
267
+ sendHtml(200, fx.mopsPageHtml)
268
+ return
269
+ }
270
+ if (pathname === '/mops/api/t146sb10' || pathname === '/mops-error/api/t146sb10') {
271
+
272
+ //body, MOPS查詢API為POST且以JSON帶marketKind
273
+ let chunks = []
274
+ for await (let chunk of req) {
275
+ chunks.push(chunk)
276
+ }
277
+ let marketKind = ''
278
+ try {
279
+ marketKind = JSON.parse(Buffer.concat(chunks).toString('utf8')).marketKind
280
+ }
281
+ catch (err) {
282
+ marketKind = ''
283
+ }
284
+
285
+ //application-level錯誤, HTTP 200但code非200亦非406
286
+ if (pathname === '/mops-error/api/t146sb10') {
287
+ sendJson(200, { code: 500, message: '系統忙碌中' })
288
+ return
289
+ }
290
+
291
+ sendJson(200, fx.getMopsResult(marketKind))
292
+ return
293
+ }
294
+
295
+ //===== 證交所休市日期 =====
296
+
297
+ if (pathname === '/v1/holidaySchedule/holidaySchedule') {
298
+ sendJson(200, fx.holidaySchedule)
299
+ return
300
+ }
301
+
302
+ //===== 愛思想 =====
303
+
304
+ if (pathname === '/thinktank/') {
305
+ sendHtml(200, fx.aisixiangThinktankHtml)
306
+ return
307
+ }
308
+ if (pathname === '/thinktank/gezhaoguang.html') {
309
+ sendHtml(200, fx.aisixiangAuthorHtml)
310
+ return
311
+ }
312
+ if (pathname === '/thinktank/nobody.html') {
313
+ sendHtml(200, fx.aisixiangEmptyAuthorHtml)
314
+ return
315
+ }
316
+ if (pathname === '/zhuanti/') {
317
+ sendHtml(200, fx.aisixiangZhuantiListHtml)
318
+ return
319
+ }
320
+ if (pathname === '/zhuanti/301.html') {
321
+ let page = parseInt(qs.get('page') || '1', 10)
322
+ sendHtml(200, page === 1 ? fx.aisixiangZhuantiPage1Html : fx.aisixiangZhuantiPage2Html)
323
+ return
324
+ }
325
+ if (pathname === '/data/search') {
326
+ let keywords = qs.get('keywords') || ''
327
+ sendHtml(200, keywords === '老庄' ? fx.aisixiangSearchHitHtml : fx.aisixiangSearchEmptyHtml)
328
+ return
329
+ }
330
+ if (pathname === '/data/146669.html') {
331
+ sendHtml(200, fx.aisixiangArticleHtml)
332
+ return
333
+ }
334
+ if (pathname === '/data/999999.html') {
335
+ sendHtml(200, fx.aisixiangBadArticleHtml)
336
+ return
337
+ }
338
+
339
+ //===== 觀察者網 =====
340
+
341
+ if (pathname === '/' || pathname === '/NotExistSlug/list_1.shtml') {
342
+ //站方對不存在之slug會302跳首頁, 此處直接回首頁內容以重現該情境
343
+ sendHtml(200, fx.guanchaHomeHtml)
344
+ return
345
+ }
346
+ if (pathname === '/AnSheng/list_1.shtml') {
347
+ sendHtml(200, fx.guanchaListPage1Html)
348
+ return
349
+ }
350
+ if (pathname === '/AnSheng/list_2.shtml') {
351
+ sendHtml(200, fx.guanchaListPage2Html)
352
+ return
353
+ }
354
+ if (pathname.startsWith('/AnSheng/list_')) {
355
+ sendHtml(200, fx.guanchaListEmptyHtml)
356
+ return
357
+ }
358
+ if (pathname === '/AnSheng/2026_08_07_800001.shtml') {
359
+ sendHtml(200, fx.guanchaArticleHtml)
360
+ return
361
+ }
362
+ if (pathname === '/AnSheng/2026_01_01_000000.shtml') {
363
+ //已下架文章, 站方會302跳首頁
364
+ sendHtml(200, fx.guanchaHomeHtml)
365
+ return
366
+ }
367
+ if (pathname === '/CaiJing/list_1.shtml') {
368
+ sendHtml(200, fx.guanchaListPage1Html)
369
+ return
370
+ }
371
+ if (pathname.startsWith('/CaiJing/list_')) {
372
+ sendHtml(200, fx.guanchaListEmptyHtml)
373
+ return
374
+ }
375
+
376
+ sendText(404, 'not found')
377
+ })
378
+
379
+ server.listen(0, '127.0.0.1', () => {
380
+ let port = server.address().port
381
+ resolve({
382
+ port,
383
+ url: (pathname) => `http://127.0.0.1:${port}${pathname}`,
384
+ getCount: (pathname) => counts[pathname] || 0,
385
+ close: () => new Promise((resolve) => {
386
+ server.close(() => {
387
+ resolve(true)
388
+ })
389
+ }),
390
+ })
391
+ })
392
+
393
+ })
394
+ }
395
+
396
+
397
+ export default serverForTest
@@ -0,0 +1,4 @@
1
+ import addVersion from 'w-package-tools/src/addVersion.mjs'
2
+
3
+
4
+ addVersion()
@@ -0,0 +1,5 @@
1
+ import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
2
+
3
+
4
+ cleanFolder('dist')
5
+ cleanFolder('docs')
@@ -0,0 +1,49 @@
1
+ import rollupFiles from 'w-package-tools/src/rollupFiles.mjs'
2
+ import getFiles from 'w-package-tools/src/getFiles.mjs'
3
+
4
+
5
+ let fdSrc = './src'
6
+ let fdTar = './dist'
7
+
8
+
9
+ rollupFiles({
10
+ fns: 'WDwdataHub.mjs',
11
+ fdSrc,
12
+ fdTar,
13
+ nameDistType: 'kebabCase', //直接由hookNameDist給予
14
+ globals: {
15
+ 'util': 'util',
16
+ 'path': 'path',
17
+ 'module': 'module',
18
+ 'http': 'http',
19
+ 'https': 'https',
20
+ 'stream': 'stream',
21
+ 'zlib': 'zlib',
22
+ 'events': 'events',
23
+ 'buffer': 'buffer',
24
+ 'cheerio': 'cheerio',
25
+ 'rss-parser': 'rss-parser',
26
+ 'playwright': 'playwright',
27
+ 'w-fetch-web': 'w-fetch-web',
28
+ '@mozilla/readability': '@mozilla/readability',
29
+ 'jsdom': 'jsdom',
30
+ },
31
+ external: [
32
+ 'util',
33
+ 'path',
34
+ 'module',
35
+ 'http',
36
+ 'https',
37
+ 'stream',
38
+ 'zlib',
39
+ 'events',
40
+ 'buffer',
41
+ 'cheerio',
42
+ 'rss-parser',
43
+ 'playwright',
44
+ 'w-fetch-web',
45
+ '@mozilla/readability',
46
+ 'jsdom',
47
+ ],
48
+ })
49
+
@@ -0,0 +1,4 @@
1
+ import modifyReadme from 'w-package-tools/src/modifyReadme.mjs'
2
+
3
+
4
+ modifyReadme()