├── .gitignore ├── .npmignore ├── .travis.yml ├── Extra.md ├── History.md ├── LICENSE ├── Makefile ├── Readme.md ├── bin ├── component ├── component-build ├── component-crawl ├── component-duplicates ├── component-help ├── component-install ├── component-link ├── component-ls ├── component-outdated ├── component-pin ├── component-search ├── component-update └── component-validate ├── disambiguation.md ├── package.json └── test ├── build.js ├── component.js ├── fixtures ├── local │ ├── component.json │ ├── direct │ │ ├── component.json │ │ └── index.js │ ├── index.js │ └── others │ │ ├── first │ │ ├── component.json │ │ └── index.js │ │ └── second │ │ ├── component.json │ │ └── index.js ├── no-js-css │ └── component.json ├── path │ ├── component.json │ ├── index.js │ └── lib │ │ ├── bar │ │ ├── component.json │ │ └── index.js │ │ └── baz │ │ ├── component.json │ │ └── index.js ├── plugin.js ├── tip.html └── tip.js └── install.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | components 3 | component.json 4 | build 5 | !test/fixtures/**/component.json 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | support 2 | test 3 | examples 4 | *.sock 5 | components 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | - "0.11" -------------------------------------------------------------------------------- /Extra.md: -------------------------------------------------------------------------------- 1 | # About Duo.js 2 | [Duo](https://github.com/duojs/duo) is an evolution of Component, which aims to solve some of the problems that were not addressed in the 1.0 release of Component. To quote Duo's FAQ: 3 | 4 | > While the release of Component 1.0 solved a lot of the initial gripes with earlier versions of Component, in the end we were after a more radical departure from Component that borrowed some good ideas from Browserify. 5 | 6 | Component's `component.json` should be compatible with Duo's interpretation of component.json, however, this is not guaranteed in the far future. Duo is currently in the very early stages of development and adoption, so, while newcomers might want to consider using Duo, development and support of Component will continue as long as Component continues to be used in deployment situations, and continues to be downloaded as frequently as it has. After the release of Component 1.0, the Component team will begin a roadmap for the next release. -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 1.1.0 / 2015-03-14 2 | ====================== 3 | 4 | * provide shrinkwrapper support: [component-shrinkwrapper](https://github.com/componentjs/shrinkwrapper) 5 | 6 | 1.0.1 / 2014-11-22 7 | ====================== 8 | 9 | * watch development fields [watcher.js#2](https://github.com/componentjs/watcher.js/issues/2) 10 | * check latest tag for component.json at first [component#611](https://github.com/componentjs/component/issues/611) 11 | * download archive if globs are used in component.json [downloader.js#7](https://github.com/componentjs/downloader.js/pull/7) 12 | 13 | 1.0.0 / 2014-10-30 14 | ====================== 15 | * use `debug` instead of consoler.js to warn about __requiring components below root__ 16 | * add repository redirects for api.github.com requests (if a user rename a repo) 17 | * require2 18 | 19 | * fix semver sorting for `require.latest` 20 | 21 | For a more in-depth changelog about v1, please read: https://github.com/component/guide/blob/master/changelogs/1.0.0.md. 22 | 23 | 1.0.0-rc7 / 2014-10-12 24 | ====================== 25 | 26 | * `component-build` 27 | 28 | * update autoprefixer 29 | 30 | * require2 31 | 32 | * provide `require.loader` 33 | * provide `require.latest(moduleName)` to require a remote module without specify the version 34 | 35 | 36 | 1.0.0-rc6 / 2014-10-05 37 | ====================== 38 | 39 | * `component-build --watch` deletes build files if errors occur and doesn't stop the process anymore 40 | * allow to require locals below the root without throwing an error 41 | * allow to require paths which cannot be resolved without throwing an error 42 | * fix requiring files from a local (without file extension) 43 | * feature: nested locals like `foo/bar` 44 | * fix CSS parsing for url rewriting, 10x faster 45 | * fix module name when exporting as AMD 46 | * fix AMD export for `strict` mode 47 | * fix remaining quotes when rewrite `require()` paths 48 | * allow hashtag in CSS URLs 49 | 50 | 51 | 1.0.0-rc5 / 2014-04-07 52 | ====================== 53 | 54 | Primarily bug fixes. 55 | 56 | * bitbucket support 57 | * `component-link` 58 | 59 | * add `--tag` 60 | * remove the requirement of the component name matching the repository name 61 | 62 | * `component-build` 63 | 64 | * fix `--out` 65 | * fix `--copy` 66 | * fix file path rewriting for local components 67 | 68 | * fix `component-ls --depth` 69 | 70 | 1.0.0-rc4 / 2014-04-04 71 | ====================== 72 | 73 | Component `1.0.0` is now feature complete. Please help debug and open an issues you may have with this release! `1.0.0` will not be released until http://component.io is updated. 74 | 75 | * doc updates 76 | * better debug/error messages 77 | * bug fixes 78 | * re-add `component install --proxy` 79 | 80 | 1.0.0-rc3 / 2014-04-03 81 | ====================== 82 | 83 | The primary goal of this release is to make 1.0.0 feature complete. Please try all the new commands and provide feedback! 84 | 85 | * add: 86 | 87 | - `component build --watch` 88 | - `component link` 89 | 90 | * update `component-search` to use crawled components 91 | 92 | 1.0.0-rc2 / 2014-04-03 93 | ====================== 94 | 95 | The primary goal of this release is to test the new commands. 96 | 97 | * add: 98 | 99 | - `component-duplicates` 100 | - `component-open` 101 | - `component-outdated` 102 | - `component-pin` 103 | - `component-update` 104 | - `component-validate` 105 | 106 | * reintroduce `--standalone` to `component-build` 107 | 108 | 1.0.0-rc1 / 2014-04-01 109 | ====================== 110 | 111 | The primary goal of this release is to test `component install` and `component build` and remove features we've decided to remove. 112 | 113 | * add: 114 | 115 | - `component-install` semver support 116 | - `component-install` now handles redirects (not w/ semver resolution, however) 117 | - `component-crawl` 118 | - `component-build ` for designating a specific build 119 | - `component-build styles --browsers` - default autoprefixer support 120 | - `component-build styles` - fix CSS dependency ordering 121 | - `component-build scripts` - es6 module support 122 | - `component-build scripts` - other generator improvements from [builder2](http://github.com/component/builder2.js) 123 | - `component-build scripts` - now autorequires by default 124 | 125 | * remove: 126 | 127 | - `component-create` - moved to [component-create](https://github.com/component/create.js) 128 | - `component-convert` 129 | - `component-wiki` 130 | - `component-info` 131 | - `component-changes` 132 | - `component-install --force` 133 | - `component-install` custom remotes (for now, need adapter APIs in [remotes](http://github.com/component/remotes.js)) 134 | - `component-install` proxy - temporarily removed/untested, will be added again later 135 | 136 | * changed: 137 | 138 | - `component-build scripts --umd` from `--standalone` 139 | 140 | * updated to comply with the latest [specs](https://github.com/component/spec/blob/master/component.json/specifications.md) 141 | 142 | 0.19.8 / 2014-03-29 143 | ================== 144 | 145 | * fix force install option #485 146 | * fix dependencies installed via not being added to component.json #466 147 | * bump deps 148 | 149 | 0.19.7 / 2014-02-25 150 | ================== 151 | 152 | * update github URLs in package.js to https://raw.githubusercontent.com 153 | 154 | 0.19.6 / 2014-02-06 155 | ================== 156 | 157 | * update component-installer to remove lowercasing 158 | * update "superagent-proxy" to v0.3.0 159 | * update "proxy-agent" to v1.1.0 160 | 161 | 0.19.5 / 2014-01-16 162 | ================== 163 | 164 | * update installer for lookup casing fix 165 | * fix casing in .lookup() 166 | 167 | 0.19.4 / 2014-01-16 168 | ================== 169 | 170 | * update installer for casing fix 171 | * update builder for casing fix 172 | 173 | 0.19.3 / 2014-01-07 174 | ================== 175 | 176 | * update installer 177 | 178 | 0.19.2 / 2014-01-06 179 | ================== 180 | 181 | * revert builder 182 | 183 | 0.19.1 / 2013-12-30 184 | ================== 185 | 186 | * update builder for main alias fix 187 | 188 | 0.19.0 / 2013-12-30 189 | ================== 190 | 191 | * add .netrc auth logic back 192 | * add proxy support 193 | * add full MIT license to component-create(1) 194 | * update component-builder for alias removal 195 | * change component-install to use installer.js 196 | * remove component-install(1) --out flag. Closes #389 197 | * change component-search(1) to only display "demo: ..." when present 198 | 199 | 0.18.0 / 2013-10-17 200 | ================== 201 | 202 | * update builder for json support 203 | 204 | 0.17.6 / 2013-09-17 205 | ================== 206 | 207 | * revert superagent enabling for now 208 | * add use of "open" for component-wiki 209 | 210 | 0.17.5 / 2013-09-13 211 | ================== 212 | 213 | * add superagent use back for netrc 214 | 215 | 0.17.4 / 2013-09-12 216 | ================== 217 | 218 | * update builder 219 | 220 | 0.17.3 / 2013-09-06 221 | ================== 222 | 223 | * update builder (require function change) 224 | 225 | 0.17.2 / 2013-09-03 226 | ================== 227 | 228 | * add superagent-proxy 229 | * add warning for missing bin 230 | * fix: bump version of netrc 231 | * fix: keep default gh remote from being added each install command. 232 | * fix: wait for packages to install successfully before writing component.json -- Should solve #386 233 | 234 | 0.17.0 / 2013-07-19 235 | ================== 236 | 237 | * update builder 238 | 239 | 0.16.8 / 2013-07-17 240 | ================== 241 | 242 | * fix dups reported in install output. Closes #372 243 | * fix corrupt downloads with quick superagent replacement. Closes #374 244 | 245 | 0.16.7 / 2013-07-05 246 | ================== 247 | 248 | * update superagent for unzip fixes 249 | 250 | 0.16.6 / 2013-07-02 251 | ================== 252 | 253 | * update superagent 254 | * fix node 0.8 issues when installing partial files 255 | * remove OAuth in .netrc instructions 256 | 257 | 0.16.5 / 2013-06-26 258 | ================== 259 | 260 | * update superagent 261 | * fixing resolve bug for node 0.10+ 262 | 263 | 0.16.4 / 2013-06-18 264 | ================== 265 | 266 | * fix build of empty js files when no js is present 267 | * fix installation of local dependencies via lookup paths 268 | * fix removal of semi-installed components 269 | 270 | 0.16.3 / 2013-06-06 271 | ================== 272 | 273 | * update builder 274 | 275 | 0.16.2 / 2013-05-31 276 | ================== 277 | 278 | * add dev url prefixing back 279 | 280 | 0.16.1 / 2013-05-30 281 | ================== 282 | 283 | * add mtime update of output directory on install. Closes #344 284 | * fix component-install(1) --dev, manip .development not .dependencies Closes #177 285 | 286 | 0.16.0 / 2013-05-13 287 | ================== 288 | 289 | * add netrc support 290 | * add `component-install(1)` --verbose 291 | * add .demo, closes #254 292 | * add -v, --verbose to component-search(1) with license / version. Closes #317 293 | * add `--no-require` to `component-build(1)` 294 | * remove component-docs(1) 295 | * fix: inFlight components do not emit `end` events 296 | 297 | 0.15.1 / 2013-04-26 298 | ================== 299 | 300 | * update builder for root-level main alias fix 301 | 302 | 0.15.0 / 2013-04-24 303 | ================== 304 | 305 | * update builder 306 | 307 | 0.14.0 / 2013-04-23 308 | ================== 309 | 310 | * add .main to component-create(1) generated component.json for clarity 311 | * add component-info(1) tests 312 | * add Package#url() default of first remote 313 | * remove .addLookup() from component-build(1), now performed in Builder 314 | * update builder 315 | * fix a call to fn() that should be done() 316 | * fix UMD: use "this" instead of window for global 317 | 318 | 0.13.2 / 2013-03-26 319 | ================== 320 | 321 | * change error handling to treat non-404s as fatals 322 | * fix exit status of component(1) 323 | * fix current .remote usage in Package 324 | 325 | 0.13.1 / 2013-03-19 326 | ================== 327 | 328 | * update builder 329 | * fix component-info(1) 330 | * fix: install: do not create component.json if it doesn't exist 331 | * fix fatal detection 332 | * add explicit remotes using `-r ` 333 | 334 | 0.13.0 / 2013-02-24 335 | ================== 336 | 337 | * add: only one in-flight request per component (~50% perf increase). Closes #47 338 | * add --use flag 339 | * remove makefile and .gitignore from component-create local components 340 | 341 | 0.12.0 / 2013-02-15 342 | ================== 343 | 344 | * add -c, --copy option to copy files instead of symlinking 345 | * fix AMD support for modules exporting functions 346 | 347 | 0.11.1 / 2013-02-01 348 | ================== 349 | 350 | * add component link to component-create(1) template 351 | * add `make test-remotes` 352 | * add correct version of dependency to component.json when installing 353 | * update builder 354 | * remove term-css dep 355 | * fix ability to install dependencies from remote repos 356 | 357 | 0.11.0 / 2012-12-30 358 | ================== 359 | 360 | * add AMD support to --standalone. Closes #139 361 | * add component-ls(1) --depth support 362 | * add in `` to getLocalJSON error 363 | * add in `` message to JSON parsing errors 364 | * add g+ community link 365 | * change component-ls(1) to use tree view. Closes #204 366 | * remove empty build.css output. Closes #80 367 | * update builder 368 | * fix component-info(1) example typo 369 | 370 | 0.10.1 / 2012-12-07 371 | ================== 372 | 373 | * rename win-spawn to win-fork [fixes #170] 374 | 375 | 0.10.0 / 2012-12-04 376 | ================== 377 | 378 | * add source url support when in --dev mode 379 | * fix component-search(1) EPIPE with pagers. Closes #122 380 | * remove component-open(1) 381 | 382 | 0.9.1 / 2012-11-28 383 | ================== 384 | 385 | * add increase of installation performance 50% via gzip 386 | * add increase of search performance 50% via gzip 387 | * update builder 388 | 389 | 0.9.0 / 2012-11-06 390 | ================== 391 | 392 | * add `-l, --local` to `component-create(1)`. Closes #119 393 | * add module check to `component-build(1)` --standalone dance 394 | * add `.paths` lookup path array support. Closes #137 395 | * update builder for root main alias fix 396 | * remove __COMPONENT_PATH__ support. Closes #137 397 | 398 | 0.8.0 / 2012-11-04 399 | ================== 400 | 401 | * add `-p, --prefix ` support 402 | * add asset copying and url rewriting. Closes #52 403 | * add `.images` and `.fonts` support for installation 404 | 405 | 0.7.1 / 2012-11-02 406 | ================== 407 | 408 | * add error-handling for getFiles(). Closes #121 409 | * add error(res, url) helper 410 | 411 | 0.7.0 / 2012-10-31 412 | ================== 413 | 414 | * add implicit `--save` to `component-install(1)`. Closes #103 415 | * add recursive `.local` support to `component-install(1)` 416 | * add better local dep failure message 417 | * add `-l, --license` to `component-search(1)`. Closes #107 418 | * add `component.lookup(pkg)` function 419 | * add `component.dependenciesOf(pkg)` function 420 | * add History.md to `component-create(1)`. Closes #101 421 | * add default .license of "MIT" to `component-create(1)` 422 | * update builder 423 | 424 | 0.6.4 / 2012-10-26 425 | ================== 426 | 427 | * fix a component-install(1) bug where a 404 would not display an error [damian] 428 | 429 | 0.6.3 / 2012-10-24 430 | ================== 431 | 432 | * update builder for main alias fix 433 | 434 | 0.6.2 / 2012-10-22 435 | ================== 436 | 437 | * add component-create(1) support for existing dirs and files. Closes #58 438 | * add local sub-command resolution 439 | * improve some error handling 440 | * fix annoying node warning for existsSync() 441 | * fix utils.error() stderr 442 | 443 | 0.6.1 / 2012-10-22 444 | ================== 445 | 446 | * change "bundled" to "local" 447 | 448 | 0.6.0 / 2012-10-22 449 | ================== 450 | 451 | * add __COMPONENT_PATH__ support. Closes #30 452 | * add `component.paths()` helper function 453 | * update builder 454 | 455 | 0.5.0 / 2012-10-19 456 | ================== 457 | 458 | * add "main" support 459 | * fix `component-search(1)` when description is missing. Closes #83 [Tim Oxley] 460 | 461 | 0.4.2 / 2012-10-17 462 | ================== 463 | 464 | * fix silly component-install(1) bug attempting to read ./component.json. Closes #81 465 | 466 | 0.4.1 / 2012-10-16 467 | ================== 468 | 469 | * update builder 470 | 471 | 0.4.0 / 2012-10-15 472 | ================== 473 | 474 | * add `.remotes` support. Closes #6 475 | * add --name option to specify the base name of built files. 476 | * change --standalone name to be required. Closes #71 477 | * update builder dep, remove --dev cascading. Closes #69 478 | 479 | 0.3.0 / 2012-10-10 480 | ================== 481 | 482 | * add readme template for `component-create(1)` with more boilerplate 483 | * add default of `{}` for conf for direct installs 484 | * add `auth` support for basic authentication [Dan Williams] 485 | 486 | 0.2.0 / 2012-10-06 487 | ================== 488 | 489 | * add `component-search(1)` `--open` flag to view in browser. Closes #39 490 | * add `component-wiki(1)`. Closes #55 491 | * add "y" as "yes" support 492 | * add `component-install(1)` `--save` support 493 | * fix < 0.8.x support 494 | 495 | 0.1.1 / 2012-09-19 496 | ================== 497 | 498 | * add new "stdio" child process inherit option. Closes #45 499 | * update component(1) --help docs 500 | * remove special-casing of 127 exit status 501 | * remove component-register(1) from package.json 502 | * fix subcommand execution on windows [ForbesLindesay] 503 | 504 | 0.1.0 / 2012-09-18 505 | ================== 506 | 507 | * add remote search 508 | * add ★ to search output 509 | * add sorting by stars 510 | * add --json to `component-search(1)` 511 | * remove `component-register(1)` 512 | * change `component-search(1)` to use only verbose output 513 | 514 | 0.0.7 / 2012-09-14 515 | ================== 516 | 517 | * add `--standalone [name]` support to component-build(1). Closes #34 518 | * add memoized mkdir 519 | * add empty .development `{}` to component-create(1) 520 | * update component-builder 521 | * remove "which" dependency 522 | * remove logging from component-convert(1) 523 | * remove "component.json" dep of component target in component-create(1) makefile 524 | * rename devDependencies to development 525 | 526 | 0.0.6 / 2012-09-05 527 | ================== 528 | 529 | * add `--dev` to `component-create(1)` build command 530 | * add `component-build(1)` --dev flag. Closes #25 531 | * rename `devDependencies` to `development` 532 | * fix `component-create(1)` undefined.css. Closes#24 533 | 534 | 0.0.5 / 2012-09-04 535 | ================== 536 | 537 | * add `--standalone` to `component-build(1)` 538 | 539 | 0.0.4 / 2012-09-01 540 | ================== 541 | 542 | * add `.repo` to `component-create(1)` 543 | * add `.files` support. Closes #11 544 | * fix installation of files nested in dirs 545 | * change `component-register(1)` to use .repo prop 546 | * change `component-search(1)` query to be optional 547 | * change `component-search(1)` to join args 548 | 549 | 0.0.3 / 2012-08-30 550 | ================== 551 | 552 | * add missing commands to package.json 553 | 554 | 0.0.2 / 2012-08-30 555 | ================== 556 | 557 | * update commander.js for pull-request fail 558 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | (The MIT License) 3 | 4 | Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | test: 3 | @./node_modules/.bin/mocha \ 4 | --require should \ 5 | --timeout 20s \ 6 | --slow 3s \ 7 | --bail \ 8 | --reporter spec 9 | 10 | .PHONY: test 11 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ![web component logo](http://i49.tinypic.com/e7nj9v.png) 2 | 3 | 4 | 5 | # THIS PROJECT IS DEPRECATED 6 | Component is not maintained anymore. See [here #639](https://github.com/componentjs/component/issues/639) for more information. 7 | 8 | You can still use the component registry on [component.github.io](http://component.github.io/) to search for components. 9 | All the [components](https://github.com/component) are not affected, because most of them also provide a `package.json` file. 10 | The `component.json` files in these components are still kept to provide backwards compatibility for component and [duo](http://duojs.org/). 11 | 12 | ## What now? 13 | Consider to use another tool, which rely on the [npm](https://www.npmjs.com/) and the [package.json](https://docs.npmjs.com/files/package.json) standard: 14 | 15 | - [webpack](http://webpack.github.io/) 16 | - [jspm](http://jspm.io/) (supports npm and github endpoint) 17 | - [browserify](http://browserify.org/) 18 | 19 | --- 20 | 21 | Component is a vertically integrated frontend solution, handling everything from package management to the build process, handling everything including HTML, JS, CSS, images, and fonts. Think of it as an opinionated `npm + browserify + rework-npm + grunt/gulp/broccoli` all wrapped into `component build`. 22 | 23 | Want to know more about Component? Visit the [guide](https://github.com/componentjs/guide) or view the [comparison with other solutions](https://github.com/componentjs/guide/blob/master/component/vs.md). 24 | 25 | If you're confused about _component_, _components_, _componentjs_, please read [disambiguation](https://github.com/componentjs/component/blob/master/disambiguation.md) 26 | 27 | > **Component 1.0.0**: Several 28 | major new features have been added, some have been removed, and the project has been greatly reorganized. You may need to upgrade your 29 | version of node and/or npm to avoid breakage. Please see the detailed [changelog](https://github.com/componentjs/guide/blob/master/changelogs/1.0.0.md). Component 0.x will not be maintained anymore. 30 | 31 | ## Installation 32 | 33 | First, you need [node](http://nodejs.org) v0.10+ installed. If you do not have it installed, visit [node's download page](http://nodejs.org/download/). 34 | 35 | With [node](http://nodejs.org) installed, run the following command: 36 | 37 | $ npm install -g component 38 | 39 | ## Getting Started 40 | 41 | Read this [Getting Started](https://github.com/componentjs/guide/blob/master/component/getting-started.md) guide to get a basic static site running very quickly with Component. 42 | 43 | Note: the Component repo (this repo) has only documentation for Component 0.19. All of the documentation related to 1.0.0 will be handled in the [guide repo](https://github.com/componentjs/guide). 44 | 45 | ## Team 46 | 47 | The team and organization have undergone massive changes. In summary, [jonathanong](https://github.com/jonathanong) stopped developing Component and started with [normalize.io](https://normalize.github.io/) and the guys from [segmentio](https://github.com/segmentio) switched to using [duo](http://duojs.org). Component will still be maintained and updated while it is in use. You can read more about Duo.js and Component [here](https://github.com/componentjs/component/blob/master/Extra.md#about-duojs). 48 | 49 | The long story of Component and the changes that occurred in component can be found in Jonathan Ong's blog post ["the future of component"](http://www.jongleberry.com/the-future-of-component.html). 50 | 51 | Development for component (maintenance and features) will be continued at the latest when latest browsers will support the [ES6 modules](http://guybedford.com/es6-modules-today) and [Web Components](http://www.w3.org/TR/components-intro/) natively. 52 | 53 | ## Contributors 54 | 55 | - [Anton Wilhelm](https://github.com/timaschew)/[@timaschew](https://twitter.com/timaschew) - maintainer 56 | - [Keith Rosenberg](https://github.com/netpoetica)/[@netpoetica](https://twitter.com/netpoetica) - maintainer 57 | - [Trevor Gerhardt](https://github.com/trevorgerhardt)/[@trevorgerhardt](https://twitter.com/trevorgerhardt) - maintainer 58 | - [Clinton Wood](https://github.com/clintwood) - maintainer 59 | - [Jason Kurht](https://github.com/jasonkuhrt)/[@jasonkuhrt](https://twitter.com/jasonkuhrt) - maintainer 60 | - [visionmedia](https://github.com/visionmedia)/[@tjholowaychuk](https://twitter.com/tjholowaychuk) - original author 61 | - [jonathanong](https://github.com/jonathanong)/[@jongleberry](https://twitter.com/jongleberry) - second-gen author 62 | - [segmentio](https://github.com/segmentio)/[segment.io](https://segment.io) - original sponsor 63 | -------------------------------------------------------------------------------- /bin/component: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | // usage 6 | 7 | program 8 | .version(require('../package').version) 9 | .usage(' [options]'); 10 | 11 | // sub-command help 12 | 13 | program.on('--help', function(){ 14 | console.log(' Commands:'); 15 | console.log(); 16 | console.log(' build build the component'); 17 | console.log(' crawl crawl a github user/organization for components'); 18 | console.log(' duplicates check for multiple versions of dependencies'); 19 | console.log(' install [name ...] install and save one or more components'); 20 | console.log(' link [folder] symlink a component'); 21 | console.log(' ls list installed components'); 22 | console.log(' outdated check for outdated pinned dependencies'); 23 | console.log(' pin pin ranged dependencies'); 24 | console.log(' search [query] search with the given query'); 25 | console.log(' update update pinned dependencies') 26 | console.log(' validate validate component.json\'s'); 27 | console.log(); 28 | console.log(' For more help, run `component build -h` for relevant links.'); 29 | console.log(); 30 | process.exit(); 31 | }); 32 | 33 | // parse argv 34 | 35 | program.parse(process.argv); 36 | 37 | var spawn = require('win-fork'); 38 | var path = require('path'); 39 | var fs = require('fs'); 40 | var join = path.join; 41 | var stat = fs.statSync; 42 | var exists = fs.existsSync; 43 | var resolve = path.resolve; 44 | 45 | // args void of cmd 46 | 47 | var args = process.argv.slice(3); 48 | 49 | // command 50 | 51 | var cmd = program.args[0]; 52 | 53 | // alias "install" as "add" 54 | 55 | if ('add' === cmd) cmd = 'install'; 56 | 57 | // display help 58 | 59 | if (!cmd) program.help(); 60 | 61 | // executable 62 | 63 | var bin = 'component-' + cmd; 64 | 65 | // local or resolve to absolute executable path 66 | 67 | var local = join(__dirname, bin); 68 | 69 | if (exists(local)) { 70 | bin = local; 71 | } else { 72 | bin = process.env.PATH.split(path.delimiter).reduce(function(binary, p) { 73 | p = resolve(p, bin); 74 | return exists(p) && stat(p).isFile() ? p : binary; 75 | }, bin); 76 | } 77 | 78 | // display help if bin does not exist 79 | 80 | if (!exists(bin)) { 81 | console.error('\n %s(1) does not exist', bin); 82 | program.help(); 83 | } 84 | 85 | // spawn 86 | 87 | var proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] }); 88 | 89 | proc.on('close', function(code){ 90 | process.exit(code); 91 | }); 92 | -------------------------------------------------------------------------------- /bin/component-build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | // options 6 | 7 | program 8 | .usage('component build [scripts] [styles] [files]') 9 | .option('-w, --watch', 'watch for file changes and rebuild automatically') 10 | .option('-r, --reload', 'refresh livereload server on file changes (works only with --watch)') 11 | .option('-o, --out ', 'output directory defaulting to ./build', 'build') 12 | .option('-n, --name ', 'base name for build files defaulting to build', 'build') 13 | .option('-d, --dev', 'build development dependencies, use aliases, and use sourceURLs') 14 | .option('-s, --standalone [name]', 'build a standalone, UMD-wrapped version of the component with the given global name') 15 | .option('-R, --no-require', 'exclude require from build') 16 | .option('-a, --no-auto', 'not require automatically') 17 | .option('-p, --prefix ', 'prefix css asset urls with ', '') 18 | .option('-b, --browsers ', 'browsers to support with autoprefixer') 19 | .option('-c, --copy', 'copy files instead of linking') 20 | .option('--umd [name]', 'alias for --standalone') 21 | .option('--debug', 'turn on debug statements'); 22 | 23 | // examples 24 | 25 | program.on('--help', function(){ 26 | console.log(' Examples:'); 27 | console.log(); 28 | console.log(' # build to ./build'); 29 | console.log(' $ component build'); 30 | console.log(); 31 | console.log(' # build to ./dist as assets.js, assets.css'); 32 | console.log(' $ component build -o dist -n assets'); 33 | console.log(); 34 | console.log(' # build as standalone as window.$'); 35 | console.log(' $ component build --standalone $'); 36 | console.log(); 37 | console.log(' # build only .js'); 38 | console.log(' $ component build scripts'); 39 | console.log(); 40 | process.exit(); 41 | }); 42 | 43 | // parse argv 44 | 45 | program.parse(process.argv); 46 | 47 | if (program.debug) require('debug').enable('component-build*,component-consoler*,component-resolver*'); 48 | 49 | var Resolve = require('component-resolver'); 50 | var utils = require('component-consoler'); 51 | var Build = require('component-build'); 52 | var mkdir = require('mkdirp'); 53 | var path = require('path'); 54 | var fs = require('fs'); 55 | var rimraf = require('rimraf'); 56 | 57 | var exists = fs.existsSync || path.existsSync; 58 | var args = program.args; 59 | var log = utils.log; 60 | var slice = Array.prototype.slice; 61 | 62 | // object of which files to build 63 | var builds; 64 | if (!args.length) { 65 | builds = { 66 | scripts: true, 67 | styles: true, 68 | files: true, 69 | }; 70 | } else { 71 | builds = { 72 | scripts: !!~args.indexOf('scripts') 73 | || !!~args.indexOf('js'), 74 | styles: !!~args.indexOf('styles') 75 | || !!~args.indexOf('css'), 76 | files: !!~args.indexOf('files'), 77 | }; 78 | } 79 | 80 | // component.json required 81 | 82 | if (!exists('component.json')) utils.fatal('missing component.json'); 83 | 84 | // output paths 85 | 86 | var jsPath = path.join(program.out, program.name + '.js'); 87 | var cssPath = path.join(program.out, program.name + '.css'); 88 | 89 | // mkdir -p 90 | 91 | mkdir.sync(program.out); 92 | 93 | // whitespace 94 | 95 | console.log(); 96 | 97 | process.on('exit', function(){ 98 | console.log(); 99 | }); 100 | 101 | // resolve 102 | 103 | var options = { 104 | development: program.dev, 105 | install: true, 106 | verbose: true, 107 | require: program.require, 108 | autorequire: program.auto, 109 | umd: program.standalone || program.umd || '', 110 | prefix: program.prefix || '', 111 | browsers: program.browsers, 112 | destination: program.out, 113 | copy: program.copy, 114 | }; 115 | 116 | var watching = program.watch || program.reload; 117 | var resolving = false; 118 | 119 | var build; 120 | 121 | if (!watching) return resolve(); 122 | 123 | var watcher = require('component-watcher')({ 124 | root: process.cwd(), 125 | development: program.dev 126 | }); 127 | 128 | watcher.on('resolve', resolve); 129 | watcher.on('scripts', buildScripts); 130 | watcher.on('styles', buildStyles); 131 | 132 | process.stdin.setEncoding('utf8'); 133 | process.stdin.on('data', function (data) { 134 | switch (data.trim()) { 135 | case 'r': 136 | case 'resolve': 137 | return resolve(); 138 | case 's': 139 | case 'j': 140 | case 'js': 141 | case 'scripts': 142 | return buildScripts(); 143 | case 'c': 144 | case 'css': 145 | case 'styles': 146 | return buildStyles(); 147 | } 148 | }); 149 | 150 | if (!program.reload) return; 151 | 152 | var server = require('tiny-lr-fork')(); 153 | server.listen(35729); 154 | 155 | server.on('error', function (err) { 156 | if (err.code === 'EADDRINUSE') { 157 | utils.fatal('livereload port 35729 is already in use by another process'); 158 | } 159 | 160 | utils.fatal(err); 161 | }); 162 | 163 | function reload() { 164 | if (program.reload) { 165 | server.changed({ 166 | body: { 167 | files: slice.call(arguments) 168 | } 169 | }); 170 | } 171 | } 172 | 173 | function resolve() { 174 | if (resolving) return; 175 | resolving = true; 176 | var start = Date.now(); 177 | Resolve(process.cwd(), options, function (err, tree) { 178 | resolving = false; 179 | if (err) { 180 | if (!watching) utils.fatal(err); 181 | utils.error('build', 'resolve failed: ' + err.message); 182 | return; 183 | } 184 | 185 | build = Build(tree, options); 186 | 187 | log('build', 'resolved in ' + (Date.now() - start) + 'ms'); 188 | 189 | buildScripts(); 190 | buildStyles(); 191 | buildFiles(); 192 | }) 193 | } 194 | 195 | function buildScripts() { 196 | if (resolving) return; 197 | if (!builds.scripts) return; 198 | var start = Date.now(); 199 | build.scripts(function (err, js) { 200 | if (err) { 201 | utils.error(err); 202 | if (fs.existsSync(jsPath)) fs.unlinkSync(jsPath); 203 | return; 204 | } 205 | if (!js) return; 206 | fs.writeFile(jsPath, js); 207 | log('build', jsPath + ' in ' 208 | + (Date.now() - start) + 'ms - ' 209 | + (js.length / 1024 | 0) + 'kb'); 210 | reload(jsPath); 211 | }) 212 | } 213 | 214 | function buildStyles() { 215 | if (resolving) return; 216 | if (!builds.styles) return; 217 | var start = Date.now(); 218 | build.styles(function (err, css) { 219 | if (err) { 220 | utils.error(err); 221 | if (fs.existsSync(cssPath)) fs.unlinkSync(cssPath); 222 | return; 223 | } 224 | if (!css) return; 225 | fs.writeFile(cssPath, css); 226 | log('build', cssPath + ' in ' 227 | + (Date.now() - start) + 'ms - ' 228 | + (css.length / 1024 | 0) + 'kb'); 229 | reload(cssPath); 230 | }) 231 | } 232 | 233 | function buildFiles() { 234 | if (resolving) return; 235 | if (!builds.files) return; 236 | var start = Date.now(); 237 | build.files(function (err) { 238 | if (err) { 239 | utils.error(err); 240 | rimraf(options.destination, function(err) { 241 | if (err) utils.fatal(err); 242 | return 243 | }); 244 | } else { 245 | log('build', 'files in ' + (Date.now() - start) + 'ms'); 246 | } 247 | }) 248 | } 249 | -------------------------------------------------------------------------------- /bin/component-crawl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var program = require('commander'); 8 | 9 | program 10 | .usage('...') 11 | .option('--debug', 'turn on debug statements'); 12 | 13 | program.parse(process.argv); 14 | 15 | if (program.debug) require('debug').enable('component-consoler*'); 16 | 17 | var request = require('superagent'); 18 | var utils = require('component-consoler'); 19 | 20 | var endpoint = process.env.COMPONENT_CRAWLER_ENDPOINT 21 | || 'http://component-crawler.herokuapp.com/'; 22 | 23 | var users = program.args; 24 | if (!users.length) utils.fatal(' required.'); 25 | 26 | users.forEach(function (user) { 27 | request 28 | .patch(endpoint + user) 29 | .end(function (err, res) { 30 | if (err) throw err; 31 | if (!res.ok) utils.fatal('failed to crawl "%s".', user); 32 | utils.log('crawling', user); 33 | }); 34 | }); -------------------------------------------------------------------------------- /bin/component-duplicates: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | program 6 | .option('-d, --dev', 'check development dependencies') 7 | .option('--debug', 'turn on debug statements') 8 | .parse(process.argv); 9 | 10 | if (program.debug) require('debug').enable('component-consoler*,component-flatten*,component-resolver*'); 11 | 12 | var resolve = require('component-resolver'); 13 | var flatten = require('component-flatten'); 14 | var utils = require('component-consoler'); 15 | 16 | resolve(process.cwd(), { 17 | development: program.dev, 18 | install: true, 19 | verbose: true, 20 | }, function (err, tree) { 21 | if (err) utils.fatal(err); 22 | 23 | var dupes = flatten(tree).duplicates; 24 | var names = Object.keys(dupes); 25 | if (!names.length) return utils.log('duplicates', 'no duplicates found!'); 26 | 27 | names.forEach(function (name) { 28 | var deps = dupes[name]; 29 | var versions = Object.keys(deps); 30 | utils.warn('duplicates', '"' + name + '" has ' + versions.length + ' versions in this build:'); 31 | versions.forEach(function (version) { 32 | var node = deps[version]; 33 | utils.warn('version', ' ' + version); 34 | node.dependents.forEach(function (dependent) { 35 | utils.warn('dependent', ' ' + dependent.canonical); 36 | }) 37 | }) 38 | console.error(); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /bin/component-help: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var exec = require('child_process').exec; 4 | var program = require('commander'); 5 | 6 | // parse argv 7 | 8 | program.parse(process.argv); 9 | 10 | // output --help 11 | 12 | var cmd = program.args[0] 13 | ? 'component ' + program.args[0] + ' --help' 14 | : 'component --help'; 15 | 16 | exec(cmd, function(err, stdout){ 17 | if (err) throw err; 18 | process.stdout.write(stdout); 19 | }); 20 | -------------------------------------------------------------------------------- /bin/component-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | /** 6 | * Options. 7 | */ 8 | 9 | program 10 | .usage('[name ...]') 11 | .option('-d, --dev', 'install development dependencies') 12 | .option('-p, --proxy', 'use a proxy, eg. http://localhost:3128') 13 | .option('-t, --timeout ', 'use a timeout for remotes, default: 5000ms', 5000) 14 | .option('--debug', 'turn on debug statements') 15 | // .option('-p, --proxy ', 'use a proxy, eg. http://localhost:3128') 16 | .parse(process.argv); 17 | 18 | /** 19 | * Examples. 20 | */ 21 | 22 | program.on('--help', function(){ 23 | console.log(' Examples:'); 24 | console.log(); 25 | console.log(' # install deps in ./component.json'); 26 | console.log(' $ component install'); 27 | console.log(); 28 | console.log(' # install a single component'); 29 | console.log(' $ component install component/tip'); 30 | console.log(); 31 | console.log(' # install several components'); 32 | console.log(' $ component install component/tip component/popover'); 33 | console.log(); 34 | console.log(' # install a specific tag / sha'); 35 | console.log(' $ component install component/tip@8bf1ffc3f'); 36 | console.log(); 37 | console.log(' # install regular & development deps in .'); 38 | console.log(' $ component install -d'); 39 | console.log(); 40 | process.exit(); 41 | }); 42 | 43 | if (program.debug) require('debug').enable('component-consoler*,component-resolver*'); 44 | 45 | var resolve = require('component-resolver'); 46 | var utils = require('component-consoler'); 47 | var semver = require('semver'); 48 | var path = require('path'); 49 | var fs = require('fs'); 50 | 51 | var exists = fs.existsSync; 52 | var write = fs.writeFileSync; 53 | var fatal = utils.fatal; 54 | var log = utils.log; 55 | var dependencies = program.args; 56 | var jsonPath = path.resolve('component.json'); 57 | var hasJson = exists(jsonPath); 58 | 59 | // whitespace 60 | 61 | console.log(); 62 | 63 | process.on('exit', function(){ 64 | console.log(); 65 | }); 66 | 67 | /** 68 | * Installer. 69 | */ 70 | 71 | var options = { 72 | development: program.dev, 73 | proxy: program.proxy, 74 | timeout: program.timeout, 75 | install: true, 76 | verbose: true, 77 | }; 78 | 79 | // Install everything in the dependency tree 80 | if (!dependencies.length) { 81 | if (!hasJson) fatal('missing component.json'); 82 | resolve(process.cwd(), options, function (err) { 83 | if (err) fatal(err); 84 | log('install', 'complete'); 85 | }); 86 | return; 87 | } 88 | 89 | var json = hasJson && require(jsonPath); 90 | 91 | var deps = {}; 92 | dependencies = dependencies.map(function (dependency) { 93 | var frags = dependency.split('@'); 94 | var name = frags[0].toLowerCase(); 95 | if (!~name.indexOf('/')) utils.fatal('"' + name + '" is not a valid dependency'); 96 | var version = frags[1]; 97 | deps[name] = version || '*'; 98 | return [name, version]; 99 | }); 100 | 101 | resolve({ 102 | dependencies: deps 103 | }, options, function (err, tree) { 104 | if (err) fatal(err); 105 | log('install', 'complete'); 106 | if (!json) return; 107 | 108 | json.dependencies = json.dependencies || {}; 109 | 110 | dependencies.forEach(function (dep) { 111 | var name = dep[0]; 112 | var version = dep[1]; 113 | // if the dependency, don't install. 114 | // not sure if this is correct behavior. 115 | if (json.dependencies[name]) return; 116 | // if we're installing "any" version, 117 | // add a corresponding ^ or ~ to the current version 118 | if (!version) { 119 | var node = tree.dependencies[name]; 120 | if (!node.version) { 121 | version = '*'; // this means master 122 | } else if (semver.gte(node.version, '1.0.0')) { 123 | version = '^' + node.version; 124 | } else { 125 | version = '~' + node.version; 126 | } 127 | } 128 | json.dependencies[name] = version; 129 | }); 130 | 131 | write(jsonPath, JSON.stringify(json, null, 2)); 132 | }) 133 | -------------------------------------------------------------------------------- /bin/component-link: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | program 6 | .usage('[../path/to/folder]') 7 | .option('-t, --tag ', 'link as a specific version/tag/commit/branch') 8 | .option('-r, --repository ', 'link as a specific repository') 9 | .option('--debug', 'turn on debug statements'); 10 | 11 | program.on('--help', function() { 12 | console.log(' Example: '); 13 | console.log(); 14 | console.log(' $ component link ../delegate'); 15 | console.log(); 16 | process.exit(); 17 | }); 18 | 19 | program.parse(process.argv); 20 | 21 | if (program.debug) require('debug').enable('component-consoler*'); 22 | 23 | var fs = require('fs'); 24 | var path = require('path'); 25 | var mkdirp = require('mkdirp'); 26 | var rimraf = require('rimraf'); 27 | var utils = require('component-consoler'); 28 | 29 | if (program.args.length !== 1) utils.fatal('requires exactly one local path.'); 30 | 31 | var from = path.resolve(program.args[0]); 32 | var component = path.join(from, 'component.json'); 33 | if (!fs.existsSync(component)) utils.fatal(component + ' does not exist!'); 34 | 35 | if (path.relative(process.cwd(), from).slice(0, 2) !== '..') { 36 | utils.fatal('can not link a component inside the app context.'); 37 | } 38 | 39 | var json = require(component); 40 | 41 | var repository = program.repository || json.repository || json.repo; 42 | if (!repository) utils.fatal(component + ' does not have a repository!'); 43 | if (!~repository.indexOf('/')) utils.fatal(component + ' invalid repository. Repositories are of the form /.'); 44 | 45 | var version = program.tag || json.version; 46 | if (!version) utils.fatal(component + ' does not have a version!'); 47 | 48 | var to = path.join(process.cwd(), 'components', repository, version); 49 | 50 | rimraf.sync(to); 51 | mkdirp.sync(path.dirname(to)); 52 | fs.symlinkSync(from, to, 'junction'); 53 | -------------------------------------------------------------------------------- /bin/component-ls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | // parse argv 6 | 7 | program 8 | .option('-d, --depth ', 'set the depth to ', Infinity) 9 | .option('--debug', 'turn on debug statements') 10 | .parse(process.argv); 11 | 12 | if (program.debug) require('debug').enable('component-consoler*,component-ls*,component-resolver*'); 13 | 14 | var resolve = require('component-resolver'); 15 | var utils = require('component-consoler'); 16 | var ls = require('component-ls'); 17 | 18 | // output tree 19 | 20 | resolve(process.cwd(), function (err, tree) { 21 | if (err) utils.fatal(err); 22 | ls(tree, program.depth); 23 | }) 24 | -------------------------------------------------------------------------------- /bin/component-outdated: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | program 6 | .option('-d, --dev', 'update development dependencies') 7 | .option('--debug', 'turn on debug statements') 8 | .parse(process.argv); 9 | 10 | if (program.debug) require('debug').enable('component-consoler*,component-outdated2*,component-resolver*'); 11 | 12 | var fatal = require('component-consoler').fatal; 13 | var outdated = require('component-outdated2'); 14 | var resolve = require('component-resolver'); 15 | var co = require('co'); 16 | 17 | var options = { 18 | development: program.dev, 19 | dependencies: false, 20 | verbose: true, 21 | }; 22 | 23 | resolve(process.cwd(), options, function (err, tree) { 24 | if (err) fatal(err); 25 | 26 | co(outdated(tree, options))(function (err) { 27 | if (err) fatal(err); 28 | }) 29 | }) 30 | -------------------------------------------------------------------------------- /bin/component-pin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | program 6 | .option('-d, --dev', 'pin development dependencies') 7 | .option('--debug', 'turn on debug statements') 8 | .parse(process.argv); 9 | 10 | if (program.debug) require('debug').enable('component-consoler*,component-pin*,component-resolver*'); 11 | 12 | var fatal = require('component-consoler').fatal; 13 | var resolve = require('component-resolver'); 14 | var pin = require('component-pin'); 15 | var co = require('co'); 16 | 17 | var options = { 18 | development: program.dev, 19 | install: true, 20 | verbose: true, 21 | }; 22 | 23 | resolve(process.cwd(), options, function (err, tree) { 24 | if (err) fatal(err); 25 | 26 | co(pin(tree, options))(function (err) { 27 | if (err) fatal(err); 28 | }) 29 | }) 30 | -------------------------------------------------------------------------------- /bin/component-search: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | // parse argv 6 | 7 | program 8 | .usage('[query]') 9 | .option('-o, --owner ', 'filter by a GitHub user/organization') 10 | .option('-k, --keywords ', 'filter by a comma-delimited list of keywords') 11 | .option('-l, --limit ', 'maximum number of results', parseInt) 12 | .option('-f, --force', 'force redownloading the cache') 13 | .option('-m, --maxage ', 'redownload the cache if older than '. parseInt) 14 | .option('-v, --verbose', 'verbose output') 15 | .option('--debug', 'turn on debug statements') 16 | .parse(process.argv); 17 | 18 | if (program.debug) require('debug').enable('component-consoler*,component-search*'); 19 | 20 | var co = require('co'); 21 | var utils = require('component-consoler'); 22 | var search = co(require('component-search2')); 23 | 24 | var cols = process.stdout.columns || 80; 25 | 26 | var query = { 27 | text: program.args.join(' '), 28 | owner: program.owner, 29 | limit: program.limit || 5, 30 | force: program.force, 31 | maxage: 1000 * (program.maxage || 3600), 32 | verbose: true, 33 | } 34 | 35 | if (program.keywords) { 36 | var keywords = program.keywords.split(','); 37 | if (keywords.length) query.keywords = keywords; 38 | } 39 | 40 | // whitespace 41 | 42 | console.log(); 43 | 44 | process.on('exit', function(){ 45 | console.log(); 46 | }); 47 | 48 | // search 49 | 50 | search(query, function (err, pkgs) { 51 | if (err) utils.fatal(err); 52 | if (!pkgs.length) return utils.log('search', 'no matching components found'); 53 | verbose(pkgs); 54 | }) 55 | 56 | /** 57 | * Verbose output. 58 | */ 59 | 60 | function verbose(pkgs) { 61 | console.log(); 62 | pkgs.forEach(function(pkg){ 63 | console.log(' \033[36m%s\033[m', pkg.repo.toLowerCase()); 64 | console.log(' url: \033[90mhttps://github.com/%s\033[m', pkg.repo); 65 | console.log(' desc: \033[90m%s\033[m', description(pkg.description)); 66 | if (program.verbose && pkg.demo) console.log(' demo: \033[90m%s\033[m', pkg.demo); 67 | if (program.verbose) console.log(' version: \033[90m%s\033[m', pkg.version); 68 | if (program.verbose) console.log(' license: \033[90m%s\033[m', pkg.license || 'none'); 69 | console.log(' ★ \033[90m%s\033[m', pkg.github.stargazers_count); 70 | console.log(); 71 | }); 72 | console.log(); 73 | } 74 | 75 | /** 76 | * Wrap description `str`. 77 | */ 78 | 79 | function description(str) { 80 | if (!str) return ''; 81 | var space; 82 | var width = cols - 20; 83 | for (var i = 0; i < str.length; ++i) { 84 | if (i && i % width === 0) { 85 | space = str.indexOf(' ', i); 86 | str = str.slice(0, space) + '\n ' + str.slice(space); 87 | } 88 | } 89 | return str; 90 | } 91 | -------------------------------------------------------------------------------- /bin/component-update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | program 6 | .option('-d, --dev', 'update development dependencies') 7 | .option('--debug', 'turn on debug statements') 8 | .parse(process.argv); 9 | 10 | if (program.debug) require('debug').enable('component-consoler*,component-resolver*,component-updater*'); 11 | 12 | var fatal = require('component-consoler').fatal; 13 | var resolve = require('component-resolver'); 14 | var update = require('component-updater'); 15 | var co = require('co'); 16 | 17 | var options = { 18 | development: program.dev, 19 | dependencies: false, 20 | verbose: true, 21 | }; 22 | 23 | // whitespace 24 | 25 | console.log(); 26 | 27 | process.on('exit', function(){ 28 | console.log(); 29 | }); 30 | 31 | resolve(process.cwd(), options, function (err, tree) { 32 | if (err) fatal(err); 33 | 34 | co(update(tree, options))(function (err) { 35 | if (err) fatal(err); 36 | }) 37 | }) 38 | -------------------------------------------------------------------------------- /bin/component-validate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'); 4 | 5 | program 6 | .option('--debug', 'turn on debug statements') 7 | .parse(process.argv); 8 | 9 | if (program.debug) require('debug').enable('component-consoler*,component-resolver*'); 10 | 11 | var resolve = require('component-resolver'); 12 | var fatal = require('component-consoler').fatal; 13 | 14 | resolve(process.cwd(), { 15 | // no need to resolve dependencies 16 | dependencies: false, 17 | verbose: true, 18 | validate: true, 19 | }, function (err) { 20 | if (err) fatal(err); 21 | }) 22 | -------------------------------------------------------------------------------- /disambiguation.md: -------------------------------------------------------------------------------- 1 | # Disambiguation 2 | 3 | > __component__ is ambiguous 4 | 5 | ### component 6 | Component is tool for package and build management for the frontend. It's 7 | written in JavaScript and you can run it with Node.js. 8 | 9 | http://github.com/componentjs 10 | 11 | ### components 12 | Components are modular frontend components which can be used with component to build web applications. 13 | http://github.com/component is a GitHub organization which contains many components. 14 | 15 | You can join our IRC channel on freenode: [#components](http://webchat.freenode.net/?channels=components) 16 | 17 | ### component.io 18 | http://component.github.io is the _official registry_ you can add your own 19 | components via the crawler, [see 1.0.0 changelog](https://github.com/componentjs/guide/blob/97efd0a1c8292a90bc679fafdb76e3ad4056ae5e/changelogs/1.0.0.md#registry-crawler) 20 | There is also a [GitHub Wiki](https://github.com/componentjs/component/wiki/Components) which is kind of the _old registry_. 21 | 22 | [[component.io]](http://stackoverflow.com/questions/tagged/component.io) on Stack Overflow 23 | 24 | [@componentIO](http://twitter.com/componentIO) on Twitter 25 | 26 | You should use `component.io` in a general context to avoid disambiguation. 27 | 28 | ## component in another context 29 | 30 | #### github.com/components 31 | https://github.com/components is a GitHub organization which support many 32 | package manager like npm, Bower, Component, Jam, volo, ... 33 | 34 | https://github.com/components/components 35 | 36 | 37 | #### ComponentJS 38 | Run-time Component System for structuring HTML5-based Rich Clients by 39 | Ralf S. Engelschall 40 | 41 | http://componentjs.com 42 | 43 | #### bower's component.json 44 | Bower has now their own [bower.json](https://github.com/bower/bower.json-spec) 45 | file. But in earlier versions they used 46 | [component.json](https://groups.google.com/forum/#!topic/twitter-bower/Dcq8G0en1WI). 47 | Some properties of `bower.json` and [component's](https://github.com/componentjs/spec/blob/master/component.json/specifications.md) `component.json` have the 48 | same name, but there is no `scripts` property, so `bower.json` is not compatible 49 | with component. 50 | 51 | http://bower.io 52 | 53 | #### webcomponents 54 | Web Components are a collection of standards which are working their way 55 | through the W3C. They enable truly encapsulated and reusable components for 56 | the web. And if you think HTML5 changed the web, wait to see what Web 57 | Components will do. 58 | 59 | http://webcomponents.org 60 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "component", 3 | "version": "1.1.0", 4 | "description": "Component package manager consuming git repositories", 5 | "keywords": [ 6 | "component", 7 | "package", 8 | "client", 9 | "browser", 10 | "module" 11 | ], 12 | "author": "TJ Holowaychuk ", 13 | "repository": "componentjs/component", 14 | "dependencies": { 15 | "component-build": "^1.2.2", 16 | "component-consoler": "^2.0.0", 17 | "component-flatten": "^1.0.1", 18 | "component-ls": "^2.1.0", 19 | "component-outdated2": "^1.0.4", 20 | "component-pin": "^1.0.4", 21 | "component-resolver": "^1.3.0", 22 | "component-search2": "^1.1.1", 23 | "component-updater": "^1.0.4", 24 | "component-watcher": "^1.0.1", 25 | "component-remotes": "^1.2.0", 26 | "commander": "^2.2.0", 27 | "semver": "^2.2.1", 28 | "mkdirp": "~0.3.5", 29 | "rimraf": "^2.2.6", 30 | "superagent": "~0.17.0", 31 | "win-fork": "~1.1.1", 32 | "debug": "*", 33 | "co": "^3.0.0", 34 | "tiny-lr-fork": "0.0.5" 35 | }, 36 | "devDependencies": { 37 | "mocha": "1", 38 | "should": "3" 39 | }, 40 | "bin": { 41 | "component": "bin/component", 42 | "component-build": "bin/component-build", 43 | "component-crawl": "bin/component-crawl", 44 | "component-duplicates": "bin/component-duplicates", 45 | "component-help": "bin/component-help", 46 | "component-install": "bin/component-install", 47 | "component-link": "bin/component-link", 48 | "component-ls": "bin/component-ls", 49 | "component-outdated": "bin/component-outdated", 50 | "component-pin": "bin/component-pin", 51 | "component-search": "bin/component-search", 52 | "component-update": "bin/component-update", 53 | "component-validate": "bin/component-validate" 54 | }, 55 | "main": "lib/component", 56 | "engines": { 57 | "node": ">= 0.10.0" 58 | }, 59 | "scripts": { 60 | "test": "make test" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test/build.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var exec = require('child_process').exec; 7 | var exists = require('fs').existsSync; 8 | var stat = require('fs').statSync; 9 | var assert = require('assert'); 10 | var path = require('path'); 11 | var fs = require('fs'); 12 | var vm = require('vm'); 13 | 14 | var bin = __dirname + '/../bin/component'; 15 | 16 | describe('component build', function(){ 17 | it('should build', function(done){ 18 | exec('cd test/fixtures/path && ' + bin + '-build', function(err, stdout){ 19 | if (err) return done(err); 20 | 21 | var js = fs.readFileSync('test/fixtures/path/build/build.js', 'utf8'); 22 | var ret = vm.runInNewContext(js); 23 | 24 | done(); 25 | }) 26 | }) 27 | 28 | it('should exclude the js file if no scripts, and the css file if no styles', function(done){ 29 | exec('cd test/fixtures/no-js-css && ' + bin + '-build', function(err, stdout){ 30 | if (err) return done(err); 31 | 32 | assert(!exists('test/fixtures/no-js-css/build/build.js')) 33 | assert(!exists('test/fixtures/no-js-css/build/build.css')) 34 | done(); 35 | }); 36 | }); 37 | }) 38 | -------------------------------------------------------------------------------- /test/component.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var exec = require('child_process').exec 7 | , fs = require('fs') 8 | , path = require('path'); 9 | 10 | describe('component', function(){ 11 | it('should output help', function(done){ 12 | exec('bin/component', function(err, stdout){ 13 | if (err) return done(err); 14 | stdout.should.include('component [options]'); 15 | stdout.should.include('--help'); 16 | stdout.should.include('Commands:'); 17 | stdout.should.include('install'); 18 | stdout.should.include('search'); 19 | stdout.should.include('ls'); 20 | done(); 21 | }) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /test/fixtures/local/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "local", 3 | "description": "Main component with local dependency chain", 4 | "version": "0.0.1", 5 | "dependencies": {}, 6 | "local": [ 7 | "direct" 8 | ], 9 | "paths": [ 10 | "./" 11 | ], 12 | "main": "index.js", 13 | "scripts": [ 14 | "index.js" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures/local/direct/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "direct", 3 | "description": "Local component dependency for main application", 4 | "version": "0.0.1", 5 | "dependencies": {}, 6 | "local": [ 7 | "first", 8 | "second" 9 | ], 10 | "paths": [ 11 | "../others" 12 | ], 13 | "main": "index.js", 14 | "scripts": [ 15 | "index.js" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures/local/direct/index.js: -------------------------------------------------------------------------------- 1 | var first = require('first'); 2 | var second = require('second'); 3 | 4 | module.exports = first + second; 5 | -------------------------------------------------------------------------------- /test/fixtures/local/index.js: -------------------------------------------------------------------------------- 1 | var direct = require('direct'); 2 | console.log(direct); 3 | -------------------------------------------------------------------------------- /test/fixtures/local/others/first/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "first", 3 | "description": "Local dependency of a local component", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "component/overlay": "*" 7 | }, 8 | "main": "index.js", 9 | "scripts": [ 10 | "index.js" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/local/others/first/index.js: -------------------------------------------------------------------------------- 1 | module.exports = "first"; 2 | -------------------------------------------------------------------------------- /test/fixtures/local/others/second/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "second", 3 | "description": "Local dependency of a local component", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "component/emitter": "*" 7 | }, 8 | "main": "index.js", 9 | "scripts": [ 10 | "index.js" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/local/others/second/index.js: -------------------------------------------------------------------------------- 1 | module.exports = "second"; 2 | -------------------------------------------------------------------------------- /test/fixtures/no-js-css/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "scripts": [], 4 | "styles": [] 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/path/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "locals": [ 4 | "bar" 5 | ], 6 | "scripts": ["index.js"], 7 | "paths": ["lib"] 8 | } -------------------------------------------------------------------------------- /test/fixtures/path/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('bar') -------------------------------------------------------------------------------- /test/fixtures/path/lib/bar/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bar", 3 | "scripts": ["index.js"], 4 | "locals": [ 5 | "baz" 6 | ] 7 | } -------------------------------------------------------------------------------- /test/fixtures/path/lib/bar/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('baz') -------------------------------------------------------------------------------- /test/fixtures/path/lib/baz/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "baz", 3 | "scripts": ["index.js"] 4 | } -------------------------------------------------------------------------------- /test/fixtures/path/lib/baz/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 'baz' -------------------------------------------------------------------------------- /test/fixtures/plugin.js: -------------------------------------------------------------------------------- 1 | /* 2 | example middleware plugin for builder 3 | */ 4 | 5 | module.exports = function(builder) { 6 | console.log('middleware fired!'); 7 | }; 8 | -------------------------------------------------------------------------------- /test/fixtures/tip.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
-------------------------------------------------------------------------------- /test/fixtures/tip.js: -------------------------------------------------------------------------------- 1 | module.exports = '
\n
\n
\n
'; -------------------------------------------------------------------------------- /test/install.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var exec = require('child_process').exec; 7 | var fs = require('fs'); 8 | var assert = require('assert'); 9 | var path = require('path'); 10 | var exists = fs.existsSync || path.existsSync; 11 | 12 | describe('component install', function(){ 13 | beforeEach(function(done){ 14 | exec('rm -fr components component.json', done); 15 | }) 16 | 17 | beforeEach(function(done){ 18 | fs.writeFile('component.json', JSON.stringify({ 19 | dependencies: { 20 | "component/tip": "1.0.0", 21 | "component/popover": "1.1.0" 22 | }, 23 | development: { 24 | "component/assert": "0.3.0" 25 | } 26 | }), done); 27 | }) 28 | 29 | describe('[name]', function(){ 30 | it('should show an error message if the component is named incorrectly', function(done) { 31 | exec('bin/component install component-emitter', function(err, stdout) { 32 | assert(err); 33 | done(); 34 | }) 35 | }) 36 | 37 | it('should install a single component', function(done){ 38 | exec('bin/component install component/emitter@1.0.0', function(err, stdout){ 39 | if (err) return done(err); 40 | stdout.should.include('install'); 41 | stdout.should.include('complete'); 42 | var json = require(path.resolve('components/component/emitter/1.0.0/component.json')); 43 | json.name.should.equal('emitter'); 44 | done(); 45 | }) 46 | }) 47 | 48 | it('should add the component to ./component.json', function(done){ 49 | exec('bin/component install component/emitter@0.0.4', function(err, stdout){ 50 | if (err) return done(err); 51 | var json = require(path.resolve('component.json')); 52 | json.dependencies.should.have.property('component/emitter', '0.0.4'); 53 | done(); 54 | }) 55 | }) 56 | 57 | it('should install dependencies', function(done){ 58 | exec('bin/component install component/overlay@0.1.1', function(err, stdout){ 59 | if (err) return done(err); 60 | stdout.should.include('install'); 61 | stdout.should.include('complete'); 62 | var json = require(path.resolve('components/component/emitter/1.0.0/component.json')); 63 | json.name.should.equal('emitter'); 64 | var json = require(path.resolve('components/component/overlay/0.1.1/component.json')); 65 | json.name.should.equal('overlay'); 66 | done(); 67 | }) 68 | }) 69 | 70 | it('should install dependencies through chain of local dependencies', function(done){ 71 | exec('cd test/fixtures/local && ../../../bin/component install', function(err, stdout){ 72 | if (err) return done(err); 73 | done(); 74 | }) 75 | }) 76 | 77 | it('should download files completely', function(done){ 78 | exec('bin/component install fortawesome/font-awesome@4.0.3', function(err, stdout){ 79 | if (err) return done(err); 80 | var stats = fs.statSync(path.resolve('components/fortawesome/font-awesome/v4.0.3/fonts/fontawesome-webfont.woff')); 81 | stdout.should.include('install'); 82 | stdout.should.include('complete'); 83 | done(); 84 | }) 85 | }) 86 | 87 | it('should also download json files', function (done) { 88 | exec('bin/component install swatinem/t@0.0.1', function(err, stdout){ 89 | if (err) return done(err); 90 | var exists = fs.existsSync(path.resolve('components/swatinem/t/0.0.1/lib/definitions.json')); 91 | exists.should.be.true; 92 | stdout.should.include('install'); 93 | stdout.should.include('complete'); 94 | done(); 95 | }) 96 | }) 97 | }) 98 | 99 | describe('[name...]', function(){ 100 | it('should install the multiple components', function(done){ 101 | exec('bin/component install component/domify@1.0.0 component/dialog@0.3.0', function(err, stdout){ 102 | if (err) return done(err); 103 | stdout.should.include('install'); 104 | stdout.should.include('complete'); 105 | var json = require(path.resolve('components/component/domify/1.0.0/component.json')); 106 | json.name.should.equal('domify'); 107 | var json = require(path.resolve('components/component/dialog/0.3.0/component.json')); 108 | json.name.should.equal('dialog'); 109 | done(); 110 | }) 111 | }) 112 | }) 113 | 114 | it('should default to installing from ./component.json', function(done){ 115 | exec('bin/component install', function(err, stdout){ 116 | if (err) return done(err); 117 | stdout.should.include('install'); 118 | stdout.should.include('complete'); 119 | var json = require(path.resolve('components/component/tip/1.0.0/component.json')); 120 | json.name.should.equal('tip'); 121 | var json = require(path.resolve('components/component/popover/1.1.0/component.json')); 122 | json.name.should.equal('popover'); 123 | assert(!exists('components/component/assert/0.3.0'), 'dev deps should not be installed'); 124 | done(); 125 | }) 126 | }) 127 | 128 | it('should install dev deps when --dev is used', function(done){ 129 | exec('bin/component install -d', function(err, stdout){ 130 | if (err) return done(err); 131 | stdout.should.include('install'); 132 | stdout.should.include('complete'); 133 | var json = require(path.resolve('components/component/tip/1.0.0/component.json')); 134 | json.name.should.equal('tip'); 135 | var json = require(path.resolve('components/component/popover/1.1.0/component.json')); 136 | json.name.should.equal('popover'); 137 | assert(exists('components/component/assert/0.3.0'), 'dev deps should be installed'); 138 | done(); 139 | }) 140 | }) 141 | 142 | it('should be aliased as "add"', function(done){ 143 | exec('bin/component add component/emitter@1.0.0', function(err, stdout){ 144 | if (err) return done(err); 145 | stdout.should.include('install'); 146 | stdout.should.include('complete'); 147 | var json = require(path.resolve('components/component/emitter/1.0.0/component.json')); 148 | json.name.should.equal('emitter'); 149 | done(); 150 | }) 151 | }) 152 | }) 153 | --------------------------------------------------------------------------------