List dependents of a package. #11

Merged
merged 1 commit into from Nov 11, 2012

2 participants

@timoxley

It's useful to see what depends on a particular package:

  • Aids in component discovery.
  • Gives clues at to which components are considered canonical.
  • …which in turn should help prevent components with duplicate functionality popping up.
  • Shows practical 'usage examples'.
  • Shows where work needs to be done (e.g. number of dependents on jquery).

Whether/how you want to add this to the human readable component-search output is up to you, this will at least make it available in the --json output, but perhaps a flag like --show-dependents and/or some kind of limit on the number of dependents in default output, e.g.

  component/jquery
  url: https://github.com/component/jquery
  desc: jQuery component
  dependents: btknorr/davis.js, component/progress-notification, component/calendar + 25 others
  ★ 1

Examples

(Manually omitted package details other than name and dependents)

[{
  "name": "notification",
  "dependents": [ // 2
    "component/progress-notification",
    "component/confirmation-notification"
  ]
},
{
  "name": "stream",
  "dependents": [ // 6
    "juliangruber/shoe",
    "juliangruber/sorta",
    "juliangruber/fwd",
    "juliangruber/through",
    "juliangruber/duplexer",
    "juliangruber/min-wait"
  ]
},
{
  "name": "jquery",
  "dependents": [ // 28
    "btknorr/davis.js",
    "component/progress-notification",
    "component/calendar",
    "component/color-picker",
    "component/confirmation-popover",
    "component/confirmation-notification",
    "component/dialog",
    "component/tip",
    "component/pager",
    "component/popover",
    "component/notification",
    "component/dropdown",
    "component/menu",
    "colinf/listbox-menu",
    "colinf/datepicker",
    "component/overlay",
    "component/confirmation",
    "RetroFOX/buttonset",
    "matthewmueller/list",
    "cbou/jquery-mobile",
    "retrofox/datatable",
    "btknorr/bootbox",
    "pazguille/editable",
    "matthewmueller/events",
    "btknorr/bootstrap",
    "timoxley/backbone-view",
    "ember-components/ember",
    "ember-components/data"
  ]
},
{
  "name": "classes",
  "dependents": [ // 14
    "component/dropdown",
    "component/more",
    "component/dropload",
    "RetroFOX/buttonset",
    "ForbesLindesay/booting-sub-nav",
    "tomerdmnt/carousel",
    "tomerdmnt/carousel-slide",
    "tomerdmnt/offcanvas",
    "matthewmueller/autocomplete",
    "component/dom",
    "component/sketch",
    "component/reactive",
    "component/clipboard-dom",
    "timoxley/element-selector"
  ]
}]
// ETC
@tj tj commented on the diff Nov 11, 2012
+ * @param pkg
+ * @param pkgs {Array} All packages to analyse.
+ * @return {Array} Repos of packages that depend on `pkg`.
+ */
+function dependents(pkg, pkgs) {
+ var repo = pkg.repo
+ return pkgs.filter(blank).filter(function(pkg) {
+ pkg.dependencies = pkg.dependencies || []
+ return Object.keys(pkg.dependencies).indexOf(repo) !== -1
+ }).map(function(pkg) {
+ return pkg.repo
+ })
+}
+
+function blank(pkg) {
+ return !!pkg
@tj
tj added a note Nov 11, 2012

hehe :D I still need to find the source of these damn blanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tj
tj commented Nov 11, 2012

great idea ! thanks man, this will aid in building a dependency graph as well, I definitely want that on the site

@tj tj merged commit 5c05716 into componentjs:master Nov 11, 2012
@timoxley

Bump… keen to see this one go live.

@tj
tj commented Nov 24, 2012

I do think we should map these but I think I'll make it optional in the search response since it causes a lot of JSON bloat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment