Skip to content

Commit a024755

Browse files
committed
Merge branch 'feature/tfjs-node-upgrade'
2 parents 0e39a88 + b256b9f commit a024755

File tree

5 files changed

+83
-40
lines changed

5 files changed

+83
-40
lines changed

package-lock.json

+44-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "homebridge-unifi-protect-camera-motion",
3-
"version": "0.2.6",
3+
"version": "0.2.8",
44
"description": "Unifi Protect cameras & motion sensors for Homekit with Homebridge",
55
"main": "src/index.js",
66
"scripts": {
7-
"postinstall": "npm rebuild @tensorflow/tfjs-node --build-from-source",
7+
"postinstall": "node ./scripts/postinstall.js",
88
"compile": "node --max-old-space-size=1024 ./node_modules/typescript/lib/tsc.js",
99
"homebridge": "tsc && homebridge -P . -U ./resources/test-config/",
1010
"test": "jest --config jest.config.js --collect-coverage"
@@ -25,8 +25,8 @@
2525
"homebridge": ">=1.0.0"
2626
},
2727
"dependencies": {
28-
"homebridge-camera-ffmpeg": "0.1.19",
29-
"@tensorflow/tfjs-node": "1.2.11",
28+
"homebridge-camera-ffmpeg": "1.0.0",
29+
"@tensorflow/tfjs-node": "1.7.4",
3030
"axios": "^0.19.2",
3131
"canvas": "^2.6.1",
3232
"debug": "^2.6.9",
Binary file not shown.

scripts/postinstall.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const fs = require('fs');
2+
const exec = require('child_process').exec;
3+
4+
switch (process.arch) {
5+
case 'arm':
6+
case 'arm64':
7+
fixTensorFlowForArm();
8+
break;
9+
case 'x32':
10+
case 'x64':
11+
console.log('Supported architecture, no actions required!');
12+
break;
13+
default:
14+
console.error('Unsupported processor architecture!');
15+
}
16+
17+
function fixTensorFlowForArm() {
18+
const content = {
19+
"tf-lib": "https://github.com/beele/homebridge-unifi-protect-camera-motion/blob/feature/tfjs-node-upgrade/resources/tfjs-arm/libtensorflow-cpu-linux-arm-1.15.0.tar.gz?raw=true"
20+
};
21+
22+
if (fs.existsSync(process.cwd() + '/node_modules/@tensorflow/tfjs-node/scripts/')) {
23+
fs.writeFileSync(process.cwd() + '/node_modules/@tensorflow/tfjs-node/scripts/custom-binary.json', JSON.stringify(content, null, 4));
24+
25+
exec('npm install', {cwd: process.cwd() + '/node_modules/@tensorflow/tfjs-node/'}, (error, stdout, stderr) => {
26+
console.log(stdout);
27+
console.error(stderr);
28+
});
29+
}
30+
}

src/unifi/unifi.ts

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export class Unifi {
3939
this.logDebug(request);
4040
return request;
4141
});
42+
43+
this.axiosInstance.interceptors.response.use((response: AxiosResponse) => {
44+
this.logDebug(response);
45+
return response;
46+
});
4247
}
4348
}
4449

0 commit comments

Comments
 (0)