2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

98_Installer: add ::CreateRawMetaJson()

git-svn-id: https://svn.fhem.de/fhem/trunk@18869 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2019-03-11 23:20:55 +00:00
parent 4ae3223d94
commit 840b4c9299

View File

@ -224,6 +224,12 @@ sub Get($$@) {
my $ret = CreateMetadataList( $hash, $cmd, $args[0] );
return $ret;
}
elsif ( lc($cmd) eq 'zzgetmeta.json' ) {
return "usage: $cmd MODULE" if ( @args != 1 );
my $ret = CreateRawMetaJson( $hash, $cmd, $args[0] );
return $ret;
}
else {
my $fhemModules;
@ -233,7 +239,8 @@ sub Get($$@) {
$fhemModules .= $_;
}
my $list = "showModuleInfo:FHEM,$fhemModules";
my $list =
"zzGetMETA.json:FHEM,$fhemModules showModuleInfo:FHEM,$fhemModules";
return "Unknown argument $cmd, choose one of $list";
}
@ -838,8 +845,6 @@ sub WriteReadings($$) {
# - show master/slave dependencies
# - show parent/child dependencies
# - show other dependant/related modules
# - show community and commercial support
# - aligned with bugtracker
# - fill empty keywords
# - Get Community Support URL from MAINTAINERS.txt
sub CreateMetadataList ($$$) {
@ -1467,7 +1472,7 @@ sub CreateMetadataList ($$$) {
push @ret,
$txtOpen . 'HINT:'
. $txtClose . "\n"
. 'This module does not provide prerequisites from its metadata.'
. 'This module does not provide Perl prerequisites from its metadata.'
. "\n"
. 'The following result is based on automatic source code analysis'
. "\n"
@ -1577,7 +1582,26 @@ sub CreateMetadataList ($$$) {
push @ret, 'Based on data generated by ' . $modMeta->{generated_by};
return $header . join( "\n", @ret ) . $footer;
}
sub CreateRawMetaJson ($$$) {
my ( $hash, $getCmd, $modName ) = @_;
$modName = 'Global' if ( uc($modName) eq 'FHEM' );
return '{}'
unless ( defined( $modules{$modName} ) );
FHEM::Meta::Load($modName);
return '{}'
unless ( defined( $modules{$modName}{META} )
&& scalar keys %{ $modules{$modName}{META} } > 0 );
my $j = JSON->new;
$j->allow_nonref;
$j->canonical;
$j->pretty;
return $j->encode( $modules{$modName}{META} );
}
sub __IsInstalledPerl($) {