update skuid version in vf pages with grunt

Not sure if many of you regularly deploy VF pages with the skuid:page component to new orgs. One of the problems we run into is that the skuid version in the meta-data of a VF page is the whatever version was active when the page was created. So, if you create a page on skuid 7.31 in one org, and you have a new org where the first version of skuid is 7.36, you get an error when you try to deploy the VF page to the new org. The specified version of the package doesn’t exist. Since you can’t install the older version of skuid, you have to update the skuid version in the page’s metadata before you deploy. Which is a pain if you have a lot of pages.

Or was a pain, until grunt.

You can update the metadata for all your VF pages with grunt, using grunt-string-replace, like so:

'string-replace': {
      skuidversionupdate: {
        files: [{
          expand: true,
          cwd: 'src/pages/',
          src: '*.page-meta.xml',
          dest: 'src/pages/'
        options: {
          replacements: [
              pattern: /(<majorNumber>[0-9]*</majorNumber>)/,
              replacement: '<majorNumber><b>7</b></majorNumber>'
              pattern: /(<minorNumber>[0-9]*</minorNumber>)/,
              replacement: '<minorNumber><b>36</b></minorNumber>'

This assumes that your pages live in the ‘src/pages/’ directory.
I’ve hardcoded the latest version of skuid, since I don’t expect to have to do this very often.
(But perhaps there’s a way to dynamically get the version?)

Anyway, thought I would share my success. Happy skuidifying!

Nice one Matt.