@@ -14,7 +14,7 @@ class NodeRED extends HCPP_Hooks {
14
14
public $ supported = ['18 ' ,'19 ' ,'20 ' ,'21 ' ,'22 ' ];
15
15
16
16
/**
17
- * Customize Node-RED install screen
17
+ * Customize Node-RED install screen.
18
18
*/
19
19
public function hcpp_add_webapp_xpath ( $ xpath ) {
20
20
if ( ! (isset ( $ _GET ['app ' ] ) && $ _GET ['app ' ] == 'NodeRED ' ) ) return $ xpath ;
@@ -94,7 +94,6 @@ public function hcpp_invoke_plugin( $args ) {
94
94
$ current_pkg = trim ( $ hcpp ->delLeftMost ( $ parse . '@ ' , '@ ' ) );
95
95
$ current_pkg = $ hcpp ->getLeftMost ( $ current_pkg , "\n" );
96
96
97
-
98
97
// Check if node-red is missing or outdated
99
98
if ( $ current_pkg !== $ latest_pkg ) {
100
99
$ majors [] = $ major ;
@@ -104,14 +103,14 @@ public function hcpp_invoke_plugin( $args ) {
104
103
105
104
// Install Node-RED on supported NodeJS versions
106
105
if ( count ( $ majors ) > 0 ) {
107
- $ hcpp ->nodeapp ->do_maintenance ( $ majors , function ( $ stopped ) use ( $ hcpp , $ majors ) {
106
+ $ hcpp ->nodeapp ->do_maintenance ( function ( $ stopped ) use ( $ hcpp , $ majors ) {
108
107
foreach ( $ majors as $ major ) {
109
108
$ cmd = "nvm use $ major && " ;
110
109
$ cmd .= '(npm list -g node-red || npm install -g --unsafe-perm node-red --no-interactive) ' ;
111
110
$ cmd .= '&& npm update -g node-red --no-interactive < /dev/null ' ;
112
111
$ hcpp ->runuser ( '' , $ cmd );
113
112
}
114
- });
113
+ }, $ majors );
115
114
}
116
115
}
117
116
@@ -129,12 +128,12 @@ public function hcpp_invoke_plugin( $args ) {
129
128
}
130
129
131
130
// Uninstall Node-RED on supported NodeJS versions
132
- $ hcpp ->nodeapp ->do_maintenance ( $ this -> supported , function ( $ stopped ) use ( $ hcpp , $ majors ) {
131
+ $ hcpp ->nodeapp ->do_maintenance ( function ( $ stopped ) use ( $ hcpp , $ majors ) {
133
132
foreach ( $ majors as $ major ) {
134
133
$ cmd = "nvm use $ major && npm uninstall -g node-red --no-interactive " ;
135
134
$ hcpp ->runuser ( '' , $ cmd );
136
135
}
137
- });
136
+ }, $ this -> supported );
138
137
}
139
138
140
139
// Setup Node-RED with the supported NodeJS on the given domain
@@ -202,7 +201,18 @@ public function hcpp_invoke_plugin( $args ) {
202
201
$ hcpp ->run ( "v-restart-proxy " );
203
202
}
204
203
return $ args ;
205
- }
204
+ }
205
+
206
+ /**
207
+ * Check daily for Node-RED updates and install them.
208
+ */
209
+ public function v_update_sys_queue ( $ args ) {
210
+ global $ hcpp ;
211
+ if ( ! (isset ( $ args [0 ] ) && trim ( $ args [0 ] ) == 'daily ' ) ) return $ args ;
212
+ if ( strpos ( $ hcpp ->run ('v-list-sys-hestia-autoupdate ' ), 'Enabled ' ) == false ) return $ args ;
213
+ $ hcpp ->run ( 'v-invoke-plugin nodered_install ' );
214
+ return $ args ;
215
+ }
206
216
207
217
}
208
218
global $ hcpp ;
0 commit comments