@ttkit/daily-hot-api 0.0.0-stage → 0.1.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.
- package/.env.example +77 -0
- package/LICENSE +21 -0
- package/README.md +315 -2
- package/bin/daily-hot-api.js +25 -0
- package/dist/app.controller.d.ts +41 -0
- package/dist/app.controller.js +91 -0
- package/dist/app.controller.js.map +1 -0
- package/dist/app.module.d.ts +4 -0
- package/dist/app.module.js +44 -0
- package/dist/app.module.js.map +1 -0
- package/dist/app.service.d.ts +19 -0
- package/dist/app.service.js +57 -0
- package/dist/app.service.js.map +1 -0
- package/dist/cache/cache.module.d.ts +2 -0
- package/dist/cache/cache.module.js +52 -0
- package/dist/cache/cache.module.js.map +1 -0
- package/dist/cache/cache.service.d.ts +26 -0
- package/dist/cache/cache.service.js +163 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cli/args.d.ts +24 -0
- package/dist/cli/args.js +261 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +3 -0
- package/dist/cli/commands/logs.js +55 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/restart.d.ts +3 -0
- package/dist/cli/commands/restart.js +62 -0
- package/dist/cli/commands/restart.js.map +1 -0
- package/dist/cli/commands/start.d.ts +3 -0
- package/dist/cli/commands/start.js +280 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.js +78 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +12 -0
- package/dist/cli/commands/stop.js +135 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/context.d.ts +4 -0
- package/dist/cli/context.js +3 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/env.d.ts +2 -0
- package/dist/cli/env.js +80 -0
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/errors.d.ts +14 -0
- package/dist/cli/errors.js +25 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/health.d.ts +2 -0
- package/dist/cli/health.js +44 -0
- package/dist/cli/health.js.map +1 -0
- package/dist/cli/help.d.ts +3 -0
- package/dist/cli/help.js +158 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +94 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/log-file.d.ts +8 -0
- package/dist/cli/log-file.js +58 -0
- package/dist/cli/log-file.js.map +1 -0
- package/dist/cli/output.d.ts +7 -0
- package/dist/cli/output.js +46 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/paths.d.ts +33 -0
- package/dist/cli/paths.js +76 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/run-state.d.ts +25 -0
- package/dist/cli/run-state.js +159 -0
- package/dist/cli/run-state.js.map +1 -0
- package/dist/common/middlewares/logger.middleware.d.ts +7 -0
- package/dist/common/middlewares/logger.middleware.js +29 -0
- package/dist/common/middlewares/logger.middleware.js.map +1 -0
- package/dist/config/config.module.d.ts +2 -0
- package/dist/config/config.module.js +47 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/configuration.d.ts +3 -0
- package/dist/config/configuration.js +5 -0
- package/dist/config/configuration.js.map +1 -0
- package/dist/config/validation.schema.d.ts +114 -0
- package/dist/config/validation.schema.js +69 -0
- package/dist/config/validation.schema.js.map +1 -0
- package/dist/daily-brief/clients/ai-analysis.client.d.ts +20 -0
- package/dist/daily-brief/clients/ai-analysis.client.js +217 -0
- package/dist/daily-brief/clients/ai-analysis.client.js.map +1 -0
- package/dist/daily-brief/clients/brief-search.service.d.ts +11 -0
- package/dist/daily-brief/clients/brief-search.service.js +52 -0
- package/dist/daily-brief/clients/brief-search.service.js.map +1 -0
- package/dist/daily-brief/clients/deepseek-search.client.d.ts +11 -0
- package/dist/daily-brief/clients/deepseek-search.client.js +70 -0
- package/dist/daily-brief/clients/deepseek-search.client.js.map +1 -0
- package/dist/daily-brief/clients/tavily-search.client.d.ts +11 -0
- package/dist/daily-brief/clients/tavily-search.client.js +72 -0
- package/dist/daily-brief/clients/tavily-search.client.js.map +1 -0
- package/dist/daily-brief/daily-brief.config.d.ts +31 -0
- package/dist/daily-brief/daily-brief.config.js +108 -0
- package/dist/daily-brief/daily-brief.config.js.map +1 -0
- package/dist/daily-brief/daily-brief.controller.d.ts +72 -0
- package/dist/daily-brief/daily-brief.controller.js +169 -0
- package/dist/daily-brief/daily-brief.controller.js.map +1 -0
- package/dist/daily-brief/daily-brief.module.d.ts +2 -0
- package/dist/daily-brief/daily-brief.module.js +49 -0
- package/dist/daily-brief/daily-brief.module.js.map +1 -0
- package/dist/daily-brief/daily-brief.scheduler.d.ts +30 -0
- package/dist/daily-brief/daily-brief.scheduler.js +113 -0
- package/dist/daily-brief/daily-brief.scheduler.js.map +1 -0
- package/dist/daily-brief/daily-brief.service.d.ts +101 -0
- package/dist/daily-brief/daily-brief.service.js +412 -0
- package/dist/daily-brief/daily-brief.service.js.map +1 -0
- package/dist/daily-brief/dto/brief-date-param.dto.d.ts +3 -0
- package/dist/daily-brief/dto/brief-date-param.dto.js +23 -0
- package/dist/daily-brief/dto/brief-date-param.dto.js.map +1 -0
- package/dist/daily-brief/dto/generate-brief.dto.d.ts +6 -0
- package/dist/daily-brief/dto/generate-brief.dto.js +39 -0
- package/dist/daily-brief/dto/generate-brief.dto.js.map +1 -0
- package/dist/daily-brief/dto/list-briefs-query.dto.d.ts +6 -0
- package/dist/daily-brief/dto/list-briefs-query.dto.js +42 -0
- package/dist/daily-brief/dto/list-briefs-query.dto.js.map +1 -0
- package/dist/daily-brief/dto/stock-ranking-query.dto.d.ts +6 -0
- package/dist/daily-brief/dto/stock-ranking-query.dto.js +46 -0
- package/dist/daily-brief/dto/stock-ranking-query.dto.js.map +1 -0
- package/dist/daily-brief/interfaces/daily-brief.interface.d.ts +59 -0
- package/dist/daily-brief/interfaces/daily-brief.interface.js +3 -0
- package/dist/daily-brief/interfaces/daily-brief.interface.js.map +1 -0
- package/dist/daily-brief/interfaces/search-provider.interface.d.ts +11 -0
- package/dist/daily-brief/interfaces/search-provider.interface.js +3 -0
- package/dist/daily-brief/interfaces/search-provider.interface.js.map +1 -0
- package/dist/daily-brief/utils/brief-date.d.ts +2 -0
- package/dist/daily-brief/utils/brief-date.js +16 -0
- package/dist/daily-brief/utils/brief-date.js.map +1 -0
- package/dist/daily-brief/utils/concurrency.d.ts +1 -0
- package/dist/daily-brief/utils/concurrency.js +20 -0
- package/dist/daily-brief/utils/concurrency.js.map +1 -0
- package/dist/database/database.module.d.ts +2 -0
- package/dist/database/database.module.js +57 -0
- package/dist/database/database.module.js.map +1 -0
- package/dist/database/repositories/daily-brief.repository.d.ts +96 -0
- package/dist/database/repositories/daily-brief.repository.js +457 -0
- package/dist/database/repositories/daily-brief.repository.js.map +1 -0
- package/dist/database/repositories/hot-item.repository.d.ts +52 -0
- package/dist/database/repositories/hot-item.repository.js +255 -0
- package/dist/database/repositories/hot-item.repository.js.map +1 -0
- package/dist/database/repositories/source-config.repository.d.ts +15 -0
- package/dist/database/repositories/source-config.repository.js +77 -0
- package/dist/database/repositories/source-config.repository.js.map +1 -0
- package/dist/database/schemas/daily-brief.schema.d.ts +30 -0
- package/dist/database/schemas/daily-brief.schema.js +103 -0
- package/dist/database/schemas/daily-brief.schema.js.map +1 -0
- package/dist/database/schemas/hot-item.schema.d.ts +20 -0
- package/dist/database/schemas/hot-item.schema.js +72 -0
- package/dist/database/schemas/hot-item.schema.js.map +1 -0
- package/dist/database/schemas/source-config.schema.d.ts +15 -0
- package/dist/database/schemas/source-config.schema.js +47 -0
- package/dist/database/schemas/source-config.schema.js.map +1 -0
- package/dist/history/dto/history-response.dto.d.ts +17 -0
- package/dist/history/dto/history-response.dto.js +13 -0
- package/dist/history/dto/history-response.dto.js.map +1 -0
- package/dist/history/dto/search-history.dto.d.ts +10 -0
- package/dist/history/dto/search-history.dto.js +72 -0
- package/dist/history/dto/search-history.dto.js.map +1 -0
- package/dist/history/history.controller.d.ts +13 -0
- package/dist/history/history.controller.js +92 -0
- package/dist/history/history.controller.js.map +1 -0
- package/dist/history/history.module.d.ts +2 -0
- package/dist/history/history.module.js +25 -0
- package/dist/history/history.module.js.map +1 -0
- package/dist/history/history.service.d.ts +15 -0
- package/dist/history/history.service.js +68 -0
- package/dist/history/history.service.js.map +1 -0
- package/dist/host-lists/decorators/hot-source.decorator.d.ts +9 -0
- package/dist/host-lists/decorators/hot-source.decorator.js +11 -0
- package/dist/host-lists/decorators/hot-source.decorator.js.map +1 -0
- package/dist/host-lists/dto/hot-list.dto.d.ts +14 -0
- package/dist/host-lists/dto/hot-list.dto.js +94 -0
- package/dist/host-lists/dto/hot-list.dto.js.map +1 -0
- package/dist/host-lists/hot-lists.controller.d.ts +39 -0
- package/dist/host-lists/hot-lists.controller.js +87 -0
- package/dist/host-lists/hot-lists.controller.js.map +1 -0
- package/dist/host-lists/hot-lists.module.d.ts +2 -0
- package/dist/host-lists/hot-lists.module.js +36 -0
- package/dist/host-lists/hot-lists.module.js.map +1 -0
- package/dist/host-lists/hot-lists.service.d.ts +21 -0
- package/dist/host-lists/hot-lists.service.js +115 -0
- package/dist/host-lists/hot-lists.service.js.map +1 -0
- package/dist/host-lists/interfaces/hot-list-source.interface.d.ts +5 -0
- package/dist/host-lists/interfaces/hot-list-source.interface.js +3 -0
- package/dist/host-lists/interfaces/hot-list-source.interface.js.map +1 -0
- package/dist/host-lists/interfaces/hot-list.interface.d.ts +31 -0
- package/dist/host-lists/interfaces/hot-list.interface.js +3 -0
- package/dist/host-lists/interfaces/hot-list.interface.js.map +1 -0
- package/dist/host-lists/interfaces/router-data.interface.d.ts +19 -0
- package/dist/host-lists/interfaces/router-data.interface.js +3 -0
- package/dist/host-lists/interfaces/router-data.interface.js.map +1 -0
- package/dist/host-lists/sources/36kr.source.d.ts +9 -0
- package/dist/host-lists/sources/36kr.source.js +89 -0
- package/dist/host-lists/sources/36kr.source.js.map +1 -0
- package/dist/host-lists/sources/51cto.source.d.ts +11 -0
- package/dist/host-lists/sources/51cto.source.js +71 -0
- package/dist/host-lists/sources/51cto.source.js.map +1 -0
- package/dist/host-lists/sources/52pojie.source.d.ts +9 -0
- package/dist/host-lists/sources/52pojie.source.js +109 -0
- package/dist/host-lists/sources/52pojie.source.js.map +1 -0
- package/dist/host-lists/sources/acfun.source.d.ts +9 -0
- package/dist/host-lists/sources/acfun.source.js +90 -0
- package/dist/host-lists/sources/acfun.source.js.map +1 -0
- package/dist/host-lists/sources/baidu.source.d.ts +9 -0
- package/dist/host-lists/sources/baidu.source.js +85 -0
- package/dist/host-lists/sources/baidu.source.js.map +1 -0
- package/dist/host-lists/sources/bilibili.source.d.ts +14 -0
- package/dist/host-lists/sources/bilibili.source.js +188 -0
- package/dist/host-lists/sources/bilibili.source.js.map +1 -0
- package/dist/host-lists/sources/caixin.source.d.ts +9 -0
- package/dist/host-lists/sources/caixin.source.js +102 -0
- package/dist/host-lists/sources/caixin.source.js.map +1 -0
- package/dist/host-lists/sources/cls.source.d.ts +9 -0
- package/dist/host-lists/sources/cls.source.js +62 -0
- package/dist/host-lists/sources/cls.source.js.map +1 -0
- package/dist/host-lists/sources/coolapk.source.d.ts +9 -0
- package/dist/host-lists/sources/coolapk.source.js +57 -0
- package/dist/host-lists/sources/coolapk.source.js.map +1 -0
- package/dist/host-lists/sources/csdn.source.d.ts +9 -0
- package/dist/host-lists/sources/csdn.source.js +59 -0
- package/dist/host-lists/sources/csdn.source.js.map +1 -0
- package/dist/host-lists/sources/dgtle.source.d.ts +9 -0
- package/dist/host-lists/sources/dgtle.source.js +57 -0
- package/dist/host-lists/sources/dgtle.source.js.map +1 -0
- package/dist/host-lists/sources/douban-group.source.d.ts +11 -0
- package/dist/host-lists/sources/douban-group.source.js +100 -0
- package/dist/host-lists/sources/douban-group.source.js.map +1 -0
- package/dist/host-lists/sources/douban-movie.source.d.ts +10 -0
- package/dist/host-lists/sources/douban-movie.source.js +103 -0
- package/dist/host-lists/sources/douban-movie.source.js.map +1 -0
- package/dist/host-lists/sources/douyin.d.ts +16 -0
- package/dist/host-lists/sources/douyin.js +215 -0
- package/dist/host-lists/sources/douyin.js.map +1 -0
- package/dist/host-lists/sources/eastmoney-stock.source.d.ts +11 -0
- package/dist/host-lists/sources/eastmoney-stock.source.js +151 -0
- package/dist/host-lists/sources/eastmoney-stock.source.js.map +1 -0
- package/dist/host-lists/sources/eastmoney.source.d.ts +9 -0
- package/dist/host-lists/sources/eastmoney.source.js +86 -0
- package/dist/host-lists/sources/eastmoney.source.js.map +1 -0
- package/dist/host-lists/sources/geekpark.source.d.ts +9 -0
- package/dist/host-lists/sources/geekpark.source.js +60 -0
- package/dist/host-lists/sources/geekpark.source.js.map +1 -0
- package/dist/host-lists/sources/gelonghui.source.d.ts +9 -0
- package/dist/host-lists/sources/gelonghui.source.js +139 -0
- package/dist/host-lists/sources/gelonghui.source.js.map +1 -0
- package/dist/host-lists/sources/github.source.d.ts +12 -0
- package/dist/host-lists/sources/github.source.js +171 -0
- package/dist/host-lists/sources/github.source.js.map +1 -0
- package/dist/host-lists/sources/guokr.source.d.ts +11 -0
- package/dist/host-lists/sources/guokr.source.js +98 -0
- package/dist/host-lists/sources/guokr.source.js.map +1 -0
- package/dist/host-lists/sources/hackernews.source.d.ts +11 -0
- package/dist/host-lists/sources/hackernews.source.js +121 -0
- package/dist/host-lists/sources/hackernews.source.js.map +1 -0
- package/dist/host-lists/sources/hellogithub.source.d.ts +11 -0
- package/dist/host-lists/sources/hellogithub.source.js +98 -0
- package/dist/host-lists/sources/hellogithub.source.js.map +1 -0
- package/dist/host-lists/sources/history.source.d.ts +11 -0
- package/dist/host-lists/sources/history.source.js +92 -0
- package/dist/host-lists/sources/history.source.js.map +1 -0
- package/dist/host-lists/sources/honkai.source.d.ts +9 -0
- package/dist/host-lists/sources/honkai.source.js +72 -0
- package/dist/host-lists/sources/honkai.source.js.map +1 -0
- package/dist/host-lists/sources/hostloc.source.d.ts +9 -0
- package/dist/host-lists/sources/hostloc.source.js +75 -0
- package/dist/host-lists/sources/hostloc.source.js.map +1 -0
- package/dist/host-lists/sources/hupu.source.d.ts +9 -0
- package/dist/host-lists/sources/hupu.source.js +73 -0
- package/dist/host-lists/sources/hupu.source.js.map +1 -0
- package/dist/host-lists/sources/huxiu.source.d.ts +9 -0
- package/dist/host-lists/sources/huxiu.source.js +153 -0
- package/dist/host-lists/sources/huxiu.source.js.map +1 -0
- package/dist/host-lists/sources/ifanr.source.d.ts +9 -0
- package/dist/host-lists/sources/ifanr.source.js +57 -0
- package/dist/host-lists/sources/ifanr.source.js.map +1 -0
- package/dist/host-lists/sources/index.d.ts +2 -0
- package/dist/host-lists/sources/index.js +134 -0
- package/dist/host-lists/sources/index.js.map +1 -0
- package/dist/host-lists/sources/ithome-xijiayi.source.d.ts +9 -0
- package/dist/host-lists/sources/ithome-xijiayi.source.js +75 -0
- package/dist/host-lists/sources/ithome-xijiayi.source.js.map +1 -0
- package/dist/host-lists/sources/ithome.source.d.ts +9 -0
- package/dist/host-lists/sources/ithome.source.js +71 -0
- package/dist/host-lists/sources/ithome.source.js.map +1 -0
- package/dist/host-lists/sources/jd.source.d.ts +9 -0
- package/dist/host-lists/sources/jd.source.js +82 -0
- package/dist/host-lists/sources/jd.source.js.map +1 -0
- package/dist/host-lists/sources/jianshu.source.d.ts +9 -0
- package/dist/host-lists/sources/jianshu.source.js +72 -0
- package/dist/host-lists/sources/jianshu.source.js.map +1 -0
- package/dist/host-lists/sources/jin10.source.d.ts +9 -0
- package/dist/host-lists/sources/jin10.source.js +63 -0
- package/dist/host-lists/sources/jin10.source.js.map +1 -0
- package/dist/host-lists/sources/juejin.source.d.ts +10 -0
- package/dist/host-lists/sources/juejin.source.js +81 -0
- package/dist/host-lists/sources/juejin.source.js.map +1 -0
- package/dist/host-lists/sources/kuaishou.source.d.ts +13 -0
- package/dist/host-lists/sources/kuaishou.source.js +179 -0
- package/dist/host-lists/sources/kuaishou.source.js.map +1 -0
- package/dist/host-lists/sources/linuxdo.source.d.ts +9 -0
- package/dist/host-lists/sources/linuxdo.source.js +62 -0
- package/dist/host-lists/sources/linuxdo.source.js.map +1 -0
- package/dist/host-lists/sources/lol.source.d.ts +9 -0
- package/dist/host-lists/sources/lol.source.js +58 -0
- package/dist/host-lists/sources/lol.source.js.map +1 -0
- package/dist/host-lists/sources/miyoushe.source.d.ts +9 -0
- package/dist/host-lists/sources/miyoushe.source.js +88 -0
- package/dist/host-lists/sources/miyoushe.source.js.map +1 -0
- package/dist/host-lists/sources/netease-news.source.d.ts +9 -0
- package/dist/host-lists/sources/netease-news.source.js +56 -0
- package/dist/host-lists/sources/netease-news.source.js.map +1 -0
- package/dist/host-lists/sources/ngabbs.source.d.ts +9 -0
- package/dist/host-lists/sources/ngabbs.source.js +70 -0
- package/dist/host-lists/sources/ngabbs.source.js.map +1 -0
- package/dist/host-lists/sources/nodeseek.source.d.ts +9 -0
- package/dist/host-lists/sources/nodeseek.source.js +62 -0
- package/dist/host-lists/sources/nodeseek.source.js.map +1 -0
- package/dist/host-lists/sources/nytimes.source.d.ts +9 -0
- package/dist/host-lists/sources/nytimes.source.js +77 -0
- package/dist/host-lists/sources/nytimes.source.js.map +1 -0
- package/dist/host-lists/sources/producthunt.source.d.ts +9 -0
- package/dist/host-lists/sources/producthunt.source.js +75 -0
- package/dist/host-lists/sources/producthunt.source.js.map +1 -0
- package/dist/host-lists/sources/qq-news.source.d.ts +9 -0
- package/dist/host-lists/sources/qq-news.source.js +53 -0
- package/dist/host-lists/sources/qq-news.source.js.map +1 -0
- package/dist/host-lists/sources/sina-news.source.d.ts +9 -0
- package/dist/host-lists/sources/sina-news.source.js +98 -0
- package/dist/host-lists/sources/sina-news.source.js.map +1 -0
- package/dist/host-lists/sources/sina.source.d.ts +9 -0
- package/dist/host-lists/sources/sina.source.js +78 -0
- package/dist/host-lists/sources/sina.source.js.map +1 -0
- package/dist/host-lists/sources/smzdm.source.d.ts +9 -0
- package/dist/host-lists/sources/smzdm.source.js +71 -0
- package/dist/host-lists/sources/smzdm.source.js.map +1 -0
- package/dist/host-lists/sources/sspai.source.d.ts +9 -0
- package/dist/host-lists/sources/sspai.source.js +69 -0
- package/dist/host-lists/sources/sspai.source.js.map +1 -0
- package/dist/host-lists/sources/starrail.source.d.ts +9 -0
- package/dist/host-lists/sources/starrail.source.js +72 -0
- package/dist/host-lists/sources/starrail.source.js.map +1 -0
- package/dist/host-lists/sources/taobao.source.d.ts +10 -0
- package/dist/host-lists/sources/taobao.source.js +169 -0
- package/dist/host-lists/sources/taobao.source.js.map +1 -0
- package/dist/host-lists/sources/thepaper.source.d.ts +9 -0
- package/dist/host-lists/sources/thepaper.source.js +56 -0
- package/dist/host-lists/sources/thepaper.source.js.map +1 -0
- package/dist/host-lists/sources/tieba.source.d.ts +9 -0
- package/dist/host-lists/sources/tieba.source.js +58 -0
- package/dist/host-lists/sources/tieba.source.js.map +1 -0
- package/dist/host-lists/sources/tonghuashun.source.d.ts +9 -0
- package/dist/host-lists/sources/tonghuashun.source.js +112 -0
- package/dist/host-lists/sources/tonghuashun.source.js.map +1 -0
- package/dist/host-lists/sources/toutiao.source.d.ts +9 -0
- package/dist/host-lists/sources/toutiao.source.js +56 -0
- package/dist/host-lists/sources/toutiao.source.js.map +1 -0
- package/dist/host-lists/sources/v2ex.source.d.ts +9 -0
- package/dist/host-lists/sources/v2ex.source.js +67 -0
- package/dist/host-lists/sources/v2ex.source.js.map +1 -0
- package/dist/host-lists/sources/wallstreet.source.d.ts +9 -0
- package/dist/host-lists/sources/wallstreet.source.js +59 -0
- package/dist/host-lists/sources/wallstreet.source.js.map +1 -0
- package/dist/host-lists/sources/weatheralarm.source.d.ts +9 -0
- package/dist/host-lists/sources/weatheralarm.source.js +68 -0
- package/dist/host-lists/sources/weatheralarm.source.js.map +1 -0
- package/dist/host-lists/sources/weibo.source.d.ts +15 -0
- package/dist/host-lists/sources/weibo.source.js +180 -0
- package/dist/host-lists/sources/weibo.source.js.map +1 -0
- package/dist/host-lists/sources/weread.source.d.ts +9 -0
- package/dist/host-lists/sources/weread.source.js +82 -0
- package/dist/host-lists/sources/weread.source.js.map +1 -0
- package/dist/host-lists/sources/xinyu.source.d.ts +9 -0
- package/dist/host-lists/sources/xinyu.source.js +151 -0
- package/dist/host-lists/sources/xinyu.source.js.map +1 -0
- package/dist/host-lists/sources/yicai.source.d.ts +9 -0
- package/dist/host-lists/sources/yicai.source.js +113 -0
- package/dist/host-lists/sources/yicai.source.js.map +1 -0
- package/dist/host-lists/sources/yystv.source.d.ts +9 -0
- package/dist/host-lists/sources/yystv.source.js +57 -0
- package/dist/host-lists/sources/yystv.source.js.map +1 -0
- package/dist/host-lists/sources/zhihu-daily.source.d.ts +9 -0
- package/dist/host-lists/sources/zhihu-daily.source.js +60 -0
- package/dist/host-lists/sources/zhihu-daily.source.js.map +1 -0
- package/dist/host-lists/sources/zhihu.source.d.ts +12 -0
- package/dist/host-lists/sources/zhihu.source.js +195 -0
- package/dist/host-lists/sources/zhihu.source.js.map +1 -0
- package/dist/http/http.module.d.ts +2 -0
- package/dist/http/http.module.js +30 -0
- package/dist/http/http.module.js.map +1 -0
- package/dist/http/http.service.d.ts +53 -0
- package/dist/http/http.service.js +277 -0
- package/dist/http/http.service.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +70 -0
- package/dist/main.js.map +1 -0
- package/dist/rss/rss.module.d.ts +2 -0
- package/dist/rss/rss.module.js +21 -0
- package/dist/rss/rss.module.js.map +1 -0
- package/dist/rss/rss.service.d.ts +5 -0
- package/dist/rss/rss.service.js +55 -0
- package/dist/rss/rss.service.js.map +1 -0
- package/dist/scheduler/dto/trigger-fetch.dto.d.ts +3 -0
- package/dist/scheduler/dto/trigger-fetch.dto.js +22 -0
- package/dist/scheduler/dto/trigger-fetch.dto.js.map +1 -0
- package/dist/scheduler/dto/update-source-config.dto.d.ts +4 -0
- package/dist/scheduler/dto/update-source-config.dto.js +29 -0
- package/dist/scheduler/dto/update-source-config.dto.js.map +1 -0
- package/dist/scheduler/scheduler.controller.d.ts +52 -0
- package/dist/scheduler/scheduler.controller.js +132 -0
- package/dist/scheduler/scheduler.controller.js.map +1 -0
- package/dist/scheduler/scheduler.module.d.ts +2 -0
- package/dist/scheduler/scheduler.module.js +34 -0
- package/dist/scheduler/scheduler.module.js.map +1 -0
- package/dist/scheduler/scheduler.service.d.ts +54 -0
- package/dist/scheduler/scheduler.service.js +238 -0
- package/dist/scheduler/scheduler.service.js.map +1 -0
- package/dist/scheduler/tasks/fetch-hot-data.task.d.ts +34 -0
- package/dist/scheduler/tasks/fetch-hot-data.task.js +175 -0
- package/dist/scheduler/tasks/fetch-hot-data.task.js.map +1 -0
- package/dist/token/coolapk.d.ts +11 -0
- package/dist/token/coolapk.js +40 -0
- package/dist/token/coolapk.js.map +1 -0
- package/dist/token/token.module.d.ts +2 -0
- package/dist/token/token.module.js +23 -0
- package/dist/token/token.module.js.map +1 -0
- package/dist/token/token.service.d.ts +19 -0
- package/dist/token/token.service.js +115 -0
- package/dist/token/token.service.js.map +1 -0
- package/dist/token/tools.d.ts +1 -0
- package/dist/token/tools.js +15 -0
- package/dist/token/tools.js.map +1 -0
- package/dist/token/weread.d.ts +2 -0
- package/dist/token/weread.js +55 -0
- package/dist/token/weread.js.map +1 -0
- package/dist/utils/getNum.d.ts +1 -0
- package/dist/utils/getNum.js +20 -0
- package/dist/utils/getNum.js.map +1 -0
- package/dist/utils/getTime.d.ts +11 -0
- package/dist/utils/getTime.js +134 -0
- package/dist/utils/getTime.js.map +1 -0
- package/dist/utils/headers.d.ts +16 -0
- package/dist/utils/headers.js +20 -0
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/parseRSS.d.ts +11 -0
- package/dist/utils/parseRSS.js +47 -0
- package/dist/utils/parseRSS.js.map +1 -0
- package/package.json +148 -4
- package/views/home.hbs +65 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stopCommand = stopCommand;
|
|
4
|
+
exports.stopService = stopService;
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const output_1 = require("../output");
|
|
7
|
+
const paths_1 = require("../paths");
|
|
8
|
+
const run_state_1 = require("../run-state");
|
|
9
|
+
async function stopCommand(options, context = {}) {
|
|
10
|
+
const outcome = await stopService(options, context);
|
|
11
|
+
if (options.json) {
|
|
12
|
+
console.log(JSON.stringify(outcome));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
(0, output_1.info)(outcome.message);
|
|
16
|
+
}
|
|
17
|
+
return outcome.stopped ? errors_1.EXIT_CODES.ok : errors_1.EXIT_CODES.error;
|
|
18
|
+
}
|
|
19
|
+
async function stopService(options, context = {}) {
|
|
20
|
+
const cwd = context.cwd ?? process.cwd();
|
|
21
|
+
const env = context.env ?? process.env;
|
|
22
|
+
const homeDir = (0, paths_1.resolveHomeDir)({ home: options.home, cwd, env });
|
|
23
|
+
const paths = (0, paths_1.buildCliPaths)(homeDir);
|
|
24
|
+
const existing = (0, run_state_1.readRunState)(paths.stateFile);
|
|
25
|
+
if (existing.corrupt) {
|
|
26
|
+
(0, run_state_1.clearRunState)(paths.stateFile);
|
|
27
|
+
return {
|
|
28
|
+
stopped: true,
|
|
29
|
+
stale: true,
|
|
30
|
+
forced: false,
|
|
31
|
+
message: `运行状态文件损坏,已清理: ${paths.stateFile}(热点服务未在运行)`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const state = existing.state;
|
|
35
|
+
if (!state) {
|
|
36
|
+
return {
|
|
37
|
+
stopped: true,
|
|
38
|
+
stale: false,
|
|
39
|
+
forced: false,
|
|
40
|
+
message: '热点服务未在运行',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (!(0, run_state_1.isProcessAlive)(state.pid)) {
|
|
44
|
+
(0, run_state_1.clearRunState)(paths.stateFile, state.pid);
|
|
45
|
+
return {
|
|
46
|
+
stopped: true,
|
|
47
|
+
stale: true,
|
|
48
|
+
forced: false,
|
|
49
|
+
pid: state.pid,
|
|
50
|
+
port: state.port,
|
|
51
|
+
message: `热点服务未在运行(PID ${state.pid} 已退出,已清理过期状态文件)`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const trusted = (0, run_state_1.processLooksLikeService)(state.pid, (0, paths_1.getPackageRoot)());
|
|
55
|
+
if (!trusted && !options.force) {
|
|
56
|
+
return {
|
|
57
|
+
stopped: false,
|
|
58
|
+
stale: false,
|
|
59
|
+
forced: false,
|
|
60
|
+
pid: state.pid,
|
|
61
|
+
port: state.port,
|
|
62
|
+
message: `PID ${state.pid} 存在但无法确认是 ${paths_1.APP_NAME} 进程,已跳过停止。` +
|
|
63
|
+
`若确认该进程属于本服务,请执行: ${paths_1.APP_NAME} stop --force;或手动删除状态文件 ${paths.stateFile}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (options.force) {
|
|
67
|
+
(0, output_1.warn)(`--force: 直接发送 SIGKILL 终止 PID ${state.pid}`);
|
|
68
|
+
try {
|
|
69
|
+
process.kill(state.pid, 'SIGKILL');
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error.code !== 'ESRCH') {
|
|
73
|
+
throw new errors_1.CliError(`发送 SIGKILL 失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const killed = await (0, run_state_1.waitForProcessExit)(state.pid, 5000);
|
|
77
|
+
if (!killed && (0, run_state_1.isProcessAlive)(state.pid)) {
|
|
78
|
+
throw new errors_1.CliError(`无法终止进程 ${state.pid},请手动执行: kill -9 ${state.pid}`);
|
|
79
|
+
}
|
|
80
|
+
(0, run_state_1.clearRunState)(paths.stateFile, state.pid);
|
|
81
|
+
return {
|
|
82
|
+
stopped: true,
|
|
83
|
+
stale: false,
|
|
84
|
+
forced: true,
|
|
85
|
+
pid: state.pid,
|
|
86
|
+
port: state.port,
|
|
87
|
+
message: `已强制停止热点服务(PID ${state.pid})`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
(0, output_1.progress)(`正在停止热点服务(PID ${state.pid},端口 ${state.port})...`);
|
|
91
|
+
try {
|
|
92
|
+
process.kill(state.pid, 'SIGTERM');
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error.code === 'ESRCH') {
|
|
96
|
+
(0, run_state_1.clearRunState)(paths.stateFile, state.pid);
|
|
97
|
+
return {
|
|
98
|
+
stopped: true,
|
|
99
|
+
stale: true,
|
|
100
|
+
forced: false,
|
|
101
|
+
pid: state.pid,
|
|
102
|
+
port: state.port,
|
|
103
|
+
message: `热点服务未在运行(PID ${state.pid} 已退出,已清理过期状态文件)`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
throw new errors_1.CliError(`发送停止信号失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
let forced = false;
|
|
109
|
+
const exited = await (0, run_state_1.waitForProcessExit)(state.pid, options.timeoutSeconds * 1000);
|
|
110
|
+
if (!exited) {
|
|
111
|
+
forced = true;
|
|
112
|
+
(0, output_1.warn)(`进程在 ${options.timeoutSeconds} 秒内未退出,发送 SIGKILL`);
|
|
113
|
+
try {
|
|
114
|
+
process.kill(state.pid, 'SIGKILL');
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
}
|
|
118
|
+
const killed = await (0, run_state_1.waitForProcessExit)(state.pid, 5000);
|
|
119
|
+
if (!killed && (0, run_state_1.isProcessAlive)(state.pid)) {
|
|
120
|
+
throw new errors_1.CliError(`无法停止进程 ${state.pid},请手动执行: kill -9 ${state.pid}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
(0, run_state_1.clearRunState)(paths.stateFile, state.pid);
|
|
124
|
+
return {
|
|
125
|
+
stopped: true,
|
|
126
|
+
stale: false,
|
|
127
|
+
forced,
|
|
128
|
+
pid: state.pid,
|
|
129
|
+
port: state.port,
|
|
130
|
+
message: forced
|
|
131
|
+
? `已强制停止热点服务(PID ${state.pid})`
|
|
132
|
+
: `热点服务已停止(PID ${state.pid})`,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=stop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../src/cli/commands/stop.ts"],"names":[],"mappings":";;AA2BA,kCAWC;AAED,kCAyIC;AA/KD,sCAAiD;AACjD,sCAAiD;AACjD,oCAKkB;AAClB,4CAMsB;AAWf,KAAK,UAAU,WAAW,CAC/B,OAAmB,EACnB,UAAmC,EAAE;IAErC,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,IAAA,aAAI,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAU,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAU,CAAC,KAAK,CAAC;AAC5D,CAAC;AAEM,KAAK,UAAU,WAAW,CAC/B,OAAmB,EACnB,UAAmC,EAAE;IAErC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,IAAA,sBAAc,EAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACjE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,MAAM,GAAG,MAAM,IAAA,8BAAkB,EAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,IAAI,IAAA,0BAAc,EAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,iBAAQ,CAChB,UAAU,KAAK,CAAC,GAAG,mBAAmB,KAAK,CAAC,GAAG,EAAE,CAClD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAA,yBAAa,EAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO;QACL,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,KAAK;QACZ,MAAM;QACN,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,MAAM;YACb,CAAC,CAAC,iBAAiB,KAAK,CAAC,GAAG,GAAG;YAC/B,CAAC,CAAC,eAAe,KAAK,CAAC,GAAG,GAAG;KAChC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/cli/context.ts"],"names":[],"mappings":""}
|
package/dist/cli/env.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.applyEnvFile = applyEnvFile;
|
|
37
|
+
exports.resolvePort = resolvePort;
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const dotenv = __importStar(require("dotenv"));
|
|
40
|
+
const errors_1 = require("./errors");
|
|
41
|
+
const paths_1 = require("./paths");
|
|
42
|
+
function applyEnvFile(envFile, env = process.env) {
|
|
43
|
+
if (!(0, fs_1.existsSync)(envFile)) {
|
|
44
|
+
throw new errors_1.CliError(`配置文件不存在: ${envFile}`);
|
|
45
|
+
}
|
|
46
|
+
let parsed;
|
|
47
|
+
try {
|
|
48
|
+
parsed = dotenv.parse((0, fs_1.readFileSync)(envFile));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
52
|
+
throw new errors_1.CliError(`读取配置文件失败: ${envFile} (${reason})`);
|
|
53
|
+
}
|
|
54
|
+
const applied = [];
|
|
55
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
56
|
+
if (env[key] === undefined) {
|
|
57
|
+
env[key] = value;
|
|
58
|
+
applied.push(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return applied;
|
|
62
|
+
}
|
|
63
|
+
function resolvePort(flagPort, env = process.env) {
|
|
64
|
+
if (flagPort !== undefined) {
|
|
65
|
+
return flagPort;
|
|
66
|
+
}
|
|
67
|
+
const raw = (env.PORT ?? '').trim();
|
|
68
|
+
if (!raw) {
|
|
69
|
+
return paths_1.DEFAULT_PORT;
|
|
70
|
+
}
|
|
71
|
+
if (!/^\d+$/.test(raw)) {
|
|
72
|
+
throw new errors_1.CliError(`环境变量 PORT 配置无效: "${raw}",应为 1-65535 的整数`);
|
|
73
|
+
}
|
|
74
|
+
const port = Number(raw);
|
|
75
|
+
if (port < 1 || port > 65535) {
|
|
76
|
+
throw new errors_1.CliError(`环境变量 PORT 配置无效: "${raw}",应为 1-65535 的整数`);
|
|
77
|
+
}
|
|
78
|
+
return port;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/cli/env.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,oCAwBC;AAKD,kCAsBC;AAhED,2BAA8C;AAC9C,+CAAiC;AACjC,qCAAoC;AACpC,mCAAuC;AAUvC,SAAgB,YAAY,CAC1B,OAAe,EACf,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,iBAAQ,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,MAAgC,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,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AAE,CAAC;QAC7B,MAAM,IAAI,iBAAQ,CAAC,oBAAoB,GAAG,kBAAkB,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const EXIT_CODES: {
|
|
2
|
+
readonly ok: 0;
|
|
3
|
+
readonly error: 1;
|
|
4
|
+
readonly usage: 2;
|
|
5
|
+
readonly notRunning: 3;
|
|
6
|
+
};
|
|
7
|
+
export type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
|
|
8
|
+
export declare class CliError extends Error {
|
|
9
|
+
readonly exitCode: ExitCode;
|
|
10
|
+
constructor(message: string, exitCode?: ExitCode);
|
|
11
|
+
}
|
|
12
|
+
export declare class UsageError extends CliError {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageError = exports.CliError = exports.EXIT_CODES = void 0;
|
|
4
|
+
exports.EXIT_CODES = {
|
|
5
|
+
ok: 0,
|
|
6
|
+
error: 1,
|
|
7
|
+
usage: 2,
|
|
8
|
+
notRunning: 3,
|
|
9
|
+
};
|
|
10
|
+
class CliError extends Error {
|
|
11
|
+
constructor(message, exitCode = exports.EXIT_CODES.error) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'CliError';
|
|
14
|
+
this.exitCode = exitCode;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.CliError = CliError;
|
|
18
|
+
class UsageError extends CliError {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message, exports.EXIT_CODES.usage);
|
|
21
|
+
this.name = 'UsageError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.UsageError = UsageError;
|
|
25
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/cli/errors.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IAExB,EAAE,EAAE,CAAC;IAEL,KAAK,EAAE,CAAC;IAER,KAAK,EAAE,CAAC;IAER,UAAU,EAAE,CAAC;CACL,CAAC;AAIX,MAAa,QAAS,SAAQ,KAAK;IAGjC,YAAY,OAAe,EAAE,WAAqB,kBAAU,CAAC,KAAK;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AARD,4BAQC;AAED,MAAa,UAAW,SAAQ,QAAQ;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAU,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AALD,gCAKC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkHealth = checkHealth;
|
|
4
|
+
exports.waitForHealthy = waitForHealthy;
|
|
5
|
+
const http_1 = require("http");
|
|
6
|
+
const run_state_1 = require("./run-state");
|
|
7
|
+
function checkHealth(port, timeoutMs = 2000, host = '127.0.0.1') {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
let settled = false;
|
|
10
|
+
const finish = (healthy) => {
|
|
11
|
+
if (settled) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
settled = true;
|
|
15
|
+
resolve(healthy);
|
|
16
|
+
};
|
|
17
|
+
const request = (0, http_1.get)({ host, port, path: '/health', timeout: timeoutMs }, (response) => {
|
|
18
|
+
response.resume();
|
|
19
|
+
const statusCode = response.statusCode ?? 0;
|
|
20
|
+
finish(statusCode >= 200 && statusCode < 400);
|
|
21
|
+
});
|
|
22
|
+
request.on('timeout', () => {
|
|
23
|
+
request.destroy();
|
|
24
|
+
finish(false);
|
|
25
|
+
});
|
|
26
|
+
request.on('error', () => {
|
|
27
|
+
finish(false);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function waitForHealthy(port, timeoutMs, intervalMs = 250) {
|
|
32
|
+
const deadline = Date.now() + timeoutMs;
|
|
33
|
+
do {
|
|
34
|
+
if (await checkHealth(port)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (Date.now() >= deadline) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
await (0, run_state_1.sleep)(intervalMs);
|
|
41
|
+
} while (Date.now() < deadline);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/cli/health.ts"],"names":[],"mappings":";;AAIA,kCA+BC;AAED,wCAgBC;AArDD,+BAA2B;AAC3B,2CAAoC;AAGpC,SAAgB,WAAW,CACzB,IAAY,EACZ,SAAS,GAAG,IAAI,EAChB,IAAI,GAAG,WAAW;IAElB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,CAAC,OAAgB,EAAQ,EAAE;YACxC,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,UAAG,EACjB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,EACnD,CAAC,QAAQ,EAAE,EAAE;YACX,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC;YAC5C,MAAM,CAAC,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,CAAC,CAAC;QAChD,CAAC,CACF,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACzB,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,IAAY,EACZ,SAAiB,EACjB,UAAU,GAAG,GAAG;IAEhB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxC,GAAG,CAAC;QACF,IAAI,MAAM,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,IAAA,iBAAK,EAAC,UAAU,CAAC,CAAC;IAC1B,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE;IAChC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/cli/help.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.globalHelp = globalHelp;
|
|
4
|
+
exports.commandHelp = commandHelp;
|
|
5
|
+
const paths_1 = require("./paths");
|
|
6
|
+
function versionOrUnknown() {
|
|
7
|
+
return (0, paths_1.getPackageVersion)();
|
|
8
|
+
}
|
|
9
|
+
const START_HELP = `用法: daily-hot-api [start] [选项]
|
|
10
|
+
|
|
11
|
+
在前台启动热点服务(默认命令)。服务日志直接输出到当前终端,
|
|
12
|
+
按 Ctrl+C 停止;也可以在其他终端执行 daily-hot-api stop。
|
|
13
|
+
|
|
14
|
+
选项:
|
|
15
|
+
-p, --port <端口> 覆盖监听端口(默认取 .env 的 PORT,否则 6689)
|
|
16
|
+
-d, --daemon 在后台启动,日志写入状态目录
|
|
17
|
+
--config <路径> 指定 .env 配置文件(默认顺序: DAILY_HOT_API_ENV_FILE → 当前目录 .env → 状态目录 .env)
|
|
18
|
+
--home <目录> 指定状态目录(默认 ~/.daily-hot-api)
|
|
19
|
+
-h, --help 查看帮助
|
|
20
|
+
|
|
21
|
+
示例:
|
|
22
|
+
daily-hot-api 前台启动
|
|
23
|
+
daily-hot-api -p 6699 前台启动并指定端口
|
|
24
|
+
daily-hot-api start -d 后台启动
|
|
25
|
+
daily-hot-api start -d --port 6699 --config ./prod.env`;
|
|
26
|
+
const STOP_HELP = `用法: daily-hot-api stop [选项]
|
|
27
|
+
|
|
28
|
+
停止由 CLI 启动的热点服务。先发送 SIGTERM 优雅退出,
|
|
29
|
+
超过 --timeout 仍未退出则发送 SIGKILL。
|
|
30
|
+
|
|
31
|
+
选项:
|
|
32
|
+
--timeout <秒> 等待进程退出的超时时间(默认 10 秒)
|
|
33
|
+
--force 跳过进程校验并立即 SIGKILL
|
|
34
|
+
--json 以 JSON 输出结果
|
|
35
|
+
--home <目录> 指定状态目录(默认 ~/.daily-hot-api)
|
|
36
|
+
-h, --help 查看帮助
|
|
37
|
+
|
|
38
|
+
退出码:
|
|
39
|
+
0 已停止(或本来未在运行,幂等)
|
|
40
|
+
1 停止失败`;
|
|
41
|
+
const STATUS_HELP = `用法: daily-hot-api status [选项]
|
|
42
|
+
|
|
43
|
+
查看由 CLI 启动的热点服务状态,包括 PID、端口、运行时长和健康检查。
|
|
44
|
+
|
|
45
|
+
选项:
|
|
46
|
+
--json 以 JSON 输出结果
|
|
47
|
+
--home <目录> 指定状态目录(默认 ~/.daily-hot-api)
|
|
48
|
+
-h, --help 查看帮助
|
|
49
|
+
|
|
50
|
+
退出码:
|
|
51
|
+
0 运行中
|
|
52
|
+
3 未运行`;
|
|
53
|
+
const RESTART_HELP = `用法: daily-hot-api restart [选项]
|
|
54
|
+
|
|
55
|
+
重启由 CLI 启动的热点服务。默认沿用上一次的端口、配置文件和运行模式;
|
|
56
|
+
服务未在运行时等同于 start。
|
|
57
|
+
|
|
58
|
+
选项:
|
|
59
|
+
-d, --daemon 重启后在后台运行
|
|
60
|
+
--foreground 重启后在前台运行
|
|
61
|
+
-p, --port <端口> 覆盖监听端口
|
|
62
|
+
--config <路径> 指定 .env 配置文件
|
|
63
|
+
--timeout <秒> 等待旧进程退出的超时时间(默认 10 秒)
|
|
64
|
+
--force 停止旧进程时立即 SIGKILL
|
|
65
|
+
--home <目录> 指定状态目录(默认 ~/.daily-hot-api)
|
|
66
|
+
-h, --help 查看帮助
|
|
67
|
+
|
|
68
|
+
示例:
|
|
69
|
+
daily-hot-api restart
|
|
70
|
+
daily-hot-api restart -d
|
|
71
|
+
daily-hot-api restart --foreground -p 6699`;
|
|
72
|
+
const LOGS_HELP = `用法: daily-hot-api logs [选项]
|
|
73
|
+
|
|
74
|
+
查看后台服务日志。前台模式的标准输出直接打印在启动终端,
|
|
75
|
+
不会写入日志文件。
|
|
76
|
+
|
|
77
|
+
选项:
|
|
78
|
+
-n, --lines <行数> 显示最后 N 行(默认 50)
|
|
79
|
+
-f, --follow 持续跟踪新增日志,按 Ctrl+C 退出
|
|
80
|
+
--home <目录> 指定状态目录(默认 ~/.daily-hot-api)
|
|
81
|
+
-h, --help 查看帮助
|
|
82
|
+
|
|
83
|
+
示例:
|
|
84
|
+
daily-hot-api logs
|
|
85
|
+
daily-hot-api logs -n 200
|
|
86
|
+
daily-hot-api logs -f`;
|
|
87
|
+
const HELP_HELP = `用法: daily-hot-api help [命令]
|
|
88
|
+
|
|
89
|
+
显示全局帮助或指定命令的帮助。
|
|
90
|
+
|
|
91
|
+
示例:
|
|
92
|
+
daily-hot-api help
|
|
93
|
+
daily-hot-api help start`;
|
|
94
|
+
const VERSION_HELP = `用法: daily-hot-api --version
|
|
95
|
+
|
|
96
|
+
打印当前 CLI 版本。`;
|
|
97
|
+
const COMMAND_HELP = {
|
|
98
|
+
start: START_HELP,
|
|
99
|
+
stop: STOP_HELP,
|
|
100
|
+
status: STATUS_HELP,
|
|
101
|
+
restart: RESTART_HELP,
|
|
102
|
+
logs: LOGS_HELP,
|
|
103
|
+
help: HELP_HELP,
|
|
104
|
+
version: VERSION_HELP,
|
|
105
|
+
};
|
|
106
|
+
function globalHelp() {
|
|
107
|
+
return `daily-hot-api v${versionOrUnknown()}
|
|
108
|
+
|
|
109
|
+
每日热榜聚合 API 服务命令行工具:在前台或后台启动热点服务,并管理其生命周期。
|
|
110
|
+
|
|
111
|
+
用法:
|
|
112
|
+
daily-hot-api [start] [选项] 在前台启动热点服务(默认命令)
|
|
113
|
+
daily-hot-api start -d [选项] 在后台启动热点服务
|
|
114
|
+
daily-hot-api stop [选项] 停止由 CLI 启动的热点服务
|
|
115
|
+
daily-hot-api restart [选项] 重启热点服务
|
|
116
|
+
daily-hot-api status [选项] 查看服务状态(未运行时退出码 3)
|
|
117
|
+
daily-hot-api logs [选项] 查看或跟踪后台服务日志
|
|
118
|
+
daily-hot-api help [命令] 查看命令帮助
|
|
119
|
+
daily-hot-api --version 查看版本
|
|
120
|
+
|
|
121
|
+
常用选项:
|
|
122
|
+
-p, --port <端口> 覆盖监听端口(默认取 .env 的 PORT,否则 6689)
|
|
123
|
+
-d, --daemon 在后台运行(start/restart)
|
|
124
|
+
--foreground 在前台运行(restart 用来覆盖原模式)
|
|
125
|
+
--config <路径> 指定 .env 配置文件
|
|
126
|
+
--home <目录> 指定状态目录(默认 ~/.daily-hot-api)
|
|
127
|
+
--timeout <秒> stop/restart 等待退出的超时时间(默认 10 秒)
|
|
128
|
+
--force 强制结束进程(SIGKILL,stop/restart)
|
|
129
|
+
--json 以 JSON 输出(status/stop)
|
|
130
|
+
-n, --lines <行数> logs 显示的行数(默认 50)
|
|
131
|
+
-f, --follow logs 持续跟踪新增日志
|
|
132
|
+
-h, --help 查看帮助
|
|
133
|
+
-v, --version 查看版本
|
|
134
|
+
|
|
135
|
+
示例:
|
|
136
|
+
daily-hot-api 前台启动,默认端口 6689
|
|
137
|
+
daily-hot-api -p 6699 前台启动并指定端口
|
|
138
|
+
daily-hot-api start -d 后台启动
|
|
139
|
+
daily-hot-api status 查看状态
|
|
140
|
+
daily-hot-api logs -f 跟踪后台日志
|
|
141
|
+
daily-hot-api stop 停止服务
|
|
142
|
+
npx daily-hot-api start -d 不全局安装,直接用 npx 后台启动
|
|
143
|
+
|
|
144
|
+
环境变量:
|
|
145
|
+
PORT 服务端口
|
|
146
|
+
DAILY_HOT_API_HOME 状态目录,默认 ~/.daily-hot-api
|
|
147
|
+
DAILY_HOT_API_ENV_FILE 显式指定 .env 文件(等同于 --config)
|
|
148
|
+
|
|
149
|
+
首次使用: 在运行目录准备 .env(可复制 .env.example),或使用 --config 指定。
|
|
150
|
+
文档: https://helti.github.io/daily-hot-api/guide/cli`;
|
|
151
|
+
}
|
|
152
|
+
function commandHelp(command) {
|
|
153
|
+
if (command === 'version') {
|
|
154
|
+
return `daily-hot-api v${versionOrUnknown()}\n\n${VERSION_HELP}`;
|
|
155
|
+
}
|
|
156
|
+
return COMMAND_HELP[command];
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":";;AAgHA,gCA6CC;AAED,kCAKC;AAnKD,mCAA4C;AAE5C,SAAS,gBAAgB;IACvB,OAAO,IAAA,yBAAiB,GAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;yDAgBsC,CAAC;AAE1D,MAAM,SAAS,GAAG;;;;;;;;;;;;;;UAcR,CAAC;AAEX,MAAM,WAAW,GAAG;;;;;;;;;;;SAWX,CAAC;AAEV,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;6CAkBwB,CAAC;AAE9C,MAAM,SAAS,GAAG;;;;;;;;;;;;;;wBAcM,CAAC;AAEzB,MAAM,SAAS,GAAG;;;;;;2BAMS,CAAC;AAE5B,MAAM,YAAY,GAAG;;aAER,CAAC;AAEd,MAAM,YAAY,GAAgC;IAChD,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,YAAY;CACtB,CAAC;AAEF,SAAgB,UAAU;IACxB,OAAO,kBAAkB,gBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDA2CO,CAAC;AACrD,CAAC;AAED,SAAgB,WAAW,CAAC,OAAoB;IAC9C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,kBAAkB,gBAAgB,EAAE,OAAO,YAAY,EAAE,CAAC;IACnE,CAAC;IACD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = run;
|
|
4
|
+
exports.main = main;
|
|
5
|
+
const args_1 = require("./args");
|
|
6
|
+
const logs_1 = require("./commands/logs");
|
|
7
|
+
const restart_1 = require("./commands/restart");
|
|
8
|
+
const start_1 = require("./commands/start");
|
|
9
|
+
const status_1 = require("./commands/status");
|
|
10
|
+
const stop_1 = require("./commands/stop");
|
|
11
|
+
const errors_1 = require("./errors");
|
|
12
|
+
const help_1 = require("./help");
|
|
13
|
+
const paths_1 = require("./paths");
|
|
14
|
+
async function run(argv) {
|
|
15
|
+
let options;
|
|
16
|
+
try {
|
|
17
|
+
options = (0, args_1.parseArgs)(argv);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof errors_1.UsageError) {
|
|
21
|
+
console.error(`错误: ${error.message}`);
|
|
22
|
+
console.error('');
|
|
23
|
+
console.error((0, help_1.globalHelp)());
|
|
24
|
+
return errors_1.EXIT_CODES.usage;
|
|
25
|
+
}
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
if (options.version || options.command === 'version') {
|
|
29
|
+
console.log((0, paths_1.getPackageVersion)());
|
|
30
|
+
return errors_1.EXIT_CODES.ok;
|
|
31
|
+
}
|
|
32
|
+
if (options.help || options.command === 'help') {
|
|
33
|
+
printHelp(options);
|
|
34
|
+
return errors_1.EXIT_CODES.ok;
|
|
35
|
+
}
|
|
36
|
+
switch (options.command) {
|
|
37
|
+
case 'start':
|
|
38
|
+
return (0, start_1.startCommand)(options);
|
|
39
|
+
case 'stop':
|
|
40
|
+
return (0, stop_1.stopCommand)(options);
|
|
41
|
+
case 'status':
|
|
42
|
+
return (0, status_1.statusCommand)(options);
|
|
43
|
+
case 'restart':
|
|
44
|
+
return (0, restart_1.restartCommand)(options);
|
|
45
|
+
case 'logs':
|
|
46
|
+
return (0, logs_1.logsCommand)(options);
|
|
47
|
+
default: {
|
|
48
|
+
const exhaustive = options.command;
|
|
49
|
+
throw new errors_1.UsageError(`未知命令: ${String(exhaustive)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function printHelp(options) {
|
|
54
|
+
let target;
|
|
55
|
+
if (options.command === 'help') {
|
|
56
|
+
target = options.helpTarget;
|
|
57
|
+
}
|
|
58
|
+
else if (options.commandExplicit) {
|
|
59
|
+
target = options.command;
|
|
60
|
+
}
|
|
61
|
+
if (!target || target === 'help') {
|
|
62
|
+
console.log((0, help_1.globalHelp)());
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.log((0, help_1.commandHelp)(target));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function main(argv = process.argv.slice(2)) {
|
|
69
|
+
run(argv)
|
|
70
|
+
.then((code) => {
|
|
71
|
+
process.exitCode = code;
|
|
72
|
+
})
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
let exitCode = errors_1.EXIT_CODES.error;
|
|
75
|
+
if (error instanceof errors_1.CliError) {
|
|
76
|
+
console.error(`错误: ${error.message}`);
|
|
77
|
+
exitCode = error.exitCode;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.error('错误:', error instanceof Error ? error.message : String(error));
|
|
81
|
+
if (process.env.DAILY_HOT_API_DEBUG &&
|
|
82
|
+
error instanceof Error &&
|
|
83
|
+
error.stack) {
|
|
84
|
+
console.error(error.stack);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
process.exitCode = exitCode;
|
|
88
|
+
setTimeout(() => process.exit(exitCode), 100).unref();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (require.main === module) {
|
|
92
|
+
main();
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AAUA,kBAwCC;AAoBD,oBA4BC;AAlGD,iCAAsE;AACtE,0CAA8C;AAC9C,gDAAoD;AACpD,4CAAgD;AAChD,8CAAkD;AAClD,0CAA8C;AAC9C,qCAA4D;AAC5D,iCAAiD;AACjD,mCAA4C;AAErC,KAAK,UAAU,GAAG,CAAC,IAAc;IACtC,IAAI,OAAmB,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,mBAAU,EAAE,CAAC;YAChC,OAAO,CAAC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AAK,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAG5B,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const LOG_TAIL_MAX_BYTES: number;
|
|
2
|
+
export declare function tailFile(file: string, lines: number, maxBytes?: number): string;
|
|
3
|
+
export interface LogChunk {
|
|
4
|
+
text: string;
|
|
5
|
+
nextPosition: number;
|
|
6
|
+
truncated: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function readLogChunk(file: string, fromPosition: number): LogChunk;
|