App-Dest
view release on metacpan or search on metacpan
lib/App/Dest.pm view on Meta::CPAN
dest man # display man page
=head1 DESCRIPTION
C<dest> is a simple "deployment state" change management tool. Inspired by
what Sqitch does for databases, it provides a simple mechanism for writing
deploy, verify, and revert parts of a change action. The typical use of
C<dest> is in a development context because it allows for simplified state
changes when switching between branches (as an example).
Let's say you're working with a group of other software engineers on a
particular software project using your favorite revision control system.
Let's also say that you have a database that undergoes schema changes as
features are developed, and you have various system activities like the
installation of libraries or other applications. Then let's also say the team
branches, works on stuff, shares those branches, reverts, merges, etc. And also
from time to time you want to go back in time a bit so you can reproduce a bug.
Maintaining the database state and the state of the system across all that
activity can be problematic. C<dest> tries to solve this in a very simple way,
letting you be able to deploy, revert, and verify to any point in time in
the development history.
See below for an example scenario that may help illustrate using C<dest> in a
pseudo real world situation.
lib/App/Dest.pm view on Meta::CPAN
You'll almost certainly want to add ".dest" to your C<.gitignore> file or
similar revision control ignore file.
=head2 add DIR
Once a project has been initialized, you need to tell C<dest> what directories
you want to "track". Into these tracked directories you'll place subdirectories
with recognizable names, and into each subdirectory a set of 3 files: deploy,
revert, and verify.
For example, let's say you have a database. So you create C<db> in your
project's root directory. Then call C<dest add db> from your root directory.
Inside C<db>, you might create the directory C<db/schema>. And under that
directory, add the files: deploy, revert, and verify.
The deploy file contains the instructions to create the database schema. The
revert file contains the instructions to revert what the deploy file did. And
the verify file let's you verify the deploy file worked.
=head2 rm DIR
lib/App/Dest.pm view on Meta::CPAN
This will display a diff delta of the differences of any modified action files.
You can specify an optional name parameter that refers to a tracking directory,
action name, or specific sub-action.
dest diff
dest diff db/schema
dest diff db/schema/deploy
=head2 clean [NAME]
Let's say that for some reason you have a delta between what C<dest> thinks your
system is and what your code says it ought to be, and you really believe your
code is right. You can call C<clean> to tell C<dest> to just assume that what
the code says is right.
You can optionally provide a specific action or even a step of an action to
C<clean>. For example:
dest clean db/schema
dest clean db/schema/deploy
=head2 preinstall [NAME]
Let's say you're setting up a new system or installing the project/application,
so you start by creating yourself a working directory. At some point, you'll
want to deploy all the deploy actions. You'll need to C<init> and C<add> the
directories/paths you need. But C<dest> will have a cache that matches the
current working directory. At this point, you need to C<preinstall> to remove
that cache and be in a state where you can C<update>.
Here's an example of what you might want:
dest init
dest add path_to/stuff
lib/App/Dest.pm view on Meta::CPAN
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.
lib/App/Dest.pm view on Meta::CPAN
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
lib/App/Dest.pm view on Meta::CPAN
the schema action to have already been deployed.
vi `dest make data/stuff pl` # create the action and edit the files
Inside the C<data/stuff/deploy.pl> file, include the following line:
# dest.prereq: db/schema
=head2 Other Developers
Now let's say you invite a friend or coworker to the project. That person might
do something like this:
git clone https://example.com/example_scenario project
cd project
dest init # initiates dest and sets up watches from the watch file
dest update # brings the local environment
With the "update" command, C<dest> will notice that the "db/schema" and
"data/stuff" actions haven't been deployed. It'll also notice that "data/stuff"
depends on "db/schema", so it'll deploy the schema before it deploys the data.
( run in 1.772 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )