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

New plugin version selection implementation #363

Closed
wants to merge 13 commits into from
Closed

New plugin version selection implementation #363

wants to merge 13 commits into from

Conversation

riknoll
Copy link
Contributor

@riknoll riknoll commented Jan 23, 2016

@stevengill @dblotsky please review. This is an implementation for the plugin version selection scheme that Dmitry and I proposed in this discuss PR. I'd appreciate some feedback! I have some docs written up for this too, I'm just holding off on that PR just yet.

@stevengill
Copy link
Contributor

Hey @riknoll,

Thanks for doing this! I'll review it after the cordova 6 release.

}
}
}

// Fetch the plugin first.
events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might target be undefined here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this line should have been moved down with the rest

@riknoll
Copy link
Contributor Author

riknoll commented Feb 4, 2016

@stevengill just checking in now that Cordova 6.0.0 is released. Let me know if you have any feedback.

@riknoll
Copy link
Contributor Author

riknoll commented Feb 12, 2016

Rebased to master and responded to PR feedback. @TimBarham @vladimir-kotikov can you take a look at this as well?

@@ -492,17 +492,13 @@ function list(hooksRunner, projectRoot, opts) {
var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
return hooksRunner.fire('before_platform_ls', opts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need platforms_on_fs anymore, since you get equivalent information from your call to getInstalledPlatformsWithVersions() (so you can use platformMap below instead of platforms_on_fs).

@riknoll
Copy link
Contributor Author

riknoll commented Feb 18, 2016

@TimBarham thanks for the review; I'll update the PR in a bit!

@riknoll
Copy link
Contributor Author

riknoll commented Feb 19, 2016

Responded to most the feedback. Also added warnings and verbose logging which I completely forgot in my original PR. I will rebase this branch soon

@riknoll
Copy link
Contributor Author

riknoll commented Feb 19, 2016

Rebased to master (that was fun)

it('clean up after plugin fetch spec', function() {
removeTestProject();
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really pretty code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@riknoll
Copy link
Contributor Author

riknoll commented Feb 20, 2016

@TimBarham addressed your other feedback

.then(function(v) {
result[p] = v || null;
}, function(v) {
result[p] = v || 'broken';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you intended? The parameter v here will actually be the error. In the previous version, v was simply ignored (so "version" was always set to "broken").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed

@nikhilkh
Copy link
Contributor

@vladimir-kotikov to also take a look.

@riknoll
Copy link
Contributor Author

riknoll commented Feb 29, 2016

I have significant changes to push in response to some feedback, so don't review yet. I'll comment when they're in.

@riknoll
Copy link
Contributor Author

riknoll commented Mar 1, 2016

Alright, this should be ready for review. The changes I just pushed included a few fixes to edge cases, better handling of malformed input/whitespace, and a lot more tests.

@nikhilkh
Copy link
Contributor

nikhilkh commented Mar 1, 2016

@TimBarham @vladimir-kotikov Can you please take a look in the next couple of days? It will be good to get this committed and do a release.

var version = parts[1];

// If no version is specified, retrieve the version (or source) from config.xml
if (!version && !cordova_util.isUrl(id) && !cordova_util.isDirectory(id)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather reverse if condition here to return target immediately if there is no need for any processing. This is just a matter of taste of course but IMO it would help to improve code readability a bit. The same for L302 and L304

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I just refactored this code, but I should have caught that. Changing now.

@vladimir-kotikov
Copy link
Member

LGTM apart from a couple of nitpicks.

}

listUnmetRequirements(latestFailedReqs);
events.emit('warn', 'Current project does not satisfy the engine requirements specified by any version of this plugin. Fetching latest or pinned version of plugin anyway (may be incompatible)');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad we fetch anyways!

@stevengill
Copy link
Contributor

LGTM! Great work @riknoll! Very clean code and is easy to follow. Looking forward to switching over to this.

// If no version is specified, retrieve the version (or source) from config.xml
if (version || cordova_util.isUrl(id) || cordova_util.isDirectory(id)) {
return Q(target);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: superfluous else - remove it, and decrease the indentation level of the rest of the function.

@TimBarham
Copy link
Contributor

This is looking great @rikroll! I have a few comments, but mostly pretty minor stuff.

@riknoll
Copy link
Contributor Author

riknoll commented Mar 3, 2016

Okay, I added a lot of verbose logging and responded to some of the refactor stuff @TimBarham mentioned (except where noted). I plan to rebase this down to one commit and merge at end of day today.

@riknoll
Copy link
Contributor Author

riknoll commented Mar 3, 2016

@TimBarham updated

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.

None yet

6 participants