#!/usr/local/cpanel/3rdparty/bin/perl

#                                      Copyright 2026 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package scripts::trim_nova_wordpress_dependencies;

use cPstrict;

=encoding utf-8

=head1 NAME

trim_nova_wordpress_dependencies

=head1 SYNOPSIS

    /usr/local/cpanel/scripts/trim_nova_wordpress_dependencies [--help]

=head1 DESCRIPTION

Run by the Nova plugin lifecycle straight after C<install_plugin>. Drops the
WP Toolkit-owned dependencies of C<nova-wordpress> that are not registered on
this server from its persisted feature metadata, so Feature Manager and the
feature-list backfill do not fail on a dependency the administrator cannot
enable. See L<Cpanel::Nova::Meridian/trim_unregistered_dependencies()>.

Always exits 0: a failure is logged and must not abort the install or upgrade.

=cut

use Getopt::Long ();

use Cpanel::Nova::Meridian ();

exit( run(@ARGV) // 0 ) unless caller;

sub print_usage () {
    print "Usage: trim_nova_wordpress_dependencies [--help]\n";
    return;
}

sub run (@argv) {
    my $help;
    Getopt::Long::GetOptionsFromArray( \@argv, 'help|h' => \$help )
      or do { print_usage(); return 1 };

    if ($help) {
        print_usage();
        return 0;
    }

    Cpanel::Nova::Meridian::trim_unregistered_dependencies();

    return 0;
}

1;
