nci
nci copied to clipboard
[Suggestion] Update code style to ES6
Thanks for this awesome CI Server. I want to contribute to it because I want to use it for one of my projects. I suggest to update and refactor code to ES6 style. It's more clear and more robust. (This could be done with lebab ) I think it would be better to provide also a Promise-based API (Using async/await ?) (we could conserve a compatibility with callback api) this could make the code base more clear by removing the usage of twostep
Hi @DeltaEvo. It's glad to hear that nci could be useful for you.
Code style update is in the roadmap but not the first thing to do. Unfortunately it's not just simple as convert current code base using lebab to es6 =) We need update our code style (use some modern linter e.g. eslint); manually replace twostep with something (e.g. promises); make api fallbacks for callback style api; convert code (e.g. using lebab) to es6, adapt it to new code style; possibly make some transpiling before publishing to keep support of old versions of node, etc.
First thing (from that list) that I plan to implement is to replace twostep with promises, provide polyfill for old versions of node and fallbacks for callback style api.
I'll leave this issue open to be in touch.
Hello @okv,
I think if we use Promises it's better to not include a polyfill and drop support of older version of node (v0.11 & v0.12) a lot of libraries have already droped support because these versions are in End Of LIfe
At the moment I have time so I think to start working on it and open a pull request so you can review my code ;)
You are right - officially it's not supported (but some critical fixes still provided), but some numbers (also here) tell that node 0.10 and 0.12 still quite widely used. I want to provide as wide versions range as possible for the end users.
Will be waiting for your news.
p.s. Since you are going to implement some major structural changes please take a look at current code style.
p.p.s. To clarify - currently I'm not ready to talk about es6 in nci code base but to replace twostep with promises looks like a good idea.
I think if we implements promise in nci, it can be faster with es6+ (es7) by using decorators for backward compatibility with callback based api because Without decorator and es5
function helloWorld(callback) {
var promise = Promise.resolve(42);
if(callback && typeof callback === "function") {
promise.then(function (result) {
callback(null, result);
}, callback);
}
return promise;
}
With decorator
@callbackify
function helloWorld() {
return Promise.resolve(42)
}
It's a more readable and more developper friendly, so I think I will be implementing Promise & ES6 at the same time in my fork, and when you will be ready for es6 you can check my code ;)
There is no node.js version that supports decorators. I don't want to transpile server side code. It may involve some issues with memory usage, debugging, etc. It may be some exceptional case with really old node.js 0.10, 0.12.
I don't think that doing promises and bringing es6 at the same time is good idea (because new code style should go before es6).
Sorry for my late reply.