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.
- package/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +206 -332
- package/README.zh.md +318 -0
- package/package.json +24 -70
- package/scripts/install.js +144 -0
- package/scripts/jsbuild/dev/index.js +123 -0
- package/scripts/jsbuild/index.js +77 -0
- package/{lib/checkout/build → scripts/jsbuild}/plugin/vite-plugin-add-extension-id.js +4 -2
- package/scripts/jsbuild/vite.config.js +35 -0
- package/scripts/run.js +29 -0
- package/.editorconfig +0 -28
- package/.prettierrc +0 -9
- package/bin/shoplazza +0 -137
- package/fixtures/assets/blog.scss +0 -74
- package/fixtures/assets/cart_modal.scss +0 -450
- package/fixtures/assets/collection_detail.js +0 -234
- package/fixtures/assets/collection_detail.scss +0 -345
- package/fixtures/assets/collection_list.scss +0 -11
- package/fixtures/assets/collection_slider.scss +0 -169
- package/fixtures/assets/feature_columns.scss +0 -26
- package/fixtures/assets/feature_product.scss +0 -109
- package/fixtures/assets/footer.js +0 -58
- package/fixtures/assets/footer.scss +0 -337
- package/fixtures/assets/four_images.scss +0 -29
- package/fixtures/assets/gallery.scss +0 -55
- package/fixtures/assets/header.js +0 -178
- package/fixtures/assets/header.scss +0 -929
- package/fixtures/assets/image_text.scss +0 -72
- package/fixtures/assets/logo_bar.scss +0 -11
- package/fixtures/assets/newsletter.scss +0 -90
- package/fixtures/assets/not_found.scss +0 -39
- package/fixtures/assets/page_detail.scss +0 -16
- package/fixtures/assets/pagination.scss +0 -150
- package/fixtures/assets/postcss.config.js +0 -6
- package/fixtures/assets/product_description.scss +0 -88
- package/fixtures/assets/product_detail.js +0 -634
- package/fixtures/assets/product_detail.scss +0 -1106
- package/fixtures/assets/relative_product.scss +0 -45
- package/fixtures/assets/reviews.scss +0 -70
- package/fixtures/assets/rich_text.scss +0 -71
- package/fixtures/assets/search.js +0 -87
- package/fixtures/assets/search.scss +0 -67
- package/fixtures/assets/slide.scss +0 -51
- package/fixtures/assets/slider.scss +0 -141
- package/fixtures/assets/test.scss +0 -1
- package/fixtures/assets/theme.css +0 -976
- package/fixtures/assets/theme.scss +0 -1100
- package/fixtures/assets/three_images.scss +0 -20
- package/fixtures/assets/tools.scss +0 -23
- package/fixtures/assets/two_images.scss +0 -24
- package/fixtures/assets/video.scss +0 -45
- package/fixtures/assets/video_text.scss +0 -63
- package/fixtures/config/settings_data.json +0 -107
- package/fixtures/config/settings_schema.json +0 -690
- package/fixtures/layout/theme.liquid +0 -76
- package/fixtures/locales/ar-SA.json +0 -212
- package/fixtures/locales/de-DE.json +0 -290
- package/fixtures/locales/en-US.json +0 -290
- package/fixtures/locales/es-ES.json +0 -290
- package/fixtures/locales/fr-FR.json +0 -290
- package/fixtures/locales/id-ID.json +0 -212
- package/fixtures/locales/it-IT.json +0 -212
- package/fixtures/locales/ja-JP.json +0 -289
- package/fixtures/locales/ko-KR.json +0 -290
- package/fixtures/locales/nl-NL.json +0 -290
- package/fixtures/locales/pl-PL.json +0 -290
- package/fixtures/locales/pt-PT.json +0 -212
- package/fixtures/locales/ru-RU.json +0 -212
- package/fixtures/locales/th-TH.json +0 -212
- package/fixtures/locales/zh-CN.json +0 -290
- package/fixtures/locales/zh-TW.json +0 -290
- package/fixtures/sections/apps.liquid +0 -47
- package/fixtures/sections/blog.liquid +0 -137
- package/fixtures/sections/collection_desc.liquid +0 -34
- package/fixtures/sections/collection_detail.liquid +0 -436
- package/fixtures/sections/collection_image.liquid +0 -104
- package/fixtures/sections/collection_list.liquid +0 -161
- package/fixtures/sections/collection_name.liquid +0 -34
- package/fixtures/sections/collection_slider.liquid +0 -330
- package/fixtures/sections/feature_columns.liquid +0 -275
- package/fixtures/sections/feature_product.liquid +0 -227
- package/fixtures/sections/footer.liquid +0 -488
- package/fixtures/sections/four_images.liquid +0 -160
- package/fixtures/sections/gallery.liquid +0 -258
- package/fixtures/sections/header.liquid +0 -1157
- package/fixtures/sections/html.liquid +0 -40
- package/fixtures/sections/image_text.liquid +0 -350
- package/fixtures/sections/instagram_plus.liquid +0 -393
- package/fixtures/sections/logo_bar.liquid +0 -183
- package/fixtures/sections/newsletter.liquid +0 -225
- package/fixtures/sections/not_found.liquid +0 -39
- package/fixtures/sections/overlay_image.liquid +0 -648
- package/fixtures/sections/page_detail.liquid +0 -39
- package/fixtures/sections/photo_collection.liquid +0 -433
- package/fixtures/sections/product_description.liquid +0 -208
- package/fixtures/sections/product_detail.liquid +0 -611
- package/fixtures/sections/products.liquid +0 -216
- package/fixtures/sections/relative_product.liquid +0 -121
- package/fixtures/sections/reviews.liquid +0 -115
- package/fixtures/sections/rich_text.liquid +0 -157
- package/fixtures/sections/search.liquid +0 -163
- package/fixtures/sections/slide.liquid +0 -719
- package/fixtures/sections/three_images.liquid +0 -157
- package/fixtures/sections/two_images.liquid +0 -125
- package/fixtures/sections/video.liquid +0 -95
- package/fixtures/sections/video_text.liquid +0 -128
- package/fixtures/snippets/bgset.liquid +0 -21
- package/fixtures/snippets/card_title.liquid +0 -8
- package/fixtures/snippets/cart_modal.liquid +0 -74
- package/fixtures/snippets/collection.liquid +0 -77
- package/fixtures/snippets/collection_filter_modal.liquid +0 -56
- package/fixtures/snippets/default_image_4.liquid +0 -14
- package/fixtures/snippets/default_image_6.liquid +0 -18
- package/fixtures/snippets/default_image_8.liquid +0 -23
- package/fixtures/snippets/four_images_item.liquid +0 -8
- package/fixtures/snippets/header_ads.liquid +0 -95
- package/fixtures/snippets/hero_image.liquid +0 -94
- package/fixtures/snippets/icon_video_play_large.liquid +0 -1
- package/fixtures/snippets/icon_video_play_medium.liquid +0 -4
- package/fixtures/snippets/icon_video_play_small.liquid +0 -4
- package/fixtures/snippets/lazyimg.liquid +0 -22
- package/fixtures/snippets/lazyimg_art.liquid +0 -36
- package/fixtures/snippets/lazysizes.liquid +0 -41
- package/fixtures/snippets/link.liquid +0 -2
- package/fixtures/snippets/pagination.liquid +0 -48
- package/fixtures/snippets/product.liquid +0 -126
- package/fixtures/snippets/product_art_tpl.liquid +0 -152
- package/fixtures/snippets/product_info_body.liquid +0 -337
- package/fixtures/snippets/product_info_tpl.liquid +0 -423
- package/fixtures/snippets/product_label.liquid +0 -46
- package/fixtures/snippets/settings.liquid +0 -295
- package/fixtures/snippets/social-meta-tags.liquid +0 -106
- package/fixtures/snippets/video_html.liquid +0 -11
- package/fixtures/snippets/video_source.liquid +0 -98
- package/fixtures/snippets/video_thumb_icon.liquid +0 -2
- package/fixtures/templates/404.liquid +0 -1
- package/fixtures/templates/collection.liquid +0 -92
- package/fixtures/templates/index.liquid +0 -206
- package/fixtures/templates/page.liquid +0 -1
- package/fixtures/templates/product.liquid +0 -99
- package/fixtures/templates/search.liquid +0 -1
- package/jest.config.js +0 -192
- package/lib/__tests__/log.test.js +0 -15
- package/lib/__tests__/utils.test.js +0 -69
- package/lib/app/api/cli.js +0 -225
- package/lib/app/api/openapi.js +0 -121
- package/lib/app/api/partnerOpenapi.js +0 -104
- package/lib/app/bin/index.js +0 -20
- package/lib/app/bin/javy/javy-arm-linux-v5.0.1 +0 -0
- package/lib/app/bin/javy/javy-arm-macos-v5.0.1 +0 -0
- package/lib/app/bin/javy/javy-x86_64-linux-v5.0.1 +0 -0
- package/lib/app/bin/javy/javy-x86_64-macos-v5.0.1 +0 -0
- package/lib/app/bin/javy/javy-x86_64-windows-v5.0.1 +0 -0
- package/lib/app/commands/config/actions/link.js +0 -189
- package/lib/app/commands/config/actions/use.js +0 -40
- package/lib/app/commands/config/index.js +0 -25
- package/lib/app/commands/config/link.js +0 -11
- package/lib/app/commands/config/use.js +0 -11
- package/lib/app/commands/deploy/actions/deploy.js +0 -196
- package/lib/app/commands/deploy/index.js +0 -11
- package/lib/app/commands/dev/actions/dev.js +0 -206
- package/lib/app/commands/dev/index.js +0 -11
- package/lib/app/commands/generate/actions/extension.js +0 -97
- package/lib/app/commands/generate/actions/generateCheckout.js +0 -58
- package/lib/app/commands/generate/actions/generateFunction.js +0 -56
- package/lib/app/commands/generate/actions/generateTheme.js +0 -128
- package/lib/app/commands/generate/extension.js +0 -11
- package/lib/app/commands/generate/index.js +0 -22
- package/lib/app/commands/index.js +0 -82
- package/lib/app/commands/info/actions/info.js +0 -168
- package/lib/app/commands/info/index.js +0 -11
- package/lib/app/commands/init/actions/init.js +0 -176
- package/lib/app/commands/init/index.js +0 -14
- package/lib/app/commands/versions/actions/list.js +0 -210
- package/lib/app/commands/versions/index.js +0 -22
- package/lib/app/commands/versions/list.js +0 -14
- package/lib/app/constant/code.js +0 -7
- package/lib/app/constant/color.js +0 -18
- package/lib/app/constant/extension.js +0 -16
- package/lib/app/constant/host.js +0 -23
- package/lib/app/constant/sso.js +0 -7
- package/lib/app/index.js +0 -8
- package/lib/app/services/auth/config.js +0 -33
- package/lib/app/services/auth/index.js +0 -9
- package/lib/app/services/auth/oauth-server.js +0 -70
- package/lib/app/services/auth/partner-token.js +0 -45
- package/lib/app/services/auth/sso-token.js +0 -69
- package/lib/app/services/auth/store-token.js +0 -100
- package/lib/app/services/auth/url-builder.js +0 -23
- package/lib/app/services/config/index.js +0 -41
- package/lib/app/services/devServer/app.js +0 -76
- package/lib/app/services/devServer/index.js +0 -103
- package/lib/app/services/devServer/middleware/hmacValidatorMiddleWare.js +0 -20
- package/lib/app/services/devServer/middleware/index.js +0 -5
- package/lib/app/services/devServer/tunnel/index.js +0 -43
- package/lib/app/services/devServer/tunnel/providers/cloudflare.js +0 -364
- package/lib/app/services/devServer/tunnel/providers/ngrok.js +0 -70
- package/lib/app/services/devServer/utils/index.js +0 -5
- package/lib/app/services/devServer/utils/secureCompare.js +0 -5
- package/lib/app/services/devServer/views/app.ejs +0 -133
- package/lib/app/services/extension-build/buildCheckout.js +0 -47
- package/lib/app/services/extension-build/buildFunction.js +0 -57
- package/lib/app/services/extension-build/buildTheme.js +0 -100
- package/lib/app/services/extension-build/index.js +0 -23
- package/lib/app/services/extension-build/plugins/vite-plugin-add-extension-id.js +0 -26
- package/lib/app/services/extension-diff/index.js +0 -132
- package/lib/app/services/extension-upsert/index.js +0 -21
- package/lib/app/services/extension-upsert/upsertCheckout.js +0 -44
- package/lib/app/services/extension-upsert/upsertFunction.js +0 -52
- package/lib/app/services/extension-upsert/upsertTheme.js +0 -113
- package/lib/app/services/oss/index.js +0 -45
- package/lib/app/services/partner/index.js +0 -52
- package/lib/app/store/base-store.js +0 -37
- package/lib/app/store/config-store.js +0 -55
- package/lib/app/store/config.js +0 -21
- package/lib/app/store/index.js +0 -14
- package/lib/app/store/install-store.js +0 -41
- package/lib/app/store/sso-store.js +0 -55
- package/lib/app/utils/asyncPool.js +0 -42
- package/lib/app/utils/debug/index.js +0 -16
- package/lib/app/utils/env.js +0 -24
- package/lib/app/utils/error.js +0 -20
- package/lib/app/utils/git.js +0 -20
- package/lib/app/utils/json.js +0 -27
- package/lib/app/utils/path.js +0 -33
- package/lib/app/utils/platform.js +0 -37
- package/lib/app/utils/request/cli.js +0 -72
- package/lib/app/utils/request/debug.js +0 -13
- package/lib/app/utils/request/openapi.js +0 -67
- package/lib/app/utils/request/partnerOpenapi.js +0 -47
- package/lib/app/utils/toml.js +0 -56
- package/lib/app/utils/views/message.js +0 -68
- package/lib/app/utils/views/select.js +0 -36
- package/lib/app/utils/withTempDir.js +0 -55
- package/lib/auth/__mocks__/getCode.js +0 -7
- package/lib/auth/__mocks__/index.js +0 -0
- package/lib/auth/child.js +0 -23
- package/lib/auth/getCode.js +0 -39
- package/lib/auth/index.js +0 -134
- package/lib/check.js +0 -28
- package/lib/checkout/api.js +0 -164
- package/lib/checkout/build/plugin/vite-plugin-transform-extension-html.js +0 -207
- package/lib/checkout/build/vite.config.js +0 -34
- package/lib/checkout/build.js +0 -38
- package/lib/checkout/config.js +0 -97
- package/lib/checkout/create.js +0 -132
- package/lib/checkout/delete.js +0 -26
- package/lib/checkout/deploy.js +0 -59
- package/lib/checkout/dev/index.js +0 -143
- package/lib/checkout/fields.js +0 -29
- package/lib/checkout/index.js +0 -63
- package/lib/checkout/preview.js +0 -52
- package/lib/checkout/pull.js +0 -22
- package/lib/checkout/push.js +0 -141
- package/lib/checkout/template/README.md +0 -34
- package/lib/checkout/template/_gitignore +0 -4
- package/lib/checkout/template/extension.config.js +0 -4
- package/lib/checkout/template/extensions/extension-template/extension.json +0 -10
- package/lib/checkout/template/extensions/extension-template/src/content.html +0 -3
- package/lib/checkout/template/extensions/extension-template/src/index.html +0 -5
- package/lib/checkout/template/extensions/extension-template/src/index.js +0 -11
- package/lib/checkout/template/extensions/extension-template/src/script.html +0 -3
- package/lib/checkout/template/extensions/extension-template/src/style.html +0 -3
- package/lib/checkout/template/package.json +0 -17
- package/lib/checkout/undeploy.js +0 -40
- package/lib/checkout/util.js +0 -201
- package/lib/checkout/verify.js +0 -16
- package/lib/checkout/version.js +0 -7
- package/lib/commands/__tests__/login.test.js +0 -77
- package/lib/commands/__tests__/logout.test.js +0 -29
- package/lib/commands/__tests__/store.test.js +0 -44
- package/lib/commands/__tests__/switch.test.js +0 -45
- package/lib/commands/login.js +0 -120
- package/lib/commands/logout.js +0 -23
- package/lib/commands/store.js +0 -14
- package/lib/commands/switch.js +0 -52
- package/lib/commands/theme/__tests__/delete.test.js +0 -49
- package/lib/commands/theme/__tests__/init.test.js +0 -21
- package/lib/commands/theme/__tests__/list.test.js +0 -80
- package/lib/commands/theme/__tests__/package.test.js +0 -17
- package/lib/commands/theme/__tests__/publish.test.js +0 -61
- package/lib/commands/theme/__tests__/pull.test.js +0 -69
- package/lib/commands/theme/__tests__/push.test.js +0 -63
- package/lib/commands/theme/__tests__/serve.test.js +0 -107
- package/lib/commands/theme/delete.js +0 -64
- package/lib/commands/theme/init.js +0 -51
- package/lib/commands/theme/list.js +0 -28
- package/lib/commands/theme/package.js +0 -37
- package/lib/commands/theme/publish.js +0 -56
- package/lib/commands/theme/pull.js +0 -62
- package/lib/commands/theme/push.js +0 -106
- package/lib/commands/theme/serve.js +0 -153
- package/lib/commands/theme/share.js +0 -20
- package/lib/commands/version.js +0 -6
- package/lib/common/constants.js +0 -24
- package/lib/common/db/partner.js +0 -91
- package/lib/common/inquirers/choose-app.js +0 -79
- package/lib/common/inquirers/choose-partner.js +0 -74
- package/lib/common/log.js +0 -15
- package/lib/common/login.js +0 -125
- package/lib/common/logout.js +0 -16
- package/lib/db/__mocks__/index.js +0 -9
- package/lib/db/__tests__/analytics.test.js +0 -19
- package/lib/db/__tests__/user.test.js +0 -20
- package/lib/db/analytics.js +0 -48
- package/lib/db/index.js +0 -9
- package/lib/db/user.js +0 -71
- package/lib/function/bin/index.js +0 -20
- package/lib/function/bin/javy/javy-arm-linux-v5.0.1 +0 -0
- package/lib/function/bin/javy/javy-arm-macos-v5.0.1 +0 -0
- package/lib/function/bin/javy/javy-x86_64-linux-v5.0.1 +0 -0
- package/lib/function/bin/javy/javy-x86_64-macos-v5.0.1 +0 -0
- package/lib/function/bin/javy/javy-x86_64-windows-v5.0.1 +0 -0
- package/lib/function/commands/compile.js +0 -43
- package/lib/function/commands/create.js +0 -77
- package/lib/function/commands/list.js +0 -18
- package/lib/function/commands/release.js +0 -69
- package/lib/function/index.js +0 -24
- package/lib/function/template/js/README.md +0 -37
- package/lib/function/template/js/_gitignore +0 -4
- package/lib/function/template/js/extension.config.json +0 -5
- package/lib/function/template/js/package.json +0 -17
- package/lib/function/template/js/src/index.js +0 -64
- package/lib/function/utils.js +0 -29
- package/lib/log.js +0 -13
- package/lib/openAPI/__mocks__/index.js +0 -20
- package/lib/openAPI/api.js +0 -76
- package/lib/openAPI/index.js +0 -56
- package/lib/oss.js +0 -102
- package/lib/partner-api/axios.js +0 -67
- package/lib/partner-api/index.js +0 -79
- package/lib/report.js +0 -37
- package/lib/theme-extension/api/index.js +0 -96
- package/lib/theme-extension/commands/build.js +0 -114
- package/lib/theme-extension/commands/connect.js +0 -73
- package/lib/theme-extension/commands/create.js +0 -105
- package/lib/theme-extension/commands/deploy.js +0 -56
- package/lib/theme-extension/commands/list.js +0 -35
- package/lib/theme-extension/commands/release.js +0 -59
- package/lib/theme-extension/commands/serve.js +0 -179
- package/lib/theme-extension/commands/versions.js +0 -55
- package/lib/theme-extension/index.js +0 -29
- package/lib/theme-extension/template/basic-app/README.md +0 -125
- package/lib/theme-extension/template/basic-app/extension.config.json +0 -4
- package/lib/theme-extension/template/basic-app/package.json +0 -18
- package/lib/theme-extension/template/basic-app/theme-app/assets/index.css +0 -4
- package/lib/theme-extension/template/basic-app/theme-app/assets-manifest.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/blocks/index.liquid +0 -16
- package/lib/theme-extension/template/basic-app/theme-app/locales/ar-SA.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/de-DE.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/en-US.json +0 -6
- package/lib/theme-extension/template/basic-app/theme-app/locales/es-ES.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/fr-FR.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/id-ID.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/it-IT.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/ja-JP.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/ko-KR.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/nl-NL.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/pl-PL.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/pt-PT.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/ru-RU.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/th-TH.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/locales/zh-CN.json +0 -6
- package/lib/theme-extension/template/basic-app/theme-app/locales/zh-TW.json +0 -1
- package/lib/theme-extension/template/basic-app/theme-app/snippets/index.liquid +0 -8
- package/lib/theme-extension/template/embed-app/README.md +0 -125
- package/lib/theme-extension/template/embed-app/extension.config.json +0 -4
- package/lib/theme-extension/template/embed-app/package.json +0 -18
- package/lib/theme-extension/template/embed-app/theme-app/assets-manifest.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/blocks/index.liquid +0 -18
- package/lib/theme-extension/template/embed-app/theme-app/locales/ar-SA.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/de-DE.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/en-US.json +0 -6
- package/lib/theme-extension/template/embed-app/theme-app/locales/es-ES.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/fr-FR.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/id-ID.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/it-IT.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/ja-JP.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/ko-KR.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/nl-NL.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/pl-PL.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/pt-PT.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/ru-RU.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/th-TH.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/locales/zh-CN.json +0 -6
- package/lib/theme-extension/template/embed-app/theme-app/locales/zh-TW.json +0 -1
- package/lib/theme-extension/template/embed-app/theme-app/snippets/index.liquid +0 -8
- package/lib/theme-extension/template/embed-app/theme-app/snippets/index_css.liquid +0 -6
- package/lib/theme-extension/utils/config.js +0 -32
- package/lib/theme-extension/utils/index.js +0 -213
- package/lib/tracing.js +0 -50
- package/lib/utils/config.js +0 -12
- package/lib/utils/console.js +0 -33
- package/lib/utils/env.js +0 -17
- package/lib/utils/file.js +0 -48
- package/lib/utils/platform.js +0 -37
- package/lib/utils/utils.js +0 -165
- /package/{lib/checkout → scripts/jsbuild}/dev/client.js +0 -0
- /package/{lib/app/services/extension-build/plugins → scripts/jsbuild/plugin}/vite-plugin-transform-extension-html.js +0 -0
package/lib/app/api/cli.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
const { getStoreAccessToken } = require('../services/auth');
|
|
2
|
-
const { cliClient } = require('../utils/request/cli');
|
|
3
|
-
|
|
4
|
-
// 获取 app 列表
|
|
5
|
-
function getAppListRequest(partner_id) {
|
|
6
|
-
return cliClient.get(`api/cli/partners/${partner_id}/apps`);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// 获取 partner 列表
|
|
10
|
-
function getPartnerListRequest() {
|
|
11
|
-
return cliClient.get('api/cli/partners');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 创建 app
|
|
15
|
-
function createAppRequest(partner_id, params) {
|
|
16
|
-
const { app_name, app_type } = params;
|
|
17
|
-
return cliClient.post(`api/cli/partners/${partner_id}/apps`, {
|
|
18
|
-
app_name,
|
|
19
|
-
app_type
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @description 获取模板 git 地址
|
|
25
|
-
* @param {string} template_type 模板类型 可选值:'app' | 'ext_func' | 'ext_thm' | 'ext_co'
|
|
26
|
-
* @returns {Promise<{data: { template_type: string, https: string }}>}
|
|
27
|
-
*/
|
|
28
|
-
function getTemplateGitRequest(template_type) {
|
|
29
|
-
return cliClient.get(`api/cli/template`, {
|
|
30
|
-
params: {
|
|
31
|
-
template_type
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// 获取 app 配置
|
|
37
|
-
function getAppConfigRequest(partner_id, app_client_id) {
|
|
38
|
-
return cliClient.get(`api/cli/partners/${partner_id}/apps/${app_client_id}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// app 完整信息 包括但不限配置信息
|
|
42
|
-
function getAppCompleteInfoRequest(app_client_id) {
|
|
43
|
-
return cliClient.get(`api/cli/info`, {
|
|
44
|
-
params: {
|
|
45
|
-
app_client_id
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 获取 OSS 上传凭证
|
|
52
|
-
* @param {Object} params
|
|
53
|
-
* @param {string} params.partnerId 开发者 id
|
|
54
|
-
* @param {string} params.appClientId app client id
|
|
55
|
-
* @param {number} params.fileSize 文件大小(字节)
|
|
56
|
-
* @param {string} params.md5 文件 md5(base64 编码)
|
|
57
|
-
* @returns {Promise<object>} OSS post_policy
|
|
58
|
-
*/
|
|
59
|
-
async function getPostPolicy({ partnerId, appClientId, fileSize, md5 }) {
|
|
60
|
-
return cliClient.get(`api/cli/partners/${partnerId}/apps/${appClientId}/post_policy`, {
|
|
61
|
-
params: { file_size: fileSize, md5 }
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 扩展信息
|
|
67
|
-
* @typedef {Object} Extension
|
|
68
|
-
* @property {string} extension_id - 扩展 ID(必传)
|
|
69
|
-
* @property {string} extension_name - 扩展名称(必传)
|
|
70
|
-
* @property {string} extension_type - 扩展类型(必传)
|
|
71
|
-
* @property {string} extension_version - 扩展版本(必传)
|
|
72
|
-
* @property {string} resource_url - 扩展资源地址(必传)
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* 应用信息
|
|
77
|
-
* @typedef {Object} AppInfo
|
|
78
|
-
* @property {Extension[]} extensions - 扩展列表
|
|
79
|
-
* @property {string} [dev_app_uri] - 内网穿透调试地址
|
|
80
|
-
* @property {string} [dev_redirect_uri] - 内网穿透回调地址
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 请求数据
|
|
85
|
-
* @typedef {Object} ExtensionDevData
|
|
86
|
-
* @property {AppInfo} app - 应用信息
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* dev 启动
|
|
91
|
-
* @param {Object} params - 请求参数
|
|
92
|
-
* @param {string} params.partner_id - 合作伙伴 ID
|
|
93
|
-
* @param {string} params.app_client_id - 应用客户端 ID
|
|
94
|
-
* @param {ExtensionDevData} params.data - 请求体数据
|
|
95
|
-
* @returns {Promise<Object>} 后端返回的响应
|
|
96
|
-
*/
|
|
97
|
-
async function extensionDev({ partner_id, app_client_id, data }) {
|
|
98
|
-
const { access_token, store_id } = await getStoreAccessToken(app_client_id, partner_id);
|
|
99
|
-
|
|
100
|
-
return cliClient.post(
|
|
101
|
-
`api/cli/partners/${partner_id}/apps/${app_client_id}/dev`,
|
|
102
|
-
{
|
|
103
|
-
...data,
|
|
104
|
-
store_id
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
headers: {
|
|
108
|
-
'access-token': access_token,
|
|
109
|
-
'Content-Type': 'application/json'
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 请求数据
|
|
117
|
-
* @typedef {Object} ExtensionDeployData
|
|
118
|
-
* @property {Object} app - 应用信息
|
|
119
|
-
* @property {string} app.version - 版本号
|
|
120
|
-
* @property {Extension[]} app.extensions - 扩展信息
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* deploy 部署
|
|
125
|
-
* @param {Object} params - 请求参数
|
|
126
|
-
* @param {string} params.partner_id - 合作伙伴 ID
|
|
127
|
-
* @param {string} params.app_client_id - 应用客户端 ID
|
|
128
|
-
* @param {ExtensionDeployData} params.data - 请求体数据
|
|
129
|
-
* @returns {Promise<Object>} 后端返回的响应
|
|
130
|
-
*/
|
|
131
|
-
async function extensionDeploy({ partner_id, app_client_id, data }) {
|
|
132
|
-
const { access_token, store_id } = await getStoreAccessToken(app_client_id, partner_id);
|
|
133
|
-
return cliClient.post(
|
|
134
|
-
`api/cli/partners/${partner_id}/apps/${app_client_id}/deploy`,
|
|
135
|
-
{
|
|
136
|
-
...data,
|
|
137
|
-
store_id
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
headers: {
|
|
141
|
-
'access-token': access_token
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* 获取 app 某个版本的 extensions
|
|
149
|
-
* @param {string} partner_id
|
|
150
|
-
* @param {string} app_client_id
|
|
151
|
-
* @param {string} [app_version_id]
|
|
152
|
-
* @returns {Promise<Object>}
|
|
153
|
-
*/
|
|
154
|
-
async function getAppExtensionsRequest({ partner_id, app_client_id, app_version_id = 0, is_dev }) {
|
|
155
|
-
const appInstallCache = await getStoreAccessToken(app_client_id, partner_id);
|
|
156
|
-
return cliClient.get(`api/cli/partners/${partner_id}/apps/${app_client_id}/extension_versions`, {
|
|
157
|
-
params: {
|
|
158
|
-
app_version_id,
|
|
159
|
-
is_dev
|
|
160
|
-
},
|
|
161
|
-
headers: {
|
|
162
|
-
'access-token': appInstallCache.access_token
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* 生成版本
|
|
169
|
-
* @param {Object} params
|
|
170
|
-
* @param {string} params.partner_id
|
|
171
|
-
* @param {string} params.app_client_id
|
|
172
|
-
* @param {boolean} params.is_dev
|
|
173
|
-
* @returns {Promise<Object>}
|
|
174
|
-
*/
|
|
175
|
-
async function generateVersionRequest({ partner_id, app_client_id, is_dev }) {
|
|
176
|
-
const { access_token, store_id } = await getStoreAccessToken(app_client_id, partner_id);
|
|
177
|
-
return cliClient.get(`api/cli/partners/${partner_id}/apps/${app_client_id}/version/generate`, {
|
|
178
|
-
params: {
|
|
179
|
-
is_dev,
|
|
180
|
-
store_id
|
|
181
|
-
},
|
|
182
|
-
headers: {
|
|
183
|
-
'access-token': access_token
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* 获取 app 版本列表
|
|
190
|
-
* @param {Object} params
|
|
191
|
-
* @param {string} params.partner_id
|
|
192
|
-
* @param {string} params.app_client_id
|
|
193
|
-
* @param {number} params.offset
|
|
194
|
-
* @param {number} params.limit
|
|
195
|
-
* @returns {Promise<{versions: {id: number, version: string}[], has_more: boolean}>}
|
|
196
|
-
*/
|
|
197
|
-
|
|
198
|
-
async function getAppVersionsRequest({ partner_id, app_client_id, offset = 0, limit = 10 }) {
|
|
199
|
-
const { access_token, store_id } = await getStoreAccessToken(app_client_id, partner_id);
|
|
200
|
-
|
|
201
|
-
return cliClient.get(`api/cli/partners/${partner_id}/apps/${app_client_id}/versions`, {
|
|
202
|
-
params: {
|
|
203
|
-
offset,
|
|
204
|
-
limit
|
|
205
|
-
},
|
|
206
|
-
headers: {
|
|
207
|
-
'access-token': access_token
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
module.exports = {
|
|
213
|
-
createAppRequest,
|
|
214
|
-
getAppListRequest,
|
|
215
|
-
getPartnerListRequest,
|
|
216
|
-
getTemplateGitRequest,
|
|
217
|
-
getAppConfigRequest,
|
|
218
|
-
getAppCompleteInfoRequest,
|
|
219
|
-
getAppExtensionsRequest,
|
|
220
|
-
getPostPolicy,
|
|
221
|
-
extensionDev,
|
|
222
|
-
extensionDeploy,
|
|
223
|
-
generateVersionRequest,
|
|
224
|
-
getAppVersionsRequest
|
|
225
|
-
};
|
package/lib/app/api/openapi.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const { getOpenapiClient } = require('../utils/request/openapi');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 创建或更新主题插件
|
|
5
|
-
* @param {Object} data
|
|
6
|
-
* @param {string} [data.extension_id]
|
|
7
|
-
* @param {string} [data.title]
|
|
8
|
-
* @param {string} [data.icon]
|
|
9
|
-
* @param {string} [data.resource_url]
|
|
10
|
-
* @returns {Promise<{extension_id: string}>}
|
|
11
|
-
*/
|
|
12
|
-
async function upsertThemeExtensionRequest(app_client_id, partner_id, data) {
|
|
13
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
14
|
-
return client.put('openapi/2020-07/theme-extensions', data);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 创建主题插件版本
|
|
19
|
-
* @param {string} app_client_id
|
|
20
|
-
* @param {string} partner_id
|
|
21
|
-
* @param {Object} data
|
|
22
|
-
* @param {string} data.extension_id
|
|
23
|
-
* @param {string} data.version
|
|
24
|
-
* @param {string} data.resource_url
|
|
25
|
-
* @returns {Promise<{extension_id: string}>}
|
|
26
|
-
*/
|
|
27
|
-
async function createThemeExtensionVersionRequest(app_client_id, partner_id, data) {
|
|
28
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
29
|
-
return client.post('openapi/2020-07/theme-extensions/version-tasks', data);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 获取主题插件版本任务
|
|
34
|
-
* @param {string} app_client_id
|
|
35
|
-
* @param {string} partner_id
|
|
36
|
-
* @param {string} task_id
|
|
37
|
-
* @returns {Promise<{
|
|
38
|
-
* task_id: string,
|
|
39
|
-
* state: number,
|
|
40
|
-
* message: string,
|
|
41
|
-
* task_type: string
|
|
42
|
-
* }>}
|
|
43
|
-
*/
|
|
44
|
-
async function getThemeExtensionVersionTaskRequest(app_client_id, partner_id, task_id) {
|
|
45
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
46
|
-
return client.get(`openapi/2020-07/theme-extensions/version-tasks/${task_id}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 创建 checkout 插件
|
|
51
|
-
* @param {string} app_client_id
|
|
52
|
-
* @param {string} partner_id
|
|
53
|
-
* @param {Object} data
|
|
54
|
-
* @param {string} data.name
|
|
55
|
-
* @param {string} data.version
|
|
56
|
-
* @param {string} data.resource_url
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
async function createCheckoutExtensionRequest(app_client_id, partner_id, data) {
|
|
60
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
61
|
-
return client.post('openapi/checkout_extensions/create', {
|
|
62
|
-
extension: data
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* commit checkout 插件
|
|
68
|
-
* @param {string} app_client_id
|
|
69
|
-
* @param {string} partner_id
|
|
70
|
-
* @param {Object} data
|
|
71
|
-
* @param {string} data.name
|
|
72
|
-
* @param {string} data.version
|
|
73
|
-
* @param {string} data.extension_id
|
|
74
|
-
* @param {string} data.resource_url
|
|
75
|
-
*/
|
|
76
|
-
async function commitCheckoutExtensionRequest(app_client_id, partner_id, data) {
|
|
77
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
78
|
-
return client.post(`openapi/checkout_extensions/commit`, {
|
|
79
|
-
extension: data
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 部署 checkout 插件
|
|
85
|
-
* @param {string} app_client_id
|
|
86
|
-
* @param {string} partner_id
|
|
87
|
-
* @param {Object} data
|
|
88
|
-
* @param {string} data.extension_id
|
|
89
|
-
* @param {string} data.extension_version_id
|
|
90
|
-
*/
|
|
91
|
-
async function deployCheckoutExtensionRequest(app_client_id, partner_id, { extension_id, extension_version_id }) {
|
|
92
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
93
|
-
return client.post(`openapi/checkout_extensions/deploy`, {
|
|
94
|
-
extension: {
|
|
95
|
-
extension_id,
|
|
96
|
-
id: extension_version_id
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async function deployThemeExtensionRequest(app_client_id, partner_id, { extension_id, extension_version_id }) {
|
|
102
|
-
const client = await getOpenapiClient(app_client_id, partner_id);
|
|
103
|
-
return client.post(`openapi/2020-07/theme-extensions/publications`, {
|
|
104
|
-
extension: {
|
|
105
|
-
extension_id,
|
|
106
|
-
version_id: extension_version_id,
|
|
107
|
-
type: 'enable'
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
module.exports = {
|
|
114
|
-
upsertThemeExtensionRequest,
|
|
115
|
-
createCheckoutExtensionRequest,
|
|
116
|
-
createThemeExtensionVersionRequest,
|
|
117
|
-
getThemeExtensionVersionTaskRequest,
|
|
118
|
-
commitCheckoutExtensionRequest,
|
|
119
|
-
deployCheckoutExtensionRequest,
|
|
120
|
-
deployThemeExtensionRequest,
|
|
121
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
const { partnerOpenapiClient } = require('../utils/request/partnerOpenapi');
|
|
2
|
-
const FormData = require('form-data');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
/**
|
|
5
|
-
* 连接App
|
|
6
|
-
* @param {Object} data
|
|
7
|
-
* @param {string} data.extension_id
|
|
8
|
-
* @param {string} data.type
|
|
9
|
-
* @returns {Promise<Object>}
|
|
10
|
-
*/
|
|
11
|
-
function connectionAppRequest({ app_client_id, extension_id, access_token }) {
|
|
12
|
-
|
|
13
|
-
return partnerOpenapiClient.post(
|
|
14
|
-
'openapi/2025-06/theme-extensions/connection',
|
|
15
|
-
{
|
|
16
|
-
extension_id,
|
|
17
|
-
type: 'link'
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
headers: {
|
|
21
|
-
'app-client-id': app_client_id,
|
|
22
|
-
'access-token': access_token
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 创建函数
|
|
30
|
-
* @param {string} app_client_id
|
|
31
|
-
* @param {Object} data
|
|
32
|
-
* @param {string} data.name
|
|
33
|
-
* @param {string} data.namespace
|
|
34
|
-
* @param {string} data.source_code
|
|
35
|
-
* @param {string} data.file
|
|
36
|
-
* @returns {Promise<{function_id: string, version_id: string, version: string}>}
|
|
37
|
-
*/
|
|
38
|
-
async function createFunctionRequest(app_client_id, access_token, data) {
|
|
39
|
-
const formData = new FormData();
|
|
40
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
41
|
-
if (key === 'file') {
|
|
42
|
-
// 如果是文件路径,用流替换
|
|
43
|
-
formData.append(key, fs.createReadStream(value));
|
|
44
|
-
} else if (key === 'source_code') {
|
|
45
|
-
// source_code 是文件路径,读取内容作为字符串传递
|
|
46
|
-
const sourceCode = fs.readFileSync(value, 'utf8');
|
|
47
|
-
formData.append(key, sourceCode);
|
|
48
|
-
} else {
|
|
49
|
-
formData.append(key, value);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return partnerOpenapiClient.post(`openapi/2025-06/functions/create`, formData, {
|
|
53
|
-
headers: {
|
|
54
|
-
...formData.getHeaders(), // 让 axios 自动带上正确的 multipart/form-data boundary
|
|
55
|
-
'app-client-id': app_client_id,
|
|
56
|
-
'access-token': access_token,
|
|
57
|
-
},
|
|
58
|
-
maxContentLength: Infinity,
|
|
59
|
-
maxBodyLength: Infinity
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 提交函数
|
|
65
|
-
* @param {string} app_client_id
|
|
66
|
-
* @param {Object} data
|
|
67
|
-
* @param {string} data.function_id
|
|
68
|
-
* @param {string} data.source_code
|
|
69
|
-
* @param {string} data.file
|
|
70
|
-
* @param {string} data.version
|
|
71
|
-
* @param {string} data.name
|
|
72
|
-
* @param {string} data.namespace
|
|
73
|
-
* @returns {Promise<{function_id: string, version_id: string, version: string}>}
|
|
74
|
-
*/
|
|
75
|
-
async function commitFunctionRequest(app_client_id, access_token, data) {
|
|
76
|
-
const formData = new FormData();
|
|
77
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
78
|
-
if (key === 'file') {
|
|
79
|
-
// 如果是文件路径,用流替换
|
|
80
|
-
formData.append(key, fs.createReadStream(value));
|
|
81
|
-
} else if (key === 'source_code') {
|
|
82
|
-
// source_code 是文件路径,读取内容作为字符串传递
|
|
83
|
-
const sourceCode = fs.readFileSync(value, 'utf8');
|
|
84
|
-
formData.append(key, sourceCode);
|
|
85
|
-
} else {
|
|
86
|
-
formData.append(key, value);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return partnerOpenapiClient.post(`openapi/2025-06/functions/commit`, formData, {
|
|
90
|
-
headers: {
|
|
91
|
-
...formData.getHeaders(), // 让 axios 自动带上正确的 multipart/form-data boundary
|
|
92
|
-
'app-client-id': app_client_id,
|
|
93
|
-
'access-token': access_token,
|
|
94
|
-
},
|
|
95
|
-
maxContentLength: Infinity,
|
|
96
|
-
maxBodyLength: Infinity
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
connectionAppRequest,
|
|
102
|
-
createFunctionRequest,
|
|
103
|
-
commitFunctionRequest
|
|
104
|
-
};
|
package/lib/app/bin/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { getArchPlatform } = require('../utils/platform');
|
|
4
|
-
|
|
5
|
-
function getLibPath(name) {
|
|
6
|
-
const archPlatform = getArchPlatform();
|
|
7
|
-
const supportedTargets = ['arm-linux', 'arm-macos', 'x86_64-macos', 'x86_64-windows', 'x86_64-linux'];
|
|
8
|
-
if (!supportedTargets.includes(archPlatform)) {
|
|
9
|
-
throw Error(`Unsupported platform/architecture combination ${processPlatform}/${processArch}`);
|
|
10
|
-
}
|
|
11
|
-
const libDir = fs.readdirSync(__dirname).find((n) => name === n);
|
|
12
|
-
const targetPath = fs.readdirSync(path.resolve(__dirname, libDir)).find((libName) => libName.includes(archPlatform));
|
|
13
|
-
const libPath = path.resolve(__dirname, name, targetPath);
|
|
14
|
-
fs.chmodSync(libPath, 0o755);
|
|
15
|
-
return libPath;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
getLibPath
|
|
20
|
-
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const inquirer = require('inquirer');
|
|
5
|
-
|
|
6
|
-
const { createAppRequest, getAppListRequest, getAppConfigRequest } = require('../../../api/cli');
|
|
7
|
-
const { getPartner, promptCreateOrConnect } = require('../../../services/partner');
|
|
8
|
-
const { withErrorHandling } = require('../../../utils/error');
|
|
9
|
-
const { selectOne } = require('../../../utils/views/select');
|
|
10
|
-
const { getTomlConfigFiles, parseTomlFile, createTomlConfig } = require('../../../utils/toml');
|
|
11
|
-
const { slugify } = require('../../../utils/path');
|
|
12
|
-
const { successMessageRender } = require('../../../utils/views/message');
|
|
13
|
-
const { configStore } = require('../../../store');
|
|
14
|
-
|
|
15
|
-
// 处理 configFile 相关
|
|
16
|
-
async function handleConfigFile(projectDir) {
|
|
17
|
-
// 获取所有 TOML 配置文件
|
|
18
|
-
const tomlConfigFiles = getTomlConfigFiles(projectDir);
|
|
19
|
-
let configFile;
|
|
20
|
-
let isOverwrite = false;
|
|
21
|
-
if (tomlConfigFiles.length > 0) {
|
|
22
|
-
while (true) {
|
|
23
|
-
const { rawName } = await inquirer.prompt({
|
|
24
|
-
type: 'input',
|
|
25
|
-
name: 'rawName',
|
|
26
|
-
message: 'Configuration file name:',
|
|
27
|
-
validate: (input) => (input.trim() === '' ? "Configuration file can't be empty" : true)
|
|
28
|
-
});
|
|
29
|
-
configFile = `shoplazza.app.${slugify(rawName)}.toml`;
|
|
30
|
-
let isRename = false;
|
|
31
|
-
if (fs.existsSync(path.join(projectDir, configFile))) {
|
|
32
|
-
isRename = await selectOne(
|
|
33
|
-
[
|
|
34
|
-
{ name: `Yes, I'll choose a different name`, value: true },
|
|
35
|
-
{ name: `No, overwrite my existing configuration file`, value: false }
|
|
36
|
-
],
|
|
37
|
-
{
|
|
38
|
-
message: `Configuration file ${configFile} already exists. Do you want to choose a different configuration name?`,
|
|
39
|
-
autoPickSingle: false
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
isOverwrite = !isRename;
|
|
43
|
-
}
|
|
44
|
-
if (!isRename) {
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
configFile = 'shoplazza.app.toml';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return { configFile, isOverwrite };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 格式化 appList
|
|
56
|
-
function formatAppList(appList, projectDir) {
|
|
57
|
-
const configFiles = getTomlConfigFiles(projectDir);
|
|
58
|
-
const map = configFiles.reduce((acc, configFile) => {
|
|
59
|
-
const config = parseTomlFile(configFile);
|
|
60
|
-
acc[config.client_id] = configFile;
|
|
61
|
-
return acc;
|
|
62
|
-
}, {});
|
|
63
|
-
|
|
64
|
-
return appList.map((app) => {
|
|
65
|
-
return {
|
|
66
|
-
...app,
|
|
67
|
-
configFile: map[app.client_id] || ''
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 成功提示
|
|
73
|
-
function successTips({ configFile, appName }) {
|
|
74
|
-
successMessageRender(`${chalk.bold(`${configFile} is now linked to "${appName}" on Shoplazza`)}
|
|
75
|
-
|
|
76
|
-
Using ${configFile} as your default config.
|
|
77
|
-
|
|
78
|
-
Next steps
|
|
79
|
-
• Make updates to ${configFile} in your local project
|
|
80
|
-
• To update your config, run ${chalk.hex('#d079f8')('`shoplazza app deploy`')}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function linkAction(options) {
|
|
84
|
-
const { path: argPath = '.', clientId: argClientId } = options;
|
|
85
|
-
|
|
86
|
-
// 项目目录
|
|
87
|
-
const projectDir = path.resolve(argPath);
|
|
88
|
-
|
|
89
|
-
if (!fs.existsSync(projectDir)) {
|
|
90
|
-
throw new Error(`path not found: ${projectDir}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// 选取 partner
|
|
94
|
-
const partner = await getPartner();
|
|
95
|
-
|
|
96
|
-
// 获取 app
|
|
97
|
-
const appListRes = await getAppListRequest(partner.id);
|
|
98
|
-
|
|
99
|
-
// 判断 创建 还是 链接
|
|
100
|
-
const isCreate = argClientId ? false : await promptCreateOrConnect(appListRes);
|
|
101
|
-
|
|
102
|
-
if (isCreate) {
|
|
103
|
-
// 创建
|
|
104
|
-
const appName = await inquirer
|
|
105
|
-
.prompt({
|
|
106
|
-
type: 'input',
|
|
107
|
-
name: 'app_name',
|
|
108
|
-
message: 'App name:',
|
|
109
|
-
validate: (input) => (input.trim() === '' ? "App name can't be empty" : true)
|
|
110
|
-
})
|
|
111
|
-
.then((r) => r.app_name);
|
|
112
|
-
|
|
113
|
-
// 规范化 appName
|
|
114
|
-
const normalizedAppName = slugify(appName);
|
|
115
|
-
|
|
116
|
-
const { configFile, isOverwrite } = await handleConfigFile(projectDir);
|
|
117
|
-
|
|
118
|
-
const { app } = await createAppRequest(partner.id, {
|
|
119
|
-
app_name: normalizedAppName
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
if (isOverwrite) {
|
|
123
|
-
fs.rmSync(path.join(projectDir, configFile));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
await createTomlConfig(path.join(projectDir, configFile), (config) => ({
|
|
127
|
-
...config,
|
|
128
|
-
client_id: app.client_id,
|
|
129
|
-
}));
|
|
130
|
-
|
|
131
|
-
// 缓存 app 相关信息
|
|
132
|
-
configStore.setProjectConfig(projectDir, {
|
|
133
|
-
clientId: app.client_id,
|
|
134
|
-
directory: projectDir,
|
|
135
|
-
configFile
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
successTips({ configFile, appName: app.name });
|
|
139
|
-
} else {
|
|
140
|
-
// 链接 app
|
|
141
|
-
|
|
142
|
-
// 处理 appList
|
|
143
|
-
const formattedAppList = formatAppList(appListRes.apps, projectDir);
|
|
144
|
-
// 连接已存在的 app
|
|
145
|
-
const clientId =
|
|
146
|
-
argClientId ||
|
|
147
|
-
(await selectOne(formattedAppList, {
|
|
148
|
-
autoPickSingle: false,
|
|
149
|
-
message: 'Which existing app is this for?',
|
|
150
|
-
formatChoice: (a) => ({ name: a.name + (a.configFile ? ` (${a.configFile}) ` : ''), value: a.client_id })
|
|
151
|
-
}));
|
|
152
|
-
|
|
153
|
-
let configFile;
|
|
154
|
-
let isOverwrite = false;
|
|
155
|
-
const currentApp = formattedAppList.find((a) => a.client_id === clientId);
|
|
156
|
-
if (currentApp.configFile) {
|
|
157
|
-
configFile = currentApp.configFile;
|
|
158
|
-
isOverwrite = true;
|
|
159
|
-
} else {
|
|
160
|
-
const { configFile: newConfigFile, isOverwrite: newIsOverwrite } = await handleConfigFile(projectDir);
|
|
161
|
-
configFile = newConfigFile;
|
|
162
|
-
isOverwrite = newIsOverwrite;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const { app } = await getAppConfigRequest(partner.id, clientId);
|
|
166
|
-
|
|
167
|
-
if (isOverwrite) {
|
|
168
|
-
fs.rmSync(path.join(projectDir, configFile));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
await createTomlConfig(path.join(projectDir, configFile), (config) => ({
|
|
172
|
-
...config,
|
|
173
|
-
client_id: app.client_id,
|
|
174
|
-
}));
|
|
175
|
-
|
|
176
|
-
// 缓存 app 相关信息
|
|
177
|
-
configStore.setProjectConfig(projectDir, {
|
|
178
|
-
clientId: app.client_id,
|
|
179
|
-
directory: projectDir,
|
|
180
|
-
configFile
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
successTips({ configFile, appName: app.name });
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
module.exports = {
|
|
188
|
-
linkAction: withErrorHandling(linkAction)
|
|
189
|
-
};
|