From bb0d5cd7de76c1184510b775bb8aecaeb8cfb3a1 Mon Sep 17 00:00:00 2001 From: Alex Brausewetter Date: Fri, 24 Apr 2015 15:11:44 +0000 Subject: [PATCH 01/11] 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 b2a34a77a0f24953f9400b8b1e30efe0072ffe04 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 24 Apr 2015 18:43:49 +0000 Subject: [PATCH 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 35175d40cacdfc6cdccfdabcbd3c1107f095484e Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 21:27:25 +0400 Subject: [PATCH 11/11] 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"],