Distribution::Extension::Updater - Update legacy file extensions in a Raku distribution.
# On the command line...
# upgrade all legacy extensions in a distribution directory, defaults to '.'
rdeu [ '/path/to/distro' ]
# do a dry run, don't change anything
rdeu --/tests # don't upgrade test extensions
rdeu --/mods # don't update module extensions
rdeu --/tests --/docs # don't update tests or docs
# don't display messages to stdout
# In a module...
my $distro = Distribution::Extension::Updater.new('/path/to/dir');
my $bool = $distro.has-legacy-extensions;
perform the upgrade on files with the extensions passed
$distro.update-extensions( <t p6 pm pm6 pod pod6> );
Distribution::Extension::Updater searches a distribution on a local machine for legacy Perl 6 file extensions and updates them to the newer Raku extensions. The following file types and extensions can be updated:
tests with the
This module also updates the META6.json file as unobtrusively as possible without reorganizing it by swapping out the
provides section of the file with an updated version containing the new file extensions.
If the module determines that the git command is available and the distribution has a .git directory, it will
git mv the files. Otherwise, it will move the files with Raku's
After the module updates the extensions, the changes can be added and committed to the local git repo and then uploaded to the appropriate ecosystem manually. This module does not attempt to modify the
The module does not update files located in the
resources directory or the
The module is designed to be run from the command line with the
rdeu command but also provides an API for running it from a script or other module.
COMMAND LINE OPERATION
rdeu [ path/to/distro ]
Updates the test, documentation, and module files found in the distribution with the following extensions:
.t, .pm, .p6, .pm6, .pod, .pod6. If no path is given, the command is run in the current directory.
Performs a dry-run to give a user a chance to preview what will be changed.
Suppresses messages to standard output. Warnings will still be printed.
Provides help for the
--/mods|modules --/documentation|docs --/tests
These three options can be used alone or in combination, can be used to prevent the updating of certain types of legacy extensions.
--mods turns off the updating of files with extension of
.p6, .pm, .pm6.
--tests turns off the updating of files with extension of
--docs turns off the updating of files with extension of
OBJECT CONSTRUCTION AND METHODS
As mentioned, the module can also be used from within Raku code using the following methods.
new(Str $d = '', :d(:$dir) = $d || '.', Bool :$quiet = False, Bool :$dry-run = False, *%_ ())
Creates a new D::E::U object. If no directory is provided either with a positional argument or a named argument, defaults to the current directly, '.'. Boolean arguments,
:dry-run determine whether output messages are printed and whether changes to the distribution are actually made.
has-legacy-extensions (*@exts where @exts ⊆ @valid-ext)
Returns a boolean value
True if any legacy extensions passed via @exts are found,
False otherwise. With no arguments, will search for all known legacy extensions.
update-extensions( @exts );
Perform the upgrade on files with the extensions passed in
.pod6 extensions are permitted.
Get a simple report that counts the number of files found for each legacy extensions.
Path::IO object to the meta json file if found,
True if it determines git is installed,
find( Str:D $ext )
Creates a key in the
%.ext object attribute that points to a list of files with the extension supplied by
Steve Dondley email@example.com
COPYRIGHT AND LICENSE
Copyright 2023 Steve Dondley
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.