diff --git a/blueprints/flexi-config/files/config/flexi.js b/blueprints/flexi-config/files/config/flexi.js index cd94541..b4ded99 100644 --- a/blueprints/flexi-config/files/config/flexi.js +++ b/blueprints/flexi-config/files/config/flexi.js @@ -2,6 +2,8 @@ 'use strict'; module.exports = { + configVersion: '1.0.0', + // breakpoints, order does not matter, they will be sorted by `begin` // `name` is used for layout names and booleans on the device/layout service // `prefix` is used for column classes, column attributes, and container breakpoint classes diff --git a/lib/get-validated-flexi-config.js b/lib/get-validated-flexi-config.js index 86f51be..eb8d79c 100644 --- a/lib/get-validated-flexi-config.js +++ b/lib/get-validated-flexi-config.js @@ -27,6 +27,16 @@ module.exports = function(projectRoot) { fs.existsSync(configPath)); let flexiConfig = require(configPath); + let actualVersion = flexiConfig.configVersion; + let expectedVersion = require(path.join(projectRoot, + 'node_modules', + '@html-next', + 'flexi-config', + 'blueprints', + 'flexi-config', + 'files', + 'config', + 'flexi.js')).configVersion; assert('config/flexi.js is defined, but could not be imported', flexiConfig); assert('config/flexi.js is defined, but does not contain property [array] breakpoints,' @@ -35,6 +45,14 @@ module.exports = function(projectRoot) { assert('config/flexi.js is defined, but does not contain property [number] columns,' + ` consider running ${GENERATE_CONFIG_COMMAND} to see the default config file.`, typeof flexiConfig.columns === 'number'); + assert('config/flexi.js is defined, but does not contain property [string] configVersion,' + + ` consider running ${GENERATE_CONFIG_COMMAND} to see the default config file.`, + actualVersion); + assert(`config/flexi.js version does not match the latest config file. Got '${actualVersion}',` + + ` expected '${expectedVersion}'. Consider running ${GENERATE_CONFIG_COMMAND} to see` + + ' what your config file is missing, then update the version number to match.', + actualVersion === expectedVersion); return flexiConfig; }; +