shoplazza-cli 1.0.6 → 1.0.7-beta.1
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/lib/app/api/index.js +96 -0
- package/lib/app/commands/build.js +62 -35
- package/lib/app/commands/create.js +15 -14
- package/lib/app/commands/deploy.js +19 -12
- package/lib/app/commands/list.js +15 -11
- package/lib/app/commands/serve.js +103 -50
- package/lib/app/commands/versions.js +31 -23
- package/lib/app/index.js +8 -7
- package/lib/app/template/basic-app/README.md +19 -5
- package/lib/app/template/basic-app/package.json +6 -5
- package/lib/app/template/basic-app/theme-app/assets/index.css +2 -2
- package/lib/app/template/basic-app/theme-app/assets-manifest.json +1 -0
- package/lib/app/template/basic-app/theme-app/blocks/index.liquid +6 -4
- package/lib/app/template/basic-app/theme-app/snippets/index.liquid +1 -1
- package/lib/app/template/basic-app/theme-extension.config.json +4 -0
- package/lib/app/template/embed-app/README.md +19 -6
- package/lib/app/template/embed-app/package.json +6 -5
- package/lib/app/template/embed-app/theme-app/assets-manifest.json +1 -0
- package/lib/app/template/embed-app/theme-app/blocks/index.liquid +7 -4
- package/lib/app/template/embed-app/theme-app/snippets/index.liquid +1 -1
- package/lib/app/template/embed-app/theme-app/snippets/index_css.liquid +6 -0
- package/lib/app/template/embed-app/theme-extension.config.json +4 -0
- package/lib/app/utils/config.js +7 -4
- package/lib/app/utils/index.js +10 -17
- package/lib/oss.js +0 -3
- package/lib/utils.js +1 -1
- package/package.json +1 -1
- package/lib/app/api/api.js +0 -93
- package/lib/app/api/request.js +0 -72
- package/lib/app/template/basic-app/.ci/k8s.yaml +0 -4
- package/lib/app/template/basic-app/theme-app.config.json +0 -4
- package/lib/app/template/embed-app/.ci/k8s.yaml +0 -4
- package/lib/app/template/embed-app/theme-app/assets/index.css +0 -4
- package/lib/app/template/embed-app/theme-app.config.json +0 -4
package/lib/app/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
function initThemeAppCommand(_program) {
|
|
2
|
-
const program = _program.command('
|
|
2
|
+
const program = _program.command('te').alias('theme_extension').description('Shoplazza theme extension CLI');
|
|
3
3
|
|
|
4
|
-
program.command('create').description('Create a new theme
|
|
4
|
+
program.command('create').description('Create a new theme extension').action(require('./commands/create').create);
|
|
5
5
|
|
|
6
6
|
program
|
|
7
7
|
.command('serve')
|
|
8
|
-
.description('Start a local development server for the theme
|
|
8
|
+
.description('Start a local development server for the theme extension')
|
|
9
9
|
.action(require('./commands/serve').serve);
|
|
10
10
|
|
|
11
|
-
program.command('build').description('Build the theme
|
|
11
|
+
program.command('build').description('Build the theme extension for production').action(require('./commands/build').build);
|
|
12
12
|
|
|
13
13
|
program
|
|
14
14
|
.command('versions')
|
|
15
|
-
.description('List all versions of the theme
|
|
15
|
+
.description('List all versions of the theme extension')
|
|
16
16
|
.action(require('./commands/versions').versions);
|
|
17
17
|
|
|
18
|
-
program.command('deploy').description('Deploy the theme
|
|
18
|
+
program.command('deploy').description('Deploy the theme extension').action(require('./commands/deploy').deploy);
|
|
19
|
+
|
|
20
|
+
program.command('list').description('List all theme extensions').action(require('./commands/list').list);
|
|
19
21
|
|
|
20
|
-
program.command('list').description('List all theme apps').action(require('./commands/list').list);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
module.exports = {
|
|
@@ -19,7 +19,7 @@ npm install -g shoplazza-cli
|
|
|
19
19
|
创建主题插件项目模版
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
shoplazza
|
|
22
|
+
shoplazza te create
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
---
|
|
@@ -37,7 +37,7 @@ npm start
|
|
|
37
37
|
或者
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
shoplazza
|
|
40
|
+
shoplazza te serve
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
### `build`
|
|
@@ -51,7 +51,7 @@ npm run build
|
|
|
51
51
|
或者
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
shoplazza
|
|
54
|
+
shoplazza te build
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### `deploy`
|
|
@@ -65,7 +65,7 @@ npm run deploy
|
|
|
65
65
|
或者
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
shoplazza
|
|
68
|
+
shoplazza te deploy
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
### `versions`
|
|
@@ -79,6 +79,20 @@ npm run versions
|
|
|
79
79
|
或者
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
shoplazza
|
|
82
|
+
shoplazza te versions
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### `list`
|
|
86
|
+
|
|
87
|
+
查询店铺的私有主题插件列表
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run list
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
或者
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
shoplazza te list
|
|
83
97
|
```
|
|
84
98
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{projectName}}",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"description": "theme basic
|
|
4
|
+
"description": "theme basic extension",
|
|
5
5
|
"main": "null",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"start": "shoplazza
|
|
8
|
-
"build": "shoplazza
|
|
9
|
-
"deploy": "shoplazza
|
|
10
|
-
"versions": "shoplazza
|
|
7
|
+
"start": "shoplazza te serve",
|
|
8
|
+
"build": "shoplazza te build",
|
|
9
|
+
"deploy": "shoplazza te deploy",
|
|
10
|
+
"versions": "shoplazza te versions",
|
|
11
|
+
"list": "shoplazza te list"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [],
|
|
13
14
|
"author": "",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
{% use "{{projectName}}.css" %}
|
|
2
|
+
|
|
1
3
|
<div id="{{projectName}}" class="container">
|
|
2
|
-
<
|
|
4
|
+
<h1>SHOPLAZZA THEME EXTENSION</h1>
|
|
5
|
+
{% include "{{projectName}}" %}
|
|
3
6
|
</div>
|
|
4
|
-
{% include "{{projectName}}_snippet" %}
|
|
5
7
|
|
|
6
8
|
{% schema %}
|
|
7
9
|
{
|
|
8
10
|
"name": {
|
|
9
|
-
"en-US": "
|
|
10
|
-
"zh-CN": "
|
|
11
|
+
"en-US": "{{projectName}}-US",
|
|
12
|
+
"zh-CN": "{{projectName}}-CN"
|
|
11
13
|
},
|
|
12
14
|
"settings": []
|
|
13
15
|
}
|
|
@@ -19,7 +19,7 @@ npm install -g shoplazza-cli
|
|
|
19
19
|
创建主题插件项目模版
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
shoplazza
|
|
22
|
+
shoplazza te create
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
---
|
|
@@ -37,7 +37,7 @@ npm start
|
|
|
37
37
|
或者
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
shoplazza
|
|
40
|
+
shoplazza te serve
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
### `build`
|
|
@@ -51,12 +51,12 @@ npm run build
|
|
|
51
51
|
或者
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
shoplazza
|
|
54
|
+
shoplazza te build
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### `deploy`
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
部署正式版本的主题插件
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
62
|
npm run deploy
|
|
@@ -65,7 +65,7 @@ npm run deploy
|
|
|
65
65
|
或者
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
shoplazza
|
|
68
|
+
shoplazza te deploy
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
### `versions`
|
|
@@ -79,6 +79,19 @@ npm run versions
|
|
|
79
79
|
或者
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
shoplazza
|
|
82
|
+
shoplazza te versions
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
### `list`
|
|
86
|
+
|
|
87
|
+
查询店铺的私有主题插件列表
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run list
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
或者
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
shoplazza te list
|
|
97
|
+
```
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{projectName}}",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"description": "theme embed
|
|
4
|
+
"description": "theme embed extension",
|
|
5
5
|
"main": "null",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"start": "shoplazza
|
|
8
|
-
"build": "shoplazza
|
|
9
|
-
"deploy": "shoplazza
|
|
10
|
-
"versions": "shoplazza
|
|
7
|
+
"start": "shoplazza te serve",
|
|
8
|
+
"build": "shoplazza te build",
|
|
9
|
+
"deploy": "shoplazza te deploy",
|
|
10
|
+
"versions": "shoplazza te versions",
|
|
11
|
+
"list": "shoplazza te list"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [],
|
|
13
14
|
"author": "",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
{% include "{{projectName}}_css" %}
|
|
2
|
+
|
|
1
3
|
<div id="{{projectName}}" class="container">
|
|
2
|
-
<
|
|
4
|
+
<h1>SHOPLAZZA THEME EXTENSION</h1>
|
|
5
|
+
{% include "{{projectName}}" %}
|
|
3
6
|
</div>
|
|
4
|
-
{% include "{{projectName}}_snippet" %}
|
|
5
7
|
|
|
6
8
|
{% schema %}
|
|
7
9
|
{
|
|
8
10
|
"name": {
|
|
9
|
-
"en-US": "
|
|
10
|
-
"zh-CN": "
|
|
11
|
+
"en-US": "{{projectName}}-US",
|
|
12
|
+
"zh-CN": "{{projectName}}-CN"
|
|
11
13
|
},
|
|
12
14
|
"target":"body",
|
|
15
|
+
"icon":"https://cdn.shoplazza.com/oss/operation/0aee0d0cff21440e95a08ec4c560c691.svg",
|
|
13
16
|
"settings": []
|
|
14
17
|
}
|
|
15
18
|
{% endschema %}
|
package/lib/app/utils/config.js
CHANGED
|
@@ -3,7 +3,9 @@ const { get } = require('../../db/user');
|
|
|
3
3
|
|
|
4
4
|
const WORKSPACE_PATH = process.cwd();
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const THEME_APP_DIR_PATH = path.resolve(WORKSPACE_PATH, 'theme-app');
|
|
7
|
+
|
|
8
|
+
const THEME_APP_CONFIG_PATH = path.resolve(WORKSPACE_PATH, 'theme-extension.config.json')
|
|
7
9
|
|
|
8
10
|
const STORE_DOMAIN = get('store_domain');
|
|
9
11
|
|
|
@@ -11,18 +13,19 @@ const EXCHANGE_TOKEN = get('exchange_token');
|
|
|
11
13
|
|
|
12
14
|
const THEME_APP_TYPE = {
|
|
13
15
|
BASIC_APP: {
|
|
14
|
-
description: 'basic
|
|
16
|
+
description: 'basic extension(just an basic extension)',
|
|
15
17
|
templatePath: path.resolve(__dirname, '../template/basic-app')
|
|
16
18
|
},
|
|
17
19
|
EMBEDS_APP: {
|
|
18
|
-
description: 'embed
|
|
20
|
+
description: 'embed extension(embed in a theme)',
|
|
19
21
|
templatePath: path.resolve(__dirname, '../template/embed-app')
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
module.exports = {
|
|
24
26
|
WORKSPACE_PATH,
|
|
25
|
-
|
|
27
|
+
THEME_APP_DIR_PATH,
|
|
28
|
+
THEME_APP_CONFIG_PATH,
|
|
26
29
|
STORE_DOMAIN,
|
|
27
30
|
EXCHANGE_TOKEN,
|
|
28
31
|
THEME_APP_TYPE,
|
package/lib/app/utils/index.js
CHANGED
|
@@ -4,13 +4,13 @@ const chalk = require('chalk');
|
|
|
4
4
|
const AdmZip = require('adm-zip');
|
|
5
5
|
const md5 = require('md5');
|
|
6
6
|
const { table } = require('table');
|
|
7
|
-
const { WORKSPACE_PATH } = require('./config');
|
|
7
|
+
const { WORKSPACE_PATH, THEME_APP_CONFIG_PATH } = require('./config');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 通用的占位符替换函数
|
|
11
11
|
*/
|
|
12
12
|
const replacePlaceholders = async (filePath, replacements) => {
|
|
13
|
-
if (!
|
|
13
|
+
if (!fsExtra.pathExistsSync(filePath)) {
|
|
14
14
|
console.warn(`File "${filePath}" does not exist, skipping replacement.`);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -30,7 +30,7 @@ const replacePlaceholders = async (filePath, replacements) => {
|
|
|
30
30
|
* @param {string} targetName - 新的文件名
|
|
31
31
|
*/
|
|
32
32
|
const renameFile = async (filePath, targetName) => {
|
|
33
|
-
if (!
|
|
33
|
+
if (!fsExtra.pathExistsSync(filePath)) {
|
|
34
34
|
console.warn(`File "${filePath}" does not exist, skipping.`);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -43,13 +43,12 @@ const renameFile = async (filePath, targetName) => {
|
|
|
43
43
|
* @returns {Promise<string>}
|
|
44
44
|
*/
|
|
45
45
|
async function getThemeAppConfig() {
|
|
46
|
-
|
|
47
|
-
if (!(await fsExtra.pathExists(configFilePath))) {
|
|
46
|
+
if (!fsExtra.pathExistsSync(THEME_APP_CONFIG_PATH)) {
|
|
48
47
|
throw new Error(
|
|
49
|
-
`The current workspace is not a valid theme
|
|
48
|
+
`The current workspace is not a valid theme extension project, because "${WORKSPACE_PATH}" is missing the required "theme-extension.config.json" file.`
|
|
50
49
|
);
|
|
51
50
|
}
|
|
52
|
-
return fsExtra.readJson(
|
|
51
|
+
return fsExtra.readJson(THEME_APP_CONFIG_PATH);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
/**
|
|
@@ -59,7 +58,7 @@ async function getThemeAppConfig() {
|
|
|
59
58
|
async function setThemeAppConfig(config) {
|
|
60
59
|
const oldThemeAppConfig = await getThemeAppConfig();
|
|
61
60
|
const newThemeAppConfig = { ...oldThemeAppConfig, ...config };
|
|
62
|
-
await fsExtra.writeJson(
|
|
61
|
+
await fsExtra.writeJson(THEME_APP_CONFIG_PATH, newThemeAppConfig, { spaces: 2 });
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
/**
|
|
@@ -68,7 +67,7 @@ async function setThemeAppConfig(config) {
|
|
|
68
67
|
* @returns {Promise<string>} 返回基于文件夹内容的哈希值
|
|
69
68
|
*/
|
|
70
69
|
async function calculateFolderHash(dirPath) {
|
|
71
|
-
if (!
|
|
70
|
+
if (!fsExtra.pathExistsSync(dirPath)) {
|
|
72
71
|
throw new Error(chalk.red(`Calculate folder hash path does not exist: ${dirPath}`));
|
|
73
72
|
}
|
|
74
73
|
const files = await fsExtra.readdir(dirPath);
|
|
@@ -96,7 +95,7 @@ async function calculateFolderHash(dirPath) {
|
|
|
96
95
|
* @returns {Promise<Object>} 返回压缩文件的生成路径&压碎文件名
|
|
97
96
|
*/
|
|
98
97
|
async function compress(sourcePath) {
|
|
99
|
-
if (!
|
|
98
|
+
if (!fsExtra.pathExistsSync(sourcePath)) {
|
|
100
99
|
throw new Error(chalk.red(`Compress path does not exist: ${sourcePath}`));
|
|
101
100
|
}
|
|
102
101
|
const sourceName = path.basename(sourcePath);
|
|
@@ -117,7 +116,6 @@ async function compress(sourcePath) {
|
|
|
117
116
|
if (err) {
|
|
118
117
|
reject(err);
|
|
119
118
|
} else {
|
|
120
|
-
console.log(chalk.green(`Source path compressed successfully. File saved at: ${outputPath}`));
|
|
121
119
|
resolve({
|
|
122
120
|
zipPath: outputPath,
|
|
123
121
|
zipName: fileName
|
|
@@ -156,10 +154,7 @@ function compareVersions(version1, version2) {
|
|
|
156
154
|
* @param {string} filePath - 文件的绝对路径
|
|
157
155
|
* @returns {{ fileName: string, parentDirName: string }} 返回包含文件名和父目录名的对象
|
|
158
156
|
*/
|
|
159
|
-
|
|
160
|
-
if (!(await fsExtra.pathExists(filePath))) {
|
|
161
|
-
throw new Error(chalk.red(`File path does not exist: ${filePath}`));
|
|
162
|
-
}
|
|
157
|
+
function getFileInfo(filePath) {
|
|
163
158
|
const fileName = path.basename(filePath);
|
|
164
159
|
const parentDirName = path.basename(path.dirname(filePath));
|
|
165
160
|
return { fileName, parentDirName };
|
|
@@ -206,8 +201,6 @@ function renderTable(data, options) {
|
|
|
206
201
|
});
|
|
207
202
|
}
|
|
208
203
|
|
|
209
|
-
|
|
210
|
-
|
|
211
204
|
module.exports = {
|
|
212
205
|
replacePlaceholders,
|
|
213
206
|
renameFile,
|
package/lib/oss.js
CHANGED
|
@@ -3,7 +3,6 @@ const fs = require('fs');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const FormData = require('form-data');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
|
-
const loading = require('loading-cli');
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* 获取OSS上传功能,适用于上传文件到店铺的OSS服务器
|
|
@@ -67,7 +66,6 @@ function useOss(accessToken, storeDomain, storeDomainTips) {
|
|
|
67
66
|
* console.log(ossUrl); // 输出文件的 OSS 地址
|
|
68
67
|
*/
|
|
69
68
|
async function uploadOss(filePath) {
|
|
70
|
-
console.log(chalk.green('正在上传文件到OSS...',filePath));
|
|
71
69
|
let fileName = path.basename(filePath);
|
|
72
70
|
const key = 'chick-extension/' + fileName;
|
|
73
71
|
const form = new FormData();
|
|
@@ -90,7 +88,6 @@ function useOss(accessToken, storeDomain, storeDomainTips) {
|
|
|
90
88
|
});
|
|
91
89
|
return `${data.read_host}${data.read_host.endsWith('/') ? '' : '/'}${key}`;
|
|
92
90
|
});
|
|
93
|
-
loading('succeed upload').succeed();
|
|
94
91
|
return url;
|
|
95
92
|
}
|
|
96
93
|
|
package/lib/utils.js
CHANGED
|
@@ -124,7 +124,7 @@ exports.getSSOAuthUrl = (store) => {
|
|
|
124
124
|
* @param {any} [options.xxx] - 其他chokidar.watch配置项
|
|
125
125
|
* @returns {Function} - 取消监听的函数
|
|
126
126
|
*/
|
|
127
|
-
exports.
|
|
127
|
+
exports.watchWorkspace = (workspace, options = {}) => {
|
|
128
128
|
if (!fsExtra.pathExistsSync(workspace)) {
|
|
129
129
|
console.error(chalk.red(`[ERROR] "${workspace}" does not exist.`));
|
|
130
130
|
return;
|
package/package.json
CHANGED
package/lib/app/api/api.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
const { get, post, put, del, patch } = require('./request');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 获取主题列表
|
|
5
|
-
*/
|
|
6
|
-
async function getThemeList() {
|
|
7
|
-
return get('/themes');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 获取店铺私有主题插件列表
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
async function getThemeAppList() {
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
name: '主题插件1',
|
|
18
|
-
version: '1.0.0',
|
|
19
|
-
description: '主题插件1的描述'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: '主题插件2',
|
|
23
|
-
version: '2.0.0',
|
|
24
|
-
description: '主题插件2的描述'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: '主题插件3',
|
|
28
|
-
version: '3.0.0',
|
|
29
|
-
description: '主题插件3的描述'
|
|
30
|
-
}
|
|
31
|
-
];
|
|
32
|
-
// return get('/theme-extensions');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 创建主题插件
|
|
37
|
-
*/
|
|
38
|
-
async function toCreateThemeApp(data) {
|
|
39
|
-
return put('/theme-extensions', data);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 上传主题插件
|
|
44
|
-
*/
|
|
45
|
-
async function toUploadThemeApp(data) {
|
|
46
|
-
return patch(`theme-extensions/${data.appId}/dev-doctree`, data);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 获取任务状态
|
|
51
|
-
*/
|
|
52
|
-
async function getTaskStatus(data) {
|
|
53
|
-
return get(`/theme-extensions/version-tasks/${data.taskId}`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 获取主题插件版本列表
|
|
58
|
-
*/
|
|
59
|
-
async function getThemeAppVersionList(data) {
|
|
60
|
-
return [
|
|
61
|
-
{ version: '1.0.0', date: '2023-01-01', description: 'Initial release' },
|
|
62
|
-
{ version: '1.1.0', date: '2023-02-01', description: 'Added new features and bug fixes' },
|
|
63
|
-
{ version: '1.2.0', date: '2023-03-01', description: 'Fixed bugs and improved performance' },
|
|
64
|
-
{ version: '1.3.0', date: '2023-04-01', description: 'Optimized performance and added new features' },
|
|
65
|
-
{ version: '1.4.0', date: '2023-05-01', description: 'Fixed bugs and improved user experience' }
|
|
66
|
-
];
|
|
67
|
-
// return get(`/theme-extensions/:${data.appId}/versions`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 创建主题插件版本
|
|
72
|
-
*/
|
|
73
|
-
async function toCreateThemeAppVersion(data) {
|
|
74
|
-
return post(`/theme-extensions/version-tasks`, data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 部署主题插件
|
|
79
|
-
*/
|
|
80
|
-
async function toDeployThemeApp(data) {
|
|
81
|
-
return post(`theme-extensions/publications`, data);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = {
|
|
85
|
-
getThemeList,
|
|
86
|
-
getThemeAppList,
|
|
87
|
-
toCreateThemeApp,
|
|
88
|
-
toUploadThemeApp,
|
|
89
|
-
getThemeAppVersionList,
|
|
90
|
-
toCreateThemeAppVersion,
|
|
91
|
-
toDeployThemeApp,
|
|
92
|
-
getTaskStatus
|
|
93
|
-
};
|
package/lib/app/api/request.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const instance = require('../../openAPI/index');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 基础的 API 请求方法
|
|
5
|
-
* @param {string} method 请求方法 (GET, POST, PUT, DELETE)
|
|
6
|
-
* @param {string} url 请求的路径
|
|
7
|
-
* @param {Object} data 请求的数据(适用于 POST、PUT)
|
|
8
|
-
* @param {Object} params 请求的 URL 参数(适用于 GET)
|
|
9
|
-
*/
|
|
10
|
-
async function request({ method, url, data, params }) {
|
|
11
|
-
const response = await instance({
|
|
12
|
-
method,
|
|
13
|
-
url,
|
|
14
|
-
data,
|
|
15
|
-
params
|
|
16
|
-
});
|
|
17
|
-
return response; // 返回请求结果
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* GET 请求封装
|
|
22
|
-
* @param {string} url 请求的路径
|
|
23
|
-
* @param {Object} params 请求的 URL 参数
|
|
24
|
-
*/
|
|
25
|
-
async function get(url, params) {
|
|
26
|
-
return request({ method: 'get', url, params });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* POST 请求封装
|
|
31
|
-
* @param {string} url 请求的路径
|
|
32
|
-
* @param {Object} data 请求的数据
|
|
33
|
-
*/
|
|
34
|
-
async function post(url, data) {
|
|
35
|
-
return request({ method: 'post', url, data });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* PUT 请求封装
|
|
40
|
-
* @param {string} url 请求的路径
|
|
41
|
-
* @param {Object} data 请求的数据
|
|
42
|
-
*/
|
|
43
|
-
async function put(url, data) {
|
|
44
|
-
return request({ method: 'put', url, data });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* DELETE 请求封装
|
|
49
|
-
* @param {string} url 请求的路径
|
|
50
|
-
* @param {Object} params 请求的 URL 参数
|
|
51
|
-
*/
|
|
52
|
-
async function del(url, params) {
|
|
53
|
-
return request({ method: 'delete', url, params });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* PATCH 请求封装
|
|
58
|
-
* @param {string} url 请求的路径
|
|
59
|
-
* @param {Object} data 请求的数据
|
|
60
|
-
*/
|
|
61
|
-
async function patch(url, data) {
|
|
62
|
-
return request({ method: 'patch', url, data });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
module.exports = {
|
|
67
|
-
get,
|
|
68
|
-
post,
|
|
69
|
-
put,
|
|
70
|
-
del,
|
|
71
|
-
patch
|
|
72
|
-
};
|