@opentapd/tplugin-cli 0.48.1-alpha.0 → 0.49.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.
Files changed (2) hide show
  1. package/lib/serve.js +20 -14
  2. package/package.json +3 -3
package/lib/serve.js CHANGED
@@ -65,7 +65,7 @@ module.exports = async () => {
65
65
  workspaceId = session.getConfig('companyId');
66
66
  }
67
67
 
68
- if (tpluginConf.tapd.pluginEnv === 'cloud') {
68
+ if (tpluginConf.tapd.pluginEnv === 'cloud' && !tpluginConf.tapd.isPrivate) {
69
69
  // 获取当前公司信息
70
70
  const { data } = await tapdsdk.request({ url: 'open_user_app/get_company_info', params: {}, method: 'POST' });
71
71
 
@@ -330,12 +330,13 @@ class WebsocketClient {
330
330
  * initHttpClient(): 初始化 http 服务,监听请求响应数据
331
331
  */
332
332
  async initHttpClient() {
333
- let rsp; let postData = '';
334
333
  // 获取服务端口
335
334
  this.servePort = await getPort();
336
335
 
337
336
  // 启动Server,用于接收 run 服务进程的返回数据
338
337
  http.createServer((request, response) => {
338
+ let postData = '';
339
+
339
340
  request.setEncoding('utf-8');
340
341
  request.on('data', (postDataChunk) => {
341
342
  postData += postDataChunk;
@@ -343,19 +344,24 @@ class WebsocketClient {
343
344
 
344
345
  request.on('end', () => {
345
346
  if (postData) {
346
- const postObj = JSON.parse(postData);
347
- if (postObj.type === 'resource') {
348
- rsp = postObj.res;
349
- } else {
350
- rsp = JSON.stringify({
351
- code: 200,
352
- msg: '',
353
- data: postObj.res,
354
- });
347
+ try {
348
+ const postObj = JSON.parse(postData);
349
+ let rsp;
350
+ if (postObj.type === 'resource') {
351
+ rsp = postObj.res;
352
+ } else {
353
+ rsp = JSON.stringify({
354
+ code: 200,
355
+ msg: '',
356
+ data: postObj.res,
357
+ });
358
+ }
359
+ this.success(postObj.requestId, rsp);
360
+ response.end();
361
+ } catch (error) {
362
+ response.statusCode = 400;
363
+ response.end('Invalid JSON');
355
364
  }
356
- postData = '';
357
- this.success(postObj.requestId, rsp);
358
- response.end();
359
365
  }
360
366
  });
361
367
  }).listen(this.servePort);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentapd/tplugin-cli",
3
- "version": "0.48.1-alpha.0",
3
+ "version": "0.49.0",
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.32.1-alpha.0",
29
+ "@opentapd/tplugin-core": "^1.33.0",
30
30
  "address": "^1.2.2",
31
31
  "archiver": "^5.3.1",
32
32
  "axios": "^0.21.1",
@@ -78,5 +78,5 @@
78
78
  "node": ">=14.13.0"
79
79
  },
80
80
  "main": "index.js",
81
- "gitHead": "32d3a6d163a14ddf23503fe392795552975e0ad8"
81
+ "gitHead": "261428742065feb6a1594ff9111b95c86109a434"
82
82
  }