We use grunt to scaffold to UAT and to upload zip files to UAT. Until now those commands were pointing to the Legacy CMS API endpoints. With all clients finally off the legacy CMS, that product is being sunset and that means our tools need to point to the Platform CMS in order to work. In order to make this update some changes in the package.json and Gruntfile.js are needed.
How To
package.json
- Update your “url” line (approx. line 26) to include prod as well as UAT. Make sure that NEITHER of those two URLs include http:// or https:// at the start, if they have that the upload will break. This should look like the FI_DOMAIN variable that is set up in Postman):
"url": {
"uat": "yoursitehere-uat.banno.com",
"prod": "yoursitehere.com"
},
- Also, include a new “environment” section. This variable will match with your PLATFORM_DOMAIN variable in Postman:
"environment": {
"uat": "https://uat.banno.com",
"prod": "https://banno.com"
},
At the bottom, change it so that the “author” variable is your name, in quotes. The author property needs to be updated each time you work on a site. This property tells the upload task whose userId to use based on a switch statement added into the grunt repos found on Github. If you don’t update this property before you scaffold/upload one of two things can happen.
If the name doesn’t match a current dev, you are going to get an error because it can’t determine which userId to use.
If the author property doesn’t match your name, in the CMS it’s going to say a different dev made changes.
You will also need to add a new variable called “original-dev”, this will include the name of the original developer for the site. it may or may not be the value that was originally under “author”. depending on how many edits this site has already gone through. This new property’s purpose is purely informational and just lets other devs know who originally built a site.
Example:
"boostrap-version": "Bootstrap 4",
"author": "your name here",
"original-dev": "whoever the original developer was",
Gruntfile.js
Not to be confused with your gulpfile! You want your capital-G Gruntfile.js for this. You’re going to be adding a few lines to the cms_upload task.
At approximately line 64, replace the UAT options with this:
uat: {
options: {
url: '<%= pkg.url.uat %>',
environment: '<%= pkg.environment.uat %>',
author: '<%= pkg.author %>'
},
src: ['deploy/<%= pkg.zip %>.zip']
}
- Reinstall NPM, and you should be good to go!
Troubleshooting
Invalid URI
Type 1
If you try to upload after making these updates and get the following error,
[08:25:38] Finished 'default' after 38 s
Running "cms_upload:uat" (cms_upload) task
Warning: Invalid URI "yoursite-uat.banno.com/_/api/user/logout" Use --force to continue.
Aborted due to warnings.
this is usually because your NPM was already installed on the old method. Just run npm install in your terminal after making all the needed updates, and you should be able to upload properly.
If you try that, and it doesn’t work, make sure that your grunt, grunt-cms-site-scaffold, and grunt-cms-upload tasks in the package.json are set up correctly. They should be within the larger devDependencies section, above the “gulp” tasks. If those tasks are on their own section, that’s likely incorrect.
So, for clarity, this is the incorrect setup:
// ...all the rest of your gulp file
"license": "All Rights",
"dependencies": {
"grunt": "^1.3.0",
"grunt-cms-site-scaffold": "0.0.2",
"grunt-cms-upload": "0.0.6"
}
And this is the correct setup that you should have. A few lines surrounding each change is included for context.
// ... Site name, info, etc ...
"devDependencies": {
// ... A couple tasks to start off this section ...
"del": "latest", // Included for context, does not need to be updated
"grunt": "^1.3.0",
"grunt-cms-site-scaffold": "git+ssh://git@github.com/Banno/grunt-cms-site-scaffold.git",
"grunt-cms-upload": "git+ssh://git@github.com/Banno/grunt-cms-upload.git",
"gulp": "^4.0.0", // Included for context, does not need to be updated.
// ... Lots of other tasks, etc ...
"license": "All Rights" // May need comma removed, after you've deleted the unnecessary section below this. This is where your package.json ends! Nothing else should be after this.
Type 2
If you try to upload after making these updates and get the following error:
[09:17:00] Finished 'make-zip' after 73 ms
Running "cms_upload:uat" (cms_upload) task
Warning: Invalid URI "undefined/a/auth/api/session/logout" Use --force to continue.
Aborted due to warnings.
this is because you either forgot to make updates to the Gruntfile.js or put your Gruntfile.js updates in the wrong place. Double-check to make sure that they have been done, and that they were placed in the UAT section, not the scaffold section. The UAT upload section starts at approximately line 64 of a “modern” Gruntfile.js file.
Tags: bs4, gruntfile, package, json