Merge branch 'master' of github.com:c9/newclient into sdk-market

Conflicts:
	npm-shrinkwrap.json
pull/85/head
Ruben Daniels 2015-04-29 14:10:59 +00:00
commit b688512225
8 zmienionych plików z 82 dodań i 17 usunięć

Wyświetl plik

@ -112,7 +112,8 @@ return [
hosted: false,
local: true,
home: process.env.HOME,
setStatus: function(){}
setStatus: function(){},
location: ""
},
error_handler: {
log: function(){}

11
node_modules/frontdoor/lib/route.js wygenerowano vendored
Wyświetl plik

@ -137,6 +137,10 @@ module.exports = function Route(route, options, handler, types) {
var key = keys[i];
var param = params[key];
var type = param.type;
if (param.optional && value == null) {
match[key] = value;
continue;
}
try {
value = type.parse(value);
} catch (e) {
@ -157,6 +161,7 @@ module.exports = function Route(route, options, handler, types) {
* the decoded and validated parameters are stored in `req.params`
* otherwhise an error is returned.
*/
this.decodeParams = decodeParams;
function decodeParams(req, res, next) {
var urlParams = req.match;
if (!urlParams) return;
@ -197,10 +202,12 @@ module.exports = function Route(route, options, handler, types) {
break;
value = body[key]; // body is already JSON parsed
if (param.optional && value == null)
break;
isValid = type.check(value);
break;
case "query":
if (param.optional && !(key in query))
if (param.optional && query[key] == null)
break;
try {
@ -211,7 +218,7 @@ module.exports = function Route(route, options, handler, types) {
isValid = isValid === false ? false : type.check(value);
break;
case "url":
if (param.optional && !(key in urlParams))
if (param.optional && urlParams[key] == null)
break;
value = urlParams[key]; // is already parsed and checked

60
node_modules/frontdoor/lib/route_test.js wygenerowano vendored
Wyświetl plik

@ -133,7 +133,65 @@ module.exports = {
assert.ok(!route.match(req, "/ts/353676299181"));
assert.ok(!route.match(req, "/ts/abc"));
}
},
"test router: decode parameter in body": function(next) {
var route = new Route("/user", {
params: {
id: {
type: "int",
optional: true,
source: "body"
}
}
}, sinon.stub());
var req = {
match: "match",
parsedUrl: {
query: ""
},
body: { id: 15 }
};
var res = {};
// Note: usually optionals would say 'source: "body",'
// but this should work
route.decodeParams(req, res, function(err, result) {
assert.equal(err, null);
assert.equal(req.params.id, 15);
next();
});
},
"test router: optional number argument can be falsy": function(next) {
var route = new Route("/user", {
params: {
id: {
type: "int",
optional: true,
source: "body"
}
}
}, sinon.stub());
var req = {
match: "match",
parsedUrl: {
query: ""
},
body: { id: null }
};
var res = {};
// Note: usually optionals would say 'source: "body",'
// but this should work
route.decodeParams(req, res, function(err, result) {
assert.equal(err, null);
assert.equal(req.params.id, null);
next();
});
},
};
!module.parent && require("asyncjs").test.testcase(module.exports).exec();

Wyświetl plik

@ -83,7 +83,7 @@
"c9.ide.help.support": "#60e88f5680",
"c9.ide.imgeditor": "#08bbc53578",
"c9.ide.immediate": "#6845a93705",
"c9.ide.installer": "#02e7018bf6",
"c9.ide.installer": "#63c3c021e3",
"c9.ide.mount": "#32e79866ee",
"c9.ide.navigate": "#64156c7f4a",
"c9.ide.newresource": "#f1f0624768",

Wyświetl plik

@ -299,7 +299,7 @@ define(function(require, exports, module) {
return callback(new Error("ERROR: Private flag in package.json prevents from installing"));
}
catch(e) {
return callback(new Error("ERROR: Invalid package"));
return callback(new Error("ERROR: Invalid package: " + e.message));
}
proc.execFile("bash", { args: ["-c", "cp -a " + join(process.cwd(), "/*") + " " + packagePath] }, function(err){

Wyświetl plik

@ -69,7 +69,8 @@ define(function(require, exports, module) {
console.error("ERROR: Could not get list: ", stringifyError(err));
return callback(err);
}
// TODO if tty.isatty(process.stdout) use process.stdout.columns process.stdout.rows
// to give nicely wrapped output
if (asJson) {
console.log(JSON.stringify(list, 4, " "));
return callback(null, list);
@ -87,7 +88,7 @@ define(function(require, exports, module) {
pad(item.name, max[0] + PADDING),
pad(item.description.split(".")[0], max[1] + PADDING),
LIGHTBlUE + pad("https://c9.io/profile/packages/" + item.name, max[2] + PADDING) + RESETCOLOR,
pad(item.website || item.repository.url, max[3]));
item.website || item.repository.url); // do not pad last item
});
return callback(null, list);
}

Wyświetl plik

@ -245,8 +245,8 @@ define(function(require, exports, module) {
if (json.description)
console.warn("WARNING: Description property in package.json will be ignored. README.md will be used.");
var originalDesc = json.description;
json.description = fs.readFileSync(join(cwd, "README.md"), "utf8");
var description = fs.readFileSync(join(cwd, "README.md"), "utf8")
.replace(/^\#.*\n*/, "");
// Validate plugins
var plugins = {};
@ -309,13 +309,9 @@ define(function(require, exports, module) {
if (!version)
return next();
// Reset description
var pkgJson = Object.create(json);
pkgJson.description = originalDesc;
// Write the package.json file
var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2;
var newData = JSON.stringify(pkgJson, null, indent);
var newData = JSON.stringify(json, null, indent);
fs.writeFile(cwd + "/.c9/.build/pacage.json", newData, function(){
if (dryRun)
return next(); // if dry-run is passed only update path in .build
@ -650,7 +646,7 @@ define(function(require, exports, module) {
contentType: "application/json",
body: {
name: json.name,
description: json.description,
description: description,
owner_type: "user", // @TODO implement this when adding orgs
owner_id: parseInt(user.id),
permissions: json.permissions || "world",
@ -682,7 +678,7 @@ define(function(require, exports, module) {
repository: json.repository,
longname: json.longname,
website: json.website,
description: json.description,
description: description,
screenshots: json.screenshots,
pricing: json.pricing,
enabled: true

Wyświetl plik

@ -29,6 +29,8 @@ define(function(require, module, exports) {
var timeout = options.hasOwnProperty("timeout") ? options.timeout : 10000;
var async = options.sync !== true;
var parsedUrl = parseUrl(url, options.query);
if (contentType === "application/json")
headers.Accept = headers.Accept || "application/json";
if (options.username) {
headers.Authorization = "Basic " + btoa(options.username + ":" + options.password);