index.mjs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * 更新发布工具
  3. *
  4. * Copyright © 2025 imengyu.top imengyu-update-server
  5. */
  6. import { program } from 'commander';
  7. import { login, checkLogged, logout, initAuth } from './auth.mjs';
  8. import { testVersion, getVersion, getUpdate } from './app.mjs';
  9. //程序入口
  10. //============================================
  11. program
  12. .command('login <user>')
  13. .description('登录')
  14. .action(login);
  15. program
  16. .command('logstate')
  17. .description('检查登录状态')
  18. .action(checkLogged);
  19. program
  20. .command('logout')
  21. .description('退出登录')
  22. .action(logout);
  23. program
  24. .command('test <version>')
  25. .description('测试更新入口')
  26. .action(testVersion);
  27. program
  28. .command('version <action> [type]')
  29. .description('查看版本信息/发布版本/删除版本/设置版本, action 可选 view/new/delete/set-web-update/set-app-update/set-next-app-update')
  30. .action(getVersion);
  31. program
  32. .command('update <action> [type] [all]')
  33. .description('查看更新信息/发布更新, action 可选 view/post, view type 可选 id/all; post type 可选 web/app')
  34. .option('--skip', '跳过构建')
  35. .option('--ndelete', '不删除构建文件')
  36. .action(getUpdate);
  37. function start() {
  38. program.parse(process.argv);
  39. }
  40. initAuth().then(start);
  41. process.on('unhandledRejection', (reason, p) => {
  42. console.error('Promise: ', p, 'Reason: ', reason)
  43. })