@opentapd/tplugin-cli 0.20.0-beta.8 → 0.20.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/Readme.md CHANGED
@@ -1,21 +1,13 @@
1
1
  # TAPD 托管命令行
2
2
 
3
3
 
4
- ## IDC 网络的使用
5
-
6
- ### 怎看自己是不是IDC网络
7
-
8
- 查看这个[链接](https://iwiki.woa.com/tencent/static/iwiki-editor-pro/dist/preview.html?space=&page=1227785302&id=131410&name=6997554869969258912(1).MP4&size=1160018&language=zh)
9
-
10
- ### 如果是 IDC 网路怎么办
11
-
12
4
  ```bash
13
- export TPLUGIN_ENV='idc'
14
-
15
5
  tplugin-cli logout
16
6
 
17
7
  tplugin-cli login
18
8
 
19
9
  ```
20
10
 
11
+ [快速入门](https://open.tapd.cn/document/plugin-doc/introduction/getting-started.html)
12
+
21
13
  ### 欢迎反馈
package/cli.js CHANGED
@@ -58,12 +58,14 @@ program.command('serve')
58
58
  .action(actionRunner(() => require('./lib/serve')()));
59
59
 
60
60
  // install 安装指令,安装插件到某个项目
61
- program.command('install')
62
- .description('安装测试项目')
63
- .action(actionRunner(async () => {
64
- await require('./lib/install')();
65
- console.log('');
66
- }));
61
+ if (tpluginConf.tapd.pluginEnv !== 'cloud') {
62
+ program.command('install')
63
+ .description('安装测试项目')
64
+ .action(actionRunner(async () => {
65
+ await require('./lib/install')();
66
+ console.log('');
67
+ }));
68
+ }
67
69
 
68
70
  // init 初始化插件
69
71
  program.command('init')
package/config.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "tapd": {
3
3
  "openHost": "https://open.tapd.cn",
4
- "tapdHost": "https://tapd.cn",
5
- "websocketHost": "ws://proxifer.tapd.cn/proxy",
4
+ "tapdHost": "https://www.tapd.cn",
5
+ "websocketHost": "wss://proxifer.tapd.cn/proxy",
6
6
  "apiHost": "https://api.tapd.cn",
7
7
  "upgradeWebsocketHost": "wss://upgrader.tapd.cn",
8
8
  "pluginEnv": "cloud"
package/lib/create.js CHANGED
@@ -71,22 +71,12 @@ module.exports = async (code, options) => {
71
71
  name: options.name || code,
72
72
  template: selectedTmpl.template,
73
73
  ...entranceConfigs,
74
+ async: true,
74
75
  };
75
76
 
76
77
  spinner.start('稍等片刻,正在创建...');
77
78
  // 调起创建插件
78
- const res = await create(params);
79
-
80
- if (!res || !res.status) {
81
- spinner.fail('创建插件失败');
82
- return;
83
- }
84
-
85
- if (res && res.status) {
86
- spinner.stop();
87
- // 创建完成后,拉取代码
88
- await cloneRepo(res, code);
89
- }
79
+ await create(params);
90
80
  };
91
81
 
92
82
  /**
@@ -139,7 +129,27 @@ async function getEntranceOpts() {
139
129
  // create(params): 创建插件请求
140
130
  async function create(params) {
141
131
  const { data } = await tapdsdk.request({ url: '/open_user_app/create_app', method: 'POST', params });
142
- return data;
132
+ if (!data || !data.status) {
133
+ spinner.fail('创建插件失败');
134
+ return ;
135
+ }
136
+
137
+ await getAppCreateStatus(params.code);
138
+ }
139
+
140
+ async function getAppCreateStatus(code) {
141
+ const { data } = await tapdsdk.request({ url: `/open_user_app/get_create_app_status/${code}`, method: 'GET' });
142
+ if (!data || data.data.status === '7') {
143
+ spinner.fail('创建插件失败');
144
+ return;
145
+ }
146
+ if (data.data.status === '0') {
147
+ setTimeout(() => getAppCreateStatus(code), 1000);
148
+ } else if (data.data.status === '1') {
149
+ spinner.stop();
150
+ // 创建完成后,拉取代码
151
+ await cloneRepo(data, code);
152
+ }
143
153
  }
144
154
 
145
155
  /**
package/lib/login.js CHANGED
@@ -23,18 +23,27 @@ const fs = require('fs-extra');
23
23
  module.exports = async (opts) => {
24
24
  // 当环境是工蜂的IDE时,直接发起静默登录,不需要选择登录方式
25
25
  if (opts.loginByTgit) {
26
- // 获取工蜂身份凭证
27
- const tgitTokenPath = '/home/theia/.git-credentials/credentials';
28
- const tgitToken = fs.readFileSync(tgitTokenPath, 'utf8');
29
- const matchData = tgitToken.match(/oauth2:(\S*)@git/) || [];
30
-
31
- if (matchData.length) {
32
- // 凭证中获取用户accessToken
33
- const accessToken = matchData[1];
26
+ if (!!process.env.GF_IDE_OAUTH_TOKEN) {
27
+ // 新版本直接从环境变量里拿accessToken
28
+ const accessToken = process.env.GF_IDE_OAUTH_TOKEN;
34
29
  // 使用凭证accessToken发起登录请求
35
30
  const res = await loginByTgitaccessToken(accessToken);
36
31
  // 处理登录数据
37
32
  dealLoginData(res);
33
+ } else {
34
+ // 获取工蜂身份凭证
35
+ const tgitTokenPath = '/home/theia/.git-credentials/credentials';
36
+ const tgitToken = fs.readFileSync(tgitTokenPath, 'utf8');
37
+ const matchData = tgitToken.match(/oauth2:(\S*)@git/) || [];
38
+
39
+ if (matchData.length) {
40
+ // 凭证中获取用户accessToken
41
+ const accessToken = matchData[1];
42
+ // 使用凭证accessToken发起登录请求
43
+ const res = await loginByTgitaccessToken(accessToken);
44
+ // 处理登录数据
45
+ dealLoginData(res);
46
+ }
38
47
  }
39
48
  process.exit(0);
40
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentapd/tplugin-cli",
3
- "version": "0.20.0-beta.8",
3
+ "version": "0.20.0",
4
4
  "description": "tplugin-cli",
5
5
  "bin": {
6
6
  "tplugin-cli": "index.js"