From 5272362d5cb966ba58737b7578a15585893a2773 Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Thu, 23 Apr 2015 09:30:17 +0000 Subject: [PATCH 01/80] First iteration on settings --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5226b321..b364f01f 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ plugins/c9.proxy/haproxy plugins/c9.proxy/haproxy-* **/.module-cache/ plugins/c9.account.billing/node_modules/ +plugins/c9.account.settings/node_modules/ plugins/c9.account/node_modules/ .c9revisions From 11c51b9327b7ea0036cbf809d88eb49172d0e314 Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Thu, 23 Apr 2015 13:32:54 +0000 Subject: [PATCH 02/80] Add simple team plugin --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5226b321..8eccae7c 100644 --- a/.gitignore +++ b/.gitignore @@ -70,8 +70,8 @@ plugins/c9.proxy/proxy.cfg plugins/c9.proxy/haproxy plugins/c9.proxy/haproxy-* **/.module-cache/ -plugins/c9.account.billing/node_modules/ plugins/c9.account/node_modules/ +plugins/c9.account.*/node_modules/ .c9revisions .settings From bb0d5cd7de76c1184510b775bb8aecaeb8cfb3a1 Mon Sep 17 00:00:00 2001 From: Alex Brausewetter Date: Fri, 24 Apr 2015 15:11:44 +0000 Subject: [PATCH 03/80] Move strip-whitespace from user to project settings --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c05cbbbd..e9cd8bce 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "c9.ide.ace.repl": "#ada99852fa", "c9.ide.ace.split": "#0ae0151c78", "c9.ide.ace.statusbar": "#d7b45bb7c3", - "c9.ide.ace.stripws": "#34426a03d1", + "c9.ide.ace.stripws": "#cf0f42ac59", "c9.ide.behaviors": "#6aad7006a0", "c9.ide.closeconfirmation": "#a28bfd8272", "c9.ide.configuration": "#adf50fdaa2", From d63f7fb248182e958a5e32003dfaddc5d3c3ab7f Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Fri, 24 Apr 2015 15:43:51 +0000 Subject: [PATCH 04/80] Revert "Allow using --domain to specify a custom top-level domain" This reverts commit 6044a0c4b07c366a9ae5216542adf5caad5dc68b. --- server.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/server.js b/server.js index 311897ce..9853e568 100755 --- a/server.js +++ b/server.js @@ -54,7 +54,6 @@ function main(argv, config, callback) { .default("settings", DEFAULT_SETTINGS) .describe("settings", "Settings file to use") .describe("dump", "dump config file as JSON") - .describe("domain", "Top-level domain to use (e.g, c9.io)") .boolean("help") .describe("help", "Show command line options."); @@ -87,14 +86,6 @@ function start(configName, options, callback) { var settings = require(path.join(__dirname, "./settings", settingsName))(); - if (argv.domain) { - settings.c9.domain = argv.domain; - for (var s in settings) { - settings[s].baseUrl = settings[s].baseUrl - && settings[s].baseUrl.replace(/[^./]+\.[^.]+$/, argv.domain); - } - } - var plugins = require(configPath)(settings, options); if (argv.help) { From d7981d21648ff060b08255bf812092af6973e48b Mon Sep 17 00:00:00 2001 From: Lennart kats Date: Fri, 24 Apr 2015 15:47:27 +0000 Subject: [PATCH 05/80] Revert "Revert "Allow using --domain to specify a custom top-level domain"" This reverts commit d63f7fb248182e958a5e32003dfaddc5d3c3ab7f. --- server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server.js b/server.js index 9853e568..311897ce 100755 --- a/server.js +++ b/server.js @@ -54,6 +54,7 @@ function main(argv, config, callback) { .default("settings", DEFAULT_SETTINGS) .describe("settings", "Settings file to use") .describe("dump", "dump config file as JSON") + .describe("domain", "Top-level domain to use (e.g, c9.io)") .boolean("help") .describe("help", "Show command line options."); @@ -86,6 +87,14 @@ function start(configName, options, callback) { var settings = require(path.join(__dirname, "./settings", settingsName))(); + if (argv.domain) { + settings.c9.domain = argv.domain; + for (var s in settings) { + settings[s].baseUrl = settings[s].baseUrl + && settings[s].baseUrl.replace(/[^./]+\.[^.]+$/, argv.domain); + } + } + var plugins = require(configPath)(settings, options); if (argv.help) { From 77a3e445477514a0df4a18043b78f91951059e46 Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Fri, 24 Apr 2015 18:25:20 +0000 Subject: [PATCH 07/80] Add new cs50 plugin --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e9cd8bce..84dc1331 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", + "c9.ide.processlist": "#bc11818bb5", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From b2a34a77a0f24953f9400b8b1e30efe0072ffe04 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 24 Apr 2015 18:43:49 +0000 Subject: [PATCH 08/80] add error reporting to installer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9cd8bce..427dcde4 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#4c25b26f70", + "c9.ide.installer": "#445c19c36b", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From c9f66f2c88dc1a0063c81182bf784cbd22b74add Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 25 Apr 2015 01:59:55 +0400 Subject: [PATCH 09/80] do not use --transform since it is not supported on old versions of tar --- plugins/c9.cli.publish/publish.js | 54 +++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 2ab55d97..dea177fe 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -718,38 +718,58 @@ define(function(require, exports, module) { }); }, function(next) { - var filename = options.local ? "__installed__.js" : "__packed__.js"; - fs.writeFile(filename, result.code, "utf8", next); + if (options.local) + fs.writeFile(cwd + "__installed__.js", result.code, "utf8", callback); + next(); }, function(next) { - // console.log(packedFiles) - if (options.local) - return callback(); - zip(packedFiles); + proc.execFile("rm", { + args: ["-rf", ".c9build"], + cwd: cwd + }, function() { + mkdirP(cwd + "/.c9build"); + fs.writeFile(cwd + "/.c9build/__installed__.js", result.code, "utf8", next); + }); + }, + function(next) { + var copy = require("architect-build/copy"); + + var excludeRe = /^\.(gitignore|hgignore|git|c9|hg|c9build)$/; + var excludeMap = Object.create(null); + + packedFiles.push(cwd + "/__installed__.js"); + packedFiles.forEach(function(p) { + p = "/" + normalizePath(Path.relative(cwd, p)); + excludeMap[p] = 1; + }); + copy(cwd, cwd + "/.c9build", { + exclude: function(name, parent) { + if (excludeRe.test(name)) + return true; + var fullPath = parent.substr(cwd.length) + "/" + name; + if (excludeMap[fullPath]) + return true; + return false; + } + }) + zip(); } ]); } - function zip(ignore){ + function zip(){ zipFilePath = join(os.tmpDir(), json.name + "@" + json.version) + ".tar.gz"; - var tarArgs = ["-zcvf", normalizePath(zipFilePath), "."]; + var tarArgs = ["-zcvf", normalizePath(zipFilePath)]; var c9ignore = normalizePath(process.env.HOME + "/.c9/.c9ignore"); fs.exists(c9ignore, function (exists) { if (exists) { tarArgs.push("--exclude-from=" + c9ignore); } - ignore.forEach(function(p) { - p = Path.relative(cwd, p); - if (!/^\.+\//.test(p)) { - tarArgs.push("--exclude=./" + normalizePath(p)); - } - }); - tarArgs.push("--transform='flags=r;s|__packed__|__installed__|'"); - // console.log(tarArgs) + tarArgs.push("."); proc.spawn(TAR, { args: tarArgs, - cwd: cwd + cwd: cwd + "/.c9build" }, function(err, p){ if (err) return callback(err); From ad38f83962c9588dd68eb2449b27040a1324759a Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 25 Apr 2015 02:15:25 +0400 Subject: [PATCH 10/80] cleanup --- plugins/c9.cli.publish/publish.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index dea177fe..245b78a6 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -467,11 +467,14 @@ define(function(require, exports, module) { if (dryRun) return build(); + commit(); + }); + + function commit() { SHELLSCRIPT = SHELLSCRIPT .replace(/\$1/, packagePath) .replace(/\$2/, json.version); - - // commit + proc.spawn("bash", { args: ["-c", SHELLSCRIPT] }, function(err, p){ @@ -495,10 +498,9 @@ define(function(require, exports, module) { build(); }); }); - }); + } // Build the package - // @TODO use a proper package tool // @TODO add a .c9exclude file that excludes files var zipFilePath; function build(){ @@ -727,8 +729,8 @@ define(function(require, exports, module) { args: ["-rf", ".c9build"], cwd: cwd }, function() { - mkdirP(cwd + "/.c9build"); - fs.writeFile(cwd + "/.c9build/__installed__.js", result.code, "utf8", next); + mkdirP(cwd + "/.c9/.build"); + fs.writeFile(cwd + "/.c9/.build/__installed__.js", result.code, "utf8", next); }); }, function(next) { @@ -742,7 +744,7 @@ define(function(require, exports, module) { p = "/" + normalizePath(Path.relative(cwd, p)); excludeMap[p] = 1; }); - copy(cwd, cwd + "/.c9build", { + copy(cwd, cwd + "/.c9/.build", { exclude: function(name, parent) { if (excludeRe.test(name)) return true; @@ -769,7 +771,7 @@ define(function(require, exports, module) { tarArgs.push("."); proc.spawn(TAR, { args: tarArgs, - cwd: cwd + "/.c9build" + cwd: cwd + "/.c9/.build" }, function(err, p){ if (err) return callback(err); From 3962a9c04f63a5dafab4508335e603ea7e79e7e5 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 25 Apr 2015 03:02:08 +0400 Subject: [PATCH 11/80] fix quote pairing for "\n" --- .../ace/lib/ace/mode/behaviour/behaviour_test.js | 10 ++++++++++ node_modules/ace/lib/ace/mode/behaviour/cstyle.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/node_modules/ace/lib/ace/mode/behaviour/behaviour_test.js b/node_modules/ace/lib/ace/mode/behaviour/behaviour_test.js index 9dc27bf8..245edf99 100644 --- a/node_modules/ace/lib/ace/mode/behaviour/behaviour_test.js +++ b/node_modules/ace/lib/ace/mode/behaviour/behaviour_test.js @@ -144,6 +144,16 @@ module.exports = { exec("selectleft", 1); exec("insertstring", 1, '"'); assert.equal(editor.getValue(), '("foo")'); + + editor.setValue("", 1); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '""'); + exec("insertstring", 1, '\\'); + exec("insertstring", 1, 'n'); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '"\\n"'); + }, "test: xml": function() { editor = new Editor(new MockRenderer()); diff --git a/node_modules/ace/lib/ace/mode/behaviour/cstyle.js b/node_modules/ace/lib/ace/mode/behaviour/cstyle.js index a1dce91e..dd1b0d14 100644 --- a/node_modules/ace/lib/ace/mode/behaviour/cstyle.js +++ b/node_modules/ace/lib/ace/mode/behaviour/cstyle.js @@ -269,8 +269,8 @@ var CstyleBehaviour = function() { if (leftChar == "\\" && token && /escape/.test(token.type)) return null; - var stringBefore = token && /string/.test(token.type); - var stringAfter = !rightToken || /string/.test(rightToken.type); + var stringBefore = token && /string|escape/.test(token.type); + var stringAfter = !rightToken || /string|escape/.test(rightToken.type); var pair; if (rightChar == quote) { From 182577009f0ccf3c7ee9148671a1b28df26f81fc Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 25 Apr 2015 03:24:10 +0400 Subject: [PATCH 12/80] do not automatically create tag from publish --- node_modules/architect-build/compress.js | 2 +- plugins/c9.cli.publish/publish.git.sh | 8 +- plugins/c9.cli.publish/publish.js | 96 +++++++++++++----------- 3 files changed, 57 insertions(+), 49 deletions(-) diff --git a/node_modules/architect-build/compress.js b/node_modules/architect-build/compress.js index f4e52eaa..343f5d70 100644 --- a/node_modules/architect-build/compress.js +++ b/node_modules/architect-build/compress.js @@ -17,7 +17,7 @@ function compress(sources, opts) { if (pkg.file) console.log("Adding '" + pkg.file + "'."); toplevel = UglifyJS.parse(pkg.source, { - filename: pkg.file.replace(new RegExp("^" + opts.basepath + "/"), ""), //@todo remove prefix + filename: (pkg.file || pkg.id).replace(new RegExp("^" + opts.basepath + "/"), ""), //@todo remove prefix toplevel: toplevel }); }); diff --git a/plugins/c9.cli.publish/publish.git.sh b/plugins/c9.cli.publish/publish.git.sh index f1208cb4..bf32c8d7 100644 --- a/plugins/c9.cli.publish/publish.git.sh +++ b/plugins/c9.cli.publish/publish.git.sh @@ -1,13 +1,13 @@ -PACKAGE_PATH=$1 -VERSION=$2 -CWD=${PWD} +VERSION="$1" +PACKAGE_PATH="$2" +CWD="${PWD}" if [ ! -d .git ]; then echo "$CWD is not a git repository" 1>&2 exit 1 fi -if [ ! -e $PACKAGE_PATH ]; then +if [ ! -f "$PACKAGE_PATH" ]; then echo "Could not find package.json" 1>&2 exit 1 fi diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 245b78a6..757cdc60 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -43,6 +43,7 @@ define(function(require, exports, module) { var verbose = false; var force = false; var dryRun = false; + var createTag = false; // Set up basic auth for api if needed if (BASICAUTH) api.basicAuth = BASICAUTH; @@ -78,16 +79,23 @@ define(function(require, exports, module) { "description": "Only build a test version", "default": false, "boolean": true + }, + "tag" : { + "description": "Create git tag for published version", + "alias": "t", + "default": false, + "boolean": true } }, check: function(argv) { - if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"]) - throw new Error("Missing version"); + // if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"]) + // throw new Error("Missing version"); }, exec: function(argv) { verbose = argv["verbose"]; force = argv["force"]; dryRun = argv["dry-run"]; + createTag = argv["tag"]; publish( argv._[1], @@ -108,7 +116,7 @@ define(function(require, exports, module) { } }); - cmd.addCommand({ + cmd.addCommand({ name: "build", info: " Builds development version of package to load in non-debug mode.", usage: "[--devel]", @@ -372,7 +380,7 @@ define(function(require, exports, module) { var version = options.version; var cwd = process.cwd(); var packagePath = cwd + "/package.json"; - fs.readFile(packagePath, function(err, data){ + fs.readFile(packagePath, "utf8", function(err, data){ if (err) return callback(new Error("ERROR: Could not find package.json in " + cwd)); var json; @@ -437,7 +445,7 @@ define(function(require, exports, module) { if (warned && !force && !dryRun) return callback(new Error("Use --force to ignore these warnings.")); - if (!dryRun) { + if (version) { var v = (json.version || "0.0.1").split("."); // Update the version field in the package.json file if (version == "major") { @@ -458,48 +466,16 @@ define(function(require, exports, module) { json.version = v.join("."); } - if (dryRun) + if (!version) return build(); // Write the package.json file - fs.writeFile(packagePath, JSON.stringify(json, null, " "), function(err){ + var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2; + fs.writeFile(packagePath, JSON.stringify(json, null, indent), function(err){ if (err) return callback(err); - - if (dryRun) return build(); - - commit(); + return build(); }); - function commit() { - SHELLSCRIPT = SHELLSCRIPT - .replace(/\$1/, packagePath) - .replace(/\$2/, json.version); - - proc.spawn("bash", { - args: ["-c", SHELLSCRIPT] - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code, stderr, stdout){ - if (code !== 0) - return callback(new Error("ERROR: publish failed with exit code " + code)); - - console.log("Created tag and updated package.json to version", json.version); - - build(); - }); - }); - } - // Build the package // @TODO add a .c9exclude file that excludes files var zipFilePath; @@ -862,7 +838,7 @@ define(function(require, exports, module) { return callback(new Error("ERROR: Failed to update existing package - " + stringifyError(err))); if (verbose) - console.log("Successfully updated existing package"); + console.log("Successfully updated metadata of existing package"); next(pkg); }); @@ -897,15 +873,47 @@ define(function(require, exports, module) { form.pipe(request); request.on('response', function(res) { + // TODO better handle version exists error + if (res.statusCode == 412 && !version) + console.error("ERROR: most likely version " + json.version + " already exisits, try increasing version"); if (res.statusCode != 200) return callback(new Error("ERROR: Unknown Error:" + res.statusCode)); - // Create Version Complete - callback(null, json); + commitAndPush(); }); } }); } + + function commitAndPush() { + // Create Version Complete + if (!createTag) + callback(null, json); + + proc.spawn("bash", { + args: ["-c", SHELLSCRIPT, "--", json.version, normalizePath(packagePath)] + }, function(err, p){ + if (err) return callback(err); + + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); + }); + } + + p.on("exit", function(code, stderr, stdout){ + if (code !== 0) + return callback(new Error("ERROR: publish failed with exit code " + code)); + + console.log("Created tag and updated package.json to version", json.version); + + callback(null, json); + }); + }); + } }); } From 2947c723b8a5176e8e1f6d0874f9597535903670 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 25 Apr 2015 03:54:34 +0400 Subject: [PATCH 13/80] add g++ to the list of required dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 427dcde4..6fe0f4ba 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#445c19c36b", + "c9.ide.installer": "#f8f0d11bff", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 1043a72bd5566e9f7222ff331a57cc334a95bb08 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 02:03:32 +0400 Subject: [PATCH 14/80] add experiment.js to the sdk --- plugins/c9.ide.experiment/mock_experiment.js | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 plugins/c9.ide.experiment/mock_experiment.js diff --git a/plugins/c9.ide.experiment/mock_experiment.js b/plugins/c9.ide.experiment/mock_experiment.js new file mode 100644 index 00000000..bebfb134 --- /dev/null +++ b/plugins/c9.ide.experiment/mock_experiment.js @@ -0,0 +1,26 @@ +/** + * Dummy implementation of experiments. + */ +"use strict"; + +plugin.consumes = []; +plugin.provides = ["experiment"]; + +module.exports = plugin; + +function plugin(options, imports, register) { + + register(null, { + "experiment": { + configureExperiment: function() {}, + onStart: function() { + var chain = { + variation: function() { + return chain; + } + } + return chain; + } + } + }); +} \ No newline at end of file From f1161fa5decb0bcc4940a585e04025ee9ebd7918 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 22:18:40 +0400 Subject: [PATCH 15/80] tweak c9 publish --- plugins/c9.cli.publish/publish.js | 37 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 757cdc60..7f76ab70 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -466,15 +466,24 @@ define(function(require, exports, module) { json.version = v.join("."); } - if (!version) - return build(); + return build(); - // Write the package.json file - var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2; - fs.writeFile(packagePath, JSON.stringify(json, null, indent), function(err){ - if (err) return callback(err); - return build(); - }); + function updatePackageJSON(next) { + if (!version) + return next(); + + // Write the package.json file + var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2; + var newData = JSON.stringify(json, null, indent); + fs.writeFile(cwd + "/.c9/.build/pacage.json", newData, function(err){ + if (dryRun) + return next(); // if dry-run is passed only update path in .build + fs.writeFile(packagePath, newData, function(err){ + if (err) return callback(err); + return next(); + }); + }); + } // Build the package // @TODO add a .c9exclude file that excludes files @@ -702,7 +711,7 @@ define(function(require, exports, module) { }, function(next) { proc.execFile("rm", { - args: ["-rf", ".c9build"], + args: ["-rf", ".c9/.build"], cwd: cwd }, function() { mkdirP(cwd + "/.c9/.build"); @@ -712,7 +721,7 @@ define(function(require, exports, module) { function(next) { var copy = require("architect-build/copy"); - var excludeRe = /^\.(gitignore|hgignore|git|c9|hg|c9build)$/; + var excludeRe = /^\.(gitignore|hgignore|git|c9|hg)$/; var excludeMap = Object.create(null); packedFiles.push(cwd + "/__installed__.js"); @@ -729,7 +738,11 @@ define(function(require, exports, module) { return true; return false; } - }) + }); + next(); + }, + updatePackageJSON, + function(next) { zip(); } ]); @@ -1222,7 +1235,7 @@ define(function(require, exports, module) { force = false; }); - /***** Register and define API *****/ + /***** Register and definfe API *****/ /** * From a0eb68214fbf9df8fde9a5f1af8cb8071b66efb9 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 22:20:29 +0400 Subject: [PATCH 16/80] use mini_require in odev too --- plugins/c9.vfs.server/statics.js | 7 ++++++- plugins/c9.vfs.standalone/standalone.js | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/c9.vfs.server/statics.js b/plugins/c9.vfs.server/statics.js index 18aebf82..b505ffe5 100644 --- a/plugins/c9.vfs.server/statics.js +++ b/plugins/c9.vfs.server/statics.js @@ -81,7 +81,12 @@ function main(options, imports, register) { "main": "msgpack.js" }] }]); - + + statics.addStatics([{ + path: dirname(require.resolve("architect-build/build_support/mini_require")), + mount: "/" + }]); + } /***** Lifecycle *****/ diff --git a/plugins/c9.vfs.standalone/standalone.js b/plugins/c9.vfs.standalone/standalone.js index 9aa56371..137f8680 100644 --- a/plugins/c9.vfs.standalone/standalone.js +++ b/plugins/c9.vfs.standalone/standalone.js @@ -34,11 +34,6 @@ function plugin(options, imports, register) { mount: "/" }]); - statics.addStatics([{ - path: __dirname + "/../../node_modules/architect-build/build_support", - mount: "/" - }]); - statics.addStatics([{ path: __dirname + "/../../configs", mount: "/configs" From f919637dd3ff39dc2e73bd955a4b86632c0bdc21 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 22:22:07 +0400 Subject: [PATCH 17/80] add ack support to terminal hover_link --- plugins/c9.ide.terminal/aceterm/hover_link.js | 39 ++++++++++++++++++- plugins/c9.ide.terminal/link_handler.js | 4 +- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.terminal/aceterm/hover_link.js b/plugins/c9.ide.terminal/aceterm/hover_link.js index 409749a8..d43e1edf 100644 --- a/plugins/c9.ide.terminal/aceterm/hover_link.js +++ b/plugins/c9.ide.terminal/aceterm/hover_link.js @@ -254,6 +254,42 @@ var HoverLink = function(editor) { match.value = value.replace(/:[^\d][^:]*$/, ""); // match.basePath = ""; } + else if (prompt.command === "ack" || prompt.command === "ag") { + match.type = "path"; + var fontColor = lineData[column] && lineData[column][0]; + if (match.start !== 0) { + if (fontColor == 131840) + return; + + var col = column; + while (lineData[col] && lineData[col][0] == fontColor) + col--; + match.start = col + 1; + col = column; + while (lineData[col] && lineData[col][0] == fontColor) + col++; + match.value = line.substring(match.start, col); + } + + var jumpLine = line.match(/^(\d*:)?/)[0]; + var jumpColumn = Math.max(match.start - jumpLine.length, 0); + + var pathLine = line; + while (/^\d+/.test(pathLine) && row > prompt.row) { + lineData = session.getLineData(row); + if (!lineData.wrapped) { + pathLine = session.getLine(row); + } + row--; + } + + match.path = pathLine; + if (jumpLine) + match.path += ":" + jumpLine + jumpColumn; + + if (match.start == 0 && jumpLine) + match.action = "open"; + } else if (/^(~|\.\.?)?[\/\\]/.test(value) || /\w:[\\]/.test(value)) { match.type = "path"; match.value = value.replace(/['">)}\].,;:]+$/, ""); @@ -325,7 +361,8 @@ var HoverLink = function(editor) { command: command, index: m.index, args: args, - lineData: lineData + lineData: lineData, + row: row }; } if (lineData.isUserInput) diff --git a/plugins/c9.ide.terminal/link_handler.js b/plugins/c9.ide.terminal/link_handler.js index 9435a794..bce11fb9 100644 --- a/plugins/c9.ide.terminal/link_handler.js +++ b/plugins/c9.ide.terminal/link_handler.js @@ -127,6 +127,8 @@ define(function(require, exports, module) { function showMenu(e) { if (e.type == "link" && (tabManager.focussedTab || 0).editorType) return open(e); + if (e.action == "open") + return open(e); createMenu(e); @@ -206,7 +208,7 @@ define(function(require, exports, module) { } function buildPath(e) { - var path = e.value; + var path = e.path || e.value; var abs = false; if (c9.platform == "win32") { From 35175d40cacdfc6cdccfdabcbd3c1107f095484e Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 21:27:25 +0400 Subject: [PATCH 18/80] add more php extensions --- node_modules/ace/lib/ace/ext/modelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_modules/ace/lib/ace/ext/modelist.js b/node_modules/ace/lib/ace/ext/modelist.js index 7a5a1e9c..6bc79c8b 100644 --- a/node_modules/ace/lib/ace/ext/modelist.js +++ b/node_modules/ace/lib/ace/ext/modelist.js @@ -122,7 +122,7 @@ var supportedModes = { Pascal: ["pas|p"], Perl: ["pl|pm"], pgSQL: ["pgsql"], - PHP: ["php|phtml"], + PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"], Powershell: ["ps1"], Praat: ["praat|praatscript|psc|proc"], Prolog: ["plg|prolog"], From 81c1e30e70ad29a7acad673e2ddd1e49889ec7d2 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 01:06:36 +0000 Subject: [PATCH 19/80] Fixed changing keyboard mode in preference pane --- plugins/c9.ide.ui/forms.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/c9.ide.ui/forms.js b/plugins/c9.ide.ui/forms.js index 20503017..e181909c 100644 --- a/plugins/c9.ide.ui/forms.js +++ b/plugins/c9.ide.ui/forms.js @@ -202,19 +202,24 @@ define(function(require, exports, module) { }).join(""); if (data) model.load("" + data + ""); + var dd; childNodes = [ new ui.label({ width : width, maxwidth: maxwidth, caption: name + ":" }), - new ui.dropdown({ + dd = new ui.dropdown({ model: model, width: options.width || widths.dropdown, skin: "black_dropdown", margin: "-1 0 0 0", zindex: 100, - onafterchange: options.onchange && function(e) { - options.onchange({ value: e.value || e.args[2] }); + onafterchange: function(e) { + if (options.path) + settings.set(options.path, e.value); + + if (options.onchange) + options.onchange({ value: e.value || e.args[2] }); }, - value: options.path - ? createBind(options.path) //{settings.model}:: + value: options.path + ? settings.get(options.path) : (options.defaultValue || ""), each: options.each || "[item]", caption: options.caption || "[text()]", @@ -222,6 +227,10 @@ define(function(require, exports, module) { "empty-message" : options["empty-message"] }) ]; + + settings.on(options.path, function(){ + dd.setValue(settings.get(options.path)); + }, plugin); break; case "spinner": childNodes = [ From 983dc030e0e8c5e50c9fe8e4c90984216e9dbb2f Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Tue, 28 Apr 2015 12:09:45 +0200 Subject: [PATCH 20/80] Fix test --- plugins/c9.vfs.standalone/www/test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/c9.vfs.standalone/www/test.js b/plugins/c9.vfs.standalone/www/test.js index ae30803d..cce8b53b 100644 --- a/plugins/c9.vfs.standalone/www/test.js +++ b/plugins/c9.vfs.standalone/www/test.js @@ -155,6 +155,9 @@ require([ prefs.add = function(){}; return prefs; })(), + analytics: { + addTrait: function() {} + }, commands: (function(){ var commands = {}; From 9576ecad4870fbb90350bf5a208dc563895c21a2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 14:24:51 +0400 Subject: [PATCH 21/80] tweak ack link_handler --- plugins/c9.ide.terminal/aceterm/hover_link.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.terminal/aceterm/hover_link.js b/plugins/c9.ide.terminal/aceterm/hover_link.js index d43e1edf..d38f554b 100644 --- a/plugins/c9.ide.terminal/aceterm/hover_link.js +++ b/plugins/c9.ide.terminal/aceterm/hover_link.js @@ -254,11 +254,11 @@ var HoverLink = function(editor) { match.value = value.replace(/:[^\d][^:]*$/, ""); // match.basePath = ""; } - else if (prompt.command === "ack" || prompt.command === "ag") { + else if (prompt.command === "ack" || prompt.command === "ag" || prompt.command === "ack-grep") { match.type = "path"; var fontColor = lineData[column] && lineData[column][0]; if (match.start !== 0) { - if (fontColor == 131840) + if (fontColor == session.term.defAttr) return; var col = column; @@ -274,6 +274,9 @@ var HoverLink = function(editor) { var jumpLine = line.match(/^(\d*:)?/)[0]; var jumpColumn = Math.max(match.start - jumpLine.length, 0); + if (match.start == 0 && jumpLine) + match.value = jumpLine; + var pathLine = line; while (/^\d+/.test(pathLine) && row > prompt.row) { lineData = session.getLineData(row); From 26ad32975ec483ae33721dd4dd4942e4ef94c636 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 18:13:30 +0000 Subject: [PATCH 22/80] Wait until cloud9 reconnects --- package.json | 2 +- plugins/c9.ide.plugins/loader.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6fe0f4ba..63f31c24 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "c9.ide.find.infiles": "#72582de3cd", "c9.ide.find.replace": "#e4daf722b8", "c9.ide.run.debug": "#638e6b00b3", - "c9.automate": "#b1b0cca13a", + "c9.automate": "#3e6927aa96", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#43445d6306", diff --git a/plugins/c9.ide.plugins/loader.js b/plugins/c9.ide.plugins/loader.js index 93ad2aea..7b21a959 100644 --- a/plugins/c9.ide.plugins/loader.js +++ b/plugins/c9.ide.plugins/loader.js @@ -57,8 +57,11 @@ define(function(require, exports, module) { if (loadFromDisk) { fs.readdir("~/.c9/plugins", function handle(err, files){ if (err) { - if (err.code == "EDISCONNECT") - fs.readdir("~/.c9/plugins", handle); + if (err.code == "EDISCONNECT") { + c9.once("connect", function(){ + fs.readdir("~/.c9/plugins", handle); + }); + } console.error(err); return; } From 7820745c7cf31ae7a6ee47a1eaa224c07d873bb7 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 00:29:26 +0000 Subject: [PATCH 23/80] c9 install now runs installation locally and installer as well Conflicts: plugins/c9.profile.page.packages/components/PackagePage.js plugins/c9.profile.page.packages/jsx/PackagePage.jsx --- configs/cli.js | 22 +++++++++++++++- package.json | 2 +- plugins/c9.cli.publish/publish.js | 42 ++++++++++++++++++++++++++----- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/configs/cli.js b/configs/cli.js index fef801e9..b7a89147 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -65,11 +65,28 @@ return [ packagePath: "./c9.cli.open/restart", platform: process.platform }, + "./c9.automate/automate", + "./c9.ide.installer/commands/centos", + "./c9.ide.installer/commands/bash", + "./c9.ide.installer/commands/npm", + "./c9.ide.installer/commands/symlink", + { + packagePath: "./c9.ide.installer/commands/tar.gz", + bashBin: "bash" + }, + "./c9.ide.installer/commands/ubuntu", + "./c9.ide.installer/cli", + { + packagePath: "./c9.ide.installer/installer", + homeDir: process.env.HOME, + installSelfCheck: false, + installPath: process.env.HOME + "/.c9" + }, // "./c9.cli.sync/sync", //"./c9.ide.keys/commands", { consumes: [], - provides: ["settings", "workspace", "cli_commands", "c9"], + provides: ["settings", "workspace", "cli_commands", "c9", "error_handler"], setup: function(options, imports, register) { register(null, { // @todo share with ace min @@ -80,6 +97,9 @@ return [ local: true, setStatus: function(){} }, + error_handler: { + log: function(){} + }, workspace: (function(){ var ws = new EventEmitter(); ws.connect = function(name, callback) { diff --git a/package.json b/package.json index 63f31c24..723e5a1a 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#f8f0d11bff", + "c9.ide.installer": "#13d1bd28e4", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 7f76ab70..fc1caa5c 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -118,7 +118,7 @@ define(function(require, exports, module) { cmd.addCommand({ name: "build", - info: " Builds development version of package to load in non-debug mode.", + info: " Builds development version of package to load in non-debug mode.", usage: "[--devel]", options: { "devel" : { @@ -1130,12 +1130,42 @@ define(function(require, exports, module) { if (verbose) console.log("Notifying c9.io that packages needs to be installed"); - var endpoint = options.global ? api.user : api.project; - var url = "install/" + packageName + "/" + version; - - endpoint.post(url, function(err, info){ - callback(err, info); + // Install Locally + options.local = true; + install(name + "@" + version, options, function(err){ + if (err) return callback(err); + + var path = "~/.c9/plugins/" + name; + fs.readFile(path + "/package.json", "utf8", function(err, data){ + if (err) return callback(new Error("Package.json not found in " + path)); + + var installPath; + try { installPath = JSON.parse(data).installer; } + catch(e){ + return callback(new Error("Could not parse package.json in " + path)); + } + + if (installPath) { + installer.createSession(name, version, require(path + "/" + installPath), function(err){ + if (err) return callback(new Error("Error Installing Package " + name + "@" + version)); + installToDatabase(); + }); + } + else + installToDatabase(); + }); + + + function installToDatabase(){ + var endpoint = options.global ? api.user : api.project; + var url = "install/" + packageName + "/" + version + "?silent=1"; + + endpoint.post(url, function(err, info){ + callback(err, info); + }); + } }); + } } } From c8661faee814822d4531c7672c71f1a5783ccacd Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 00:31:02 +0000 Subject: [PATCH 24/80] Added missing import --- plugins/c9.cli.publish/publish.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index fc1caa5c..4e29935e 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -1,5 +1,5 @@ define(function(require, exports, module) { - main.consumes = ["Plugin", "cli_commands", "proc", "api", "auth"]; + main.consumes = ["Plugin", "cli_commands", "proc", "api", "auth", "installer"]; main.provides = ["cli.publish"]; return main; @@ -9,6 +9,7 @@ define(function(require, exports, module) { var proc = imports.proc; var auth = imports.auth; var api = imports.api; + var installer = imports.installer; var TEST_MODE = !!process.env.C9_TEST_MODE; var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8"); From bf059cad0065a71d304cbefa742e9e72a5bad78a Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 15:52:34 +0000 Subject: [PATCH 25/80] Added gem, pip and zip package managers --- configs/cli.js | 3 +++ configs/client-default.js | 3 +++ package.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configs/cli.js b/configs/cli.js index b7a89147..df7dbe6f 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -69,6 +69,9 @@ return [ "./c9.ide.installer/commands/centos", "./c9.ide.installer/commands/bash", "./c9.ide.installer/commands/npm", + "./c9.ide.installer/commands/pip", + "./c9.ide.installer/commands/gem", + "./c9.ide.installer/commands/zip", "./c9.ide.installer/commands/symlink", { packagePath: "./c9.ide.installer/commands/tar.gz", diff --git a/configs/client-default.js b/configs/client-default.js index 39874673..c40b349b 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -525,6 +525,9 @@ module.exports = function(options) { "plugins/c9.ide.installer/commands/centos", "plugins/c9.ide.installer/commands/bash", "plugins/c9.ide.installer/commands/npm", + "plugins/c9.ide.installer/commands/pip", + "plugins/c9.ide.installer/commands/gem", + "plugins/c9.ide.installer/commands/zip", "plugins/c9.ide.installer/commands/symlink", { packagePath: "plugins/c9.ide.installer/commands/tar.gz", diff --git a/package.json b/package.json index 723e5a1a..dc29ffa0 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#13d1bd28e4", + "c9.ide.installer": "#d5c8b8f9c1", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From bc6867dd5b77dcfa21163cbaf2c31c3d9641656a Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 16:06:53 +0000 Subject: [PATCH 26/80] Add assum yes to centos and ubuntu package managers --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc29ffa0..cc33563f 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#d5c8b8f9c1", + "c9.ide.installer": "#564748e5e7", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 09b19b455761a339288614e2cf6de9aee153c8a6 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 17:07:49 +0000 Subject: [PATCH 27/80] publish.js is now split to publish.js install.js and list.js Conflicts: plugins/c9.cli.publish/publish.js --- configs/cli.js | 10 + plugins/c9.cli.publish/install.js | 542 ++++++++++++++++++++++++++++++ plugins/c9.cli.publish/list.js | 107 ++++++ plugins/c9.cli.publish/publish.js | 489 +-------------------------- 4 files changed, 670 insertions(+), 478 deletions(-) create mode 100644 plugins/c9.cli.publish/install.js create mode 100644 plugins/c9.cli.publish/list.js diff --git a/configs/cli.js b/configs/cli.js index df7dbe6f..5fc657da 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -36,6 +36,16 @@ return [ projectId: PID, apiHost: APIHOST }, + { + packagePath: "./c9.cli.publish/install", + projectId: PID, + apiHost: APIHOST + }, + { + packagePath: "./c9.cli.publish/list", + projectId: PID, + apiHost: APIHOST + }, { packagePath: "./c9.ide.auth/auth", accessToken: "token", diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js new file mode 100644 index 00000000..54580eb8 --- /dev/null +++ b/plugins/c9.cli.publish/install.js @@ -0,0 +1,542 @@ +define(function(require, exports, module) { + main.consumes = ["Plugin", "cli_commands", "proc", "api", "auth", "installer"]; + main.provides = ["cli.install"]; + return main; + + function main(options, imports, register) { + var Plugin = imports.Plugin; + var cmd = imports.cli_commands; + var proc = imports.proc; + var auth = imports.auth; + var api = imports.api; + var installer = imports.installer; + + var TEST_MODE = !!process.env.C9_TEST_MODE; + var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8"); + var TAR = "tar"; + var APIHOST = options.apiHost; + var BASICAUTH = process.env.C9_TEST_AUTH; + var SCM = { + "git": { + binary: "git", + clone: "clone" + }, + "mercurial": { + binary: "hg", + clone: "clone" + }, + "hg": { + binary: "hg", + clone: "clone" + } + }; + + var fs = require("fs"); + var join = require("path").join; + var os = require("os"); + var http = require(APIHOST.indexOf("localhost") > -1 ? "http" : "https"); + + var verbose = false; + var force = false; + + // Set up basic auth for api if needed + if (BASICAUTH) api.basicAuth = BASICAUTH; + + /***** Initialization *****/ + + var plugin = new Plugin("Ajax.org", main.consumes); + // var emit = plugin.getEmitter(); + + var loaded; + function load(){ + if (loaded) return; + loaded = true; + + cmd.addCommand({ + name: "install", + info: " Installs a cloud9 package.", + usage: "[--verbose] [--force] [--global] [--local] [--debug] [--dry-run] [@]", + options: { + "local": { + description: "", + "default": false, + "boolean": true + }, + "global": { + description: "", + "default": false, + "boolean": true + }, + "debug": { + description: "", + "default": false, + "boolean": true + }, + "package" : { + description: "", + "default": false + }, + "verbose" : { + "description": "Output more information", + "alias": "v", + "default": false, + "boolean": true + }, + "dry-run" : { + "description": "Only build a test version", + "default": false, + "boolean": true + }, + "force" : { + "description": "Ignore warnings", + "alias": "f", + "default": false, + "boolean": true + } + }, + check: function(argv) { + if (argv._.length < 2 && !argv["package"]) + throw new Error("package"); + }, + exec: function(argv) { + verbose = argv["verbose"]; + force = argv["force"]; + + if (argv.accessToken) + auth.accessToken = argv.accessToken; + + if (!argv.local && !argv.debug) { + if (!process.env.C9_PID) { + console.warn("It looks like you are not running on c9.io. Will default to local installation of the package"); + argv.local = true; + } + } + + var name = argv._[1]; + install( + name, + { + global: argv.global, + local: argv.local, + debug: argv.debug, + dryRun: argv["dry-run"] + }, + function(err, data){ + if (err) { + console.error(err.message || "Terminated."); + process.exit(1); + } + else { + console.log("Succesfully installed", name + (argv.debug ? "" : "@" + data.version)); + process.exit(0); + } + }); + } + }); + + cmd.addCommand({ + name: "remove", + info: " Removes a cloud9 package.", + usage: "[--verbose] [--global] [--local] ", // @TODO --global + options: { + "local": { + description: "", + "default": false, + "boolean": true + }, + "global": { + description: "", + "default": false, + "boolean": true + }, + "package" : { + description: "" + }, + "verbose" : { + "description": "Output more information", + "alias": "v", + "default": false, + "boolean": true + } + }, + check: function(argv) { + if (argv._.length < 2 && !argv["package"]) + throw new Error("package"); + }, + exec: function(argv) { + verbose = argv["verbose"]; + + if (argv.accessToken) + auth.accessToken = argv.accessToken; + + var name = argv._[1]; + uninstall( + name, + { + global: argv.global, + local: argv.local + }, + function(err, data){ + if (err) { + console.error(err.message || "Terminated."); + process.exit(1); + } + else { + console.log("Succesfully removed", name); + process.exit(0); + } + }); + } + }); + } + + /***** Methods *****/ + + function install(packageName, options, callback){ + // Call install url + var parts = packageName.split("@"); + var name = parts[0]; + var version = parts[1]; + var repository; + + if (!version || options.debug) { + if (verbose) + console.log("Retrieving package info"); + + api.packages.get(name, function (err, info) { + if (err) return callback(err); + + if (verbose) + console.log("Found:", info); + + version = info.latest; + repository = info.repository; + + installPackage(); + }); + } + else { + installPackage(); + } + + function prepareDirectory(callback){ + // Create package dir + var packagePath = process.env.HOME + "/.c9/plugins/" + name; + var exists = fs.existsSync(packagePath) ; + if (exists) { + if (!force) + return callback(new Error("WARNING: Directory not empty: " + packagePath + + ". Use --force to overwrite.")); + + proc.execFile("rm", { + args: ["-Rf", packagePath] + }, function(){ + mkdirP(packagePath); + callback(null, packagePath); + }); + } + else { + mkdirP(packagePath); + callback(null, packagePath); + } + } + + function installPackage(){ + if (!version) + return callback(new Error("No version found for this package")); + + if (options.local) { + if (!options.dryRun) + return callback(new Error("Dry run is not supported for local installation")); + + if (verbose) + console.log("Installing package locally"); + + prepareDirectory(function(err, packagePath){ + if (err) return callback(err); + + // Download package + var gzPath = join(os.tmpDir(), name + "@" + version + ".tar.gz"); + var file = fs.createWriteStream(gzPath); + + var path = "/packages/" + name + "/versions/" + version + + "/download?access_token=" + + encodeURIComponent(auth.accessToken); + var host = APIHOST.split(":")[0]; + var port = parseInt(APIHOST.split(":")[1]) || null; + + var request = http.get({ + agent: false, + method: "get", + host: host, + port: port, + auth: BASICAUTH, + path: path + }, function(response){ + response.pipe(file); + }); + + if (verbose) + console.log("Downloading package to", gzPath); + + request.on('response', function(res) { + if (res.statusCode != 200) + return callback(new Error("Unknown Error:" + res.statusCode)); + }); + + file.on('finish', function() { + if (verbose) + console.log("Unpacking", gzPath, "to", packagePath); + + // Untargz package + proc.spawn(TAR, { + args: ["-C", normalizePath(packagePath), "-zxvf", normalizePath(gzPath)] + }, function(err, p){ + if (err) return callback(err); + + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); + }); + } + + p.on("exit", function(code){ + var err = code !== 0 + ? new Error("Failed to unpack package") + : null; + if (err) return callback(err); + + proc.spawn(join(process.env.HOME, ".c9/node/bin/npm"), { + args: ["install"], + cwd: packagePath + }, function(err, p){ + if (err) return callback(err); + + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); + }); + } + + p.on("exit", function(code){ + // Done + callback(err, { + version: version + }); + }); + }); + }); + }); + }); + }); + } + else if (options.debug) { + if (verbose) + console.log("Installing debug version of package"); + + if (!options.dryRun) + return callback(new Error("Dry run is not supported for debug installation")); + + prepareDirectory(function(err, packagePath){ + if (err) return callback(err); + + if (verbose) + console.log("Cloning repository: ", repository); + + // Git clone repository + var scm = SCM[repository.type]; + proc.spawn(scm.binary, { + args: [scm.clone, repository.url, packagePath] + }, function(err, p){ + if (err) return callback(err); + + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); + }); + } + + p.on("exit", function(code){ + var err = code !== 0 + ? new Error("Failed to clone package from repository. Do you have access?") + : null; + + // Done + callback(err); + }); + }); + }); + } + else { + if (verbose) + console.log("Notifying c9.io that packages needs to be installed"); + + var dryRun = options.dryRun; + + // Install Locally + options.local = true; + install(name + "@" + version, options, function(err){ + if (err) return callback(err); + + var path = "~/.c9/plugins/" + name; + fs.readFile(path + "/package.json", "utf8", function(err, data){ + if (err) return callback(new Error("Package.json not found in " + path)); + + var installPath; + try { installPath = JSON.parse(data).installer; } + catch(e){ + return callback(new Error("Could not parse package.json in " + path)); + } + + if (installPath) { + installer.createSession(name, version, require(path + "/" + installPath), function(err){ + if (err) return callback(new Error("Error Installing Package " + name + "@" + version)); + installToDatabase(); + }); + } + else + installToDatabase(); + }); + + + function installToDatabase(){ + var endpoint = options.global ? api.user : api.project; + var url = "install/" + packageName + "/" + version + "?mode=silent"; + + endpoint.post(url, function(err, info){ + callback(err, info); + }); + } + }); + + } + } + } + + function uninstall(packageName, options, callback){ + // Call uninstall url + var parts = packageName.split("@"); + var name = parts[0]; + var version = parts[1]; + + if (!version) { + api.packages.get(name, function (err, info) { + if (err) return callback(err); + version = info.latest; + + uninstallPackage(); + }); + } + else { + uninstallPackage(); + } + + function uninstallPackage(){ + if (options.local || options.debug) { + // rm -Rf + var packagePath = process.env.HOME + "/.c9/plugins/" + name; + proc.spawn("rm", { + args: ["-rf", packagePath] + }, function(err, p){ + if (err) return callback(err); + + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); + }); + } + + p.on("exit", function(code){ + var err = code !== 0 + ? new Error("Failed to remove package.") + : null; + + // if debug > see if should be installed and put back original + // @TODO + + // Done + callback(err); + }); + }); + } + else { + var endpoint = options.global ? api.user : api.project; + var url = "uninstall/" + packageName; + + endpoint.post(url, function(err, info){ + callback(err, info); + }); + } + } + } + + function mkdirP(path){ + var dirs = path.split('/'); + var prevDir = dirs.splice(0,1) + "/"; + while (dirs.length > 0) { + var curDir = prevDir + dirs.splice(0,1); + if (! fs.existsSync(curDir) ) { + fs.mkdirSync(curDir); + } + prevDir = curDir + '/'; + } + } + + function normalizePath(p) { + if (process.platform == "win32") + p = p.replace(/\\/g, "/").replace(/^(\w):/, "/$1"); + return p; + } + + /***** Lifecycle *****/ + + plugin.on("load", function(){ + load(); + }); + plugin.on("enable", function(){ + + }); + plugin.on("disable", function(){ + + }); + plugin.on("unload", function(){ + loaded = false; + verbose = false; + force = false; + }); + + /***** Register and definfe API *****/ + + /** + * + **/ + plugin.freezePublicAPI({ + /** + * + */ + install: install, + + /** + * + */ + uninstall: uninstall + }); + + register(null, { + "cli.install": plugin + }); + } + +}); \ No newline at end of file diff --git a/plugins/c9.cli.publish/list.js b/plugins/c9.cli.publish/list.js new file mode 100644 index 00000000..92bd0f4c --- /dev/null +++ b/plugins/c9.cli.publish/list.js @@ -0,0 +1,107 @@ +define(function(require, exports, module) { + main.consumes = ["Plugin", "cli_commands", "api"]; + main.provides = ["cli.list"]; + return main; + + function main(options, imports, register) { + var Plugin = imports.Plugin; + var cmd = imports.cli_commands; + var api = imports.api; + + var BASICAUTH = process.env.C9_TEST_AUTH; + var verbose = false; + + // Set up basic auth for api if needed + if (BASICAUTH) api.basicAuth = BASICAUTH; + + /***** Initialization *****/ + + var plugin = new Plugin("Ajax.org", main.consumes); + // var emit = plugin.getEmitter(); + + var loaded; + function load(){ + if (loaded) return; + loaded = true; + + cmd.addCommand({ + name: "list", + info: " Lists all available packages.", + usage: "[--json]", + options: { + "json": { + description: "", + "default": false, + "boolean": true + }, + }, + check: function(argv) {}, + exec: function(argv) { + verbose = argv["verbose"]; + + list(argv.json); + } + }); + } + + /***** Methods *****/ + + function stringifyError(err){ + return (verbose ? JSON.stringify(err, 4, " ") : (typeof err == "string" ? err : err.message)); + } + + function list(asJson, callback){ + callback = callback || function(){}; + api.packages.get("", function(err, list){ + if (err) { + console.error("ERROR: Could not get list: ", stringifyError(err)); + return callback(err); + } + + if (asJson) { + console.log(JSON.stringify(list, 4, " ")); + return callback(null, list); + } + else { + list.forEach(function(item){ + console.log(item.name, "https://c9.io/packages/" + item.name); + }); + return callback(null, list); + } + }); + } + + /***** Lifecycle *****/ + + plugin.on("load", function(){ + load(); + }); + plugin.on("enable", function(){ + + }); + plugin.on("disable", function(){ + + }); + plugin.on("unload", function(){ + loaded = false; + verbose = false; + }); + + /***** Register and definfe API *****/ + + /** + * + **/ + plugin.freezePublicAPI({ + /** + * + */ + list: list + }); + + register(null, { + "cli.list": plugin + }); + } + +}); diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 4e29935e..338ed487 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -1,5 +1,5 @@ define(function(require, exports, module) { - main.consumes = ["Plugin", "cli_commands", "proc", "api", "auth", "installer"]; + main.consumes = ["Plugin", "cli_commands", "proc", "api", "auth"]; main.provides = ["cli.publish"]; return main; @@ -9,7 +9,6 @@ define(function(require, exports, module) { var proc = imports.proc; var auth = imports.auth; var api = imports.api; - var installer = imports.installer; var TEST_MODE = !!process.env.C9_TEST_MODE; var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8"); @@ -157,12 +156,12 @@ define(function(require, exports, module) { .trim() .replace(/PACKAGE_NAME/g, packageName); - fs.writeFileSync(cwd + "/__installed__.js", code, "utf8") - } else { - dryRun = true - publish({local: true}, function(err, data){}); + fs.writeFileSync(cwd + "/__installed__.js", code, "utf8"); + } + else { + dryRun = true; + publish({local: true}, function(){}); } - } }); @@ -195,156 +194,6 @@ define(function(require, exports, module) { }); } }); - - cmd.addCommand({ - name: "install", - info: " Installs a cloud9 package.", - usage: "[--verbose] [--force] [--global] [--local] [--debug] [@]", // @TODO --global, --debug, --local - options: { - "local": { - description: "", - "default": false, - "boolean": true - }, - "global": { - description: "", - "default": false, - "boolean": true - }, - "debug": { - description: "", - "default": false, - "boolean": true - }, - "package" : { - description: "", - "default": false - }, - "verbose" : { - "description": "Output more information", - "alias": "v", - "default": false, - "boolean": true - }, - "force" : { - "description": "Ignore warnings", - "alias": "f", - "default": false, - "boolean": true - } - }, - check: function(argv) { - if (argv._.length < 2 && !argv["package"]) - throw new Error("package"); - }, - exec: function(argv) { - verbose = argv["verbose"]; - force = argv["force"]; - - if (argv.accessToken) - auth.accessToken = argv.accessToken; - - if (!argv.local && !argv.debug) { - if (!process.env.C9_PID) { - console.warn("It looks like you are not running on c9.io. Will default to local installation of the package"); - argv.local = true; - } - } - - var name = argv._[1]; - install( - name, - { - global: argv.global, - local: argv.local, - debug: argv.debug - }, - function(err, data){ - if (err) { - console.error(err.message || "Terminated."); - process.exit(1); - } - else { - console.log("Succesfully installed", name + (argv.debug ? "" : "@" + data.version)); - process.exit(0); - } - }); - } - }); - - cmd.addCommand({ - name: "remove", - info: " Removes a cloud9 package.", - usage: "[--verbose] [--global] [--local] ", // @TODO --global - options: { - "local": { - description: "", - "default": false, - "boolean": true - }, - "global": { - description: "", - "default": false, - "boolean": true - }, - "package" : { - description: "" - }, - "verbose" : { - "description": "Output more information", - "alias": "v", - "default": false, - "boolean": true - } - }, - check: function(argv) { - if (argv._.length < 2 && !argv["package"]) - throw new Error("package"); - }, - exec: function(argv) { - verbose = argv["verbose"]; - - if (argv.accessToken) - auth.accessToken = argv.accessToken; - - var name = argv._[1]; - uninstall( - name, - { - global: argv.global, - local: argv.local - }, - function(err, data){ - if (err) { - console.error(err.message || "Terminated."); - process.exit(1); - } - else { - console.log("Succesfully removed", name); - process.exit(0); - } - }); - } - }); - - cmd.addCommand({ - name: "list", - info: " Lists all available packages.", - usage: "[--json]", - options: { - "json": { - description: "", - "default": false, - "boolean": true - }, - }, - check: function(argv) {}, - exec: function(argv) { - verbose = argv["verbose"]; - - list(argv.json); - } - }); } /***** Methods *****/ @@ -353,27 +202,6 @@ define(function(require, exports, module) { return (verbose ? JSON.stringify(err, 4, " ") : (typeof err == "string" ? err : err.message)); } - function list(asJson, callback){ - callback = callback || function(){}; - api.packages.get("", function(err, list){ - if (err) { - console.error("ERROR: Could not get list: ", stringifyError(err)); - return callback(err); - } - - if (asJson) { - console.log(JSON.stringify(list, 4, " ")); - return callback(null, list); - } - else { - list.forEach(function(item){ - console.log(item.name, "https://c9.io/packages/" + item.name); - }); - return callback(null, list); - } - }); - } - function publish(options, callback) { if (typeof options != "object") options = {version: options}; @@ -398,8 +226,8 @@ define(function(require, exports, module) { if (!force) return callback(new Error("Use --force to ignore this warning.")); } - if (!json.description) - return callback(new Error("ERROR: Missing description property in package.json")); + if (json.description) + return console.warn("WARNING: Description property in package.json found, but not used. Create a README.md instead."); if (!json.repository) return callback(new Error("ERROR: Missing repository property in package.json")); if (!json.categories || json.categories.length == 0) @@ -412,6 +240,8 @@ define(function(require, exports, module) { return callback(new Error("Use --force to ignore these warnings.")); } + json.description = fs.readFileSync(join(cwd, "README.md"), "utf8"); + // Validate plugins var plugins = {}; fs.readdirSync(cwd).forEach(function(filename) { @@ -949,288 +779,6 @@ define(function(require, exports, module) { }); } - function install(packageName, options, callback){ - // Call install url - var parts = packageName.split("@"); - var name = parts[0]; - var version = parts[1]; - var repository; - - if (!version || options.debug) { - if (verbose) - console.log("Retrieving package info"); - - api.packages.get(name, function (err, info) { - if (err) return callback(err); - - if (verbose) - console.log("Found:", info); - - version = info.latest; - repository = info.repository; - - installPackage(); - }); - } - else { - installPackage(); - } - - function prepareDirectory(callback){ - // Create package dir - var packagePath = process.env.HOME + "/.c9/plugins/" + name; - var exists = fs.existsSync(packagePath) ; - if (exists) { - if (!force) - return callback(new Error("WARNING: Directory not empty: " + packagePath - + ". Use --force to overwrite.")); - - proc.execFile("rm", { - args: ["-Rf", packagePath] - }, function(){ - mkdirP(packagePath); - callback(null, packagePath); - }); - } - else { - mkdirP(packagePath); - callback(null, packagePath); - } - } - - function installPackage(){ - if (!version) - return callback(new Error("No version found for this package")); - - if (options.local) { - if (verbose) - console.log("Installing package locally"); - - prepareDirectory(function(err, packagePath){ - if (err) return callback(err); - - // Download package - var gzPath = join(os.tmpDir(), name + "@" + version + ".tar.gz"); - var file = fs.createWriteStream(gzPath); - - var path = "/packages/" + name + "/versions/" + version - + "/download?access_token=" - + encodeURIComponent(auth.accessToken); - var host = APIHOST.split(":")[0]; - var port = parseInt(APIHOST.split(":")[1]) || null; - - var request = http.get({ - agent: false, - method: "get", - host: host, - port: port, - auth: BASICAUTH, - path: path - }, function(response){ - response.pipe(file); - }); - - if (verbose) - console.log("Downloading package to", gzPath); - - request.on('response', function(res) { - if (res.statusCode != 200) - return callback(new Error("Unknown Error:" + res.statusCode)); - }); - - file.on('finish', function(err) { - if (verbose) - console.log("Unpacking", gzPath, "to", packagePath); - - // Untargz package - proc.spawn(TAR, { - args: ["-C", normalizePath(packagePath), "-zxvf", normalizePath(gzPath)] - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code){ - var err = code !== 0 - ? new Error("Failed to unpack package") - : null; - if (err) return callback(err); - - proc.spawn(join(process.env.HOME, ".c9/node/bin/npm"), { - args: ["install"], - cwd: packagePath - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code){ - // Done - callback(err, { - version: version - }); - }); - }); - }); - }); - }); - }); - } - else if (options.debug) { - if (verbose) - console.log("Installing debug version of package"); - - prepareDirectory(function(err, packagePath){ - if (err) return callback(err); - - if (verbose) - console.log("Cloning repository: ", repository); - - // Git clone repository - var scm = SCM[repository.type]; - proc.spawn(scm.binary, { - args: [scm.clone, repository.url, packagePath] - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code){ - var err = code !== 0 - ? new Error("Failed to clone package from repository. Do you have access?") - : null; - - // Done - callback(err); - }); - }); - }); - } - else { - if (verbose) - console.log("Notifying c9.io that packages needs to be installed"); - - // Install Locally - options.local = true; - install(name + "@" + version, options, function(err){ - if (err) return callback(err); - - var path = "~/.c9/plugins/" + name; - fs.readFile(path + "/package.json", "utf8", function(err, data){ - if (err) return callback(new Error("Package.json not found in " + path)); - - var installPath; - try { installPath = JSON.parse(data).installer; } - catch(e){ - return callback(new Error("Could not parse package.json in " + path)); - } - - if (installPath) { - installer.createSession(name, version, require(path + "/" + installPath), function(err){ - if (err) return callback(new Error("Error Installing Package " + name + "@" + version)); - installToDatabase(); - }); - } - else - installToDatabase(); - }); - - - function installToDatabase(){ - var endpoint = options.global ? api.user : api.project; - var url = "install/" + packageName + "/" + version + "?silent=1"; - - endpoint.post(url, function(err, info){ - callback(err, info); - }); - } - }); - - } - } - } - - function uninstall(packageName, options, callback){ - // Call uninstall url - var parts = packageName.split("@"); - var name = parts[0]; - var version = parts[1]; - - if (!version) { - api.packages.get(name, function (err, info) { - if (err) return callback(err); - version = info.latest; - - uninstallPackage(); - }); - } - else { - uninstallPackage(); - } - - function uninstallPackage(){ - if (options.local || options.debug) { - // rm -Rf - var packagePath = process.env.HOME + "/.c9/plugins/" + name; - proc.spawn("rm", { - args: ["-rf", packagePath] - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code){ - var err = code !== 0 - ? new Error("Failed to remove package.") - : null; - - // if debug > see if should be installed and put back original - // @TODO - - // Done - callback(err); - }); - }); - } - else { - var endpoint = options.global ? api.user : api.project; - var url = "uninstall/" + packageName; - - endpoint.post(url, function(err, info){ - callback(err, info); - }); - } - } - } - function mkdirP(path){ var dirs = path.split('/'); var prevDir = dirs.splice(0,1) + "/"; @@ -1280,22 +828,7 @@ define(function(require, exports, module) { /** * */ - unpublish: unpublish, - - /** - * - */ - install: install, - - /** - * - */ - uninstall: uninstall, - - /** - * - */ - list: list + unpublish: unpublish }); register(null, { From af9d420266b10e0cf063ebf4730933d47d342ea7 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 19:07:00 +0000 Subject: [PATCH 28/80] Added message command and verbose mode for cli and fixes output for zip and tar.gz --- configs/cli.js | 5 +- configs/client-default.js | 1 + package.json | 2 +- plugins/c9.cli.publish/install.js | 323 +++++++++++++++++------------- plugins/c9.cli.publish/publish.js | 2 + plugins/c9.vfs.client/vfs.cli.js | 2 +- 6 files changed, 189 insertions(+), 146 deletions(-) diff --git a/configs/cli.js b/configs/cli.js index 5fc657da..49d59327 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -83,6 +83,7 @@ return [ "./c9.ide.installer/commands/gem", "./c9.ide.installer/commands/zip", "./c9.ide.installer/commands/symlink", + "./c9.ide.installer/commands/message", { packagePath: "./c9.ide.installer/commands/tar.gz", bashBin: "bash" @@ -93,7 +94,8 @@ return [ packagePath: "./c9.ide.installer/installer", homeDir: process.env.HOME, installSelfCheck: false, - installPath: process.env.HOME + "/.c9" + installPath: process.env.HOME + "/.c9", + cli: true }, // "./c9.cli.sync/sync", //"./c9.ide.keys/commands", @@ -108,6 +110,7 @@ return [ debug: true, hosted: false, local: true, + home: process.env.HOME, setStatus: function(){} }, error_handler: { diff --git a/configs/client-default.js b/configs/client-default.js index c40b349b..f693e944 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -529,6 +529,7 @@ module.exports = function(options) { "plugins/c9.ide.installer/commands/gem", "plugins/c9.ide.installer/commands/zip", "plugins/c9.ide.installer/commands/symlink", + "plugins/c9.ide.installer/commands/message", { packagePath: "plugins/c9.ide.installer/commands/tar.gz", bashBin: options.bashBin diff --git a/package.json b/package.json index cc33563f..f745d60c 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#564748e5e7", + "c9.ide.installer": "#2dc739e7e3", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index 54580eb8..eb14b7b2 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -1,5 +1,8 @@ define(function(require, exports, module) { - main.consumes = ["Plugin", "cli_commands", "proc", "api", "auth", "installer"]; + main.consumes = [ + "Plugin", "cli_commands", "proc", "api", "auth", "installer", + "installer.cli" + ]; main.provides = ["cli.install"]; return main; @@ -10,6 +13,7 @@ define(function(require, exports, module) { var auth = imports.auth; var api = imports.api; var installer = imports.installer; + var installerCLI = imports["installer.cli"]; var TEST_MODE = !!process.env.C9_TEST_MODE; var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8"); @@ -83,7 +87,7 @@ define(function(require, exports, module) { "boolean": true }, "dry-run" : { - "description": "Only build a test version", + "description": "Installs current directory as a package", "default": false, "boolean": true }, @@ -199,7 +203,7 @@ define(function(require, exports, module) { var version = parts[1]; var repository; - if (!version || options.debug) { + if ((!version || options.debug) && !options.dryRun) { if (verbose) console.log("Retrieving package info"); @@ -242,117 +246,107 @@ define(function(require, exports, module) { } function installPackage(){ - if (!version) + if (!version && !options.dryRun) return callback(new Error("No version found for this package")); if (options.local) { - if (!options.dryRun) - return callback(new Error("Dry run is not supported for local installation")); + installLocal(); + } + else if (options.debug) { + installDebug(); + } + else { + installFull(); + } + } + + function installLocal(){ + if (verbose) + console.log("Installing package locally"); + + prepareDirectory(function(err, packagePath){ + if (err) return callback(err); - if (verbose) - console.log("Installing package locally"); - - prepareDirectory(function(err, packagePath){ - if (err) return callback(err); - - // Download package - var gzPath = join(os.tmpDir(), name + "@" + version + ".tar.gz"); - var file = fs.createWriteStream(gzPath); - - var path = "/packages/" + name + "/versions/" + version - + "/download?access_token=" - + encodeURIComponent(auth.accessToken); - var host = APIHOST.split(":")[0]; - var port = parseInt(APIHOST.split(":")[1]) || null; - - var request = http.get({ - agent: false, - method: "get", - host: host, - port: port, - auth: BASICAUTH, - path: path - }, function(response){ - response.pipe(file); - }); - - if (verbose) - console.log("Downloading package to", gzPath); - - request.on('response', function(res) { - if (res.statusCode != 200) - return callback(new Error("Unknown Error:" + res.statusCode)); - }); - - file.on('finish', function() { - if (verbose) - console.log("Unpacking", gzPath, "to", packagePath); + function installNPM(){ + proc.spawn(join(process.env.HOME, ".c9/node/bin/npm"), { + args: ["install"], + cwd: packagePath + }, function(err, p){ + if (err) return callback(err); - // Untargz package - proc.spawn(TAR, { - args: ["-C", normalizePath(packagePath), "-zxvf", normalizePath(gzPath)] - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code){ - var err = code !== 0 - ? new Error("Failed to unpack package") - : null; - if (err) return callback(err); - - proc.spawn(join(process.env.HOME, ".c9/node/bin/npm"), { - args: ["install"], - cwd: packagePath - }, function(err, p){ - if (err) return callback(err); - - if (verbose) { - p.stdout.on("data", function(c){ - process.stdout.write(c.toString("utf8")); - }); - p.stderr.on("data", function(c){ - process.stderr.write(c.toString("utf8")); - }); - } - - p.on("exit", function(code){ - // Done - callback(err, { - version: version - }); - }); - }); + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); + }); + } + + p.on("exit", function(code){ + // Done + callback(err, { + version: version }); }); }); - }); - } - else if (options.debug) { - if (verbose) - console.log("Installing debug version of package"); + } - if (!options.dryRun) - return callback(new Error("Dry run is not supported for debug installation")); - - prepareDirectory(function(err, packagePath){ - if (err) return callback(err); - - if (verbose) - console.log("Cloning repository: ", repository); + if (options.dryRun) { + try { + var json = JSON.parse(fs.readFileSync(join(process.cwd(), "package.json"))); + if (json.private) + return callback(new Error("ERROR: Private flag in package.json prevents from installing")); + } + catch(e) { + return callback(new Error("ERROR: Invalid package")); + } - // Git clone repository - var scm = SCM[repository.type]; - proc.spawn(scm.binary, { - args: [scm.clone, repository.url, packagePath] + proc.execFile("bash", { args: ["-c", "cp -a " + join(process.cwd(), "/*") + " " + packagePath] }, function(err){ + if (err) return callback(err); + + installNPM(); + }); + + return; + } + + // Download package + var gzPath = join(os.tmpDir(), name + "@" + version + ".tar.gz"); + var file = fs.createWriteStream(gzPath); + + var path = "/packages/" + name + "/versions/" + version + + "/download?access_token=" + + encodeURIComponent(auth.accessToken); + var host = APIHOST.split(":")[0]; + var port = parseInt(APIHOST.split(":")[1]) || null; + + var request = http.get({ + agent: false, + method: "get", + host: host, + port: port, + auth: BASICAUTH, + path: path + }, function(response){ + response.pipe(file); + }); + + if (verbose) + console.log("Downloading package to", gzPath); + + request.on('response', function(res) { + if (res.statusCode != 200) + return callback(new Error("Unknown Error:" + res.statusCode)); + }); + + file.on('finish', function() { + if (verbose) + console.log("Unpacking", gzPath, "to", packagePath); + + // Untargz package + proc.spawn(TAR, { + args: ["-C", normalizePath(packagePath), "-zxvf", normalizePath(gzPath)] }, function(err, p){ if (err) return callback(err); @@ -367,58 +361,101 @@ define(function(require, exports, module) { p.on("exit", function(code){ var err = code !== 0 - ? new Error("Failed to clone package from repository. Do you have access?") + ? new Error("Failed to unpack package") : null; + if (err) return callback(err); - // Done - callback(err); + installNPM(); }); }); }); - } - else { + }); + } + + function installDebug(){ + if (verbose) + console.log("Installing debug version of package"); + + if (!options.dryRun) + return callback(new Error("Dry run is not supported for debug installations")); + + prepareDirectory(function(err, packagePath){ + if (err) return callback(err); + if (verbose) - console.log("Notifying c9.io that packages needs to be installed"); + console.log("Cloning repository: ", repository); - var dryRun = options.dryRun; - - // Install Locally - options.local = true; - install(name + "@" + version, options, function(err){ + // Git clone repository + var scm = SCM[repository.type]; + proc.spawn(scm.binary, { + args: [scm.clone, repository.url, packagePath] + }, function(err, p){ if (err) return callback(err); - var path = "~/.c9/plugins/" + name; - fs.readFile(path + "/package.json", "utf8", function(err, data){ - if (err) return callback(new Error("Package.json not found in " + path)); - - var installPath; - try { installPath = JSON.parse(data).installer; } - catch(e){ - return callback(new Error("Could not parse package.json in " + path)); - } - - if (installPath) { - installer.createSession(name, version, require(path + "/" + installPath), function(err){ - if (err) return callback(new Error("Error Installing Package " + name + "@" + version)); - installToDatabase(); - }); - } - else - installToDatabase(); - }); - - - function installToDatabase(){ - var endpoint = options.global ? api.user : api.project; - var url = "install/" + packageName + "/" + version + "?mode=silent"; - - endpoint.post(url, function(err, info){ - callback(err, info); + if (verbose) { + p.stdout.on("data", function(c){ + process.stdout.write(c.toString("utf8")); + }); + p.stderr.on("data", function(c){ + process.stderr.write(c.toString("utf8")); }); } + + p.on("exit", function(code){ + var err = code !== 0 + ? new Error("Failed to clone package from repository. Do you have access?") + : null; + + // Done + callback(err); + }); + }); + }); + } + + function installFull(){ + if (verbose) + console.log("Notifying c9.io that packages needs to be installed"); + + // Install Locally + options.local = true; + install(name + "@" + version, options, function(err){ + if (err) return callback(err); + + var path = process.env.HOME + "/.c9/plugins/" + name; + fs.readFile(path + "/package.json", "utf8", function(err, data){ + if (err) return callback(new Error("Package.json not found in " + path)); + + var installPath; + try { installPath = JSON.parse(data).installer; } + catch(e){ + return callback(new Error("Could not parse package.json in " + path)); + } + + if (installPath) { + installerCLI.verbose = verbose; + installer.createSession(name, version, require(path + "/" + installPath), function(err){ + if (err) return callback(new Error("Error Installing Package " + name + "@" + version)); + installToDatabase(); + }); + } + else + installToDatabase(); }); - } + + function installToDatabase(){ + if (options.dryRun) + return callback(null, { version: "dry-run" }); + + var endpoint = options.global ? api.user : api.project; + var url = "install/" + packageName + "/" + version + "?mode=silent"; + + endpoint.post(url, function(err, info){ + callback(err, info); + }); + } + }); } } diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 338ed487..37e20cda 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -219,6 +219,8 @@ define(function(require, exports, module) { } // Basic Validation + if (json.private) + return callback(new Error("ERROR: Private flag in package.json prevents from publishing")); if (!json.name) return callback(new Error("ERROR: Missing name property in package.json")); if (basename(cwd) != json.name) { diff --git a/plugins/c9.vfs.client/vfs.cli.js b/plugins/c9.vfs.client/vfs.cli.js index 915200fe..92d339e8 100644 --- a/plugins/c9.vfs.client/vfs.cli.js +++ b/plugins/c9.vfs.client/vfs.cli.js @@ -9,7 +9,7 @@ define(function(require, module, exports) { var vfs = new localFs({ root: "/", - nopty: true, + // nopty: true, defaultEnv: { CUSTOM: 43 } }); From 24aba37278bdb472ddad165c1154ba4a78dc255c Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 19:12:12 +0000 Subject: [PATCH 29/80] Tweak to description warning --- plugins/c9.cli.publish/publish.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 37e20cda..b142dbd6 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -228,8 +228,6 @@ define(function(require, exports, module) { if (!force) return callback(new Error("Use --force to ignore this warning.")); } - if (json.description) - return console.warn("WARNING: Description property in package.json found, but not used. Create a README.md instead."); if (!json.repository) return callback(new Error("ERROR: Missing repository property in package.json")); if (!json.categories || json.categories.length == 0) @@ -242,6 +240,9 @@ define(function(require, exports, module) { return callback(new Error("Use --force to ignore these warnings.")); } + if (json.description) + return console.warn("WARNING: Description property in package.json will be ignored. README.md will be used."); + json.description = fs.readFileSync(join(cwd, "README.md"), "utf8"); // Validate plugins From 485f194359aefe25f780b28976581150e5dd27d2 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 19:43:38 +0000 Subject: [PATCH 30/80] Nicer representation of c9 list command --- plugins/c9.cli.publish/list.js | 27 +++++++++++++++++++++++++-- plugins/c9.cli.publish/publish.js | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/plugins/c9.cli.publish/list.js b/plugins/c9.cli.publish/list.js index 92bd0f4c..b99ad46f 100644 --- a/plugins/c9.cli.publish/list.js +++ b/plugins/c9.cli.publish/list.js @@ -11,6 +11,10 @@ define(function(require, exports, module) { var BASICAUTH = process.env.C9_TEST_AUTH; var verbose = false; + var LIGHTBlUE = "\x1b[01;94m"; + var RESETCOLOR = "\x1b[0m"; + var PADDING = 2; + // Set up basic auth for api if needed if (BASICAUTH) api.basicAuth = BASICAUTH; @@ -39,7 +43,11 @@ define(function(require, exports, module) { exec: function(argv) { verbose = argv["verbose"]; - list(argv.json); + list(argv.json, function(err){ + if (err) + console.error(err.message || err); + process.exit(err ? 1 : 0); + }); } }); } @@ -50,6 +58,10 @@ define(function(require, exports, module) { return (verbose ? JSON.stringify(err, 4, " ") : (typeof err == "string" ? err : err.message)); } + function pad(str, nr){ + return str + Array(nr - str.length).join(" "); + } + function list(asJson, callback){ callback = callback || function(){}; api.packages.get("", function(err, list){ @@ -63,8 +75,19 @@ define(function(require, exports, module) { return callback(null, list); } else { + var max = [0, 0, 0, 0]; list.forEach(function(item){ - console.log(item.name, "https://c9.io/packages/" + item.name); + max[0] = Math.max(max[0], item.name.length); + max[1] = Math.max(max[1], Math.min(100, item.description.split(".")[0].length)); + max[2] = Math.max(max[2], item.name.length + 33); + max[3] = Math.max(max[3], (item.website || item.repository.url).length); + }); + list.forEach(function(item){ + console.log( + 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])); }); return callback(null, list); } diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index b142dbd6..627b85ef 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -241,7 +241,7 @@ define(function(require, exports, module) { } if (json.description) - return console.warn("WARNING: Description property in package.json will be ignored. README.md will be used."); + console.warn("WARNING: Description property in package.json will be ignored. README.md will be used."); json.description = fs.readFileSync(join(cwd, "README.md"), "utf8"); From e6f514e5fbea53a6574f73a3db670e46564c7390 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 19:51:14 +0000 Subject: [PATCH 31/80] Tweaks --- plugins/c9.cli.publish/list.js | 2 +- plugins/c9.cli.publish/publish.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/c9.cli.publish/list.js b/plugins/c9.cli.publish/list.js index b99ad46f..a937e903 100644 --- a/plugins/c9.cli.publish/list.js +++ b/plugins/c9.cli.publish/list.js @@ -78,7 +78,7 @@ define(function(require, exports, module) { var max = [0, 0, 0, 0]; list.forEach(function(item){ max[0] = Math.max(max[0], item.name.length); - max[1] = Math.max(max[1], Math.min(100, item.description.split(".")[0].length)); + max[1] = Math.max(max[1], Math.min(50, item.description.split(".")[0].length)); max[2] = Math.max(max[2], item.name.length + 33); max[3] = Math.max(max[3], (item.website || item.repository.url).length); }); diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 627b85ef..81ba44f4 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -243,6 +243,7 @@ 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"); // Validate plugins @@ -306,10 +307,14 @@ 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(json, null, indent); - fs.writeFile(cwd + "/.c9/.build/pacage.json", newData, function(err){ + var newData = JSON.stringify(pkgJson, 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 fs.writeFile(packagePath, newData, function(err){ From edd2ca0b8c563d9695d78a9656ac1b1496e99079 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 19:59:45 +0000 Subject: [PATCH 32/80] Require repository.url for publishing packages --- plugins/c9.cli.publish/publish.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 81ba44f4..37ae956c 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -230,6 +230,8 @@ define(function(require, exports, module) { } if (!json.repository) return callback(new Error("ERROR: Missing repository property in package.json")); + if (!json.repository.url) + return callback(new Error("ERROR: Missing repository.url property in package.json")); if (!json.categories || json.categories.length == 0) return callback(new Error("ERROR: At least one category is required in package.json")); From bcac492e984843615256ea2c93a6b528483ce97f Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 22:42:31 +0000 Subject: [PATCH 33/80] Add a previous button to a failed execute in the installer --- package.json | 4 ++-- plugins/c9.ide.plugins/loader.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f745d60c..ed9ba16b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "c9.ide.find.infiles": "#72582de3cd", "c9.ide.find.replace": "#e4daf722b8", "c9.ide.run.debug": "#638e6b00b3", - "c9.automate": "#3e6927aa96", + "c9.automate": "#20305221f7", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#43445d6306", @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#2dc739e7e3", + "c9.ide.installer": "#66d689af95", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", diff --git a/plugins/c9.ide.plugins/loader.js b/plugins/c9.ide.plugins/loader.js index 7b21a959..651e2bc5 100644 --- a/plugins/c9.ide.plugins/loader.js +++ b/plugins/c9.ide.plugins/loader.js @@ -58,9 +58,9 @@ define(function(require, exports, module) { fs.readdir("~/.c9/plugins", function handle(err, files){ if (err) { if (err.code == "EDISCONNECT") { - c9.once("connect", function(){ + setTimeout(function(){ fs.readdir("~/.c9/plugins", handle); - }); + }, 100); } console.error(err); return; From 81839341028fecdb54ae740cfdddb17e2eedf297 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 01:38:23 +0400 Subject: [PATCH 34/80] use async.series also when autoinstalling --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed9ba16b..733f9460 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#66d689af95", + "c9.ide.installer": "#e956bc0696", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 594eb7d943fc86b7ff41911ae73c970a37d3a6b1 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 27 Apr 2015 23:02:01 +0000 Subject: [PATCH 35/80] potential fix for not starting in headless mode --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 733f9460..ae27993b 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#e956bc0696", + "c9.ide.installer": "#9b047123bb", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 06af43a78b85fbaafae3e7abc4fef6c8059b9796 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Fri, 24 Apr 2015 22:44:32 +0000 Subject: [PATCH 36/80] Fixed *a lot* of installer issues --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae27993b..a79c821d 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "c9.ide.find.infiles": "#72582de3cd", "c9.ide.find.replace": "#e4daf722b8", "c9.ide.run.debug": "#638e6b00b3", - "c9.automate": "#20305221f7", + "c9.automate": "#8638ccd495", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#43445d6306", @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#9b047123bb", + "c9.ide.installer": "#dd4c28cd9a", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 8ade8783ae1e3eb85916c3df01516ce93c441193 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 00:25:02 +0000 Subject: [PATCH 37/80] Headless now takes the normal flow --- package.json | 6 +++--- plugins/c9.ide.plugins/loader.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a79c821d..4ed24d12 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "c9.ide.find.infiles": "#72582de3cd", "c9.ide.find.replace": "#e4daf722b8", "c9.ide.run.debug": "#638e6b00b3", - "c9.automate": "#8638ccd495", + "c9.automate": "#47e2c429c9", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#43445d6306", @@ -77,13 +77,13 @@ "c9.ide.behaviors": "#6aad7006a0", "c9.ide.closeconfirmation": "#a28bfd8272", "c9.ide.configuration": "#adf50fdaa2", - "c9.ide.dialog.wizard": "#ea640aa5a1", + "c9.ide.dialog.wizard": "#5df4f14bb8", "c9.ide.fontawesome": "#781602c5d8", "c9.ide.format": "#f51451ac57", "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#dd4c28cd9a", + "c9.ide.installer": "#c0c85f897e", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", diff --git a/plugins/c9.ide.plugins/loader.js b/plugins/c9.ide.plugins/loader.js index 651e2bc5..7b21a959 100644 --- a/plugins/c9.ide.plugins/loader.js +++ b/plugins/c9.ide.plugins/loader.js @@ -58,9 +58,9 @@ define(function(require, exports, module) { fs.readdir("~/.c9/plugins", function handle(err, files){ if (err) { if (err.code == "EDISCONNECT") { - setTimeout(function(){ + c9.once("connect", function(){ fs.readdir("~/.c9/plugins", handle); - }, 100); + }); } console.error(err); return; From 24ae5acf0f66f77811c984ea34a33ebd76ca0b4e Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 04:09:16 +0400 Subject: [PATCH 38/80] support sudo without pty.js --- package.json | 2 +- plugins/c9.fs/proc2pty.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4ed24d12..c07e5bcc 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#c0c85f897e", + "c9.ide.installer": "#086206a67f", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", diff --git a/plugins/c9.fs/proc2pty.js b/plugins/c9.fs/proc2pty.js index 249cda20..d9b9d562 100644 --- a/plugins/c9.fs/proc2pty.js +++ b/plugins/c9.fs/proc2pty.js @@ -4,7 +4,7 @@ define(function(require, exports, module) { module.exports = function(process){ var pty = new EventEmitter(); pty.write = function(data){ - process.stdin.write(data); + process.stdin.write(data.replace(/\r/g, "\n")); }; pty.resize = function(){}; pty.destroy = @@ -23,5 +23,5 @@ define(function(require, exports, module) { }); return pty; - } + }; }); \ No newline at end of file From b747e418627c53e5c488ea950ae67a77201fe6c8 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 04:10:22 +0400 Subject: [PATCH 39/80] update state of always install checkbox when shwoing dialog --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c07e5bcc..af456022 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#086206a67f", + "c9.ide.installer": "#dcd72fae73", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 232f6f01dd86d089f8d685ac74ef5bff1febe5e5 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 04:11:12 +0400 Subject: [PATCH 40/80] use sudo to install missing build-essential --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af456022..1cebfb15 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#dcd72fae73", + "c9.ide.installer": "#c3790e1c6a", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From f669c557d8c22bf788d9fbe3ec19522947b6b015 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 00:32:14 +0000 Subject: [PATCH 41/80] update setting when it's updated from settings --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1cebfb15..e21acc79 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#c3790e1c6a", + "c9.ide.installer": "#f358a56311", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 89f5323ad433dac7961db163b2ed11ac89fc4327 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 00:34:28 +0000 Subject: [PATCH 42/80] cleanup --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e21acc79..187334ab 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#f358a56311", + "c9.ide.installer": "#9bdac12d81", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 55ad10af6938c953505f25b64afea138953eedc6 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 01:40:20 +0000 Subject: [PATCH 43/80] Added brew support --- configs/cli.js | 1 + configs/client-default.js | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/cli.js b/configs/cli.js index 49d59327..ba843516 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -77,6 +77,7 @@ return [ }, "./c9.automate/automate", "./c9.ide.installer/commands/centos", + "./c9.ide.installer/commands/darwin", "./c9.ide.installer/commands/bash", "./c9.ide.installer/commands/npm", "./c9.ide.installer/commands/pip", diff --git a/configs/client-default.js b/configs/client-default.js index f693e944..0e403b4e 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -523,6 +523,7 @@ module.exports = function(options) { }, "plugins/c9.automate/automate", "plugins/c9.ide.installer/commands/centos", + "plugins/c9.ide.installer/commands/darwin", "plugins/c9.ide.installer/commands/bash", "plugins/c9.ide.installer/commands/npm", "plugins/c9.ide.installer/commands/pip", diff --git a/package.json b/package.json index 187334ab..fa35e43b 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#9bdac12d81", + "c9.ide.installer": "#02e7018bf6", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 2f833df7f4d6faba5a6e020c25e745fc76c62d3a Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 04:14:56 +0400 Subject: [PATCH 44/80] make output of error handler nicer --- plugins/c9.ide.errorhandler/raygun_error_handler.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/c9.ide.errorhandler/raygun_error_handler.js b/plugins/c9.ide.errorhandler/raygun_error_handler.js index 12be8f71..3c3dcca8 100644 --- a/plugins/c9.ide.errorhandler/raygun_error_handler.js +++ b/plugins/c9.ide.errorhandler/raygun_error_handler.js @@ -62,7 +62,9 @@ define(function(require, exports, module) { exception = new Error(exception); if (!exception) exception = new Error("Unspecified error"); - console.error(exception.stack); + console.error(exception); + if (customData) + console.log(customData); Raygun.send(exception, customData, tags); } From 3bbff9b45b91da4eb89d0a5474a07425973b5754 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 22:16:55 +0000 Subject: [PATCH 45/80] Remove a heading at the top of the readme --- plugins/c9.cli.publish/publish.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 37ae956c..d120a885 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -246,7 +246,8 @@ define(function(require, exports, module) { 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"); + json.description = fs.readFileSync(join(cwd, "README.md"), "utf8") + .replace(/^\#.*\n*/, ""); // Validate plugins var plugins = {}; From 16136f2c474e3a3e0b4b09e900c107481621b0a0 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 29 Apr 2015 02:27:11 +0400 Subject: [PATCH 46/80] do not destroy package.json of published plugin --- configs/cli.js | 3 ++- package.json | 2 +- plugins/c9.cli.publish/publish.js | 13 ++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/configs/cli.js b/configs/cli.js index ba843516..08fac3d6 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -112,7 +112,8 @@ return [ hosted: false, local: true, home: process.env.HOME, - setStatus: function(){} + setStatus: function(){}, + location: "" }, error_handler: { log: function(){} diff --git a/package.json b/package.json index fa35e43b..cdd2b9a1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index d120a885..0a4693b2 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -245,8 +245,7 @@ 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 @@ -310,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 @@ -651,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", @@ -683,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 From 7dd8b141aee15f91bacc5fa8af942ade72088afd Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 28 Apr 2015 22:41:55 +0000 Subject: [PATCH 47/80] Fix installer error reporting --- plugins/c9.cli.publish/install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index eb14b7b2..31311621 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -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){ From b8fc691bea98a36e589e0e63c8638bfaaea5a353 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 29 Apr 2015 04:19:20 +0400 Subject: [PATCH 48/80] more c9 cli tweaks --- plugins/c9.cli.publish/list.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/c9.cli.publish/list.js b/plugins/c9.cli.publish/list.js index a937e903..c1511530 100644 --- a/plugins/c9.cli.publish/list.js +++ b/plugins/c9.cli.publish/list.js @@ -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); } From b42d7a62f200ae03562f67c5a865670ed0985fd4 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 01:41:03 +0000 Subject: [PATCH 49/80] Change to , fix fs module and fix issue with flow. Also now installed is written properly --- configs/cli.js | 5 +++ package.json | 3 +- plugins/c9.cli.publish/install.js | 59 +++++++++++++++++++------------ plugins/c9.fs/fs.js | 5 ++- plugins/c9.fs/fs.streams.js | 14 +++++--- 5 files changed, 56 insertions(+), 30 deletions(-) diff --git a/configs/cli.js b/configs/cli.js index 08fac3d6..eeb5de2d 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -1,6 +1,11 @@ module.exports = function(options) { var EventEmitter = require("events").EventEmitter; +EventEmitter.prototype.emit = new Function("type", + EventEmitter.prototype.emit.toString() + .replace(/return false/g, "return") + .replace(/^.*\n/, "") + .replace(/\}$/, "")); var PID = process.env.C9_PID || 526; var APIHOST = process.env.C9_APIHOST || "api.c9.io"; // "api.c9.io"; diff --git a/package.json b/package.json index cdd2b9a1..7f6c70c1 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#63c3c021e3", + "c9.ide.installer": "#fd20938443", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", @@ -95,6 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", + "c9.ide.processlist": "#bc11818bb5", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index 31311621..131ec69f 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -59,7 +59,7 @@ define(function(require, exports, module) { cmd.addCommand({ name: "install", info: " Installs a cloud9 package.", - usage: "[--verbose] [--force] [--global] [--local] [--debug] [--dry-run] [@]", + usage: "[--verbose] [--force] [--global] [--local] [--debug] [[@] | . ]", options: { "local": { description: "", @@ -86,11 +86,6 @@ define(function(require, exports, module) { "default": false, "boolean": true }, - "dry-run" : { - "description": "Installs current directory as a package", - "default": false, - "boolean": true - }, "force" : { "description": "Ignore warnings", "alias": "f", @@ -117,13 +112,17 @@ define(function(require, exports, module) { } var name = argv._[1]; + var test = name == "."; + if (test) + name = require("path").basename(process.cwd()); + install( name, { global: argv.global, local: argv.local, debug: argv.debug, - dryRun: argv["dry-run"] + test: test }, function(err, data){ if (err) { @@ -203,7 +202,7 @@ define(function(require, exports, module) { var version = parts[1]; var repository; - if ((!version || options.debug) && !options.dryRun) { + if ((!version || options.debug) && !options.test) { if (verbose) console.log("Retrieving package info"); @@ -226,9 +225,14 @@ define(function(require, exports, module) { function prepareDirectory(callback){ // Create package dir var packagePath = process.env.HOME + "/.c9/plugins/" + name; - var exists = fs.existsSync(packagePath) ; + var exists = fs.existsSync(packagePath); + + // Ignore when testing and in the same dir + if (options.test && process.cwd() == packagePath) + exists = false; + if (exists) { - if (!force) + if (!force && !options.test) return callback(new Error("WARNING: Directory not empty: " + packagePath + ". Use --force to overwrite.")); @@ -246,7 +250,7 @@ define(function(require, exports, module) { } function installPackage(){ - if (!version && !options.dryRun) + if (!version && !options.test) return callback(new Error("No version found for this package")); if (options.local) { @@ -292,7 +296,7 @@ define(function(require, exports, module) { }); } - if (options.dryRun) { + if (options.test) { try { var json = JSON.parse(fs.readFileSync(join(process.cwd(), "package.json"))); if (json.private) @@ -302,11 +306,20 @@ define(function(require, exports, module) { return callback(new Error("ERROR: Invalid package: " + e.message)); } - proc.execFile("bash", { args: ["-c", "cp -a " + join(process.cwd(), "/*") + " " + packagePath] }, function(err){ - if (err) return callback(err); - + if (process.cwd() == packagePath) installNPM(); - }); + else { + proc.execFile("bash", { + args: [ + "-c", "cp -a " + join(process.cwd(), "/*") + + " " + packagePath + ] + }, function(err){ + if (err) return callback(err); + + installNPM(); + }); + } return; } @@ -376,7 +389,7 @@ define(function(require, exports, module) { if (verbose) console.log("Installing debug version of package"); - if (!options.dryRun) + if (!options.test) return callback(new Error("Dry run is not supported for debug installations")); prepareDirectory(function(err, packagePath){ @@ -421,11 +434,11 @@ define(function(require, exports, module) { options.local = true; install(name + "@" + version, options, function(err){ if (err) return callback(err); - + var path = process.env.HOME + "/.c9/plugins/" + name; fs.readFile(path + "/package.json", "utf8", function(err, data){ if (err) return callback(new Error("Package.json not found in " + path)); - + var installPath; try { installPath = JSON.parse(data).installer; } catch(e){ @@ -434,10 +447,10 @@ define(function(require, exports, module) { if (installPath) { installerCLI.verbose = verbose; - installer.createSession(name, version, require(path + "/" + installPath), function(err){ + installer.createSession(name, version || "", require(path + "/" + installPath), function(err){ if (err) return callback(new Error("Error Installing Package " + name + "@" + version)); installToDatabase(); - }); + }, force || options.test); } else installToDatabase(); @@ -445,8 +458,8 @@ define(function(require, exports, module) { function installToDatabase(){ - if (options.dryRun) - return callback(null, { version: "dry-run" }); + if (options.test) + return callback(null, { version: "test" }); var endpoint = options.global ? api.user : api.project; var url = "install/" + packageName + "/" + version + "?mode=silent"; diff --git a/plugins/c9.fs/fs.js b/plugins/c9.fs/fs.js index e725d694..a3145076 100644 --- a/plugins/c9.fs/fs.js +++ b/plugins/c9.fs/fs.js @@ -18,7 +18,7 @@ define(function(require, exports, module) { var vfs = imports.vfs; var Plugin = imports.Plugin; - var stream = require("./fs.streams")(vfs, options.base, options.baseProc); + var stream = require("./fs.streams")(vfs, options.base, options.baseProc, options.cli); var xhr = options.cli ? stream : require("./fs.xhr")(vfs.rest); var uCaseFirst = require("c9/string").uCaseFirst; @@ -54,6 +54,8 @@ define(function(require, exports, module) { if (loaded) return false; loaded = true; + if (options.cli) + plugin.on("error", function(e){ console.error(e.error); }); } function wrap(name, fn) { @@ -104,6 +106,7 @@ define(function(require, exports, module) { original_callback.__cb__ = cb; var event = { path: path, args: args, fn: fn }; + if (emit("before" + uCaseFirst(name), event) === false) return false; diff --git a/plugins/c9.fs/fs.streams.js b/plugins/c9.fs/fs.streams.js index 8ab60423..19a5fbfe 100644 --- a/plugins/c9.fs/fs.streams.js +++ b/plugins/c9.fs/fs.streams.js @@ -3,10 +3,14 @@ define(function(require, exports, module) { var Stream = require("stream").Stream; var PATH = require("path"); -return function(vfs, base, baseProc) { +return function(vfs, base, baseProc, cli) { var resolvePath = function(path, basePath) { - if (path.charAt(0) == "~") return path; + if (path.charAt(0) == "~") { + if (cli) + return process.env.HOME + "/" + path.substr(1); + return path; + } if (!basePath) basePath = base; @@ -20,7 +24,7 @@ return function(vfs, base, baseProc) { }; function readFile(path, encoding, callback) { - if (!callback) { + if (!callback || typeof encoding == "function") { callback = encoding; encoding = null; } @@ -28,7 +32,7 @@ return function(vfs, base, baseProc) { var options = {}; if (encoding) options.encoding = encoding; - + vfs.readfile(resolvePath(path), options, function(err, meta) { if (err) return callback(err); @@ -54,7 +58,7 @@ return function(vfs, base, baseProc) { } function writeFile(path, data, encoding, callback) { - if (!callback) { + if (!callback || typeof encoding == "function") { callback = encoding; encoding = null; } From 561c28bb6f8cdd97a6396efa1e046ee4ecc9293a Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 02:10:22 +0000 Subject: [PATCH 50/80] Improve verbose messaging --- plugins/c9.cli.publish/install.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index 131ec69f..6b58a4a9 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -427,9 +427,6 @@ define(function(require, exports, module) { } function installFull(){ - if (verbose) - console.log("Notifying c9.io that packages needs to be installed"); - // Install Locally options.local = true; install(name + "@" + version, options, function(err){ @@ -460,6 +457,9 @@ define(function(require, exports, module) { function installToDatabase(){ if (options.test) return callback(null, { version: "test" }); + + if (verbose) + console.log("Notifying c9.io that packages needs to be installed"); var endpoint = options.global ? api.user : api.project; var url = "install/" + packageName + "/" + version + "?mode=silent"; From 7821268201f70b8aa776558adf631dec6140dffd Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 02:26:35 +0000 Subject: [PATCH 51/80] Fixes standalone --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index cdd2b9a1..ba788baa 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", + "c9.ide.processlist": "#bc11818bb5", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From 50de13f7f7c4e54e3942ef24d126fd8206c1903f Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 02:26:59 +0000 Subject: [PATCH 52/80] Adds processlist as a separate plugin --- configs/client-default.js | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configs/client-default.js b/configs/client-default.js index 0e403b4e..789b64f7 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -515,6 +515,7 @@ module.exports = function(options) { }, "plugins/c9.ide.panels/panel", "plugins/c9.ide.panels/area", + "plugins/c9.ide.processlist/processlist", // Installer { diff --git a/package.json b/package.json index ba788baa..1ea41b78 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", - "c9.ide.processlist": "#bc11818bb5", + "c9.ide.processlist": "#baf23765c1", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From a7b914a97aa743171a0ac5e890870423f7acf16c Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 02:28:44 +0000 Subject: [PATCH 53/80] update sdkconfig --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ea41b78..ba788baa 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", - "c9.ide.processlist": "#baf23765c1", + "c9.ide.processlist": "#bc11818bb5", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From 6f2bca09a40a39ba32e2ddc55f8840995c3014fc Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 02:33:22 +0000 Subject: [PATCH 54/80] Fix css and fix small typo in installer --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba788baa..98e1eb0c 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#63c3c021e3", + "c9.ide.installer": "#f745122dc9", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", @@ -95,7 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", - "c9.ide.processlist": "#bc11818bb5", + "c9.ide.processlist": "#ffb4fc225f", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From 29479a12b9161476f4e663e1ae56f1a95abc22aa Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 02:44:02 +0000 Subject: [PATCH 55/80] Keep selection when datagrid refreshes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98e1eb0c..5cfdd323 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", - "c9.ide.processlist": "#ffb4fc225f", + "c9.ide.processlist": "#9fd4807dd9", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From 58afdf088c2c4bfda58e5faab8063239fc3375de Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 29 Apr 2015 11:32:32 +0200 Subject: [PATCH 56/80] Allow optional parameters to be falsy --- node_modules/frontdoor/lib/route.js | 12 +++-- node_modules/frontdoor/lib/route_test.js | 60 +++++++++++++++++++++++- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/node_modules/frontdoor/lib/route.js b/node_modules/frontdoor/lib/route.js index 0c699ab7..d8276197 100644 --- a/node_modules/frontdoor/lib/route.js +++ b/node_modules/frontdoor/lib/route.js @@ -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,7 +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. */ - function decodeParams(req, res, next) { + var decodeParams = this.decodeParams = function(req, res, next) { var urlParams = req.match; if (!urlParams) return; @@ -197,10 +201,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 +217,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 diff --git a/node_modules/frontdoor/lib/route_test.js b/node_modules/frontdoor/lib/route_test.js index 9e11be1c..d1a1bacd 100644 --- a/node_modules/frontdoor/lib/route_test.js +++ b/node_modules/frontdoor/lib/route_test.js @@ -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(); From 22cc05a80c0e425e62eb8d3d56ef9b3f01615ad9 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 29 Apr 2015 11:37:41 +0200 Subject: [PATCH 57/80] Send Accept header when needed --- plugins/c9.core/http-xhr.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/c9.core/http-xhr.js b/plugins/c9.core/http-xhr.js index aeb2e9d1..9d8eafcd 100644 --- a/plugins/c9.core/http-xhr.js +++ b/plugins/c9.core/http-xhr.js @@ -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); From d6d19ff38eabff74aedfab491411ed165ea5ca9c Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 29 Apr 2015 12:05:28 +0200 Subject: [PATCH 58/80] Fix test --- node_modules/frontdoor/lib/route.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node_modules/frontdoor/lib/route.js b/node_modules/frontdoor/lib/route.js index d8276197..56343a48 100644 --- a/node_modules/frontdoor/lib/route.js +++ b/node_modules/frontdoor/lib/route.js @@ -161,7 +161,8 @@ module.exports = function Route(route, options, handler, types) { * the decoded and validated parameters are stored in `req.params` * otherwhise an error is returned. */ - var decodeParams = this.decodeParams = function(req, res, next) { + this.decodeParams = decodeParams; + function decodeParams(req, res, next) { var urlParams = req.match; if (!urlParams) return; From e4e6774e2c055316de8446db455af0ae9891fe0d Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 12:56:08 +0000 Subject: [PATCH 59/80] Add extra quotes --- plugins/c9.cli.publish/install.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index 6b58a4a9..b1b179db 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -311,8 +311,8 @@ define(function(require, exports, module) { else { proc.execFile("bash", { args: [ - "-c", "cp -a " + join(process.cwd(), "/*") - + " " + packagePath + "-c", "cp -a \"" + join(process.cwd(), "/\"*") + + " \"" + packagePath + "\"" ] }, function(err){ if (err) return callback(err); From c0596d9bda3a548ee16a5da387c2bedcbe78efbf Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 20:18:39 +0000 Subject: [PATCH 60/80] Don't default to the open command --- plugins/c9.cli/cli.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/c9.cli/cli.js b/plugins/c9.cli/cli.js index ab533f32..4a5923fc 100755 --- a/plugins/c9.cli/cli.js +++ b/plugins/c9.cli/cli.js @@ -29,11 +29,6 @@ define(function(require, exports, module) { return false; }); - if (!commands[module] && process.argv.length > 2 && process.argv.every(function(n){ return !n.match(/^--/)})) { - process.argv.splice(2, 0, "open"); - module = "open"; - } - optimist = require('optimist'); if (!module || !commands[module]) { From 900de372334a3d8d6a4479b66cc4e929c764d2a1 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 29 Apr 2015 18:48:58 +0000 Subject: [PATCH 61/80] fix typos --- plugins/c9.cli.publish/publish.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 0a4693b2..f38f7b75 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -312,7 +312,7 @@ define(function(require, exports, module) { // Write the package.json file var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2; var newData = JSON.stringify(json, null, indent); - fs.writeFile(cwd + "/.c9/.build/pacage.json", newData, function(){ + fs.writeFile(cwd + "/.c9/.build/package.json", newData, function(){ if (dryRun) return next(); // if dry-run is passed only update path in .build fs.writeFile(packagePath, newData, function(err){ @@ -446,7 +446,7 @@ define(function(require, exports, module) { extraCode.push({ type: "installer", filename: json.installer, - data: version + data: installerVersion }); } @@ -820,7 +820,7 @@ define(function(require, exports, module) { force = false; }); - /***** Register and definfe API *****/ + /***** Register and define API *****/ /** * From e3c93e9247d9544e189acd6d8b7e039db2f3e245 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 29 Apr 2015 19:26:54 +0000 Subject: [PATCH 62/80] make handling of installer version numbers more consistent --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f6c70c1..3877e02f 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#fd20938443", + "c9.ide.installer": "#5363500a49", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From cc9f039843074b652b8b580513baa2e6ffffbf20 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 29 Apr 2015 20:08:55 +0000 Subject: [PATCH 63/80] include modules required from config in dependency list --- node_modules/architect-build/npm_build.js | 3 ++- server.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/node_modules/architect-build/npm_build.js b/node_modules/architect-build/npm_build.js index 8912b0df..1bc1a643 100644 --- a/node_modules/architect-build/npm_build.js +++ b/node_modules/architect-build/npm_build.js @@ -157,8 +157,9 @@ function build(base, args, cb) { plugin.packagePath_orig = plugin.packagePath; }); }; - server(args, null, function(err, config) { + server(args, null, function(err, config, configPath) { addModule("server.js"); + addModule(configPath); config.forEach(function(plugin) { if (plugin.packagePath) addModule(relPath(plugin.packagePath)); diff --git a/server.js b/server.js index 311897ce..d8b5732f 100755 --- a/server.js +++ b/server.js @@ -120,7 +120,7 @@ function start(configName, options, callback) { } if (argv._getConfig) - return callback && callback(null, config); + return callback && callback(null, config, configPath); var app = architect.createApp(config, function (err, app) { if (err) { From 1f3c5a7a646f2247873409cb90ad3e9e4d9336be Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 00:30:37 +0400 Subject: [PATCH 64/80] use installer version for checking installed state --- configs/cli.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/cli.js b/configs/cli.js index eeb5de2d..9df5c891 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -4,7 +4,7 @@ var EventEmitter = require("events").EventEmitter; EventEmitter.prototype.emit = new Function("type", EventEmitter.prototype.emit.toString() .replace(/return false/g, "return") - .replace(/^.*\n/, "") + .replace(/^[^{]*{/, "") .replace(/\}$/, "")); var PID = process.env.C9_PID || 526; diff --git a/package.json b/package.json index 3877e02f..e6a17ce7 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#5363500a49", + "c9.ide.installer": "#db436137e1", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From a6c14e78985f20de3310b4ea69112928d4565823 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 00:41:54 +0400 Subject: [PATCH 65/80] fix text plugin of amd-loader --- plugins/c9.cli.publish/install.js | 1 - plugins/c9.cli.publish/publish.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index b1b179db..c16de698 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -16,7 +16,6 @@ define(function(require, exports, module) { var installerCLI = imports["installer.cli"]; var TEST_MODE = !!process.env.C9_TEST_MODE; - var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8"); var TAR = "tar"; var APIHOST = options.apiHost; var BASICAUTH = process.env.C9_TEST_AUTH; diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index f38f7b75..8bb04348 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -11,7 +11,7 @@ define(function(require, exports, module) { var api = imports.api; var TEST_MODE = !!process.env.C9_TEST_MODE; - var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh").toString("utf8"); + var SHELLSCRIPT = TEST_MODE ? "" : require("text!./publish.git.sh"); var TAR = "tar"; var APIHOST = options.apiHost; var BASICAUTH = process.env.C9_TEST_AUTH; From f8ec16f93538fcf81ea59a22dad2edf1393e1537 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 00:48:06 +0400 Subject: [PATCH 66/80] update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e6a17ce7..2aef02ab 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "acorn": ">=0.11.0", - "amd-loader": "~0.0.5", + "amd-loader": "", "async": "^0.9.0", "base64id": "~0.1.0", "c9": "", @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#db436137e1", + "c9.ide.installer": "#8c5c8701e5", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 133f1dea2030eae0dd16ee42a9c35a043e4df2c1 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 20:57:36 +0000 Subject: [PATCH 67/80] Fix installer button issue --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5cfdd323..569327fa 100644 --- a/package.json +++ b/package.json @@ -77,13 +77,13 @@ "c9.ide.behaviors": "#6aad7006a0", "c9.ide.closeconfirmation": "#a28bfd8272", "c9.ide.configuration": "#adf50fdaa2", - "c9.ide.dialog.wizard": "#5df4f14bb8", + "c9.ide.dialog.wizard": "#7667ec79a8", "c9.ide.fontawesome": "#781602c5d8", "c9.ide.format": "#f51451ac57", "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#f745122dc9", + "c9.ide.installer": "#0b915c68e9", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 9f4c1b98e1c8024bbb532088eff491e9b98ef3c6 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 01:41:33 +0400 Subject: [PATCH 68/80] use cp instead of bash spawn cp --- plugins/c9.cli.publish/install.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index c16de698..ae1b1012 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -308,11 +308,8 @@ define(function(require, exports, module) { if (process.cwd() == packagePath) installNPM(); else { - proc.execFile("bash", { - args: [ - "-c", "cp -a \"" + join(process.cwd(), "/\"*") - + " \"" + packagePath + "\"" - ] + proc.execFile("cp", { + args: ["-R", process.cwd(), dirname(packagePath)] }, function(err){ if (err) return callback(err); From 50d68e78f1ad471861be2e8b001ccd5236be0412 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 01:44:23 +0400 Subject: [PATCH 69/80] do not use pty.js in cli mode --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2aef02ab..9a66ff8c 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#8c5c8701e5", + "c9.ide.installer": "#7993ca3181", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From 9264039711c43c3af766dfb9856f2de1f0baaf97 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 22:06:32 +0000 Subject: [PATCH 70/80] Small fixes and typos --- package.json | 2 +- plugins/c9.cli.publish/install.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a66ff8c..06ac5112 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#7993ca3181", + "c9.ide.installer": "#a69136d696", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", diff --git a/plugins/c9.cli.publish/install.js b/plugins/c9.cli.publish/install.js index ae1b1012..b1643e22 100644 --- a/plugins/c9.cli.publish/install.js +++ b/plugins/c9.cli.publish/install.js @@ -15,6 +15,8 @@ define(function(require, exports, module) { var installer = imports.installer; var installerCLI = imports["installer.cli"]; + var dirname = require("path").dirname; + var TEST_MODE = !!process.env.C9_TEST_MODE; var TAR = "tar"; var APIHOST = options.apiHost; From e704f45e66b162ebad3344f577bd2e0e9866e1bf Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 29 Apr 2015 22:07:05 +0000 Subject: [PATCH 71/80] cleanup --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 06ac5112..e2bcf6c2 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#a69136d696", + "c9.ide.installer": "#86392483b6", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From a400a735ec2ca87bace8d23f71d05b74ed0af561 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 03:08:24 +0400 Subject: [PATCH 72/80] properly pass cwd to cli installer process --- configs/cli.js | 11 ++++++----- package.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/configs/cli.js b/configs/cli.js index 9df5c891..8d95eff0 100644 --- a/configs/cli.js +++ b/configs/cli.js @@ -1,11 +1,12 @@ module.exports = function(options) { +// workaround for api difference between node and c9 events modules var EventEmitter = require("events").EventEmitter; -EventEmitter.prototype.emit = new Function("type", - EventEmitter.prototype.emit.toString() - .replace(/return false/g, "return") - .replace(/^[^{]*{/, "") - .replace(/\}$/, "")); +var emit_ = EventEmitter.prototype.emit +EventEmitter.prototype.emit = function() { + emit_.apply(this, arguments); + return true; +} var PID = process.env.C9_PID || 526; var APIHOST = process.env.C9_APIHOST || "api.c9.io"; // "api.c9.io"; diff --git a/package.json b/package.json index ed158aa2..629e7b76 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "c9.ide.help.support": "#60e88f5680", "c9.ide.imgeditor": "#08bbc53578", "c9.ide.immediate": "#6845a93705", - "c9.ide.installer": "#80d050b6de", + "c9.ide.installer": "#a1e01c07a3", "c9.ide.mount": "#32e79866ee", "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", From f9568d84253ef007c08f638eea25cd9c57e4450d Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 03:36:30 +0400 Subject: [PATCH 73/80] suppress pty.js warning --- plugins/c9.vfs.client/vfs.cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.vfs.client/vfs.cli.js b/plugins/c9.vfs.client/vfs.cli.js index 92d339e8..915200fe 100644 --- a/plugins/c9.vfs.client/vfs.cli.js +++ b/plugins/c9.vfs.client/vfs.cli.js @@ -9,7 +9,7 @@ define(function(require, module, exports) { var vfs = new localFs({ root: "/", - // nopty: true, + nopty: true, defaultEnv: { CUSTOM: 43 } }); From 414f4ea54d61cc79915cc0c0136b91f49a32d571 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 03:52:47 +0400 Subject: [PATCH 74/80] add readme for processlist plugin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 629e7b76..354ffdc5 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "c9.ide.readonly": "#f6f07bbe42", "c9.ide.recentfiles": "#7c099abf40", "c9.ide.remote": "#cd45e81d2f", - "c9.ide.processlist": "#9fd4807dd9", + "c9.ide.processlist": "#bc11818bb5", "c9.ide.run": "#71c5562e42", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#b91d23f48b", From 9843b85fa8e2f57f66ea84cbb6b7d8a9775019db Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 03:54:04 +0400 Subject: [PATCH 75/80] fix +7009 Selection is invisible when using Classic light gray and Cloud9 night --- plugins/c9.ide.layout.classic/themes/default-dark-gray.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.layout.classic/themes/default-dark-gray.less b/plugins/c9.ide.layout.classic/themes/default-dark-gray.less index 6c792f2a..b3ad5668 100644 --- a/plugins/c9.ide.layout.classic/themes/default-dark-gray.less +++ b/plugins/c9.ide.layout.classic/themes/default-dark-gray.less @@ -52,7 +52,7 @@ @ace-cloud9-day-background: lighten(#F8F8F8, @lighten-chrome); @ace-cloud9-night-gutter: @panel-background; @ace-cloud9-night-background: lighten(#181818, @lighten-chrome); -@ace-cloud9-night-active-line: lighten(#292929, @lighten-chrome); +@ace-cloud9-night-active-line: rgba(68, 68, 68, 0.78); // todo make selection lighter #5A5A5A too? @ace-gutter-font-smoothing: true; @ace-gutter-shadow: 1px 0 rgba(255, 255, 255, 0.75) inset; From b4c643c9ab65fa858b07feea140d96ccc2006c16 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 03:55:19 +0400 Subject: [PATCH 76/80] fix toggle comments in handlebars mode --- node_modules/ace/lib/ace/mode/handlebars.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node_modules/ace/lib/ace/mode/handlebars.js b/node_modules/ace/lib/ace/mode/handlebars.js index 3f2e7179..164ad43f 100644 --- a/node_modules/ace/lib/ace/mode/handlebars.js +++ b/node_modules/ace/lib/ace/mode/handlebars.js @@ -13,7 +13,6 @@ var Mode = function() { HtmlMode.call(this); this.HighlightRules = HandlebarsHighlightRules; this.$behaviour = new HtmlBehaviour(); - this.foldingRules = new HtmlFoldMode(); }; @@ -21,7 +20,7 @@ var Mode = function() { oop.inherits(Mode, HtmlMode); (function() { - this.blockComment = {start: "{!--", end: "--}"}; + this.blockComment = {start: "{{!--", end: "--}}"}; this.$id = "ace/mode/handlebars"; }).call(Mode.prototype); From 499c8976b9397ae605d583ac55e27107582b5165 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 04:10:09 +0400 Subject: [PATCH 77/80] better invisible tabs --- node_modules/ace/lib/ace/layer/text.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/node_modules/ace/lib/ace/layer/text.js b/node_modules/ace/lib/ace/layer/text.js index ced2c5f1..1e80b684 100644 --- a/node_modules/ace/lib/ace/layer/text.js +++ b/node_modules/ace/lib/ace/layer/text.js @@ -52,7 +52,7 @@ var Text = function(parentEl) { this.EOL_CHAR_LF = "\xAC"; this.EOL_CHAR_CRLF = "\xa4"; this.EOL_CHAR = this.EOL_CHAR_LF; - this.TAB_CHAR = "\u2192"; //"\u21E5"; + this.TAB_CHAR = "\u2014"; //"\u21E5"; this.SPACE_CHAR = "\xB7"; this.$padding = 0; @@ -128,8 +128,7 @@ var Text = function(parentEl) { for (var i = 1; i < tabSize + 1; i++) { if (this.showInvisibles) { tabStr.push("" - + this.TAB_CHAR - + lang.stringRepeat(" ", i - 1) + + lang.stringRepeat(this.TAB_CHAR, i) + ""); } else { tabStr.push(lang.stringRepeat(" ", i)); @@ -145,7 +144,7 @@ var Text = function(parentEl) { spaceClass = " ace_invisible_space"; tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); - var tabContent = this.TAB_CHAR + lang.stringRepeat(" ", this.tabSize - 1); + var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); } else{ var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; From 9bc6190ad051cc6e0b1933601d599c2ce367a8da Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 30 Apr 2015 04:14:01 +0400 Subject: [PATCH 78/80] fix color of bracket highlight in katzenmilch theme --- node_modules/ace/lib/ace/theme/katzenmilch.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_modules/ace/lib/ace/theme/katzenmilch.css b/node_modules/ace/lib/ace/theme/katzenmilch.css index 0b5a7a23..a4559a2a 100644 --- a/node_modules/ace/lib/ace/theme/katzenmilch.css +++ b/node_modules/ace/lib/ace/theme/katzenmilch.css @@ -40,7 +40,7 @@ .ace-katzenmilch .ace_marker-layer .ace_bracket { margin: -1px 0 0 -1px; - border: 1px solid #000000 + border: 1px solid rgba(0, 0, 0, 0.33); } .ace-katzenmilch .ace_marker-layer .ace_active-line { From dc8486a2dad9d1ff546796e2ba551dd409d58359 Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Thu, 30 Apr 2015 08:14:36 +0000 Subject: [PATCH 79/80] Typo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 354ffdc5..1572b3d3 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "c9.ide.find": "#6cc6d3379d", "c9.ide.find.infiles": "#72582de3cd", "c9.ide.find.replace": "#e4daf722b8", - "c9.ide.run.debug": "#638e6b00b3", + "c9.ide.run.debug": "#06a7bd9615", "c9.automate": "#47e2c429c9", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", From 2fd7a8b619298d1c3d86e97e214972134a9ebe1c Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 25 Mar 2015 17:38:30 +0400 Subject: [PATCH 80/80] include collab in main vfs build --- node_modules/vfs-local/localfs.js | 8 +++- package.json | 2 +- plugins/c9.vfs.extend/collab-server.js | 45 +---------------------- plugins/c9.vfs.extend/diff_match_patch.js | 40 ++++++++++++++++++++ plugins/c9.vfs.server/vfs_wrapper.js | 3 ++ 5 files changed, 53 insertions(+), 45 deletions(-) create mode 100644 plugins/c9.vfs.extend/diff_match_patch.js diff --git a/node_modules/vfs-local/localfs.js b/node_modules/vfs-local/localfs.js index 2ecf079e..d43c1756 100644 --- a/node_modules/vfs-local/localfs.js +++ b/node_modules/vfs-local/localfs.js @@ -2409,7 +2409,13 @@ module.exports = function setup(fsOptions) { } //////////////////////////////////////////////////////////////////////////////// - + + if (fsOptions.extendApi) { + for (var i in fsOptions.extendApi) { + extend(i, fsOptions.extendApi[i], function() {}); + } + } + return vfs; }; diff --git a/package.json b/package.json index 1572b3d3..9f47d5d3 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "c9.ide.language.javascript.tern": "#7aab8b0b6a", "c9.ide.language.javascript.infer": "#cfec494a3c", "c9.ide.language.jsonalyzer": "#21b64e5820", - "c9.ide.collab": "#504750d8f0", + "c9.ide.collab": "#edef363853", "c9.ide.local": "#2bfd7ff051", "c9.ide.find": "#6cc6d3379d", "c9.ide.find.infiles": "#72582de3cd", diff --git a/plugins/c9.vfs.extend/collab-server.js b/plugins/c9.vfs.extend/collab-server.js index 8e77d0fe..89ac7283 100644 --- a/plugins/c9.vfs.extend/collab-server.js +++ b/plugins/c9.vfs.extend/collab-server.js @@ -1,7 +1,4 @@ -// Uglify -// uglifyjs -c -m -o collab-server.js plugins/c9.vfs.extend/collab-server.js -// Deploy to shared space: -// scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -i c9/node_modules/settings/keys/deploy collab-server.js 52ee501f50044657c4000005@project-livec99d49a9ef92.rhcloud.com:/var/lib/openshift/52ee501f50044657c4000005/app-root/data/759814/root/c9-vfs-extend/collab-server.js + "use strict"; var Fs = require("fs"); var Path = require("path"); @@ -2763,48 +2760,10 @@ var exports = module.exports = function(vfs, options, register) { exports.Store = Store; exports.compressDocument = compressDocument; -/* Google diff match patch library: https://code.google.com/p/google-diff-match-patch/ */ - var DIFF_EQUAL = 0; var DIFF_INSERT = 1; var DIFF_DELETE = -1; -function diff_match_patch(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=0.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=32} -diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[[0,a]]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b),c=a.substring(0,f),a=a.substring(f),b=b.substring(f),f=this.diff_commonSuffix(a,b),g=a.substring(a.length-f),a=a.substring(0,a.length-f),b=b.substring(0,b.length-f),a=this.diff_compute_(a,b,e,d);c&&a.unshift([0,c]);g&&a.push([0,g]);this.diff_cleanupMerge(a);return a}; -diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[[1,b]];if(!b)return[[-1,a]];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);if(-1!=g)return c=[[1,e.substring(0,g)],[0,f],[1,e.substring(g+f.length)]],a.length>b.length&&(c[0][0]=c[2][0]=-1),c;if(1==f.length)return[[-1,a],[1,b]];return(e=this.diff_halfMatch_(a,b))?(f=e[0],a=e[1],g=e[2],b=e[3],e=e[4],f=this.diff_main(f,g,c,d),c=this.diff_main(a,b,c,d),f.concat([[0,e]],c)):c&&100c);u++){for(var n=-u+q;n<=u-s;n+=2){var l=g+n,m;m=n==-u||n!=u&&j[l-1]d)s+=2;else if(r>e)q+=2;else if(p&&(l=g+k-n,0<=l&&l=t)return this.diff_bisectSplit_(a,b,m,r,c)}}for(n=-u+o;n<=u-v;n+=2){l=g+n;t=n==-u||n!=u&&i[l-1]d)v+=2;else if(m>e)o+=2;else if(!p&&(l=g+k-n,0<=l&&l=t)))return this.diff_bisectSplit_(a,b,m,r,c)}}return[[-1,a],[1,b]]}; -diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d),a=a.substring(c),b=b.substring(d),f=this.diff_main(f,g,!1,e),e=this.diff_main(a,b,!1,e);return f.concat(e)}; -diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,f=-1,g=d.length;fd?a=a.substring(c-d):c=a.length?[h,j,n,l,g]:null}if(0>=this.Diff_Timeout)return null;var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.lengthd[4].length?g:d:d:g;var j;a.length>b.length?(g=h[0],d=h[1],e=h[2],j=h[3]):(e=h[0],j=h[1],g=h[2],d=h[3]);h=h[4];return[g,d,e,j,h]}; -diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,j=0,i=0;f=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,[0,c.substring(0,d)]),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,[0,b.substring(0,e)]),a[f-1][0]=1,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=-1,a[f+1][1]=b.substring(e),f++;f++}f++}}; -diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_),c=g&&c.match(diff_match_patch.linebreakRegex_),d=h&&d.match(diff_match_patch.linebreakRegex_),i=c&&a.match(diff_match_patch.blanklineEndRegex_),j=d&&b.match(diff_match_patch.blanklineStartRegex_);return i||j?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c=i&&(i=k,g=d,h=e,j=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-1,1),c--),a[c][1]=h,j?a[c+1][1]=j:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/; -diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,j=!1,i=!1;fb)break;e=c;f=d}return a.length!=g&&-1===a[g][0]?f:f+(b-e)}; -diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=//g,f=/\n/g,g=0;g");switch(h){case 1:b[g]=''+j+"";break;case -1:b[g]=''+j+"";break;case 0:b[g]=""+j+""}}return b.join("")}; -diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;cthis.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));for(var j=1<=i;o--){var v=e[a.charAt(o-1)];k[o]=0===s?(k[o+1]<<1|1)&v:(k[o+1]<<1|1)&v|(q[o+1]|q[o])<<1|1|q[o+1];if(k[o]&j&&(v=d(s,o-1),v<=g))if(g=v,h=o-1,h>c)i=Math.max(1,2*c-h);else break}if(d(s+1,c)>g)break;q=k}return h}; -diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c=2*this.Patch_Margin&&e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}1!==i&&(f+=k.length);-1!==i&&(g+=k.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c}; -diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;cthis.Match_MaxBits){if(j=this.match_main(b,h.substring(0,this.Match_MaxBits),g),-1!=j&&(i=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==i||j>=i))j=-1}else j=this.match_main(b,h,g);if(-1==j)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=j-g,g=-1==i?b.substring(j,j+h.length):b.substring(j,i+this.Match_MaxBits),h==g)b=b.substring(0,j)+this.diff_text2(a[f].diffs)+b.substring(j+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);for(var h=0,k,i=0;ie[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;0==e.length||0!=e[e.length-1][0]?(e.push([0,c]),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c}; -diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c2*b?(h.length1+=i.length,e+=i.length,j=!1,h.diffs.push([g,i]),d.diffs.shift()):(i=i.substring(0,b-h.length1-this.Patch_Margin),h.length1+=i.length,e+=i.length,0===g?(h.length2+=i.length,f+=i.length):j=!1,h.diffs.push([g,i]),i==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(i.length))}g=this.diff_text2(h.diffs);g=g.substring(g.length-this.Patch_Margin);i=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==i&&(h.length1+=i.length,h.length2+=i.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=i:h.diffs.push([0,i]));j||a.splice(++c,0,h)}}}; -diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;c=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[[0,a]]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b),c=a.substring(0,f),a=a.substring(f),b=b.substring(f),f=this.diff_commonSuffix(a,b),g=a.substring(a.length-f),a=a.substring(0,a.length-f),b=b.substring(0,b.length-f),a=this.diff_compute_(a,b,e,d);c&&a.unshift([0,c]);g&&a.push([0,g]);this.diff_cleanupMerge(a);return a}; +diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[[1,b]];if(!b)return[[-1,a]];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);if(-1!=g)return c=[[1,e.substring(0,g)],[0,f],[1,e.substring(g+f.length)]],a.length>b.length&&(c[0][0]=c[2][0]=-1),c;if(1==f.length)return[[-1,a],[1,b]];return(e=this.diff_halfMatch_(a,b))?(f=e[0],a=e[1],g=e[2],b=e[3],e=e[4],f=this.diff_main(f,g,c,d),c=this.diff_main(a,b,c,d),f.concat([[0,e]],c)):c&&100c);u++){for(var n=-u+q;n<=u-s;n+=2){var l=g+n,m;m=n==-u||n!=u&&j[l-1]d)s+=2;else if(r>e)q+=2;else if(p&&(l=g+k-n,0<=l&&l=t)return this.diff_bisectSplit_(a,b,m,r,c)}}for(n=-u+o;n<=u-v;n+=2){l=g+n;t=n==-u||n!=u&&i[l-1]d)v+=2;else if(m>e)o+=2;else if(!p&&(l=g+k-n,0<=l&&l=t)))return this.diff_bisectSplit_(a,b,m,r,c)}}return[[-1,a],[1,b]]}; +diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d),a=a.substring(c),b=b.substring(d),f=this.diff_main(f,g,!1,e),e=this.diff_main(a,b,!1,e);return f.concat(e)}; +diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,f=-1,g=d.length;fd?a=a.substring(c-d):c=a.length?[h,j,n,l,g]:null}if(0>=this.Diff_Timeout)return null;var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.lengthd[4].length?g:d:d:g;var j;a.length>b.length?(g=h[0],d=h[1],e=h[2],j=h[3]):(e=h[0],j=h[1],g=h[2],d=h[3]);h=h[4];return[g,d,e,j,h]}; +diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,j=0,i=0;f=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,[0,c.substring(0,d)]),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,[0,b.substring(0,e)]),a[f-1][0]=1,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=-1,a[f+1][1]=b.substring(e),f++;f++}f++}}; +diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_),c=g&&c.match(diff_match_patch.linebreakRegex_),d=h&&d.match(diff_match_patch.linebreakRegex_),i=c&&a.match(diff_match_patch.blanklineEndRegex_),j=d&&b.match(diff_match_patch.blanklineStartRegex_);return i||j?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c=i&&(i=k,g=d,h=e,j=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-1,1),c--),a[c][1]=h,j?a[c+1][1]=j:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/; +diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,j=!1,i=!1;fb)break;e=c;f=d}return a.length!=g&&-1===a[g][0]?f:f+(b-e)}; +diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=//g,f=/\n/g,g=0;g");switch(h){case 1:b[g]=''+j+"";break;case -1:b[g]=''+j+"";break;case 0:b[g]=""+j+""}}return b.join("")}; +diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;cthis.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));for(var j=1<=i;o--){var v=e[a.charAt(o-1)];k[o]=0===s?(k[o+1]<<1|1)&v:(k[o+1]<<1|1)&v|(q[o+1]|q[o])<<1|1|q[o+1];if(k[o]&j&&(v=d(s,o-1),v<=g))if(g=v,h=o-1,h>c)i=Math.max(1,2*c-h);else break}if(d(s+1,c)>g)break;q=k}return h}; +diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c=2*this.Patch_Margin&&e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}1!==i&&(f+=k.length);-1!==i&&(g+=k.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c}; +diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;cthis.Match_MaxBits){if(j=this.match_main(b,h.substring(0,this.Match_MaxBits),g),-1!=j&&(i=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==i||j>=i))j=-1}else j=this.match_main(b,h,g);if(-1==j)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=j-g,g=-1==i?b.substring(j,j+h.length):b.substring(j,i+this.Match_MaxBits),h==g)b=b.substring(0,j)+this.diff_text2(a[f].diffs)+b.substring(j+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);for(var h=0,k,i=0;ie[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;0==e.length||0!=e[e.length-1][0]?(e.push([0,c]),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c}; +diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c2*b?(h.length1+=i.length,e+=i.length,j=!1,h.diffs.push([g,i]),d.diffs.shift()):(i=i.substring(0,b-h.length1-this.Patch_Margin),h.length1+=i.length,e+=i.length,0===g?(h.length2+=i.length,f+=i.length):j=!1,h.diffs.push([g,i]),i==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(i.length))}g=this.diff_text2(h.diffs);g=g.substring(g.length-this.Patch_Margin);i=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==i&&(h.length1+=i.length,h.length2+=i.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=i:h.diffs.push([0,i]));j||a.splice(++c,0,h)}}}; +diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;c