onepub-dev / dcli

An extensive library and tooling for building console/cli applications and scripts using the Dart programming language.
245 stars 26 forks source link

Implement transformers for the dcli pack command #169

Open bsutton opened 3 years ago

bsutton commented 3 years ago

The 'dcli pack' command allows you to pack resources into a dart exe.

Sometimes it is desirable to apply transformations to these files before they are packed.

This might be to include a version no. in one of the configuration files.

My thoughts are that:

the user creates a transforms directory under their tool directory: <project root>/dcli/pack/transforms

The user can then place one or more scripts in the transforms directory.

When the pack command is called it runs each of the scripts in the transform directory. The pack command will apply the transforms in order after sorting them alphanumerically. The user can control the order the transforms are applied by naming them with a numeric prefix 01_xx.dart, 02_xx.dart.

Each transform will take the arguments <resource name> <input file> <output file>

The input and output file will change between each transform but the resource name will be constant allowing the transform to choose what transformation are to be applied.

If the transform doesn't want to apply any transformations to the input file then it can simply copy the input file to the output file.