Merge branch 'master' of github.com:c9/newclient

pull/223/head
nightwing 2015-11-25 16:52:55 +04:00
commit 4c3e3af194
16 zmienionych plików z 281 dodań i 123 usunięć

31
node_modules/c9/available.js wygenerowano vendored 100644
Wyświetl plik

@ -0,0 +1,31 @@
"use strict";
var _ = require("lodash");
/**
* Substract all values of used from quota + extra
* This is the so-called "uncountedQuota" logic.
*/
function available(quota, used, extra) {
var keys = _.union(_.keys(quota), _.keys(used));
extra = extra || {};
return keys.reduce(function(available, key) {
available[key] = quota[key] || 0;
extra[key] = extra[key] || 0;
if (!used[key])
return available;
var needed = used[key] - extra[key];
if (!needed)
return available;
available[key] = available[key] - needed;
return available;
}, {});
}
module.exports = available;

117
node_modules/c9/available_test.js wygenerowano vendored 100644
Wyświetl plik

@ -0,0 +1,117 @@
#!/usr/bin/env node
"use strict";
"use server";
require("c9/setup_paths");
require("c9/inline-mocha")(module);
var assert = require("assert-diff");
var available = require("./available");
describe(__filename, function() {
it("Should do basic math for shared keys in the input", function() {
var cases = [{
label: "When total < used",
total: {
ram: 10,
disk: 5,
},
used: {
ram: 20,
disk: 5,
},
avail: {
ram: -10,
disk: 0
}
}, {
label: "When keys in total not in used",
total: {
ram: 10,
disk: 5,
foo: 10,
},
used: {
ram: 10,
disk: 5,
},
avail: {
ram: 0,
disk: 0,
foo: 10
}
}, {
label: "When keys in used not in total",
total: {
ram: 10,
disk: 5,
},
used: {
foo: 10,
ram: 10,
disk: 5,
},
avail: {
ram: 0,
disk: 0,
foo: -10
}
}, {
label: "When all looks normal",
total: {
ram: 10,
disk: 5,
},
used: {
ram: 5,
disk: 2,
},
avail: {
ram: 5,
disk: 3,
}
}, {
label: "With a little extra",
total: {
ram: 10,
disk: 6,
},
used: {
ram: 10,
disk: 5,
},
extra: {
ram: 3,
disk: 3
},
avail: {
ram: 3,
disk: 4,
}
}, {
label: "But extra is not more",
total: {
ram: 10,
disk: 10,
},
used: {
ram: 5,
disk: 5,
},
extra: {
ram: 5,
disk: 3
},
avail: {
ram: 10,
disk: 8,
}
}];
cases.forEach(function(testCase) {
var avail = available(testCase.total, testCase.used, testCase.extra);
assert.deepEqual(avail, testCase.avail, testCase.label);
});
});
});

22
node_modules/c9/has-internal-test-name.js wygenerowano vendored 100644
Wyświetl plik

@ -0,0 +1,22 @@
if (define === undefined) {
var define = function(fn) {
fn(require, exports, module);
};
}
define(function(require, exports, module) {
"use strict";
var internalTestNames = ["c9test", "c9 test"];
var regex = new RegExp("^(" + internalTestNames.join("|") + ")+");
function hasInternalTestName(user) {
if (!user.name && !user.username) return false;
var testedName = user.name ? user.name : user.username;
return regex.test(testedName);
}
module.exports = hasInternalTestName;
});

44
node_modules/c9/has-internal-test-name_test.js wygenerowano vendored 100644
Wyświetl plik

@ -0,0 +1,44 @@
"use strict";
"use mocha";
require("c9/inline-mocha")(module);
var assert = require("assert");
var faker = require("faker");
var hasInternalTestName= require("c9/has-internal-test-name");
describe("has-internal-test-name", function() {
it("returns false when undefined name", function() {
var name;
assert.equal(false, hasInternalTestName(name), "should return false when name undefined");
});
it("returns true when name contains c9test", function() {
var name = "c9testregnjkdfkfd";
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
name = "c9test01";
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
name = "c9testjhrrj ffjh";
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
});
it("returns true when name contains c9 test", function() {
var name = "c9 test dkjfdgjhfgdfk";
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
name = "c9 test07";
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
name = "c9 testdkjfdgjhfgdfk";
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
});
it("returns false when not internal user test name", function() {
var name = faker.name.firstName();
assert.equal(false, hasInternalTestName(name), "should return false when name is not for internal testing");
});
});

7
node_modules/c9/skip-analytics.js wygenerowano vendored
Wyświetl plik

@ -6,12 +6,15 @@ if (define === undefined) {
define(function(require, exports, module) {
"use strict";
var hasInternalDomain = require("c9/has-internal-domain");
var hasInternalTestName = require("c9/has-internal-test-name");
function skipAnalytics(user) {
if (!user) return true;
if (user.id === -1) return true;
if (user.id === -1 || user.uid === -1) return true;
if (hasInternalTestName(user)) return true;
if (hasInternalDomain(user.email)) return true;
return false;
}

49
node_modules/c9/skip-analytics_test.js wygenerowano vendored
Wyświetl plik

@ -10,44 +10,71 @@ describe("skip-analytics", function() {
it("returns true when user undefined", function() {
var user;
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user undefined");
});
it("returns true when user id is -1", function() {
var user = {
id: -1
};
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user id is -1");
});
it("returns true when user uid is -1", function() {
var user = {
uid: -1
};
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user uid is -1");
});
it("returns false when user does not have an internal test name and no email", function() {
var user = {
id: faker.random.uuid(),
name: faker.name.firstName()
};
assert.equal(false, skipAnalytics(user), "skipAnalytics should return false when user does not have an internal test name and no email");
});
it("returns true when user has an internal test name and no email", function() {
var user = {
id: faker.random.uuid(),
name: "c9test07"
};
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has an internal test name and no email");
});
it("returns false when user has no email", function() {
var user = {
id: faker.random.uuid()
};
assert.equal(false, skipAnalytics(user), "skipAnalytics should return false when user has no email");
});
it("returns true when user has internal email", function() {
var user = {
id: faker.random.uuid(),
email: "test@c9.io"
};
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has internal email");
user.email = "test@cloud9beta.com";
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has internal beta email");
});
it("returns false when user is authorized and does not have intermal email", function() {
it("returns false when user is authorized and does not have intermal email", function() {
var user = {
id: faker.random.uuid(),
email: faker.internet.email()
};
assert.equal(false, skipAnalytics(user), "skipAnalytics should return false when user is authorized and does not have internal email");
});
});

10
node_modules/c9/urls.js wygenerowano vendored
Wyświetl plik

@ -73,6 +73,9 @@ function getBaseUrl(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
if (!sourceBaseUrlPattern)
throw new Error("getBaseUrl() requires at least two arguments");
if (!targetBaseUrlPattern)
targetBaseUrlPattern = sourceBaseUrlPattern;
var sourceHostMatcher = sourceBaseUrlPattern
.replace(/^https?:\/\//, "")
@ -91,15 +94,10 @@ function getBaseUrl(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
targetHost = "c9.io";
}
if (/^(ide|vfs)./.test(targetHost) && !targetBaseUrlPattern)
console.error(new Error("Warning: no targetBaseUrlPattern specified, will stay at " + targetHost), {
sourceBaseUrlPattern: sourceBaseUrlPattern
});
if (/^(ide|vfs)./.test(targetHost))
console.trace("Warning: possibly incorrect baseUrl constructed, with 'ide.' in the hostname: " + targetHost);
return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, targetHost)
return replaceDomain(targetBaseUrlPattern, targetHost)
.replace(/\/$/, "");
}

Wyświetl plik

@ -11,6 +11,11 @@ module.exports = function setup(mount, vfs, mountOptions) {
var errorHandler = mountOptions.errorHandler || function (req, res, err, code) {
console.error(err.stack || err);
if (res.headersSent) {
res.end("");
return;
}
if (code) res.statusCode = code;
else if (typeof err.code == "number") res.statusCode = err.code;
else if (err.code === "EBADREQUEST") res.statusCode = 400;

Wyświetl plik

@ -1,7 +1,7 @@
{
"name": "c9",
"description": "New Cloud9 Client",
"version": "3.1.470",
"version": "3.1.511",
"author": "Ajax.org B.V. <info@ajax.org>",
"private": true,
"main": "bin/c9",
@ -63,12 +63,12 @@
"c9.ide.language.javascript": "#2b77bdb96a",
"c9.ide.language.javascript.immediate": "#0535804ada",
"c9.ide.language.javascript.eslint": "#3ec4557969",
"c9.ide.language.javascript.tern": "#40cf04bded",
"c9.ide.language.javascript.tern": "#468cc173c4",
"c9.ide.language.javascript.infer": "#8478e3c702",
"c9.ide.language.jsonalyzer": "#8401c240b3",
"c9.ide.collab": "#9915f10460",
"c9.ide.local": "#a6e689e33b",
"c9.ide.find": "#35379124ca",
"c9.ide.find": "#e33fbaed2f",
"c9.ide.find.infiles": "#c3bf17286d",
"c9.ide.find.replace": "#8cbce45290",
"c9.ide.run.debug": "#8e081d7471",
@ -105,7 +105,7 @@
"c9.ide.run": "#c0b6677da6",
"c9.ide.run.build": "#0598fff697",
"c9.ide.run.debug.xdebug": "#5c004d2d75",
"c9.ide.save": "#5118b30230",
"c9.ide.save": "#a2820d0ea1",
"c9.ide.scm": "#417fb0387b",
"c9.ide.terminal.monitor": "#35afa7f97f",
"c9.ide.test": "#520fa1e6c5",
@ -114,6 +114,6 @@
"c9.ide.threewaymerge": "#229382aa0b",
"c9.ide.undo": "#b028bcb4d5",
"c9.ide.upload": "#0bd010d3dc",
"c9.ide.welcome": "#7450aebef6"
"c9.ide.welcome": "#336862828d"
}
}

Wyświetl plik

@ -1,94 +0,0 @@
/*global describe:false, it:false */
"use client";
require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai) {
var expect = chai.expect;
expect.setupArchitectTest([
{
packagePath: "plugins/c9.core/c9",
startdate: new Date(),
debug: 2,
hosted: true,
local: false
},
"plugins/c9.vfs.client/vfs_client",
"plugins/c9.vfs.client/endpoint",
"plugins/c9.ide.auth/auth",
"plugins/c9.core/api",
"plugins/c9.core/ext",
"plugins/c9.core/http-xhr",
{
consumes: [],
provides: ["auth.bootstrap", "info", "dialog.error"],
setup: expect.html.mocked
},
{
consumes: ["c9", "vfs"],
provides: [],
setup: main
}
], architect);
function main(options, imports, register) {
var c9 = imports.c9;
var vfs = imports.vfs;
describe('c9', function() {
this.timeout(30000);
it('should send proper events during connecting', function(done) {
// var count = 0;
// c9.on("connecting", function c1(){
// count++;
// expect(c9.connecting).to.equal(true);
// expect(c9.connected).to.equal(false);
// expect(c9.has(c9.NETWORK)).to.equal(false);
// c9.off("connecting", c1);
// });
expect(c9.connected).to.equal(false);
c9.once("connect", function c2(){
// expect(count, "Connecting event was not called").to.equal(1);
expect(c9.connected).to.equal(true);
expect(c9.has(c9.NETWORK)).to.equal(true);
done();
});
c9.enable();
});
it('check status settings and getting', function(done) {
c9.setStatus(c9.status & ~c9.STORAGE);
expect(c9.has(c9.STORAGE)).to.equal(false);
c9.setStatus(c9.status | c9.STORAGE);
expect(c9.has(c9.STORAGE)).to.equal(true);
done();
});
it('should send correct events during away', function(done) {
expect(c9.connected).to.equal(true);
expect(c9.has(c9.NETWORK)).to.equal(true);
c9.once("away", function c1(){
expect(c9.connected).to.equal(false);
expect(c9.has(c9.NETWORK)).to.equal(true);
});
c9.once("back", function c1(){
expect(c9.connected).to.equal(true);
expect(c9.has(c9.NETWORK)).to.equal(true);
done();
});
vfs.connection.socket.close();
});
});
onload && onload();
}
});

Wyświetl plik

@ -61,7 +61,7 @@ function plugin(options, imports, register) {
errorClient: clients.error,
warningClient: clients.warning,
customClient: function(name) {
return client[name];
return clients[name];
},
customData: customData
}

Wyświetl plik

@ -1,5 +1,6 @@
/*global describe it before*/
"use blacklist";
"use client";
require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"],

Wyświetl plik

@ -108,6 +108,8 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"],
});
describe('metadata', function() {
this.timeout(20000);
before(function(done) {
apf.config.setProperty("allow-select", false);
apf.config.setProperty("allow-blur", false);

Wyświetl plik

@ -89,6 +89,8 @@ require(["lib/architect/architect", "lib/chai/chai"],
});
describe('tabs', function() {
this.timeout(20000);
before(function(done) {
apf.config.setProperty("allow-select", false);
apf.config.setProperty("allow-blur", false);

Wyświetl plik

@ -96,6 +96,8 @@ require([
});
describe('preferences', function() {
this.timeout(20000);
before(function(done) {
apf.config.setProperty("allow-select", false);
apf.config.setProperty("allow-blur", false);
@ -113,7 +115,6 @@ require([
var plugin = new Plugin();
describe("addSettings", function(){
this.timeout(10000);
it('should open a pane with just an editor', function(done) {
settings.set("user/general/keybindings/@preset", "custom");
@ -173,8 +174,6 @@ require([
});
});
describe("unload()", function(){
this.timeout(10000)
it('should unload the preferences', function(done) {
general.unload();
prefs.unload();

Wyświetl plik

@ -1,5 +1,6 @@
/*global describe it before beforeEach*/
"use blacklist";
"use client";
require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai) {
@ -40,7 +41,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
var c9 = imports.c9;
describe('vfs', function() {
this.timeout(20000);
this.timeout(30000);
beforeEach(function(done) {
if (vfs.connected)