* feat(core): 添加 Bing 搜索推送功能 - 在 errorCode.constant.ts 中添加 Bing 相关的错误代码 - 在 configs.dto.ts 中添加 BingSearchOptionDto 类用于配置 Bing 推送选项 - 在 helper.cron.service.ts 中实现 pushToBingSearch 方法进行 Bing 搜索推送 * feat(core): 添加必应搜索推送配置并优化相关功能 - 在默认配置中添加 bingSearchOptions 项 - 更新 BingSearchOptionDto 类,统一字段命名 - 在 IConfig 接口中添加 bingSearchOptions 字段 - 修改 CronService 中的 pushToBingSearch 方法,适配新配置 * build: 更新下载资源链接 - 将 CDN 下载 URL 从 `https://mirror.ghproxy.com/` 更改为 `https://ghfast.top/` * feat(api-client): 添加 Bing 搜索配置模型 - 新增 BingSearchOptionsModel 类,用于 Bing 搜索的配置选项 - 该模型包括 enable 和 token 两个属性,与 BaiduSearchOptionsModel 类似 * refactor(configs): 统一配置类命名规则 - 将 BingSearchOptionDto 重命名为 BingSearchOptionsDto,与 BaiduSearchOptionsDto 保持一致 - 更新相关引用和配置字段类型 * feat(core): 添加每日凌晨1点执行的 Bing 搜索推送任务 - 在 CronService 类中添加了 pushToBingSearch 方法 - 使用 @CronOnce 装饰器设置任务执行时间为每天凌晨1点 - 任务名称为 'pushToBingSearch' - 方法描述为 '推送到Bing' * chore: 添加.eslintcache到.gitignore - 在.gitignore文件中添加.eslintcache,避免eslint缓存文件被版本控制 * feat(docs): 更新readme * refactor(core): 优化 Bing 站长提交日志输出 - 修改了 Bing 站长提交结果的日志输出格式 - 当提交成功时,输出简短的成功日志 - 当提交失败时,仍输出详细的错误信息 * Update apps/core/src/processors/helper/helper.cron.service.ts Co-authored-by: Innei <tukon479@gmail.com> Signed-off-by: Teror Fox <i@trfox.top> * chore: 删除废弃的服务器部署脚本 * feat(core): 添加 Bing API 域名无效错误码 - 在 ErrorCodeEnum 枚举中添加 BingDomainInvalid 错误码 - 在 ErrorCode 对象中添加对应的错误信息和状态码 * refactor(core): 修复 Bing 推送异常时返回值问题 --------- Signed-off-by: Teror Fox <i@trfox.top> Co-authored-by: Innei <tukon479@gmail.com>
89 lines
2.3 KiB
JavaScript
89 lines
2.3 KiB
JavaScript
#!/usr/bin/env zx
|
|
// @ts-check
|
|
|
|
const {
|
|
cd,
|
|
$,
|
|
os,
|
|
fs,
|
|
path,
|
|
fetch,
|
|
nothrow,
|
|
sleep,
|
|
argv: av,
|
|
} = require('zx-cjs')
|
|
const { homedir } = os
|
|
const { repository } = require('../package.json')
|
|
|
|
const argv = process.argv.slice(2)
|
|
const scpPath = av.scp_path
|
|
function getOsBuildAssetName() {
|
|
return `release-linux.zip`
|
|
}
|
|
|
|
async function main() {
|
|
cd(path.resolve(homedir(), 'mx'))
|
|
if (!scpPath) {
|
|
const releases = await fetch(
|
|
`https://api.github.com/repos/${repository.directory}/releases`,
|
|
).then((res) => res.json())
|
|
const [latest] = releases
|
|
const tagName = latest.tag_name
|
|
|
|
const res = await fetch(
|
|
`https://api.github.com/repos/${repository.directory}/releases/tags/${tagName}`,
|
|
)
|
|
const data = await res.json()
|
|
const downloadUrl = data.assets.find((asset) =>
|
|
[getOsBuildAssetName(), 'release.zip'].includes(asset.name),
|
|
)?.browser_download_url
|
|
|
|
if (!downloadUrl) {
|
|
throw new Error('no download url found')
|
|
}
|
|
|
|
const buffer = await fetch(
|
|
`https://mirror.ghproxy.com/${downloadUrl}`,
|
|
).then((res) => res.buffer())
|
|
const tmpName = (Math.random() * 10).toString(16)
|
|
fs.writeFileSync(`/tmp/${tmpName}.zip`, buffer, { flag: 'w' })
|
|
|
|
await $`mv ./run ./run.bak`
|
|
|
|
await $`unzip /tmp/${tmpName}.zip -d ./run`
|
|
await $`rm /tmp/${tmpName}.zip`
|
|
} else {
|
|
await $`mv ./run ./run.bak`
|
|
|
|
await $`unzip ${scpPath} -d ./run`
|
|
await $`rm ${scpPath}`
|
|
}
|
|
|
|
await $`rm ./run/ecosystem.config.js`
|
|
await $`cp ./run.bak/ecosystem.config.js ./run/ecosystem.config.js`
|
|
|
|
cd('./run')
|
|
|
|
await nothrow($`pm2 reload ecosystem.config.js -- ${argv}`)
|
|
console.log('等待 8 秒')
|
|
await sleep(8000)
|
|
try {
|
|
await $`curl -f -m 3 localhost:2333/api/v2 -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36'`
|
|
await $`pm2 save`
|
|
cd(path.resolve(homedir(), 'mx'))
|
|
await $`rm -rf ./run.bak`
|
|
} catch {
|
|
await $`pm2 stop ecosystem.config.js`
|
|
// throw new Error('server is not running')
|
|
console.error('server start error, now rollback...')
|
|
cd(path.resolve(homedir(), 'mx'))
|
|
await $`rm -rf ./run`
|
|
await $`mv ./run.bak ./run`
|
|
cd('./run')
|
|
await $`pm2 delete ecosystem.config.js`
|
|
await $`pm2 start ecosystem.config.js`
|
|
}
|
|
}
|
|
|
|
main()
|