@skyroc/scripts 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +508 -0
  3. package/dist/cli.mjs +78 -0
  4. package/dist/config-BKkdncJS.mjs +987 -0
  5. package/dist/index.mjs +14 -0
  6. package/package.json +83 -0
  7. package/templates/admin/.env +62 -0
  8. package/templates/admin/.env.prod +7 -0
  9. package/templates/admin/.env.test +7 -0
  10. package/templates/admin/.oxlintrc.json +6 -0
  11. package/templates/admin/README.md +508 -0
  12. package/templates/admin/index.html +14 -0
  13. package/templates/admin/package.json +105 -0
  14. package/templates/admin/public/favicon.svg +3 -0
  15. package/templates/admin/src/App.tsx +71 -0
  16. package/templates/admin/src/assets/audio/wechat-style-notification.wav +0 -0
  17. package/templates/admin/src/assets/imgs/skyroc.jpg +0 -0
  18. package/templates/admin/src/assets/svg-icon/activity.svg +1 -0
  19. package/templates/admin/src/assets/svg-icon/at-sign.svg +1 -0
  20. package/templates/admin/src/assets/svg-icon/avatar.svg +1 -0
  21. package/templates/admin/src/assets/svg-icon/banner.svg +1 -0
  22. package/templates/admin/src/assets/svg-icon/cast.svg +1 -0
  23. package/templates/admin/src/assets/svg-icon/chrome.svg +1 -0
  24. package/templates/admin/src/assets/svg-icon/copy.svg +1 -0
  25. package/templates/admin/src/assets/svg-icon/custom-icon.svg +1 -0
  26. package/templates/admin/src/assets/svg-icon/empty-data.svg +1 -0
  27. package/templates/admin/src/assets/svg-icon/error.svg +1 -0
  28. package/templates/admin/src/assets/svg-icon/expectation.svg +1 -0
  29. package/templates/admin/src/assets/svg-icon/heart.svg +1 -0
  30. package/templates/admin/src/assets/svg-icon/logo.svg +15 -0
  31. package/templates/admin/src/assets/svg-icon/network-error.svg +1 -0
  32. package/templates/admin/src/assets/svg-icon/no-icon.svg +1 -0
  33. package/templates/admin/src/assets/svg-icon/no-permission.svg +1 -0
  34. package/templates/admin/src/assets/svg-icon/not-found.svg +1 -0
  35. package/templates/admin/src/assets/svg-icon/service-error.svg +1 -0
  36. package/templates/admin/src/bootstrap.tsx +60 -0
  37. package/templates/admin/src/components/SkyrocAvatar.tsx +13 -0
  38. package/templates/admin/src/components/SystemLogo.tsx +7 -0
  39. package/templates/admin/src/config.ts +125 -0
  40. package/templates/admin/src/features/antd/AntdProvider.tsx +21 -0
  41. package/templates/admin/src/features/auth/components/UserAvatar.tsx +76 -0
  42. package/templates/admin/src/features/auth/use-auth-form-rules.ts +83 -0
  43. package/templates/admin/src/features/auth/use-auth.ts +96 -0
  44. package/templates/admin/src/features/auth/use-login.ts +72 -0
  45. package/templates/admin/src/features/effects/GlobalEffect.tsx +15 -0
  46. package/templates/admin/src/features/menus/dynamic-routes.ts +10 -0
  47. package/templates/admin/src/features/menus/extras.ts +3 -0
  48. package/templates/admin/src/features/menus/menu-category.ts +14 -0
  49. package/templates/admin/src/features/menus/menu-config.ts +5 -0
  50. package/templates/admin/src/features/router/RouterProvider.tsx +18 -0
  51. package/templates/admin/src/features/router/guard.ts +97 -0
  52. package/templates/admin/src/features/router/index.ts +52 -0
  53. package/templates/admin/src/features/router/routeTree.gen.ts +237 -0
  54. package/templates/admin/src/features/router/router-ref.ts +24 -0
  55. package/templates/admin/src/locales/antd.ts +8 -0
  56. package/templates/admin/src/locales/index.ts +22 -0
  57. package/templates/admin/src/locales/sync.ts +14 -0
  58. package/templates/admin/src/main.tsx +9 -0
  59. package/templates/admin/src/pages/(admin)/home/index.tsx +46 -0
  60. package/templates/admin/src/pages/(admin)/layout.tsx +44 -0
  61. package/templates/admin/src/pages/(auth)/login/index.tsx +102 -0
  62. package/templates/admin/src/pages/(auth)/login/layout.tsx +71 -0
  63. package/templates/admin/src/pages/(auth)/login-out.tsx +27 -0
  64. package/templates/admin/src/pages/(errors)/403.tsx +16 -0
  65. package/templates/admin/src/pages/(errors)/404.tsx +16 -0
  66. package/templates/admin/src/pages/(errors)/500.tsx +16 -0
  67. package/templates/admin/src/pages/__root.tsx +54 -0
  68. package/templates/admin/src/pages/error.tsx +19 -0
  69. package/templates/admin/src/pages/index.tsx +14 -0
  70. package/templates/admin/src/pages/loading.tsx +45 -0
  71. package/templates/admin/src/pages/not-found.tsx +9 -0
  72. package/templates/admin/src/plugins/app.tsx +47 -0
  73. package/templates/admin/src/plugins/assets.ts +4 -0
  74. package/templates/admin/src/plugins/index.ts +32 -0
  75. package/templates/admin/src/service/adapter.ts +63 -0
  76. package/templates/admin/src/service/api/auth/api.ts +31 -0
  77. package/templates/admin/src/service/api/auth/hooks.ts +28 -0
  78. package/templates/admin/src/service/api/auth/index.ts +10 -0
  79. package/templates/admin/src/service/api/auth/keys.ts +7 -0
  80. package/templates/admin/src/service/api/auth/urls.ts +7 -0
  81. package/templates/admin/src/service/api/index.ts +2 -0
  82. package/templates/admin/src/service/api/route/api.ts +7 -0
  83. package/templates/admin/src/service/api/route/hooks.ts +21 -0
  84. package/templates/admin/src/service/api/route/index.ts +10 -0
  85. package/templates/admin/src/service/api/route/keys.ts +3 -0
  86. package/templates/admin/src/service/api/route/urls.ts +5 -0
  87. package/templates/admin/src/service/queryClient.ts +13 -0
  88. package/templates/admin/src/service/request/index.ts +62 -0
  89. package/templates/admin/src/styles/scss/global.scss +1 -0
  90. package/templates/admin/src/styles/scss/scrollbar.scss +28 -0
  91. package/templates/admin/src/types/auto-imports.d.ts +186 -0
  92. package/templates/admin/src/types/global.d.ts +16 -0
  93. package/templates/admin/src/types/router.d.ts +14 -0
  94. package/templates/admin/src/types/storage.d.ts +17 -0
  95. package/templates/admin/src/types/vite-env.d.ts +117 -0
  96. package/templates/admin/src/utils/common.tsx +38 -0
  97. package/templates/admin/src/utils/icon.ts +9 -0
  98. package/templates/admin/src/utils/service.ts +75 -0
  99. package/templates/admin/src/utils/storage.ts +7 -0
  100. package/templates/admin/tsconfig.json +22 -0
  101. package/templates/admin/uno.config.ts +18 -0
  102. package/templates/admin/vite.config.ts +13 -0
  103. package/templates/admin-shell/i18n/atoms/lang.ts +20 -0
  104. package/templates/admin-shell/i18n/config/default.ts +11 -0
  105. package/templates/admin-shell/i18n/features/lang/LangEffect.tsx +25 -0
  106. package/templates/admin-shell/i18n/features/lang/LangSwitch.tsx +49 -0
  107. package/templates/admin-shell/i18n/hooks/use-lang.ts +47 -0
  108. package/templates/admin-shell/i18n/i18n.ts +116 -0
  109. package/templates/admin-shell/i18n/index.ts +23 -0
  110. package/templates/admin-shell/i18n/langs/en-us/common.json +49 -0
  111. package/templates/admin-shell/i18n/langs/en-us/datatable.json +8 -0
  112. package/templates/admin-shell/i18n/langs/en-us/dropdown.json +9 -0
  113. package/templates/admin-shell/i18n/langs/en-us/form.json +27 -0
  114. package/templates/admin-shell/i18n/langs/en-us/icon.json +13 -0
  115. package/templates/admin-shell/i18n/langs/en-us/notification.json +20 -0
  116. package/templates/admin-shell/i18n/langs/en-us/page.json +442 -0
  117. package/templates/admin-shell/i18n/langs/en-us/request.json +8 -0
  118. package/templates/admin-shell/i18n/langs/en-us/route.json +84 -0
  119. package/templates/admin-shell/i18n/langs/en-us/system.json +9 -0
  120. package/templates/admin-shell/i18n/langs/en-us/theme.json +173 -0
  121. package/templates/admin-shell/i18n/langs/index.ts +63 -0
  122. package/templates/admin-shell/i18n/langs/zh-cn/common.json +49 -0
  123. package/templates/admin-shell/i18n/langs/zh-cn/datatable.json +8 -0
  124. package/templates/admin-shell/i18n/langs/zh-cn/dropdown.json +9 -0
  125. package/templates/admin-shell/i18n/langs/zh-cn/form.json +27 -0
  126. package/templates/admin-shell/i18n/langs/zh-cn/icon.json +13 -0
  127. package/templates/admin-shell/i18n/langs/zh-cn/notification.json +20 -0
  128. package/templates/admin-shell/i18n/langs/zh-cn/page.json +442 -0
  129. package/templates/admin-shell/i18n/langs/zh-cn/request.json +8 -0
  130. package/templates/admin-shell/i18n/langs/zh-cn/route.json +84 -0
  131. package/templates/admin-shell/i18n/langs/zh-cn/system.json +9 -0
  132. package/templates/admin-shell/i18n/langs/zh-cn/theme.json +173 -0
  133. package/templates/admin-shell/i18n/types/i18n.ts +29 -0
  134. package/templates/admin-shell/i18n/types.ts +53 -0
  135. package/templates/admin-shell/i18n/utils/helpers.ts +18 -0
  136. package/templates/admin-shell/layouts/AdminLayout.tsx +161 -0
  137. package/templates/admin-shell/layouts/constant.ts +56 -0
  138. package/templates/admin-shell/layouts/context.tsx +101 -0
  139. package/templates/admin-shell/layouts/features/menus/MenuBadge.tsx +76 -0
  140. package/templates/admin-shell/layouts/features/menus/dynamic-routes.ts +146 -0
  141. package/templates/admin-shell/layouts/features/menus/menu-generator.tsx +444 -0
  142. package/templates/admin-shell/layouts/features/menus/menu-renderer.tsx +149 -0
  143. package/templates/admin-shell/layouts/features/menus/permissions.ts +28 -0
  144. package/templates/admin-shell/layouts/features/menus/use-menus.ts +98 -0
  145. package/templates/admin-shell/layouts/features/use-route.ts +30 -0
  146. package/templates/admin-shell/layouts/index.ts +44 -0
  147. package/templates/admin-shell/layouts/materials/index.ts +6 -0
  148. package/templates/admin-shell/layouts/materials/libs/admin-layout/index.module.css +63 -0
  149. package/templates/admin-shell/layouts/materials/libs/admin-layout/index.module.css.d.ts +18 -0
  150. package/templates/admin-shell/layouts/materials/libs/admin-layout/index.tsx +238 -0
  151. package/templates/admin-shell/layouts/materials/libs/admin-layout/shared.ts +67 -0
  152. package/templates/admin-shell/layouts/materials/libs/page-tab/ButtonTab.tsx +44 -0
  153. package/templates/admin-shell/layouts/materials/libs/page-tab/ChromeTab.tsx +54 -0
  154. package/templates/admin-shell/layouts/materials/libs/page-tab/ChromeTabBg.tsx +30 -0
  155. package/templates/admin-shell/layouts/materials/libs/page-tab/SliderTab.tsx +44 -0
  156. package/templates/admin-shell/layouts/materials/libs/page-tab/SvgClose.tsx +51 -0
  157. package/templates/admin-shell/layouts/materials/libs/page-tab/hook.ts +34 -0
  158. package/templates/admin-shell/layouts/materials/libs/page-tab/index.module.css +120 -0
  159. package/templates/admin-shell/layouts/materials/libs/page-tab/index.module.css.d.ts +18 -0
  160. package/templates/admin-shell/layouts/materials/libs/page-tab/index.tsx +76 -0
  161. package/templates/admin-shell/layouts/materials/libs/page-tab/shared.ts +32 -0
  162. package/templates/admin-shell/layouts/materials/types/index.ts +322 -0
  163. package/templates/admin-shell/layouts/modules/AdminContent.tsx +285 -0
  164. package/templates/admin-shell/layouts/modules/AdminFooter.tsx +13 -0
  165. package/templates/admin-shell/layouts/modules/AdminLogo.tsx +28 -0
  166. package/templates/admin-shell/layouts/modules/AdminSider.tsx +50 -0
  167. package/templates/admin-shell/layouts/modules/admin-header/AdminHeader.tsx +132 -0
  168. package/templates/admin-shell/layouts/modules/admin-header/components/Breadcrumb.tsx +62 -0
  169. package/templates/admin-shell/layouts/modules/admin-header/components/ThemeButton.tsx +24 -0
  170. package/templates/admin-shell/layouts/modules/admin-menu/AdminMenu.tsx +37 -0
  171. package/templates/admin-shell/layouts/modules/admin-menu/components/FirstLevelMenu.tsx +156 -0
  172. package/templates/admin-shell/layouts/modules/admin-menu/components/HorizontalMenu.tsx +88 -0
  173. package/templates/admin-shell/layouts/modules/admin-menu/components/MenuPortal.tsx +28 -0
  174. package/templates/admin-shell/layouts/modules/admin-menu/components/VerticalMenu.tsx +123 -0
  175. package/templates/admin-shell/layouts/modules/admin-menu/enum.ts +47 -0
  176. package/templates/admin-shell/layouts/modules/admin-menu/modules/Horizontal.tsx +22 -0
  177. package/templates/admin-shell/layouts/modules/admin-menu/modules/TopHybridHeaderFirst.tsx +15 -0
  178. package/templates/admin-shell/layouts/modules/admin-menu/modules/TopHybridSidebarFirst.tsx +18 -0
  179. package/templates/admin-shell/layouts/modules/admin-menu/modules/Vertical.tsx +14 -0
  180. package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalHybridHeaderFirst.tsx +18 -0
  181. package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalMix.tsx +132 -0
  182. package/templates/admin-shell/layouts/modules/admin-search/AdminSearch.tsx +36 -0
  183. package/templates/admin-shell/layouts/modules/admin-search/components/SearchFooter.tsx +38 -0
  184. package/templates/admin-shell/layouts/modules/admin-search/components/SearchModal.tsx +171 -0
  185. package/templates/admin-shell/layouts/modules/admin-search/components/SearchResult.tsx +43 -0
  186. package/templates/admin-shell/layouts/modules/admin-tab/AdminTab.tsx +125 -0
  187. package/templates/admin-shell/layouts/modules/admin-tab/components/TabContextMenu.tsx +107 -0
  188. package/templates/admin-shell/layouts/modules/admin-tab/hooks/useTabScroll.ts +86 -0
  189. package/templates/admin-shell/layouts/modules/shared/logo.ts +42 -0
  190. package/templates/admin-shell/layouts/modules/theme-drawer/ThemeDrawer.tsx +68 -0
  191. package/templates/admin-shell/layouts/modules/theme-drawer/components/AnimatedCollapse.tsx +36 -0
  192. package/templates/admin-shell/layouts/modules/theme-drawer/components/AnimatedItem.tsx +35 -0
  193. package/templates/admin-shell/layouts/modules/theme-drawer/components/LayoutModeCard.tsx +110 -0
  194. package/templates/admin-shell/layouts/modules/theme-drawer/components/SettingItem.tsx +31 -0
  195. package/templates/admin-shell/layouts/modules/theme-drawer/modules/ConfigOperation.tsx +53 -0
  196. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/CustomPicker.tsx +105 -0
  197. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeColor.tsx +58 -0
  198. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeSchema.tsx +42 -0
  199. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeToken.tsx +44 -0
  200. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/index.tsx +23 -0
  201. package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/GlobalSettings.tsx +57 -0
  202. package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/ThemeGeneral.tsx +20 -0
  203. package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/WatermarkSettings.tsx +103 -0
  204. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/ContentSettings.tsx +100 -0
  205. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/FooterSettings.tsx +71 -0
  206. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/HeaderSettings.tsx +63 -0
  207. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/LayoutMode.tsx +73 -0
  208. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/SiderSettings.tsx +124 -0
  209. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/TabSettings.tsx +95 -0
  210. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/ThemeLayout.tsx +32 -0
  211. package/templates/admin-shell/layouts/modules/theme-drawer/modules/preset/ThemePreset.tsx +132 -0
  212. package/templates/admin-shell/layouts/options.tsx +79 -0
  213. package/templates/admin-shell/layouts/setup.ts +102 -0
  214. package/templates/admin-shell/layouts/state/AdminEffect.tsx +56 -0
  215. package/templates/admin-shell/layouts/state/AdminTabEffect.tsx +28 -0
  216. package/templates/admin-shell/layouts/state/index.ts +3 -0
  217. package/templates/admin-shell/layouts/state/menus/MenuToggler.tsx +53 -0
  218. package/templates/admin-shell/layouts/state/menus/use-admin-menu-badges.ts +46 -0
  219. package/templates/admin-shell/layouts/state/menus/use-admin-menus.tsx +164 -0
  220. package/templates/admin-shell/layouts/state/tabs/index.ts +1 -0
  221. package/templates/admin-shell/layouts/state/tabs/shared.tsx +148 -0
  222. package/templates/admin-shell/layouts/state/tabs/use-admin-tab.ts +377 -0
  223. package/templates/admin-shell/layouts/state/use-admin-state.ts +118 -0
  224. package/templates/admin-shell/layouts/types/router.d.ts +10 -0
  225. package/templates/admin-shell/layouts/types/storage.ts +18 -0
  226. package/templates/admin-shell/notification/NotificationButton.tsx +91 -0
  227. package/templates/admin-shell/notification/NotificationContext.ts +8 -0
  228. package/templates/admin-shell/notification/NotificationPanel.tsx +194 -0
  229. package/templates/admin-shell/notification/NotificationProvider.tsx +59 -0
  230. package/templates/admin-shell/notification/index.ts +12 -0
  231. package/templates/admin-shell/notification/mock.ts +59 -0
  232. package/templates/admin-shell/notification/notification-store.ts +438 -0
  233. package/templates/admin-shell/notification/notification.css +60 -0
  234. package/templates/admin-shell/notification/types.ts +104 -0
  235. package/templates/admin-shell/notification/use-notification.ts +51 -0
  236. package/templates/admin-shell/notification/useNotificationContext.ts +14 -0
  237. package/templates/admin-shell/runtime/app-update.ts +156 -0
  238. package/templates/admin-shell/runtime/dayjs.ts +20 -0
  239. package/templates/admin-shell/runtime/iconify.ts +17 -0
  240. package/templates/admin-shell/runtime/index.ts +10 -0
  241. package/templates/admin-shell/runtime/nprogress.ts +25 -0
  242. package/templates/admin-shell/runtime/plugins.ts +62 -0
  243. package/templates/admin-shell/styles/global.css +54 -0
  244. package/templates/admin-shell/styles/nprogress.css +85 -0
  245. package/templates/admin-shell/styles/reset.css +378 -0
  246. package/templates/admin-shell/theme/antd/AntdProvider.tsx +106 -0
  247. package/templates/admin-shell/theme/antd/index.ts +23 -0
  248. package/templates/admin-shell/theme/antd/shared.ts +80 -0
  249. package/templates/admin-shell/theme/antd/ui.ts +250 -0
  250. package/templates/admin-shell/theme/antd-algorithm/algorithm/dark/colors.ts +99 -0
  251. package/templates/admin-shell/theme/antd-algorithm/algorithm/dark/index.ts +87 -0
  252. package/templates/admin-shell/theme/antd-algorithm/algorithm/default/colors.ts +91 -0
  253. package/templates/admin-shell/theme/antd-algorithm/algorithm/default/index.ts +77 -0
  254. package/templates/admin-shell/theme/antd-algorithm/index.ts +80 -0
  255. package/templates/admin-shell/theme/antd-algorithm/seed/index.ts +41 -0
  256. package/templates/admin-shell/theme/antd-algorithm/shared/colorAlgorithm.ts +10 -0
  257. package/templates/admin-shell/theme/antd-algorithm/shared/genColorMapToken.ts +165 -0
  258. package/templates/admin-shell/theme/antd-algorithm/shared/genCommonMapToken.ts +23 -0
  259. package/templates/admin-shell/theme/antd-algorithm/shared/genControlHeight.ts +14 -0
  260. package/templates/admin-shell/theme/antd-algorithm/shared/genFontMapToken.ts +274 -0
  261. package/templates/admin-shell/theme/antd-algorithm/shared/genRadiusMapToken.ts +139 -0
  262. package/templates/admin-shell/theme/antd-algorithm/shared/genSizeMapToken.ts +114 -0
  263. package/templates/admin-shell/theme/antd-algorithm/types/index.ts +20 -0
  264. package/templates/admin-shell/theme/components/ThemeEffect.tsx +55 -0
  265. package/templates/admin-shell/theme/components/ThemeSchemaSegmented.tsx +27 -0
  266. package/templates/admin-shell/theme/components/ThemeSchemaSwitch.tsx +77 -0
  267. package/templates/admin-shell/theme/components/shared.ts +5 -0
  268. package/templates/admin-shell/theme/config/default.ts +108 -0
  269. package/templates/admin-shell/theme/config/index.ts +1 -0
  270. package/templates/admin-shell/theme/hooks/index.ts +2 -0
  271. package/templates/admin-shell/theme/hooks/use-theme.ts +244 -0
  272. package/templates/admin-shell/theme/index.ts +78 -0
  273. package/templates/admin-shell/theme/presets/azir.json +39 -0
  274. package/templates/admin-shell/theme/presets/compact.json +38 -0
  275. package/templates/admin-shell/theme/presets/dark.json +93 -0
  276. package/templates/admin-shell/theme/presets/default.json +95 -0
  277. package/templates/admin-shell/theme/presets/index.ts +29 -0
  278. package/templates/admin-shell/theme/presets/shadcn.json +99 -0
  279. package/templates/admin-shell/theme/setup.ts +115 -0
  280. package/templates/admin-shell/theme/types/index.ts +27 -0
  281. package/templates/admin-shell/theme/types/theme.d.ts +316 -0
  282. package/templates/admin-shell/theme/utils/dark-mode.ts +46 -0
  283. package/templates/admin-shell/theme/utils/filters.ts +20 -0
  284. package/templates/admin-shell/theme/utils/index.ts +3 -0
  285. package/templates/admin-shell/theme/utils/settings.ts +43 -0
  286. package/templates/admin-shell/types/api/auth.d.ts +148 -0
  287. package/templates/admin-shell/types/api/common.d.ts +54 -0
  288. package/templates/admin-shell/types/api/route.d.ts +104 -0
  289. package/templates/admin-shell/types/api/service.d.ts +51 -0
  290. package/templates/admin-shell/types/api/system-manage.d.ts +160 -0
  291. package/templates/admin-shell/types/app/common.d.ts +31 -0
  292. package/templates/admin-shell/types/app/global.d.ts +71 -0
  293. package/templates/admin-shell/types/app/menu.d.ts +57 -0
  294. package/templates/admin-shell/types/app/router.d.ts +201 -0
  295. package/templates/admin-shell/types/app/storage.d.ts +10 -0
  296. package/templates/admin-shell/types/app/union-key.d.ts +156 -0
  297. package/templates/admin-shell/types/locales/i18n.d.ts +135 -0
  298. package/templates/admin-shell/ui/antd/components/AppTree.tsx +62 -0
  299. package/templates/admin-shell/ui/antd/components/BeyondHiding.tsx +42 -0
  300. package/templates/admin-shell/ui/antd/components/ButtonIcon.tsx +123 -0
  301. package/templates/admin-shell/ui/antd/components/ButtonLink.tsx +30 -0
  302. package/templates/admin-shell/ui/antd/components/ErrorBoundary.tsx +45 -0
  303. package/templates/admin-shell/ui/antd/components/ExceptionBase.tsx +69 -0
  304. package/templates/admin-shell/ui/antd/components/FullScreen.tsx +33 -0
  305. package/templates/admin-shell/ui/antd/components/PinToggler.tsx +35 -0
  306. package/templates/admin-shell/ui/antd/components/ReloadButton.tsx +20 -0
  307. package/templates/admin-shell/ui/antd/components/index.ts +12 -0
  308. package/templates/admin-shell/ui/antd/components/styles/button-icon-animations.css +246 -0
  309. package/templates/admin-shell/ui/antd/index.ts +1 -0
  310. package/templates/admin-shell/ui/antd/styles.d.ts +1 -0
  311. package/templates/admin-shell/ui/compose/animate-feature.ts +5 -0
  312. package/templates/admin-shell/ui/compose/components/BetterScroll.tsx +51 -0
  313. package/templates/admin-shell/ui/compose/components/DarkModeContainer.tsx +22 -0
  314. package/templates/admin-shell/ui/compose/components/FlipText.tsx +41 -0
  315. package/templates/admin-shell/ui/compose/components/I18nLabel.tsx +18 -0
  316. package/templates/admin-shell/ui/compose/components/LazyAnimate.tsx +10 -0
  317. package/templates/admin-shell/ui/compose/components/LookForward.tsx +24 -0
  318. package/templates/admin-shell/ui/compose/components/NumberTicker.tsx +105 -0
  319. package/templates/admin-shell/ui/compose/components/Portal.tsx +74 -0
  320. package/templates/admin-shell/ui/compose/components/SvgIcon.tsx +39 -0
  321. package/templates/admin-shell/ui/compose/components/TypingAnimation.tsx +83 -0
  322. package/templates/admin-shell/ui/compose/components/WaveBg.tsx +56 -0
  323. package/templates/admin-shell/ui/compose/components/index.ts +11 -0
  324. package/templates/admin-shell/ui/compose/index.ts +2 -0
  325. package/templates/admin-shell/ui/compose/table/DragContent.tsx +239 -0
  326. package/templates/admin-shell/ui/compose/table/TableHeaderOperation.tsx +210 -0
  327. package/templates/admin-shell/ui/compose/table/hooks.ts +196 -0
  328. package/templates/admin-shell/ui/compose/table/index.ts +16 -0
  329. package/templates/admin-shell/ui/compose/table/types.ts +244 -0
  330. package/templates/admin-shell/ui/compose/table/use-table-operate.ts +136 -0
  331. package/templates/admin-shell/ui/compose/table/use-table-scroll.ts +49 -0
  332. package/templates/admin-shell/ui/compose/table/use-table.ts +303 -0
  333. package/templates/admin.meta.json +756 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ohh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,508 @@
1
+ # @skyroc/scripts
2
+
3
+ Skyroc Admin CLI 工具集 — 通过统一入口 `sa` 命令,封装 changelog 生成、版本发布、规范化 Git 提交、依赖更新、清理构建产物等项目自动化脚本。
4
+
5
+ ## 解决什么问题
6
+
7
+ ```
8
+ ❌ 每次发版:手动改版本号 → 手动写 CHANGELOG → 手动打 tag → 手动 push
9
+ ❌ git commit:在脑中查规范 → 手写类型/范围 → 不确定格式对不对
10
+ ❌ 项目清理:一个个目录找 node_modules / dist → 逐一删除
11
+ ❌ 依赖更新:不知道哪些包有新版本 → 逐一核对
12
+ ```
13
+
14
+ `@skyroc/scripts` 的答案:**一条命令 + 交互式引导 + 配置文件驱动**。
15
+
16
+ ## 安装
17
+
18
+ ```bash
19
+ # 在 monorepo 根目录已通过 workspace 引用,无需额外安装
20
+ # 若需独立使用:
21
+ pnpm add -D @skyroc/scripts
22
+ ```
23
+
24
+ ## 快速上手
25
+
26
+ ```bash
27
+ # 查看帮助与所有可用命令(不带子命令直接跑 sa 也会输出帮助)
28
+ pnpm sa --help
29
+
30
+ # 查看版本
31
+ pnpm sa --version
32
+ ```
33
+
34
+ 典型工作流:
35
+
36
+ ```bash
37
+ # 日常提交
38
+ pnpm sa git-commit
39
+
40
+ # 发版
41
+ pnpm sa release
42
+
43
+ # 清理构建产物
44
+ pnpm sa cleanup
45
+
46
+ # 生成一个可独立运行的 admin app
47
+ pnpm sa create-admin my-admin --target ~/projects/my-admin
48
+
49
+ # 在本仓库内新增一个 app(保留 workspace: / catalog: 协议)
50
+ pnpm sa create-admin my-admin --workspace
51
+
52
+ # 从 apps/admin 同步内置 admin 模板
53
+ pnpm sa sync-admin-template
54
+ ```
55
+
56
+ ## 命令一览
57
+
58
+ | 命令 | 说明 |
59
+ | --- | --- |
60
+ | `sa changelog` | 生成 / 更新 CHANGELOG.md |
61
+ | `sa cleanup` | 删除 dist、node_modules 等构建产物 |
62
+ | `sa create-admin <name>` | 基于内置模板生成新的 admin app(默认物化成可独立安装的工程,`--workspace` 保留 monorepo 协议) |
63
+ | `sa git-commit` | 交互式生成符合 Conventional Commits 规范的提交信息 |
64
+ | `sa git-commit-verify` | 校验当前 git 提交信息是否符合规范(用于 git hook) |
65
+ | `sa release` | 版本发布:升级版本号 → 生成 changelog → commit + tag + push |
66
+ | `sa sync-admin-template` | 从 `apps/admin` 生成内置 admin 模板与物化元数据(仅限仓库内) |
67
+ | `sa update-pkg` | 检测并升级 package.json 中的依赖版本 |
68
+
69
+ ## 全局选项
70
+
71
+ 所有命令共享以下选项:
72
+
73
+ | 选项 | 简写 | 说明 | 默认值 |
74
+ | --- | --- | --- | --- |
75
+ | `--lang <lang>` | `-l` | CLI 交互语言,支持 `en-us` / `zh-cn` | `en-us` |
76
+ | `--execute <cmd>` | `-e` | release 版本号升级后、git commit 前执行的额外命令 | `pnpm sa changelog` |
77
+ | `--push` | `-p` | release 完成后是否自动 push | `true` |
78
+ | `--total` | `-t` | changelog 命令:基于所有历史 tag 生成完整 changelog | `false` |
79
+ | `--cleanupDir <dir>` | `-c` | cleanup 命令:自定义清理目录的 glob 匹配模式,多个用 `,` 分隔 | 见配置默认值 |
80
+
81
+ ## 命令详情
82
+
83
+ ### `sa create-admin`
84
+
85
+ 基于内置 admin 模板生成一个新的 Vite + React admin app。默认输出到 `apps/<name>`,并自动写入 `package.json`、`.env` 中的应用名称、描述和 storage prefix。模板只保留最小登录、错误兜底和一个 Home 页面,业务页面由新项目自己添加。
86
+
87
+ #### 两种模式
88
+
89
+ 模板是 `apps/admin` 的逐字节快照,里面满是只有本 monorepo 才能解析的写法:`workspace:*`、`catalog:dev`、指向 `internal/` 的 tsconfig / oxlint extends 链。这些写法在仓库外一律无解,因此生成时有两种模式:
90
+
91
+ | 模式 | 触发方式 | 依赖协议 | 适用场景 |
92
+ | --- | --- | --- | --- |
93
+ | **standalone**(默认) | 不加参数 | 物化成具体版本号 | 在本仓库之外生成一个独立工程 |
94
+ | **workspace** | `--workspace` | 原样保留 | 在本仓库内新增一个 app |
95
+
96
+ **standalone 模式**会额外做这些改写,让生成的工程 `pnpm install` 就能装上:
97
+
98
+ - `workspace:*` / `catalog:xxx` → 具体 semver(`workspace:*` 取 `^<version>`,让新项目还能跟着上游收补丁)
99
+ - `tsconfig.json`、`.oxlintrc.json` 的 extends 链就地展平,不再依赖 `@skyroc/tsconfig` 和 `internal/config/`
100
+ - 从 `pnpm-workspace.yaml` 继承的 `overrides` 写进 `pnpm.overrides`
101
+ - 重置 `version` 为 `0.0.0`、`private` 为 `true`,并移除 skyroc-admin 的 `homepage` / `repository` / `author` / `website` 等身份字段
102
+ - 移除靠 `pnpm --filter` 构建同仓库包的 `build:admin-vite` 与 `pre*` 钩子
103
+ - `uno.config.ts` 的 `filesystem` 扫描路径改指向 `node_modules`
104
+ - 补上 `.gitignore` 与 `README.md`(模板本身没有)
105
+
106
+ **workspace 模式**只改 `package.json` 的 `name` / `description` 和 `.env`,其余原样保留——留在仓库内的 app 本来就该复用 workspace 协议。
107
+
108
+ ```bash
109
+ # 独立工程(默认)
110
+ pnpm sa create-admin my-admin --target ~/projects/my-admin
111
+
112
+ # 仓库内新增 app,保留 workspace:/catalog: 协议
113
+ pnpm sa create-admin my-admin --workspace
114
+
115
+ # 指定目录
116
+ pnpm sa create-admin my-admin --target apps/admin-template
117
+
118
+ # 覆盖已存在目录
119
+ pnpm sa create-admin my-admin --force
120
+
121
+ # 自定义应用标题和描述
122
+ pnpm sa create-admin my-admin --title "My Admin" --description "Internal admin console"
123
+
124
+ # 生成后立即安装
125
+ pnpm sa create-admin my-admin --install
126
+ ```
127
+
128
+ > **注意**:物化只负责把协议翻译成 registry 能识别的版本号,不保证这些包真的发布过。生成时若发现依赖里有
129
+ > `private: true` 的 workspace 包,命令会显式告警。admin shell(`@skyroc/web-admin-shell`)不受此限——它不进
130
+ > 依赖列表,源码会被直接复制进生成项目的 `src/framework`。
131
+
132
+ #### 选项
133
+
134
+ | 选项 | 说明 |
135
+ | --- | --- |
136
+ | `--target <dir>` | 目标目录,默认 `apps/<name>` |
137
+ | `--title <title>` | 应用标题,写入 `VITE_APP_TITLE`,默认由包名推导 |
138
+ | `--description <desc>` | 应用描述,写入 `package.json` 与 `VITE_APP_DESC` |
139
+ | `--force` | 目标目录非空时先删除再生成 |
140
+ | `--install` | 生成后执行 `pnpm install` |
141
+ | `--workspace` | 保留 monorepo 协议,供仓库内使用 |
142
+
143
+ ### `sa sync-admin-template`
144
+
145
+ 从 `apps/admin` 生成 `packages/@core/scripts/templates/admin`。`apps/admin` 是唯一源码,模板目录是发布快照,不手工维护。
146
+
147
+ 同步产出两样东西:
148
+
149
+ 1. `templates/admin/` —— `apps/admin` 的逐字节镜像。跳过 `node_modules`、`dist`、`.turbo`、`.tanstack`、`coverage`、`.DS_Store`、本地 `.env.*.local` 和 `src/features/router/routeTree.gen.ts`,再根据模板自身的 `src/pages` 重新生成 `routeTree.gen.ts`。
150
+ 2. `templates/admin.meta.json` —— 物化元数据。**只有在 monorepo 内才解析得出**,所以必须在同步期算好:解析后的依赖版本、展平后的 tsconfig 与 oxlint 配置、根级 `overrides`、以及未发布的 workspace 包清单。`create-admin` 的 standalone 模式只读这份文件做替换,不需要 monorepo 在场。
151
+
152
+ 元数据放在 `templates/admin/` **外层**,这样快照目录仍是纯镜像,逐字节比对不需要为 sidecar 开特例。
153
+
154
+ ```bash
155
+ # 同步模板 + 元数据
156
+ pnpm sa sync-admin-template
157
+
158
+ # 只检查是否落后(模板与元数据都会比对),适合 CI
159
+ pnpm sa sync-admin-template --check
160
+ ```
161
+
162
+ > 本命令依赖 `@tanstack/router-generator` 生成路由树,该包是 devDependency 且按需加载——它只服务于仓库内的同步流程,
163
+ > 不该让所有安装了 `@skyroc/scripts` 的用户都背上这个重依赖。在仓库外执行会得到一条明确的报错。
164
+
165
+ ### `sa git-commit`
166
+
167
+ 交互式引导完成一次符合 [Conventional Commits](https://conventionalcommits.org) 规范的 git 提交。
168
+
169
+ **交互流程:**
170
+
171
+ 1. 选择提交类型(type)
172
+ 2. 选择提交范围(scope)
173
+ 3. 输入描述(description)
174
+ - 描述以 `!` 开头时,自动标记为破坏性变更(`breaking change`)
175
+
176
+ **生成格式:**
177
+
178
+ ```
179
+ <type>(<scope>): <description>
180
+ # 例:feat(components): add new Button component
181
+ # 破坏性变更:feat(api)!: remove deprecated endpoints
182
+ ```
183
+
184
+ **支持的提交类型:**
185
+
186
+ | 类型 | 说明 |
187
+ | --- | --- |
188
+ | `feat` | 新功能 |
189
+ | `feat-wip` | 开发中的功能(partial commit) |
190
+ | `fix` | Bug 修复 |
191
+ | `docs` | 仅文档变更 |
192
+ | `typo` | 代码或文档中的拼写/笔误修正 |
193
+ | `style` | 不影响代码含义的格式调整 |
194
+ | `refactor` | 既不修复 bug 也不添加功能的代码重构 |
195
+ | `perf` | 性能优化 |
196
+ | `optimize` | 代码质量优化 |
197
+ | `test` | 测试相关 |
198
+ | `build` | 构建系统或外部依赖变更 |
199
+ | `ci` | CI 配置变更 |
200
+ | `chore` | 其他杂项变更 |
201
+ | `revert` | 回退先前提交 |
202
+
203
+ **支持的提交范围:**
204
+
205
+ | 范围 | 说明 |
206
+ | --- | --- |
207
+ | `projects` | 整体项目 |
208
+ | `packages` | 子包 |
209
+ | `components` | 组件 |
210
+ | `hooks` | Hook 函数 |
211
+ | `utils` | 工具函数 |
212
+ | `types` | TypeScript 类型声明 |
213
+ | `styles` | 样式 |
214
+ | `deps` | 项目依赖 |
215
+ | `release` | 版本发布 |
216
+ | `other` | 其他 |
217
+
218
+ ---
219
+
220
+ ### `sa git-commit-verify`
221
+
222
+ 读取本次提交的信息,校验其是否符合 Conventional Commits 规范:
223
+
224
+ ```
225
+ <type>(<scope>)?(!)?: <description>
226
+ ```
227
+
228
+ 校验规则:
229
+
230
+ - **首尾锚定**——只校验提交信息的第一行,且必须整行匹配。`随便写点什么 xx: yy` 不放行。
231
+ - **type 走白名单**——只接受上表列出的 14 个类型,`banana: x` 不放行;大小写敏感,`FEAT:` 不放行。
232
+ - **描述不能为空**——`feat(x): ` 不放行。
233
+
234
+ 提交信息文件通过 `git rev-parse --git-path COMMIT_EDITMSG` 定位,因此在 git worktree 下同样可用(worktree 里的 `.git` 是文件而不是目录,手工拼 `<toplevel>/.git/...` 会拿到一个不存在的路径)。
235
+
236
+ 不符合则抛出错误并终止提交。
237
+
238
+ **在 git hook 中使用:**
239
+
240
+ ```bash
241
+ # .husky/commit-msg
242
+ pnpm sa git-commit-verify
243
+ ```
244
+
245
+ 以下格式的提交信息会被自动放行(不校验):
246
+
247
+ - Merge Pull Request
248
+ - Merge branch / tag / remote-tracking branch
249
+ - Revert 提交
250
+ - amend / fixup / squash 操作
251
+ - 自动合并提交
252
+
253
+ ---
254
+
255
+ ### `sa changelog`
256
+
257
+ 基于 git tag 差异,调用 `@soybeanjs/changelog` 生成或追加 `CHANGELOG.md`。
258
+
259
+ ```bash
260
+ # 生成最新 tag 以来的变更
261
+ pnpm sa changelog
262
+
263
+ # 基于所有历史 tag 重新生成完整 changelog
264
+ pnpm sa changelog --total
265
+ ```
266
+
267
+ ---
268
+
269
+ ### `sa release`
270
+
271
+ 一键完成完整发版流程:
272
+
273
+ ```
274
+ 1. 交互式选择新版本号(bumpp)
275
+ 2. 更新所有 package.json 中的 version 字段(包含子包,排除 node_modules)
276
+ 3. 执行 --execute 指定的命令(默认:pnpm sa changelog)
277
+ 4. 创建 git commit:chore(projects): release v<version>
278
+ 5. 打 git tag:v<version>
279
+ 6. push commit + tag(可通过 --push false 跳过)
280
+ ```
281
+
282
+ ```bash
283
+ # 标准发版(自动 push)
284
+ pnpm sa release
285
+
286
+ # 发版但不 push(本地验证后手动 push)
287
+ pnpm sa release --push false
288
+
289
+ # 发版后执行自定义命令(替换默认的 changelog 生成)
290
+ pnpm sa release --execute "pnpm build && pnpm sa changelog"
291
+ ```
292
+
293
+ ---
294
+
295
+ ### `sa cleanup`
296
+
297
+ 批量删除项目中匹配 glob 模式的目录或文件,适合在切换分支或提交 PR 前彻底清理构建产物。
298
+
299
+ ```bash
300
+ # 使用默认清理规则
301
+ pnpm sa cleanup
302
+
303
+ # 仅清理指定目录(覆盖默认规则)
304
+ pnpm sa cleanup --cleanupDir "**/dist,**/node_modules"
305
+ ```
306
+
307
+ **默认清理规则:**
308
+
309
+ ```
310
+ **/dist
311
+ **/package-lock.json
312
+ **/yarn.lock
313
+ **/pnpm-lock.yaml
314
+ **/node_modules
315
+ ```
316
+
317
+ ---
318
+
319
+ ### `sa update-pkg`
320
+
321
+ 调用 `npm-check-updates` 检测并升级 `package.json` 依赖版本。
322
+
323
+ ```bash
324
+ # 使用默认参数(--deep -u,递归更新所有子包并写入 package.json)
325
+ pnpm sa update-pkg
326
+ ```
327
+
328
+ 更新完成后需重新执行 `pnpm install` 使变更生效:
329
+
330
+ ```bash
331
+ pnpm sa update-pkg && pnpm install
332
+ ```
333
+
334
+ ## 配置
335
+
336
+ `@skyroc/scripts` 通过 [c12](https://github.com/unjs/c12) 加载配置,支持以下配置文件(位于项目根目录):
337
+
338
+ ```
339
+ skyroc.config.ts
340
+ skyroc.config.js
341
+ skyroc.config.mjs
342
+ package.json 中的 "skyroc" 字段
343
+ ```
344
+
345
+ 历史遗留的 `soybean.config.*` / `package.json` 的 `"soybean"` 字段仍然会被读取,`skyroc.*` 覆盖在它之上。新项目请直接用 `skyroc.*`。
346
+
347
+ ### 配置项
348
+
349
+ ```ts
350
+ interface CliOption {
351
+ /**
352
+ * 项目根目录
353
+ * @default process.cwd()
354
+ */
355
+ cwd: string;
356
+
357
+ /**
358
+ * cleanup 命令的清理目录 glob 模式列表
359
+ * 语法参考:https://github.com/isaacs/minimatch
360
+ * @default ["**/dist", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/node_modules"]
361
+ */
362
+ cleanupDirs: string[];
363
+
364
+ /**
365
+ * update-pkg 命令传给 npm-check-updates 的参数
366
+ * @default ['--deep', '-u']
367
+ */
368
+ ncuCommandArgs: string[];
369
+
370
+ /**
371
+ * changelog 命令的配置项
372
+ * 参考:https://github.com/soybeanjs/changelog
373
+ */
374
+ changelogOptions: Partial<ChangelogOption>;
375
+
376
+ /**
377
+ * git-commit-verify 放行的提交信息正则列表
378
+ * 匹配任意一项则跳过校验
379
+ */
380
+ gitCommitVerifyIgnores: RegExp[];
381
+ }
382
+ ```
383
+
384
+ ### 配置示例
385
+
386
+ ```ts
387
+ // skyroc.config.ts
388
+ import { defineConfig } from '@skyroc/scripts';
389
+
390
+ export default defineConfig({
391
+ cleanupDirs: ['**/dist', '**/node_modules'],
392
+ ncuCommandArgs: ['--deep', '-u', '--reject', 'react'],
393
+ changelogOptions: {
394
+ // 参考 @soybeanjs/changelog 文档
395
+ },
396
+ gitCommitVerifyIgnores: [
397
+ /^WIP:/
398
+ ]
399
+ });
400
+ ```
401
+
402
+ ## 在 Git Hooks 中集成
403
+
404
+ 推荐搭配 [husky](https://github.com/typicode/husky) 使用:
405
+
406
+ ```bash
407
+ # .husky/commit-msg
408
+ pnpm sa git-commit-verify
409
+ ```
410
+
411
+ ```json
412
+ // package.json
413
+ {
414
+ "scripts": {
415
+ "commit": "sa git-commit",
416
+ "prepare": "husky install"
417
+ }
418
+ }
419
+ ```
420
+
421
+ ## 语言支持
422
+
423
+ `--lang` 选项控制交互界面语言,目前支持:
424
+
425
+ | 值 | 说明 |
426
+ | --- | --- |
427
+ | `en-us` | 英文(默认) |
428
+ | `zh-cn` | 简体中文 |
429
+
430
+ ```bash
431
+ pnpm sa git-commit --lang zh-cn
432
+ ```
433
+
434
+ ## 测试
435
+
436
+ 纯函数(依赖协议解析、配置展平、glob 匹配、包名与 env 改写、提交信息正则)都有单测覆盖:
437
+
438
+ ```bash
439
+ pnpm --filter @skyroc/scripts test
440
+ pnpm --filter @skyroc/scripts test:coverage
441
+ ```
442
+
443
+ ## 架构
444
+
445
+ ```
446
+ packages/@core/scripts/
447
+ ├── bin.ts # CLI 入口(开发时通过 tsx 执行)
448
+ ├── src/
449
+ │ ├── cli.ts # setupCli():注册命令、解析 argv、统一收口错误
450
+ │ ├── index.ts # 库入口:defineConfig() 与各命令的具名导出
451
+ │ ├── commands/
452
+ │ │ ├── changelog.ts # genChangelog()
453
+ │ │ ├── cleanup.ts # cleanup()
454
+ │ │ ├── create-admin.ts # createAdminTemplate()
455
+ │ │ ├── git-commit.ts # gitCommit() / gitCommitVerify()
456
+ │ │ ├── release.ts # release()
457
+ │ │ ├── sync-admin-template.ts # syncAdminTemplate()
458
+ │ │ └── update-pkg.ts # updatePkg()
459
+ │ ├── template/
460
+ │ │ ├── meta.ts # TemplateMeta 类型 + sidecar 读写(两端共享)
461
+ │ │ ├── resolve.ts # monorepo 侧:解析 workspace:/catalog:/extends 链
462
+ │ │ └── materialize.ts # 消费侧:把 meta 套用到生成目录
463
+ │ ├── config/
464
+ │ │ └── index.ts # loadCliOptions():c12 加载配置 + 默认值合并
465
+ │ ├── locales/
466
+ │ │ └── index.ts # 多语言文本(en-us / zh-cn)
467
+ │ ├── shared/
468
+ │ │ └── index.ts # execCommand() / getPackageRoot() / getWorkspaceRoot()
469
+ │ └── types/
470
+ │ └── index.ts # CliOption 类型定义
471
+ ├── __tests__/ # vitest 单测(纯函数)
472
+ ├── templates/
473
+ │ ├── admin/ # admin app 模板(apps/admin 的逐字节快照)
474
+ │ └── admin.meta.json # 物化元数据(同步期生成)
475
+ └── dist/
476
+ ├── cli.mjs # CLI 构建产物(bin 指向它)
477
+ └── index.mjs # 库构建产物
478
+ ```
479
+
480
+ **入口拆分**:`src/index.ts` 是纯库入口,不会有副作用;CLI 的自启动逻辑独立在 `src/cli.ts`。这样 `import { defineConfig } from '@skyroc/scripts'` 不会顺带把 CLI 跑起来。
481
+
482
+ **依赖说明:**
483
+
484
+ | 依赖 | 用途 |
485
+ | --- | --- |
486
+ | `cac` | CLI 框架,命令/选项注册与解析 |
487
+ | `bumpp` | 交互式版本号升级 |
488
+ | `@soybeanjs/changelog` | Changelog 生成 |
489
+ | `enquirer` | 终端交互式 prompt |
490
+ | `c12` | 配置文件加载(支持多种格式) |
491
+ | `confbox` | 解析 `pnpm-workspace.yaml`,读取 catalogs 与 overrides |
492
+ | `execa` | 跨平台子进程执行 |
493
+ | `npm-check-updates` | 依赖版本检测与更新 |
494
+ | `kolorist` | 终端颜色输出 |
495
+ | `rimraf` | 跨平台递归删除(`sa cleanup`) |
496
+
497
+ | devDependency | 用途 |
498
+ | --- | --- |
499
+ | `@tanstack/router-generator` | 仅 `sync-admin-template` 生成路由树时按需加载,不进 dependencies |
500
+
501
+ ## 设计原则
502
+
503
+ - **零侵入** — 配置文件可选,合理的默认值覆盖大多数场景
504
+ - **交互式优先** — 复杂操作(发版、提交)引导式完成,不靠记忆
505
+ - **可扩展** — 通过 `skyroc.config.ts` 覆盖任意默认行为
506
+ - **跨平台** — execa + rimraf,Windows / macOS / Linux 均可使用
507
+ - **解析与生成分离** — 只有 monorepo 内才解析得出的东西(依赖协议、extends 链),一律在同步期算好落成元数据;生成期只做替换,不假设 monorepo 在场
508
+ - **不静默降级** — 依赖解析不出来就报错而不是产出半成品;模板漂移、私有包装不上都会显式告警
package/dist/cli.mjs ADDED
@@ -0,0 +1,78 @@
1
+ import { h as genChangelog, i as release, l as createAdminTemplate, m as cleanup, n as updatePkg, o as gitCommit, r as syncAdminTemplate, s as gitCommitVerify, t as loadCliOptions } from "./config-BKkdncJS.mjs";
2
+ import process from "node:process";
3
+ import { blue, lightGreen, red } from "kolorist";
4
+ import { cac } from "cac";
5
+
6
+ //#region package.json
7
+ var version = "2.5.0";
8
+
9
+ //#endregion
10
+ //#region src/cli.ts
11
+ async function setupCli() {
12
+ const cliOptions = await loadCliOptions();
13
+ const cli = cac(blue("skyroc-admin"));
14
+ cli.version(lightGreen(version)).option("-e, --execute [command]", "Execute additional command after bumping and before git commit. Defaults to 'npx soy changelog'").option("-p, --push", "Indicates whether to push the git commit and tag").option("-t, --total", "Generate changelog by total tags").option("-c, --cleanupDir <dir>", "The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use \",\" to separate them").option("-l, --lang <lang>", "display lang of cli", { default: "en-us" }).help();
15
+ const commands = {
16
+ changelog: {
17
+ action: async (args) => {
18
+ await genChangelog(cliOptions.changelogOptions, args?.total);
19
+ },
20
+ desc: "generate changelog"
21
+ },
22
+ cleanup: {
23
+ action: async () => {
24
+ await cleanup(cliOptions.cleanupDirs);
25
+ },
26
+ desc: "delete dirs: node_modules, dist, etc."
27
+ },
28
+ "git-commit": {
29
+ action: async (args) => {
30
+ await gitCommit(args?.lang);
31
+ },
32
+ desc: "git commit, generate commit message which match Conventional Commits standard"
33
+ },
34
+ "git-commit-verify": {
35
+ action: async (args) => {
36
+ await gitCommitVerify(args?.lang, cliOptions.gitCommitVerifyIgnores);
37
+ },
38
+ desc: "verify git commit message, make sure it match Conventional Commits standard"
39
+ },
40
+ release: {
41
+ action: async (args) => {
42
+ await release(args?.execute, args?.push);
43
+ },
44
+ desc: "release: update version, generate changelog, commit code"
45
+ },
46
+ "update-pkg": {
47
+ action: async () => {
48
+ await updatePkg(cliOptions.ncuCommandArgs);
49
+ },
50
+ desc: "update package.json dependencies versions"
51
+ }
52
+ };
53
+ for (const [command, { action, desc }] of Object.entries(commands)) cli.command(command, lightGreen(desc)).action(action);
54
+ cli.command("create-admin <name>", lightGreen("create a new Skyroc admin app from the built-in template")).option("--target <dir>", "target directory, defaults to apps/<name>").option("--title <title>", "app title written to VITE_APP_TITLE").option("--description <description>", "app description written to package.json and VITE_APP_DESC").option("--force", "overwrite target directory if it already exists").option("--install", "run pnpm install after generation").option("--workspace", "keep workspace:/catalog: protocols, for apps that stay inside this monorepo").action(async (name, args) => {
55
+ await createAdminTemplate(name, args);
56
+ });
57
+ cli.command("sync-admin-template", lightGreen("sync the built-in admin template from apps/admin")).option("--check", "check whether the admin template is up to date without writing files").option("--source <dir>", "source admin app directory, defaults to apps/admin").option("--target <dir>", "target template directory, defaults to packages/@core/scripts/templates/admin").action(async (args) => {
58
+ await syncAdminTemplate(args);
59
+ });
60
+ cli.command("").action(() => {
61
+ cli.outputHelp();
62
+ });
63
+ cli.parse(process.argv, { run: false });
64
+ await cli.runMatchedCommand();
65
+ }
66
+ /**
67
+ * 命令是异步的,而 cac 的 action 返回的 promise 不会被它自己接住。
68
+ *
69
+ * 不在这里收口的话,所有失败都会变成 unhandled rejection——用户看到的是一整段 Node 堆栈,而命令精心排版的错误提示被埋在里面。
70
+ */
71
+ setupCli().catch((error) => {
72
+ const message = error instanceof Error ? error.message : String(error);
73
+ console.error(`${red("✖")} ${message}`);
74
+ process.exit(1);
75
+ });
76
+
77
+ //#endregion
78
+ export { setupCli };