@flowfuse/driver-localfs 2.17.0 → 2.17.1-ec1b72e-202505271334.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/localfs.js +40 -0
- package/package.json +4 -3
package/localfs.js
CHANGED
|
@@ -17,6 +17,7 @@ const got = require('got')
|
|
|
17
17
|
const path = require('path')
|
|
18
18
|
const semver = require('semver')
|
|
19
19
|
const childProcess = require('child_process')
|
|
20
|
+
const { WebSocket } = require('ws')
|
|
20
21
|
|
|
21
22
|
let initialPortNumber
|
|
22
23
|
let initialAgentPortNumber
|
|
@@ -805,5 +806,44 @@ module.exports = {
|
|
|
805
806
|
console.log(err)
|
|
806
807
|
}
|
|
807
808
|
}
|
|
809
|
+
},
|
|
810
|
+
resources: async (project) => {
|
|
811
|
+
if (this._projects[project.id] === undefined) {
|
|
812
|
+
throw new Error('Cannot get instance resources')
|
|
813
|
+
}
|
|
814
|
+
const port = await project.getSetting('port')
|
|
815
|
+
const result = await got.get('http://localhost:' + (port + 1000) + '/flowforge/resources').json()
|
|
816
|
+
if (Array.isArray(result)) {
|
|
817
|
+
return {
|
|
818
|
+
meta: {},
|
|
819
|
+
resources: result,
|
|
820
|
+
count: result.length
|
|
821
|
+
}
|
|
822
|
+
} else {
|
|
823
|
+
return result
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
resourcesStream: async (project, socket) => {
|
|
827
|
+
if (this._projects[project.id] === undefined) {
|
|
828
|
+
throw new Error('Cannot get instance resources')
|
|
829
|
+
}
|
|
830
|
+
const port = await project.getSetting('port')
|
|
831
|
+
const url = 'ws://localhost:' + (port + 1000) + '/flowforge/resources'
|
|
832
|
+
const resourceStream = new WebSocket(url, {})
|
|
833
|
+
resourceStream.on('message', (data) => {
|
|
834
|
+
socket.send(data)
|
|
835
|
+
})
|
|
836
|
+
resourceStream.on('error', (err) => {
|
|
837
|
+
logger.error(`Error in resource stream: ${err}`)
|
|
838
|
+
socket.close()
|
|
839
|
+
})
|
|
840
|
+
socket.on('close', () => {
|
|
841
|
+
try {
|
|
842
|
+
resourceStream.close()
|
|
843
|
+
} catch (_err) {
|
|
844
|
+
// ignore error
|
|
845
|
+
}
|
|
846
|
+
})
|
|
847
|
+
return resourceStream
|
|
808
848
|
}
|
|
809
849
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowfuse/driver-localfs",
|
|
3
|
-
"version": "2.17.0",
|
|
3
|
+
"version": "2.17.1-ec1b72e-202505271334.0",
|
|
4
4
|
"description": "Local Filesystem FlowFuse Project driver",
|
|
5
5
|
"main": "localfs.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@flowfuse/nr-launcher": "^2.17.0",
|
|
25
24
|
"@flowfuse/mqtt-schema-agent": "^1.0.0",
|
|
25
|
+
"@flowfuse/nr-launcher": "2.16.1-e5e5139-202505051644.0",
|
|
26
26
|
"form-data": "^4.0.0",
|
|
27
27
|
"got": "^11.8.5",
|
|
28
|
-
"semver": "
|
|
28
|
+
"semver": "~7.6.0",
|
|
29
|
+
"ws": "^8.18.2"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"eslint": "^8.25.0",
|