mirror of
https://github.com/AIsouler/GKD_subscription.git
synced 2025-12-20 16:54:43 +08:00
feat: 新增 checkUpdateUrl 字段
This commit is contained in:
19
src/file.ts
19
src/file.ts
@@ -16,6 +16,7 @@ const sortKeys: (keyof SubscriptionConfig)[] = [
|
||||
'author',
|
||||
'supportUri',
|
||||
'updateUrl',
|
||||
'checkUpdateUrl',
|
||||
'apps',
|
||||
];
|
||||
|
||||
@@ -39,9 +40,11 @@ const pkg: typeof PkgT = JSON.parse(
|
||||
);
|
||||
const pkgKeys = Object.keys(pkg);
|
||||
|
||||
export const writeConfig = async (fp: string, config: SubscriptionConfig) => {
|
||||
export const writeConfig = async (config: SubscriptionConfig) => {
|
||||
const gkdFp = process.cwd() + '/dist/gkd.json';
|
||||
const versionFp = process.cwd() + '/dist/gkd.version.json';
|
||||
const oldConfig: SubscriptionConfig = JSON.parse(
|
||||
await fs.readFile(fp, 'utf-8').catch(() => '{}'),
|
||||
await fs.readFile(gkdFp, 'utf-8').catch(() => '{}'),
|
||||
);
|
||||
|
||||
const newConfig: SubscriptionConfig = {
|
||||
@@ -72,7 +75,17 @@ export const writeConfig = async (fp: string, config: SubscriptionConfig) => {
|
||||
|
||||
// update gkd.json
|
||||
const buffer = Buffer.from(orderdStringify(newConfig, sortKeys), 'utf-8');
|
||||
await fs.writeFile(fp, buffer);
|
||||
await fs.writeFile(gkdFp, buffer);
|
||||
|
||||
// update gkd.version.json
|
||||
await fs.writeFile(
|
||||
versionFp,
|
||||
JSON.stringify(
|
||||
{ id: newConfig.id, version: newConfig.version },
|
||||
undefined,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
console.log(
|
||||
`更新订阅: v${newConfig.version}, 文件大小: ${
|
||||
|
||||
Reference in New Issue
Block a user