GRUNT Script for Package development

Permalink
Hello dear Community,

i have written an useful GRUNT Script for concrete5 Package development. This Script increments the version number of the package in the controller.php.

Together with the compress utility it is really awesome.

grunt.task.registerTask('incrementVersion', function () {
    var controllerFile = "controller.php";
    var incrementPackageVersionNumber = function (s) {
        var re = /\$pkgVersion[\s*]=[\s*][\'|\"](.*)[\'|\"]/g
        var m = re.exec(s);
        if (m.length) {
            var oldVersionNumber = m[1];
            var newVersionNumber = '';
            var temp = oldVersionNumber.split(".");
            var major = 0;
            var minor = 0;
            var rev = 0;
            if (temp.length === 3) {
                major = parseInt(temp[0]);
                minor = parseInt(temp[1]);


Best regards

fabianbitter
 
mnakalay replied on at Permalink Reply
mnakalay
Hello,
that's pretty cool.

When working on an add-on, I often don't limit myself to version numbers like major.minor.rev

I often have things like 1.0.0.3.12. Sometimes, I can have a version number of x.x.x and decide to increment it to x.x.x.0.0.0.0.0.1 to make sure I can update locally without jeopardizing future "official" updates

Anyway, I rewrote your function to deal with an arbitrary number of rev numbers and to allow numbers of any value, not necessarily only up to 9.

It still works with the major.minor.rev model but it's shorter and allows for more use case.

I hope you'll find it useful

grunt.task.registerTask('incrementVersion', function() {
    var controllerFile = 'controller.php';
    var incrementPackageVersionNumber = function (s) {
        var re = /\$pkgVersion[\s*]=[\s*][\'|\"](.*)[\'|\"]/g
        var m = re.exec(s);
        if (m.length) {
            // the max value a number can take
            var maxAllowed = 9;
            var oldVersionNumber = m[1];
            var newVersionNumber = '';
            var temp = oldVersionNumber.split(".");
            var count = temp.length;
            for (i = count-1; i >= 0; i--) {
                if (parseInt(temp[i]) >= maxAllowed) {
                    temp[i] = 0;
JohntheFish replied on at Permalink Reply
JohntheFish
For making a package continuously updatable during development, I use variations of:
function __construct()
    {
        $this->pkgVersion = $this->pkgVersion . '.' . time();
    }
protected $pkgVersion = '0.9.0.0';
mnakalay replied on at Permalink Reply
mnakalay
Wow John, that's extreme! But clever.

The grunt script is actually something I also find useful because I routinely forget to modify the version number before uploading a new version to the marketplace. So I have a grunt script that does that and zips the package while removing the extra files I don't want from the zip
JohntheFish replied on at Permalink Reply
JohntheFish
I created a package to do that sort of thing from the dashboard, tightly coupled to my own dev system master copies and versions. Its very me-specific for the way I work.
mnakalay replied on at Permalink Reply
mnakalay
(ʘ_ʘ) And you're keeping it to yourself? With Christmas coming?