Skip to content

Commit d41c0d2

Browse files
committed
Update maint. support
1 parent 02de3c7 commit d41c0d2

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

nodered.php

+17-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class NodeRED extends HCPP_Hooks {
1414
public $supported = ['18','19','20','21','22'];
1515

1616
/**
17-
* Customize Node-RED install screen
17+
* Customize Node-RED install screen.
1818
*/
1919
public function hcpp_add_webapp_xpath( $xpath ) {
2020
if ( ! (isset( $_GET['app'] ) && $_GET['app'] == 'NodeRED' ) ) return $xpath;
@@ -94,7 +94,6 @@ public function hcpp_invoke_plugin( $args ) {
9494
$current_pkg = trim( $hcpp->delLeftMost( $parse . '@', '@' ) );
9595
$current_pkg = $hcpp->getLeftMost( $current_pkg, "\n" );
9696

97-
9897
// Check if node-red is missing or outdated
9998
if ( $current_pkg !== $latest_pkg ) {
10099
$majors[] = $major;
@@ -104,14 +103,14 @@ public function hcpp_invoke_plugin( $args ) {
104103

105104
// Install Node-RED on supported NodeJS versions
106105
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 ) {
108107
foreach( $majors as $major ) {
109108
$cmd = "nvm use $major && ";
110109
$cmd .= '(npm list -g node-red || npm install -g --unsafe-perm node-red --no-interactive) ';
111110
$cmd .= '&& npm update -g node-red --no-interactive < /dev/null';
112111
$hcpp->runuser( '', $cmd );
113112
}
114-
});
113+
}, $majors);
115114
}
116115
}
117116

@@ -129,12 +128,12 @@ public function hcpp_invoke_plugin( $args ) {
129128
}
130129

131130
// 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 ) {
133132
foreach( $majors as $major ) {
134133
$cmd = "nvm use $major && npm uninstall -g node-red --no-interactive";
135134
$hcpp->runuser( '', $cmd );
136135
}
137-
});
136+
}, $this->supported);
138137
}
139138

140139
// Setup Node-RED with the supported NodeJS on the given domain
@@ -202,7 +201,18 @@ public function hcpp_invoke_plugin( $args ) {
202201
$hcpp->run( "v-restart-proxy" );
203202
}
204203
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+
}
206216

207217
}
208218
global $hcpp;

0 commit comments

Comments
 (0)