There are two options to start using the Sugar Module Packager:
- Start from the pre-made template (with or without Docker)
- Start from scratch by requiring the composer library (with or without Docker)
If you have Docker installed, you can conveniently run the following commands
mkdir my-module
cd my-module
docker run -it -v ${PWD}:/usr/src/packager -w /usr/src/packager esimonetti/sugarmodulepackager template
mkdir my-module
cd my-module
docker run -it -v ${PWD}:/usr/src/packager -w /usr/src/packager esimonetti/sugarmodulepackager new
After the Sugar Module Packager has been installed successfully, it is possible to package your code (through Docker) by executing: ./vendor/bin/package-docker <version number>
ie: ./vendor/bin/package-docker 1.6
Alternatively to Docker, it is possible to proceed with the manual approach
Visit https://github.com/esimonetti/SugarTemplateModule and follow the instructions
Require the composer library within your module's source directory by executing: composer require esimonetti/sugar-module-packager 0.2.3
The .gitignore should look like the following:
composer.lock
/vendor/
/pkg/
/releases/
After the Sugar Module Packager has been installed successfully, it is possible to package your code (without Docker) by executing: ./vendor/bin/package <version number>
ie: ./vendor/bin/package 1.6
A simple code example on how to leverage this library can be found on: https://github.com/esimonetti/SugarModulePackagerSample
- The
src
directory contains the code that should be copied into the Sugar instance according to their relative path withinsrc
- There are a couple of exceptions:
LICENSE
andREADME.txt
files will not be copied into the instance, just into the installable package
- There are a couple of exceptions:
configuration
directory- Must define the
manifest
information onmanifest.php
- Optionally, it is possible to define the
installdefs
actions oninstalldefs.php
- Optionally, for more complex use-cases, it is possible to define code templating actions to be completed by the packager across multiple modules, within the
templates.php
file- It is possible to define multiple template sections based on multiple template actions and patterns to replicate across modules
- The array keys of the templates configuration array define the package directories to read files from, when generating the output
- The array content defines the
directory_pattern
tree prefix, that will be appendedd as a prefix of every file path of the local directory- The string
{MODULENAME}
within thedirectory_pattern
templates configuration option, will be replaced with the current module name during package generation
- The string
- The array content defines the
modules
list that must contain the module names as array keys and the object name as array values- The string
{MODULENAME}
within your local directory template files, will be replaced during package generation as the configuration's module list array key (the module name, usually plural eg:Accounts
) - The string
{OBJECTNAME}
within your local directory template files, will be replaced during package generation as the configuration's module list array value (the object name of the module, usually singular eg:Account
)
- The string
- It is possible to define multiple template sections based on multiple template actions and patterns to replicate across modules
- Must define the