Skip to content
This repository
Browse code

Initial commit

  • Loading branch information...
commit 98a5bb9421e32e1d4bd4edfa498d0f1c68fc41b2 0 parents
TJ Holowaychuk authored
2  .gitignore
... ...
@@ -0,0 +1,2 @@
  1
+node_modules
  2
+components
4  .npmignore
... ...
@@ -0,0 +1,4 @@
  1
+support
  2
+test
  3
+examples
  4
+*.sock
5  History.md
Source Rendered
... ...
@@ -0,0 +1,5 @@
  1
+
  2
+0.0.1 / 2010-01-03
  3
+==================
  4
+
  5
+  * Initial release
7  Makefile
... ...
@@ -0,0 +1,7 @@
  1
+
  2
+test:
  3
+	@./node_modules/.bin/mocha \
  4
+		--require should \
  5
+		--reporter spec
  6
+
  7
+.PHONY: test
29  Readme.md
Source Rendered
... ...
@@ -0,0 +1,29 @@
  1
+
  2
+# component
  3
+
  4
+  Component package manager consuming git repositories
  5
+
  6
+## License 
  7
+
  8
+(The MIT License)
  9
+
  10
+Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
  11
+
  12
+Permission is hereby granted, free of charge, to any person obtaining
  13
+a copy of this software and associated documentation files (the
  14
+'Software'), to deal in the Software without restriction, including
  15
+without limitation the rights to use, copy, modify, merge, publish,
  16
+distribute, sublicense, and/or sell copies of the Software, and to
  17
+permit persons to whom the Software is furnished to do so, subject to
  18
+the following conditions:
  19
+
  20
+The above copyright notice and this permission notice shall be
  21
+included in all copies or substantial portions of the Software.
  22
+
  23
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  24
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  26
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  27
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  28
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  29
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47  bin/component
... ...
@@ -0,0 +1,47 @@
  1
+#!/usr/bin/env node
  2
+
  3
+/**
  4
+ * Module dependencies.
  5
+ */
  6
+
  7
+var program = require('commander')
  8
+  , component = require('..')
  9
+  , spawn = require('child_process').spawn
  10
+  , fs = require('fs')
  11
+  , exists = fs.existsSync;
  12
+
  13
+// sub-command help
  14
+
  15
+program.on('--help', function(){
  16
+  console.log('  Commands:');
  17
+  console.log();
  18
+  console.log('    install <name ...>  install one or more components');
  19
+  console.log('    search [query]      search with the given query');
  20
+  console.log();
  21
+  process.exit();
  22
+});
  23
+
  24
+// parse argv
  25
+
  26
+program.parse(process.argv);
  27
+
  28
+// command
  29
+
  30
+var cmd = __dirname + '/component-' + program.args[0];
  31
+
  32
+// args void of cmd
  33
+
  34
+var args = process.argv.slice(3);
  35
+
  36
+// doesn't exist
  37
+
  38
+if (!exists(cmd)) {
  39
+  component.fatal('the "%s" command does not exist', program.args[0]);
  40
+}
  41
+
  42
+// exec command
  43
+
  44
+var proc = spawn(cmd, args);
  45
+proc.stdout.pipe(process.stdout);
  46
+proc.stderr.pipe(process.stderr);
  47
+proc.on('exit', process.exit);
26  bin/component-install
... ...
@@ -0,0 +1,26 @@
  1
+#!/usr/bin/env node
  2
+
  3
+/**
  4
+ * Module dependencies.
  5
+ */
  6
+
  7
+var program = require('commander')
  8
+  , component = require('..');
  9
+
  10
+// options
  11
+
  12
+program
  13
+  .option('-o, --out <dir>', 'output components to the given <dir>')
  14
+
  15
+// parse argv
  16
+
  17
+program.parse(process.argv);
  18
+
  19
+// install
  20
+
  21
+console.log();
  22
+program.args.forEach(function(pkg){
  23
+  component.log('install', pkg);
  24
+  pkg = component.install(pkg, program.out || 'components');
  25
+});
  26
+console.log();
12  bin/component-search
... ...
@@ -0,0 +1,12 @@
  1
+#!/usr/bin/env node
  2
+
  3
+/**
  4
+ * Module dependencies.
  5
+ */
  6
+
  7
+var program = require('commander')
  8
+  , component = require('..');
  9
+
  10
+// parse argv
  11
+
  12
+program.parse(process.argv);
2  index.js
... ...
@@ -0,0 +1,2 @@
  1
+
  2
+module.exports = require('./lib/component');
44  lib/Installer.js
... ...
@@ -0,0 +1,44 @@
  1
+
  2
+/**
  3
+ * Module dependencies.
  4
+ */
  5
+
  6
+var Emitter = require('events').EventEmitter
  7
+  , dirname = require('path').dirname
  8
+  , basename = require('path').basename
  9
+  , extname = require('path').extname
  10
+  , mkdir = require('mkdirp').mkdirp
  11
+  , request = require('superagent')
  12
+  , debug = require('debug')('component:installer')
  13
+  , fs = require('fs');
  14
+
  15
+/**
  16
+ * Expose installer.
  17
+ */
  18
+
  19
+module.exports = Installer;
  20
+
  21
+/**
  22
+ * Initialize a new `Installer` with
  23
+ * the given `pkg` name and `dest` dir.
  24
+ *
  25
+ * @param {String} pkg
  26
+ * @param {String} dest
  27
+ * @api private
  28
+ */
  29
+
  30
+function Installer(pkg, dest) {
  31
+  debug('installing %s to %s', pkg, dest);
  32
+  if (!pkg) throw new Error('pkg required');
  33
+  if (!dest) throw new Error('destination required');
  34
+  this.pkg = pkg;
  35
+  this.dest = dest;
  36
+}
  37
+
  38
+/**
  39
+ * Inherit from `Emitter.prototype`.
  40
+ */
  41
+
  42
+Installer.prototype.__proto__ = Emitter.prototype;
  43
+
  44
+
79  lib/component.js
... ...
@@ -0,0 +1,79 @@
  1
+
  2
+/**
  3
+ * Module dependencies.
  4
+ */
  5
+
  6
+var Installer = require('./Installer')
  7
+  , mkdir = require('mkdirp');
  8
+
  9
+/**
  10
+ * Output fatal error message and exit.
  11
+ *
  12
+ * @param {String} fmt
  13
+ * @param {Mixed} ...
  14
+ * @api private
  15
+ */
  16
+
  17
+exports.fatal = function(){
  18
+  exports.error.apply(null, arguments);
  19
+  process.exit(1);
  20
+};
  21
+
  22
+/**
  23
+ * Output error message.
  24
+ *
  25
+ * @param {String} fmt
  26
+ * @param {Mixed} ...
  27
+ * @api private
  28
+ */
  29
+
  30
+exports.error = function(fmt){
  31
+  fmt = '\n  \033[31m' + fmt + '\033[m\n';
  32
+  console.error.apply(null, arguments);
  33
+};
  34
+
  35
+/**
  36
+ * Log the given `type` with `msg`.
  37
+ *
  38
+ * @param {String} type
  39
+ * @param {String} msg
  40
+ * @api public
  41
+ */
  42
+
  43
+exports.log = function(type, msg){
  44
+  console.log('  \033[36m%s\033[m : \033[90m%s\033[m', type, msg);
  45
+};
  46
+
  47
+/**
  48
+ * Normalize `name` string, returning an object
  49
+ * representation of what is to be installed.
  50
+ *
  51
+ * Syntax:
  52
+ *
  53
+ *    <name> ['@' version]
  54
+ *
  55
+ * @param {String} name
  56
+ * @return {Object}
  57
+ * @api private
  58
+ */
  59
+
  60
+exports.parse = function(name) {
  61
+  var m = name.match(/([^:@]+)(?:@([^:]+))?/);
  62
+
  63
+  return {
  64
+    name: m[1],
  65
+    version: m[2]
  66
+  }
  67
+};
  68
+
  69
+/**
  70
+ * Install the given `pkg` to `dest`.
  71
+ *
  72
+ * @param {String} pkg
  73
+ * @param {String} dest
  74
+ * @api public
  75
+ */
  76
+
  77
+exports.install = function(pkg, dest){
  78
+  return new Installer(pkg, dest);
  79
+};
19  package.json
... ...
@@ -0,0 +1,19 @@
  1
+{
  2
+  "name": "component",
  3
+  "version": "0.0.1",
  4
+  "description": "Component package manager consuming git repositories",
  5
+  "keywords": ["component", "package", "client", "browser", "module"],
  6
+  "author": "TJ Holowaychuk <tj@vision-media.ca>",
  7
+  "dependencies": {
  8
+    "term-css": "1.0.0",
  9
+    "commander": "1.0.0",
  10
+    "mkdirp": "0.3.3",
  11
+    "superagent": "0.6.0",
  12
+    "debug": "*"
  13
+  },
  14
+  "devDependencies": {
  15
+    "mocha": "*",
  16
+    "should": "*"
  17
+  },
  18
+  "main": "index"
  19
+}

0 notes on commit 98a5bb9

Please sign in to comment.
Something went wrong with that request. Please try again.