-
Notifications
You must be signed in to change notification settings - Fork 456
Create and use config.js script merging defaults and custom configuration - Closes #3171 #3373
Conversation
You can get following output with the new structure, which is way more detailed compared to previous implementation.
|
07c3418
to
1b27382
Compare
…compilation logic
a310d40
to
7423f8b
Compare
@fchavant @ManuGowda You can run the command to see all the usage of this file.
And run with proper parameters to get the config as console output. Then pipe it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After creating a build I am not able to run generate_config.js usage
:
francois@ams1-lisk-build-003:~/tmp/lisk-1.6.0-rc.4-Linux-x86_64$ node ./scripts/generate_config.js usage
/home/francois/tmp/lisk-1.6.0-rc.4-Linux-x86_64/src/helpers/config.js:32
configurator.registerSchema(appSchema);
^
TypeError: Cannot read property 'registerSchema' of undefined
at Object.<anonymous> (/home/francois/tmp/lisk-1.6.0-rc.4-Linux-x86_64/src/helpers/config.js:32:14)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/home/francois/tmp/lisk-1.6.0-rc.4-Linux-x86_64/scripts/generate_config.js:22:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
and package-lock.json
in lisk/
are not in sync.
@fchavant That change is not introduced by this PR. |
@nazarhussain that may be but I cannot create a build and so cannot test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good, some minor comments
@@ -0,0 +1,148 @@ | |||
const _ = require('lodash'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this folder to
controller/configurator/configurator.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am convinced its a utility not a main namespace. As we planned to rename helpers
to util
then it will look more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utility but it's one of the main functionality for controller, and it has specific logic init, so i think it's worth to put it as first citizen.
Also, i want to get rid of helpers
or utils
in general =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me its not a main functionality of the controller, rather add on to simplify configuration management for end user. These functions still exists and must required, call these helpers or util. In any large project you always have such collection of functions. And util
is a known convention in NodeJS community so not a bad thing to have.
And wether we treat these as first citizen or not that depends how much we test coverage we have for them.
); | ||
Object.keys(this.metaInfo).forEach(key => { | ||
message.push( | ||
`${(this.metaInfo[key].arg || '').padEnd(15)} ${( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why padEnd
this? and next one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To show an aligned output on the console in help command. See the output in start of the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe comment or use of constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I am just waiting for the build to get consistently green.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't test inside of a binary build but looks good.
What was the problem?
The config compilation logic for all modules and component was distributed in different places.
How did I fix it?
Created a configurator object which compiles and reuse that logic.
How to test it?
Run all tests
Review checklist