index.mjs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. import { logError } from './utils.mjs';
  10. //程序入口
  11. //============================================
  12. program
  13. .command('login <user>')
  14. .description('登录')
  15. .action(login);
  16. program
  17. .command('logstate')
  18. .description('检查登录状态')
  19. .action(checkLogged);
  20. program
  21. .command('logout')
  22. .description('退出登录')
  23. .action(logout);
  24. program
  25. .command('test <version>')
  26. .description('测试更新入口')
  27. .action(testVersion);
  28. program
  29. .command('version <action> [type]')
  30. .description('查看版本信息/发布版本/删除版本/设置版本, action 可选 view/new/delete/set-web-update/set-app-update/set-next-app-update')
  31. .action(getVersion);
  32. program
  33. .command('update <action> [type] [all]')
  34. .description('查看更新信息/发布更新, action 可选 view/post, view type 可选 id/all; post type 可选 web/app')
  35. .option('--skip', '跳过构建')
  36. .option('--ndelete', '不删除构建文件')
  37. .action(getUpdate);
  38. function start() {
  39. program.parse(process.argv);
  40. }
  41. initAuth().then(start);
  42. <<<<<<< HEAD
  43. process.on('unhandledRejection', (reason) => {
  44. let reasonStr = '';
  45. if (typeof reason === 'string') {
  46. reasonStr = reason;
  47. } else if (typeof reason === 'object') {
  48. if (reason.message) {
  49. reasonStr = reason.message;
  50. }
  51. } else {
  52. reasonStr = reason.toString();
  53. }
  54. logError('UnhandledRejection:', reasonStr)
  55. })
  56. =======
  57. process.on('unhandledRejection', (reason, p) => {
  58. console.error('Promise: ', p, 'Reason: ', reason)
  59. })
  60. >>>>>>> 7c11b917b224c1bfd3d86d6cc15ea83fede0098f