@upstart.gg/sdk 0.0.95 → 0.0.97

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 (527) hide show
  1. package/dist/node/cli/api.js +2 -2
  2. package/dist/node/cli/api.js.map +1 -1
  3. package/dist/node/cli/commands/login/cmd-login.js +6 -6
  4. package/dist/node/cli/commands/login/cmd-login.js.map +1 -1
  5. package/dist/node/cli/commands/logout/cmd-logout.js +2 -2
  6. package/dist/node/cli/commands/publish/cmd-publish.d.ts.map +1 -1
  7. package/dist/node/cli/commands/publish/cmd-publish.js +18 -18
  8. package/dist/node/cli/commands/publish/cmd-publish.js.map +1 -1
  9. package/dist/node/cli/commands/publish/uploader.js +7 -7
  10. package/dist/node/cli/commands/publish/uploader.js.map +1 -1
  11. package/dist/node/cli/is-logged-in.js +2 -2
  12. package/dist/node/cli/is-logged-in.js.map +1 -1
  13. package/dist/node/cli/program.js +24 -24
  14. package/dist/node/cli/program.js.map +1 -1
  15. package/dist/node/shared/config.d.ts +4 -14
  16. package/dist/node/shared/config.d.ts.map +1 -1
  17. package/dist/node/shared/config.js +4 -4
  18. package/dist/node/shared/config.js.map +1 -1
  19. package/dist/node/shared/logger.d.ts.map +1 -1
  20. package/dist/node/shared/logger.js +2 -2
  21. package/dist/node/shared/logger.js.map +1 -1
  22. package/dist/shared/ajv.d.ts +2 -0
  23. package/dist/shared/ajv.d.ts.map +1 -1
  24. package/dist/shared/ajv.js +1 -1
  25. package/dist/shared/attributes.d.ts +45 -83
  26. package/dist/shared/attributes.d.ts.map +1 -1
  27. package/dist/shared/attributes.js +1 -1
  28. package/dist/shared/brick-manifest.d.ts +7 -17
  29. package/dist/shared/brick-manifest.d.ts.map +1 -1
  30. package/dist/shared/brick-manifest.js +1 -1
  31. package/dist/shared/bricks/manifests/accordion.manifest.d.ts +111 -0
  32. package/dist/shared/bricks/manifests/accordion.manifest.d.ts.map +1 -0
  33. package/dist/shared/bricks/manifests/accordion.manifest.js +3 -0
  34. package/dist/shared/bricks/manifests/all-manifests.d.ts +5 -0
  35. package/dist/shared/bricks/manifests/all-manifests.d.ts.map +1 -1
  36. package/dist/shared/bricks/manifests/all-manifests.js +1 -1
  37. package/dist/shared/bricks/manifests/button.manifest.d.ts +22 -13
  38. package/dist/shared/bricks/manifests/button.manifest.d.ts.map +1 -1
  39. package/dist/shared/bricks/manifests/button.manifest.js +1 -1
  40. package/dist/shared/bricks/manifests/card.manifest.d.ts +44 -54
  41. package/dist/shared/bricks/manifests/card.manifest.d.ts.map +1 -1
  42. package/dist/shared/bricks/manifests/card.manifest.js +1 -1
  43. package/dist/shared/bricks/manifests/carousel.manifest.d.ts +39 -12
  44. package/dist/shared/bricks/manifests/carousel.manifest.d.ts.map +1 -1
  45. package/dist/shared/bricks/manifests/carousel.manifest.js +1 -1
  46. package/dist/shared/bricks/manifests/container.manifest.d.ts +49 -172
  47. package/dist/shared/bricks/manifests/container.manifest.d.ts.map +1 -1
  48. package/dist/shared/bricks/manifests/container.manifest.js +1 -1
  49. package/dist/shared/bricks/manifests/divider.manifest.d.ts +63 -0
  50. package/dist/shared/bricks/manifests/divider.manifest.d.ts.map +1 -0
  51. package/dist/shared/bricks/manifests/divider.manifest.js +3 -0
  52. package/dist/shared/bricks/manifests/footer.manifest.d.ts +30 -35
  53. package/dist/shared/bricks/manifests/footer.manifest.d.ts.map +1 -1
  54. package/dist/shared/bricks/manifests/footer.manifest.js +1 -1
  55. package/dist/shared/bricks/manifests/form.manifest.d.ts +22 -12
  56. package/dist/shared/bricks/manifests/form.manifest.d.ts.map +1 -1
  57. package/dist/shared/bricks/manifests/form.manifest.js +1 -1
  58. package/dist/shared/bricks/manifests/hero.manifest.d.ts +31 -71
  59. package/dist/shared/bricks/manifests/hero.manifest.d.ts.map +1 -1
  60. package/dist/shared/bricks/manifests/hero.manifest.js +1 -1
  61. package/dist/shared/bricks/manifests/icon.manifest.d.ts +18 -12
  62. package/dist/shared/bricks/manifests/icon.manifest.d.ts.map +1 -1
  63. package/dist/shared/bricks/manifests/icon.manifest.js +1 -1
  64. package/dist/shared/bricks/manifests/image.manifest.d.ts +36 -50
  65. package/dist/shared/bricks/manifests/image.manifest.d.ts.map +1 -1
  66. package/dist/shared/bricks/manifests/image.manifest.js +1 -1
  67. package/dist/shared/bricks/manifests/images-gallery.manifest.d.ts +55 -115
  68. package/dist/shared/bricks/manifests/images-gallery.manifest.d.ts.map +1 -1
  69. package/dist/shared/bricks/manifests/images-gallery.manifest.js +1 -1
  70. package/dist/shared/bricks/manifests/map.manifest.d.ts +36 -12
  71. package/dist/shared/bricks/manifests/map.manifest.d.ts.map +1 -1
  72. package/dist/shared/bricks/manifests/map.manifest.js +1 -1
  73. package/dist/shared/bricks/manifests/navbar.manifest.d.ts +160 -0
  74. package/dist/shared/bricks/manifests/navbar.manifest.d.ts.map +1 -0
  75. package/dist/shared/bricks/manifests/navbar.manifest.js +3 -0
  76. package/dist/shared/bricks/manifests/sidebar.manifest.d.ts +83 -12
  77. package/dist/shared/bricks/manifests/sidebar.manifest.d.ts.map +1 -1
  78. package/dist/shared/bricks/manifests/sidebar.manifest.js +1 -1
  79. package/dist/shared/bricks/manifests/social-links.manifest.d.ts +37 -12
  80. package/dist/shared/bricks/manifests/social-links.manifest.d.ts.map +1 -1
  81. package/dist/shared/bricks/manifests/social-links.manifest.js +1 -1
  82. package/dist/shared/bricks/manifests/testimonials.manifest.d.ts +94 -0
  83. package/dist/shared/bricks/manifests/testimonials.manifest.d.ts.map +1 -0
  84. package/dist/shared/bricks/manifests/testimonials.manifest.js +3 -0
  85. package/dist/shared/bricks/manifests/text.manifest.d.ts +31 -63
  86. package/dist/shared/bricks/manifests/text.manifest.d.ts.map +1 -1
  87. package/dist/shared/bricks/manifests/text.manifest.js +1 -1
  88. package/dist/shared/bricks/manifests/timeline.manifest.d.ts +122 -0
  89. package/dist/shared/bricks/manifests/timeline.manifest.d.ts.map +1 -0
  90. package/dist/shared/bricks/manifests/timeline.manifest.js +3 -0
  91. package/dist/shared/bricks/manifests/video.manifest.d.ts +38 -12
  92. package/dist/shared/bricks/manifests/video.manifest.d.ts.map +1 -1
  93. package/dist/shared/bricks/manifests/video.manifest.js +1 -1
  94. package/dist/shared/bricks/props/_style-presets.d.ts +1 -1
  95. package/dist/shared/bricks/props/_style-presets.d.ts.map +1 -1
  96. package/dist/shared/bricks/props/_style-presets.js +1 -1
  97. package/dist/shared/bricks/props/align.d.ts +7 -3
  98. package/dist/shared/bricks/props/align.d.ts.map +1 -1
  99. package/dist/shared/bricks/props/align.js +1 -1
  100. package/dist/shared/bricks/props/background.d.ts +8 -1
  101. package/dist/shared/bricks/props/background.d.ts.map +1 -1
  102. package/dist/shared/bricks/props/background.js +1 -1
  103. package/dist/shared/bricks/props/boolean.js +1 -1
  104. package/dist/shared/bricks/props/border.d.ts +24 -22
  105. package/dist/shared/bricks/props/border.d.ts.map +1 -1
  106. package/dist/shared/bricks/props/border.js +1 -1
  107. package/dist/shared/bricks/props/color.d.ts +5 -0
  108. package/dist/shared/bricks/props/color.d.ts.map +1 -0
  109. package/dist/shared/bricks/props/color.js +3 -0
  110. package/dist/shared/bricks/props/common.d.ts +9 -1
  111. package/dist/shared/bricks/props/common.d.ts.map +1 -1
  112. package/dist/shared/bricks/props/common.js +1 -1
  113. package/dist/shared/bricks/props/container.d.ts +37 -45
  114. package/dist/shared/bricks/props/container.d.ts.map +1 -1
  115. package/dist/shared/bricks/props/container.js +1 -1
  116. package/dist/shared/bricks/props/css-length.d.ts +5 -0
  117. package/dist/shared/bricks/props/css-length.d.ts.map +1 -0
  118. package/dist/shared/bricks/props/css-length.js +3 -0
  119. package/dist/shared/bricks/props/datasource.d.ts +9 -13
  120. package/dist/shared/bricks/props/datasource.d.ts.map +1 -1
  121. package/dist/shared/bricks/props/datasource.js +1 -1
  122. package/dist/shared/bricks/props/date.d.ts +4 -0
  123. package/dist/shared/bricks/props/date.d.ts.map +1 -0
  124. package/dist/shared/bricks/props/date.js +3 -0
  125. package/dist/shared/bricks/props/effects.d.ts +4 -21
  126. package/dist/shared/bricks/props/effects.d.ts.map +1 -1
  127. package/dist/shared/bricks/props/effects.js +1 -1
  128. package/dist/shared/bricks/props/enum.d.ts +13 -0
  129. package/dist/shared/bricks/props/enum.d.ts.map +1 -0
  130. package/dist/shared/bricks/props/enum.js +3 -0
  131. package/dist/shared/bricks/props/file.d.ts +2 -0
  132. package/dist/shared/bricks/props/file.d.ts.map +1 -0
  133. package/dist/shared/bricks/props/file.js +3 -0
  134. package/dist/shared/bricks/props/geolocation.d.ts +16 -0
  135. package/dist/shared/bricks/props/geolocation.d.ts.map +1 -0
  136. package/dist/shared/bricks/props/geolocation.js +3 -0
  137. package/dist/shared/bricks/props/helpers.d.ts +8 -4
  138. package/dist/shared/bricks/props/helpers.d.ts.map +1 -1
  139. package/dist/shared/bricks/props/helpers.js +1 -1
  140. package/dist/shared/bricks/props/image.d.ts +7 -1
  141. package/dist/shared/bricks/props/image.d.ts.map +1 -1
  142. package/dist/shared/bricks/props/image.js +1 -1
  143. package/dist/shared/bricks/props/number.js +1 -1
  144. package/dist/shared/bricks/props/padding.d.ts +2 -1
  145. package/dist/shared/bricks/props/padding.d.ts.map +1 -1
  146. package/dist/shared/bricks/props/padding.js +1 -1
  147. package/dist/shared/bricks/props/position.d.ts.map +1 -1
  148. package/dist/shared/bricks/props/position.js +1 -1
  149. package/dist/shared/bricks/props/preset.d.ts +92 -0
  150. package/dist/shared/bricks/props/preset.d.ts.map +1 -0
  151. package/dist/shared/bricks/props/preset.js +3 -0
  152. package/dist/shared/bricks/props/string.d.ts +8 -3
  153. package/dist/shared/bricks/props/string.d.ts.map +1 -1
  154. package/dist/shared/bricks/props/string.js +1 -1
  155. package/dist/shared/bricks/props/text.d.ts +3 -4
  156. package/dist/shared/bricks/props/text.d.ts.map +1 -1
  157. package/dist/shared/bricks/props/text.js +1 -1
  158. package/dist/shared/bricks/props/types.d.ts +5 -2
  159. package/dist/shared/bricks/props/types.d.ts.map +1 -1
  160. package/dist/shared/bricks.d.ts +243 -134
  161. package/dist/shared/bricks.d.ts.map +1 -1
  162. package/dist/shared/bricks.js +1 -1
  163. package/dist/shared/chunk-2AJYHJFG.js +8 -0
  164. package/dist/shared/chunk-2FHWS73Y.js +6 -0
  165. package/dist/shared/chunk-3FJVF357.js +3 -0
  166. package/dist/shared/chunk-3RHYJ6E7.js +5 -0
  167. package/dist/shared/chunk-3VZACK2Y.js +3 -0
  168. package/dist/shared/chunk-3XCKZ4JQ.js +3 -0
  169. package/dist/shared/chunk-4MPRHJWO.js +3 -0
  170. package/dist/shared/chunk-5EOWW7BX.js +4 -0
  171. package/dist/shared/chunk-5HYPCOSS.js +3 -0
  172. package/dist/shared/chunk-5K5C6XFX.js +3 -0
  173. package/dist/shared/chunk-6QS5PKLA.js +3 -0
  174. package/dist/shared/chunk-74EL657O.js +3 -0
  175. package/dist/shared/chunk-AJDYOLKP.js +3 -0
  176. package/dist/shared/chunk-ALFOZHAH.js +3 -0
  177. package/dist/shared/{chunk-FGU4BGP4.js → chunk-ATDJCXC2.js} +1 -1
  178. package/dist/shared/chunk-BJSO43AS.js +3 -0
  179. package/dist/shared/chunk-BTKLQQZA.js +3 -0
  180. package/dist/shared/chunk-CAVNF3BU.js +3 -0
  181. package/dist/shared/chunk-CCNU3J56.js +3 -0
  182. package/dist/shared/chunk-CTRS76PX.js +3 -0
  183. package/dist/shared/chunk-DCH2FI6T.js +8 -0
  184. package/dist/shared/chunk-DFSQR6QC.js +3 -0
  185. package/dist/shared/chunk-ENU4SEHO.js +3 -0
  186. package/dist/shared/chunk-G7LX3UKQ.js +3 -0
  187. package/dist/shared/chunk-GGJBTPGW.js +3 -0
  188. package/dist/shared/chunk-H24R3IWA.js +3 -0
  189. package/dist/shared/chunk-HYVQXAK5.js +3 -0
  190. package/dist/shared/chunk-LKVQQQTI.js +3 -0
  191. package/dist/shared/chunk-MITJPRGD.js +6 -0
  192. package/dist/shared/chunk-NLZBY65T.js +3 -0
  193. package/dist/shared/chunk-OUI2VDNM.js +3 -0
  194. package/dist/shared/chunk-OYIL5SCU.js +3 -0
  195. package/dist/shared/chunk-P5DZK4TS.js +3 -0
  196. package/dist/shared/chunk-PK3R5VOF.js +3 -0
  197. package/dist/shared/chunk-QPATZM3I.js +3 -0
  198. package/dist/shared/chunk-RDBEWW4G.js +7 -0
  199. package/dist/shared/chunk-RPBQZW5I.js +3 -0
  200. package/dist/shared/chunk-SLSIAUYV.js +3 -0
  201. package/dist/shared/chunk-SUG225LF.js +3 -0
  202. package/dist/shared/chunk-U5XOIYSS.js +3 -0
  203. package/dist/shared/{chunk-HIZPJNEM.js → chunk-UL7L3HYV.js} +1 -1
  204. package/dist/shared/chunk-V6BCYHZH.js +3 -0
  205. package/dist/shared/chunk-VA5LFJVE.js +3 -0
  206. package/dist/shared/chunk-VAC73HJE.js +3 -0
  207. package/dist/shared/chunk-VBWC36L2.js +3 -0
  208. package/dist/shared/chunk-VLGLD6GR.js +3 -0
  209. package/dist/shared/chunk-VTFWVTPI.js +3 -0
  210. package/dist/shared/chunk-WAAKB6OB.js +3 -0
  211. package/dist/shared/chunk-Y36SM2AO.js +3 -0
  212. package/dist/shared/chunk-Y7CEEEVW.js +3 -0
  213. package/dist/shared/chunk-YZ5Y4WE6.js +3 -0
  214. package/dist/shared/chunk-Z7SYP6FG.js +3 -0
  215. package/dist/shared/chunk-ZJNA4QQC.js +3 -0
  216. package/dist/shared/chunk-ZMDHKAWL.js +3 -0
  217. package/dist/shared/context.d.ts +38 -0
  218. package/dist/shared/context.d.ts.map +1 -0
  219. package/dist/shared/{chunk-WJ5CDDXW.js → context.js} +0 -1
  220. package/dist/shared/datarecords/types.d.ts +40 -20
  221. package/dist/shared/datarecords/types.d.ts.map +1 -1
  222. package/dist/shared/datarecords/types.js +1 -1
  223. package/dist/shared/datasources/external/http-json/fetcher.d.ts.map +1 -0
  224. package/dist/shared/datasources/external/http-json/options.d.ts.map +1 -0
  225. package/dist/shared/datasources/external/{json → http-json}/schema.d.ts +0 -1
  226. package/dist/shared/datasources/external/http-json/schema.d.ts.map +1 -0
  227. package/dist/shared/datasources/external/http-json/tests/fetcher.test.d.ts.map +1 -0
  228. package/dist/shared/datasources/external/rss/fetcher.d.ts.map +1 -1
  229. package/dist/shared/datasources/external/rss/sample.d.ts.map +1 -1
  230. package/dist/shared/datasources/external/rss/schema.d.ts +7 -13
  231. package/dist/shared/datasources/external/rss/schema.d.ts.map +1 -1
  232. package/dist/shared/datasources/external/youtube/list/sample.d.ts +23 -32
  233. package/dist/shared/datasources/external/youtube/list/sample.d.ts.map +1 -1
  234. package/dist/shared/datasources/external/youtube/list/schema.d.ts +24 -33
  235. package/dist/shared/datasources/external/youtube/list/schema.d.ts.map +1 -1
  236. package/dist/shared/datasources/internal/blog/schema.d.ts.map +1 -1
  237. package/dist/shared/datasources/internal/changelog/schema.d.ts.map +1 -1
  238. package/dist/shared/datasources/internal/recipes/schema.d.ts.map +1 -1
  239. package/dist/shared/datasources/samples.d.ts +1 -1
  240. package/dist/shared/datasources/samples.d.ts.map +1 -1
  241. package/dist/shared/datasources/schemas.d.ts +33 -583
  242. package/dist/shared/datasources/schemas.d.ts.map +1 -1
  243. package/dist/shared/datasources/schemas.js +1 -1
  244. package/dist/shared/datasources/types.d.ts +75 -1314
  245. package/dist/shared/datasources/types.d.ts.map +1 -1
  246. package/dist/shared/datasources/types.js +1 -1
  247. package/dist/shared/datasources.d.ts +14 -0
  248. package/dist/shared/datasources.d.ts.map +1 -1
  249. package/dist/shared/datasources.js +1 -1
  250. package/dist/shared/images.d.ts +30 -0
  251. package/dist/shared/images.d.ts.map +1 -0
  252. package/dist/shared/images.js +3 -0
  253. package/dist/shared/layout-constants.js +1 -1
  254. package/dist/shared/page.d.ts +110 -2676
  255. package/dist/shared/page.d.ts.map +1 -1
  256. package/dist/shared/page.js +1 -1
  257. package/dist/shared/prompt.d.ts +4 -0
  258. package/dist/shared/prompt.d.ts.map +1 -0
  259. package/dist/shared/prompt.js +3 -0
  260. package/dist/shared/responsive.d.ts +3 -3
  261. package/dist/shared/responsive.d.ts.map +1 -1
  262. package/dist/shared/responsive.js +1 -1
  263. package/dist/shared/site.d.ts +545 -0
  264. package/dist/shared/site.d.ts.map +1 -0
  265. package/dist/shared/site.js +3 -0
  266. package/dist/shared/sitemap.d.ts +38 -0
  267. package/dist/shared/sitemap.d.ts.map +1 -0
  268. package/dist/shared/sitemap.js +3 -0
  269. package/dist/shared/theme.d.ts +41 -19
  270. package/dist/shared/theme.d.ts.map +1 -1
  271. package/dist/shared/theme.js +1 -1
  272. package/dist/shared/themes/color-system.d.ts +5 -309
  273. package/dist/shared/themes/color-system.d.ts.map +1 -1
  274. package/dist/shared/themes/color-system.js +1 -1
  275. package/dist/shared/utils/invariant.js +1 -1
  276. package/dist/shared/utils/schema.d.ts +10 -1
  277. package/dist/shared/utils/schema.d.ts.map +1 -1
  278. package/dist/shared/utils/schema.js +1 -1
  279. package/dist/shared/utils/typed-ref.d.ts +32 -0
  280. package/dist/shared/utils/typed-ref.d.ts.map +1 -0
  281. package/dist/shared/utils/typed-ref.js +3 -0
  282. package/package.json +12 -12
  283. package/src/node/cli/api.ts +101 -0
  284. package/src/node/cli/commands/cmd-build.ts +64 -0
  285. package/src/node/cli/commands/login/cmd-login.ts +111 -0
  286. package/src/node/cli/commands/logout/cmd-logout.ts +11 -0
  287. package/src/node/cli/commands/publish/cmd-publish.ts +135 -0
  288. package/src/node/cli/commands/publish/parse-gitignore.ts +278 -0
  289. package/src/node/cli/commands/publish/uploader.ts +333 -0
  290. package/src/node/cli/constants.ts +14 -0
  291. package/src/node/cli/is-logged-in.ts +28 -0
  292. package/src/node/cli/program.ts +77 -0
  293. package/src/node/cli/store.ts +64 -0
  294. package/src/node/cli/tests/api.test.ts +161 -0
  295. package/src/node/cli/types.ts +34 -0
  296. package/src/node/cli/utils.ts +20 -0
  297. package/src/node/shared/config.ts +69 -0
  298. package/src/node/shared/logger.ts +44 -0
  299. package/src/shared/ajv.ts +111 -0
  300. package/src/shared/analytics/init.ts +14 -0
  301. package/src/shared/analytics/track.ts +21 -0
  302. package/src/shared/analytics/types.ts +13 -0
  303. package/src/shared/attributes.ts +222 -0
  304. package/src/shared/brick-manifest.ts +110 -0
  305. package/src/shared/bricks/manifests/accordion.manifest.ts +179 -0
  306. package/src/shared/bricks/manifests/all-manifests.ts +92 -0
  307. package/src/shared/bricks/manifests/button.manifest.ts +145 -0
  308. package/src/shared/bricks/manifests/card.manifest.ts +269 -0
  309. package/src/shared/bricks/manifests/carousel.manifest.ts +106 -0
  310. package/src/shared/bricks/manifests/container.manifest.ts +357 -0
  311. package/src/shared/bricks/manifests/divider.manifest.ts +121 -0
  312. package/src/shared/bricks/manifests/footer.manifest.ts +487 -0
  313. package/src/shared/bricks/manifests/form.manifest.ts +112 -0
  314. package/src/shared/bricks/manifests/hero.manifest.ts +132 -0
  315. package/src/shared/bricks/manifests/icon.manifest.ts +130 -0
  316. package/src/shared/bricks/manifests/image.manifest.ts +203 -0
  317. package/src/shared/bricks/manifests/images-gallery.manifest.ts +227 -0
  318. package/src/shared/bricks/manifests/map.manifest.ts +75 -0
  319. package/src/shared/bricks/manifests/navbar.manifest.ts +344 -0
  320. package/src/shared/bricks/manifests/sidebar.manifest.ts +90 -0
  321. package/src/shared/bricks/manifests/social-links.manifest.ts +370 -0
  322. package/src/shared/bricks/manifests/testimonials.manifest.ts +397 -0
  323. package/src/shared/bricks/manifests/tests/header.manifest.test.ts +10 -0
  324. package/src/shared/bricks/manifests/text.manifest.ts +164 -0
  325. package/src/shared/bricks/manifests/timeline.manifest.ts +456 -0
  326. package/src/shared/bricks/manifests/video.manifest.ts +59 -0
  327. package/src/shared/bricks/props/_style-presets.ts +352 -0
  328. package/src/shared/bricks/props/align.ts +59 -0
  329. package/src/shared/bricks/props/background.ts +118 -0
  330. package/src/shared/bricks/props/boolean.ts +11 -0
  331. package/src/shared/bricks/props/border.ts +84 -0
  332. package/src/shared/bricks/props/color.ts +24 -0
  333. package/src/shared/bricks/props/common.ts +37 -0
  334. package/src/shared/bricks/props/container.ts +356 -0
  335. package/src/shared/bricks/props/css-length.ts +25 -0
  336. package/src/shared/bricks/props/datasource.ts +60 -0
  337. package/src/shared/bricks/props/date.ts +24 -0
  338. package/src/shared/bricks/props/effects.ts +123 -0
  339. package/src/shared/bricks/props/enum.ts +42 -0
  340. package/src/shared/bricks/props/file.ts +12 -0
  341. package/src/shared/bricks/props/geolocation.ts +30 -0
  342. package/src/shared/bricks/props/helpers.ts +101 -0
  343. package/src/shared/bricks/props/image.ts +90 -0
  344. package/src/shared/bricks/props/number.ts +16 -0
  345. package/src/shared/bricks/props/padding.ts +21 -0
  346. package/src/shared/bricks/props/position.ts +27 -0
  347. package/src/shared/bricks/props/preset.ts +136 -0
  348. package/src/shared/bricks/props/string.ts +60 -0
  349. package/src/shared/bricks/props/tests/align.test.ts +37 -0
  350. package/src/shared/bricks/props/tests/background.test.ts +102 -0
  351. package/src/shared/bricks/props/tests/border.test.ts +38 -0
  352. package/src/shared/bricks/props/tests/effects.test.ts +37 -0
  353. package/src/shared/bricks/props/tests/helpers.test.ts +133 -0
  354. package/src/shared/bricks/props/tests/image.test.ts +71 -0
  355. package/src/shared/bricks/props/tests/padding.ts +12 -0
  356. package/src/shared/bricks/props/tests/string.test.ts +79 -0
  357. package/src/shared/bricks/props/text.ts +66 -0
  358. package/src/shared/bricks/props/types.ts +57 -0
  359. package/src/shared/bricks.ts +232 -0
  360. package/src/shared/context.ts +39 -0
  361. package/src/shared/datarecords/external/airtable/handler.ts +21 -0
  362. package/src/shared/datarecords/external/airtable/options.ts +22 -0
  363. package/src/shared/datarecords/external/generic-webhook/handler.ts +10 -0
  364. package/src/shared/datarecords/external/generic-webhook/options.ts +13 -0
  365. package/src/shared/datarecords/external/google/oauth/config.ts +30 -0
  366. package/src/shared/datarecords/external/google/sheets/handler.ts +26 -0
  367. package/src/shared/datarecords/external/google/sheets/options.ts +9 -0
  368. package/src/shared/datarecords/types.ts +120 -0
  369. package/src/shared/datarecords.ts +5 -0
  370. package/src/shared/datasources/README.md +3 -0
  371. package/src/shared/datasources/external/facebook/posts/fetcher.ts +62 -0
  372. package/src/shared/datasources/external/facebook/posts/sample.ts +35 -0
  373. package/src/shared/datasources/external/facebook/posts/schema.ts +33 -0
  374. package/src/shared/datasources/external/facebook/posts/tests/fetcher.test.ts +91 -0
  375. package/src/shared/datasources/external/http-json/fetcher.ts +28 -0
  376. package/src/shared/datasources/external/http-json/options.ts +12 -0
  377. package/src/shared/datasources/external/http-json/schema.ts +6 -0
  378. package/src/shared/datasources/external/http-json/tests/fetcher.test.ts +70 -0
  379. package/src/shared/datasources/external/instagram/feed/fetcher.ts +43 -0
  380. package/src/shared/datasources/external/instagram/feed/sample.ts +22 -0
  381. package/src/shared/datasources/external/instagram/feed/schema.ts +23 -0
  382. package/src/shared/datasources/external/instagram/feed/tests/fetcher.test.ts +82 -0
  383. package/src/shared/datasources/external/mastodon/account/fetcher.ts +33 -0
  384. package/src/shared/datasources/external/mastodon/account/sample.ts +33 -0
  385. package/src/shared/datasources/external/mastodon/account/schema.ts +45 -0
  386. package/src/shared/datasources/external/mastodon/account/tests/fetcher.test.ts +65 -0
  387. package/src/shared/datasources/external/mastodon/options.ts +11 -0
  388. package/src/shared/datasources/external/mastodon/status/fetcher.ts +45 -0
  389. package/src/shared/datasources/external/mastodon/status/sample.array.ts +59 -0
  390. package/src/shared/datasources/external/mastodon/status/sample.single.ts +55 -0
  391. package/src/shared/datasources/external/mastodon/status/schema.ts +130 -0
  392. package/src/shared/datasources/external/mastodon/status/tests/fetcher.test.ts +74 -0
  393. package/src/shared/datasources/external/meta/oauth/config.ts +16 -0
  394. package/src/shared/datasources/external/meta/options.ts +11 -0
  395. package/src/shared/datasources/external/rss/fetcher.ts +30 -0
  396. package/src/shared/datasources/external/rss/options.ts +11 -0
  397. package/src/shared/datasources/external/rss/sample.ts +22 -0
  398. package/src/shared/datasources/external/rss/schema.ts +42 -0
  399. package/src/shared/datasources/external/threads/media/fetcher.ts +63 -0
  400. package/src/shared/datasources/external/threads/media/sample.ts +44 -0
  401. package/src/shared/datasources/external/threads/media/schema.ts +37 -0
  402. package/src/shared/datasources/external/tiktok/oauth/config.ts +17 -0
  403. package/src/shared/datasources/external/tiktok/video/fetcher.ts +49 -0
  404. package/src/shared/datasources/external/tiktok/video/options.ts +12 -0
  405. package/src/shared/datasources/external/tiktok/video/sample.ts +26 -0
  406. package/src/shared/datasources/external/tiktok/video/schema.ts +27 -0
  407. package/src/shared/datasources/external/youtube/list/fetcher.ts +46 -0
  408. package/src/shared/datasources/external/youtube/list/options.ts +15 -0
  409. package/src/shared/datasources/external/youtube/list/sample.ts +33 -0
  410. package/src/shared/datasources/external/youtube/list/schema.ts +38 -0
  411. package/src/shared/datasources/external/youtube/oauth/config.ts +15 -0
  412. package/src/shared/datasources/fetcher.ts +17 -0
  413. package/src/shared/datasources/internal/blog/schema.ts +69 -0
  414. package/src/shared/datasources/internal/changelog/schema.ts +48 -0
  415. package/src/shared/datasources/internal/contact-info/schema.ts +20 -0
  416. package/src/shared/datasources/internal/cv/schema.ts +217 -0
  417. package/src/shared/datasources/internal/faq/schema.ts +27 -0
  418. package/src/shared/datasources/internal/job-board/schema.ts +228 -0
  419. package/src/shared/datasources/internal/links/schema.ts +15 -0
  420. package/src/shared/datasources/internal/recipes/schema.ts +42 -0
  421. package/src/shared/datasources/internal/restaurant/schema.ts +225 -0
  422. package/src/shared/datasources/provider-options.ts +7 -0
  423. package/src/shared/datasources/samples.ts +26 -0
  424. package/src/shared/datasources/schemas.ts +45 -0
  425. package/src/shared/datasources/types.ts +276 -0
  426. package/src/shared/datasources/utils.ts +16 -0
  427. package/src/shared/datasources.ts +42 -0
  428. package/src/shared/env.ts +23 -0
  429. package/src/shared/errors.ts +1 -0
  430. package/src/shared/images.ts +44 -0
  431. package/src/shared/index.ts +3 -0
  432. package/src/shared/layout-constants.ts +25 -0
  433. package/src/shared/manifest.ts +50 -0
  434. package/src/shared/oauth.ts +16 -0
  435. package/src/shared/page.ts +61 -0
  436. package/src/shared/prompt.ts +9 -0
  437. package/src/shared/responsive.ts +5 -0
  438. package/src/shared/site.ts +97 -0
  439. package/src/shared/sitemap.ts +66 -0
  440. package/src/shared/social-icons.ts +307 -0
  441. package/src/shared/tests/attributes.test.ts +37 -0
  442. package/src/shared/theme.ts +245 -0
  443. package/src/shared/themes/README.md +34 -0
  444. package/src/shared/themes/color-system.ts +127 -0
  445. package/src/shared/utils/canvas-data-uri.ts +2 -0
  446. package/src/shared/utils/invariant.ts +25 -0
  447. package/src/shared/utils/json-date.ts +8 -0
  448. package/src/shared/utils/merge.ts +12 -0
  449. package/src/shared/utils/object-hash.ts +7 -0
  450. package/src/shared/utils/schema.ts +30 -0
  451. package/src/shared/utils/try-catch.ts +12 -0
  452. package/src/shared/utils/typed-ref.ts +41 -0
  453. package/dist/shared/bricks/manifests/countdown.manifest.d.ts +0 -57
  454. package/dist/shared/bricks/manifests/countdown.manifest.d.ts.map +0 -1
  455. package/dist/shared/bricks/manifests/countdown.manifest.js +0 -3
  456. package/dist/shared/bricks/manifests/generic-component.manifest.d.ts +0 -62
  457. package/dist/shared/bricks/manifests/generic-component.manifest.d.ts.map +0 -1
  458. package/dist/shared/bricks/manifests/generic-component.manifest.js +0 -3
  459. package/dist/shared/bricks/manifests/header.manifest.d.ts +0 -275
  460. package/dist/shared/bricks/manifests/header.manifest.d.ts.map +0 -1
  461. package/dist/shared/bricks/manifests/header.manifest.js +0 -3
  462. package/dist/shared/bricks/props/_docs-common-styles.d.ts +0 -59
  463. package/dist/shared/bricks/props/_docs-common-styles.d.ts.map +0 -1
  464. package/dist/shared/bricks/props/_docs-common-styles.js +0 -3
  465. package/dist/shared/bricks/props/tests/container.test.d.ts +0 -2
  466. package/dist/shared/bricks/props/tests/container.test.d.ts.map +0 -1
  467. package/dist/shared/chunk-2ZPY4LCA.js +0 -3
  468. package/dist/shared/chunk-3CY6AZG7.js +0 -3
  469. package/dist/shared/chunk-4FLI7C3B.js +0 -3
  470. package/dist/shared/chunk-64II435T.js +0 -3
  471. package/dist/shared/chunk-6LDLGZUM.js +0 -3
  472. package/dist/shared/chunk-6MEWEGNA.js +0 -3
  473. package/dist/shared/chunk-AZ63RF3K.js +0 -3
  474. package/dist/shared/chunk-BK6LBWDI.js +0 -3
  475. package/dist/shared/chunk-BMDB2V7J.js +0 -3
  476. package/dist/shared/chunk-BXEKJXEP.js +0 -3
  477. package/dist/shared/chunk-DAPQ4JPP.js +0 -3
  478. package/dist/shared/chunk-ERSFH7XA.js +0 -3
  479. package/dist/shared/chunk-F2ZVIFHO.js +0 -3
  480. package/dist/shared/chunk-H6L4KRCJ.js +0 -3
  481. package/dist/shared/chunk-IKAMZM4I.js +0 -3
  482. package/dist/shared/chunk-IWSVY2VC.js +0 -3
  483. package/dist/shared/chunk-JVDUEZYO.js +0 -3
  484. package/dist/shared/chunk-KB4HY432.js +0 -3
  485. package/dist/shared/chunk-LDOM2LJF.js +0 -3
  486. package/dist/shared/chunk-P5FVZ5PL.js +0 -3
  487. package/dist/shared/chunk-PD7P5KSV.js +0 -3
  488. package/dist/shared/chunk-PJ6HA55L.js +0 -3
  489. package/dist/shared/chunk-PSSJMWGU.js +0 -3
  490. package/dist/shared/chunk-Q4MXTCE4.js +0 -8
  491. package/dist/shared/chunk-QCQH5WLN.js +0 -3
  492. package/dist/shared/chunk-RBYYMUOZ.js +0 -3
  493. package/dist/shared/chunk-RHRJYPU3.js +0 -3
  494. package/dist/shared/chunk-S64XUCWM.js +0 -3
  495. package/dist/shared/chunk-SO5M7CYA.js +0 -3
  496. package/dist/shared/chunk-SQVL4WSX.js +0 -3
  497. package/dist/shared/chunk-SWGSHUTE.js +0 -3
  498. package/dist/shared/chunk-U44NTSIO.js +0 -3
  499. package/dist/shared/chunk-U4R5EGBK.js +0 -3
  500. package/dist/shared/chunk-U5WW6K7W.js +0 -3
  501. package/dist/shared/chunk-V2NS45PF.js +0 -3
  502. package/dist/shared/chunk-WOEBR25A.js +0 -3
  503. package/dist/shared/chunk-WPTVLIYS.js +0 -3
  504. package/dist/shared/chunk-WXKRIUTA.js +0 -3
  505. package/dist/shared/chunk-XBX6II3M.js +0 -3
  506. package/dist/shared/chunk-XGCBIXOO.js +0 -3
  507. package/dist/shared/chunk-YY6DANZF.js +0 -3
  508. package/dist/shared/chunk-ZWQHIQEQ.js +0 -3
  509. package/dist/shared/datasources/external/json/fetcher.d.ts.map +0 -1
  510. package/dist/shared/datasources/external/json/options.d.ts.map +0 -1
  511. package/dist/shared/datasources/external/json/schema.d.ts.map +0 -1
  512. package/dist/shared/datasources/external/json/tests/fetcher.test.d.ts.map +0 -1
  513. package/dist/shared/datasources/external/rss/tests/fetcher.test.d.ts +0 -2
  514. package/dist/shared/datasources/external/rss/tests/fetcher.test.d.ts.map +0 -1
  515. package/dist/shared/template.d.ts +0 -898
  516. package/dist/shared/template.d.ts.map +0 -1
  517. package/dist/shared/template.js +0 -3
  518. package/dist/shared/tests/page.test.d.ts +0 -2
  519. package/dist/shared/tests/page.test.d.ts.map +0 -1
  520. package/dist/shared/tests/test-config.d.ts +0 -3
  521. package/dist/shared/tests/test-config.d.ts.map +0 -1
  522. package/dist/shared/themes/all-themes.d.ts +0 -3
  523. package/dist/shared/themes/all-themes.d.ts.map +0 -1
  524. package/dist/shared/themes/all-themes.js +0 -3
  525. /package/dist/shared/datasources/external/{json → http-json}/fetcher.d.ts +0 -0
  526. /package/dist/shared/datasources/external/{json → http-json}/options.d.ts +0 -0
  527. /package/dist/shared/datasources/external/{json → http-json}/tests/fetcher.test.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/node/cli/commands/publish/uploader.ts","../../../../../src/node/cli/constants.ts","../../../../../src/node/shared/logger.ts","../../../../../package.json","../../../../../src/node/cli/commands/publish/parse-gitignore.ts","../../../../../src/node/cli/store.ts","../../../../../src/node/cli/api.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport crypto from \"node:crypto\";\nimport fg from \"fast-glob\";\nimport { API_BASE_URL, DEFAULT_UPLOAD_MAX_CONCURRENCY } from \"../../constants\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport { pipeline } from \"node:stream\";\nimport type { GenericApiError } from \"../../types\";\nimport { logger } from \"~/node/shared/logger\";\nimport chalk from \"chalk\";\nimport FormData from \"form-data\";\nimport parseGitIgnore from \"./parse-gitignore\";\nimport PQueue from \"p-queue\";\nimport ora from \"ora\";\nimport { customAlphabet } from \"nanoid\";\nimport { post } from \"../../api\";\n\ninterface UploadStats {\n fileName: string;\n fileSize: number;\n uploadDuration: number;\n statusCode: number;\n serverResponse: string;\n}\n\nclass UploadError extends Error implements GenericApiError {\n constructor(\n public error: string,\n public error_description: string,\n public filename: string,\n ) {\n super(`${error}: ${error_description}`);\n this.name = \"UploadError\";\n }\n}\n\ninterface UploadConfig {\n maxDataSize: number;\n retryAttempts: number;\n retryDelay: number;\n}\n\nconst defaultConfig: UploadConfig = {\n maxDataSize: 12 * 1024 * 1024, // 12MB\n retryAttempts: 2,\n retryDelay: 1000,\n};\n\nconst agent = new http.Agent({\n keepAlive: true,\n maxSockets: 10,\n keepAliveMsecs: 3000, // Keep connections open for 3 seconds\n});\n\nasync function discoverFiles(templateDir: string): Promise<string[]> {\n const gitignore = path.join(templateDir, \".gitignore\");\n const gitignoreExists = fs.existsSync(gitignore);\n const gitignored = gitignoreExists ? parseGitIgnore(fs.readFileSync(gitignore, \"utf-8\")).patterns : [];\n\n return fg(\"**/*\", {\n cwd: templateDir,\n onlyFiles: true,\n dot: true,\n absolute: true,\n ignore: [\n \"node_modules/**\",\n \".cache/**\",\n \"**/.DS_Store\",\n \".gitignore\",\n \".env\",\n \".env.*\",\n \".git/**\",\n \"dist/**\",\n ...gitignored,\n ],\n });\n}\n\nasync function uploadFile(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n const uploadWithRetry = async (attempt: number): Promise<UploadStats> => {\n try {\n return await performUpload(filePath, relativePath, uploadUrl, templateId, spinner, token, config);\n } catch (error) {\n if (attempt < config.retryAttempts) {\n logger.warn(`Retrying upload for ${relativePath} (attempt ${attempt + 1})`);\n await new Promise((resolve) => setTimeout(resolve, config.retryDelay));\n return uploadWithRetry(attempt + 1);\n }\n throw error;\n }\n };\n\n return uploadWithRetry(0);\n}\n\nasync function performUpload(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n return new Promise<UploadStats>((resolve, reject) => {\n const stats = fs.statSync(filePath);\n const fileName = path.basename(filePath);\n const startTime = Date.now();\n\n const form = new FormData({\n maxDataSize: config.maxDataSize,\n });\n const fileStream = fs.createReadStream(filePath);\n let totalUploaded = 0;\n\n const updateProgress = (chunk: Buffer | string) => {\n totalUploaded += chunk.length;\n };\n\n fileStream.on(\"data\", updateProgress);\n form.append(\"file\", fileStream, {\n filename: fileName,\n knownLength: stats.size,\n });\n\n const options: https.RequestOptions = {\n agent,\n method: \"POST\",\n headers: {\n authorization: `Bearer ${token}`,\n \"x-upstart-template-file-path\": relativePath,\n \"x-upstart-template-id\": templateId,\n ...form.getHeaders(),\n },\n };\n\n const protocol = uploadUrl.startsWith(\"https\") ? https : http;\n const req = protocol.request(uploadUrl, options, (res) => {\n let responseBody = \"\";\n res.on(\"data\", (chunk) => {\n responseBody += chunk;\n });\n\n res.on(\"end\", () => {\n const endTime = Date.now();\n const uploadStats: UploadStats = {\n fileName,\n fileSize: stats.size,\n uploadDuration: endTime - startTime,\n statusCode: res.statusCode ?? 0,\n serverResponse: responseBody,\n };\n\n if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {\n spinner.text = `Uploaded ${relativePath}`;\n resolve(uploadStats);\n } else {\n let errorObject: UploadError;\n if (res.headers[\"content-type\"]?.startsWith(\"application/json\")) {\n const parsedError = JSON.parse(responseBody);\n errorObject = new UploadError(\n parsedError.error || \"unknown_error\",\n parsedError.error_description || \"Unknown error occurred\",\n relativePath,\n );\n } else {\n errorObject = new UploadError(\n \"unknown_error\",\n responseBody || \"Unknown error occurred\",\n relativePath,\n );\n }\n\n spinner.fail(\n `Failed to upload ${relativePath} [${errorObject.error}] ${errorObject.error_description}`,\n );\n\n reject(errorObject);\n }\n });\n });\n\n req.on(\"error\", (error) => {\n reject(new UploadError(\"request_error\", error.message, relativePath));\n });\n\n pipeline(form, req, (err) => {\n if (err) {\n reject(\n new UploadError(\"pipeline_error\", `Pipeline failed for ${fileName}: ${err.message}`, relativePath),\n );\n }\n });\n });\n}\n\nfunction reportUploadStatistics(\n templateId: string,\n uploadedFiles: UploadStats[],\n failedFiles: PromiseRejectedResult[],\n) {\n if (failedFiles.length > 0) {\n logger.error(chalk.red(`Failed to upload ${failedFiles.length} files:`));\n failedFiles.forEach((failure) => {\n const error = failure.reason as UploadError;\n logger.error(`- ${error.filename}: ${error.error_description} (${error.error})`);\n });\n } else {\n logger.info(\n chalk.green(`Uploaded ${uploadedFiles.length} files successfully for template ${templateId}.\\n`),\n );\n }\n}\n\nexport async function uploadTemplate(\n templateId: string,\n templateDir: string,\n token: string,\n dryRun = false,\n config: Partial<UploadConfig> = {},\n) {\n const fullConfig = { ...defaultConfig, ...config };\n const queue = new PQueue({ concurrency: DEFAULT_UPLOAD_MAX_CONCURRENCY });\n const files = await discoverFiles(templateDir);\n const filesCount = files.length;\n const signatures: Record<string, string> = {};\n // generate a upload id\n const uploadId = generateUploadId();\n let completedUploads = 0;\n\n // compute signatures\n for (const file of files) {\n const relativePath = path.relative(templateDir, file);\n const md5 = await sha1sum(file);\n signatures[relativePath] = md5;\n }\n\n if (dryRun) {\n logger.info(\"Dry run mode enabled. Skipping upload.\\n\");\n logger.info(\"The following files would have been uploaded:\");\n files.forEach((file) => logger.info(`- ${file}`));\n process.exit(0);\n }\n\n const spinner = ora(`Uploading ${filesCount} files...`).start();\n\n // upload files\n const uploadPromises = files.map((file) => {\n const fullPath = path.resolve(templateDir, file);\n const relativePath = path.relative(templateDir, file);\n const url = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}`;\n return queue.add(async () => {\n const result = await uploadFile(fullPath, relativePath, url, templateId, spinner, token, fullConfig);\n completedUploads++;\n return result;\n });\n });\n\n const results = await Promise.allSettled(uploadPromises);\n spinner.stop();\n\n const uploadedFiles = results.filter(\n (result): result is PromiseFulfilledResult<UploadStats> => result.status === \"fulfilled\",\n );\n\n const failedFiles = results.filter(\n (result): result is PromiseRejectedResult => result.status === \"rejected\",\n );\n\n reportUploadStatistics(\n templateId,\n uploadedFiles.map((r) => r.value),\n failedFiles,\n );\n\n // finalize upload\n if (!failedFiles.length && uploadedFiles.length) {\n const finalizeUrl = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}/finalize`;\n const finalizePayload = {\n signatures,\n };\n\n const finalizeResponse = await post(finalizeUrl, finalizePayload);\n\n if (finalizeResponse.isError) {\n logger.error(\n `Failed to finalize upload: ${finalizeResponse.data.error_description} (${finalizeResponse.data.error})`,\n );\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles: [],\n success: false,\n };\n }\n }\n\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles,\n success: failedFiles.length === 0,\n };\n}\n\nasync function sha1sum(filePath: string): Promise<string> {\n const hash = await crypto.subtle.digest(\"SHA-1\", fs.readFileSync(filePath));\n // convert arrayBuffer to hex\n return Array.from(new Uint8Array(hash))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\nfunction generateUploadId(): string {\n const randomId = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 5);\n const now = new Date();\n const year = now.getUTCFullYear();\n const month = (now.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = now.getUTCDate().toString().padStart(2, \"0\");\n const hours = now.getUTCHours().toString().padStart(2, \"0\");\n const minutes = now.getUTCMinutes().toString().padStart(2, \"0\");\n const seconds = now.getUTCSeconds().toString().padStart(2, \"0\");\n return `${year}${month}${day}${hours}${minutes}${seconds}_${randomId()}`;\n}\n","export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\nimport { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${version}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","{\n \"name\": \"@upstart.gg/sdk\",\n \"version\": \"0.0.95\",\n \"type\": \"module\",\n \"files\": [\n \"dist\",\n \"env.d.ts\"\n ],\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": \"./dist/shared/index.js\",\n \"types\": \"./dist/shared/index.d.ts\"\n },\n \"./shared/*\": {\n \"types\": \"./dist/shared/*.d.ts\",\n \"import\": \"./dist/shared/*.js\"\n },\n \"./builder/*\": {\n \"import\": \"./dist/node/builder/*.js\"\n },\n \"./cli/*\": {\n \"import\": \"./dist/node/cli/*.js\"\n },\n \"./env.d.ts\": {\n \"types\": \"./env.d.ts\",\n \"require\": \"./env.d.ts\",\n \"import\": \"./env.d.ts\"\n },\n \"./*\": {\n \"types\": \"./dist/shared/*.d.ts\",\n \"import\": \"./dist/shared/*.js\"\n }\n },\n \"dependencies\": {\n \"@date-fns/utc\": \"1.2.0\",\n \"@headlessui/react\": \"2.2.1\",\n \"@inquirer/prompts\": \"5.3.8\",\n \"@radix-ui/react-context-menu\": \"2.2.2\",\n \"@radix-ui/react-toggle-group\": \"1.1.0\",\n \"@radix-ui/themes\": \"3.1.4\",\n \"@sinclair/typebox\": \"0.33.7\",\n \"@upstart.gg/style-system\": \"workspace:*\",\n \"ajv\": \"8.17.1\",\n \"ajv-formats\": \"3.0.1\",\n \"chalk\": \"5.3.0\",\n \"chroma-js\": \"3.1.2\",\n \"commander\": \"12.1.0\",\n \"conf\": \"13.0.1\",\n \"date-fns\": \"3.6.0\",\n \"debug\": \"4.3.6\",\n \"fast-glob\": \"3.3.2\",\n \"form-data\": \"4.0.0\",\n \"get-port\": \"7.1.0\",\n \"htmlparser2\": \"9.1.0\",\n \"http-errors-enhanced\": \"2.0.8\",\n \"immer\": \"10.1.1\",\n \"import-meta-resolve\": \"4.1.0\",\n \"lodash-es\": \"4.17.21\",\n \"nanoid\": \"5.0.7\",\n \"open\": \"10.1.0\",\n \"ora\": \"8.1.0\",\n \"p-queue\": \"8.0.1\",\n \"react-hotkeys-hook\": \"4.5.1\",\n \"react-icons\": \"5.3.0\",\n \"react-selecto\": \"1.26.3\",\n \"rollup-plugin-strip-banner\": \"3.1.0\",\n \"usehooks-ts\": \"3.1.0\",\n \"zundo\": \"2.3.0\",\n \"zustand\": \"4.5.5\"\n },\n \"peerDependencies\": {\n \"@upstart.gg/style-system\": \"workspace:*\",\n \"react\": \"18.3.0-canary-3d9b20132-20240124\",\n \"react-dom\": \"18.3.0-canary-3d9b20132-20240124\"\n },\n \"devDependencies\": {\n \"@cloudflare/workers-types\": \"4.20240806.0\",\n \"@types/chroma-js\": \"2.4.4\",\n \"@types/cli-progress\": \"3.11.6\",\n \"@types/debug\": \"4.1.12\",\n \"@types/express\": \"^4.17.21\",\n \"@types/lodash-es\": \"4.17.12\",\n \"@types/node\": \"^20.14.10\",\n \"@types/react\": \"18.3.3\",\n \"@types/react-dom\": \"^18.3.0\",\n \"@types/sortablejs\": \"1.15.8\",\n \"@vitejs/plugin-react\": \"^4.3.4\",\n \"concurrently\": \"8.2.2\",\n \"express\": \"^4.21.2\",\n \"rimraf\": \"6.0.1\",\n \"tsup\": \"8.2.4\",\n \"vite\": \"5.4.6\",\n \"vite-plugin-dts\": \"4.2.1\",\n \"vite-plugin-image-optimizer\": \"1.1.8\",\n \"vite-plugin-inspect\": \"0.8.7\",\n \"vite-plugin-virtual\": \"0.3.0\",\n \"vite-tsconfig-paths\": \"5.0.1\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"build:types\": \"tsc --emitDeclarationOnly --declaration --declarationMap\",\n \"dev\": \"NODE_OPTIONS='--max-old-space-size=12384' tsup --watch\",\n \"sizetest\": \"pnpm build && du -sh dist\",\n \"lint\": \"biome check --write . && tsc --noEmit\",\n \"ci:lint\": \"tsc --noEmit\",\n \"test\": \"vitest\",\n \"gen-ia-docs\": \"tsx scripts/generate-ia-docs.ts\"\n },\n \"author\": \"Matthias Etienne\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","/*!\n * parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>\n * Copyright (c) 2015-present, Jon Schlinkert.\n * Released under the MIT License.\n *\n * Converted to typescript by Matthias E. <matthias@upstart.gg>\n */\n\nimport * as fs from \"node:fs\";\n\n// eslint-disable-next-line no-control-regex\nconst INVALID_PATH_CHARS_REGEX = /[<>\"|?*\\n\\r\\t\\f\\x00-\\x1F]/;\nconst GLOBSTAR_REGEX = /(?:^|\\/)[*]{2}($|\\/)/;\nconst MAX_PATH_LENGTH = 260 - 12;\n\ninterface ParseOptions {\n path?: string;\n dedupe?: boolean;\n unique?: boolean;\n ignore?: string[];\n unignore?: string[];\n format?: boolean;\n formatSection?: (section: Section) => string;\n}\n\ninterface Section {\n name: string;\n comment?: string;\n patterns: string[];\n}\n\ninterface ParsedGitignore {\n sections: Section[];\n patterns: string[];\n path?: string;\n input: Buffer;\n format: (opts?: ParseOptions) => string;\n dedupe: (opts?: ParseOptions) => ParsedGitignore;\n globs: (opts?: ParseOptions) => GlobResult[];\n}\n\ninterface GlobResult {\n type: \"ignore\" | \"unignore\";\n path: string | null;\n patterns: string[];\n index: number;\n}\n\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n v !== null && typeof v === \"object\" && !Array.isArray(v);\n\nconst isValidPath = (input: unknown): input is string =>\n typeof input === \"string\" && input.length <= MAX_PATH_LENGTH && !INVALID_PATH_CHARS_REGEX.test(input);\n\nconst split = (str: string): string[] => str.split(/\\r\\n?|\\n/);\nconst isComment = (str: string): boolean => str.startsWith(\"#\");\nconst isParsed = (input: unknown): input is ParsedGitignore =>\n isObject(input) && Array.isArray(input.patterns) && Array.isArray(input.sections);\n\nconst patterns = (input: string): string[] =>\n split(input)\n .map((l) => l.trim())\n .filter((line) => line !== \"\" && !isComment(line));\n\nconst parse = (input: string | ParsedGitignore, options: ParseOptions = {}): ParsedGitignore => {\n let filepath = options.path;\n\n if (isParsed(input)) return input;\n if (isValidPath(input) && fs.existsSync(input)) {\n filepath = input;\n input = fs.readFileSync(input, \"utf8\");\n }\n\n const lines = split(input);\n const names = new Map<string, Section>();\n\n let parsed: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let section: Section = { name: \"default\", patterns: [] };\n let prev: Section | null = null;\n\n for (const line of lines) {\n const value = line.trim();\n\n if (value.startsWith(\"#\")) {\n const [, name] = /^#+\\s*(.*)\\s*$/.exec(value) || [];\n\n if (prev) {\n names.delete(prev.name);\n prev.comment = prev.comment ? `${prev.comment}\\n${value}` : value;\n prev.name = name ? `${prev.name.trim()}\\n${name.trim()}` : prev.name.trim();\n names.set(prev.name.toLowerCase().trim(), prev);\n continue;\n }\n\n section = { name: name?.trim() || \"\", comment: value, patterns: [] };\n names.set(section.name.toLowerCase(), section);\n parsed.sections.push(section);\n prev = section;\n continue;\n }\n\n if (value !== \"\") {\n section.patterns.push(value);\n parsed.patterns.push(value);\n }\n\n prev = null;\n }\n\n if (options.dedupe === true || options.unique === true) {\n parsed = dedupe(parsed, { ...options, format: false });\n }\n\n parsed.path = filepath;\n parsed.input = Buffer.from(input);\n parsed.format = (opts?: ParseOptions) => format(parsed, { ...options, ...opts });\n parsed.dedupe = (opts?: ParseOptions) => dedupe(parsed, { ...options, ...opts });\n parsed.globs = (opts?: ParseOptions) => globs(parsed, { path: filepath, ...options, ...opts });\n return parsed;\n};\n\nconst parseFile = (filepath: string, options?: ParseOptions): ParsedGitignore =>\n parse(fs.readFileSync(filepath, \"utf8\"), options);\n\nconst dedupe = (input: string | ParsedGitignore, options: ParseOptions): ParsedGitignore => {\n const parsed = parse(input, { ...options, dedupe: false });\n\n const names = new Map<string, Section>();\n const res: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let current: Section;\n\n // first, combine duplicate sections\n for (const section of parsed.sections) {\n const { name = \"\", comment, patterns } = section;\n const key = name.trim().toLowerCase();\n\n for (const pattern of patterns) {\n if (!res.patterns.includes(pattern)) {\n res.patterns.push(pattern);\n }\n }\n\n if (name && names.has(key)) {\n current = names.get(key)!;\n current.patterns = [...current.patterns, ...patterns];\n } else {\n current = { name, comment, patterns };\n res.sections.push(current);\n names.set(key, current);\n }\n }\n\n // next, de-dupe patterns in each section\n for (const section of res.sections) {\n section.patterns = [...new Set(section.patterns)];\n }\n\n return res;\n};\n\nconst glob = (pattern: string): string => {\n // Return if a glob pattern has already been specified for sub-directories\n if (GLOBSTAR_REGEX.test(pattern)) {\n return pattern;\n }\n\n // If there is a separator at the beginning or middle (or both) of the pattern,\n // then the pattern is relative to the directory level of the particular .gitignore\n // file itself. Otherwise the pattern may also match at any level below the\n // .gitignore level. relative paths only\n let relative = false;\n if (pattern.startsWith(\"/\")) {\n pattern = pattern.slice(1);\n relative = true;\n } else if (pattern.slice(1, pattern.length - 1).includes(\"/\")) {\n relative = true;\n }\n\n // If there is a separator at the end of the pattern then the pattern will only match directories.\n pattern += pattern.endsWith(\"/\") ? \"**/\" : \"/**\";\n\n // If not relative, the pattern can match any files and directories.\n return relative ? pattern : `**/${pattern}`;\n};\n\nconst globs = (input: string | ParsedGitignore, options: ParseOptions = {}): GlobResult[] => {\n const parsed = parse(input, options);\n const result: GlobResult[] = [];\n let index = 0;\n\n const globPatterns = parsed.patterns\n .concat(options.ignore || [])\n .concat((options.unignore || []).map((p) => (!p.startsWith(\"!\") ? `!${p}` : p)));\n\n const push = (prefix: string, pattern: string) => {\n const prev = result[result.length - 1];\n const type = prefix ? \"unignore\" : \"ignore\";\n\n if (prev && prev.type === type) {\n if (!prev.patterns.includes(pattern)) {\n prev.patterns.push(pattern);\n }\n } else {\n result.push({ type, path: options.path || null, patterns: [pattern], index });\n index++;\n }\n };\n\n for (let pattern of globPatterns) {\n let prefix = \"\";\n\n // An optional prefix \"!\" which negates the pattern; any matching file excluded by\n // a previous pattern will become included again\n if (pattern.startsWith(\"!\")) {\n pattern = pattern.slice(1);\n prefix = \"!\";\n }\n\n // add the raw pattern to the results\n push(prefix, pattern.startsWith(\"/\") ? pattern.slice(1) : pattern);\n\n // add the glob pattern to the results\n push(prefix, glob(pattern));\n }\n\n return result;\n};\n\n/**\n * Formats a .gitignore section\n */\nconst formatSection = (section: Section = { name: \"\", patterns: [] }): string => {\n const output = [section.comment || \"\"];\n\n if (section.patterns?.length) {\n output.push(section.patterns.join(\"\\n\"));\n output.push(\"\");\n }\n\n return output.join(\"\\n\");\n};\n\n/**\n * Format a .gitignore file from the given input or object from `.parse()`.\n * @param {String | ParsedGitignore} input File path or contents.\n * @param {ParseOptions} options\n * @return {String} Returns formatted string.\n * @api public\n */\nconst format = (input: string | ParsedGitignore, options: ParseOptions = {}): string => {\n const parsed = parse(input, options);\n\n const fn = options.formatSection || formatSection;\n const sections = parsed.sections || parsed;\n const output: string[] = [];\n\n for (const section of ([] as Section[]).concat(sections)) {\n output.push(fn(section));\n }\n\n return output.join(\"\\n\");\n};\n\nexport {\n parse,\n parseFile,\n dedupe,\n format,\n globs,\n formatSection,\n patterns,\n type ParseOptions,\n type Section,\n type ParsedGitignore,\n type GlobResult,\n};\n\nexport default parse;\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n"],"mappings":";;AAAA,OAAOA,MAAU,YACjB,OAAOC,MAAQ,UACf,OAAOC,OAAY,cACnB,OAAOC,OAAQ,YCHR,IAAMC,EAAmB,cAEzB,IAAMC,GACX,Q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AGC,CAAK,GAAGC,CAAO,GAAGC,CAAO,IAAIR,EAAS,CAAC,EACxE","names":["path","fs","crypto","fg","CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","DEFAULT_UPLOAD_MAX_CONCURRENCY","http","https","pipeline","createLoggerBase","version","chalk","createLogger","level","allowClearScreen","showVersion","logger","createLoggerBase","version","message","options","chalk","FormData","fs","INVALID_PATH_CHARS_REGEX","GLOBSTAR_REGEX","MAX_PATH_LENGTH","isObject","v","isValidPath","input","split","str","isParsed","input","isObject","parse","input","options","filepath","isParsed","isValidPath","lines","split","names","parsed","section","prev","line","value","name","dedupe","opts","format","globs","dedupe","input","options","parsed","parse","names","res","current","section","name","comment","patterns","key","pattern","glob","GLOBSTAR_REGEX","relative","globs","result","index","globPatterns","p","push","prefix","prev","type","formatSection","output","format","fn","sections","parse_gitignore_default","parse","PQueue","ora","customAlphabet","Conf","path","crypto","fs","fileURLToPath","chalk","__dirname","fileURLToPath","key","getKey","accessStore","Conf","CLI_PROJECT_NAME","findNearestNodeModules","currentDir","__dirname","path","nodeModulesPath","fs","getKey","tmpSecureStoreDir","keyPath","key","crypto","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","toURL","path","apiBaseURL","API_BASE_URL","formatResponse","response","data","UploadError","error","error_description","filename","defaultConfig","agent","http","discoverFiles","templateDir","gitignore","path","gitignored","fs","parse_gitignore_default","fg","uploadFile","filePath","relativePath","uploadUrl","templateId","spinner","token","config","uploadWithRetry","attempt","performUpload","logger","resolve","reject","stats","fileName","startTime","form","FormData","fileStream","totalUploaded","updateProgress","chunk","options","req","https","res","responseBody","endTime","uploadStats","errorObject","parsedError","pipeline","err","reportUploadStatistics","uploadedFiles","failedFiles","chalk","failure","uploadTemplate","dryRun","fullConfig","queue","PQueue","DEFAULT_UPLOAD_MAX_CONCURRENCY","files","filesCount","signatures","uploadId","generateUploadId","completedUploads","file","md5","sha1sum","ora","uploadPromises","fullPath","url","API_BASE_URL","result","results","r","finalizeUrl","finalizeResponse","post","hash","crypto","b","randomId","customAlphabet","now","year","month","day","hours","minutes","seconds"]}
1
+ {"version":3,"sources":["../../../../../src/node/cli/commands/publish/uploader.ts","../../../../../src/node/cli/constants.ts","../../../../../src/node/shared/logger.ts","../../../../../src/node/cli/commands/publish/parse-gitignore.ts","../../../../../src/node/cli/store.ts","../../../../../src/node/cli/api.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport crypto from \"node:crypto\";\nimport fg from \"fast-glob\";\nimport { API_BASE_URL, DEFAULT_UPLOAD_MAX_CONCURRENCY } from \"../../constants\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport { pipeline } from \"node:stream\";\nimport type { GenericApiError } from \"../../types\";\nimport { logger } from \"~/node/shared/logger\";\nimport chalk from \"chalk\";\nimport FormData from \"form-data\";\nimport parseGitIgnore from \"./parse-gitignore\";\nimport PQueue from \"p-queue\";\nimport ora from \"ora\";\nimport { customAlphabet } from \"nanoid\";\nimport { post } from \"../../api\";\n\ninterface UploadStats {\n fileName: string;\n fileSize: number;\n uploadDuration: number;\n statusCode: number;\n serverResponse: string;\n}\n\nclass UploadError extends Error implements GenericApiError {\n constructor(\n public error: string,\n public error_description: string,\n public filename: string,\n ) {\n super(`${error}: ${error_description}`);\n this.name = \"UploadError\";\n }\n}\n\ninterface UploadConfig {\n maxDataSize: number;\n retryAttempts: number;\n retryDelay: number;\n}\n\nconst defaultConfig: UploadConfig = {\n maxDataSize: 12 * 1024 * 1024, // 12MB\n retryAttempts: 2,\n retryDelay: 1000,\n};\n\nconst agent = new http.Agent({\n keepAlive: true,\n maxSockets: 10,\n keepAliveMsecs: 3000, // Keep connections open for 3 seconds\n});\n\nasync function discoverFiles(templateDir: string): Promise<string[]> {\n const gitignore = path.join(templateDir, \".gitignore\");\n const gitignoreExists = fs.existsSync(gitignore);\n const gitignored = gitignoreExists ? parseGitIgnore(fs.readFileSync(gitignore, \"utf-8\")).patterns : [];\n\n return fg(\"**/*\", {\n cwd: templateDir,\n onlyFiles: true,\n dot: true,\n absolute: true,\n ignore: [\n \"node_modules/**\",\n \".cache/**\",\n \"**/.DS_Store\",\n \".gitignore\",\n \".env\",\n \".env.*\",\n \".git/**\",\n \"dist/**\",\n ...gitignored,\n ],\n });\n}\n\nasync function uploadFile(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n const uploadWithRetry = async (attempt: number): Promise<UploadStats> => {\n try {\n return await performUpload(filePath, relativePath, uploadUrl, templateId, spinner, token, config);\n } catch (error) {\n if (attempt < config.retryAttempts) {\n logger.warn(`Retrying upload for ${relativePath} (attempt ${attempt + 1})`);\n await new Promise((resolve) => setTimeout(resolve, config.retryDelay));\n return uploadWithRetry(attempt + 1);\n }\n throw error;\n }\n };\n\n return uploadWithRetry(0);\n}\n\nasync function performUpload(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n return new Promise<UploadStats>((resolve, reject) => {\n const stats = fs.statSync(filePath);\n const fileName = path.basename(filePath);\n const startTime = Date.now();\n\n const form = new FormData({\n maxDataSize: config.maxDataSize,\n });\n const fileStream = fs.createReadStream(filePath);\n let totalUploaded = 0;\n\n const updateProgress = (chunk: Buffer | string) => {\n totalUploaded += chunk.length;\n };\n\n fileStream.on(\"data\", updateProgress);\n form.append(\"file\", fileStream, {\n filename: fileName,\n knownLength: stats.size,\n });\n\n const options: https.RequestOptions = {\n agent,\n method: \"POST\",\n headers: {\n authorization: `Bearer ${token}`,\n \"x-upstart-template-file-path\": relativePath,\n \"x-upstart-template-id\": templateId,\n ...form.getHeaders(),\n },\n };\n\n const protocol = uploadUrl.startsWith(\"https\") ? https : http;\n const req = protocol.request(uploadUrl, options, (res) => {\n let responseBody = \"\";\n res.on(\"data\", (chunk) => {\n responseBody += chunk;\n });\n\n res.on(\"end\", () => {\n const endTime = Date.now();\n const uploadStats: UploadStats = {\n fileName,\n fileSize: stats.size,\n uploadDuration: endTime - startTime,\n statusCode: res.statusCode ?? 0,\n serverResponse: responseBody,\n };\n\n if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {\n spinner.text = `Uploaded ${relativePath}`;\n resolve(uploadStats);\n } else {\n let errorObject: UploadError;\n if (res.headers[\"content-type\"]?.startsWith(\"application/json\")) {\n const parsedError = JSON.parse(responseBody);\n errorObject = new UploadError(\n parsedError.error || \"unknown_error\",\n parsedError.error_description || \"Unknown error occurred\",\n relativePath,\n );\n } else {\n errorObject = new UploadError(\n \"unknown_error\",\n responseBody || \"Unknown error occurred\",\n relativePath,\n );\n }\n\n spinner.fail(\n `Failed to upload ${relativePath} [${errorObject.error}] ${errorObject.error_description}`,\n );\n\n reject(errorObject);\n }\n });\n });\n\n req.on(\"error\", (error) => {\n reject(new UploadError(\"request_error\", error.message, relativePath));\n });\n\n pipeline(form, req, (err) => {\n if (err) {\n reject(\n new UploadError(\"pipeline_error\", `Pipeline failed for ${fileName}: ${err.message}`, relativePath),\n );\n }\n });\n });\n}\n\nfunction reportUploadStatistics(\n templateId: string,\n uploadedFiles: UploadStats[],\n failedFiles: PromiseRejectedResult[],\n) {\n if (failedFiles.length > 0) {\n logger.error(chalk.red(`Failed to upload ${failedFiles.length} files:`));\n failedFiles.forEach((failure) => {\n const error = failure.reason as UploadError;\n logger.error(`- ${error.filename}: ${error.error_description} (${error.error})`);\n });\n } else {\n logger.info(\n chalk.green(`Uploaded ${uploadedFiles.length} files successfully for template ${templateId}.\\n`),\n );\n }\n}\n\nexport async function uploadTemplate(\n templateId: string,\n templateDir: string,\n token: string,\n dryRun = false,\n config: Partial<UploadConfig> = {},\n) {\n const fullConfig = { ...defaultConfig, ...config };\n const queue = new PQueue({ concurrency: DEFAULT_UPLOAD_MAX_CONCURRENCY });\n const files = await discoverFiles(templateDir);\n const filesCount = files.length;\n const signatures: Record<string, string> = {};\n // generate a upload id\n const uploadId = generateUploadId();\n let completedUploads = 0;\n\n // compute signatures\n for (const file of files) {\n const relativePath = path.relative(templateDir, file);\n const md5 = await sha1sum(file);\n signatures[relativePath] = md5;\n }\n\n if (dryRun) {\n logger.info(\"Dry run mode enabled. Skipping upload.\\n\");\n logger.info(\"The following files would have been uploaded:\");\n files.forEach((file) => logger.info(`- ${file}`));\n process.exit(0);\n }\n\n const spinner = ora(`Uploading ${filesCount} files...`).start();\n\n // upload files\n const uploadPromises = files.map((file) => {\n const fullPath = path.resolve(templateDir, file);\n const relativePath = path.relative(templateDir, file);\n const url = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}`;\n return queue.add(async () => {\n const result = await uploadFile(fullPath, relativePath, url, templateId, spinner, token, fullConfig);\n completedUploads++;\n return result;\n });\n });\n\n const results = await Promise.allSettled(uploadPromises);\n spinner.stop();\n\n const uploadedFiles = results.filter(\n (result): result is PromiseFulfilledResult<UploadStats> => result.status === \"fulfilled\",\n );\n\n const failedFiles = results.filter(\n (result): result is PromiseRejectedResult => result.status === \"rejected\",\n );\n\n reportUploadStatistics(\n templateId,\n uploadedFiles.map((r) => r.value),\n failedFiles,\n );\n\n // finalize upload\n if (!failedFiles.length && uploadedFiles.length) {\n const finalizeUrl = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}/finalize`;\n const finalizePayload = {\n signatures,\n };\n\n const finalizeResponse = await post(finalizeUrl, finalizePayload);\n\n if (finalizeResponse.isError) {\n logger.error(\n `Failed to finalize upload: ${finalizeResponse.data.error_description} (${finalizeResponse.data.error})`,\n );\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles: [],\n success: false,\n };\n }\n }\n\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles,\n success: failedFiles.length === 0,\n };\n}\n\nasync function sha1sum(filePath: string): Promise<string> {\n const hash = await crypto.subtle.digest(\"SHA-1\", fs.readFileSync(filePath));\n // convert arrayBuffer to hex\n return Array.from(new Uint8Array(hash))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\nfunction generateUploadId(): string {\n const randomId = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 5);\n const now = new Date();\n const year = now.getUTCFullYear();\n const month = (now.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = now.getUTCDate().toString().padStart(2, \"0\");\n const hours = now.getUTCHours().toString().padStart(2, \"0\");\n const minutes = now.getUTCMinutes().toString().padStart(2, \"0\");\n const seconds = now.getUTCSeconds().toString().padStart(2, \"0\");\n return `${year}${month}${day}${hours}${minutes}${seconds}_${randomId()}`;\n}\n","export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\n// import { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\nconst VERSION = 0.1;\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${VERSION}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","/*!\n * parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>\n * Copyright (c) 2015-present, Jon Schlinkert.\n * Released under the MIT License.\n *\n * Converted to typescript by Matthias E. <matthias@upstart.gg>\n */\n\nimport * as fs from \"node:fs\";\n\n// eslint-disable-next-line no-control-regex\nconst INVALID_PATH_CHARS_REGEX = /[<>\"|?*\\n\\r\\t\\f\\x00-\\x1F]/;\nconst GLOBSTAR_REGEX = /(?:^|\\/)[*]{2}($|\\/)/;\nconst MAX_PATH_LENGTH = 260 - 12;\n\ninterface ParseOptions {\n path?: string;\n dedupe?: boolean;\n unique?: boolean;\n ignore?: string[];\n unignore?: string[];\n format?: boolean;\n formatSection?: (section: Section) => string;\n}\n\ninterface Section {\n name: string;\n comment?: string;\n patterns: string[];\n}\n\ninterface ParsedGitignore {\n sections: Section[];\n patterns: string[];\n path?: string;\n input: Buffer;\n format: (opts?: ParseOptions) => string;\n dedupe: (opts?: ParseOptions) => ParsedGitignore;\n globs: (opts?: ParseOptions) => GlobResult[];\n}\n\ninterface GlobResult {\n type: \"ignore\" | \"unignore\";\n path: string | null;\n patterns: string[];\n index: number;\n}\n\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n v !== null && typeof v === \"object\" && !Array.isArray(v);\n\nconst isValidPath = (input: unknown): input is string =>\n typeof input === \"string\" && input.length <= MAX_PATH_LENGTH && !INVALID_PATH_CHARS_REGEX.test(input);\n\nconst split = (str: string): string[] => str.split(/\\r\\n?|\\n/);\nconst isComment = (str: string): boolean => str.startsWith(\"#\");\nconst isParsed = (input: unknown): input is ParsedGitignore =>\n isObject(input) && Array.isArray(input.patterns) && Array.isArray(input.sections);\n\nconst patterns = (input: string): string[] =>\n split(input)\n .map((l) => l.trim())\n .filter((line) => line !== \"\" && !isComment(line));\n\nconst parse = (input: string | ParsedGitignore, options: ParseOptions = {}): ParsedGitignore => {\n let filepath = options.path;\n\n if (isParsed(input)) return input;\n if (isValidPath(input) && fs.existsSync(input)) {\n filepath = input;\n input = fs.readFileSync(input, \"utf8\");\n }\n\n const lines = split(input);\n const names = new Map<string, Section>();\n\n let parsed: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let section: Section = { name: \"default\", patterns: [] };\n let prev: Section | null = null;\n\n for (const line of lines) {\n const value = line.trim();\n\n if (value.startsWith(\"#\")) {\n const [, name] = /^#+\\s*(.*)\\s*$/.exec(value) || [];\n\n if (prev) {\n names.delete(prev.name);\n prev.comment = prev.comment ? `${prev.comment}\\n${value}` : value;\n prev.name = name ? `${prev.name.trim()}\\n${name.trim()}` : prev.name.trim();\n names.set(prev.name.toLowerCase().trim(), prev);\n continue;\n }\n\n section = { name: name?.trim() || \"\", comment: value, patterns: [] };\n names.set(section.name.toLowerCase(), section);\n parsed.sections.push(section);\n prev = section;\n continue;\n }\n\n if (value !== \"\") {\n section.patterns.push(value);\n parsed.patterns.push(value);\n }\n\n prev = null;\n }\n\n if (options.dedupe === true || options.unique === true) {\n parsed = dedupe(parsed, { ...options, format: false });\n }\n\n parsed.path = filepath;\n parsed.input = Buffer.from(input);\n parsed.format = (opts?: ParseOptions) => format(parsed, { ...options, ...opts });\n parsed.dedupe = (opts?: ParseOptions) => dedupe(parsed, { ...options, ...opts });\n parsed.globs = (opts?: ParseOptions) => globs(parsed, { path: filepath, ...options, ...opts });\n return parsed;\n};\n\nconst parseFile = (filepath: string, options?: ParseOptions): ParsedGitignore =>\n parse(fs.readFileSync(filepath, \"utf8\"), options);\n\nconst dedupe = (input: string | ParsedGitignore, options: ParseOptions): ParsedGitignore => {\n const parsed = parse(input, { ...options, dedupe: false });\n\n const names = new Map<string, Section>();\n const res: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let current: Section;\n\n // first, combine duplicate sections\n for (const section of parsed.sections) {\n const { name = \"\", comment, patterns } = section;\n const key = name.trim().toLowerCase();\n\n for (const pattern of patterns) {\n if (!res.patterns.includes(pattern)) {\n res.patterns.push(pattern);\n }\n }\n\n if (name && names.has(key)) {\n current = names.get(key)!;\n current.patterns = [...current.patterns, ...patterns];\n } else {\n current = { name, comment, patterns };\n res.sections.push(current);\n names.set(key, current);\n }\n }\n\n // next, de-dupe patterns in each section\n for (const section of res.sections) {\n section.patterns = [...new Set(section.patterns)];\n }\n\n return res;\n};\n\nconst glob = (pattern: string): string => {\n // Return if a glob pattern has already been specified for sub-directories\n if (GLOBSTAR_REGEX.test(pattern)) {\n return pattern;\n }\n\n // If there is a separator at the beginning or middle (or both) of the pattern,\n // then the pattern is relative to the directory level of the particular .gitignore\n // file itself. Otherwise the pattern may also match at any level below the\n // .gitignore level. relative paths only\n let relative = false;\n if (pattern.startsWith(\"/\")) {\n pattern = pattern.slice(1);\n relative = true;\n } else if (pattern.slice(1, pattern.length - 1).includes(\"/\")) {\n relative = true;\n }\n\n // If there is a separator at the end of the pattern then the pattern will only match directories.\n pattern += pattern.endsWith(\"/\") ? \"**/\" : \"/**\";\n\n // If not relative, the pattern can match any files and directories.\n return relative ? pattern : `**/${pattern}`;\n};\n\nconst globs = (input: string | ParsedGitignore, options: ParseOptions = {}): GlobResult[] => {\n const parsed = parse(input, options);\n const result: GlobResult[] = [];\n let index = 0;\n\n const globPatterns = parsed.patterns\n .concat(options.ignore || [])\n .concat((options.unignore || []).map((p) => (!p.startsWith(\"!\") ? `!${p}` : p)));\n\n const push = (prefix: string, pattern: string) => {\n const prev = result[result.length - 1];\n const type = prefix ? \"unignore\" : \"ignore\";\n\n if (prev && prev.type === type) {\n if (!prev.patterns.includes(pattern)) {\n prev.patterns.push(pattern);\n }\n } else {\n result.push({ type, path: options.path || null, patterns: [pattern], index });\n index++;\n }\n };\n\n for (let pattern of globPatterns) {\n let prefix = \"\";\n\n // An optional prefix \"!\" which negates the pattern; any matching file excluded by\n // a previous pattern will become included again\n if (pattern.startsWith(\"!\")) {\n pattern = pattern.slice(1);\n prefix = \"!\";\n }\n\n // add the raw pattern to the results\n push(prefix, pattern.startsWith(\"/\") ? pattern.slice(1) : pattern);\n\n // add the glob pattern to the results\n push(prefix, glob(pattern));\n }\n\n return result;\n};\n\n/**\n * Formats a .gitignore section\n */\nconst formatSection = (section: Section = { name: \"\", patterns: [] }): string => {\n const output = [section.comment || \"\"];\n\n if (section.patterns?.length) {\n output.push(section.patterns.join(\"\\n\"));\n output.push(\"\");\n }\n\n return output.join(\"\\n\");\n};\n\n/**\n * Format a .gitignore file from the given input or object from `.parse()`.\n * @param {String | ParsedGitignore} input File path or contents.\n * @param {ParseOptions} options\n * @return {String} Returns formatted string.\n * @api public\n */\nconst format = (input: string | ParsedGitignore, options: ParseOptions = {}): string => {\n const parsed = parse(input, options);\n\n const fn = options.formatSection || formatSection;\n const sections = parsed.sections || parsed;\n const output: string[] = [];\n\n for (const section of ([] as Section[]).concat(sections)) {\n output.push(fn(section));\n }\n\n return output.join(\"\\n\");\n};\n\nexport {\n parse,\n parseFile,\n dedupe,\n format,\n globs,\n formatSection,\n patterns,\n type ParseOptions,\n type Section,\n type ParsedGitignore,\n type GlobResult,\n};\n\nexport default parse;\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n"],"mappings":";;AAAA,OAAOA,MAAU,YACjB,OAAOC,MAAQ,UACf,OAAOC,OAAY,cACnB,OAAOC,OAAQ,YCHR,IAAMC,EAAmB,cAEzB,IAAMC,GACX,QAAQ,IAAI,gCAAkC,uCAEnCC,EAAe,QAAQ,IAAI,6BAA+B,yBAC1DC,GAAkB,QAAQ,IAAI,gCAAkC,qBAChEC,EAAiC,GDF9C,OAAOC,MAAU,YACjB,OAAOC,OAAW,aAClB,OAAS,YAAAC,OAAgB,cEPzB,OACE,gBAAgBC,MAIX,OAEP,OAAOC,MAAW,QAElB,IAAMC,EAAU,GAIT,SAASC,EAAaC,EAA4BC,EAA4BC,EAAc,GAAO,CAExG,IAAMC,EAASP,EAAiBI,IAAU,QAAU,OAASA,EAAO,CAClE,OAAQ,YACR,iBAAAC,CACF,CAAC,EAED,OAAIC,GACFC,EAAO,KAAKN,EAAM,IAAI,SAAS,EAAE,KAAK,sBAAeC,CAAO;AAAA,CAAI,CAAC,EAG5D,CACL,GAAGK,EACH,QAAS,CAACC,EAAiBC,IAAyBF,EAAO,KAAKN,EAAM,MAAMO,CAAO,EAAGC,CAAO,EAC7F,MAAO,CAACD,EAAiBC,IAAyBF,EAAO,MAAMN,EAAM,IAAIO,CAAO,EAAGC,CAAO,EAC1F,KAAM,CAACD,EAAiBC,IAAyBF,EAAO,KAAKN,EAAM,OAAOO,CAAO,EAAGC,CAAO,EAC3F,SAAU,CAACD,EAAiBC,IAAyBF,EAAO,SAASN,EAAM,OAAOO,CAAO,EAAGC,CAAO,EACnG,MAAO,CAACD,EAAiBC,IAAyB,CAC5CL,IAAU,SACZG,EAAO,KA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,SAAS,EAAE,SAAS,EAAG,GAAG,EAC1DG,EAAMH,EAAI,WAAW,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EACjDI,EAAQJ,EAAI,YAAY,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EACpDK,EAAUL,EAAI,cAAc,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EACxDM,EAAUN,EAAI,cAAc,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EAC9D,MAAO,GAAGC,CAAI,GAAGC,CAAK,GAAGC,CAAG,GAAGC,CAAK,GAAGC,CAAO,GAAGC,CAAO,IAAIR,EAAS,CAAC,EACxE","names":["path","fs","crypto","fg","CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","DEFAULT_UPLOAD_MAX_CONCURRENCY","http","https","pipeline","createLoggerBase","chalk","VERSION","createLogger","level","allowClearScreen","showVersion","logger","message","options","chalk","FormData","fs","INVALID_PATH_CHARS_REGEX","GLOBSTAR_REGEX","MAX_PATH_LENGTH","isObject","v","isValidPath","input","split","str","isParsed","input","isObject","parse","input","options","filepath","isParsed","isValidPath","lines","split","names","parsed","section","prev","line","value","name","dedupe","opts","format","globs","dedupe","input","options","parsed","parse","names","res","current","section","name","comment","patterns","key","pattern","glob","GLOBSTAR_REGEX","relative","globs","result","index","globPatterns","p","push","prefix","prev","type","formatSection","output","format","fn","sections","parse_gitignore_default","parse","PQueue","ora","customAlphabet","Conf","path","crypto","fs","fileURLToPath","chalk","__dirname","fileURLToPath","key","getKey","accessStore","Conf","CLI_PROJECT_NAME","findNearestNodeModules","currentDir","__dirname","path","nodeModulesPath","fs","getKey","tmpSecureStoreDir","keyPath","key","crypto","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","toURL","path","apiBaseURL","API_BASE_URL","formatResponse","response","data","UploadError","error","error_description","filename","defaultConfig","agent","http","discoverFiles","templateDir","gitignore","path","gitignored","fs","parse_gitignore_default","fg","uploadFile","filePath","relativePath","uploadUrl","templateId","spinner","token","config","uploadWithRetry","attempt","performUpload","logger","resolve","reject","stats","fileName","startTime","form","FormData","fileStream","totalUploaded","updateProgress","chunk","options","req","https","res","responseBody","endTime","uploadStats","errorObject","parsedError","pipeline","err","reportUploadStatistics","uploadedFiles","failedFiles","chalk","failure","uploadTemplate","dryRun","fullConfig","queue","PQueue","DEFAULT_UPLOAD_MAX_CONCURRENCY","files","filesCount","signatures","uploadId","generateUploadId","completedUploads","file","md5","sha1sum","ora","uploadPromises","fullPath","url","API_BASE_URL","result","results","r","finalizeUrl","finalizeResponse","post","hash","crypto","b","randomId","customAlphabet","now","year","month","day","hours","minutes","seconds"]}
@@ -1,5 +1,5 @@
1
1
  /*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
2
2
 
3
- var O=Object.defineProperty;var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var S=(e,t)=>{for(var s in t)O(e,s,{get:t[s],enumerable:!0})};var y,M,g,$,f,m=p(()=>{"use strict";y="upstart-cli",M=process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",g=process.env.PUBLIC_UPSTART_API_BASE_URL??"https://api.upstart.gg",$=process.env.PUBLIC_UPSTART_EDITOR_BASE_URL??"https://upstart.gg",f="oauth/userinfo"});import k from"conf";import u from"node:path";import P from"node:crypto";import a from"node:fs";import{fileURLToPath as I}from"node:url";import X from"chalk";function v(){let e=U;for(;e!==u.parse(e).root;){let t=u.join(e,"node_modules");if(a.existsSync(t))return t;e=u.dirname(e)}return null}function N(){let e=v();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=u.join(e,".enpage-tmp");a.existsSync(t)||a.mkdirSync(t,{recursive:!0,mode:448});let s=u.join(t,".enpage-key");if(!a.existsSync(s)){let r=P.randomBytes(32).toString("hex");return a.writeFileSync(s,r,{mode:384}),r}return a.readFileSync(s,"utf8")}var U,w,i,l=p(()=>{"use strict";m();U=I(new URL(".",import.meta.url)),w=N(),i=new k({projectName:y,encryptionKey:w,clearInvalidConfig:!0})});var _,T=p(()=>{_="0.0.95"});import{createLogger as b}from"vite";import c from"chalk";function C(e,t,s=!1){let o=b(e==="debug"?"info":e,{prefix:"[upstart]",allowClearScreen:t});return s&&o.info(c.hex("#7270c6").bold(`\u{1F680} Upstart v${_}
4
- `)),{...o,success:(r,n)=>o.info(c.green(r),n),error:(r,n)=>o.error(c.red(r),n),warn:(r,n)=>o.warn(c.yellow(r),n),warnOnce:(r,n)=>o.warnOnce(c.yellow(r),n),debug:(r,n)=>{e==="debug"&&o.info(c.gray(r),n)}}}var d,h=p(()=>{"use strict";T();d=C()});var x={};S(x,{get:()=>j,post:()=>D});async function D(e,t,s={}){i.get("access_token")&&(s.Authorization=`Bearer ${i.get("access_token")}`);let o=await fetch(E(e),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...s},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(r=>{d.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),d.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return L(o)}async function j(e,t={}){i.get("access_token")&&(t.Authorization=`Bearer ${i.get("access_token")}`);let s=await fetch(E(e),{headers:t,method:"GET"}).catch(o=>{d.error(`Fatal Error requesting API: ${o.message} (${o.cause.code})`),d.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return L(s)}function E(e){let t=new URL(g.endsWith("/")?g:`${g}/`);return new URL(e,t)}async function L(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}var R=p(()=>{"use strict";h();m();l()});m();l();async function ce(e=!1){let t=i.get("access_token"),s=i.get("expires_at");if(!t)return!1;if(s&&s<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{get:o}=await Promise.resolve().then(()=>(R(),x)),{isSuccess:r}=await o(f);return r}export{ce as isLoggedIn};
3
+ var x=Object.defineProperty;var p=(e,r)=>()=>(e&&(r=e(e=0)),r);var O=(e,r)=>{for(var o in r)x(e,o,{get:r[o],enumerable:!0})};var y,b,f,M,l,m=p(()=>{"use strict";y="upstart-cli",b=process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",f=process.env.PUBLIC_UPSTART_API_BASE_URL??"https://api.upstart.gg",M=process.env.PUBLIC_UPSTART_EDITOR_BASE_URL??"https://upstart.gg",l="oauth/userinfo"});var d=p(()=>{"use strict"});import P from"conf";import g from"node:path";import I from"node:crypto";import i from"node:fs";import{fileURLToPath as U}from"node:url";import Q from"chalk";function A(){let e=h;for(;e!==g.parse(e).root;){let r=g.join(e,"node_modules");if(i.existsSync(r))return r;e=g.dirname(e)}return null}function N(){let e=A();if(!e)throw new Error("Could not find nearest node_modules directory.");let r=g.join(e,".enpage-tmp");i.existsSync(r)||i.mkdirSync(r,{recursive:!0,mode:448});let o=g.join(r,".enpage-key");if(!i.existsSync(o)){let t=I.randomBytes(32).toString("hex");return i.writeFileSync(o,t,{mode:384}),t}return i.readFileSync(o,"utf8")}var h,k,a,_=p(()=>{"use strict";m();d();h=U(new URL(".",import.meta.url)),k=N(),a=new P({projectName:y,encryptionKey:k,clearInvalidConfig:!0})});import{createLogger as w}from"vite";import c from"chalk";function D(e,r,o=!1){let s=w(e==="debug"?"info":e,{prefix:"[upstart]",allowClearScreen:r});return o&&s.info(c.hex("#7270c6").bold(`\u{1F680} Upstart v${C}
4
+ `)),{...s,success:(t,n)=>s.info(c.green(t),n),error:(t,n)=>s.error(c.red(t),n),warn:(t,n)=>s.warn(c.yellow(t),n),warnOnce:(t,n)=>s.warnOnce(c.yellow(t),n),debug:(t,n)=>{e==="debug"&&s.info(c.gray(t),n)}}}var C,u,T=p(()=>{"use strict";C=.1;u=D()});var R={};O(R,{get:()=>v,post:()=>B});async function B(e,r,o={}){a.get("access_token")&&(o.Authorization=`Bearer ${a.get("access_token")}`);let s=await fetch(E(e),{method:"POST",headers:{"Content-Type":r instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...o},body:r instanceof URLSearchParams?r:JSON.stringify(r)}).catch(t=>{u.error(`Fatal Error requesting API: ${t.message} (${t.cause.code})`),u.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return L(s)}async function v(e,r={}){a.get("access_token")&&(r.Authorization=`Bearer ${a.get("access_token")}`);let o=await fetch(E(e),{headers:r,method:"GET"}).catch(s=>{u.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),u.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return L(o)}function E(e){let r=new URL(f.endsWith("/")?f:`${f}/`);return new URL(e,r)}async function L(e){let r=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:r}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:r}}var S=p(()=>{"use strict";T();m();_()});m();_();async function ce(e=!1){let r=a.get("access_token"),o=a.get("expires_at");if(!r)return!1;if(o&&o<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{get:s}=await Promise.resolve().then(()=>(S(),R)),{isSuccess:t}=await s(l);return t}export{ce as isLoggedIn};
5
5
  //# sourceMappingURL=is-logged-in.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/node/cli/constants.ts","../../../src/node/cli/store.ts","../../../package.json","../../../src/node/shared/logger.ts","../../../src/node/cli/api.ts","../../../src/node/cli/is-logged-in.ts"],"sourcesContent":["export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","{\n \"name\": \"@upstart.gg/sdk\",\n \"version\": \"0.0.95\",\n \"type\": \"module\",\n \"files\": [\n \"dist\",\n \"env.d.ts\"\n ],\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": \"./dist/shared/index.js\",\n \"types\": \"./dist/shared/index.d.ts\"\n },\n \"./shared/*\": {\n \"types\": \"./dist/shared/*.d.ts\",\n \"import\": \"./dist/shared/*.js\"\n },\n \"./builder/*\": {\n \"import\": \"./dist/node/builder/*.js\"\n },\n \"./cli/*\": {\n \"import\": \"./dist/node/cli/*.js\"\n },\n \"./env.d.ts\": {\n \"types\": \"./env.d.ts\",\n \"require\": \"./env.d.ts\",\n \"import\": \"./env.d.ts\"\n },\n \"./*\": {\n \"types\": \"./dist/shared/*.d.ts\",\n \"import\": \"./dist/shared/*.js\"\n }\n },\n \"dependencies\": {\n \"@date-fns/utc\": \"1.2.0\",\n \"@headlessui/react\": \"2.2.1\",\n \"@inquirer/prompts\": \"5.3.8\",\n \"@radix-ui/react-context-menu\": \"2.2.2\",\n \"@radix-ui/react-toggle-group\": \"1.1.0\",\n \"@radix-ui/themes\": \"3.1.4\",\n \"@sinclair/typebox\": \"0.33.7\",\n \"@upstart.gg/style-system\": \"workspace:*\",\n \"ajv\": \"8.17.1\",\n \"ajv-formats\": \"3.0.1\",\n \"chalk\": \"5.3.0\",\n \"chroma-js\": \"3.1.2\",\n \"commander\": \"12.1.0\",\n \"conf\": \"13.0.1\",\n \"date-fns\": \"3.6.0\",\n \"debug\": \"4.3.6\",\n \"fast-glob\": \"3.3.2\",\n \"form-data\": \"4.0.0\",\n \"get-port\": \"7.1.0\",\n \"htmlparser2\": \"9.1.0\",\n \"http-errors-enhanced\": \"2.0.8\",\n \"immer\": \"10.1.1\",\n \"import-meta-resolve\": \"4.1.0\",\n \"lodash-es\": \"4.17.21\",\n \"nanoid\": \"5.0.7\",\n \"open\": \"10.1.0\",\n \"ora\": \"8.1.0\",\n \"p-queue\": \"8.0.1\",\n \"react-hotkeys-hook\": \"4.5.1\",\n \"react-icons\": \"5.3.0\",\n \"react-selecto\": \"1.26.3\",\n \"rollup-plugin-strip-banner\": \"3.1.0\",\n \"usehooks-ts\": \"3.1.0\",\n \"zundo\": \"2.3.0\",\n \"zustand\": \"4.5.5\"\n },\n \"peerDependencies\": {\n \"@upstart.gg/style-system\": \"workspace:*\",\n \"react\": \"18.3.0-canary-3d9b20132-20240124\",\n \"react-dom\": \"18.3.0-canary-3d9b20132-20240124\"\n },\n \"devDependencies\": {\n \"@cloudflare/workers-types\": \"4.20240806.0\",\n \"@types/chroma-js\": \"2.4.4\",\n \"@types/cli-progress\": \"3.11.6\",\n \"@types/debug\": \"4.1.12\",\n \"@types/express\": \"^4.17.21\",\n \"@types/lodash-es\": \"4.17.12\",\n \"@types/node\": \"^20.14.10\",\n \"@types/react\": \"18.3.3\",\n \"@types/react-dom\": \"^18.3.0\",\n \"@types/sortablejs\": \"1.15.8\",\n \"@vitejs/plugin-react\": \"^4.3.4\",\n \"concurrently\": \"8.2.2\",\n \"express\": \"^4.21.2\",\n \"rimraf\": \"6.0.1\",\n \"tsup\": \"8.2.4\",\n \"vite\": \"5.4.6\",\n \"vite-plugin-dts\": \"4.2.1\",\n \"vite-plugin-image-optimizer\": \"1.1.8\",\n \"vite-plugin-inspect\": \"0.8.7\",\n \"vite-plugin-virtual\": \"0.3.0\",\n \"vite-tsconfig-paths\": \"5.0.1\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"build:types\": \"tsc --emitDeclarationOnly --declaration --declarationMap\",\n \"dev\": \"NODE_OPTIONS='--max-old-space-size=12384' tsup --watch\",\n \"sizetest\": \"pnpm build && du -sh dist\",\n \"lint\": \"biome check --write . && tsc --noEmit\",\n \"ci:lint\": \"tsc --noEmit\",\n \"test\": \"vitest\",\n \"gen-ia-docs\": \"tsx scripts/generate-ia-docs.ts\"\n },\n \"author\": \"Matthias Etienne\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\nimport { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${version}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n","import { OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport { accessStore } from \"./store\";\n\nexport async function isLoggedIn(checkRemote = false): Promise<boolean> {\n const token = accessStore.get(\"access_token\");\n const expiration = accessStore.get(\"expires_at\");\n\n if (!token) {\n return false;\n }\n\n if (expiration && expiration < Date.now()) {\n console.log(\"Seems like your token expired...\");\n return false;\n }\n\n if (!checkRemote) {\n return true;\n }\n\n // Check if token is valid\n\n // import dynamically \"./api\" to avoid circular dependency\n const { get } = await import(\"./api\");\n const { isSuccess } = await get(OAUTH_ENDPOINT_USER_INFO);\n\n return isSuccess;\n}\n"],"mappings":";;6HAAA,IAAaA,EAEAC,EAGAC,EACAC,EAKAC,EAXbC,EAAAC,EAAA,kBAAaN,EAAmB,cAEnBC,EACX,QAAQ,IAAI,gCAAkC,uCAEnCC,EAAe,QAAQ,IAAI,6BAA+B,yBAC1DC,EAAkB,QAAQ,IAAI,gCAAkC,qBAKhEC,EAA2B,mBCTxC,OAAOG,MAAU,OACjB,OAAOC,MAAU,YACjB,OAAOC,MAAY,cACnB,OAAOC,MAAQ,UACf,OAAS,iBAAAC,MAAqB,WAE9B,OAAOC,MAAW,QAwBlB,SAASC,GAAwC,CAC/C,IAAIC,EAAaC,EACjB,KAAOD,IAAeN,EAAK,MAAMM,CAAU,EAAE,MAAM,CACjD,IAAME,EAAkBR,EAAK,KAAKM,EAAY,cAAc,EAC5D,GAAIJ,EAAG,WAAWM,CAAe,EAC/B,OAAOA,EAETF,EAAaN,EAAK,QAAQM,CAAU,CACtC,CACA,OAAO,IACT,CAEA,SAASG,GAAS,CAChB,IAAMD,EAAkBH,EAAuB,EAC/C,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,gDAAgD,EAElE,IAAME,EAAoBV,EAAK,KAAKQ,EAAiB,aAAa,EAC7DN,EAAG,WAAWQ,CAAi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AAIA,EAAe,GAAGA,CAAY,GAAG,EACzF,OAAO,IAAI,IAAIV,EAAMS,CAAU,CACjC,CAEA,eAAeD,EACbJ,EACkD,CAClD,IAAMH,EAAOG,EAAS,QAAQ,IAAI,cAAc,GAAG,WAAW,kBAAkB,EAC1E,MAAMA,EAAS,KAAK,EACpB,MAAMA,EAAS,KAAK,EAE1B,OAAIA,EAAS,GACJ,CACL,UAAW,GACX,QAAS,GACT,OAAQA,EAAS,OACjB,WAAYA,EAAS,WACrB,KAAMH,CACR,EAEO,CACL,UAAW,GACX,QAAS,GACT,OAAQG,EAAS,OACjB,WAAYA,EAAS,WACrB,KAAMH,CACR,CAEJ,CApGA,IAAAU,EAAAC,EAAA,kBAAAC,IACAC,IACAC,MCFAC,IACAC,IAEA,eAAsBC,GAAWC,EAAc,GAAyB,CACtE,IAAMC,EAAQC,EAAY,IAAI,cAAc,EACtCC,EAAaD,EAAY,IAAI,YAAY,EAE/C,GAAI,CAACD,EACH,MAAO,GAGT,GAAIE,GAAcA,EAAa,KAAK,IAAI,EACtC,eAAQ,IAAI,kCAAkC,EACvC,GAGT,GAAI,CAACH,EACH,MAAO,GAMT,GAAM,CAAE,IAAAI,CAAI,EAAI,KAAM,qCAChB,CAAE,UAAAC,CAAU,EAAI,MAAMD,EAAIE,CAAwB,EAExD,OAAOD,CACT","names":["CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","OAUTH_ENDPOINT_USER_INFO","init_constants","__esmMin","Conf","path","crypto","fs","fileURLToPath","chalk","findNearestNodeModules","currentDir","__dirname","nodeModulesPath","getKey","tmpSecureStoreDir","keyPath","key","accessStore","init_store","__esmMin","init_constants","CLI_PROJECT_NAME","version","init_package","__esmMin","createLoggerBase","chalk","createLogger","level","allowClearScreen","showVersion","logger","version","message","options","init_logger","__esmMin","init_package","api_exports","__export","get","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","apiBaseURL","API_BASE_URL","init_api","__esmMin","init_logger","init_constants","init_store","init_constants","init_store","isLoggedIn","checkRemote","token","accessStore","expiration","get","isSuccess","OAUTH_ENDPOINT_USER_INFO"]}
1
+ {"version":3,"sources":["../../../src/node/cli/constants.ts","../../../src/node/cli/utils.ts","../../../src/node/cli/store.ts","../../../src/node/shared/logger.ts","../../../src/node/cli/api.ts","../../../src/node/cli/is-logged-in.ts"],"sourcesContent":["export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","export function getPackageManager() {\n // Detect package manager\n let packageManager: string | undefined;\n if (process.env.npm_config_user_agent) {\n const pmPart = process.env.npm_config_user_agent.split(\" \")[0];\n packageManager = pmPart.slice(0, pmPart.lastIndexOf(\"/\"));\n }\n\n // Display message\n if (!packageManager) {\n console.log(\"Warning: could not detect package manager\");\n packageManager = \"npm\";\n }\n\n return packageManager;\n}\n\nexport function formatAPIError(error: { error: string; error_description?: string }) {\n return `[${error.error}]${error.error_description ? `: ${error.error_description}` : \"\"}`;\n}\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\n// import { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\nconst VERSION = 0.1;\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${VERSION}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n","import { OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport { accessStore } from \"./store\";\n\nexport async function isLoggedIn(checkRemote = false): Promise<boolean> {\n const token = accessStore.get(\"access_token\");\n const expiration = accessStore.get(\"expires_at\");\n\n if (!token) {\n return false;\n }\n\n if (expiration && expiration < Date.now()) {\n console.log(\"Seems like your token expired...\");\n return false;\n }\n\n if (!checkRemote) {\n return true;\n }\n\n // Check if token is valid\n\n // import dynamically \"./api\" to avoid circular dependency\n const { get } = await import(\"./api\");\n const { isSuccess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,IAAAU,EAAAC,EAAA,kBAAAC,IACAC,IACAC,MCFAC,IACAC,IAEA,eAAsBC,GAAWC,EAAc,GAAyB,CACtE,IAAMC,EAAQC,EAAY,IAAI,cAAc,EACtCC,EAAaD,EAAY,IAAI,YAAY,EAE/C,GAAI,CAACD,EACH,MAAO,GAGT,GAAIE,GAAcA,EAAa,KAAK,IAAI,EACtC,eAAQ,IAAI,kCAAkC,EACvC,GAGT,GAAI,CAACH,EACH,MAAO,GAMT,GAAM,CAAE,IAAAI,CAAI,EAAI,KAAM,qCAChB,CAAE,UAAAC,CAAU,EAAI,MAAMD,EAAIE,CAAwB,EAExD,OAAOD,CACT","names":["CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","OAUTH_ENDPOINT_USER_INFO","init_constants","__esmMin","init_utils","__esmMin","Conf","path","crypto","fs","fileURLToPath","chalk","findNearestNodeModules","currentDir","__dirname","nodeModulesPath","getKey","tmpSecureStoreDir","keyPath","key","accessStore","init_store","__esmMin","init_constants","init_utils","CLI_PROJECT_NAME","createLoggerBase","chalk","createLogger","level","allowClearScreen","showVersion","logger","VERSION","message","options","init_logger","__esmMin","api_exports","__export","get","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","apiBaseURL","API_BASE_URL","init_api","__esmMin","init_logger","init_constants","init_store","init_constants","init_store","isLoggedIn","checkRemote","token","accessStore","expiration","get","isSuccess","OAUTH_ENDPOINT_USER_INFO"]}