shoplazza-cli 1.1.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +206 -332
  4. package/README.zh.md +318 -0
  5. package/package.json +24 -70
  6. package/scripts/install.js +144 -0
  7. package/scripts/jsbuild/dev/index.js +123 -0
  8. package/scripts/jsbuild/index.js +77 -0
  9. package/{lib/checkout/build → scripts/jsbuild}/plugin/vite-plugin-add-extension-id.js +4 -2
  10. package/scripts/jsbuild/vite.config.js +35 -0
  11. package/scripts/run.js +29 -0
  12. package/.editorconfig +0 -28
  13. package/.prettierrc +0 -9
  14. package/bin/shoplazza +0 -137
  15. package/fixtures/assets/blog.scss +0 -74
  16. package/fixtures/assets/cart_modal.scss +0 -450
  17. package/fixtures/assets/collection_detail.js +0 -234
  18. package/fixtures/assets/collection_detail.scss +0 -345
  19. package/fixtures/assets/collection_list.scss +0 -11
  20. package/fixtures/assets/collection_slider.scss +0 -169
  21. package/fixtures/assets/feature_columns.scss +0 -26
  22. package/fixtures/assets/feature_product.scss +0 -109
  23. package/fixtures/assets/footer.js +0 -58
  24. package/fixtures/assets/footer.scss +0 -337
  25. package/fixtures/assets/four_images.scss +0 -29
  26. package/fixtures/assets/gallery.scss +0 -55
  27. package/fixtures/assets/header.js +0 -178
  28. package/fixtures/assets/header.scss +0 -929
  29. package/fixtures/assets/image_text.scss +0 -72
  30. package/fixtures/assets/logo_bar.scss +0 -11
  31. package/fixtures/assets/newsletter.scss +0 -90
  32. package/fixtures/assets/not_found.scss +0 -39
  33. package/fixtures/assets/page_detail.scss +0 -16
  34. package/fixtures/assets/pagination.scss +0 -150
  35. package/fixtures/assets/postcss.config.js +0 -6
  36. package/fixtures/assets/product_description.scss +0 -88
  37. package/fixtures/assets/product_detail.js +0 -634
  38. package/fixtures/assets/product_detail.scss +0 -1106
  39. package/fixtures/assets/relative_product.scss +0 -45
  40. package/fixtures/assets/reviews.scss +0 -70
  41. package/fixtures/assets/rich_text.scss +0 -71
  42. package/fixtures/assets/search.js +0 -87
  43. package/fixtures/assets/search.scss +0 -67
  44. package/fixtures/assets/slide.scss +0 -51
  45. package/fixtures/assets/slider.scss +0 -141
  46. package/fixtures/assets/test.scss +0 -1
  47. package/fixtures/assets/theme.css +0 -976
  48. package/fixtures/assets/theme.scss +0 -1100
  49. package/fixtures/assets/three_images.scss +0 -20
  50. package/fixtures/assets/tools.scss +0 -23
  51. package/fixtures/assets/two_images.scss +0 -24
  52. package/fixtures/assets/video.scss +0 -45
  53. package/fixtures/assets/video_text.scss +0 -63
  54. package/fixtures/config/settings_data.json +0 -107
  55. package/fixtures/config/settings_schema.json +0 -690
  56. package/fixtures/layout/theme.liquid +0 -76
  57. package/fixtures/locales/ar-SA.json +0 -212
  58. package/fixtures/locales/de-DE.json +0 -290
  59. package/fixtures/locales/en-US.json +0 -290
  60. package/fixtures/locales/es-ES.json +0 -290
  61. package/fixtures/locales/fr-FR.json +0 -290
  62. package/fixtures/locales/id-ID.json +0 -212
  63. package/fixtures/locales/it-IT.json +0 -212
  64. package/fixtures/locales/ja-JP.json +0 -289
  65. package/fixtures/locales/ko-KR.json +0 -290
  66. package/fixtures/locales/nl-NL.json +0 -290
  67. package/fixtures/locales/pl-PL.json +0 -290
  68. package/fixtures/locales/pt-PT.json +0 -212
  69. package/fixtures/locales/ru-RU.json +0 -212
  70. package/fixtures/locales/th-TH.json +0 -212
  71. package/fixtures/locales/zh-CN.json +0 -290
  72. package/fixtures/locales/zh-TW.json +0 -290
  73. package/fixtures/sections/apps.liquid +0 -47
  74. package/fixtures/sections/blog.liquid +0 -137
  75. package/fixtures/sections/collection_desc.liquid +0 -34
  76. package/fixtures/sections/collection_detail.liquid +0 -436
  77. package/fixtures/sections/collection_image.liquid +0 -104
  78. package/fixtures/sections/collection_list.liquid +0 -161
  79. package/fixtures/sections/collection_name.liquid +0 -34
  80. package/fixtures/sections/collection_slider.liquid +0 -330
  81. package/fixtures/sections/feature_columns.liquid +0 -275
  82. package/fixtures/sections/feature_product.liquid +0 -227
  83. package/fixtures/sections/footer.liquid +0 -488
  84. package/fixtures/sections/four_images.liquid +0 -160
  85. package/fixtures/sections/gallery.liquid +0 -258
  86. package/fixtures/sections/header.liquid +0 -1157
  87. package/fixtures/sections/html.liquid +0 -40
  88. package/fixtures/sections/image_text.liquid +0 -350
  89. package/fixtures/sections/instagram_plus.liquid +0 -393
  90. package/fixtures/sections/logo_bar.liquid +0 -183
  91. package/fixtures/sections/newsletter.liquid +0 -225
  92. package/fixtures/sections/not_found.liquid +0 -39
  93. package/fixtures/sections/overlay_image.liquid +0 -648
  94. package/fixtures/sections/page_detail.liquid +0 -39
  95. package/fixtures/sections/photo_collection.liquid +0 -433
  96. package/fixtures/sections/product_description.liquid +0 -208
  97. package/fixtures/sections/product_detail.liquid +0 -611
  98. package/fixtures/sections/products.liquid +0 -216
  99. package/fixtures/sections/relative_product.liquid +0 -121
  100. package/fixtures/sections/reviews.liquid +0 -115
  101. package/fixtures/sections/rich_text.liquid +0 -157
  102. package/fixtures/sections/search.liquid +0 -163
  103. package/fixtures/sections/slide.liquid +0 -719
  104. package/fixtures/sections/three_images.liquid +0 -157
  105. package/fixtures/sections/two_images.liquid +0 -125
  106. package/fixtures/sections/video.liquid +0 -95
  107. package/fixtures/sections/video_text.liquid +0 -128
  108. package/fixtures/snippets/bgset.liquid +0 -21
  109. package/fixtures/snippets/card_title.liquid +0 -8
  110. package/fixtures/snippets/cart_modal.liquid +0 -74
  111. package/fixtures/snippets/collection.liquid +0 -77
  112. package/fixtures/snippets/collection_filter_modal.liquid +0 -56
  113. package/fixtures/snippets/default_image_4.liquid +0 -14
  114. package/fixtures/snippets/default_image_6.liquid +0 -18
  115. package/fixtures/snippets/default_image_8.liquid +0 -23
  116. package/fixtures/snippets/four_images_item.liquid +0 -8
  117. package/fixtures/snippets/header_ads.liquid +0 -95
  118. package/fixtures/snippets/hero_image.liquid +0 -94
  119. package/fixtures/snippets/icon_video_play_large.liquid +0 -1
  120. package/fixtures/snippets/icon_video_play_medium.liquid +0 -4
  121. package/fixtures/snippets/icon_video_play_small.liquid +0 -4
  122. package/fixtures/snippets/lazyimg.liquid +0 -22
  123. package/fixtures/snippets/lazyimg_art.liquid +0 -36
  124. package/fixtures/snippets/lazysizes.liquid +0 -41
  125. package/fixtures/snippets/link.liquid +0 -2
  126. package/fixtures/snippets/pagination.liquid +0 -48
  127. package/fixtures/snippets/product.liquid +0 -126
  128. package/fixtures/snippets/product_art_tpl.liquid +0 -152
  129. package/fixtures/snippets/product_info_body.liquid +0 -337
  130. package/fixtures/snippets/product_info_tpl.liquid +0 -423
  131. package/fixtures/snippets/product_label.liquid +0 -46
  132. package/fixtures/snippets/settings.liquid +0 -295
  133. package/fixtures/snippets/social-meta-tags.liquid +0 -106
  134. package/fixtures/snippets/video_html.liquid +0 -11
  135. package/fixtures/snippets/video_source.liquid +0 -98
  136. package/fixtures/snippets/video_thumb_icon.liquid +0 -2
  137. package/fixtures/templates/404.liquid +0 -1
  138. package/fixtures/templates/collection.liquid +0 -92
  139. package/fixtures/templates/index.liquid +0 -206
  140. package/fixtures/templates/page.liquid +0 -1
  141. package/fixtures/templates/product.liquid +0 -99
  142. package/fixtures/templates/search.liquid +0 -1
  143. package/jest.config.js +0 -192
  144. package/lib/__tests__/log.test.js +0 -15
  145. package/lib/__tests__/utils.test.js +0 -69
  146. package/lib/app/api/cli.js +0 -225
  147. package/lib/app/api/openapi.js +0 -121
  148. package/lib/app/api/partnerOpenapi.js +0 -104
  149. package/lib/app/bin/index.js +0 -20
  150. package/lib/app/bin/javy/javy-arm-linux-v5.0.1 +0 -0
  151. package/lib/app/bin/javy/javy-arm-macos-v5.0.1 +0 -0
  152. package/lib/app/bin/javy/javy-x86_64-linux-v5.0.1 +0 -0
  153. package/lib/app/bin/javy/javy-x86_64-macos-v5.0.1 +0 -0
  154. package/lib/app/bin/javy/javy-x86_64-windows-v5.0.1 +0 -0
  155. package/lib/app/commands/config/actions/link.js +0 -189
  156. package/lib/app/commands/config/actions/use.js +0 -40
  157. package/lib/app/commands/config/index.js +0 -25
  158. package/lib/app/commands/config/link.js +0 -11
  159. package/lib/app/commands/config/use.js +0 -11
  160. package/lib/app/commands/deploy/actions/deploy.js +0 -196
  161. package/lib/app/commands/deploy/index.js +0 -11
  162. package/lib/app/commands/dev/actions/dev.js +0 -206
  163. package/lib/app/commands/dev/index.js +0 -11
  164. package/lib/app/commands/generate/actions/extension.js +0 -97
  165. package/lib/app/commands/generate/actions/generateCheckout.js +0 -58
  166. package/lib/app/commands/generate/actions/generateFunction.js +0 -56
  167. package/lib/app/commands/generate/actions/generateTheme.js +0 -128
  168. package/lib/app/commands/generate/extension.js +0 -11
  169. package/lib/app/commands/generate/index.js +0 -22
  170. package/lib/app/commands/index.js +0 -82
  171. package/lib/app/commands/info/actions/info.js +0 -168
  172. package/lib/app/commands/info/index.js +0 -11
  173. package/lib/app/commands/init/actions/init.js +0 -176
  174. package/lib/app/commands/init/index.js +0 -14
  175. package/lib/app/commands/versions/actions/list.js +0 -210
  176. package/lib/app/commands/versions/index.js +0 -22
  177. package/lib/app/commands/versions/list.js +0 -14
  178. package/lib/app/constant/code.js +0 -7
  179. package/lib/app/constant/color.js +0 -18
  180. package/lib/app/constant/extension.js +0 -16
  181. package/lib/app/constant/host.js +0 -23
  182. package/lib/app/constant/sso.js +0 -7
  183. package/lib/app/index.js +0 -8
  184. package/lib/app/services/auth/config.js +0 -33
  185. package/lib/app/services/auth/index.js +0 -9
  186. package/lib/app/services/auth/oauth-server.js +0 -70
  187. package/lib/app/services/auth/partner-token.js +0 -45
  188. package/lib/app/services/auth/sso-token.js +0 -69
  189. package/lib/app/services/auth/store-token.js +0 -100
  190. package/lib/app/services/auth/url-builder.js +0 -23
  191. package/lib/app/services/config/index.js +0 -41
  192. package/lib/app/services/devServer/app.js +0 -76
  193. package/lib/app/services/devServer/index.js +0 -103
  194. package/lib/app/services/devServer/middleware/hmacValidatorMiddleWare.js +0 -20
  195. package/lib/app/services/devServer/middleware/index.js +0 -5
  196. package/lib/app/services/devServer/tunnel/index.js +0 -43
  197. package/lib/app/services/devServer/tunnel/providers/cloudflare.js +0 -364
  198. package/lib/app/services/devServer/tunnel/providers/ngrok.js +0 -70
  199. package/lib/app/services/devServer/utils/index.js +0 -5
  200. package/lib/app/services/devServer/utils/secureCompare.js +0 -5
  201. package/lib/app/services/devServer/views/app.ejs +0 -133
  202. package/lib/app/services/extension-build/buildCheckout.js +0 -47
  203. package/lib/app/services/extension-build/buildFunction.js +0 -57
  204. package/lib/app/services/extension-build/buildTheme.js +0 -100
  205. package/lib/app/services/extension-build/index.js +0 -23
  206. package/lib/app/services/extension-build/plugins/vite-plugin-add-extension-id.js +0 -26
  207. package/lib/app/services/extension-diff/index.js +0 -132
  208. package/lib/app/services/extension-upsert/index.js +0 -21
  209. package/lib/app/services/extension-upsert/upsertCheckout.js +0 -44
  210. package/lib/app/services/extension-upsert/upsertFunction.js +0 -52
  211. package/lib/app/services/extension-upsert/upsertTheme.js +0 -113
  212. package/lib/app/services/oss/index.js +0 -45
  213. package/lib/app/services/partner/index.js +0 -52
  214. package/lib/app/store/base-store.js +0 -37
  215. package/lib/app/store/config-store.js +0 -55
  216. package/lib/app/store/config.js +0 -21
  217. package/lib/app/store/index.js +0 -14
  218. package/lib/app/store/install-store.js +0 -41
  219. package/lib/app/store/sso-store.js +0 -55
  220. package/lib/app/utils/asyncPool.js +0 -42
  221. package/lib/app/utils/debug/index.js +0 -16
  222. package/lib/app/utils/env.js +0 -24
  223. package/lib/app/utils/error.js +0 -20
  224. package/lib/app/utils/git.js +0 -20
  225. package/lib/app/utils/json.js +0 -27
  226. package/lib/app/utils/path.js +0 -33
  227. package/lib/app/utils/platform.js +0 -37
  228. package/lib/app/utils/request/cli.js +0 -72
  229. package/lib/app/utils/request/debug.js +0 -13
  230. package/lib/app/utils/request/openapi.js +0 -67
  231. package/lib/app/utils/request/partnerOpenapi.js +0 -47
  232. package/lib/app/utils/toml.js +0 -56
  233. package/lib/app/utils/views/message.js +0 -68
  234. package/lib/app/utils/views/select.js +0 -36
  235. package/lib/app/utils/withTempDir.js +0 -55
  236. package/lib/auth/__mocks__/getCode.js +0 -7
  237. package/lib/auth/__mocks__/index.js +0 -0
  238. package/lib/auth/child.js +0 -23
  239. package/lib/auth/getCode.js +0 -39
  240. package/lib/auth/index.js +0 -134
  241. package/lib/check.js +0 -28
  242. package/lib/checkout/api.js +0 -164
  243. package/lib/checkout/build/plugin/vite-plugin-transform-extension-html.js +0 -207
  244. package/lib/checkout/build/vite.config.js +0 -34
  245. package/lib/checkout/build.js +0 -38
  246. package/lib/checkout/config.js +0 -97
  247. package/lib/checkout/create.js +0 -132
  248. package/lib/checkout/delete.js +0 -26
  249. package/lib/checkout/deploy.js +0 -59
  250. package/lib/checkout/dev/index.js +0 -143
  251. package/lib/checkout/fields.js +0 -29
  252. package/lib/checkout/index.js +0 -63
  253. package/lib/checkout/preview.js +0 -52
  254. package/lib/checkout/pull.js +0 -22
  255. package/lib/checkout/push.js +0 -141
  256. package/lib/checkout/template/README.md +0 -34
  257. package/lib/checkout/template/_gitignore +0 -4
  258. package/lib/checkout/template/extension.config.js +0 -4
  259. package/lib/checkout/template/extensions/extension-template/extension.json +0 -10
  260. package/lib/checkout/template/extensions/extension-template/src/content.html +0 -3
  261. package/lib/checkout/template/extensions/extension-template/src/index.html +0 -5
  262. package/lib/checkout/template/extensions/extension-template/src/index.js +0 -11
  263. package/lib/checkout/template/extensions/extension-template/src/script.html +0 -3
  264. package/lib/checkout/template/extensions/extension-template/src/style.html +0 -3
  265. package/lib/checkout/template/package.json +0 -17
  266. package/lib/checkout/undeploy.js +0 -40
  267. package/lib/checkout/util.js +0 -201
  268. package/lib/checkout/verify.js +0 -16
  269. package/lib/checkout/version.js +0 -7
  270. package/lib/commands/__tests__/login.test.js +0 -77
  271. package/lib/commands/__tests__/logout.test.js +0 -29
  272. package/lib/commands/__tests__/store.test.js +0 -44
  273. package/lib/commands/__tests__/switch.test.js +0 -45
  274. package/lib/commands/login.js +0 -120
  275. package/lib/commands/logout.js +0 -23
  276. package/lib/commands/store.js +0 -14
  277. package/lib/commands/switch.js +0 -52
  278. package/lib/commands/theme/__tests__/delete.test.js +0 -49
  279. package/lib/commands/theme/__tests__/init.test.js +0 -21
  280. package/lib/commands/theme/__tests__/list.test.js +0 -80
  281. package/lib/commands/theme/__tests__/package.test.js +0 -17
  282. package/lib/commands/theme/__tests__/publish.test.js +0 -61
  283. package/lib/commands/theme/__tests__/pull.test.js +0 -69
  284. package/lib/commands/theme/__tests__/push.test.js +0 -63
  285. package/lib/commands/theme/__tests__/serve.test.js +0 -107
  286. package/lib/commands/theme/delete.js +0 -64
  287. package/lib/commands/theme/init.js +0 -51
  288. package/lib/commands/theme/list.js +0 -28
  289. package/lib/commands/theme/package.js +0 -37
  290. package/lib/commands/theme/publish.js +0 -56
  291. package/lib/commands/theme/pull.js +0 -62
  292. package/lib/commands/theme/push.js +0 -106
  293. package/lib/commands/theme/serve.js +0 -153
  294. package/lib/commands/theme/share.js +0 -20
  295. package/lib/commands/version.js +0 -6
  296. package/lib/common/constants.js +0 -24
  297. package/lib/common/db/partner.js +0 -91
  298. package/lib/common/inquirers/choose-app.js +0 -79
  299. package/lib/common/inquirers/choose-partner.js +0 -74
  300. package/lib/common/log.js +0 -15
  301. package/lib/common/login.js +0 -125
  302. package/lib/common/logout.js +0 -16
  303. package/lib/db/__mocks__/index.js +0 -9
  304. package/lib/db/__tests__/analytics.test.js +0 -19
  305. package/lib/db/__tests__/user.test.js +0 -20
  306. package/lib/db/analytics.js +0 -48
  307. package/lib/db/index.js +0 -9
  308. package/lib/db/user.js +0 -71
  309. package/lib/function/bin/index.js +0 -20
  310. package/lib/function/bin/javy/javy-arm-linux-v5.0.1 +0 -0
  311. package/lib/function/bin/javy/javy-arm-macos-v5.0.1 +0 -0
  312. package/lib/function/bin/javy/javy-x86_64-linux-v5.0.1 +0 -0
  313. package/lib/function/bin/javy/javy-x86_64-macos-v5.0.1 +0 -0
  314. package/lib/function/bin/javy/javy-x86_64-windows-v5.0.1 +0 -0
  315. package/lib/function/commands/compile.js +0 -43
  316. package/lib/function/commands/create.js +0 -77
  317. package/lib/function/commands/list.js +0 -18
  318. package/lib/function/commands/release.js +0 -69
  319. package/lib/function/index.js +0 -24
  320. package/lib/function/template/js/README.md +0 -37
  321. package/lib/function/template/js/_gitignore +0 -4
  322. package/lib/function/template/js/extension.config.json +0 -5
  323. package/lib/function/template/js/package.json +0 -17
  324. package/lib/function/template/js/src/index.js +0 -64
  325. package/lib/function/utils.js +0 -29
  326. package/lib/log.js +0 -13
  327. package/lib/openAPI/__mocks__/index.js +0 -20
  328. package/lib/openAPI/api.js +0 -76
  329. package/lib/openAPI/index.js +0 -56
  330. package/lib/oss.js +0 -102
  331. package/lib/partner-api/axios.js +0 -67
  332. package/lib/partner-api/index.js +0 -79
  333. package/lib/report.js +0 -37
  334. package/lib/theme-extension/api/index.js +0 -96
  335. package/lib/theme-extension/commands/build.js +0 -114
  336. package/lib/theme-extension/commands/connect.js +0 -73
  337. package/lib/theme-extension/commands/create.js +0 -105
  338. package/lib/theme-extension/commands/deploy.js +0 -56
  339. package/lib/theme-extension/commands/list.js +0 -35
  340. package/lib/theme-extension/commands/release.js +0 -59
  341. package/lib/theme-extension/commands/serve.js +0 -179
  342. package/lib/theme-extension/commands/versions.js +0 -55
  343. package/lib/theme-extension/index.js +0 -29
  344. package/lib/theme-extension/template/basic-app/README.md +0 -125
  345. package/lib/theme-extension/template/basic-app/extension.config.json +0 -4
  346. package/lib/theme-extension/template/basic-app/package.json +0 -18
  347. package/lib/theme-extension/template/basic-app/theme-app/assets/index.css +0 -4
  348. package/lib/theme-extension/template/basic-app/theme-app/assets-manifest.json +0 -1
  349. package/lib/theme-extension/template/basic-app/theme-app/blocks/index.liquid +0 -16
  350. package/lib/theme-extension/template/basic-app/theme-app/locales/ar-SA.json +0 -1
  351. package/lib/theme-extension/template/basic-app/theme-app/locales/de-DE.json +0 -1
  352. package/lib/theme-extension/template/basic-app/theme-app/locales/en-US.json +0 -6
  353. package/lib/theme-extension/template/basic-app/theme-app/locales/es-ES.json +0 -1
  354. package/lib/theme-extension/template/basic-app/theme-app/locales/fr-FR.json +0 -1
  355. package/lib/theme-extension/template/basic-app/theme-app/locales/id-ID.json +0 -1
  356. package/lib/theme-extension/template/basic-app/theme-app/locales/it-IT.json +0 -1
  357. package/lib/theme-extension/template/basic-app/theme-app/locales/ja-JP.json +0 -1
  358. package/lib/theme-extension/template/basic-app/theme-app/locales/ko-KR.json +0 -1
  359. package/lib/theme-extension/template/basic-app/theme-app/locales/nl-NL.json +0 -1
  360. package/lib/theme-extension/template/basic-app/theme-app/locales/pl-PL.json +0 -1
  361. package/lib/theme-extension/template/basic-app/theme-app/locales/pt-PT.json +0 -1
  362. package/lib/theme-extension/template/basic-app/theme-app/locales/ru-RU.json +0 -1
  363. package/lib/theme-extension/template/basic-app/theme-app/locales/th-TH.json +0 -1
  364. package/lib/theme-extension/template/basic-app/theme-app/locales/zh-CN.json +0 -6
  365. package/lib/theme-extension/template/basic-app/theme-app/locales/zh-TW.json +0 -1
  366. package/lib/theme-extension/template/basic-app/theme-app/snippets/index.liquid +0 -8
  367. package/lib/theme-extension/template/embed-app/README.md +0 -125
  368. package/lib/theme-extension/template/embed-app/extension.config.json +0 -4
  369. package/lib/theme-extension/template/embed-app/package.json +0 -18
  370. package/lib/theme-extension/template/embed-app/theme-app/assets-manifest.json +0 -1
  371. package/lib/theme-extension/template/embed-app/theme-app/blocks/index.liquid +0 -18
  372. package/lib/theme-extension/template/embed-app/theme-app/locales/ar-SA.json +0 -1
  373. package/lib/theme-extension/template/embed-app/theme-app/locales/de-DE.json +0 -1
  374. package/lib/theme-extension/template/embed-app/theme-app/locales/en-US.json +0 -6
  375. package/lib/theme-extension/template/embed-app/theme-app/locales/es-ES.json +0 -1
  376. package/lib/theme-extension/template/embed-app/theme-app/locales/fr-FR.json +0 -1
  377. package/lib/theme-extension/template/embed-app/theme-app/locales/id-ID.json +0 -1
  378. package/lib/theme-extension/template/embed-app/theme-app/locales/it-IT.json +0 -1
  379. package/lib/theme-extension/template/embed-app/theme-app/locales/ja-JP.json +0 -1
  380. package/lib/theme-extension/template/embed-app/theme-app/locales/ko-KR.json +0 -1
  381. package/lib/theme-extension/template/embed-app/theme-app/locales/nl-NL.json +0 -1
  382. package/lib/theme-extension/template/embed-app/theme-app/locales/pl-PL.json +0 -1
  383. package/lib/theme-extension/template/embed-app/theme-app/locales/pt-PT.json +0 -1
  384. package/lib/theme-extension/template/embed-app/theme-app/locales/ru-RU.json +0 -1
  385. package/lib/theme-extension/template/embed-app/theme-app/locales/th-TH.json +0 -1
  386. package/lib/theme-extension/template/embed-app/theme-app/locales/zh-CN.json +0 -6
  387. package/lib/theme-extension/template/embed-app/theme-app/locales/zh-TW.json +0 -1
  388. package/lib/theme-extension/template/embed-app/theme-app/snippets/index.liquid +0 -8
  389. package/lib/theme-extension/template/embed-app/theme-app/snippets/index_css.liquid +0 -6
  390. package/lib/theme-extension/utils/config.js +0 -32
  391. package/lib/theme-extension/utils/index.js +0 -213
  392. package/lib/tracing.js +0 -50
  393. package/lib/utils/config.js +0 -12
  394. package/lib/utils/console.js +0 -33
  395. package/lib/utils/env.js +0 -17
  396. package/lib/utils/file.js +0 -48
  397. package/lib/utils/platform.js +0 -37
  398. package/lib/utils/utils.js +0 -165
  399. /package/{lib/checkout → scripts/jsbuild}/dev/client.js +0 -0
  400. /package/{lib/app/services/extension-build/plugins → scripts/jsbuild/plugin}/vite-plugin-transform-extension-html.js +0 -0
package/README.zh.md ADDED
@@ -0,0 +1,318 @@
1
+ # shoplazza-cli
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Go Version](https://img.shields.io/badge/go-%3E%3D1.24-blue.svg)](https://go.dev/)
5
+ [![npm version](https://img.shields.io/npm/v/shoplazza-cli.svg)](https://www.npmjs.com/package/shoplazza-cli)
6
+
7
+ [中文版](./README.zh.md) | [English](./README.md)
8
+
9
+ Shoplazza 开放平台官方 CLI 工具 — 让人类和 AI Agent 都能在终端中操作 Shoplazza 店铺。开发应用和主题、管理商品、折扣、订单和客户,结构化输出天然适配 AI Agent 集成。
10
+
11
+ [安装](#安装与快速开始) · [认证](#认证) · [开发工作流](#开发工作流) · [命令](#三层命令调用) · [进阶用法](#进阶用法) · [贡献](#贡献)
12
+
13
+ ## 为什么选 shoplazza-cli?
14
+
15
+ - **为 Agent 原生设计** — 结构化 JSON 输出开箱即用,AI Agent 无需额外适配即可操作 Shoplazza 店铺
16
+ - **电商全域覆盖** — 商品、折扣、订单、客户完整 CRUD,20+ 快捷命令覆盖高频操作
17
+ - **完整开发者工作流** — App 创建、扩展脚手架(checkout / theme / function)、本地开发服务器 + HMR、一键部署;主题 init、实时热重载与打包
18
+ - **安全可控** — 输入防注入、OS 原生密钥链存储凭证、Access Token 自动刷新
19
+ - **三层调用架构** — 快捷命令(人机友好)→ API 命令(OpenAPI 同步)→ 通用调用(全 API 覆盖)
20
+ - **三分钟上手** — 交互式登录授权,从安装到第一次 API 调用只需三步
21
+
22
+ ## 功能
23
+
24
+ | 业务域 | 能力 |
25
+ |--------|------|
26
+ | 🛍️ 商品 | CRUD + 快捷命令:`+search`、`+publish`、`+unpublish`、`+create`、`+set-price`、`+stock` |
27
+ | 🏷️ 折扣 | CRUD + 8 个快捷创建命令,覆盖自动折扣与代码折扣 |
28
+ | 📦 订单 | CRUD + 快捷命令:`+search`、`+count`、`+ship`、`+refund`、`+update-tracking` |
29
+ | 👤 客户 | CRUD + 快捷命令:`+search`、`+create` |
30
+ | 🎨 主题 | `init`、`serve`(实时热重载)、`pull`、`push`、`package`、`share` |
31
+ | 🧩 应用 | 完整生命周期:init → extension create → dev → deploy;扩展类型:checkout、theme、function |
32
+
33
+ ## 安装与快速开始
34
+
35
+ ### 安装
36
+
37
+ | 方式 | 命令 | 说明 |
38
+ |------|------|------|
39
+ | **Homebrew**(macOS / Linux) | `brew install Shoplazza/tap/shoplazza-cli` | 推荐。通过 `brew upgrade` 自动更新。 |
40
+ | **一键脚本**(macOS / Linux) | `curl -fsSL https://raw.githubusercontent.com/Shoplazza/shoplazza-cli/main/install.sh \| bash` | 自动检测系统和架构。 |
41
+ | **npm** | `npm install -g @shoplazza/cli` | 需要 Node.js `>=14.18.0`。 |
42
+ | **下载二进制** | 见 [GitHub Releases](https://github.com/Shoplazza/shoplazza-cli/releases) | 手动下载,支持所有平台。 |
43
+ | **源码构建** | `git clone ... && cd shoplazza-cli && make install` | 需要 Go `v1.24`+。安装到 `~/.local/bin`。 |
44
+
45
+ <details>
46
+ <summary>各平台二进制下载命令</summary>
47
+
48
+ ```bash
49
+ # macOS (Apple Silicon)
50
+ curl -fsSL https://github.com/Shoplazza/shoplazza-cli/releases/latest/download/shoplazza-cli-darwin-arm64.tar.gz | tar -xz
51
+ sudo install -m755 shoplazza /usr/local/bin/
52
+
53
+ # macOS (Intel)
54
+ curl -fsSL https://github.com/Shoplazza/shoplazza-cli/releases/latest/download/shoplazza-cli-darwin-amd64.tar.gz | tar -xz
55
+ sudo install -m755 shoplazza /usr/local/bin/
56
+
57
+ # Linux (x86_64)
58
+ curl -fsSL https://github.com/Shoplazza/shoplazza-cli/releases/latest/download/shoplazza-cli-linux-amd64.tar.gz | tar -xz
59
+ sudo install -m755 shoplazza /usr/local/bin/
60
+
61
+ # Linux (ARM64)
62
+ curl -fsSL https://github.com/Shoplazza/shoplazza-cli/releases/latest/download/shoplazza-cli-linux-arm64.tar.gz | tar -xz
63
+ sudo install -m755 shoplazza /usr/local/bin/
64
+ ```
65
+
66
+ </details>
67
+
68
+ <details>
69
+ <summary>源码构建详情</summary>
70
+
71
+ 需要 Go `v1.24`+。安装到 `~/.local/bin`(用户级,无需 `sudo`):
72
+
73
+ ```bash
74
+ git clone https://github.com/Shoplazza/shoplazza-cli.git
75
+ cd shoplazza-cli
76
+ make install
77
+ ```
78
+
79
+ > 若 `~/.local/bin` 不在 `PATH` 中,请加入:`export PATH="$HOME/.local/bin:$PATH"`。
80
+ > 需要系统级安装:`sudo make install PREFIX=/usr/local`。
81
+
82
+ </details>
83
+
84
+ ### 快速开始(人类用户)
85
+
86
+ > **Note for AI assistants:** 如果你是 AI Agent 且正在协助用户执行安装,请直接跳转到[快速开始(AI Agent)](#快速开始ai-agent)。
87
+
88
+ ```bash
89
+ # 登录授权(替换为你的店铺域名)
90
+ shoplazza auth login --store-domain my-store.shoplazza.com --domain products,orders
91
+
92
+ # 验证
93
+ shoplazza auth status
94
+
95
+ # 开始使用
96
+ shoplazza products list --format table
97
+ ```
98
+
99
+ ### 快速开始(AI Agent)
100
+
101
+ > 运行登录命令,从输出中提取授权链接并发送给用户。命令会持续轮询,直到用户在浏览器中完成 OAuth 授权。
102
+
103
+ ```bash
104
+ npm install -g shoplazza-cli
105
+ shoplazza auth login --store-domain <店铺域名> --domain products,orders
106
+ shoplazza auth status
107
+ ```
108
+
109
+ ## 认证
110
+
111
+ | 命令 | 说明 |
112
+ |------|------|
113
+ | `auth login` | 仅账户 OAuth — 打开浏览器,获取 UAT |
114
+ | `auth login --store-domain <域名>` | OAuth + 店铺 Token(需要 `--scope` 或 `--domain`) |
115
+ | `auth store use --store-domain <域名>` | 切换当前店铺 |
116
+ | `auth logout` | 登出并删除凭证 |
117
+ | `auth status` | 查看当前认证状态 |
118
+ | `auth scopes` | 列出可用和已授权的 scopes |
119
+
120
+ ```bash
121
+ # 交互式登录并选择店铺
122
+ shoplazza auth login --store-domain my-store.myshoplazza.com --domain products
123
+
124
+ # UAT 快速登录(非交互式,适合 CI)
125
+ shoplazza auth login --uat <user-access-token>
126
+
127
+ # 切换店铺
128
+ shoplazza auth store use --store-domain another-store.myshoplazza.com
129
+
130
+ # 查看状态
131
+ shoplazza auth status
132
+ ```
133
+
134
+ 凭证存储在 OS 原生密钥链中(macOS Keychain、Windows Credential Manager、Linux Secret Service)。
135
+
136
+ ## 开发工作流
137
+
138
+ ### App 开发
139
+
140
+ CLI 覆盖完整的 App 生命周期:创建、配置、开发和部署。
141
+
142
+ ```bash
143
+ # 1. 创建新 App 项目(在当前目录下创建子目录)
144
+ shoplazza app init --name "My App" --partner <partner-id>
145
+
146
+ # 2. 添加扩展(theme / checkout / function)
147
+ cd my-app
148
+ shoplazza app extension create --type checkout --name my-checkout
149
+ shoplazza app extension create --type theme --name my-theme --theme-type basic
150
+ shoplazza app extension create --type function --name my-fn
151
+
152
+ # 3. 本地开发(开发服务器 + HMR)— 店铺由当前活跃的 App 配置决定
153
+ shoplazza app dev
154
+
155
+ # 4. 部署所有扩展
156
+ shoplazza app deploy
157
+
158
+ # 5. 查看已部署版本
159
+ shoplazza app versions
160
+ ```
161
+
162
+ <details>
163
+ <summary>更多 App 命令</summary>
164
+
165
+ ```bash
166
+ shoplazza app list # 列出账户下的 App
167
+ shoplazza app info # 查看 App 及扩展信息
168
+ shoplazza app config use --config alt.toml # 切换活跃 App 配置
169
+ shoplazza app config link --client-id <id> # 关联已有 App
170
+
171
+ # Function 扩展(单独编译/发布)
172
+ shoplazza app function compile --extension my-fn
173
+ shoplazza app function release --extension my-fn
174
+ shoplazza app function list
175
+ ```
176
+
177
+ </details>
178
+
179
+ ### Theme 主题开发
180
+
181
+ CLI 提供完整的主题开发工作流,支持实时热重载。
182
+
183
+ ```bash
184
+ # 1. 从 Nova-2023 模板创建新主题
185
+ shoplazza themes init --name my-theme
186
+
187
+ # 2. 启动开发服务器(自动创建开发主题,实时热重载)
188
+ cd my-theme
189
+ shoplazza themes serve
190
+
191
+ # 3. 拉取 / 推送 / 打包
192
+ shoplazza themes pull --theme-id <theme-id>
193
+ shoplazza themes push --theme-id <theme-id>
194
+ shoplazza themes package
195
+
196
+ # 4. 上传为预览版
197
+ shoplazza themes share
198
+ ```
199
+
200
+ ## 三层命令调用
201
+
202
+ CLI 提供三种粒度的调用方式,覆盖从快速操作到完全自定义的全部场景。
203
+
204
+ ### 1. 快捷命令(Shortcuts)
205
+
206
+ 以 `+` 为前缀,对人类与 AI 友好化封装,内置智能默认值和结构化输出。
207
+
208
+ ```bash
209
+ # 商品
210
+ shoplazza products +search --keyword "衬衫"
211
+ shoplazza products +publish <product-id>
212
+
213
+ # 折扣 — 自动折扣
214
+ shoplazza discounts +rebate --title "夏季满减" --percentage 15 --min-amount 100
215
+ shoplazza discounts +flashsale --title "限时秒杀" --percentage 20 --product-ids "123,456"
216
+
217
+ # 折扣 — 代码折扣
218
+ shoplazza discounts +percent-code --code "SAVE20" --percentage 20
219
+ shoplazza discounts +bxgy-code --code "BUY2GET1" --buy-quantity 2 --get-quantity 1
220
+
221
+ # 订单
222
+ shoplazza orders +ship <order-id>
223
+ ```
224
+
225
+ 运行 `shoplazza <domain> --help` 查看某个业务域的所有快捷命令。
226
+
227
+ ### 2. API 命令
228
+
229
+ 从 OpenAPI 元数据自动生成,命令与平台端点一一对应。
230
+
231
+ ```bash
232
+ shoplazza products list
233
+ shoplazza products get <product-id>
234
+ shoplazza products create --data @product.json
235
+
236
+ shoplazza discounts list
237
+ shoplazza discounts create-discount --data @discount.json
238
+
239
+ # 所有业务域:products, discounts, orders, customers, billing, shop, themes, webhook
240
+ shoplazza orders list
241
+ shoplazza customers list
242
+ ```
243
+
244
+ ### 3. 通用 API 调用
245
+
246
+ 直接调用任意 Shoplazza 开放平台端点,覆盖全量 API。
247
+
248
+ ```bash
249
+ shoplazza api rest GET /openapi/2022-01/products.json
250
+ shoplazza api rest POST /openapi/2022-01/products.json \
251
+ --data '{"product": {"title": "新商品", "status": "active"}}'
252
+ ```
253
+
254
+ ## 进阶用法
255
+
256
+ ### 通用 Flag
257
+
258
+ | Flag | 适用范围 | 说明 |
259
+ |------|----------|------|
260
+ | `--format json\|pretty\|table` | 所有命令 | 输出格式(默认:`json`) |
261
+ | `--fields "f1,f2"` | 快捷命令 | 响应字段投影 |
262
+ | `--dry-run` | API 和快捷命令 | 预览请求但不执行 |
263
+ | `--jq "expr"` / `-q` | API 命令 | 使用 jq 表达式过滤 JSON 输出 |
264
+
265
+ ### Schema 自省
266
+
267
+ 查看任意服务的方法列表、参数、所需 scopes 和响应结构:
268
+
269
+ ```bash
270
+ shoplazza schema # 列出所有服务
271
+ shoplazza schema products # 查看指定服务
272
+ shoplazza schema products.list # 查看指定方法
273
+ ```
274
+
275
+ ### 环境变量
276
+
277
+ | 变量 | 说明 |
278
+ |------|------|
279
+ | `SHOPLAZZA_UAT` | 用于非交互式登录的 User Access Token(等同 `--uat`) |
280
+ | `SHOPLAZZA_CLI_AUTH_BASE_URL` | 覆盖认证服务基础 URL(默认:`https://partners.shoplazza.com`) |
281
+
282
+ ## 安全与风险提示
283
+
284
+ > 使用前请阅读
285
+
286
+ - **AI Agent 自动化风险** — 当 AI Agent 代你操作 CLI 时,所有 API 调用都会产生真实影响(创建商品、修改订单、删除折扣)。请在执行前审查 Agent 提出的命令。
287
+ - **凭证安全** — Token 存储在 OS 原生密钥链中。切勿分享你的 UAT 或店铺 Token。如果怀疑凭证泄露,请立即轮换。
288
+ - **权限控制** — 使用 `--scope` 或 `--domain` 限制登录时授予的权限。只授予工作流所需的最小 scopes。
289
+
290
+ ## 贡献
291
+
292
+ 欢迎社区贡献!如果你发现 bug 或有功能建议,请在 [GitHub](https://github.com/Shoplazza/shoplazza-cli) 提交 Issue 或 Pull Request。
293
+
294
+ 对于较大的改动,建议先通过 Issue 与我们讨论。
295
+
296
+ ### 本地开发
297
+
298
+ ```bash
299
+ # 构建
300
+ make build
301
+
302
+ # 运行测试
303
+ make test
304
+
305
+ # Lint(提 PR 前必跑)
306
+ go mod tidy
307
+ go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main
308
+
309
+ # 本地安装
310
+ make install
311
+ ```
312
+
313
+ 提交信息遵循 [Conventional Commits](https://www.conventionalcommits.org/) 规范:`feat:`、`fix:`、`docs:`、`test:`、`refactor:`、`chore:`、`ci:`。
314
+
315
+ ## 许可证
316
+
317
+ 本项目基于 **MIT 许可证** 开源。
318
+ 该软件运行时会调用 Shoplazza 开放平台的 API,使用这些 API 需要遵守 [Shoplazza 开发者协议](https://www.shoplazza.dev/)。
package/package.json CHANGED
@@ -1,85 +1,39 @@
1
1
  {
2
2
  "name": "shoplazza-cli",
3
- "version": "1.1.2",
4
- "description": "",
5
- "main": "bin/shoplazza",
6
- "engines": {
7
- "node": ">=14.14.0"
8
- },
3
+ "version": "2.0.0",
4
+ "description": "The official CLI for Shoplazza Open Platform",
9
5
  "bin": {
10
- "shoplazza": "bin/shoplazza"
6
+ "shoplazza": "scripts/run.js"
11
7
  },
12
8
  "scripts": {
13
- "prettier": "prettier --write ./lib",
14
- "test": "jest --runInBand --forceExit"
9
+ "postinstall": "node scripts/install.js"
10
+ },
11
+ "os": ["darwin", "linux", "win32"],
12
+ "cpu": ["x64", "arm64"],
13
+ "engines": {
14
+ "node": ">=14.18.0"
15
+ },
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Shoplazza/shoplazza-cli.git"
15
20
  },
16
- "keywords": [],
17
- "author": "",
18
- "license": "ISC",
19
- "devDependencies": {
20
- "axios-mock-adapter": "^1.20.0",
21
- "jest": "^28.1.0",
22
- "prettier": "2.6.2"
21
+ "homepage": "https://github.com/Shoplazza/shoplazza-cli#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/Shoplazza/shoplazza-cli/issues"
23
24
  },
24
25
  "dependencies": {
25
- "@iarna/toml": "^2.2.5",
26
- "@ngrok/ngrok": "^1.5.2",
27
- "@sentry/node": "^6.19.7",
28
- "@sentry/tracing": "^6.19.7",
29
- "adm-zip": "^0.5.9",
30
- "ali-oss": "^6.17.1",
31
- "axios": "^1.6.8",
32
- "axios-curlirize": "^1.3.7",
33
- "better-sqlite3": "^11.5.0",
34
- "chalk": "^4.1.2",
35
26
  "chokidar": "^3.6.0",
36
- "classnames": "~2.3.2",
37
- "clean-css": "^5.3.1",
38
- "colors": "^1.4.0",
39
- "commander": "^9.2.0",
40
- "conf": "10.2.0",
41
27
  "connect": "^3.7.0",
42
- "dotenv": "^17.2.1",
43
- "download-git-repo": "^3.0.2",
44
- "ejs": "^3.1.10",
45
- "execa": "^5.1.1",
46
- "express": "^5.1.0",
47
- "extension-ui": "^1.0.6",
48
- "fancy-log": "~1.3.3",
49
- "file-type": "~16.5.0",
50
- "form-data": "^4.0.0",
51
- "fs-extra": "^10.1.0",
52
- "glob": "^8.0.3",
53
- "imagemin": "~8.0.0",
54
- "imagemin-jpegtran": "~7.0.0",
55
- "imagemin-pngquant": "~9.0.2",
56
- "imagemin-svgo": "~9.0.0",
57
- "inquirer": "^8.2.3",
58
- "js-queue": "~2.0.2",
59
28
  "jscodeshift": "^0.15.0",
60
- "livereload": "^0.9.3",
61
- "loading-cli": "^1.1.2",
62
- "md5": "~2.3.0",
63
- "mime": "^3.0.0",
64
- "mobx": "~6.9.0",
65
- "node-fetch": "^2.6.7",
66
- "node-watch": "^0.7.3",
67
- "open": "^8.4.0",
68
- "ora": "^5.4.1",
69
- "process": "~0.11.10",
70
- "semver": "~7.3.5",
71
29
  "serve-static": "^1.15.0",
72
- "simple-git": "^3.28.0",
73
- "spark-md5": "^3.0.2",
74
- "table": "^6.9.0",
75
- "uglify-js": "^3.17.4",
76
- "update-notifier": "^5.1.0",
77
30
  "vite": "~4.3.1",
78
- "vite-plugin-inspect": "^0.7.25",
79
- "ws": "^8.17.0",
80
- "yargs": "^17.5.0"
31
+ "ws": "^8.17.0"
81
32
  },
82
- "volta": {
83
- "node": "22.17.1"
84
- }
33
+ "files": [
34
+ "scripts/install.js",
35
+ "scripts/run.js",
36
+ "scripts/jsbuild/",
37
+ "CHANGELOG.md"
38
+ ]
85
39
  }
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall script — downloads the prebuilt shoplazza binary for the current
4
+ * platform from GitHub Releases and places it at bin/shoplazza[.exe].
5
+ *
6
+ * Environment overrides:
7
+ * SHOPLAZZA_CLI_RELEASE_URL — custom base URL (default: GitHub release asset URL)
8
+ * SHOPLAZZA_CLI_SKIP_INSTALL — set to "1" to skip download (useful for CI that
9
+ * builds from source instead)
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ const { execSync } = require('child_process');
15
+ const fs = require('fs');
16
+ const https = require('https');
17
+ const http = require('http');
18
+ const os = require('os');
19
+ const path = require('path');
20
+ const { version } = require('../package.json');
21
+
22
+ if (process.env.SHOPLAZZA_CLI_SKIP_INSTALL === '1') {
23
+ console.log('SHOPLAZZA_CLI_SKIP_INSTALL=1 — skipping binary download.');
24
+ process.exit(0);
25
+ }
26
+
27
+ // ── Platform detection ────────────────────────────────────────────────────────
28
+
29
+ const PLATFORM_MAP = {
30
+ darwin: 'darwin',
31
+ linux: 'linux',
32
+ win32: 'windows',
33
+ };
34
+
35
+ const ARCH_MAP = {
36
+ x64: 'amd64',
37
+ arm64: 'arm64',
38
+ };
39
+
40
+ const platform = PLATFORM_MAP[process.platform];
41
+ const arch = ARCH_MAP[process.arch];
42
+
43
+ if (!platform || !arch) {
44
+ console.error(`Unsupported platform: ${process.platform}/${process.arch}`);
45
+ console.error('Please build from source: https://github.com/Shoplazza/shoplazza-cli');
46
+ process.exit(1);
47
+ }
48
+
49
+ const ext = platform === 'windows' ? '.zip' : '.tar.gz';
50
+ const binName = platform === 'windows' ? 'shoplazza.exe' : 'shoplazza';
51
+ const pkgName = `shoplazza-cli-${version}-${platform}-${arch}`;
52
+ const fileName = `${pkgName}${ext}`;
53
+
54
+ // ── Destination ───────────────────────────────────────────────────────────────
55
+
56
+ const binDir = path.join(__dirname, '..', 'bin');
57
+ const binPath = path.join(binDir, binName);
58
+
59
+ fs.mkdirSync(binDir, { recursive: true });
60
+
61
+ // ── Download URL ──────────────────────────────────────────────────────────────
62
+
63
+ const RELEASE_BASE =
64
+ process.env.SHOPLAZZA_CLI_RELEASE_URL ||
65
+ `https://github.com/Shoplazza/shoplazza-cli/releases/download/v${version}`;
66
+
67
+ const downloadURL = `${RELEASE_BASE}/${fileName}`;
68
+
69
+ // ── Helpers ───────────────────────────────────────────────────────────────────
70
+
71
+ function download(url, dest) {
72
+ return new Promise((resolve, reject) => {
73
+ const proto = url.startsWith('https') ? https : http;
74
+ const file = fs.createWriteStream(dest);
75
+
76
+ function get(u) {
77
+ proto.get(u, (res) => {
78
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
79
+ // Follow redirects.
80
+ file.close();
81
+ get(res.headers.location);
82
+ return;
83
+ }
84
+ if (res.statusCode !== 200) {
85
+ file.close();
86
+ fs.unlinkSync(dest);
87
+ reject(new Error(`HTTP ${res.statusCode} for ${u}`));
88
+ return;
89
+ }
90
+ res.pipe(file);
91
+ file.on('finish', () => file.close(resolve));
92
+ }).on('error', (err) => {
93
+ fs.unlinkSync(dest);
94
+ reject(err);
95
+ });
96
+ }
97
+
98
+ get(url);
99
+ });
100
+ }
101
+
102
+ function extract(archive, destDir) {
103
+ if (archive.endsWith('.tar.gz')) {
104
+ execSync(`tar -xzf ${JSON.stringify(archive)} -C ${JSON.stringify(destDir)}`);
105
+ } else {
106
+ // .zip (Windows)
107
+ execSync(`powershell -Command "Expand-Archive -Path '${archive}' -DestinationPath '${destDir}' -Force"`);
108
+ }
109
+ }
110
+
111
+ // ── Main ──────────────────────────────────────────────────────────────────────
112
+
113
+ (async () => {
114
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'shoplazza-install-'));
115
+ const archivePath = path.join(tmpDir, fileName);
116
+
117
+ try {
118
+ console.log(`Downloading ${fileName} …`);
119
+ await download(downloadURL, archivePath);
120
+
121
+ console.log(`Extracting …`);
122
+ extract(archivePath, tmpDir);
123
+
124
+ // Binary is inside a named subdirectory matching the archive name.
125
+ const extracted = path.join(tmpDir, pkgName, binName);
126
+ const fallback = path.join(tmpDir, binName);
127
+ const src = fs.existsSync(extracted) ? extracted : fallback;
128
+
129
+ fs.copyFileSync(src, binPath);
130
+ if (platform !== 'windows') {
131
+ fs.chmodSync(binPath, 0o755);
132
+ }
133
+
134
+ console.log(`Installed shoplazza ${version} → ${binPath}`);
135
+ } finally {
136
+ fs.rmSync(tmpDir, { recursive: true, force: true });
137
+ }
138
+ })().catch((err) => {
139
+ console.error(`Failed to install shoplazza CLI: ${err.message}`);
140
+ console.error('You can build from source instead:');
141
+ console.error(' git clone https://github.com/Shoplazza/shoplazza-cli.git');
142
+ console.error(' cd shoplazza-cli && make install');
143
+ process.exit(1);
144
+ });
@@ -0,0 +1,123 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const http = require('http');
5
+ const connect = require('connect');
6
+ const serveStatic = require('serve-static');
7
+ const { WebSocketServer } = require('ws');
8
+ const chokidar = require('chokidar');
9
+ const { build } = require('vite');
10
+ const { viteConfig } = require('../vite.config');
11
+
12
+ const PORT = 8888;
13
+ function getRootPath() { return process.cwd(); }
14
+ function getDistPath() { return path.join(getRootPath(), 'dist'); }
15
+ function getExtensionsPath() { return path.join(getRootPath(), 'extensions'); }
16
+
17
+ // Build one extension and return its emitted dist filename (v1 buildExtension).
18
+ async function buildExtension(id) {
19
+ const entry = { [id]: path.join(getExtensionsPath(), id, 'src', 'index.js') };
20
+ await build(viteConfig(entry));
21
+ return fs.readdirSync(getDistPath()).find((f) => f.startsWith(id + '.'));
22
+ }
23
+
24
+ function getExtensionConfig(id) {
25
+ try {
26
+ const jsonPath = path.join(getExtensionsPath(), id, 'extension.json');
27
+ return JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
28
+ } catch (_) {
29
+ return {};
30
+ }
31
+ }
32
+
33
+ function generateExtensionData(id) {
34
+ const distName = fs.readdirSync(getDistPath()).find((f) => f.startsWith(id + '.'));
35
+ const config = getExtensionConfig(id);
36
+ return {
37
+ extensionId: id,
38
+ resourceUrl: `http://localhost:${PORT}/${distName}`,
39
+ status: 'draft',
40
+ version: config.version,
41
+ fields: JSON.stringify(config)
42
+ };
43
+ }
44
+
45
+ let webSocket = undefined;
46
+
47
+ function handleWsConnection(ws) {
48
+ webSocket = ws;
49
+ ws.on('error', console.error);
50
+ ws.on('message', function message(data) {
51
+ console.log(`Received message ${data} from user `);
52
+ });
53
+
54
+ let extensionList = [];
55
+ fs.readdirSync(getExtensionsPath()).forEach((ext) => {
56
+ extensionList.push(generateExtensionData(ext));
57
+ });
58
+ extensionList = extensionList.filter((ext) => !ext.resourceUrl.endsWith('undefined'));
59
+ ws.send(JSON.stringify({ event: 'init', data: extensionList }));
60
+ }
61
+
62
+ async function createWsServer(httpServer) {
63
+ const wss = new WebSocketServer({ noServer: true });
64
+ wss.on('connection', handleWsConnection);
65
+
66
+ httpServer.on('upgrade', function upgrade(request, socket, head) {
67
+ wss.handleUpgrade(request, socket, head, function done(ws) {
68
+ wss.emit('connection', ws, request);
69
+ });
70
+ });
71
+ return wss;
72
+ }
73
+
74
+ function createServer(dir) {
75
+ const app = connect();
76
+ app.use(
77
+ serveStatic(dir, {
78
+ setHeaders: function (res) {
79
+ res.setHeader('Access-Control-Allow-Origin', '*');
80
+ res.setHeader('Access-Control-Allow-Methods', 'GET');
81
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
82
+ }
83
+ })
84
+ );
85
+ return http.createServer(app);
86
+ }
87
+
88
+ async function startDev() {
89
+ if (fs.existsSync(getDistPath())) fs.rmSync(getDistPath(), { recursive: true, force: true });
90
+
91
+ const argIds = process.argv.slice(2).filter(Boolean);
92
+ const allDirs = fs
93
+ .readdirSync(getExtensionsPath(), { withFileTypes: true })
94
+ .filter((d) => d.isDirectory())
95
+ .map((d) => d.name);
96
+ const willBuildExts = argIds.length ? argIds.filter((id) => allDirs.includes(id)) : allDirs;
97
+ if (!willBuildExts.length) {
98
+ console.error('No extensions to develop under ./extensions');
99
+ process.exit(1);
100
+ }
101
+
102
+ await Promise.all(willBuildExts.map((id) => buildExtension(id)));
103
+ fs.copyFileSync(path.join(__dirname, 'client.js'), path.join(getDistPath(), 'index.js'));
104
+
105
+ // Watch for file changes (cross-platform path splitting)
106
+ chokidar.watch(getExtensionsPath()).on('change', async (event) => {
107
+ const rel = path.relative(getExtensionsPath(), event); // e.g. "demo/src/index.js"
108
+ const id = rel.split(path.sep).shift(); // first path segment = extension id
109
+ if (id) {
110
+ console.log(`update extension: ${id}`);
111
+ await buildExtension(id);
112
+ webSocket && webSocket.send(JSON.stringify({ event: 'update', data: generateExtensionData(id) }));
113
+ }
114
+ });
115
+
116
+ // Start HTTP + WS server
117
+ const httpServer = createServer(getDistPath());
118
+ createWsServer(httpServer);
119
+ httpServer.listen(PORT);
120
+ console.log(`started server on url: http://localhost:${PORT}/index.js`);
121
+ }
122
+
123
+ startDev();