Skip to content

Commit 522148b

Browse files
committed
check config version
1 parent 3426e2e commit 522148b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

blueprints/flexi-config/files/config/flexi.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
'use strict';
33

44
module.exports = {
5+
configVersion: '1.0.0',
6+
57
// breakpoints, order does not matter, they will be sorted by `begin`
68
// `name` is used for layout names and booleans on the device/layout service
79
// `prefix` is used for column classes, column attributes, and container breakpoint classes

lib/get-validated-flexi-config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ module.exports = function(projectRoot) {
2727
fs.existsSync(configPath));
2828

2929
let flexiConfig = require(configPath);
30+
let actualVersion = flexiConfig.configVersion;
31+
let expectedVersion = require(path.join(projectRoot,
32+
'node_modules',
33+
'@html-next',
34+
'flexi-config',
35+
'blueprints',
36+
'flexi-config',
37+
'files',
38+
'config',
39+
'flexi.js')).configVersion;
3040

3141
assert('config/flexi.js is defined, but could not be imported', flexiConfig);
3242
assert('config/flexi.js is defined, but does not contain property [array] breakpoints,'
@@ -35,6 +45,14 @@ module.exports = function(projectRoot) {
3545
assert('config/flexi.js is defined, but does not contain property [number] columns,'
3646
+ ` consider running ${GENERATE_CONFIG_COMMAND} to see the default config file.`,
3747
typeof flexiConfig.columns === 'number');
48+
assert('config/flexi.js is defined, but does not contain property [string] configVersion,'
49+
+ ` consider running ${GENERATE_CONFIG_COMMAND} to see the default config file.`,
50+
actualVersion);
51+
assert(`config/flexi.js version does not match the latest config file. Got '${actualVersion}',`
52+
+ ` expected '${expectedVersion}'. Consider running ${GENERATE_CONFIG_COMMAND} to see`
53+
+ ' what your config file is missing, then update the version number to match.',
54+
actualVersion === expectedVersion);
3855

3956
return flexiConfig;
4057
};
58+

0 commit comments

Comments
 (0)