@camera.ui/go2rtc 0.0.12 → 0.0.14
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/dist/install.js +1 -1
- package/package.json +3 -3
- package/scripts/install.js +0 -126
package/dist/install.js
CHANGED
|
@@ -30,7 +30,7 @@ const binaries = {
|
|
|
30
30
|
i386: 'go2rtc_win32.zip',
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
|
-
const GO2RTC_VERSION = 'v1.9.
|
|
33
|
+
const GO2RTC_VERSION = 'v1.9.1';
|
|
34
34
|
const arch = os_1.default.arch();
|
|
35
35
|
const platform = os_1.default.platform();
|
|
36
36
|
const filename = binaries[platform]?.[arch];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camera.ui/go2rtc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "camera.ui go2rtc package",
|
|
5
5
|
"author": "seydx (https://github.com/seydx/camera.ui)",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "rimraf dist && tsc",
|
|
16
16
|
"format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
|
|
17
|
-
"postinstall": "node
|
|
17
|
+
"postinstall": "node dist/install.js",
|
|
18
18
|
"lint": "eslint --fix --ext .js,.ts .",
|
|
19
19
|
"update": "updates --update ./",
|
|
20
20
|
"install-updates": "npm i --save",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rushstack/eslint-patch": "^1.10.2",
|
|
30
30
|
"@types/fs-extra": "^11.0.4",
|
|
31
|
-
"@types/node": "^20.12.
|
|
31
|
+
"@types/node": "^20.12.8",
|
|
32
32
|
"@types/ws": "^8.5.10",
|
|
33
33
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
34
34
|
"@typescript-eslint/parser": "^7.8.0",
|
package/scripts/install.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const { pipeline } = require('stream/promises');
|
|
8
|
-
const unzipper = require('unzipper');
|
|
9
|
-
|
|
10
|
-
const binaries = {
|
|
11
|
-
darwin: {
|
|
12
|
-
x64: 'go2rtc_mac_amd64.zip',
|
|
13
|
-
arm64: 'go2rtc_mac_arm64.zip',
|
|
14
|
-
},
|
|
15
|
-
linux: {
|
|
16
|
-
x64: 'go2rtc_linux_amd64',
|
|
17
|
-
arm: 'go2rtc_linux_arm',
|
|
18
|
-
armv6: 'go2rtc_linux_armv6',
|
|
19
|
-
arm64: 'go2rtc_linux_arm64',
|
|
20
|
-
i386: 'go2rtc_linux_i386',
|
|
21
|
-
mipsel: 'go2rtc_linux_mipsel',
|
|
22
|
-
},
|
|
23
|
-
win32: {
|
|
24
|
-
x64: 'go2rtc_win64.zip',
|
|
25
|
-
arm64: 'go2rtc_win_arm64.zip',
|
|
26
|
-
i386: 'go2rtc_win32.zip',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const GO2RTC_VERSION = 'v1.9.0';
|
|
31
|
-
const arch = os.arch();
|
|
32
|
-
const platform = os.platform();
|
|
33
|
-
const filename = binaries[platform]?.[arch];
|
|
34
|
-
const releasesUrl = 'https://api.github.com/repos/AlexxIT/go2rtc/releases';
|
|
35
|
-
|
|
36
|
-
console.log(`Detected platform: ${platform} / ${arch}`);
|
|
37
|
-
|
|
38
|
-
const go2rtcBinaryPath = path.resolve(__dirname, '../binary');
|
|
39
|
-
const go2rtcFilePath = path.resolve(go2rtcBinaryPath, filename || '');
|
|
40
|
-
const go2rtcExtractedFileName = 'go2rtc' + (platform === 'win32' ? '.exe' : '');
|
|
41
|
-
const go2rtcExtractedFilePath = path.resolve(go2rtcBinaryPath, go2rtcExtractedFileName);
|
|
42
|
-
|
|
43
|
-
const isZipUrl = (url) => {
|
|
44
|
-
const pathArray = new URL(url).pathname.split('/');
|
|
45
|
-
const fileName = pathArray[pathArray.length - 1];
|
|
46
|
-
|
|
47
|
-
return fileName !== undefined && path.extname(fileName) === '.zip';
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const downloadFile = async (url) => {
|
|
51
|
-
console.log(`Downloading Go2Rtc ${GO2RTC_VERSION} to ${go2rtcFilePath}...`);
|
|
52
|
-
|
|
53
|
-
const { data } = await axios.get(url, {
|
|
54
|
-
onDownloadProgress: (progressEvent) => {
|
|
55
|
-
if (process.env.CI || !progressEvent.total) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const percent = Math.round((progressEvent.loaded / progressEvent.total) * 100) + '%';
|
|
60
|
-
process.stdout.write('\r' + percent);
|
|
61
|
-
|
|
62
|
-
if (progressEvent.loaded === progressEvent.total) {
|
|
63
|
-
process.stdout.write('\r');
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
timeout: 30 * 1000, // 30s
|
|
67
|
-
maxRedirects: 3,
|
|
68
|
-
responseType: 'stream',
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
await fs.ensureDir(go2rtcBinaryPath);
|
|
72
|
-
|
|
73
|
-
const streams = [data, fs.createWriteStream(go2rtcFilePath)];
|
|
74
|
-
|
|
75
|
-
await pipeline(streams);
|
|
76
|
-
|
|
77
|
-
if (isZipUrl(url)) {
|
|
78
|
-
console.log(`Extracting ${go2rtcFilePath} to ${go2rtcExtractedFilePath}...`);
|
|
79
|
-
|
|
80
|
-
const directory = await unzipper.Open.file(go2rtcFilePath);
|
|
81
|
-
|
|
82
|
-
await new Promise((resolve, reject) => {
|
|
83
|
-
directory.files[0].stream().pipe(fs.createWriteStream(go2rtcExtractedFilePath)).on('error', reject).on('finish', resolve);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log(`Removing ${go2rtcFilePath}...`);
|
|
87
|
-
|
|
88
|
-
await fs.remove(go2rtcFilePath);
|
|
89
|
-
} else {
|
|
90
|
-
console.log(`Renaming ${go2rtcFilePath} to ${go2rtcExtractedFilePath}...`);
|
|
91
|
-
await fs.rename(go2rtcFilePath, go2rtcExtractedFilePath);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const getReleaseAssets = async (version) => {
|
|
96
|
-
const response = await axios.get(`${releasesUrl}/tags/${version}`);
|
|
97
|
-
|
|
98
|
-
const assets = response.data.assets.map((asset) => asset.browser_download_url);
|
|
99
|
-
const files = assets.map((asset) => asset.split(`${version}/`)[1]);
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
assets,
|
|
103
|
-
files,
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const downloadGo2Rtc = async () => {
|
|
108
|
-
const release = await getReleaseAssets(GO2RTC_VERSION);
|
|
109
|
-
|
|
110
|
-
if (!filename || !release.assets.find((r) => r.endsWith(filename))) {
|
|
111
|
-
throw new Error(`No go2rtc binary found for architecture (${platform} / ${arch})`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const downloadUrl = release.assets.find((r) => r.endsWith(filename));
|
|
115
|
-
|
|
116
|
-
await downloadFile(downloadUrl);
|
|
117
|
-
|
|
118
|
-
if (platform === 'linux' || platform === 'darwin') {
|
|
119
|
-
console.log(`Making ${go2rtcExtractedFilePath} executable...`);
|
|
120
|
-
fs.chmodSync(go2rtcExtractedFilePath, 0o755);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
console.log('Done!');
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
downloadGo2Rtc();
|