update skuid version in vf pages with grunt

  • 1
  • Idea
  • Updated 3 years ago
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>7</majorNumber>'
            },
            {
              pattern: /(<minorNumber>[0-9]*<\/minorNumber>)/,
              replacement: '<minorNumber>36</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!
Photo of Matt Sones

Matt Sones, Champion

  • 31,530 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,242 Points 20k badge 2x thumb
Nice one Matt.
Photo of Matt Sones

Matt Sones, Champion

  • 31,530 Points 20k badge 2x thumb
Thanks!