@yixiaoermail/cli 3.2.27 → 3.2.29

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 (343) hide show
  1. package/README.md +54 -54
  2. package/bin/ensure-executable.js +25 -25
  3. package/bin/install.js +311 -311
  4. package/bin/postinstall.js +14 -14
  5. package/bin/resolve-binary.js +22 -22
  6. package/bin/yxer.js +100 -100
  7. package/checksums.txt +6 -6
  8. package/package.json +30 -30
  9. package/references/cli/command-design.md +306 -306
  10. package/references/cli/command-reference.md +271 -271
  11. package/references/cli/publish-channels.md +77 -77
  12. package/references/create-account-group.md +27 -27
  13. package/references/delete-account-group.md +20 -20
  14. package/references/domains/accounts-and-env.md +46 -46
  15. package/references/domains/draft-and-material.md +41 -41
  16. package/references/domains/install-and-sync.md +63 -63
  17. package/references/domains/publish.md +87 -87
  18. package/references/domains/troubleshooting.md +38 -38
  19. package/references/execution-standard.md +145 -145
  20. package/references/get-account-groups.md +15 -15
  21. package/references/get-account-increments.md +55 -55
  22. package/references/get-account-overviews.md +56 -56
  23. package/references/get-challenges.md +14 -14
  24. package/references/get-collections.md +41 -34
  25. package/references/get-content-overviews.md +59 -59
  26. package/references/get-drama-tasks.md +43 -43
  27. package/references/get-friends.md +48 -48
  28. package/references/get-games.md +39 -39
  29. package/references/get-goods.md +52 -52
  30. package/references/get-groups.md +35 -35
  31. package/references/get-hot-events.md +14 -14
  32. package/references/get-locations.md +48 -48
  33. package/references/get-members.md +28 -28
  34. package/references/get-miniapps.md +38 -38
  35. package/references/get-music-categories.md +44 -44
  36. package/references/get-music.md +69 -69
  37. package/references/get-publish-activities.md +40 -40
  38. package/references/get-publish-categories.md +67 -67
  39. package/references/get-sync-apps.md +14 -14
  40. package/references/get-topics.md +13 -13
  41. package/references/go-live-process.md +160 -160
  42. package/references/keyword-reference.md +115 -115
  43. package/references/legacy/capabilities.md +39 -39
  44. package/references/material-resource.md +88 -88
  45. package/references/platform-doc-maintenance.md +33 -33
  46. package/references/platform.md +62 -62
  47. package/references/platforms/article/acfun.md +90 -90
  48. package/references/platforms/article/aiqiyi.md +56 -56
  49. package/references/platforms/article/baijiahao.md +94 -94
  50. package/references/platforms/article/bilibili.md +88 -88
  51. package/references/platforms/article/chejiahao.md +81 -81
  52. package/references/platforms/article/csdn.md +86 -86
  53. package/references/platforms/article/dayuhao.md +78 -78
  54. package/references/platforms/article/douban.md +62 -62
  55. package/references/platforms/article/douyin.md +106 -106
  56. package/references/platforms/article/index.md +158 -157
  57. package/references/platforms/article/jianshu.md +56 -56
  58. package/references/platforms/article/kuaichuanhao.md +78 -78
  59. package/references/platforms/article/qiehao.md +78 -78
  60. package/references/platforms/article/souhuhao.md +75 -75
  61. package/references/platforms/article/toutiaohao.md +80 -80
  62. package/references/platforms/article/wangyihao.md +79 -79
  63. package/references/platforms/article/weixingongzhonghao-open.md +86 -0
  64. package/references/platforms/article/weixingongzhonghao.md +174 -137
  65. package/references/platforms/article/xinlangweibo.md +75 -75
  66. package/references/platforms/article/xueqiuhao.md +73 -73
  67. package/references/platforms/article/yichehao.md +92 -92
  68. package/references/platforms/article/yidianhao.md +76 -76
  69. package/references/platforms/article/zhihu.md +75 -75
  70. package/references/platforms/imageText/baijiahao.md +102 -102
  71. package/references/platforms/imageText/douyin.md +111 -111
  72. package/references/platforms/imageText/index.md +117 -117
  73. package/references/platforms/imageText/kuaishou.md +106 -106
  74. package/references/platforms/imageText/shipinhao.md +112 -112
  75. package/references/platforms/imageText/taobaoguanghe.md +26 -26
  76. package/references/platforms/imageText/toutiaohao.md +78 -78
  77. package/references/platforms/imageText/weixingongzhonghao.md +106 -90
  78. package/references/platforms/imageText/xiaohongshu.md +98 -98
  79. package/references/platforms/imageText/xinlangweibo.md +77 -77
  80. package/references/platforms/imageText/zhihu.md +92 -92
  81. package/references/platforms/index.md +20 -20
  82. package/references/platforms/video/acfun.md +82 -82
  83. package/references/platforms/video/aiqiyi.md +89 -89
  84. package/references/platforms/video/baijiahao.md +130 -130
  85. package/references/platforms/video/bilibili-open.md +59 -59
  86. package/references/platforms/video/bilibili.md +80 -80
  87. package/references/platforms/video/chejiahao.md +63 -63
  88. package/references/platforms/video/dayuhao.md +91 -91
  89. package/references/platforms/video/dewu.md +80 -80
  90. package/references/platforms/video/douyin.md +173 -173
  91. package/references/platforms/video/duoduoshipin.md +82 -82
  92. package/references/platforms/video/facebook.md +37 -37
  93. package/references/platforms/video/fengwang.md +81 -81
  94. package/references/platforms/video/index.md +176 -176
  95. package/references/platforms/video/instagram.md +40 -40
  96. package/references/platforms/video/kuaishou-open.md +44 -44
  97. package/references/platforms/video/kuaishou.md +77 -77
  98. package/references/platforms/video/meipai.md +79 -79
  99. package/references/platforms/video/meiyou.md +59 -59
  100. package/references/platforms/video/pipixia.md +58 -58
  101. package/references/platforms/video/qiehao.md +91 -91
  102. package/references/platforms/video/shipinhao.md +142 -141
  103. package/references/platforms/video/souhuhao.md +107 -107
  104. package/references/platforms/video/souhushipin.md +64 -64
  105. package/references/platforms/video/taobaoguanghe.md +26 -26
  106. package/references/platforms/video/tengxunshipin.md +63 -63
  107. package/references/platforms/video/tiktok.md +52 -50
  108. package/references/platforms/video/toutiaohao.md +68 -68
  109. package/references/platforms/video/wangyihao.md +93 -93
  110. package/references/platforms/video/weishi.md +61 -61
  111. package/references/platforms/video/xiaohongshu.md +150 -150
  112. package/references/platforms/video/xiaohongshushop.md +92 -92
  113. package/references/platforms/video/xinlangweibo.md +79 -79
  114. package/references/platforms/video/yichehao.md +61 -61
  115. package/references/platforms/video/yidianhao.md +85 -85
  116. package/references/platforms/video/youtube.md +53 -53
  117. package/references/platforms/video/zhihu.md +85 -85
  118. package/references/protocols/confirmation.md +63 -63
  119. package/references/protocols/error-recovery.md +51 -51
  120. package/references/protocols/execution.md +65 -65
  121. package/references/protocols/provenance.md +62 -62
  122. package/references/proxy-management.md +69 -69
  123. package/references/query-accounts.md +85 -85
  124. package/references/save-draft.md +75 -75
  125. package/references/topic-tags.md +140 -140
  126. package/references/troubleshooting-guide.md +105 -105
  127. package/references/update-account-group.md +28 -28
  128. package/references/usage-workflow.md +208 -208
  129. package/references/workflows/account-selection.md +38 -38
  130. package/references/workflows/common-rules.md +1 -1
  131. package/references/workflows/data-accuracy.md +86 -86
  132. package/references/workflows/draft-workflow.md +47 -47
  133. package/references/workflows/local-vs-cloud.md +57 -57
  134. package/references/workflows/material-workflow.md +64 -64
  135. package/references/workflows/payload-sourcing.md +82 -82
  136. package/references/workflows/publish-article.md +73 -73
  137. package/references/workflows/publish-imageText.md +67 -67
  138. package/references/workflows/publish-troubleshooting.md +59 -59
  139. package/references/workflows/publish-video.md +72 -72
  140. package/references/yixiaoer-shared.md +106 -106
  141. package/schemas/account.schema.json +19 -19
  142. package/schemas/platforms/acfun.article.schema.json +117 -117
  143. package/schemas/platforms/acfun.video.schema.json +139 -139
  144. package/schemas/platforms/aiqiyi.article.schema.json +29 -29
  145. package/schemas/platforms/aiqiyi.video.schema.json +154 -154
  146. package/schemas/platforms/baijiahao.article.schema.json +168 -168
  147. package/schemas/platforms/baijiahao.imageText.schema.json +111 -111
  148. package/schemas/platforms/baijiahao.video.schema.json +227 -227
  149. package/schemas/platforms/bilibili-open.video.schema.json +168 -168
  150. package/schemas/platforms/bilibili.article.schema.json +109 -109
  151. package/schemas/platforms/bilibili.video.schema.json +175 -175
  152. package/schemas/platforms/chejiahao.article.schema.json +108 -108
  153. package/schemas/platforms/chejiahao.video.schema.json +111 -111
  154. package/schemas/platforms/csdn.article.schema.json +106 -106
  155. package/schemas/platforms/dayuhao.article.schema.json +106 -106
  156. package/schemas/platforms/dayuhao.video.schema.json +174 -174
  157. package/schemas/platforms/dewu.video.schema.json +134 -134
  158. package/schemas/platforms/douban.article.schema.json +48 -48
  159. package/schemas/platforms/douyin.article.schema.json +326 -326
  160. package/schemas/platforms/douyin.imageText.schema.json +301 -301
  161. package/schemas/platforms/douyin.video.schema.json +930 -930
  162. package/schemas/platforms/duoduoshipin.video.schema.json +124 -124
  163. package/schemas/platforms/facebook.video.schema.json +28 -28
  164. package/schemas/platforms/fengwang.video.schema.json +135 -135
  165. package/schemas/platforms/instagram.video.schema.json +28 -28
  166. package/schemas/platforms/jianshu.article.schema.json +33 -33
  167. package/schemas/platforms/kuaichuanhao.article.schema.json +95 -95
  168. package/schemas/platforms/kuaishou-open.video.schema.json +102 -102
  169. package/schemas/platforms/kuaishou.imageText.schema.json +181 -181
  170. package/schemas/platforms/kuaishou.video.schema.json +274 -274
  171. package/schemas/platforms/meipai.video.schema.json +123 -123
  172. package/schemas/platforms/meiyou.video.schema.json +96 -96
  173. package/schemas/platforms/pipixia.video.schema.json +94 -94
  174. package/schemas/platforms/qiehao.article.schema.json +89 -89
  175. package/schemas/platforms/qiehao.video.schema.json +147 -147
  176. package/schemas/platforms/shipinhao.imageText.schema.json +151 -151
  177. package/schemas/platforms/shipinhao.video.schema.json +283 -283
  178. package/schemas/platforms/souhuhao.article.schema.json +73 -73
  179. package/schemas/platforms/souhuhao.video.schema.json +171 -171
  180. package/schemas/platforms/souhushipin.video.schema.json +115 -115
  181. package/schemas/platforms/taobaoguanghe.imageText.schema.json +56 -56
  182. package/schemas/platforms/taobaoguanghe.video.schema.json +40 -40
  183. package/schemas/platforms/tengxunshipin.video.schema.json +115 -115
  184. package/schemas/platforms/tiktok.video.schema.json +72 -72
  185. package/schemas/platforms/toutiaohao.article.schema.json +162 -162
  186. package/schemas/platforms/toutiaohao.imageText.schema.json +87 -87
  187. package/schemas/platforms/toutiaohao.video.schema.json +138 -138
  188. package/schemas/platforms/wangyihao.article.schema.json +86 -86
  189. package/schemas/platforms/wangyihao.video.schema.json +152 -152
  190. package/schemas/platforms/weishi.video.schema.json +101 -101
  191. package/schemas/platforms/weixin.account-open.article.schema.json +106 -0
  192. package/schemas/platforms/weixin.account.article.schema.json +257 -148
  193. package/schemas/platforms/weixin.account.imageText.schema.json +218 -118
  194. package/schemas/platforms/xhs.imageText.schema.json +133 -133
  195. package/schemas/platforms/xiaohongshu.video.schema.json +226 -226
  196. package/schemas/platforms/xiaohongshushop.video.schema.json +142 -142
  197. package/schemas/platforms/xinlang.article.schema.json +69 -69
  198. package/schemas/platforms/xinlang.imageText.schema.json +107 -107
  199. package/schemas/platforms/xinlang.video.schema.json +182 -182
  200. package/schemas/platforms/xueqiuhao.article.schema.json +84 -84
  201. package/schemas/platforms/yichehao.article.schema.json +140 -140
  202. package/schemas/platforms/yichehao.video.schema.json +101 -101
  203. package/schemas/platforms/yidianhao.article.schema.json +78 -78
  204. package/schemas/platforms/yidianhao.video.schema.json +152 -152
  205. package/schemas/platforms/youtube.video.schema.json +92 -92
  206. package/schemas/platforms/zhihu.article.schema.json +104 -104
  207. package/schemas/platforms/zhihu.imageText.schema.json +61 -61
  208. package/schemas/platforms/zhihu.video.schema.json +144 -144
  209. package/schemas/publish.schema.json +26 -26
  210. package/skills/yixiaoer/QUICKSTART.md +265 -265
  211. package/skills/yixiaoer/SKILL.md +1 -1
  212. package/skills/yixiaoer/references/cli/command-design.md +306 -306
  213. package/skills/yixiaoer/references/cli/command-reference.md +271 -271
  214. package/skills/yixiaoer/references/cli/publish-channels.md +77 -77
  215. package/skills/yixiaoer/references/create-account-group.md +27 -27
  216. package/skills/yixiaoer/references/delete-account-group.md +20 -20
  217. package/skills/yixiaoer/references/domains/accounts-and-env.md +46 -46
  218. package/skills/yixiaoer/references/domains/draft-and-material.md +41 -41
  219. package/skills/yixiaoer/references/domains/install-and-sync.md +63 -63
  220. package/skills/yixiaoer/references/domains/publish.md +87 -87
  221. package/skills/yixiaoer/references/domains/troubleshooting.md +38 -38
  222. package/skills/yixiaoer/references/execution-standard.md +145 -145
  223. package/skills/yixiaoer/references/get-account-groups.md +15 -15
  224. package/skills/yixiaoer/references/get-account-increments.md +55 -55
  225. package/skills/yixiaoer/references/get-account-overviews.md +56 -56
  226. package/skills/yixiaoer/references/get-challenges.md +14 -14
  227. package/skills/yixiaoer/references/get-collections.md +41 -34
  228. package/skills/yixiaoer/references/get-content-overviews.md +59 -59
  229. package/skills/yixiaoer/references/get-drama-tasks.md +43 -43
  230. package/skills/yixiaoer/references/get-friends.md +48 -48
  231. package/skills/yixiaoer/references/get-games.md +39 -39
  232. package/skills/yixiaoer/references/get-goods.md +52 -52
  233. package/skills/yixiaoer/references/get-groups.md +35 -35
  234. package/skills/yixiaoer/references/get-hot-events.md +14 -14
  235. package/skills/yixiaoer/references/get-locations.md +48 -48
  236. package/skills/yixiaoer/references/get-members.md +28 -28
  237. package/skills/yixiaoer/references/get-miniapps.md +38 -38
  238. package/skills/yixiaoer/references/get-music-categories.md +44 -44
  239. package/skills/yixiaoer/references/get-music.md +69 -69
  240. package/skills/yixiaoer/references/get-publish-activities.md +40 -40
  241. package/skills/yixiaoer/references/get-publish-categories.md +67 -67
  242. package/skills/yixiaoer/references/get-sync-apps.md +14 -14
  243. package/skills/yixiaoer/references/get-topics.md +13 -13
  244. package/skills/yixiaoer/references/go-live-process.md +160 -160
  245. package/skills/yixiaoer/references/keyword-reference.md +115 -115
  246. package/skills/yixiaoer/references/legacy/capabilities.md +39 -39
  247. package/skills/yixiaoer/references/material-resource.md +88 -88
  248. package/skills/yixiaoer/references/platform-doc-maintenance.md +33 -33
  249. package/skills/yixiaoer/references/platform.md +62 -62
  250. package/skills/yixiaoer/references/platforms/article/acfun.md +90 -90
  251. package/skills/yixiaoer/references/platforms/article/aiqiyi.md +56 -56
  252. package/skills/yixiaoer/references/platforms/article/baijiahao.md +94 -94
  253. package/skills/yixiaoer/references/platforms/article/bilibili.md +88 -88
  254. package/skills/yixiaoer/references/platforms/article/chejiahao.md +81 -81
  255. package/skills/yixiaoer/references/platforms/article/csdn.md +86 -86
  256. package/skills/yixiaoer/references/platforms/article/dayuhao.md +78 -78
  257. package/skills/yixiaoer/references/platforms/article/douban.md +62 -62
  258. package/skills/yixiaoer/references/platforms/article/douyin.md +106 -106
  259. package/skills/yixiaoer/references/platforms/article/index.md +158 -157
  260. package/skills/yixiaoer/references/platforms/article/jianshu.md +56 -56
  261. package/skills/yixiaoer/references/platforms/article/kuaichuanhao.md +78 -78
  262. package/skills/yixiaoer/references/platforms/article/qiehao.md +78 -78
  263. package/skills/yixiaoer/references/platforms/article/souhuhao.md +75 -75
  264. package/skills/yixiaoer/references/platforms/article/toutiaohao.md +80 -80
  265. package/skills/yixiaoer/references/platforms/article/wangyihao.md +79 -79
  266. package/skills/yixiaoer/references/platforms/article/weixingongzhonghao-open.md +86 -0
  267. package/skills/yixiaoer/references/platforms/article/weixingongzhonghao.md +174 -137
  268. package/skills/yixiaoer/references/platforms/article/xinlangweibo.md +75 -75
  269. package/skills/yixiaoer/references/platforms/article/xueqiuhao.md +73 -73
  270. package/skills/yixiaoer/references/platforms/article/yichehao.md +92 -92
  271. package/skills/yixiaoer/references/platforms/article/yidianhao.md +76 -76
  272. package/skills/yixiaoer/references/platforms/article/zhihu.md +75 -75
  273. package/skills/yixiaoer/references/platforms/imageText/baijiahao.md +102 -102
  274. package/skills/yixiaoer/references/platforms/imageText/douyin.md +111 -111
  275. package/skills/yixiaoer/references/platforms/imageText/index.md +117 -117
  276. package/skills/yixiaoer/references/platforms/imageText/kuaishou.md +106 -106
  277. package/skills/yixiaoer/references/platforms/imageText/shipinhao.md +112 -112
  278. package/skills/yixiaoer/references/platforms/imageText/taobaoguanghe.md +26 -26
  279. package/skills/yixiaoer/references/platforms/imageText/toutiaohao.md +78 -78
  280. package/skills/yixiaoer/references/platforms/imageText/weixingongzhonghao.md +106 -90
  281. package/skills/yixiaoer/references/platforms/imageText/xiaohongshu.md +98 -98
  282. package/skills/yixiaoer/references/platforms/imageText/xinlangweibo.md +77 -77
  283. package/skills/yixiaoer/references/platforms/imageText/zhihu.md +92 -92
  284. package/skills/yixiaoer/references/platforms/index.md +20 -20
  285. package/skills/yixiaoer/references/platforms/video/acfun.md +82 -82
  286. package/skills/yixiaoer/references/platforms/video/aiqiyi.md +89 -89
  287. package/skills/yixiaoer/references/platforms/video/baijiahao.md +130 -130
  288. package/skills/yixiaoer/references/platforms/video/bilibili-open.md +59 -59
  289. package/skills/yixiaoer/references/platforms/video/bilibili.md +80 -80
  290. package/skills/yixiaoer/references/platforms/video/chejiahao.md +63 -63
  291. package/skills/yixiaoer/references/platforms/video/dayuhao.md +91 -91
  292. package/skills/yixiaoer/references/platforms/video/dewu.md +80 -80
  293. package/skills/yixiaoer/references/platforms/video/douyin.md +173 -173
  294. package/skills/yixiaoer/references/platforms/video/duoduoshipin.md +82 -82
  295. package/skills/yixiaoer/references/platforms/video/facebook.md +37 -37
  296. package/skills/yixiaoer/references/platforms/video/fengwang.md +81 -81
  297. package/skills/yixiaoer/references/platforms/video/index.md +176 -176
  298. package/skills/yixiaoer/references/platforms/video/instagram.md +40 -40
  299. package/skills/yixiaoer/references/platforms/video/kuaishou-open.md +44 -44
  300. package/skills/yixiaoer/references/platforms/video/kuaishou.md +77 -77
  301. package/skills/yixiaoer/references/platforms/video/meipai.md +79 -79
  302. package/skills/yixiaoer/references/platforms/video/meiyou.md +59 -59
  303. package/skills/yixiaoer/references/platforms/video/pipixia.md +58 -58
  304. package/skills/yixiaoer/references/platforms/video/qiehao.md +91 -91
  305. package/skills/yixiaoer/references/platforms/video/shipinhao.md +142 -141
  306. package/skills/yixiaoer/references/platforms/video/souhuhao.md +107 -107
  307. package/skills/yixiaoer/references/platforms/video/souhushipin.md +64 -64
  308. package/skills/yixiaoer/references/platforms/video/taobaoguanghe.md +26 -26
  309. package/skills/yixiaoer/references/platforms/video/tengxunshipin.md +63 -63
  310. package/skills/yixiaoer/references/platforms/video/tiktok.md +52 -50
  311. package/skills/yixiaoer/references/platforms/video/toutiaohao.md +68 -68
  312. package/skills/yixiaoer/references/platforms/video/wangyihao.md +93 -93
  313. package/skills/yixiaoer/references/platforms/video/weishi.md +61 -61
  314. package/skills/yixiaoer/references/platforms/video/xiaohongshu.md +150 -150
  315. package/skills/yixiaoer/references/platforms/video/xiaohongshushop.md +92 -92
  316. package/skills/yixiaoer/references/platforms/video/xinlangweibo.md +79 -79
  317. package/skills/yixiaoer/references/platforms/video/yichehao.md +61 -61
  318. package/skills/yixiaoer/references/platforms/video/yidianhao.md +85 -85
  319. package/skills/yixiaoer/references/platforms/video/youtube.md +53 -53
  320. package/skills/yixiaoer/references/platforms/video/zhihu.md +85 -85
  321. package/skills/yixiaoer/references/protocols/confirmation.md +63 -63
  322. package/skills/yixiaoer/references/protocols/error-recovery.md +51 -51
  323. package/skills/yixiaoer/references/protocols/execution.md +65 -65
  324. package/skills/yixiaoer/references/protocols/provenance.md +62 -62
  325. package/skills/yixiaoer/references/proxy-management.md +69 -69
  326. package/skills/yixiaoer/references/query-accounts.md +85 -85
  327. package/skills/yixiaoer/references/save-draft.md +75 -75
  328. package/skills/yixiaoer/references/topic-tags.md +140 -140
  329. package/skills/yixiaoer/references/troubleshooting-guide.md +105 -105
  330. package/skills/yixiaoer/references/update-account-group.md +28 -28
  331. package/skills/yixiaoer/references/usage-workflow.md +208 -208
  332. package/skills/yixiaoer/references/workflows/account-selection.md +38 -38
  333. package/skills/yixiaoer/references/workflows/common-rules.md +1 -1
  334. package/skills/yixiaoer/references/workflows/data-accuracy.md +86 -86
  335. package/skills/yixiaoer/references/workflows/draft-workflow.md +47 -47
  336. package/skills/yixiaoer/references/workflows/local-vs-cloud.md +57 -57
  337. package/skills/yixiaoer/references/workflows/material-workflow.md +64 -64
  338. package/skills/yixiaoer/references/workflows/payload-sourcing.md +82 -82
  339. package/skills/yixiaoer/references/workflows/publish-article.md +73 -73
  340. package/skills/yixiaoer/references/workflows/publish-imageText.md +67 -67
  341. package/skills/yixiaoer/references/workflows/publish-troubleshooting.md +59 -59
  342. package/skills/yixiaoer/references/workflows/publish-video.md +72 -72
  343. package/skills/yixiaoer/references/yixiaoer-shared.md +106 -106
package/bin/install.js CHANGED
@@ -1,311 +1,311 @@
1
- #!/usr/bin/env node
2
-
3
- const crypto = require("node:crypto");
4
- const fs = require("node:fs");
5
- const os = require("node:os");
6
- const path = require("node:path");
7
- const { execFileSync } = require("node:child_process");
8
- const { ensureExecutable } = require("./ensure-executable");
9
-
10
- const PACKAGE_NAME = "yxer";
11
- const ARCHIVE_PREFIX = "yxer-cli";
12
- const packageInfo = require("../package.json");
13
- const VERSION = packageInfo.version.replace(/-.*$/, "");
14
- if (!packageInfo.yxerDownloadRootUrl) {
15
- throw new Error("Missing yxerDownloadRootUrl in package.json");
16
- }
17
-
18
- function buildVersionBaseUrl(rootUrl, version) {
19
- return `${rootUrl.replace(/\/+$/, "")}/v${version}`;
20
- }
21
-
22
- const DEFAULT_BASE_URL = buildVersionBaseUrl(packageInfo.yxerDownloadRootUrl, VERSION);
23
- const ALLOWED_HOSTS = new Set([
24
- new URL(DEFAULT_BASE_URL).hostname,
25
- "github.com",
26
- "objects.githubusercontent.com",
27
- "release-assets.githubusercontent.com",
28
- "registry.npmmirror.com"
29
- ]);
30
-
31
- const PLATFORM_MAP = {
32
- darwin: "darwin",
33
- linux: "linux",
34
- win32: "windows"
35
- };
36
-
37
- const ARCH_MAP = {
38
- x64: "amd64",
39
- arm64: "arm64"
40
- };
41
-
42
- function getTarget(platform = process.platform, arch = process.arch) {
43
- const mappedPlatform = PLATFORM_MAP[platform];
44
- const mappedArch = ARCH_MAP[arch];
45
- if (!mappedPlatform || !mappedArch) {
46
- return null;
47
- }
48
-
49
- const ext = platform === "win32" ? "zip" : "tar.gz";
50
- const binaryExt = platform === "win32" ? ".exe" : "";
51
- const baseName = `${ARCHIVE_PREFIX}-${VERSION}-${mappedPlatform}-${mappedArch}`;
52
-
53
- return {
54
- platform,
55
- arch,
56
- mappedPlatform,
57
- mappedArch,
58
- archiveName: `${baseName}.${ext}`,
59
- binaryName: `${PACKAGE_NAME}${binaryExt}`
60
- };
61
- }
62
-
63
- function isSupportedPlatform(platform = process.platform, arch = process.arch) {
64
- return getTarget(platform, arch) !== null;
65
- }
66
-
67
- function getBinDir(baseDir = __dirname) {
68
- return path.join(baseDir, "..", "bin-native");
69
- }
70
-
71
- function getChecksumsPath(baseDir = __dirname) {
72
- return path.join(baseDir, "..", "checksums.txt");
73
- }
74
-
75
- function getBinaryPath(baseDir = __dirname, platform = process.platform, arch = process.arch) {
76
- const target = getTarget(platform, arch);
77
- if (!target) {
78
- return null;
79
- }
80
-
81
- return path.join(getBinDir(baseDir), target.binaryName);
82
- }
83
-
84
- function assertAllowedHost(url) {
85
- const hostname = new URL(url).hostname;
86
- if (!ALLOWED_HOSTS.has(hostname)) {
87
- throw new Error(`Download host not allowed: ${hostname}`);
88
- }
89
- }
90
-
91
- function buildDownloadUrl(baseUrl, archiveName) {
92
- return `${baseUrl.replace(/\/+$/, "")}/${archiveName}`;
93
- }
94
-
95
- function downloadWithCurl(url, destPath, execFile = execFileSync) {
96
- assertAllowedHost(url);
97
-
98
- const args = [
99
- "--fail",
100
- "--location",
101
- "--silent",
102
- "--show-error",
103
- "--connect-timeout",
104
- "10",
105
- "--max-time",
106
- "120",
107
- "--max-redirs",
108
- "3",
109
- "--output",
110
- destPath
111
- ];
112
-
113
- if (process.platform === "win32") {
114
- args.unshift("--ssl-revoke-best-effort");
115
- }
116
-
117
- args.push(url);
118
- execFile("curl", args, { stdio: ["ignore", "ignore", "pipe"] });
119
- }
120
-
121
- function downloadWithPowerShell(url, destPath, execFile = execFileSync) {
122
- assertAllowedHost(url);
123
-
124
- const psCommand =
125
- "$ProgressPreference='SilentlyContinue';" +
126
- "$ErrorActionPreference='Stop';" +
127
- "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" +
128
- "Invoke-WebRequest -UseBasicParsing -Uri $env:YXER_URL -OutFile $env:YXER_DEST";
129
-
130
- execFile(
131
- "powershell.exe",
132
- ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", psCommand],
133
- {
134
- stdio: ["ignore", "ignore", "pipe"],
135
- env: {
136
- ...process.env,
137
- YXER_URL: url,
138
- YXER_DEST: destPath
139
- }
140
- }
141
- );
142
- }
143
-
144
- function download(url, destPath, platform = process.platform, execFile = execFileSync) {
145
- try {
146
- downloadWithCurl(url, destPath, execFile);
147
- } catch (error) {
148
- if (platform !== "win32") {
149
- throw error;
150
- }
151
-
152
- try {
153
- downloadWithPowerShell(url, destPath, execFile);
154
- } catch (fallbackError) {
155
- fallbackError.message =
156
- `${error.message}; fallback via PowerShell failed: ${fallbackError.message}`;
157
- throw fallbackError;
158
- }
159
- }
160
- }
161
-
162
- function parseChecksums(content) {
163
- const result = new Map();
164
- for (const line of content.split(/\r?\n/)) {
165
- const trimmed = line.trim();
166
- if (!trimmed) {
167
- continue;
168
- }
169
-
170
- const separator = trimmed.indexOf(" ");
171
- if (separator === -1) {
172
- continue;
173
- }
174
-
175
- result.set(trimmed.slice(separator + 2), trimmed.slice(0, separator));
176
- }
177
-
178
- return result;
179
- }
180
-
181
- function getExpectedChecksum(archiveName, checksumsPath = getChecksumsPath()) {
182
- if (!fs.existsSync(checksumsPath)) {
183
- return null;
184
- }
185
-
186
- const checksums = parseChecksums(fs.readFileSync(checksumsPath, "utf8"));
187
- return checksums.get(archiveName) || null;
188
- }
189
-
190
- function verifyChecksum(archivePath, expectedHash) {
191
- if (!expectedHash) {
192
- return;
193
- }
194
-
195
- const hash = crypto.createHash("sha256");
196
- const fd = fs.openSync(archivePath, "r");
197
-
198
- try {
199
- const buffer = Buffer.alloc(64 * 1024);
200
- let bytesRead = 0;
201
- while ((bytesRead = fs.readSync(fd, buffer, 0, buffer.length, null)) > 0) {
202
- hash.update(buffer.subarray(0, bytesRead));
203
- }
204
- } finally {
205
- fs.closeSync(fd);
206
- }
207
-
208
- const actualHash = hash.digest("hex");
209
- if (actualHash.toLowerCase() !== expectedHash.toLowerCase()) {
210
- throw new Error(
211
- `Checksum mismatch for ${path.basename(archivePath)}: expected ${expectedHash} but got ${actualHash}`
212
- );
213
- }
214
- }
215
-
216
- function extractArchive(archivePath, destDir) {
217
- if (process.platform === "win32") {
218
- const psCommand =
219
- "$ErrorActionPreference='Stop';" +
220
- "Expand-Archive -LiteralPath $env:YXER_ARCHIVE -DestinationPath $env:YXER_DEST -Force";
221
- execFileSync(
222
- "powershell.exe",
223
- ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", psCommand],
224
- {
225
- stdio: ["ignore", "inherit", "inherit"],
226
- env: {
227
- ...process.env,
228
- YXER_ARCHIVE: archivePath,
229
- YXER_DEST: destDir
230
- }
231
- }
232
- );
233
- return;
234
- }
235
-
236
- execFileSync("tar", ["-xzf", archivePath, "-C", destDir], { stdio: "ignore" });
237
- }
238
-
239
- function resolveBaseUrl() {
240
- const customUrl = (process.env.YXER_DOWNLOAD_BASE_URL || "").trim();
241
- if (!customUrl) {
242
- return DEFAULT_BASE_URL;
243
- }
244
-
245
- ALLOWED_HOSTS.add(new URL(customUrl).hostname);
246
- return customUrl;
247
- }
248
-
249
- function install(baseDir = __dirname) {
250
- const target = getTarget();
251
- if (!target) {
252
- throw new Error(`Unsupported platform: ${process.platform}/${process.arch}`);
253
- }
254
-
255
- const binDir = getBinDir(baseDir);
256
- const binaryPath = path.join(binDir, target.binaryName);
257
- fs.mkdirSync(binDir, { recursive: true });
258
-
259
- if (fs.existsSync(binaryPath)) {
260
- ensureExecutable(binaryPath);
261
- return binaryPath;
262
- }
263
-
264
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "yxer-install-"));
265
- const archivePath = path.join(tmpDir, target.archiveName);
266
-
267
- try {
268
- const downloadUrl = buildDownloadUrl(resolveBaseUrl(), target.archiveName);
269
- download(downloadUrl, archivePath);
270
- verifyChecksum(archivePath, getExpectedChecksum(target.archiveName, getChecksumsPath(baseDir)));
271
- extractArchive(archivePath, tmpDir);
272
-
273
- const extractedBinary = path.join(tmpDir, target.binaryName);
274
- if (!fs.existsSync(extractedBinary)) {
275
- throw new Error(`Extracted binary not found: ${target.binaryName}`);
276
- }
277
-
278
- fs.copyFileSync(extractedBinary, binaryPath);
279
- ensureExecutable(binaryPath);
280
- return binaryPath;
281
- } finally {
282
- fs.rmSync(tmpDir, { recursive: true, force: true });
283
- }
284
- }
285
-
286
- if (require.main === module) {
287
- try {
288
- install();
289
- } catch (error) {
290
- console.error(`Failed to install yxer: ${error.message}`);
291
- process.exit(1);
292
- }
293
- }
294
-
295
- module.exports = {
296
- ALLOWED_HOSTS,
297
- buildDownloadUrl,
298
- buildVersionBaseUrl,
299
- download,
300
- downloadWithCurl,
301
- downloadWithPowerShell,
302
- getBinaryPath,
303
- getBinDir,
304
- getExpectedChecksum,
305
- getTarget,
306
- install,
307
- isSupportedPlatform,
308
- parseChecksums,
309
- resolveBaseUrl,
310
- verifyChecksum
311
- };
1
+ #!/usr/bin/env node
2
+
3
+ const crypto = require("node:crypto");
4
+ const fs = require("node:fs");
5
+ const os = require("node:os");
6
+ const path = require("node:path");
7
+ const { execFileSync } = require("node:child_process");
8
+ const { ensureExecutable } = require("./ensure-executable");
9
+
10
+ const PACKAGE_NAME = "yxer";
11
+ const ARCHIVE_PREFIX = "yxer-cli";
12
+ const packageInfo = require("../package.json");
13
+ const VERSION = packageInfo.version.replace(/-.*$/, "");
14
+ if (!packageInfo.yxerDownloadRootUrl) {
15
+ throw new Error("Missing yxerDownloadRootUrl in package.json");
16
+ }
17
+
18
+ function buildVersionBaseUrl(rootUrl, version) {
19
+ return `${rootUrl.replace(/\/+$/, "")}/v${version}`;
20
+ }
21
+
22
+ const DEFAULT_BASE_URL = buildVersionBaseUrl(packageInfo.yxerDownloadRootUrl, VERSION);
23
+ const ALLOWED_HOSTS = new Set([
24
+ new URL(DEFAULT_BASE_URL).hostname,
25
+ "github.com",
26
+ "objects.githubusercontent.com",
27
+ "release-assets.githubusercontent.com",
28
+ "registry.npmmirror.com"
29
+ ]);
30
+
31
+ const PLATFORM_MAP = {
32
+ darwin: "darwin",
33
+ linux: "linux",
34
+ win32: "windows"
35
+ };
36
+
37
+ const ARCH_MAP = {
38
+ x64: "amd64",
39
+ arm64: "arm64"
40
+ };
41
+
42
+ function getTarget(platform = process.platform, arch = process.arch) {
43
+ const mappedPlatform = PLATFORM_MAP[platform];
44
+ const mappedArch = ARCH_MAP[arch];
45
+ if (!mappedPlatform || !mappedArch) {
46
+ return null;
47
+ }
48
+
49
+ const ext = platform === "win32" ? "zip" : "tar.gz";
50
+ const binaryExt = platform === "win32" ? ".exe" : "";
51
+ const baseName = `${ARCHIVE_PREFIX}-${VERSION}-${mappedPlatform}-${mappedArch}`;
52
+
53
+ return {
54
+ platform,
55
+ arch,
56
+ mappedPlatform,
57
+ mappedArch,
58
+ archiveName: `${baseName}.${ext}`,
59
+ binaryName: `${PACKAGE_NAME}${binaryExt}`
60
+ };
61
+ }
62
+
63
+ function isSupportedPlatform(platform = process.platform, arch = process.arch) {
64
+ return getTarget(platform, arch) !== null;
65
+ }
66
+
67
+ function getBinDir(baseDir = __dirname) {
68
+ return path.join(baseDir, "..", "bin-native");
69
+ }
70
+
71
+ function getChecksumsPath(baseDir = __dirname) {
72
+ return path.join(baseDir, "..", "checksums.txt");
73
+ }
74
+
75
+ function getBinaryPath(baseDir = __dirname, platform = process.platform, arch = process.arch) {
76
+ const target = getTarget(platform, arch);
77
+ if (!target) {
78
+ return null;
79
+ }
80
+
81
+ return path.join(getBinDir(baseDir), target.binaryName);
82
+ }
83
+
84
+ function assertAllowedHost(url) {
85
+ const hostname = new URL(url).hostname;
86
+ if (!ALLOWED_HOSTS.has(hostname)) {
87
+ throw new Error(`Download host not allowed: ${hostname}`);
88
+ }
89
+ }
90
+
91
+ function buildDownloadUrl(baseUrl, archiveName) {
92
+ return `${baseUrl.replace(/\/+$/, "")}/${archiveName}`;
93
+ }
94
+
95
+ function downloadWithCurl(url, destPath, execFile = execFileSync) {
96
+ assertAllowedHost(url);
97
+
98
+ const args = [
99
+ "--fail",
100
+ "--location",
101
+ "--silent",
102
+ "--show-error",
103
+ "--connect-timeout",
104
+ "10",
105
+ "--max-time",
106
+ "120",
107
+ "--max-redirs",
108
+ "3",
109
+ "--output",
110
+ destPath
111
+ ];
112
+
113
+ if (process.platform === "win32") {
114
+ args.unshift("--ssl-revoke-best-effort");
115
+ }
116
+
117
+ args.push(url);
118
+ execFile("curl", args, { stdio: ["ignore", "ignore", "pipe"] });
119
+ }
120
+
121
+ function downloadWithPowerShell(url, destPath, execFile = execFileSync) {
122
+ assertAllowedHost(url);
123
+
124
+ const psCommand =
125
+ "$ProgressPreference='SilentlyContinue';" +
126
+ "$ErrorActionPreference='Stop';" +
127
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" +
128
+ "Invoke-WebRequest -UseBasicParsing -Uri $env:YXER_URL -OutFile $env:YXER_DEST";
129
+
130
+ execFile(
131
+ "powershell.exe",
132
+ ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", psCommand],
133
+ {
134
+ stdio: ["ignore", "ignore", "pipe"],
135
+ env: {
136
+ ...process.env,
137
+ YXER_URL: url,
138
+ YXER_DEST: destPath
139
+ }
140
+ }
141
+ );
142
+ }
143
+
144
+ function download(url, destPath, platform = process.platform, execFile = execFileSync) {
145
+ try {
146
+ downloadWithCurl(url, destPath, execFile);
147
+ } catch (error) {
148
+ if (platform !== "win32") {
149
+ throw error;
150
+ }
151
+
152
+ try {
153
+ downloadWithPowerShell(url, destPath, execFile);
154
+ } catch (fallbackError) {
155
+ fallbackError.message =
156
+ `${error.message}; fallback via PowerShell failed: ${fallbackError.message}`;
157
+ throw fallbackError;
158
+ }
159
+ }
160
+ }
161
+
162
+ function parseChecksums(content) {
163
+ const result = new Map();
164
+ for (const line of content.split(/\r?\n/)) {
165
+ const trimmed = line.trim();
166
+ if (!trimmed) {
167
+ continue;
168
+ }
169
+
170
+ const separator = trimmed.indexOf(" ");
171
+ if (separator === -1) {
172
+ continue;
173
+ }
174
+
175
+ result.set(trimmed.slice(separator + 2), trimmed.slice(0, separator));
176
+ }
177
+
178
+ return result;
179
+ }
180
+
181
+ function getExpectedChecksum(archiveName, checksumsPath = getChecksumsPath()) {
182
+ if (!fs.existsSync(checksumsPath)) {
183
+ return null;
184
+ }
185
+
186
+ const checksums = parseChecksums(fs.readFileSync(checksumsPath, "utf8"));
187
+ return checksums.get(archiveName) || null;
188
+ }
189
+
190
+ function verifyChecksum(archivePath, expectedHash) {
191
+ if (!expectedHash) {
192
+ return;
193
+ }
194
+
195
+ const hash = crypto.createHash("sha256");
196
+ const fd = fs.openSync(archivePath, "r");
197
+
198
+ try {
199
+ const buffer = Buffer.alloc(64 * 1024);
200
+ let bytesRead = 0;
201
+ while ((bytesRead = fs.readSync(fd, buffer, 0, buffer.length, null)) > 0) {
202
+ hash.update(buffer.subarray(0, bytesRead));
203
+ }
204
+ } finally {
205
+ fs.closeSync(fd);
206
+ }
207
+
208
+ const actualHash = hash.digest("hex");
209
+ if (actualHash.toLowerCase() !== expectedHash.toLowerCase()) {
210
+ throw new Error(
211
+ `Checksum mismatch for ${path.basename(archivePath)}: expected ${expectedHash} but got ${actualHash}`
212
+ );
213
+ }
214
+ }
215
+
216
+ function extractArchive(archivePath, destDir) {
217
+ if (process.platform === "win32") {
218
+ const psCommand =
219
+ "$ErrorActionPreference='Stop';" +
220
+ "Expand-Archive -LiteralPath $env:YXER_ARCHIVE -DestinationPath $env:YXER_DEST -Force";
221
+ execFileSync(
222
+ "powershell.exe",
223
+ ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", psCommand],
224
+ {
225
+ stdio: ["ignore", "inherit", "inherit"],
226
+ env: {
227
+ ...process.env,
228
+ YXER_ARCHIVE: archivePath,
229
+ YXER_DEST: destDir
230
+ }
231
+ }
232
+ );
233
+ return;
234
+ }
235
+
236
+ execFileSync("tar", ["-xzf", archivePath, "-C", destDir], { stdio: "ignore" });
237
+ }
238
+
239
+ function resolveBaseUrl() {
240
+ const customUrl = (process.env.YXER_DOWNLOAD_BASE_URL || "").trim();
241
+ if (!customUrl) {
242
+ return DEFAULT_BASE_URL;
243
+ }
244
+
245
+ ALLOWED_HOSTS.add(new URL(customUrl).hostname);
246
+ return customUrl;
247
+ }
248
+
249
+ function install(baseDir = __dirname) {
250
+ const target = getTarget();
251
+ if (!target) {
252
+ throw new Error(`Unsupported platform: ${process.platform}/${process.arch}`);
253
+ }
254
+
255
+ const binDir = getBinDir(baseDir);
256
+ const binaryPath = path.join(binDir, target.binaryName);
257
+ fs.mkdirSync(binDir, { recursive: true });
258
+
259
+ if (fs.existsSync(binaryPath)) {
260
+ ensureExecutable(binaryPath);
261
+ return binaryPath;
262
+ }
263
+
264
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "yxer-install-"));
265
+ const archivePath = path.join(tmpDir, target.archiveName);
266
+
267
+ try {
268
+ const downloadUrl = buildDownloadUrl(resolveBaseUrl(), target.archiveName);
269
+ download(downloadUrl, archivePath);
270
+ verifyChecksum(archivePath, getExpectedChecksum(target.archiveName, getChecksumsPath(baseDir)));
271
+ extractArchive(archivePath, tmpDir);
272
+
273
+ const extractedBinary = path.join(tmpDir, target.binaryName);
274
+ if (!fs.existsSync(extractedBinary)) {
275
+ throw new Error(`Extracted binary not found: ${target.binaryName}`);
276
+ }
277
+
278
+ fs.copyFileSync(extractedBinary, binaryPath);
279
+ ensureExecutable(binaryPath);
280
+ return binaryPath;
281
+ } finally {
282
+ fs.rmSync(tmpDir, { recursive: true, force: true });
283
+ }
284
+ }
285
+
286
+ if (require.main === module) {
287
+ try {
288
+ install();
289
+ } catch (error) {
290
+ console.error(`Failed to install yxer: ${error.message}`);
291
+ process.exit(1);
292
+ }
293
+ }
294
+
295
+ module.exports = {
296
+ ALLOWED_HOSTS,
297
+ buildDownloadUrl,
298
+ buildVersionBaseUrl,
299
+ download,
300
+ downloadWithCurl,
301
+ downloadWithPowerShell,
302
+ getBinaryPath,
303
+ getBinDir,
304
+ getExpectedChecksum,
305
+ getTarget,
306
+ install,
307
+ isSupportedPlatform,
308
+ parseChecksums,
309
+ resolveBaseUrl,
310
+ verifyChecksum
311
+ };
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env node
2
-
3
- const { install, isSupportedPlatform } = require("./install");
4
-
5
- try {
6
- if (!isSupportedPlatform(process.platform, process.arch)) {
7
- process.exit(0);
8
- }
9
-
10
- install();
11
- } catch (error) {
12
- console.error(`[yxer] postinstall failed: ${error.message}`);
13
- process.exit(0);
14
- }
1
+ #!/usr/bin/env node
2
+
3
+ const { install, isSupportedPlatform } = require("./install");
4
+
5
+ try {
6
+ if (!isSupportedPlatform(process.platform, process.arch)) {
7
+ process.exit(0);
8
+ }
9
+
10
+ install();
11
+ } catch (error) {
12
+ console.error(`[yxer] postinstall failed: ${error.message}`);
13
+ process.exit(0);
14
+ }