Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes for publishing to NPM and fixing errant global

  • Loading branch information...
commit ca3fd569f050ef7771fc2e00b071cd3cd6e61850 1 parent 966b569
@kriszyp authored
Showing with 19 additions and 10 deletions.
  1. +19 −10 lib/model/package.js
View
29 lib/model/package.js
@@ -6,7 +6,7 @@ var Model = require("perstore/model").Model,
promiseModule = require("promised-io/promise"),
queryRepo = require("./git").queryRepo,
host = require("commonjs-utils/settings").host || "/",
- print = require("sys").puts,
+ print = console.log,
httpClient = require("promised-io/http-client"),
when = promiseModule.when,
fs = require("promised-io/fs"),
@@ -27,11 +27,17 @@ PackageModel = exports.Package = Model(packageStore, {
var redirectUrl = "http://packages.dojofoundation.org/" + packageData.name;
packageData.url = redirectUrl;
packageData.location = redirectUrl;
- var npmResponse = request({
- url:"http://registry.npmjs.org/" + packageData.name,
- method:"PUT",
- headers: {"content-type": "application/json"},
- body: [JSON.stringify(packageData)]
+ var npmResponse = when(updateVersions(packageData), function(packageData){
+ return request({
+ url:"http://registry.npmjs.org/" + packageData.name,
+ method:"PUT",
+ headers: {
+ "content-type": "application/json",
+ // we use the dojofoundation login which is dojofoundation:dojorocks
+ "authorization": "Basic ZG9qb2ZvdW5kYXRpb246ZG9qb3JvY2tz"
+ },
+ body: [JSON.stringify(packageData)]
+ });
});
}else{
var npmResponse = {status: 200};
@@ -47,6 +53,7 @@ PackageModel = exports.Package = Model(packageStore, {
body: [""]
};
}else{
+ npmResponse.__isJSGIResponse__ = true;
return npmResponse;
}
});
@@ -168,8 +175,10 @@ function updateVersions(pckg, force){
if(packageData && packageData.mappings){
for(var mapping in packageData.mappings){
var target = packageData.mappings[mapping];
- dependencies[mapping] = target.replace(/.*\/v?/,'');
- when(publish(target.archive || target, mapping), null, print);
+ if(target.replace){
+ dependencies[mapping] = target.replace(/.*\/v?/,'');
+ when(publish(target.archive || target, mapping), null, print);
+ }
}
}
// TODO: Once my packages are fixed, uncomment
@@ -185,7 +194,7 @@ function updateVersions(pckg, force){
}catch(e){
print("Error setting version " + e.stack);
}
- }), function(){
+ }).then(null, print), function(){
if(latestVersion && (!pckg["dist-tags"] || pckg["dist-tags"] != latestVersion)){
pckg["dist-tags"] = {"latest": latestVersion};
packageStore.put(pckg);
@@ -193,7 +202,7 @@ function updateVersions(pckg, force){
return all(packageUpdates);
});
});
- deferred = promiseModule.defer();
+ var deferred = promiseModule.defer();
var finished;
function finish(){
if(!finished){
Please sign in to comment.
Something went wrong with that request. Please try again.