Files
aliyunApsSkill/aliyun-sync/aliyun-aps-sync/src/index.js
2026-05-25 18:10:46 +08:00

66 lines
1.9 KiB
JavaScript

import { config } from './config.js';
const args = process.argv.slice(2);
const command = args[0] || 'sync';
const extraArgs = args.slice(1);
const billsResume = extraArgs.includes('--resume');
const ordersIncremental = extraArgs.includes('--incremental');
const messagesResume = extraArgs.includes('--resume');
const hotResume = extraArgs.includes('--resume');
for (const arg of extraArgs) {
if (arg.startsWith('--incremental-order-start-date=')) {
process.env.ALIYUN_APS_INCREMENTAL_ORDER_START_DATE = arg.split('=').slice(1).join('=');
}
}
const { login, scheduleSync, syncAll, syncAllIncremental, syncBillsOnly, syncMessagesOnly, syncOrdersOnly, syncHot } = await import('./sync.js');
if (command === 'login') {
await login();
process.exit(0);
}
if (command === 'sync') {
const summary = await syncAll({ resume: billsResume });
console.log(JSON.stringify(summary, null, 2));
process.exit(0);
}
if (command === 'incremental') {
const summary = await syncAllIncremental();
console.log(JSON.stringify(summary, null, 2));
process.exit(0);
}
if (command === 'bills') {
const summary = await syncBillsOnly({ resume: billsResume });
console.log(JSON.stringify(summary, null, 2));
process.exit(0);
}
if (command === 'orders') {
const summary = await syncOrdersOnly({ resume: billsResume, incremental: ordersIncremental });
console.log(JSON.stringify(summary, null, 2));
process.exit(0);
}
if (command === 'messages') {
const summary = await syncMessagesOnly({ incremental: config.scheduleMode === 'incremental', resume: messagesResume });
console.log(JSON.stringify(summary, null, 2));
process.exit(0);
}
if (command === 'hot') {
const summary = await syncHot({ resume: hotResume });
console.log(JSON.stringify(summary, null, 2));
process.exit(0);
}
if (command === 'schedule') {
await scheduleSync();
} else {
console.error(`不支持的命令: ${command}`);
process.exit(1);
}