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

pull/134/merge
Ruben Daniels 2015-08-20 17:00:49 -07:00
commit 2362b34eb3
15 zmienionych plików z 523 dodań i 22 usunięć

Wyświetl plik

@ -660,7 +660,6 @@ module.exports = function(options) {
{
packagePath: "plugins/c9.ide.configuration/configure"
},
"plugins/c9.ide.services/linked-services",
"plugins/c9.ide.save/save",
"plugins/c9.ide.recentfiles/recentfiles",
{

7
node_modules/c9/ssh.js wygenerowano vendored
Wyświetl plik

@ -18,6 +18,7 @@ exports.buildArgs = function(prvkeyFile, host) {
"-o", "IdentityFile=" + prvkeyFile,
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes",
"-F", "/dev/null", // use empty config file to not depend on local settings
// force pseudo terminal to make sure that the remote process is killed
// when the local ssh process is killed
@ -148,9 +149,9 @@ exports.generateKeyPair = function(email, callback) {
exports.validateSSHKey = function(prvkey, host, callback) {
exports.exec(prvkey, host, "", [], function(err, stdout, stderr) {
// console.log("out >> " + stdout);
// console.log("err >> " + stderr);
// console.log(err);
debug("out >> " + stdout);
debug("err >> " + stderr);
debug(err);
callback(null, !stderr.match(/Permission denied \(.*publickey/));
});
};

Wyświetl plik

@ -11,6 +11,7 @@ module.exports = function(options, imports, register) {
function cors(origin, options) {
return function(req, res, next) {
options = options || {};
var whitelist = options.whitelist || [];
var writeHead = res.writeHead;
res.writeHead = function(status, headers) {
@ -20,6 +21,18 @@ function cors(origin, options) {
if (key.toLowerCase().indexOf("access-control") === 0)
delete(headers[key]);
if (req.headers.origin) {
var hasHostName = whitelist.some(function(hostname) {
return req.headers.origin.match(new RegExp(hostname.replace(".", "\\.") + "$"));
});
if (whitelist.length && !hasHostName)
return writeHead.call(res, status, headers);
if (hasHostName)
origin = req.headers.origin;
}
headers["Access-Control-Allow-Origin"] = origin;
headers["Access-Control-Allow-Methods"] = options.methods || "GET, OPTIONS";
if (options.headers)
@ -38,7 +51,7 @@ function cors(origin, options) {
res.end();
return;
}
next();
};
}

Wyświetl plik

@ -1,7 +1,7 @@
{
"name": "c9",
"description": "New Cloud9 Client",
"version": "3.0.2366",
"version": "3.0.2433",
"author": "Ajax.org B.V. <info@ajax.org>",
"private": true,
"main": "bin/c9",
@ -55,23 +55,23 @@
"c9"
],
"c9plugins": {
"c9.ide.language": "#9a817580cb",
"c9.ide.language": "#d95aecc807",
"c9.ide.language.css": "#ef8a28943e",
"c9.ide.language.generic": "#77d43cfaf0",
"c9.ide.language.html": "#99efa2853f",
"c9.ide.language.html.diff": "#24f3608d26",
"c9.ide.language.javascript": "#8479d0a9c1",
"c9.ide.language.javascript.immediate": "#0535804ada",
"c9.ide.language.javascript.eslint": "#9b2721c3d0",
"c9.ide.language.javascript.eslint": "#08e0af061f",
"c9.ide.language.javascript.tern": "#3ef5101eec",
"c9.ide.language.javascript.infer": "#4c9a4282ff",
"c9.ide.language.jsonalyzer": "#dcb9e546f8",
"c9.ide.language.jsonalyzer": "#0717d1510f",
"c9.ide.collab": "#b49eda3791",
"c9.ide.local": "#a9703b630c",
"c9.ide.find": "#5c18bbbcc1",
"c9.ide.find.infiles": "#72582de3cd",
"c9.ide.find": "#35379124ca",
"c9.ide.find.infiles": "#c132ad243c",
"c9.ide.find.replace": "#44772dd796",
"c9.ide.run.debug": "#0f244ecdfc",
"c9.ide.run.debug": "#25a59d1269",
"c9.automate": "#47e2c429c9",
"c9.ide.ace.emmet": "#6dc4585e02",
"c9.ide.ace.gotoline": "#a8ff07c8f4",
@ -102,7 +102,7 @@
"c9.ide.recentfiles": "#7c099abf40",
"c9.ide.remote": "#301d2ab519",
"c9.ide.processlist": "#bc11818bb5",
"c9.ide.run": "#1e99c8c1d2",
"c9.ide.run": "#acc8f1aa81",
"c9.ide.run.build": "#ad45874c88",
"c9.ide.run.debug.xdebug": "#3b1520f83d",
"c9.ide.save": "#cc613b6ead",

Wyświetl plik

@ -236,7 +236,7 @@ describe("cli.publish", function(){
});
});
describe.only("install and remove (uninstall)", function() {
describe("install and remove (uninstall)", function() {
var pluginDir = join(process.env.HOME, ".c9/plugins/c9.ide.example");
// Lets make sure there is at least one package in the database

Wyświetl plik

@ -78,6 +78,10 @@ define(function(require, module, exports) {
}
}
if (options.withCredentials) {
xhr.withCredentials = true;
}
var timer;
var timedout = false;
if (timeout) {

Wyświetl plik

@ -1,3 +1,5 @@
"use blacklist";
/**
* Bogus plugin. Circularity ftw.
*/
@ -13,8 +15,7 @@ define(function(require, exports, module) {
function main(options, imports, register) {
var Plugin = imports.Plugin;
var ui = imports.ui;
imports.
/***** Initialization *****/
var plugin = new Plugin("Ajax.org", main.consumes);
@ -59,6 +60,6 @@ define(function(require, exports, module) {
//register(null, { "myplugin" : plugin });
register(null, { "myplugin" : {
myfunc2: myfunc
});
}});
}
});

Wyświetl plik

@ -1375,7 +1375,7 @@ define(function(require, exports, module) {
}
function getMode(syntax) {
syntax = (syntax || "text").toLowerCase();
syntax = (syntax || settings.get("project/ace/@defaultSyntax") || "text").toLowerCase();
if (syntax.indexOf("/") == -1)
syntax = "ace/mode/" + syntax;

Wyświetl plik

@ -113,7 +113,8 @@ define(function(require, exports, module) {
http.request("/_auth/logout", function(err1) {
http.request(ideBaseUrl + "/auth/signout", {
method: "POST"
method: "POST",
withCredentials: true
}, function(err2) {
loggedIn = false;
emit("logout", {uid: uid, newUid: ANONYMOUS});

Wyświetl plik

@ -44,7 +44,7 @@ define(function(require, module, exports) {
column.setWidth(CURWIDTH);
column.setAttribute("class", where);
column.oncontextmenu = function(e) {
bar.oncontextmenu = function(e) {
var menu = menus.get("Window").menu;
menu.display(e.x, e.y);
menu.childNodes.forEach(function(x) {

Wyświetl plik

@ -34,6 +34,7 @@ if (typeof process !== "undefined") {
define(function(require, exports, module) {
"use strict";
"use client";
var EditSession = require("../edit_session").EditSession;
var Tokenizer = require("../tokenizer").Tokenizer;

Wyświetl plik

@ -34,6 +34,7 @@ if (typeof process !== "undefined") {
define(function(require, exports, module) {
"use strict";
"use client";
var assert = require("../test/assertions");
var JavaScriptWorker = require("./javascript_worker").JavaScriptWorker;

Wyświetl plik

@ -0,0 +1,439 @@
define(function(require, exports, module) {
"use strict";
main.consumes = [
"Plugin",
"c9", "proc", "Dialog",
];
main.provides = ["plugin.updater.npm"];
return main;
function main(options, imports, register) {
var Plugin = imports["Plugin"];
var c9 = imports["c9"];
var proc = imports["proc"];
var Dialog = imports["Dialog"];
var async = require("async");
var path = require("path");
var semverCompare = require("semver-compare");
var NPM_MIN_VERSION = "2.6.0";
/***** Initialization *****/
var npmBin = options.npmBin || "/home/ubuntu/.nvm/nvm-exec";
var pluginsPath = options.pluginsPath || "/home/ubuntu/.c9/plugins";
var managedPath = options.managedPath || "/home/ubuntu/.c9/managed";
var managedNpmPath = [managedPath, "npm"].join("/");
var managedEtcPath = [managedNpmPath, "etc"].join("/");
var managedRcPath = [managedEtcPath, "npmrc"].join("/");
var managedCachePath = [managedPath, "npm", "cache"].join("/");
var managedPluginsPath = [managedPath, "plugins"].join("/");
var managedModulesPath = [managedPath, "node_modules"].join("/");
var plugin = new Plugin("Ajax.org", main.consumes);
function load() {
var pkgs = options.packages;
if (!pkgs) {
console.warn("[plugin.updater.npm] no managed packages configured, not loading.");
return;
}
// TODO: DRY error handling
fsMkdirs([ managedPath, managedEtcPath, managedModulesPath, pluginsPath ], function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
fsWriteNpmrc(function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
npmCheckVersion(function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
// TODO: clean up the flow for detecting and installing missing
// packages. the nested functions are messy.
async.filter(pkgs, function(pkg, done) {
npmExplorePath(pkg, function(err, path) {
var isMissing = !!err;
if (isMissing)
debug("missing package:", pkg, err);
done(isMissing);
});
}, function(missing) {
if (missing.length) {
console.info("[plugin.updater.npm] Installing missing plugins:", missing);
showUpdateDialog();
npmInstall(missing, function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
buildLinks(pkgs, function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
// reload browser
window.location.reload();
});
});
}
else {
npmOutdated(pkgs, function(err, outdated) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
if (!outdated) {
debug("Plugins up-to-date.");
return;
}
console.info("[plugin.updater.npm] Updating outdated plugins:", outdated);
showUpdateDialog();
buildLinks(pkgs, function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
showErrorDialog(err);
return;
}
npmUpdate(outdated, function(err) {
if (err) {
console.error("[plugin.updater.npm]", err);
alert("[plugin.updater.npm] Error: " + err.message);
}
// reload browser
window.location.reload();
});
});
});
}
});
});
});
});
}
function unload() {
}
/* -- Helper Functions ----- */
function debug(format) {
if (c9.debug) {
var util = require("util");
console.info(util.format.apply(null,
Array.prototype.slice.call(arguments)
));
}
}
function trimRight(str) {
return str.replace(/\s+$/, "");
}
/* -- npm Management ----- */
/**
* Check that the installed npm version matches the NPM_MIN_VERSION
* required
*
* @param {Function} callback
* @param {Error=} callback.err An error if the version is lower than required
*/
function npmCheckVersion(callback) {
npmExec("npm", ["-v"], function(err, stdout, stderr) {
if (err) return callback(err, stdout, stderr);
var version = stdout;
debug("npm version", version);
if (semverCompare(version, NPM_MIN_VERSION) === -1) {
var error = new Error("npm version " + NPM_MIN_VERSION + " or greater required");
return callback(error);
}
callback();
});
}
function npmExec(command, args, callback) {
debug(npmBin, { args: [ "npm", command ].concat(args) });
proc.execFile(npmBin, {
args: [ "npm", command ].concat(args),
cwd: managedPath,
env: {
"npm_config_production": "true",
"npm_config_depth": 0,
"npm_config_link": "true",
"npm_config_userconfig": "/dev/null",
"npm_config_prefix": managedNpmPath,
"npm_config_cache": managedCachePath,
},
}, function(err, stdout, stderr) {
debug([err, stdout, stderr]);
if (err) return callback(err, stdout, err.message);
stdout = trimRight(stdout);
stderr = trimRight(stderr);
callback(null, stdout, stderr);
});
}
/* -- Package Management ----- */
function npmOutdated(pkgs, callback) {
npmExec("outdated", ["--json"], function(err, stdout, stderr) {
if (err)
return callback(err, null, stdout, stderr);
if (!stdout)
return callback(null, null, stdout, stderr);
var outdated = JSON.parse(stdout);
outdated = Object.keys(outdated);
callback(null, outdated, stdout, stderr);
});
}
function npmInstall(pkgs, callback) {
npmExec("install", ["--"].concat(pkgs), function(err, stdout, stderr) {
callback(err, stdout, stderr);
});
}
function npmUpdate(pkgs, callback) {
npmExec("update", ["--"].concat(pkgs), function(err, stdout, stderr) {
callback(err, stdout, stderr);
});
}
function npmExplorePath(pkg, callback) {
npmExec("explore", [pkg, "--", "pwd"], function(err, stdout, stderr) {
if (err)
return callback(err, null, stderr);
callback(null, stdout, stderr);
});
}
/**
* Build the symbolic links from `~/.c9/plugins` to the managed plugins.
*
* @param {String[]} pkgs A list of package names to link.
*
* @param {Function} callback
* @param {Error=} callback.err
*/
function buildLinks(pkgs, callback) {
async.each(pkgs, function(pkg, done) {
npmExplorePath(pkg, function(err, pkgPath) {
if (err) return done(err);
fsForceLink(pkgPath, done);
});
}, callback);
}
/**
* Removes symbolic links from the `~/.c9/plugins` folder.
*/
function fsRmLinks(callback) {
debug("find", { args: [ pluginsPath, "-maxdepth", "1", "-type", "l", "-exec", "rm", "{}", ";" ] });
// find . -maxdepth 1 -type l -exec rm {} \;
proc.execFile("find", {
args: [
pluginsPath,
"-maxdepth", "1",
"-type", "l",
"-exec", "rm", "{}", ";"
],
}, function(err, stdout, stderr) {
debug([err, stdout, stderr]);
callback(err, stdout, stderr);
});
}
/**
* Create a symbolic link in `~/.c9/plugins` pointing to the given
* plugin path.
*
* @param {String} pkgPath Path to the source package folder
*/
function fsLink(pkgPath, callback) {
debug("ls", { args: [ "-s", "-f", pkgPath, [ pluginsPath, "." ].join("/") ]});
proc.execFile("ln", {
args: [
"-s", "-f",
pkgPath,
[ pluginsPath, "." ].join("/"),
],
}, function(err, stdout, stderr) {
debug([err, stdout, stderr]);
callback(err, stdout, stderr);
});
}
/**
* Forcefully delete an existing plugin folder and change it to
* a symbolic link in `~/.c9/plugins` pointing to the given plugin
* path.
*
* @param {String} pkgPath Path to the source package folder
*/
function fsForceLink(pkgPath, callback) {
var basename = path.basename(pkgPath);
proc.execFile("rm", {
args: [
"-rf", basename,
],
cwd: pluginsPath,
}, function(err, stdout, stderr) {
debug([err, stdout, stderr]);
if (err)
return callback(err, stdout, stderr);
fsLink(pkgPath, callback);
});
}
function fsMkdirs(dirPaths, callback) {
debug("mkdir", { args: [ "-p", "--" ].concat(dirPaths) });
proc.execFile("mkdir", {
args: [ "-p", "--" ].concat(dirPaths),
}, function(err, stdout, stderr) {
callback(err, stdout, stderr);
});
}
function fsWriteNpmrc(callback) {
var config = [
"//registry.npmjs.org/:_authToken = a7c61f6e-5b10-41db-947f-8bc8f1f9468b",
];
//
// HACK: - fs.writeFile() does not always work? we are using echo
// instead
//
// - config is not escaped
//
debug("sh", { args: [ "-c", "echo '" + config.join("\\n") + "' > " + managedRcPath ] });
proc.execFile("sh", {
args: [
"-c",
"echo '" + config.join("\\n") + "' > " + managedRcPath
],
}, function(err, stdout, stderr) {
callback(err, stdout, stderr);
});
}
/* -- Interface ----- */
/**
* Show a modal upgrade progress dialog, blocking the IDE interface
* while we are updating the plugins.
*/
function showUpdateDialog() {
var dialog = new Dialog("Ajax.org", [], {
name: "plugin.updater.npm.dialog",
allowClose: false,
modal: true,
elements: [
],
});
dialog.title = "Installing Updates";
dialog.heading = "";
dialog.body = "Your workspace will be updated to the newest version and reload automatically.";
dialog.show();
return dialog;
}
/**
* Show an upgrade error dialog, requesting to delete and recreate the
* workspace. This is shown for critical update errors.
*/
function showErrorDialog(err) {
var dialog = new Dialog("Ajax.org", [], {
name: "plugin.updater.npm.error_dialog",
allowClose: true,
modal: true,
elements: [
],
});
var errorMessage = (err && err.message) ? "" + err.message : err;
dialog.title = "Error installing updates";
dialog.heading = "";
dialog.body = "<strong>Important updates could not be installed on this workspace.</strong><br><br>"
+ "Please delete this workspace and create a new one, in order to continue "
+ "working in an up-to-date environment.<br><br>"
+ "<div style='max-height: 100px; overflow: auto;'><small><code>" + errorMessage + "</code></small></div>";
dialog.show();
return dialog;
}
/***** Register and define API *****/
plugin.on("load", load);
plugin.on("unload", unload);
/**
* @class salesforc.sync
*/
plugin.freezePublicAPI({
});
register(null, {
"plugin.updater.npm" : plugin
});
}
});

Wyświetl plik

@ -22,6 +22,8 @@ define(function(require, exports, module) {
var basename = require("path").basename;
var dirname = require("path").dirname;
var escapeHTML = require("ace/lib/lang").escapeHTML;
/***** Initialization *****/
@ -650,9 +652,9 @@ define(function(require, exports, module) {
model.getCaptionHTML = function(node) {
if (node.isFavorite) {
var path = node.labelPath || node.path;
return basename(path)
return escapeHTML(basename(path))
+ "<span class='extrainfo'> - "
+ dirname(path) + "</span>";
+ escapeHTML(dirname(path)) + "</span>";
}
else
return getCaptionHTML.call(model, node);

Wyświetl plik

@ -0,0 +1,39 @@
// semver-compare (1.0.0)
// https://github.com/substack/semver-compare
//
// This software is released under the MIT license:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
define(function(require, exports, module) {
module.exports = function cmp (a, b) {
var pa = a.split('.');
var pb = b.split('.');
for (var i = 0; i < 3; i++) {
var na = Number(pa[i]);
var nb = Number(pb[i]);
if (na > nb) return 1;
if (nb > na) return -1;
if (!isNaN(na) && isNaN(nb)) return 1;
if (isNaN(na) && !isNaN(nb)) return -1;
}
return 0;
};
});