cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Bond-Caron <jbo...@gdesolutions.com>
Subject cli & plugman - optimist, nopt - refactoring
Date Tue, 28 Jan 2014 22:21:31 GMT
A bit of context, I've been digging more into adding -force or -f to forcefully remove plugins
(supported by plugman & cli)

As I was bouncing in between cli & plugman code, I felt an itch on some issues:

-          In cli, options is passed as an array to the 'subcommands' which is confusing as
it's an object everywhere else

IMHO, options should always be an object & the subcommands shoudn't need to do more parsing



-          Cli uses 'optimist' for command line parsing, plugman 'nopt'

-          Lots passing 'options' gymnastics into other functions

Long story short, I ended up refactoring a lot of the code:
https://github.com/jbondc/cordova-cli/compare/apache:master...master
https://github.com/jbondc/cordova-plugman/compare/apache:master...master

Notable changes:

-          cli now uses 'nopt' to parse command line arguments

-          hooks & build methods are passed a 'command' which is also an object

-          took out a callback christmas tree:

https://github.com/jbondc/cordova-plugman/blob/ad2c74b3344c8899e8ede12827f7ca4637a01b6f/src/install.js#L306

(there was a bug in there where Q() fails to emit/report the Error)

-          lots of testing, though some tests are still failing

-          Removed 'mock' tests for plugman uninstall which uncovered bugs with the removal/re-install
of plugins from a path

-          I tried to keep to changes around consistency

Objectives of these changes (big patch) would be to:

-          Swap code to use 'command' from an external library (shared by cli & plugman):

https://github.com/jbondc/cordova-labs/blob/master/cordova-lib/command.ts

Before I continue to get the remaining tests passing, wanted to get some feedback:


-          Should I split the patch in multiple pieces? How?

-          Anything I'm overlooking or some objections with it?

-          Any thoughts on using TypeScript or Coffeescript as a library (e.g. cordova-lib)?

Cheers,
Jon

Ps: should be joining the hangout tomorrow

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message