Permalink
Browse files

rename publish command to publish-package

  • Loading branch information...
1 parent 9f1234a commit 6c4142f10eb89d8106729b3f86266eae5ce5686a @caolan committed May 22, 2012
Showing with 68 additions and 72 deletions.
  1. +5 −3 bin/jam.js
  2. +1 −0 lib/commands/index.js
  3. +59 −0 lib/commands/publish-package.js
  4. +2 −55 lib/commands/publish.js
  5. +1 −14 lib/repository.js
View
@@ -24,9 +24,11 @@ jamrc.load(function (err, settings) {
console.log('Available commands:');
var len = utils.longest(Object.keys(commands));
for (var k in commands) {
- console.log(
- ' ' + utils.padRight(k, len) + ' ' + commands[k].summary
- );
+ if (!commands[k].hidden) {
+ console.log(
+ ' ' + utils.padRight(k, len) + ' ' + commands[k].summary
+ );
+ }
}
logger.clean_exit = true;
}
View
@@ -4,6 +4,7 @@ module.exports = {
update: require('./update'),
clean: require('./clean'),
publish: require('./publish'),
+ 'publish-package': require('./publish-package'),
unpublish: require('./unpublish'),
pack: require('./pack'),
unpack: require('./unpack'),
@@ -0,0 +1,59 @@
+var utils = require('../utils'),
+ logger = require('../logger'),
+ couchdb = require('../couchdb'),
+ repository = require('../repository'),
+ argParse = require('../args').parse,
+ url = require('url'),
+ urlParse = url.parse,
+ urlFormat = url.format;
+
+
+exports.summary = 'Publish a package to a repository';
+
+exports.usage = '' +
+'jam publish [PACKAGE_PATH]\n' +
+'\n' +
+'Parameters:\n' +
+' PACKAGE_PATH Path to package directory to pack (defaults to ".")\n' +
+'\n' +
+'Options:\n' +
+' --repo Target repository URL (otherwise uses "default" in jamrc)\n' +
+' --force, -f Overwrite if version is already published'
+
+
+exports.run = function (settings, args) {
+ var a = argParse(args, {
+ 'repo': {match: '--repo', value: true},
+ 'force': {match: ['--force', '-f']}
+ });
+ var dir = a.positional[0] || '.';
+ var repo = a.options.repo || settings.repositories[0];
+ utils.completeAuth(repo, true, function (err, repo) {
+ if (err) {
+ return callback(err);
+ }
+ utils.catchAuthError(exports.publish, repo, [dir, a.options],
+ function (err) {
+ if (err) {
+ return logger.error(err);
+ }
+ logger.end();
+ }
+ );
+ });
+};
+
+
+exports.publish = function (repo, dir, options, callback) {
+ var root = couchdb(repo);
+ root.instance.pathname = '';
+ root.session(function (err, info, resp) {
+ if (err) {
+ return callback(err);
+ }
+ options.user = info.userCtx.name;
+ options.server_time = new Date(resp.headers.date);
+ repository.publish(dir, repo, options, callback);
+ });
+};
+
View
@@ -1,58 +1,5 @@
-var utils = require('../utils'),
- logger = require('../logger'),
- couchdb = require('../couchdb'),
- repository = require('../repository'),
- argParse = require('../args').parse,
- url = require('url'),
- urlParse = url.parse,
- urlFormat = url.format;
-
-
-exports.summary = 'Publish a package to a repository';
-
-exports.usage = '' +
-'jam publish [PACKAGE_PATH]\n' +
-'\n' +
-'Parameters:\n' +
-' PACKAGE_PATH Path to package directory to pack (defaults to ".")\n' +
-'\n' +
-'Options:\n' +
-' --repo Target repository URL (otherwise uses "default" in jamrc)\n' +
-' --force, -f Overwrite if version is already published'
-
+exports.hidden = true;
exports.run = function (settings, args) {
- var a = argParse(args, {
- 'repo': {match: '--repo', value: true},
- 'force': {match: ['--force', '-f']}
- });
- var dir = a.positional[0] || '.';
- var repo = a.options.repo || settings.repositories[0];
- utils.completeAuth(repo, true, function (err, repo) {
- if (err) {
- return callback(err);
- }
- utils.catchAuthError(exports.publish, repo, [dir, a.options],
- function (err) {
- if (err) {
- return logger.error(err);
- }
- logger.end();
- }
- );
- });
-};
-
-
-exports.publish = function (repo, dir, options, callback) {
- var root = couchdb(repo);
- root.instance.pathname = '';
- root.session(function (err, info, resp) {
- if (err) {
- return callback(err);
- }
- options.user = info.userCtx.name;
- options.server_time = new Date(resp.headers.date);
- repository.publish(dir, repo, options, callback);
- });
+ console.log('Did you mean publish-package or publish-task?');
};
View
@@ -481,22 +481,9 @@ exports.maxSatisfying = function (name, ranges, repositories, callback) {
};
-// data argument is an optional cached package document from a previous call to
-// repository.resolve to avoid multiple db.get calls if possible
-
-exports.fetch = function (name, version, repos, /*opt*/repository, callback) {
-
+exports.fetch = function (name, version, repos, callback) {
logger.debug('fetching', name + ' (' + version + ')');
- if (!callback) {
- callback = repository;
- repository = null;
- }
- if (!callback) {
- callback = data;
- data = null;
- }
-
cache.get(name, version, function (err, tarfile, cachedir) {
if (cachedir && tarfile) {
settings.load(cachedir, function (err, cfg) {

0 comments on commit 6c4142f

Please sign in to comment.