@opentapd/tplugin-cli 0.32.1-alpha.1 → 0.32.1-alpha.10
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/cli.js +11 -3
- package/lib/create.js +26 -5
- package/package.json +3 -4
- package/config.js +0 -93
package/cli.js
CHANGED
|
@@ -27,9 +27,17 @@ program.version(packageJson.version)
|
|
|
27
27
|
.usage('<command> [options]');
|
|
28
28
|
|
|
29
29
|
// create <code> 创建插件
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
30
|
+
if (tpluginConf.tapd.pluginEnv !== 'cloud') {
|
|
31
|
+
program.command('create <code>')
|
|
32
|
+
.description('通过CLI创建一个TAPD插件')
|
|
33
|
+
.option('-n, --name <name>', '插件名字')
|
|
34
|
+
.action(actionRunner((code, opts) => require('./lib/create')(code, opts)));
|
|
35
|
+
} else {
|
|
36
|
+
// 云端的code其实是name
|
|
37
|
+
program.command('create <code>')
|
|
38
|
+
.description('通过CLI创建一个TAPD插件')
|
|
39
|
+
.action(actionRunner((code, opts) => require('./lib/create')(code, opts)));
|
|
40
|
+
}
|
|
33
41
|
|
|
34
42
|
// login 登录
|
|
35
43
|
program.command('login')
|
package/lib/create.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Author: terrysxu@tencent.com
|
|
4
4
|
* Author: raferzeng@tencent.com
|
|
5
5
|
*
|
|
6
|
-
* The implementation of CLI: create <
|
|
6
|
+
* The implementation of CLI: create <code>
|
|
7
7
|
*/
|
|
8
8
|
const inquirer = require('inquirer');
|
|
9
9
|
const chalk = require('chalk');
|
|
@@ -21,16 +21,24 @@ const { downloadAndUnzip } = require('../util/tools');
|
|
|
21
21
|
const { promisify } = require('util');
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @description
|
|
25
|
-
* @param
|
|
24
|
+
* @description 根据code和option配置,创建插件
|
|
25
|
+
* @param code 唯一标识
|
|
26
|
+
* @param options 选择的创建配置
|
|
26
27
|
*/
|
|
27
|
-
module.exports = async (
|
|
28
|
+
module.exports = async (code, options) => {
|
|
28
29
|
// 初始化Session
|
|
29
30
|
const session = new Session();
|
|
30
31
|
|
|
31
32
|
// 校验登录态
|
|
32
33
|
session.checkAuth();
|
|
33
34
|
|
|
35
|
+
if (tpluginConf.tapd.pluginEnv !== 'cloud') {
|
|
36
|
+
await checkAppParams({
|
|
37
|
+
code,
|
|
38
|
+
name: options.name || code,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
spinner.start('加载应用模板...');
|
|
35
43
|
// 加载创建模板
|
|
36
44
|
const createTmpl = await getCreateTmpl();
|
|
@@ -61,17 +69,30 @@ module.exports = async (name) => {
|
|
|
61
69
|
const entranceConfigs = supportEntrances ? await selectEntrances() : {};
|
|
62
70
|
|
|
63
71
|
const params = {
|
|
64
|
-
name,
|
|
72
|
+
name: options.name || code,
|
|
65
73
|
template: selectedTmpl.template,
|
|
66
74
|
...entranceConfigs,
|
|
67
75
|
async: true,
|
|
68
76
|
};
|
|
69
77
|
|
|
78
|
+
if (tpluginConf.tapd.pluginEnv !== 'cloud') {
|
|
79
|
+
params.code = code;
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
spinner.start('稍等片刻,正在创建...');
|
|
71
83
|
// 调起创建插件
|
|
72
84
|
await create(params);
|
|
73
85
|
};
|
|
74
86
|
|
|
87
|
+
/**
|
|
88
|
+
* checkAppParams(): 检查插件参数
|
|
89
|
+
* @return array data
|
|
90
|
+
*/
|
|
91
|
+
async function checkAppParams(params) {
|
|
92
|
+
const { data } = await tapdsdk.request({ url: '/open_user_app/check_app_params', method: 'POST', params });
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
|
|
75
96
|
/**
|
|
76
97
|
* getCreateTmpl(): 获取创建模板列表
|
|
77
98
|
* @return array data
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentapd/tplugin-cli",
|
|
3
|
-
"version": "0.32.1-alpha.
|
|
3
|
+
"version": "0.32.1-alpha.10",
|
|
4
4
|
"description": "tplugin-cli",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tplugin-cli": "index.js"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"author": "",
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@opentapd/tplugin-core": "^1.20.
|
|
29
|
+
"@opentapd/tplugin-core": "^1.20.1-alpha.7",
|
|
30
30
|
"address": "^1.2.2",
|
|
31
31
|
"archiver": "^5.3.1",
|
|
32
32
|
"axios": "^0.21.1",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"scf-bin",
|
|
72
72
|
"util",
|
|
73
73
|
"cli.js",
|
|
74
|
-
"config.js",
|
|
75
74
|
"index.js",
|
|
76
75
|
"config.json"
|
|
77
76
|
],
|
|
@@ -79,5 +78,5 @@
|
|
|
79
78
|
"node": ">=14.13.0"
|
|
80
79
|
},
|
|
81
80
|
"main": "index.js",
|
|
82
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "5dc7094c7ef5f13c7dc69ec3b1818474fe2f20a3"
|
|
83
82
|
}
|
package/config.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
const env = process.env.TPLUGIN_ENV ? process.env.TPLUGIN_ENV : 'oa';
|
|
2
|
-
|
|
3
|
-
const proApiHostConfigMap = {
|
|
4
|
-
test: 'http://wolf.woa.com/tapdapi',
|
|
5
|
-
extest: 'http://apiv2.wolfex.woa.com',
|
|
6
|
-
cloudtest: 'http://apiv2.wolfcloud.woa.com',
|
|
7
|
-
ex: 'https://apiv2.tapd.tencent.com',
|
|
8
|
-
oa: 'http://apiv2.tapd.woa.com',
|
|
9
|
-
idc: 'http://oss.apiv2.tapd.woa.com',
|
|
10
|
-
cloud: 'https://api.tapd.cn',
|
|
11
|
-
};
|
|
12
|
-
const websocketHostConfigMap = {
|
|
13
|
-
test: 'ws://proxifer.wolf.woa.com/proxy',
|
|
14
|
-
extest: 'ws://proxifer.wolf.woa.com/proxy',
|
|
15
|
-
cloudtest: 'ws://proxifer.wolfcloud.woa.com/proxy',
|
|
16
|
-
ex: 'wss://proxifer.tapd.tencent.com/proxy',
|
|
17
|
-
oa: 'ws://proxifer.tapd.woa.com/proxy',
|
|
18
|
-
idc: 'ws://proxifer.tapd.woa.com/proxy',
|
|
19
|
-
cloud: 'wss://proxifer.tapd.cn/proxy',
|
|
20
|
-
};
|
|
21
|
-
const tapdHostConfigMap = {
|
|
22
|
-
test: 'https://wolf.woa.com',
|
|
23
|
-
extest: 'https://wolfex.woa.com',
|
|
24
|
-
cloudtest: 'https://wolfcloud.woa.com',
|
|
25
|
-
ex: 'https://tapd.tencent.com',
|
|
26
|
-
oa: 'https://tapd.woa.com',
|
|
27
|
-
idc: 'https://tapd.woa.com',
|
|
28
|
-
cloud: 'https://www.tapd.cn',
|
|
29
|
-
};
|
|
30
|
-
const openHostConfigMap = {
|
|
31
|
-
test: 'http://o.wolf.woa.com',
|
|
32
|
-
extest: 'http://o.wolf.woa.com',
|
|
33
|
-
cloudtest: 'http://o.wolfcloud.woa.com',
|
|
34
|
-
ex: 'https://o.tapd.tencent.com',
|
|
35
|
-
oa: 'https://o.tapd.woa.com',
|
|
36
|
-
idc: 'https://o.tapd.woa.com',
|
|
37
|
-
cloud: 'https://open.tapd.cn',
|
|
38
|
-
};
|
|
39
|
-
const upgradeWebsocketHostConfigMap = {
|
|
40
|
-
test: 'ws://upgrader.devops.tiger.oa.com',
|
|
41
|
-
extest: 'ws://upgrader.devops.tiger.oa.com',
|
|
42
|
-
cloudtest: 'ws://upgrader.wolfcloud.woa.com',
|
|
43
|
-
ex: 'wss://upgrader.tapd.tencent.com',
|
|
44
|
-
oa: 'wss://upgrader.tapd.woa.com',
|
|
45
|
-
idc: 'wss://upgrader.tapd.woa.com',
|
|
46
|
-
cloud: 'wss://upgrader.tapd.cn',
|
|
47
|
-
};
|
|
48
|
-
const pluginEnvConfigMap = {
|
|
49
|
-
test: 'oa',
|
|
50
|
-
extest: 'ex',
|
|
51
|
-
ex: 'ex',
|
|
52
|
-
cloudtest: 'cloud',
|
|
53
|
-
cloud: 'cloud',
|
|
54
|
-
oa: 'oa',
|
|
55
|
-
idc: 'oa',
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const npmRegistry = {
|
|
59
|
-
test: 'https://mirrors.tencent.com/npm/',
|
|
60
|
-
oa: 'https://mirrors.tencent.com/npm/',
|
|
61
|
-
idc: 'https://mirrors.tencent.com/npm/',
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const pipBaseURL = {
|
|
65
|
-
test: 'https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple',
|
|
66
|
-
oa: 'https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple',
|
|
67
|
-
idc: 'https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple',
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const pipExtraURL = {
|
|
71
|
-
test: 'https://mirrors.tencent.com/pypi/simple/',
|
|
72
|
-
oa: 'https://mirrors.tencent.com/pypi/simple/',
|
|
73
|
-
idc: 'https://mirrors.tencent.com/pypi/simple/',
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// 地址配置
|
|
77
|
-
module.exports = {
|
|
78
|
-
tapd: {
|
|
79
|
-
openHost: openHostConfigMap[env], // 开放平台地址
|
|
80
|
-
tapdHost: tapdHostConfigMap[env], // TAPD平台地址
|
|
81
|
-
websocketHost: websocketHostConfigMap[env], // Socket地址
|
|
82
|
-
apiHost: proApiHostConfigMap[env], // API地址
|
|
83
|
-
upgradeWebsocketHost: upgradeWebsocketHostConfigMap[env], // 热更新代理地址
|
|
84
|
-
pluginEnv: pluginEnvConfigMap[env], // 插件环境
|
|
85
|
-
},
|
|
86
|
-
npm: {
|
|
87
|
-
registry: npmRegistry[env],
|
|
88
|
-
},
|
|
89
|
-
pip: {
|
|
90
|
-
baseURL: pipBaseURL[env],
|
|
91
|
-
extralURL: pipExtraURL[env],
|
|
92
|
-
},
|
|
93
|
-
};
|