trtc-electron-sdk 11.9.606-beta.9 → 12.0.605
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 +211 -54
- package/liteav/trtc.d.ts +1 -2
- package/liteav/trtc.js +1 -2
- package/liteav/vod_player.d.ts +0 -1
- package/liteav/vod_player.js +0 -3
- package/package.json +8 -8
- package/scripts/download.js +187 -228
- package/scripts/utils.js +25 -93
package/README.md
CHANGED
|
@@ -1,64 +1,221 @@
|
|
|
1
|
-
# TRTC
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
# TRTC on Electron
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
## 跑通 DEMO
|
|
5
|
+
<span id="step1"></span>
|
|
6
|
+
### 步骤1:创建新的应用
|
|
7
|
+
1. 登录实时音视频控制台,选择【开发辅助】>【[快速跑通Demo](https://console.cloud.tencent.com/trtc/quickstart)】。
|
|
8
|
+
2. 单击【立即开始】,输入应用名称,例如`TestTRTC`,单击【创建应用】。
|
|
9
|
+
|
|
10
|
+
<span id="step2"></span>
|
|
11
|
+
### 步骤2:下载 SDK 和 Demo 源码
|
|
12
|
+
1. 鼠标移动至对应卡片,单击【[Github](https://github.com/tencentyun/TRTCSDK/tree/master/Electron)】跳转至 Github(或单击【[ZIP](http://liteavsdk-1252463788.cosgz.myqcloud.com/TXLiteAVSDK_TRTC_Electron_latest.zip)】),下载相关 SDK 及配套的 Demo 源码。
|
|
13
|
+

|
|
14
|
+
2. 下载完成后,返回实时音视频控制台,单击【我已下载,下一步】,可以查看 SDKAppID 和密钥信息。
|
|
15
|
+
|
|
16
|
+
<span id="step3"></span>
|
|
17
|
+
### 步骤3:配置 Demo 工程文件
|
|
18
|
+
1. 解压 [步骤2](#step2) 中下载的源码包。
|
|
19
|
+
2. 找到并打开 `TRTCSDK/Electron/js/GenerateTestUserSig.js` 文件。
|
|
20
|
+
3. 设置 `GenerateTestUserSig.js` 文件中的相关参数:
|
|
21
|
+
<ul><li>SDKAPPID:默认为0,请设置为实际的 SDKAppID。</li>
|
|
22
|
+
<li>SECRETKEY:默认为空字符串,请设置为实际的密钥信息。</li></ul>
|
|
23
|
+
<img src="https://main.qcloudimg.com/raw/a82e1c7c3b4edde3b9ac1326b2556147.png"/>
|
|
24
|
+
4. 返回实时音视频控制台,单击【粘贴完成,下一步】。
|
|
25
|
+
5. 单击【关闭指引,进入控制台管理应用】。
|
|
26
|
+
|
|
27
|
+
<span id="step4"></span>
|
|
28
|
+
### 步骤4:编译运行
|
|
29
|
+
|
|
30
|
+
#### Windows 平台
|
|
31
|
+
1. 下载最新版本的 [Node.js](https://nodejs.org/en/download/) 安装包,如果您的电脑是64位操作系统,请选择 Windows Installer (.msi) 64-bit,32位操作系统请选择 Windows Installer (.msi) 32-bit。
|
|
32
|
+

|
|
33
|
+
2. 打开应用程序列表中的 `Node.js command prompt`,启动命令行窗口,并将目录定位到 [步骤3](#step3) 中解压到的目标路径,并运行如下命令:
|
|
34
|
+
```
|
|
35
|
+
npm install
|
|
36
|
+
```
|
|
37
|
+

|
|
38
|
+
3. 如果您在中国大陆,可能会遭遇下载 electron 压缩包很慢的问题:
|
|
39
|
+

|
|
40
|
+
此时可以通过配置国内的镜像地址,或者从 [Github](https://github.com/electron/electron/releases) 下载对应的版本和 `SHASUMS256.txt` 文件到 `C:\Users\[您的用户名]\AppData\Local\electron\Cache` 目录下,如下图:
|
|
41
|
+

|
|
42
|
+
4. 待 npm 的依赖包都安装完成后,继续在命令行窗口运行如下命令,即可运行起 Electron Demo。
|
|
43
|
+
```
|
|
44
|
+
npm start
|
|
45
|
+
```
|
|
46
|
+

|
|
47
|
+
|
|
36
48
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
trtc_electron_arch=ia32 // only support windows
|
|
49
|
+
#### Mac OS 平台
|
|
50
|
+
1. 打开终端(Terminal)窗口,输入如下命令安装 Homebrew,如果已经安装请跳过此步骤。
|
|
40
51
|
```
|
|
52
|
+
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
53
|
+
```
|
|
54
|
+
2. 继续键入如下命令,安装 Node.js:
|
|
55
|
+
```
|
|
56
|
+
$ brew install node
|
|
57
|
+
```
|
|
58
|
+
3. 如果您在中国大陆,可能会发现使用 Homebrew 的默认地址安装 Node.js 会比较慢,此时可以考虑替换为国内镜像地址。
|
|
59
|
+
```cmd
|
|
60
|
+
$ cd `brew --repo`
|
|
61
|
+
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
|
|
62
|
+
$ brew update
|
|
63
|
+
```
|
|
64
|
+
4. 通过 cd 命令定位到 [步骤3](#step3) 中解压到的目标路径,并运行如下命令:
|
|
65
|
+
```
|
|
66
|
+
npm install
|
|
67
|
+
```
|
|
68
|
+

|
|
69
|
+
5. 待 npm 的依赖包都安装完成后,继续在命令行窗口运行如下命令,即可运行起 Electron Demo。
|
|
70
|
+
```
|
|
71
|
+
npm start
|
|
72
|
+
```
|
|
73
|
+

|
|
74
|
+
|
|
41
75
|
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
- arch: if not set, it will be `process.arch` of your installation node.js. **Only windows Supported.**
|
|
76
|
+
## 参考文档
|
|
77
|
+
https://trtc-1252463788.file.myqcloud.com/electron_sdk/docs/index.html
|
|
45
78
|
|
|
46
|
-
|
|
47
|
-
|
|
79
|
+
## 快速集成
|
|
80
|
+
|
|
81
|
+
#### step1. 通过npm下载trtc库(确认联网状态)
|
|
82
|
+
```
|
|
83
|
+
npm install trtc-electron-sdk@latest --save-dev
|
|
48
84
|
```
|
|
49
85
|
|
|
50
|
-
|
|
86
|
+
#### step2. 对接基本功能函数
|
|
51
87
|
```js
|
|
52
|
-
|
|
88
|
+
//1、引入库
|
|
89
|
+
const TRTCCloud = require('trtc-electron-sdk');
|
|
90
|
+
const {
|
|
91
|
+
TRTCVideoStreamType,
|
|
92
|
+
TRTCAppScene,
|
|
93
|
+
TRTCVideoResolution,
|
|
94
|
+
TRTCVideoResolutionMode,
|
|
95
|
+
TRTCParams
|
|
96
|
+
} = require('trtc-electron-sdk/liteav/trtc_define');
|
|
97
|
+
|
|
98
|
+
//2、构建 TRTCCloud
|
|
99
|
+
this.rtcCloud = new TRTCCloud();
|
|
100
|
+
|
|
101
|
+
//3、注册回调
|
|
102
|
+
subscribeEvents = (rtcCloud) => {
|
|
103
|
+
rtcCloud.on('onError', (errcode, errmsg) => {
|
|
104
|
+
console.info('trtc_demo: onError :' + errcode + " msg" + errmsg);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
rtcCloud.on('onEnterRoom', (elapsed) => {
|
|
108
|
+
console.info('trtc_demo: onEnterRoom elapsed:' + elapsed);
|
|
109
|
+
});
|
|
110
|
+
rtcCloud.on('onExitRoom', (reason) => {
|
|
111
|
+
console.info('trtc_demo: onExitRoom reason:' + reason);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// 注册远程视频的可用状态
|
|
115
|
+
rtcCloud.on('onUserVideoAvailable', (uid, available) => {
|
|
116
|
+
console.info('trtc_demo: onUserVideoAvailable uid:' + uid + " available:" + available);
|
|
117
|
+
if (available) {
|
|
118
|
+
let view = this.findVideoView(uid, TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
119
|
+
this.rtcCloud.startRemoteView(uid, view);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.rtcCloud.stopRemoteView(uid);
|
|
123
|
+
this.destroyVideoView(uid, TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
//.....
|
|
128
|
+
//.....
|
|
129
|
+
};
|
|
130
|
+
subscribeEvents(this.rtcCloud);
|
|
131
|
+
|
|
132
|
+
//4、进入房间
|
|
133
|
+
enterroom () {
|
|
134
|
+
//1. 进房参数
|
|
135
|
+
let param = new TRTCParams();
|
|
136
|
+
param.sdkAppId = sdkInfo.sdkappid;
|
|
137
|
+
param.roomId = parseInt(this.roomId);
|
|
138
|
+
param.userSig = userSig;
|
|
139
|
+
param.userId = this.userId;
|
|
140
|
+
param.privateMapKey = '';
|
|
141
|
+
param.businessInfo = '';
|
|
142
|
+
this.rtcCloud.enterRoom(param, TRTCAppScene.TRTCAppSceneVideoCall);
|
|
143
|
+
//2. 编码参数
|
|
144
|
+
let encparam = new TRTCVideoEncParam();
|
|
145
|
+
encparam.videoResolution = TRTCVideoResolution.TRTCVideoResolution_640_360;
|
|
146
|
+
encparam.resMode = TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape;
|
|
147
|
+
encparam.videoFps = 15;
|
|
148
|
+
encparam.videoBitrate = 550;
|
|
149
|
+
this.rtcCloud.setVideoEncoderParam(encparam);
|
|
150
|
+
//3. 打开采集和预览本地视频、采集音频
|
|
151
|
+
enableVideoCapture(true);
|
|
152
|
+
enableAudioCapture(true);
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
//5、退出房间
|
|
156
|
+
exitroom() {
|
|
157
|
+
this.rtcCloud.exitRoom();
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
//6、开启视频
|
|
161
|
+
enableVideoCapture(bEnable) {
|
|
162
|
+
if (bEnable) {
|
|
163
|
+
let view = this.findView("local", TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
164
|
+
this.rtcCloud.startLocalPreview(view);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this.rtcCloud.stopLocalPreview();
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
//7、开启音频
|
|
172
|
+
enableAudioCapture(bEnable) {
|
|
173
|
+
if (bEnable) {
|
|
174
|
+
this.rtcCloud.startLocalAudio();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this.rtcCloud.stopLocalAudio();
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
//8、找个DOM结点,作为视频显示的view
|
|
182
|
+
findVideoView(uid, streamtype) {
|
|
183
|
+
let key = uid + String(streamtype);
|
|
184
|
+
var userVideoEl = document.getElementById(key);
|
|
185
|
+
if (!userVideoEl) {
|
|
186
|
+
userVideoEl = document.createElement('div');
|
|
187
|
+
userVideoEl.id = key;
|
|
188
|
+
userVideoEl.classList.add('video_view');
|
|
189
|
+
document.querySelector("#video_wrap").appendChild(userVideoEl);
|
|
190
|
+
}
|
|
191
|
+
return userVideoEl;
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
//9、在视频退出时,清掉一个DOM结点
|
|
195
|
+
destroyVideoView(uid, streamtype) {
|
|
196
|
+
let key = uid + String(streamtype);
|
|
197
|
+
var userVideoEl = document.getElementById(key);
|
|
198
|
+
if (userVideoEl) {
|
|
199
|
+
document.querySelector("#video_wrap").removeChild(userVideoEl);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
53
202
|
|
|
54
|
-
const rtcCloud = TRTCCloud.getTRTCShareInstance();
|
|
55
|
-
// Obtain the SDK version
|
|
56
|
-
const version = rtcCloud.getSDKVersion();
|
|
57
203
|
```
|
|
58
204
|
|
|
59
|
-
##
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
205
|
+
## 常见问题
|
|
206
|
+
|
|
207
|
+
### 1. 查看密钥时只能获取公钥和私钥信息,要如何获取密钥?
|
|
208
|
+
TRTC SDK 6.6 版本(2019年08月)开始启用新的签名算法 HMAC-SHA256。在此之前已创建的应用,需要先升级签名算法才能获取新的加密密钥。如不升级,您也可以继续使用 [老版本算法 ECDSA-SHA256](https://cloud.tencent.com/document/product/647/17275#.E8.80.81.E7.89.88.E6.9C.AC.E7.AE.97.E6.B3.95)。
|
|
209
|
+
|
|
210
|
+
升级操作:
|
|
211
|
+
1. 登录 [实时音视频控制台](https://console.cloud.tencent.com/trtc)。
|
|
212
|
+
2. 在左侧导航栏选择【应用管理】,单击目标应用所在行的【应用信息】。
|
|
213
|
+
3. 选择【快速上手】页签,单击【第二步 获取签发UserSig的密钥】区域的【点此升级】。
|
|
214
|
+
|
|
215
|
+
### 2. 两台设备同时运行 Demo,为什么看不到彼此的画面?
|
|
216
|
+
请确保两台设备在运行 Demo 时使用的是不同的 UserID,TRTC 不支持同一个 UserID (除非 SDKAppID 不同)在两个设备同时使用。
|
|
217
|
+
|
|
218
|
+

|
|
219
|
+
|
|
220
|
+
### 3. 防火墙有什么限制?
|
|
221
|
+
由于 SDK 使用 UDP 协议进行音视频传输,所以对 UDP 有拦截的办公网络下无法使用,如遇到类似问题,请参考文档:[应对公司防火墙限制](https://cloud.tencent.com/document/product/647/34399)。
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -632,12 +632,11 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
632
632
|
*/
|
|
633
633
|
handleOnLocalRecordComplete(errCode: number, storagePath: string): void;
|
|
634
634
|
/**
|
|
635
|
-
*
|
|
635
|
+
* 系统音频采集回调,SDK在采集失败时会抛出该事件回调,用于通知错误信息
|
|
636
636
|
*
|
|
637
637
|
* @event TRTCCallback#onSystemAudioLoopbackError
|
|
638
638
|
*
|
|
639
639
|
* @param {Number} errCode - 错误码含义
|
|
640
|
-
* - 0 :代表启动成功;
|
|
641
640
|
* - ERR_AUDIO_PLUGIN_START_FAIL(-1330) :开启系统声音录制失败,例如音频驱动插件不可用
|
|
642
641
|
* - ERR_AUDIO_PLUGIN_INSTALL_NOT_AUTHORIZED (-1331) :未授权安装音频驱动插件
|
|
643
642
|
* - ERR_AUDIO_PLUGIN_INSTALL_FAILED (-1332) :安装音频驱动插件失败
|
package/liteav/trtc.js
CHANGED
|
@@ -1312,12 +1312,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1312
1312
|
//
|
|
1313
1313
|
/////////////////////////////////////////////////////////////////////////////////
|
|
1314
1314
|
/**
|
|
1315
|
-
*
|
|
1315
|
+
* 系统音频采集回调,SDK在采集失败时会抛出该事件回调,用于通知错误信息
|
|
1316
1316
|
*
|
|
1317
1317
|
* @event TRTCCallback#onSystemAudioLoopbackError
|
|
1318
1318
|
*
|
|
1319
1319
|
* @param {Number} errCode - 错误码含义
|
|
1320
|
-
* - 0 :代表启动成功;
|
|
1321
1320
|
* - ERR_AUDIO_PLUGIN_START_FAIL(-1330) :开启系统声音录制失败,例如音频驱动插件不可用
|
|
1322
1321
|
* - ERR_AUDIO_PLUGIN_INSTALL_NOT_AUTHORIZED (-1331) :未授权安装音频驱动插件
|
|
1323
1322
|
* - ERR_AUDIO_PLUGIN_INSTALL_FAILED (-1332) :安装音频驱动插件失败
|
package/liteav/vod_player.d.ts
CHANGED
package/liteav/vod_player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trtc-electron-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.605",
|
|
4
4
|
"description": "trtc electron sdk",
|
|
5
5
|
"main": "./liteav/trtc.js",
|
|
6
6
|
"types": "./liteav/trtc.d.ts",
|
|
@@ -38,25 +38,25 @@
|
|
|
38
38
|
"typescript": "^4.0.3"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"install": "npm run download
|
|
41
|
+
"install": "npm run download",
|
|
42
42
|
"download": "node ./scripts/download.js",
|
|
43
43
|
"postinstall": "node ./scripts/postinstall.js",
|
|
44
|
-
"dev": "npm run build && npm run doc && npm run copy:sdk
|
|
44
|
+
"dev": "npm run build && npm run doc && npm run copy:sdk",
|
|
45
45
|
"copy:sdk": "rimraf ./build && node ./scripts/copy-sdk.js",
|
|
46
|
-
"build": "npm run build:types && npm run build:js && npm run copy:types && npm run copy:sdk
|
|
46
|
+
"build": "npm run build:types && npm run build:js && npm run copy:types && npm run copy:sdk",
|
|
47
47
|
"build:types": "rimraf ./types && tsc -p dtsconfig.json",
|
|
48
48
|
"build:js": "rimraf ./liteav && tsc -p tsconfig.json",
|
|
49
49
|
"copy:types": "node ./scripts/copy-types.js",
|
|
50
|
-
"watch": "npm run dev && npm run watch:js
|
|
50
|
+
"watch": "npm run dev && npm run watch:js",
|
|
51
51
|
"watch:types": "rimraf ./types && tsc --watch -p dtsconfig.json",
|
|
52
52
|
"watch:js": "rimraf ./liteav && tsc --watch -p tsconfig.json",
|
|
53
53
|
"publish_doc": "node ./scripts/publish-doc.js",
|
|
54
|
-
"doc": "npm run doc:clean && npm run doc:build
|
|
55
|
-
"doc:build": "npm run doc:build-zh && npm run doc:build-en
|
|
54
|
+
"doc": "npm run doc:clean && npm run doc:build",
|
|
55
|
+
"doc:build": "npm run doc:build-zh && npm run doc:build-en",
|
|
56
56
|
"doc:build-zh": "jsdoc -c ./jsdoc/jsdoc_zh.json && node ./jsdoc/fix-doc_zh.js",
|
|
57
57
|
"doc:build-en": "jsdoc -c ./jsdoc/jsdoc_en.json && node ./jsdoc/fix-doc_en.js",
|
|
58
58
|
"doc:clean": "node ./jsdoc/clean-doc.js",
|
|
59
|
-
"prerelease": "npm run build && npm run doc && node ./scripts/prerelase.js
|
|
59
|
+
"prerelease": "npm run build && npm run doc && node ./scripts/prerelase.js",
|
|
60
60
|
"publish_npm": "node scripts/publish-npm.js"
|
|
61
61
|
},
|
|
62
62
|
"repository": {
|
package/scripts/download.js
CHANGED
|
@@ -1,244 +1,203 @@
|
|
|
1
|
-
const download = require(
|
|
2
|
-
const path = require(
|
|
3
|
-
const fs = require(
|
|
4
|
-
const rimraf = require(
|
|
5
|
-
const signale = require(
|
|
6
|
-
const {
|
|
1
|
+
const download = require('download');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const rimraf = require('rimraf');
|
|
5
|
+
const signale = require('signale');
|
|
6
|
+
const { exec } = require('child_process');
|
|
7
|
+
const { HttpsProxyAgent } = require('hpagent');
|
|
7
8
|
|
|
8
9
|
const currentPath = process.cwd();
|
|
9
|
-
const pathFlagValue = `packages${
|
|
10
|
-
process.platform === "win32" ? "\\" : "/"
|
|
11
|
-
}trtc-electron-sdk`;
|
|
10
|
+
const pathFlagValue = `packages${process.platform === "win32" ? "\\" : "/"}trtc-electron-sdk`;
|
|
12
11
|
if (currentPath.indexOf(pathFlagValue) !== -1) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
16
|
-
return;
|
|
12
|
+
signale.info("trtc-electron-sdk: development mode, skip native sdk lib download");
|
|
13
|
+
return;
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} = require("./utils");
|
|
29
|
-
const { Platform } = require("./constant");
|
|
17
|
+
readCliArgv,
|
|
18
|
+
readArgvFromNpmEnv,
|
|
19
|
+
detectOS,
|
|
20
|
+
detectOwnVersion,
|
|
21
|
+
detectOwnName,
|
|
22
|
+
readProxyUrlFromEnv,
|
|
23
|
+
} = require('./utils');
|
|
24
|
+
const { Platform } = require('./constant');
|
|
30
25
|
|
|
31
26
|
const buildDownloadInfo = () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
downloadUrl: `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${osLabel}-${version}.zip`,
|
|
56
|
-
name,
|
|
57
|
-
version,
|
|
58
|
-
archType: configArgv.arch,
|
|
59
|
-
};
|
|
27
|
+
const configArgv = Object.assign({
|
|
28
|
+
arch: process.arch,
|
|
29
|
+
platform: process.platform,
|
|
30
|
+
}, readCliArgv(), readArgvFromNpmEnv());
|
|
31
|
+
|
|
32
|
+
// build os label
|
|
33
|
+
const osLabel = detectOS(configArgv.arch, configArgv.platform);
|
|
34
|
+
|
|
35
|
+
// build version label
|
|
36
|
+
const { version } = detectOwnVersion();
|
|
37
|
+
signale.info('buildDownloadInfo version=', version);
|
|
38
|
+
|
|
39
|
+
const name = detectOwnName();
|
|
40
|
+
signale.info('buildDownloadInfo name=', name);
|
|
41
|
+
|
|
42
|
+
// generate download url
|
|
43
|
+
return {
|
|
44
|
+
platform: osLabel,
|
|
45
|
+
downloadUrl: `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${osLabel}-${version}.zip`,
|
|
46
|
+
name,
|
|
47
|
+
version,
|
|
48
|
+
archType: configArgv.arch
|
|
49
|
+
};
|
|
60
50
|
};
|
|
61
51
|
|
|
62
52
|
const main = () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
strip: 0,
|
|
92
|
-
extract: true,
|
|
93
|
-
};
|
|
94
|
-
const proxyUrl = readProxyUrlFromEnv(downloadUrl);
|
|
95
|
-
if (proxyUrl) {
|
|
96
|
-
downloadOptions.agent = {
|
|
97
|
-
https: new HttpsProxyAgent({
|
|
98
|
-
keepAlive: true,
|
|
99
|
-
keepAliveMsecs: 1000,
|
|
100
|
-
maxSockets: 256,
|
|
101
|
-
maxFreeSockets: 256,
|
|
102
|
-
scheduling: "lifo",
|
|
103
|
-
proxy: proxyUrl,
|
|
104
|
-
}),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
download(downloadUrl, outputDir, downloadOptions)
|
|
108
|
-
.then(() => {
|
|
109
|
-
signale.success(`Download finished - ${platform}`);
|
|
110
|
-
|
|
111
|
-
fs.copySync(
|
|
112
|
-
path.join(outputDir, "./build/Release"),
|
|
113
|
-
path.join(buildDir, "Release")
|
|
114
|
-
);
|
|
115
|
-
signale.success(`copy success! - ${platform}`);
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
platform === Platform.WINDOWS32 ||
|
|
119
|
-
platform === Platform.WINDOWS64
|
|
120
|
-
) {
|
|
121
|
-
// windows 下
|
|
122
|
-
rimraf.sync(outputDir);
|
|
123
|
-
} else if (
|
|
124
|
-
platform === Platform.MACOS ||
|
|
125
|
-
platform === Platform.MACOS_ARM
|
|
126
|
-
) {
|
|
127
|
-
// mac 下
|
|
128
|
-
const arch = archType;
|
|
129
|
-
fs.copySync(
|
|
130
|
-
path.join(outputDir, "./build/Release/trtc_electron_sdk.node"),
|
|
131
|
-
path.join(buildDir, "Release", arch, "trtc_electron_sdk.node")
|
|
132
|
-
);
|
|
133
|
-
fs.copySync(
|
|
134
|
-
path.join(outputDir, "./build/mac-framework", arch),
|
|
135
|
-
path.join(buildDir, "mac-framework", arch)
|
|
136
|
-
);
|
|
137
|
-
signale.success(`copy success! - mac ${arch}`, "\n");
|
|
138
|
-
|
|
139
|
-
let anotherPlatform, anotherArch;
|
|
140
|
-
if (arch === "x64") {
|
|
141
|
-
// download arm64
|
|
142
|
-
anotherPlatform = Platform.MACOS_ARM;
|
|
143
|
-
anotherArch = "arm64";
|
|
144
|
-
} else {
|
|
145
|
-
// arch = arm64, download x64
|
|
146
|
-
anotherPlatform = Platform.MACOS;
|
|
147
|
-
anotherArch = "x64";
|
|
148
|
-
}
|
|
149
|
-
const anotherDownloadUrl = `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${anotherPlatform}-${version}.zip`;
|
|
150
|
-
signale.info("Download Url =", anotherDownloadUrl, "\n");
|
|
151
|
-
signale.pending(
|
|
152
|
-
`Downloading C++ addon Electron SDK... ${anotherArch}\n`
|
|
153
|
-
);
|
|
154
|
-
download(anotherDownloadUrl, path.join(outputDir, anotherPlatform), {
|
|
155
|
-
strip: 0,
|
|
156
|
-
extract: true,
|
|
157
|
-
})
|
|
158
|
-
.then(() => {
|
|
159
|
-
signale.success(`Download finished - mac ${anotherArch}`);
|
|
160
|
-
|
|
161
|
-
fs.copySync(
|
|
162
|
-
path.join(
|
|
163
|
-
outputDir,
|
|
164
|
-
anotherPlatform,
|
|
165
|
-
"/build/Release/trtc_electron_sdk.node"
|
|
166
|
-
),
|
|
167
|
-
path.join(
|
|
168
|
-
buildDir,
|
|
169
|
-
"Release",
|
|
170
|
-
anotherArch,
|
|
171
|
-
"trtc_electron_sdk.node"
|
|
172
|
-
)
|
|
173
|
-
);
|
|
174
|
-
fs.copySync(
|
|
175
|
-
path.join(
|
|
176
|
-
outputDir,
|
|
177
|
-
anotherPlatform,
|
|
178
|
-
"/build/mac-framework",
|
|
179
|
-
anotherArch
|
|
180
|
-
),
|
|
181
|
-
path.join(buildDir, "mac-framework", anotherArch)
|
|
182
|
-
);
|
|
183
|
-
signale.success(`copy success! - mac ${anotherArch}`);
|
|
184
|
-
|
|
185
|
-
rimraf.sync(outputDir);
|
|
186
|
-
})
|
|
187
|
-
.catch((err) => {
|
|
188
|
-
signale.fatal(`download error! - mac ${anotherPlatform}`, err);
|
|
189
|
-
});
|
|
190
|
-
} else if (
|
|
191
|
-
platform === Platform.LINUX_X64 ||
|
|
192
|
-
platform === Platform.LINUX_ARM64
|
|
193
|
-
) {
|
|
194
|
-
// Linux 下
|
|
195
|
-
const arch = process.arch;
|
|
196
|
-
fs.copySync(
|
|
197
|
-
path.join(outputDir, "./build/Release"),
|
|
198
|
-
path.join(buildDir, "Release", arch)
|
|
199
|
-
);
|
|
200
|
-
signale.success(`copy success! - linux ${arch}`, "\n");
|
|
201
|
-
|
|
202
|
-
let anotherPlatform, anotherArch;
|
|
203
|
-
if (arch === "x64") {
|
|
204
|
-
// download arm64
|
|
205
|
-
anotherPlatform = Platform.LINUX_ARM64;
|
|
206
|
-
anotherArch = "arm64";
|
|
207
|
-
} else {
|
|
208
|
-
// arch = arm64, download x64
|
|
209
|
-
anotherPlatform = Platform.LINUX_X64;
|
|
210
|
-
anotherArch = "x64";
|
|
211
|
-
}
|
|
212
|
-
const anotherDownloadUrl = `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${anotherPlatform}-${version}.zip`;
|
|
213
|
-
signale.info("Download Url =", anotherDownloadUrl, "\n");
|
|
214
|
-
signale.pending(
|
|
215
|
-
`Downloading C++ addon Electron SDK... ${anotherArch}\n`
|
|
216
|
-
);
|
|
217
|
-
download(anotherDownloadUrl, path.join(outputDir, anotherPlatform), {
|
|
53
|
+
const {
|
|
54
|
+
platform,
|
|
55
|
+
downloadUrl,
|
|
56
|
+
name,
|
|
57
|
+
version,
|
|
58
|
+
archType
|
|
59
|
+
} = buildDownloadInfo();
|
|
60
|
+
|
|
61
|
+
const outputDir = path.join(__dirname, '../temp');
|
|
62
|
+
const buildDir = path.join(__dirname, '../build');
|
|
63
|
+
|
|
64
|
+
rimraf.sync(outputDir);
|
|
65
|
+
rimraf(buildDir, err => {
|
|
66
|
+
if (err) {
|
|
67
|
+
signale.fatal(err);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// print download info
|
|
72
|
+
signale.info('removeDir =', buildDir);
|
|
73
|
+
signale.info('outputDir =', outputDir);
|
|
74
|
+
|
|
75
|
+
signale.info('Package Version =', version);
|
|
76
|
+
signale.info('Platform =', platform);
|
|
77
|
+
signale.info('Download Url =', downloadUrl, '\n');
|
|
78
|
+
|
|
79
|
+
signale.pending('Downloading C++ addon Electron SDK...\n');
|
|
80
|
+
const downloadOptions = {
|
|
218
81
|
strip: 0,
|
|
219
|
-
extract: true
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
} else {
|
|
235
|
-
signale.warn(`Not supported platform: ${platform}`);
|
|
82
|
+
extract: true
|
|
83
|
+
};
|
|
84
|
+
const proxyUrl = readProxyUrlFromEnv(downloadUrl);
|
|
85
|
+
if (proxyUrl) {
|
|
86
|
+
downloadOptions.agent = {
|
|
87
|
+
https: new HttpsProxyAgent({
|
|
88
|
+
keepAlive: true,
|
|
89
|
+
keepAliveMsecs: 1000,
|
|
90
|
+
maxSockets: 256,
|
|
91
|
+
maxFreeSockets: 256,
|
|
92
|
+
scheduling: 'lifo',
|
|
93
|
+
proxy: proxyUrl
|
|
94
|
+
})
|
|
95
|
+
}
|
|
236
96
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
97
|
+
download(downloadUrl, outputDir, downloadOptions).then(() => {
|
|
98
|
+
signale.success(`Download finished - ${platform}`);
|
|
99
|
+
|
|
100
|
+
fs.copySync(
|
|
101
|
+
path.join(outputDir, './build/Release'),
|
|
102
|
+
path.join(buildDir, 'Release')
|
|
103
|
+
);
|
|
104
|
+
signale.success(`copy success! - ${platform}`);
|
|
105
|
+
|
|
106
|
+
if (platform === Platform.WINDOWS32 || platform === Platform.WINDOWS64) {
|
|
107
|
+
// windows 下
|
|
108
|
+
rimraf.sync(outputDir);
|
|
109
|
+
} else if (platform === 'mac' || platform === 'mac-arm64') {
|
|
110
|
+
// mac 下
|
|
111
|
+
const arch = archType;
|
|
112
|
+
fs.copySync(
|
|
113
|
+
path.join(outputDir, './build/Release/trtc_electron_sdk.node'),
|
|
114
|
+
path.join(buildDir, 'Release', arch, 'trtc_electron_sdk.node')
|
|
115
|
+
);
|
|
116
|
+
fs.copySync(
|
|
117
|
+
path.join(outputDir, './build/mac-framework', arch),
|
|
118
|
+
path.join(buildDir, 'mac-framework', arch)
|
|
119
|
+
);
|
|
120
|
+
signale.success(`copy success! - mac ${arch}`, '\n');
|
|
121
|
+
|
|
122
|
+
let anotherPlatform, anotherArch;
|
|
123
|
+
if (arch === 'x64') {
|
|
124
|
+
// download arm64
|
|
125
|
+
anotherPlatform = Platform.MACOS_ARM;
|
|
126
|
+
anotherArch = 'arm64';
|
|
127
|
+
} else {
|
|
128
|
+
// arch = arm64, download x64
|
|
129
|
+
anotherPlatform = Platform.MACOS;
|
|
130
|
+
anotherArch = 'x64';
|
|
131
|
+
}
|
|
132
|
+
const anotherDownloadUrl = `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${anotherPlatform}-${version}.zip`;
|
|
133
|
+
signale.info('Download Url =', anotherDownloadUrl, '\n');
|
|
134
|
+
signale.pending(`Downloading C++ addon Electron SDK... ${anotherArch}\n`);
|
|
135
|
+
download(anotherDownloadUrl, path.join(outputDir, anotherPlatform), {
|
|
136
|
+
strip: 0,
|
|
137
|
+
extract: true
|
|
138
|
+
})
|
|
139
|
+
.then(() => {
|
|
140
|
+
signale.success(`Download finished - mac ${anotherArch}`);
|
|
141
|
+
|
|
142
|
+
fs.copySync(
|
|
143
|
+
path.join(outputDir, anotherPlatform, '/build/Release/trtc_electron_sdk.node'),
|
|
144
|
+
path.join(buildDir, 'Release', anotherArch, 'trtc_electron_sdk.node')
|
|
145
|
+
);
|
|
146
|
+
fs.copySync(
|
|
147
|
+
path.join(outputDir, anotherPlatform, '/build/mac-framework', anotherArch),
|
|
148
|
+
path.join(buildDir, 'mac-framework', anotherArch)
|
|
149
|
+
);
|
|
150
|
+
signale.success(`copy success! - mac ${anotherArch}`);
|
|
151
|
+
|
|
152
|
+
rimraf.sync(outputDir);
|
|
153
|
+
})
|
|
154
|
+
.catch(err => {
|
|
155
|
+
signale.fatal(`download error! - mac ${anotherPlatform}`, err);
|
|
156
|
+
});
|
|
157
|
+
} else if (platform === 'linux-x64' || platform === 'linux-arm64') {
|
|
158
|
+
// Linux 下
|
|
159
|
+
const arch = process.arch;
|
|
160
|
+
fs.copySync(
|
|
161
|
+
path.join(outputDir, './build/Release'),
|
|
162
|
+
path.join(buildDir, 'Release', arch)
|
|
163
|
+
);
|
|
164
|
+
signale.success(`copy success! - linux ${arch}`, '\n');
|
|
165
|
+
|
|
166
|
+
let anotherPlatform, anotherArch;
|
|
167
|
+
if (arch === 'x64') {
|
|
168
|
+
// download arm64
|
|
169
|
+
anotherPlatform = Platform.LINUX_ARM64;
|
|
170
|
+
anotherArch = 'arm64';
|
|
171
|
+
} else {
|
|
172
|
+
// arch = arm64, download x64
|
|
173
|
+
anotherPlatform = Platform.LINUX_X64;
|
|
174
|
+
anotherArch = 'x64';
|
|
175
|
+
}
|
|
176
|
+
const anotherDownloadUrl = `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${anotherPlatform}-${version}.zip`;
|
|
177
|
+
signale.info('Download Url =', anotherDownloadUrl, '\n');
|
|
178
|
+
signale.pending(`Downloading C++ addon Electron SDK... ${anotherArch}\n`);
|
|
179
|
+
download(anotherDownloadUrl, path.join(outputDir, anotherPlatform), {
|
|
180
|
+
strip: 0,
|
|
181
|
+
extract: true
|
|
182
|
+
}).then(() => {
|
|
183
|
+
signale.success(`Download finished - linux ${anotherArch}`);
|
|
184
|
+
fs.copySync(
|
|
185
|
+
path.join(outputDir, anotherPlatform, '/build/Release'),
|
|
186
|
+
path.join(buildDir, 'Release', anotherArch)
|
|
187
|
+
);
|
|
188
|
+
signale.success(`copy success! - linux ${anotherArch}`);
|
|
189
|
+
|
|
190
|
+
rimraf.sync(outputDir);
|
|
191
|
+
}).catch(err => {
|
|
192
|
+
signale.fatal(`download error! - linux ${anotherPlatform}`, err);
|
|
193
|
+
})
|
|
194
|
+
} else {
|
|
195
|
+
signale.warn(`Not supported platform: ${platform}`);
|
|
196
|
+
}
|
|
197
|
+
}).catch(err => {
|
|
198
|
+
signale.fatal(`Failed! Download error - ${platform}`, err);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
242
201
|
};
|
|
243
202
|
|
|
244
203
|
main();
|
package/scripts/utils.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utils for command line tools
|
|
3
3
|
*/
|
|
4
|
-
const semver = require(
|
|
5
|
-
const pkg = require(
|
|
6
|
-
const path = require("path");
|
|
4
|
+
const semver = require('semver');
|
|
5
|
+
const pkg = require('../package.json');
|
|
7
6
|
|
|
8
|
-
const { Platform } = require(
|
|
9
|
-
const { platform, arch } = require("os");
|
|
7
|
+
const { Platform } = require('./constant');
|
|
10
8
|
|
|
11
|
-
module.exports.readCliArgv = function
|
|
9
|
+
module.exports.readCliArgv = function() {
|
|
12
10
|
const cliArgv = process.argv;
|
|
13
11
|
const newArgv = {};
|
|
14
12
|
let tmp = [];
|
|
15
|
-
console.log(
|
|
16
|
-
for (let i = 0, len = cliArgv.length; i < len; i++) {
|
|
13
|
+
console.log('readCliArgv',cliArgv);
|
|
14
|
+
for (let i = 0, len = cliArgv.length ; i < len ; i++) {
|
|
17
15
|
if (i === 0) {
|
|
18
16
|
newArgv.nodeDir = cliArgv[i];
|
|
19
17
|
continue;
|
|
@@ -22,21 +20,21 @@ module.exports.readCliArgv = function () {
|
|
|
22
20
|
newArgv.scriptDir = cliArgv[i];
|
|
23
21
|
continue;
|
|
24
22
|
}
|
|
25
|
-
tmp = cliArgv[i].replace(
|
|
23
|
+
tmp = cliArgv[i].replace('--','').split('=');
|
|
26
24
|
newArgv[tmp[0]] = tmp[1];
|
|
27
25
|
tmp = [];
|
|
28
26
|
}
|
|
29
27
|
return newArgv;
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
module.exports.readProxyUrlFromEnv = function
|
|
33
|
-
if (downloadUrl.indexOf(
|
|
34
|
-
return process.env.https_proxy ||
|
|
30
|
+
module.exports.readProxyUrlFromEnv = function(downloadUrl) {
|
|
31
|
+
if (downloadUrl.indexOf('https') === 0) {
|
|
32
|
+
return process.env.https_proxy || ''
|
|
35
33
|
}
|
|
36
|
-
return process.env.http_proxy ||
|
|
37
|
-
}
|
|
34
|
+
return process.env.http_proxy || '';
|
|
35
|
+
}
|
|
38
36
|
|
|
39
|
-
module.exports.readArgvFromNpmEnv = function
|
|
37
|
+
module.exports.readArgvFromNpmEnv = function() {
|
|
40
38
|
const result = {};
|
|
41
39
|
if (process.env.npm_config_trtc_electron_arch) {
|
|
42
40
|
result.arch = process.env.npm_config_trtc_electron_arch;
|
|
@@ -47,89 +45,25 @@ module.exports.readArgvFromNpmEnv = function () {
|
|
|
47
45
|
return result;
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
module.exports.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let PkgJsonDir = INIT_CWD.join("/") + "/package.json";
|
|
56
|
-
try {
|
|
57
|
-
require(PkgJsonDir);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
pnpm_PkgJsonDir = pnpm_PkgJsonDir.split("/");
|
|
60
|
-
pnpm_PkgJsonDir = pnpm_PkgJsonDir.splice(0, pnpm_PkgJsonDir.length - 5);
|
|
61
|
-
PkgJsonDir = pnpm_PkgJsonDir.join("/") + "/package.json";
|
|
62
|
-
}
|
|
63
|
-
const { trtc_electron } = require(PkgJsonDir);
|
|
64
|
-
console.log(
|
|
65
|
-
"INIT_CWD",
|
|
66
|
-
INIT_CWD,
|
|
67
|
-
"PkgJsonDir",
|
|
68
|
-
PkgJsonDir,
|
|
69
|
-
"trtc_electron",
|
|
70
|
-
trtc_electron
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
if (!trtc_electron) {
|
|
74
|
-
return {};
|
|
75
|
-
}
|
|
76
|
-
const { platform, arch } = trtc_electron;
|
|
77
|
-
const result = {};
|
|
78
|
-
if (platform) {
|
|
79
|
-
result.platform = platform;
|
|
80
|
-
}
|
|
81
|
-
if (arch) {
|
|
82
|
-
result.arch = arch;
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
module.exports.detectConfigArgv = function (configArgv) {
|
|
88
|
-
const localArch = process.arch;
|
|
89
|
-
const localPlatform = process.platform;
|
|
90
|
-
if (Object.prototype.toString.call(configArgv) === "[object Object]") {
|
|
91
|
-
const { platform, arch } = configArgv;
|
|
92
|
-
if (platform === "darwin") {
|
|
93
|
-
if (arch !== "x64" && arch !== "arm64") {
|
|
94
|
-
configArgv.arch = localArch;
|
|
95
|
-
}
|
|
96
|
-
} else if (platform === "win32") {
|
|
97
|
-
if (arch !== "ia32" && arch !== "x64") {
|
|
98
|
-
configArgv.arch = localArch;
|
|
99
|
-
}
|
|
100
|
-
} else if (platform === "linux") {
|
|
101
|
-
if (arch !== "x64" && arch !== "arm64") {
|
|
102
|
-
configArgv.arch = localArch;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return configArgv;
|
|
106
|
-
} else {
|
|
107
|
-
return {
|
|
108
|
-
platform: localPlatform,
|
|
109
|
-
arch: localArch,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
module.exports.detectOS = (archType = "", platformType = "") => {
|
|
115
|
-
const platform = platformType !== "" ? platformType : process.platform;
|
|
116
|
-
const arch = archType !== "" ? archType : process.arch;
|
|
117
|
-
if (platform === "darwin") {
|
|
118
|
-
if (arch === "x64") {
|
|
48
|
+
module.exports.detectOS = (archType = '', platformType = '') => {
|
|
49
|
+
const platform = platformType !== '' ? platformType : process.platform;
|
|
50
|
+
const arch = archType !== '' ? archType : process.arch;
|
|
51
|
+
if (platform === 'darwin') {
|
|
52
|
+
if (arch === 'x64') {
|
|
119
53
|
return Platform.MACOS;
|
|
120
54
|
} else {
|
|
121
55
|
return Platform.MACOS_ARM;
|
|
122
56
|
}
|
|
123
|
-
} else if (platform ===
|
|
124
|
-
if (arch ===
|
|
57
|
+
} else if (platform === 'win32') {
|
|
58
|
+
if (arch === 'x64') {
|
|
125
59
|
return Platform.WINDOWS64;
|
|
126
60
|
} else {
|
|
127
61
|
return Platform.WINDOWS32;
|
|
128
62
|
}
|
|
129
|
-
} else if (platform ===
|
|
130
|
-
if (arch ===
|
|
63
|
+
} else if (platform === 'linux') {
|
|
64
|
+
if (arch === 'x64') {
|
|
131
65
|
return Platform.LINUX_X64;
|
|
132
|
-
} else if (arch ===
|
|
66
|
+
} else if (arch === 'arm64') {
|
|
133
67
|
return Platform.LINUX_ARM64;
|
|
134
68
|
} else {
|
|
135
69
|
// unsupported
|
|
@@ -141,10 +75,7 @@ module.exports.detectOS = (archType = "", platformType = "") => {
|
|
|
141
75
|
module.exports.detectOwnVersion = () => {
|
|
142
76
|
const { major, minor, patch } = semver.coerce(pkg.version);
|
|
143
77
|
return {
|
|
144
|
-
major,
|
|
145
|
-
minor,
|
|
146
|
-
patch,
|
|
147
|
-
version: pkg.version,
|
|
78
|
+
major, minor, patch, version: pkg.version
|
|
148
79
|
};
|
|
149
80
|
};
|
|
150
81
|
|
|
@@ -152,3 +83,4 @@ module.exports.detectOwnName = () => {
|
|
|
152
83
|
const name = pkg.name;
|
|
153
84
|
return name;
|
|
154
85
|
};
|
|
86
|
+
|