App-Dest
view release on metacpan or search on metacpan
lib/App/Dest.pm view on Meta::CPAN
If there are actions in the code that have not been deployed, these will be
deployed. If there are actions that have been deployed that are no longer in
the code, they will be reverted.
If there are actions that are in the code that have been deployed, but the
"deploy" file has changed, then C<update> will revert the previously deployed
"deploy" file then deploy the new "deploy" file. (And note that the deployment
will automatically call C<verify>.)
You can optionally add one or more "INCS" strings to the update command to
restrict the update to only perform operations that include one of the "INCS" in
its action file. So for example, let's say you have a "db/changes" directory
with some actions and a "etc/changes" directory with some actions. If you were
to specify "db/changes" as one of your "INCS", this would only update actions
from that directory tree.
Adding a "-d" flag to the command will cause a "dry run" to run, which will
not perform any actions but will instead report what actions would happen.
=head2 version
Displays the current C<dest> version.
=head2 help
Displays a synposis of commands and their usage.
=head2 man
Displays the man page for C<dest>.
=head1 DEPENDENCIES
Sometimes you may have deployments that have dependencies on other deployments.
For example, if you want to add a column to a table in a database, that table
(and the database) have to exist already.
To define a dependency, place the action's name after a C<dest.prereq> marker in
the deploy action file. This will likely need to be in the form of a comment.
(The comment marker can be whatever the language of the deployment file is.) For
example, in a SQL file that adds a column, you might have:
-- dest.prereq: db/schema
Dependencies are defined only in deploy actions. Reverting infers its dependency
tree from the dependencies defined in deploy actions, just in reverse.
=head1 WRAPPERS
Unless a "wrapper" is used (and thus, by default), C<dest> will assume that the
action files (those 3 files under each action name) are self-contained
executable files. Often if not almost always the action sub-files would be a
lot simpler and contain less code duplication if they were executed through
some sort of wrapper.
Given our database example, we'd likely want each of the action sub-files to be
pure SQL. In that case, we'll need to write some wrapper program that C<dest>
will run that will then consume and run the SQL files as appropriate.
C<dest> looks for wrapper files up the chain from the location of the action
file. Specifically, it'll assume a file is a wrapper if the filename is
"dest.wrap". If such a file is found, then that file is called, and the name of
the action sub-file is passed as its only argument.
As an example, let's say I created an action set that looked like this
example/
ls/
deploy
revert
verify
Let's then also say that the C<example/ls/deploy> file contains: C<ls>
I could create a deployment file C<example/dest.wrap> that looked like this:
#!/bin/sh
/bin/sh "$1"
Wrappers will only ever be run from the current code. For example, if you have
a revert file for some action and you checkout your working directory to a
point in time prior to the revert file existing, C<dest> maintains a copy of the
original revert file so it can revert the action. However, it will always rely
on whatever wrapper is in the current working directory.
The C<dest.wrap> is called with two parameters: first, the name of the change
program, and second, the action type ("deploy", "revert", "verify").
=head1 WATCH FILE
Optionally, you can elect to use a watch file that can be committed to your
favorite revision control system. In the root directory of your project, create
a filed called "dest.watch" and list therein the directories (relative to the
root directory of the project) to watch.
If this "dest.watch" file exists in the root directory of your project, C<dest>
will add the following behavior:
During an "init" action, the C<dest.watch> file will be read to setup all
watched directories (as though you manually called the "add" action on each).
During a "status" action, C<dest> will report any differences between your
current watch list and the C<dest.watch> file.
During an "update" action, C<dest> will automatically add (as if you manually
called the "add" action) each directory in the C<dest.watch> file that is
currently not watched by C<dest> prior to executing the update action.
=head1 EXAMPLE SCENARIO
To help illustrate what C<dest> can do, consider the following example scenario.
You start a new project that requires the use of a typical database. You want to
control the schema of that database with progressively executed SQL files. You
also have data operations that require more functionality than what SQL can
provide, so you'd like to have data operations handled by progressively executed
Perl programs.
=head2 Project Initiation
You could setup your changes and C<dest> as follows (starting in your project's
( run in 3.067 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )