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
@@ -1,164 +0,0 @@
1
- const Axios = require('axios');
2
- const path = require('path');
3
- const fs = require('fs');
4
- const FormData = require('form-data');
5
- const loading = require('loading-cli');
6
- const { openAipVersion } = require('./config');
7
- const { isDebug, consoleWarn } = require('../utils/console');
8
- const { getProjectConfig } = require('./util');
9
- const chalk = require('chalk');
10
- const { useOss } = require('../oss');
11
-
12
- const FILE_SIGN_URL = '/checkout_extensions/file/sign';
13
- const CREATE_URL = '/checkout_extensions/create';
14
- const COMMIT_URL = '/checkout_extensions/commit';
15
- const LIST_URL = '/checkout_extensions/list';
16
- const VERSION_LIST_URL = '/checkout_extensions/version/list';
17
- const DEPLOY_URL = '/checkout_extensions/deploy';
18
- const UNDEPLOY_URL = '/checkout_extensions/undeploy';
19
- const PREVIEW_URL = '/checkout_extensions/preview';
20
-
21
- let configJson = undefined;
22
- let uploadOss = null;
23
-
24
- const request = new Axios.create();
25
-
26
- request.interceptors.request.use((config) => {
27
- if (config.data instanceof FormData) {
28
- Object.assign(config.headers, config.data.getHeaders());
29
- }
30
- if (!configJson) {
31
- configJson = getProjectConfig();
32
- }
33
- config.headers['Access-Token'] = configJson.token;
34
- if (!config.url.startsWith('http')) {
35
- config.url = path.join(configJson.store, openAipVersion, config.url);
36
- // TODO 这里需要处理一下,使用 URL 对象
37
-
38
- }
39
-
40
- if (isDebug()) {
41
- console.log(`\n==> ${config.method}: ${config.url}`);
42
- }
43
- return config;
44
- });
45
-
46
- const errorMapping = {
47
- INVALID_ARGUMENT: 'Invalid argument',
48
- PERMISSION_DENIED: 'Permission denied',
49
- INTERNAL_ERROR: 'Internal error'
50
- };
51
- const handleResponseError = (response) => {
52
- const errorMsg = errorMapping[response.data?.message];
53
- if (errorMsg) {
54
- throw `${errorMsg} at ${response.config.url}`;
55
- }
56
- };
57
-
58
- request.interceptors.response.use(
59
- (response) => {
60
- if (isDebug()) {
61
- console.log(`\n<== ${response.status}: ${response.config.url}`);
62
- }
63
- handleResponseError(response);
64
- return response;
65
- },
66
- (error) => {
67
- if (isDebug()) {
68
- console.log(`\n<== error ${error.response.status}: ${error.response.config.url}`);
69
- }
70
- if (error.response?.status == 403) {
71
- return Promise.reject(new Error('Token permission failure'));
72
- }
73
- return Promise.reject(error);
74
- }
75
- );
76
-
77
- async function uploadFile(dirPath, file) {
78
- if (!uploadOss) {
79
- uploadOss = useOss(
80
- configJson.token,
81
- new URL(configJson.store).hostname,
82
- `✗ No store found. Please check your "extension.config.js" file.`
83
- ).uploadOss;
84
- }
85
- return uploadOss(`${dirPath}/${file}`);
86
- }
87
- async function uploadDir(dirPath, files) {
88
- return Promise.all(
89
- files.map((file) => {
90
- return uploadOss(`${dirPath}/${file}`);
91
- })
92
- );
93
- }
94
-
95
- module.exports = {
96
- uploadDir,
97
- uploadFile,
98
- getExtensionList: async (params) => {
99
- const load = loading('Fetch extension list').start();
100
- try {
101
- const res = await request(`${LIST_URL}`, {
102
- params
103
- });
104
- load.succeed('Successfully fetched the extension list.');
105
- return res;
106
- } catch (error) {
107
- load.fail('Failed to fetch the extension list.');
108
- throw error;
109
- }
110
- },
111
- getVersionList: async (params) => {
112
- const load = loading('Fetch version list').start();
113
- try {
114
- const res = await request(`${VERSION_LIST_URL}`, {
115
- params
116
- });
117
- load.succeed('Successfully fetched the version list.');
118
- return res;
119
- } catch (error) {
120
- load.fail('Failed to fetch the version list.');
121
- throw error;
122
- }
123
- },
124
- pushExtension: async (data, isFirstPush = false) => {
125
- data = {
126
- extension: {
127
- ...data
128
- }
129
- };
130
- const res = await request({ url: isFirstPush ? CREATE_URL : COMMIT_URL, method: 'POST', data });
131
- if (res.data?.status === 3 && res.data?.message === 'INVALID_VERSION') {
132
- throw 'During repeated pushes, the version number must be greater than the previous version number.';
133
- }
134
- return res;
135
- },
136
- deployExtension: async (data) => {
137
- data = {
138
- extension: {
139
- ...data
140
- }
141
- };
142
- return request({ url: DEPLOY_URL, method: 'POST', data });
143
- },
144
- undeployExtension: async (data) => {
145
- data = {
146
- extension: {
147
- ...data
148
- }
149
- };
150
- return request({ url: UNDEPLOY_URL, method: 'POST', data });
151
- },
152
- previewExtension: async (data) => {
153
- data = {
154
- extension: {
155
- ...data
156
- }
157
- };
158
- const res = await request({ url: PREVIEW_URL, method: 'POST', data });
159
- if (res.data?.status === 14 && res.data?.message === 'ITEM_UNAVAILABLE') {
160
- throw 'Failed to generate a preview URL because your store currently has no available items.';
161
- }
162
- return res;
163
- }
164
- };
@@ -1,207 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const j = require('jscodeshift');
4
-
5
- const EXTENSION_RENDER_FN_NAME = 'extend';
6
- const HTML_FILE_PATH_KEY = 'component';
7
- const ASTNodeType = {
8
- RETURN_STATMENT: 'ReturnStatement',
9
- CALL_EXPRESSION: 'CallExpression',
10
- OBJECT_EXPRESSION: 'ObjectExpression',
11
- IDENTIFIER: 'Identifier',
12
- IMPORT_DEFAULT_SPECIFIER: 'ImportDefaultSpecifier',
13
- IMPORT_DECLARATION: 'ImportDeclaration'
14
- };
15
- const findRenderFnList = (code) => {
16
- const renderFnList = [];
17
-
18
- j(code)
19
- .find(j.CallExpression)
20
- .forEach((astNode) => {
21
- if (astNode?.value?.callee?.name === EXTENSION_RENDER_FN_NAME) {
22
- const objectExpressionNode = astNode?.value?.arguments?.find(
23
- (args) => args.type === ASTNodeType.OBJECT_EXPRESSION
24
- );
25
- if (objectExpressionNode) {
26
- const componentProp = objectExpressionNode?.properties?.find(
27
- (prop) => prop?.key?.name === HTML_FILE_PATH_KEY
28
- );
29
-
30
- const name = componentProp?.value?.callee?.name;
31
- name && renderFnList.push(name);
32
- }
33
- }
34
- });
35
-
36
- return renderFnList;
37
- };
38
-
39
- const findImportDeclareStatementNodeList = (code) => {
40
- const importDeclareStatementList = [];
41
-
42
- j(code)
43
- .find(j.ImportDeclaration)
44
- .forEach((importStatementNode) => {
45
- const importDefaultSpecifier = importStatementNode?.value?.specifiers?.find(
46
- (specifierNode) => specifierNode?.type === ASTNodeType.IMPORT_DEFAULT_SPECIFIER
47
- )?.local?.name;
48
- const importPath = importStatementNode?.value?.source?.value;
49
-
50
- importDefaultSpecifier &&
51
- importPath &&
52
- typeof importPath === 'string' &&
53
- importDeclareStatementList.push({ importDefaultSpecifier, importPath });
54
- });
55
-
56
- return importDeclareStatementList;
57
- };
58
-
59
- const readFile = (path) => {
60
- const supportedExt = ['html'];
61
-
62
- const ext = path.split('.').pop()?.toLowerCase() || '';
63
- if (supportedExt.includes(ext)) {
64
- return fs.readFileSync(path, {
65
- encoding: 'utf8'
66
- });
67
- }
68
-
69
- return '';
70
- };
71
-
72
- const removeBodyMark = (code) => {
73
- return code.replaceAll(/\<body\>/g, '').replaceAll(/\<\/body\>/g, '');
74
- };
75
-
76
- const addExtensionApiPrefix = (code) => {
77
- const EXTENSION_API_CALL_EXPRESSION = '__EXTENSION_UI__.extensionApi.';
78
- return code.replaceAll(/extensionApi\./g, EXTENSION_API_CALL_EXPRESSION);
79
- };
80
-
81
- let cachedHtmlStr = {};
82
-
83
- const handleHtmlDeps = (htmlStr, curPath) => {
84
- let str = htmlStr;
85
- // eg. import "./index.html" import './index.html'
86
- const importReg = /import\s*(?:(?:\"([\.\/\w]+)\")|(?:'([\.\/\w]+)'))/;
87
-
88
- let result = importReg.exec(str);
89
- while (result) {
90
- const importedHtmlPath = result[1] || result[2];
91
- if (importedHtmlPath) {
92
- try {
93
- const importedHtmlAbsolutePath = path.resolve(path.dirname(curPath), importedHtmlPath);
94
- if (!Object.prototype.hasOwnProperty.call(cachedHtmlStr, importedHtmlAbsolutePath)) {
95
- cachedHtmlStr[importedHtmlAbsolutePath] = '';
96
-
97
- const importedHtmlStr = readFile(importedHtmlAbsolutePath);
98
-
99
- cachedHtmlStr[importedHtmlAbsolutePath] = handleHtmlDeps(importedHtmlStr, curPath);
100
- }
101
-
102
- str = str.replace(importReg, () => cachedHtmlStr[importedHtmlAbsolutePath]);
103
- } catch (e) {
104
- console.error(e);
105
- }
106
- }
107
- result = importReg.exec(str);
108
- }
109
-
110
- str = removeBodyMark(str);
111
-
112
- return str;
113
- };
114
-
115
- const strMinify = (code) => code.split('\n').filter(Boolean).join('');
116
-
117
- const createTemplateLiteral = (code) => j.stringLiteral(code);
118
-
119
- const removeImportDeclareStatment = (code, specifiers) => {
120
- return j(code)
121
- .find(j.Program)
122
- .forEach((program) => {
123
- const body = program?.value?.body || [];
124
- if (body.length > 0) {
125
- const index = body.findIndex(
126
- (node) =>
127
- node?.type === ASTNodeType.IMPORT_DECLARATION &&
128
- !!node?.specifiers?.find(
129
- (specifier) =>
130
- specifier?.type === ASTNodeType.IMPORT_DEFAULT_SPECIFIER &&
131
- specifiers.includes(specifier?.local?.name || '')
132
- )
133
- );
134
- if (index > -1) program.value.body.splice(index, 1);
135
- }
136
- })
137
- .toSource();
138
- };
139
- module.exports = {
140
- vitePluginTransformExtensionHtml: () => {
141
- return {
142
- name: 'vitePluginTransformExtensionHtml',
143
- enforce: 'pre',
144
- apply: 'build',
145
- transform(code, srcPath) {
146
- if (!srcPath.endsWith('.js')) {
147
- return code;
148
- }
149
-
150
- const renderFnList = findRenderFnList(code);
151
- const importDeclareStatementList = findImportDeclareStatementNodeList(code);
152
-
153
- const removedImportSpecifiers = [];
154
-
155
- const returnStatementChangedCode = j(code)
156
- .find(j.FunctionDeclaration)
157
- .forEach((functionDeclareNode) => {
158
- const fnName = functionDeclareNode?.value?.id?.name || '';
159
- if (!renderFnList.includes(fnName)) return;
160
-
161
- const returnStatment = functionDeclareNode?.value?.body?.body?.find(
162
- (node) => node.type === ASTNodeType.RETURN_STATMENT
163
- );
164
-
165
- const isIdentifierReturnType = returnStatment?.argument?.type === ASTNodeType.IDENTIFIER;
166
- if (!isIdentifierReturnType) return;
167
-
168
- const identifierName = returnStatment?.argument?.name;
169
- const htmlFilePathNode = importDeclareStatementList.find(
170
- (stat) => stat.importDefaultSpecifier === identifierName
171
- );
172
-
173
- if (htmlFilePathNode) {
174
- try {
175
- const absolutePath = path.resolve(path.dirname(srcPath), htmlFilePathNode.importPath);
176
- cachedHtmlStr[absolutePath] = '';
177
- const htmlStr = readFile(absolutePath);
178
-
179
- let result = handleHtmlDeps(htmlStr, srcPath);
180
- cachedHtmlStr = {};
181
-
182
- result = strMinify(result);
183
- result = addExtensionApiPrefix(result);
184
- const templateLiteral = createTemplateLiteral(result);
185
-
186
- returnStatment.argument = templateLiteral;
187
-
188
- removedImportSpecifiers.push(identifierName);
189
- } catch (e) {
190
- console.error(e);
191
- }
192
- }
193
- })
194
- .toSource();
195
-
196
- const importStatementRemovedCode = removeImportDeclareStatment(
197
- returnStatementChangedCode,
198
- removedImportSpecifiers
199
- );
200
- return importStatementRemovedCode;
201
- },
202
- buildEnd: () => {
203
- console.log('transform html end');
204
- }
205
- };
206
- }
207
- };
@@ -1,34 +0,0 @@
1
- const { cwd } = require('process');
2
- const { vitePluginAddExtensionId } = require('./plugin/vite-plugin-add-extension-id');
3
- const { vitePluginTransformExtensionHtml } = require('./plugin/vite-plugin-transform-extension-html');
4
- const { getDistPath } = require('../util');
5
-
6
- // https://vitejs.dev/config/
7
- module.exports = {
8
- viteConfig: (pageEntry) => {
9
- return {
10
- plugins: [vitePluginTransformExtensionHtml(), vitePluginAddExtensionId()],
11
- base: '/',
12
- root: cwd(),
13
- build: {
14
- minify: false,
15
- emptyOutDir: false,
16
- copyPublicDir: false,
17
- rollupOptions: {
18
- input: pageEntry,
19
- output: {
20
- entryFileNames: '[name].[hash].js',
21
- chunkFileNames: '[name].[hash].js',
22
- assetFileNames: '[name].[hash].[ext]',
23
- compact: true,
24
- inlineDynamicImports: false,
25
- dir: getDistPath()
26
- },
27
- watch: {
28
- include: './extensions'
29
- }
30
- }
31
- }
32
- };
33
- }
34
- };
@@ -1,38 +0,0 @@
1
- const { consoleError, consoleBlue } = require('../utils/console');
2
- const { build } = require('vite');
3
- const { viteConfig } = require('./build/vite.config');
4
- const { getExtensionInfo, getDistPath } = require('./util');
5
- const path = require('path');
6
- const fs = require('fs');
7
-
8
- async function viteBuild(command) {
9
- try {
10
- require('./version');
11
- const { id, path: extensionPath } = getExtensionInfo(command.id);
12
- const pageEntry = {
13
- [id]: path.join(extensionPath, 'src', 'index.js')
14
- };
15
- if (!fs.existsSync(getDistPath())) {
16
- fs.mkdirSync(getDistPath());
17
- }
18
- fs.readdirSync(getDistPath()).forEach((fname) => {
19
- if (fname.includes(id)) {
20
- fs.rmSync(path.join(getDistPath(), fname));
21
- }
22
- });
23
- await build(viteConfig(pageEntry));
24
- } catch (err) {
25
- throw 'build_error: ' + err;
26
- }
27
- }
28
-
29
- async function cliBuild(command) {
30
- try {
31
- await viteBuild(command);
32
- } catch (err) {}
33
- }
34
-
35
- module.exports = {
36
- cliBuild,
37
- viteBuild
38
- };
@@ -1,97 +0,0 @@
1
- module.exports = {
2
- cwd: process.cwd(),
3
- openAipVersion: '/openapi',
4
- defaultExtensionDir: 'extensions',
5
- configFile: 'extension.json',
6
- buildDir: 'dist',
7
- package: 'package.json',
8
- questions: commands => {
9
- const { store, token, theme } = commands;
10
- return require('inquirer').prompt([
11
- {
12
- name: 'store',
13
- type: 'input',
14
- default: store,
15
- message: 'Please enter your store(Eg: https://developer.myshoplaza.com)',
16
- when: () => {
17
- if (!store) return true;
18
- try {
19
- new URL(store);
20
- } catch (e) {
21
- return 'Incorrect store'
22
- }
23
- return false;
24
- },
25
- validate: text => {
26
- if (!text) return false;
27
- try {
28
- new URL(text);
29
- } catch (e) {
30
- return 'Incorrect store'
31
- }
32
- return true;
33
- }
34
- },
35
- {
36
- name: 'token',
37
- type: 'input',
38
- default: token,
39
- when: !token,
40
- message: 'Please enter your token(Private app token)',
41
- validate: text => !!text
42
- }
43
- ]);
44
- },
45
- pullQuestion: () => {
46
- return require('inquirer').prompt([
47
- {
48
- type: 'list',
49
- name: 'pullType',
50
- message: 'Choose pull type: ',
51
- default: 'extension',
52
- prefix: '*',
53
- choices: [
54
- {
55
- name: 'Extension',
56
- value: 'extension'
57
- },
58
- {
59
- name: 'Fields',
60
- value: 'fields',
61
- },
62
- // TODO:
63
- // {
64
- // name: 'Source',
65
- // value: 'source'
66
- // }
67
- ]
68
- }
69
- ]);
70
- },
71
- outputDirPathQuestion: (commands = {}) => {
72
- const outputDirPath = process.env.OUTPUT_DIR_PATH || commands.outputDirPath;
73
- return require('inquirer').prompt([
74
- {
75
- type: 'input',
76
- name: 'outputDirPath',
77
- message: 'Please enter extension output directory relative path(Eg: ./src/xxx ): ',
78
- default: outputDirPath || './dist/chick-extension',
79
- when: !outputDirPath,
80
- validate: text => !!text
81
- }
82
- ]);
83
- },
84
- dirPathQuestion: (commands = {}) => {
85
- const dirPath = process.env.DIR_PATH || commands.dirPath;
86
- return require('inquirer').prompt([
87
- {
88
- type: 'input',
89
- name: 'dirPath',
90
- message: 'Please enter extension directory relative path(Eg: ./src/xxx ): ',
91
- default: dirPath || './extensions',
92
- when: !dirPath,
93
- validate: text => !!text
94
- }
95
- ]);
96
- }
97
- };
@@ -1,132 +0,0 @@
1
- const { consoleError, consoleSuccess } = require('../utils/console');
2
- const path = require('path');
3
- const fs = require('fs');
4
- const inquirer = require('inquirer');
5
- const { copy } = require('./util');
6
-
7
- const cwd = process.cwd();
8
-
9
- const templateDir = path.resolve(__dirname, './template');
10
-
11
- const renameFiles = {
12
- _gitignore: '.gitignore'
13
- };
14
-
15
- const extensionNamePromptConfig = {
16
- type: 'input',
17
- name: 'extensionName',
18
- message: 'Enter the extension name:',
19
- prefix: '*'
20
- };
21
-
22
- async function promptWhenAddExtension(before = []) {
23
- return inquirer.prompt([
24
- ...before,
25
- {
26
- type: 'input',
27
- name: 'store',
28
- message: 'Enter your store URL(example: https://xxx.myshoplaza.com/):',
29
- prefix: '*'
30
- },
31
- {
32
- type: 'input',
33
- name: 'token',
34
- message: 'Enter the store\'s token:',
35
- prefix: '*'
36
- },
37
- extensionNamePromptConfig
38
- ]);
39
- }
40
-
41
- /**
42
- * 使用cli创建一个项目
43
- * @param {} command 项目名
44
- * @returns
45
- */
46
- async function createProject(command) {
47
- const { projectName, extensionName, store, token } = await promptWhenAddExtension([
48
- {
49
- type: 'input',
50
- name: 'projectName',
51
- message: 'Please input your project name:',
52
- prefix: '*'
53
- }
54
- ]);
55
- const projectDir = projectName.replace(/\/+$/g, '');
56
- const root = path.join(cwd, projectDir);
57
- if (fs.existsSync(root)) {
58
- consoleError(`the directory '${projectDir}' is exist.`);
59
- return;
60
- }
61
- if (!extensionName.trim()) {
62
- consoleError('extension id is required');
63
- return;
64
- }
65
- fs.mkdirSync(root, { recursive: true });
66
-
67
- const write = (file, content) => {
68
- const targetPath = path.join(root, renameFiles[file] ?? file);
69
- if (content) {
70
- fs.writeFileSync(targetPath, content);
71
- } else {
72
- copy(path.join(templateDir, file), targetPath);
73
- }
74
- };
75
-
76
- const files = fs.readdirSync(templateDir);
77
- for (const file of files.filter((f) => !['package.json'].includes(f))) {
78
- write(file);
79
- }
80
-
81
- let projectConfigContent = fs.readFileSync(path.join(templateDir, 'extension.config.js'), 'utf-8');
82
- projectConfigContent = projectConfigContent.replace('{store}', store).replace('{token}', token);
83
- write('extension.config.js', projectConfigContent);
84
-
85
- const pkg = JSON.parse(fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8'));
86
- pkg.name = projectDir;
87
- write('package.json', JSON.stringify(pkg, null, 2) + '\n');
88
-
89
- fs.renameSync(path.join(root, 'extensions/extension-template'), path.join(root, `extensions/${extensionName}`));
90
-
91
- const extensionConfig = JSON.parse(
92
- fs.readFileSync(path.join(path.resolve(root, `extensions/${extensionName}`), `extension.json`), 'utf-8')
93
- );
94
- extensionConfig.extensionName = extensionName;
95
- write(`extensions/${extensionName}/extension.json`, JSON.stringify(extensionConfig, null, 2) + '\n');
96
- consoleSuccess(`Successfully created extension project '${projectName}'.`);
97
- }
98
-
99
- /**
100
- * 使用cli在现有项目中新增一个 extension
101
- */
102
- async function createExtension(command) {
103
- const { extensionName } = await inquirer.prompt([extensionNamePromptConfig]);
104
- const extensionsDir = path.join(cwd, 'extensions');
105
- if (!fs.existsSync(extensionsDir)) {
106
- consoleError('Please check current dir is a extension project');
107
- return;
108
- }
109
-
110
- const targetDir = path.join(extensionsDir, extensionName);
111
- if (fs.existsSync(targetDir)) {
112
- consoleError(`This '${extensionName}' extension already exists.`);
113
- return;
114
- }
115
- fs.mkdirSync(targetDir);
116
-
117
- const extensionTemplateDir = path.join(templateDir, 'extensions', 'extension-template');
118
- const files = fs.readdirSync(extensionTemplateDir);
119
- for (const file of files.filter((f) => f !== 'extension.json')) {
120
- copy(path.join(extensionTemplateDir, file), path.join(targetDir, file));
121
- }
122
-
123
- const extensionConfig = JSON.parse(fs.readFileSync(path.join(extensionTemplateDir, `extension.json`), 'utf-8'));
124
- extensionConfig.extensionName = extensionName;
125
- fs.writeFileSync(path.join(targetDir, 'extension.json'), JSON.stringify(extensionConfig, null, 2) + '\n');
126
- consoleSuccess(`Successfully created extension '${extensionName}'.`);
127
- }
128
-
129
- module.exports = {
130
- createProject,
131
- createExtension
132
- };
@@ -1,26 +0,0 @@
1
- const api = require('./api');
2
- const loading = require('loading-cli');
3
- const { verifyConfig } = require('./verify');
4
- const { getExtensionInfo, getExtensionConfig } = require('./util');
5
-
6
- module.exports = async (commands = {}) => {
7
- await verifyConfig(commands);
8
- const info = getExtensionInfo(commands.id);
9
- const config = getExtensionConfig(commands.id);
10
- const deleteLoading = loading(`Delete the extension '${info.id}'.`).start();
11
- await Promise.all([
12
- api.deleteExtension({
13
- extension_id: info.id,
14
- version: config.version
15
- })
16
- ])
17
- .then(() => {
18
- deleteLoading.succeed(`Delete the extension '${info.id}' succeed.`);
19
- })
20
- .catch(() => {
21
- deleteLoading.fail(`Delete the extension '${info.id}' failed.`).fail();
22
- })
23
- .finally(() => {
24
- deleteLoading.stop();
25
- });
26
- };