-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further non-breaking cleanup & improvements #20
Conversation
e18ff3c
to
70cfb17
Compare
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.
Looks nice in general. I pushed some suggested changes:
- suggested squash fixes to the main function:
- do not reassign function arguments - looks ugly and is a bad idea according to: https://spin.atomicobject.com/2011/04/10/javascript-don-t-reassign-your-function-arguments/
- split up cordovaCreate function to deal with dest dir in a nicer way:
- favors const over let
- ugly TODO item seems to go away
- test fixes:
- mark NPM package test for specific version
- restore & fix NPM package test with no specific version (it would be ideal if you would fix rather than remove the test in f4d455c)
And a few more items:
- Shouldn't README be updated to reflect the API options?
- New API option does not seem to be directly covered by spec, would like to see at least 1 test cover the new API option.
index.js
Outdated
return Promise.resolve().then(function () { | ||
events = setupEvents(extEvents); | ||
events.emit('verbose', 'Using detached cordova-create'); | ||
* Delegates to the correct function based on the given arguments |
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.
Should the exported API options be better documented here?
Also shouldn't README.md be updated to reflect the new API options, along with the deprecation notice?
index.js
Outdated
}; | ||
|
||
/** | ||
* Legacy interface. See README for documentation |
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.
Shouldn't there be a deprecation notice here and in README.md?
The deprecation notice is not needed at this point since there is no longer a change to the external interface in this PR.
index.js
Outdated
* Legacy interface. See README for documentation | ||
*/ | ||
function cordovaCreateLegacyAdapter (dir, id, name, cfg, extEvents) { | ||
// TODO DEPRECATION NOTICE |
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.
Shouldn't we do this now as requested in other comments?
I just pushed a few more changes, would be happy to move them to another PR:
|
Thanks for your extensive review @brodybits!
I'd like to avoid any additional changes to prevent conflicts with my existing work for apache/cordova-discuss#89. Unfortunately all your suggested additional changes actually do conflict with that. My plan is as follows
So I'd suggest you do not yet create another cleanup PR. I will squash the test commit you provided, thanks. Regarding the supposed new interfaceI've been a bit overzealous here. I will remove the delegation function and add that as part of a PR for apache/cordova-discuss#99. The interface introduced here is not as described in apache/cordova-discuss#99 and should be considered private. I have mixed feelings regarding your proposed changes for the main function. I will elaborate in code comments. |
@brodybits Regarding the suggested changes to the main function:
Even though I don't particularly like to assign to arguments, I like the alternatives here less. Especially because of conflicts with existing work and because I hope for this to be going away with future refactors anyway (see below). Furthermore, I don't think the dangers outlined in the post above apply to us. We do not use
This change breaks the Single Level of Abstraction principle (example). After landing any major breaking changes I do want to split the main function up, though. But in a way that actually explains what's happening and improves unit-testability. Something like: normalizeArguments()
resolveTemplate()
expandTemplate() Do you think you can live with my updated changes given my reasoning and plans outlined above? If this lands I would prepare a preview PR for the work I've done on the breaking changes next. |
Including: - Unwrap deeply nested options object - Rename options object to `opts` - Shallow copy `opts` to avoid mutating caller's object - Make Q-wrapping explicit Co-authored-by: Christopher J. Brody <[email protected]>
This reduces pollution of user's home directory and definitely makes the previously performed makeshift cache-busting obsolete since we fetch into a fresh temp directory every time. Addresses §6 of apache/cordova-discuss#89 Co-authored-by: Christopher J. Brody <[email protected]>
This does _not_ change the tests itself, even though they are broken
The errors from fetch were strongly emphasized (all red) for no obvious reason. Moreover, everything after the first error event emission never ran since the error event seems to cause an error to be thrown.
Thanks @raphinesse for going through my comments. I think the most important thing was not to break any existing tests. While I would like to see the other points addressed sometime I think they are minor enough to leave for later. +1 for cleaning up the internal interface while waiting for agreement on the external interface. A couple side points: I wish this PR had come with a reminder of apache/cordova-discuss#89 for the context. (I totally forgot about the discussion, didn't even remember commenting on it until I took another look.) But better late than never:) I was surprised that you named me as co-author of e020d8d, don't think I had anything to do with the changes there. |
Yes, I thought so too when writing my replies. Sorry for that. My bad 😞
I incorporated your changes regarding arguments assignment into the adapter function. Should I remove you? |
Missed that one (still don't see it). Thanks for the credit, though. |
See commits for details