shoplazza-cli 1.0.13 → 1.1.2
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/README.md +12 -12
- package/bin/shoplazza +5 -3
- package/lib/app/api/cli.js +225 -0
- package/lib/app/api/openapi.js +121 -0
- package/lib/app/api/partnerOpenapi.js +104 -0
- package/lib/app/bin/index.js +20 -0
- 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 +189 -0
- package/lib/app/commands/config/actions/use.js +40 -0
- package/lib/app/commands/config/index.js +25 -0
- package/lib/app/commands/config/link.js +11 -0
- package/lib/app/commands/config/use.js +11 -0
- package/lib/app/commands/deploy/actions/deploy.js +196 -0
- package/lib/app/commands/deploy/index.js +11 -0
- package/lib/app/commands/dev/actions/dev.js +206 -0
- package/lib/app/commands/dev/index.js +11 -0
- package/lib/app/commands/generate/actions/extension.js +97 -0
- package/lib/app/commands/generate/actions/generateCheckout.js +58 -0
- package/lib/app/commands/generate/actions/generateFunction.js +56 -0
- package/lib/app/commands/generate/actions/generateTheme.js +128 -0
- package/lib/app/commands/generate/extension.js +11 -0
- package/lib/app/commands/generate/index.js +22 -0
- package/lib/app/commands/index.js +82 -0
- package/lib/app/commands/info/actions/info.js +168 -0
- package/lib/app/commands/info/index.js +11 -0
- package/lib/app/commands/init/actions/init.js +176 -0
- package/lib/app/commands/init/index.js +14 -0
- package/lib/app/commands/versions/actions/list.js +210 -0
- package/lib/app/commands/versions/index.js +22 -0
- package/lib/app/commands/versions/list.js +14 -0
- package/lib/app/constant/code.js +7 -0
- package/lib/app/constant/color.js +18 -0
- package/lib/app/constant/extension.js +16 -0
- package/lib/app/constant/host.js +23 -0
- package/lib/app/constant/sso.js +7 -0
- package/lib/app/index.js +4 -25
- package/lib/app/services/auth/config.js +33 -0
- package/lib/app/services/auth/index.js +9 -0
- package/lib/app/services/auth/oauth-server.js +70 -0
- package/lib/app/services/auth/partner-token.js +45 -0
- package/lib/app/services/auth/sso-token.js +69 -0
- package/lib/app/services/auth/store-token.js +100 -0
- package/lib/app/services/auth/url-builder.js +23 -0
- package/lib/app/services/config/index.js +41 -0
- package/lib/app/services/devServer/app.js +76 -0
- package/lib/app/services/devServer/index.js +103 -0
- package/lib/app/services/devServer/middleware/hmacValidatorMiddleWare.js +20 -0
- package/lib/app/services/devServer/middleware/index.js +5 -0
- package/lib/app/services/devServer/tunnel/index.js +43 -0
- package/lib/app/services/devServer/tunnel/providers/cloudflare.js +364 -0
- package/lib/app/services/devServer/tunnel/providers/ngrok.js +70 -0
- package/lib/app/services/devServer/utils/index.js +5 -0
- package/lib/app/services/devServer/utils/secureCompare.js +5 -0
- package/lib/app/services/devServer/views/app.ejs +133 -0
- package/lib/app/services/extension-build/buildCheckout.js +47 -0
- package/lib/app/services/extension-build/buildFunction.js +57 -0
- package/lib/app/services/extension-build/buildTheme.js +100 -0
- package/lib/app/services/extension-build/index.js +23 -0
- package/lib/app/services/extension-build/plugins/vite-plugin-add-extension-id.js +26 -0
- package/lib/app/services/extension-build/plugins/vite-plugin-transform-extension-html.js +207 -0
- package/lib/app/services/extension-diff/index.js +132 -0
- package/lib/app/services/extension-upsert/index.js +21 -0
- package/lib/app/services/extension-upsert/upsertCheckout.js +44 -0
- package/lib/app/services/extension-upsert/upsertFunction.js +52 -0
- package/lib/app/services/extension-upsert/upsertTheme.js +113 -0
- package/lib/app/services/oss/index.js +45 -0
- package/lib/app/services/partner/index.js +52 -0
- package/lib/app/store/base-store.js +37 -0
- package/lib/app/store/config-store.js +55 -0
- package/lib/app/store/config.js +21 -0
- package/lib/app/store/index.js +14 -0
- package/lib/app/store/install-store.js +41 -0
- package/lib/app/store/sso-store.js +55 -0
- package/lib/app/utils/asyncPool.js +42 -0
- package/lib/app/utils/debug/index.js +16 -0
- package/lib/app/utils/env.js +24 -0
- package/lib/app/utils/error.js +20 -0
- package/lib/app/utils/git.js +20 -0
- package/lib/app/utils/json.js +27 -0
- package/lib/app/utils/path.js +33 -0
- package/lib/app/utils/platform.js +37 -0
- package/lib/app/utils/request/cli.js +72 -0
- package/lib/app/utils/request/debug.js +13 -0
- package/lib/app/utils/request/openapi.js +67 -0
- package/lib/app/utils/request/partnerOpenapi.js +47 -0
- package/lib/app/utils/toml.js +56 -0
- package/lib/app/utils/views/message.js +68 -0
- package/lib/app/utils/views/select.js +36 -0
- package/lib/app/utils/withTempDir.js +55 -0
- package/lib/checkout/api.js +2 -0
- package/lib/function/bin/javy/javy-arm-macos-v5.0.1 +0 -0
- package/lib/oss.js +5 -2
- package/lib/theme-extension/index.js +29 -0
- package/package.json +12 -1
- package/examples/checkout-extension/README.md +0 -19
- package/examples/checkout-extension/extension.config.js +0 -4
- package/examples/checkout-extension/extensions/add-shipping-desc/extension.json +0 -10
- package/examples/checkout-extension/extensions/add-shipping-desc/src/index.js +0 -7
- package/examples/checkout-extension/extensions/ext-1/extension.json +0 -10
- package/examples/checkout-extension/extensions/ext-1/src/content.html +0 -3
- package/examples/checkout-extension/extensions/ext-1/src/index.html +0 -5
- package/examples/checkout-extension/extensions/ext-1/src/index.js +0 -11
- package/examples/checkout-extension/extensions/ext-1/src/script.html +0 -3
- package/examples/checkout-extension/extensions/ext-1/src/style.html +0 -3
- package/examples/checkout-extension/extensions/product-list/extension.json +0 -10
- package/examples/checkout-extension/extensions/product-list/src/index.js +0 -5
- package/examples/checkout-extension/extensions/rewrite-navigate/extension.json +0 -10
- package/examples/checkout-extension/extensions/rewrite-navigate/src/content.html +0 -38
- package/examples/checkout-extension/extensions/rewrite-navigate/src/index.html +0 -5
- package/examples/checkout-extension/extensions/rewrite-navigate/src/index.js +0 -12
- package/examples/checkout-extension/extensions/rewrite-navigate/src/script.html +0 -26
- package/examples/checkout-extension/extensions/rewrite-navigate/src/style.html +0 -23
- package/examples/checkout-extension/package-lock.json +0 -121
- package/examples/checkout-extension/package.json +0 -17
- /package/lib/{app → theme-extension}/api/index.js +0 -0
- /package/lib/{app → theme-extension}/commands/build.js +0 -0
- /package/lib/{app → theme-extension}/commands/connect.js +0 -0
- /package/lib/{app → theme-extension}/commands/create.js +0 -0
- /package/lib/{app → theme-extension}/commands/deploy.js +0 -0
- /package/lib/{app → theme-extension}/commands/list.js +0 -0
- /package/lib/{app → theme-extension}/commands/release.js +0 -0
- /package/lib/{app → theme-extension}/commands/serve.js +0 -0
- /package/lib/{app → theme-extension}/commands/versions.js +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/README.md +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/extension.config.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/package.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/assets/index.css +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/assets-manifest.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/blocks/index.liquid +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/ar-SA.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/de-DE.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/en-US.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/es-ES.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/fr-FR.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/id-ID.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/it-IT.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/ja-JP.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/ko-KR.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/nl-NL.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/pl-PL.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/pt-PT.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/ru-RU.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/th-TH.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/zh-CN.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/locales/zh-TW.json +0 -0
- /package/lib/{app → theme-extension}/template/basic-app/theme-app/snippets/index.liquid +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/README.md +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/extension.config.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/package.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/assets-manifest.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/blocks/index.liquid +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/ar-SA.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/de-DE.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/en-US.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/es-ES.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/fr-FR.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/id-ID.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/it-IT.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/ja-JP.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/ko-KR.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/nl-NL.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/pl-PL.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/pt-PT.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/ru-RU.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/th-TH.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/zh-CN.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/locales/zh-TW.json +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/snippets/index.liquid +0 -0
- /package/lib/{app → theme-extension}/template/embed-app/theme-app/snippets/index_css.liquid +0 -0
- /package/lib/{app → theme-extension}/utils/config.js +0 -0
- /package/lib/{app → theme-extension}/utils/index.js +0 -0
package/README.md
CHANGED
|
@@ -378,37 +378,37 @@ $ shoplazza theme delete [--theme]
|
|
|
378
378
|
|
|
379
379
|
## app
|
|
380
380
|
|
|
381
|
-
###
|
|
381
|
+
### init
|
|
382
382
|
|
|
383
383
|
```terminal
|
|
384
|
-
$ shoplazza app
|
|
384
|
+
$ shoplazza app init
|
|
385
385
|
```
|
|
386
386
|
|
|
387
|
-
>
|
|
387
|
+
> Initialize a new Shoplazza app project.
|
|
388
388
|
|
|
389
|
-
###
|
|
389
|
+
### generate
|
|
390
390
|
|
|
391
391
|
```terminal
|
|
392
|
-
$ shoplazza app
|
|
392
|
+
$ shoplazza app generate extension
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
-
>
|
|
395
|
+
> create a new extension.
|
|
396
396
|
|
|
397
|
-
###
|
|
397
|
+
### dev
|
|
398
398
|
|
|
399
399
|
```terminal
|
|
400
|
-
$ shoplazza app
|
|
400
|
+
$ shoplazza app dev
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
-
>
|
|
403
|
+
> choose a store to test your extension app.
|
|
404
404
|
|
|
405
|
-
###
|
|
405
|
+
### deploy
|
|
406
406
|
|
|
407
407
|
```terminal
|
|
408
|
-
$ shoplazza app
|
|
408
|
+
$ shoplazza app deploy
|
|
409
409
|
```
|
|
410
410
|
|
|
411
|
-
>
|
|
411
|
+
> deploy your extension app.
|
|
412
412
|
|
|
413
413
|
## Theme Directory
|
|
414
414
|
|
package/bin/shoplazza
CHANGED
|
@@ -5,14 +5,14 @@ require('../lib/check');
|
|
|
5
5
|
const { program } = require('commander');
|
|
6
6
|
const updateNotifier = require('update-notifier');
|
|
7
7
|
const Sentry = require('@sentry/node');
|
|
8
|
-
const Tracing = require('@sentry/tracing');
|
|
9
8
|
const pkg = require('../package.json');
|
|
10
9
|
const report = require('../lib/report');
|
|
11
10
|
require('../lib/tracing');
|
|
12
11
|
|
|
13
12
|
const { makeCheckoutCommand } = require('../lib/checkout');
|
|
14
|
-
const { initThemeAppCommand } = require('../lib/
|
|
13
|
+
const { initThemeAppCommand } = require('../lib/theme-extension');
|
|
15
14
|
const { makeFunctionCommand } = require('../lib/function');
|
|
15
|
+
const { makeAppCommand } = require('../lib/app');
|
|
16
16
|
|
|
17
17
|
Sentry.init({
|
|
18
18
|
dsn: 'https://89964605acaf4db8839f2d5237396d6c@sentry.shoplazza.com/730',
|
|
@@ -31,7 +31,7 @@ updateNotifier({ pkg }).notify({
|
|
|
31
31
|
isGlobal: true
|
|
32
32
|
});
|
|
33
33
|
program.usage('[command] [options]');
|
|
34
|
-
program.option('--debug <ent>', 'debug mode')
|
|
34
|
+
program.option('--debug <ent>', 'debug mode');
|
|
35
35
|
|
|
36
36
|
program.command('version').description('Welcome to the Shoplazza CLI').action(require('../lib/commands/version'));
|
|
37
37
|
program.description('Welcome to the Shoplazza CLI').option('-v --version').action(require('../lib/commands/version'));
|
|
@@ -121,6 +121,8 @@ makeCheckoutCommand(program);
|
|
|
121
121
|
initThemeAppCommand(program);
|
|
122
122
|
// function cli
|
|
123
123
|
makeFunctionCommand(program);
|
|
124
|
+
// app cli
|
|
125
|
+
makeAppCommand(program);
|
|
124
126
|
|
|
125
127
|
program.parse(process.argv);
|
|
126
128
|
!program.args.length && program.help();
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|