Skip to content
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

Merged
merged 5 commits into from
Jul 5, 2018

Conversation

raphinesse
Copy link
Contributor

See commits for details

@raphinesse raphinesse force-pushed the cleanup-2 branch 2 times, most recently from e18ff3c to 70cfb17 Compare July 4, 2018 22:05
@raphinesse raphinesse requested review from dpogue and brody4hire July 4, 2018 22:08
Copy link

@brody4hire brody4hire left a 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:

  1. suggested squash fixes to the main function:
  2. 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

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
Copy link

@brody4hire brody4hire Jul 5, 2018

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

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?

@brody4hire
Copy link

I just pushed a few more changes, would be happy to move them to another PR:

  • do not overwrite events object
  • use forEach instead of for loop
  • use const whenever possible

@raphinesse
Copy link
Contributor Author

Thanks for your extensive review @brodybits!

I just pushed a few more changes, would be happy to move them to another PR

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

  1. Reach a consensus on which parts of Breaking changes in cordova-create cordova-discuss#89 we do want
  2. Adapt my existing work and get it into master (Including documentation and tests)
  3. Do another round of cleanup. Including ES20XXify and all.

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 interface

I'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.

@raphinesse
Copy link
Contributor Author

@brodybits Regarding the suggested changes 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/

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 arguments at all and never should do so in the future. In ES6+ code we can always use rest parameters instead. Moreover, we are not mixing up args as the author does, but refine the exisiting arguments while not changing their meaning.


split up cordovaCreate function to deal with dest dir in a nicer way:

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.

raphinesse and others added 5 commits July 5, 2018 12:48
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.
@brody4hire
Copy link

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.

@raphinesse
Copy link
Contributor Author

I wish this PR had come with a reminder of apache/cordova-discuss#89 for the context.

Yes, I thought so too when writing my replies. Sorry for that. My bad 😞

I was surprised that you named me as co-author of e020d8d, don't think I had anything to do with the changes there.

I incorporated your changes regarding arguments assignment into the adapter function. Should I remove you?

@brody4hire
Copy link

I incorporated your changes regarding arguments assignment into the adapter function.

Missed that one (still don't see it). Thanks for the credit, though.

@raphinesse raphinesse merged commit 86b0585 into apache:master Jul 5, 2018
@raphinesse raphinesse deleted the cleanup-2 branch July 5, 2018 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants