From 9ffaaf9367c2141e28f9b29f590fb78b10136892 Mon Sep 17 00:00:00 2001 From: "Lennart C. L. Kats" Date: Thu, 21 Apr 2016 15:05:40 +0200 Subject: [PATCH 1/5] Revert "Fix "make static" for outplan" --- node_modules/architect-build/module-deps.js | 15 ++++------- plugins/c9.static/build_test.js | 28 +++------------------ 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/node_modules/architect-build/module-deps.js b/node_modules/architect-build/module-deps.js index c9a592c6..77718e8d 100644 --- a/node_modules/architect-build/module-deps.js +++ b/node_modules/architect-build/module-deps.js @@ -113,7 +113,6 @@ module.exports = function(mains, opts) { } function setModuleSource(mod, src, cb) { - src = src.replace(/\r\n/g, "\n"); // normalize windows newlines if (cache) cache.files[mod.file] = src; mod.source = src; @@ -346,14 +345,13 @@ function removeUseStrict(module) { module.source = module.source.replace(/['"]use strict['"];/g, ""); } -var commentRe = /^(;)?(?:\s*(?:\/\/.+\n|\/\*(?:[^*]|\*(?!\/))*\*\/))+(?: *\n)?/gm; function removeLicenceComments(module) { if (/\.(js|jsx|css|less)/.test(module.path)) - module.source = module.source.replace(commentRe, "$1"); + module.source = module.source.replace(/(?:(;)|\n|^)\s*\/\*[\d\D]*?\*\/|(\n|^)\s*\/\/.*/g, "$1"); } function removeLicenceCommentsKeepLines(module) { if (/\.(js|jsx|css|less)/.test(module.path)) { - module.source = module.source.replace(commentRe, function(cm, start) { + module.source = module.source.replace(/(?:(;)|\n|^)\s*\/\*[\d\D]*?\*\/|\n\s*\/\/.*/g, function(cm, start) { return (start||"") + cm.replace(/.+/g, ""); }); } @@ -393,8 +391,8 @@ function wrapUMD(module) { + ' $build_deps$.module.define(name, [], function() { return $build_deps$.module.exports });\n' + ' }\n' + '}\n' - + 'define.amd = true;\n' - + module.source + '\n' + + 'define.amd = true;' + + module.source + '});'; } @@ -412,7 +410,4 @@ function quote(str) { } -module.exports.getSubmodules = getSubmodules; -module.exports.resolveModulePath = resolveModulePath; -module.exports.removeLicenceComments = removeLicenceComments; -module.exports.removeLicenceCommentsKeepLines = removeLicenceCommentsKeepLines; \ No newline at end of file +module.exports.resolveModulePath = resolveModulePath; \ No newline at end of file diff --git a/plugins/c9.static/build_test.js b/plugins/c9.static/build_test.js index 7dd15bed..73c7e33f 100755 --- a/plugins/c9.static/build_test.js +++ b/plugins/c9.static/build_test.js @@ -17,7 +17,7 @@ require("amd-loader"); var build, options, pathConfig; -describe("The build module", function(){ +describe("The Module", function(){ this.timeout(60000); beforeEach(function(next) { @@ -63,7 +63,7 @@ describe("The build module", function(){ }); }); - it("should compile less", function(done) { + it("test compile less", function(done) { build.buildSkin("ssh", "dark", pathConfig, function(err, result) { if (err) return done(err); @@ -71,28 +71,6 @@ describe("The build module", function(){ assert(code); done(err); }); - }); - - it("should remove comments", function(done) { - var removeLicenceComments = require("architect-build/module-deps").removeLicenceComments; - function remove(src) { - var module = { source: "" + src, path: ".js" }; - removeLicenceComments(module); - return module.source; - } - assert.equal(remove("" + function() { - // 1 - var a; - /***/ // hello - var x; // not removed - /* asd - */ - x += "he/*ll*/o" + a; - }) , function() { - var a; - var x; // not removed - x += "he/*ll*/o" + a; - }); - done(); + }); }); \ No newline at end of file From 28eeabc98cd07d234f4120422806188ef7b16152 Mon Sep 17 00:00:00 2001 From: c9bot Date: Thu, 21 Apr 2016 15:06:11 +0200 Subject: [PATCH 2/5] c9-auto-bump 3.1.2305 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dbaf4265..29ac5a8c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "c9", "description": "New Cloud9 Client", - "version": "3.1.2304", + "version": "3.1.2305", "author": "Ajax.org B.V. ", "private": true, "main": "bin/c9", From 915e5eea884cc9ffd4de66cbc9664e6bb387cdd6 Mon Sep 17 00:00:00 2001 From: "Lennart C. L. Kats" Date: Thu, 21 Apr 2016 15:06:52 +0200 Subject: [PATCH 3/5] Revert "A/B testing" --- configs/client-default.js | 1 - configs/standalone.js | 2 + package.json | 2 +- plugins/c9.abtesting/abtesting.js | 86 --------------- plugins/c9.ide.abtesting/abtesting.js | 105 ------------------- plugins/c9.ide.experiment/mock_experiment.js | 26 +++++ plugins/c9.ide.server/plugins.js | 2 - 7 files changed, 29 insertions(+), 195 deletions(-) delete mode 100644 plugins/c9.abtesting/abtesting.js delete mode 100644 plugins/c9.ide.abtesting/abtesting.js create mode 100644 plugins/c9.ide.experiment/mock_experiment.js diff --git a/configs/client-default.js b/configs/client-default.js index c0859368..50593d86 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -709,7 +709,6 @@ module.exports = function(options) { premium: options.project.premium, } }, - "plugins/c9.ide.abtesting/abtesting", { packagePath: "plugins/c9.ide.welcome/welcome", staticPrefix: staticPrefix + "/plugins/c9.ide.welcome", diff --git a/configs/standalone.js b/configs/standalone.js index 44c95a36..bb6f596e 100644 --- a/configs/standalone.js +++ b/configs/standalone.js @@ -158,6 +158,7 @@ module.exports = function(config, optimist) { "c9.vfs.client": true, "c9.cli.bridge": true, "c9.nodeapi": true, + "c9.ide.experiment": true, "saucelabs.preview": true, "salesforce.sync": true, "salesforce.language": true @@ -193,6 +194,7 @@ module.exports = function(config, optimist) { "./c9.vfs.server/statics", "./c9.analytics/mock_analytics", "./c9.metrics/mock_metrics", + "./c9.ide.experiment/mock_experiment", { packagePath: "./c9.vfs.server/vfs.connect.standalone", workspaceDir: baseProc, diff --git a/package.json b/package.json index 29ac5a8c..9613ac17 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "c9.ide.language.javascript.infer": "#18acb93a3a", "c9.ide.language.jsonalyzer": "#4b329741b1", "c9.ide.language.codeintel": "#253ae15f5e", - "c9.ide.collab": "#28129e17ae", + "c9.ide.collab": "#9c8fec5d78", "c9.ide.local": "#10eb45842a", "c9.ide.find": "#e33fbaed2f", "c9.ide.find.infiles": "#c0a13737ef", diff --git a/plugins/c9.abtesting/abtesting.js b/plugins/c9.abtesting/abtesting.js deleted file mode 100644 index 44fc2b00..00000000 --- a/plugins/c9.abtesting/abtesting.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Server-side support for A/B testing experiments. - * - * Note that this plugin demands users and user IDs for most of its API, - * where this is optional in the client-side implementation. - */ -main.consumes = ["analytics"]; -main.provides = ["abtesting"]; -module.exports = main; - -function main(options, imports, register) { - var analytics = imports["analytics"]; - var outplan = require("outplan"); - - var MS_PER_DAY = 1000 * 60 * 60 * 24; - - outplan.configure({ - logFunction: function(e) { - var label = e.name + " - " + e.event; - analytics.track(label, { variation: e.params.name }); - } - }); - - function create(name, choices, options) { - return outplan.create(name, choices, options); - } - - function expose(experimentName, userId, options) { - return outplan.expose(experimentName, userId, options); - } - - function isUserCreatedAfter(experimentDate, user) { - if (!user || !user.date_add) - throw new Error("Expected: user"); - var diffDays = (experimentDate - Date.now()) / MS_PER_DAY; - if (diffDays > 20) { - // Sanity check: new Date() takes zero-based month argument, one-based day argument - throw new Error("Passed a date far in the future to isUserCreatedAfter()"); - } - return user.date_add > experimentDate; - } - - register(null, { - "abtesting": { - /** - * Create a new experiment. Alias for require("outplan").create() - * - * @param {String} name - * The name of the experiment. - * @param {String[]|Object[]} choices - * A list of variations, e.g. ["A", "B"], - * or variation objects, e.g. [{ name: "A", color: "#AAA" }, { name: "B", color: "#BBB" }] - * @param {Object} [option] - * Options for the experiment. This may also include - * arguments for the distribution operator, e.g. weight. - * @param {Function} [options.operator] - * The distribution operator, e.g. outplan.WeightedChoice. - */ - create: create, - - /** - * Get the selected variation of an experiment, and call the log function with - * an "expose" event to track its exposure. - * - * @param {String} name The experiment name. - * @param {Number} userId A unique identifier for the current user. - * @param {Object} [options] Options - * @param {Boolean} [options.log=true] Whether to log an "exposure event" - */ - expose: expose, - - /** - * Helper to determine if the current user was created after the start of an experiment. - * - * @throws {Error} when a date in the future (~20 days from now) is passed. - * This error is thrown as a sanity check to make sure `new Date()` - * is called with a zero-based month argument (and a one-based day). - * - * @param {Date} experimentDate - * @param {Object} user A user object - * @param {Number} user.date_add - */ - isUserCreatedAfter: isUserCreatedAfter, - } - }); -} diff --git a/plugins/c9.ide.abtesting/abtesting.js b/plugins/c9.ide.abtesting/abtesting.js deleted file mode 100644 index 1a7160db..00000000 --- a/plugins/c9.ide.abtesting/abtesting.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Client-side support for A/B testing experiments. - */ -define(function(require, exports, module) { - "use strict"; - - main.consumes = ["Plugin", "info", "c9.analytics"]; - main.provides = ["abtesting"]; - return main; - - function main(options, imports, register) { - var Plugin = imports.Plugin; - var plugin = new Plugin("Ajax.org", main.consumes); - var info = imports.info; - var analytics = imports["c9.analytics"]; - var outplan = require("outplan"); - - var MS_PER_DAY = 1000 * 60 * 60 * 24; - - var userId; - - plugin.on("load", function() { - userId = info.getUser().id; - outplan.configure({ - logFunction: function(e) { - var label = e.name + " - " + e.event; - analytics.track(label, { variation: e.params.name }); - } - }); - }); - - plugin.on("unload", function() { - userId = undefined; - }); - - function create(name, choices, options) { - var experiment = outplan.create(name, choices, options); - experiment.expose = expose.bind(null, name); - return experiment; - } - - function expose(experimentName, overrideUserId, options) { - if (overrideUserId && typeof overrideUserId === "object") - return expose(experimentName, null, options); - - return outplan.expose(experimentName, overrideUserId == null ? userId : overrideUserId, options); - } - - function isUserCreatedAfter(experimentDate) { - var diffDays = (experimentDate - Date.now()) / MS_PER_DAY; - if (diffDays > 20) { - // Sanity check: new Date() takes zero-based month argument, one-based day argument - throw new Error("Passed a date far in the future to isUserCreatedAfter()"); - } - return info.getUser().date_add > experimentDate; - } - - /** - * Support for A/B testing experiments. - */ - plugin.freezePublicAPI({ - /** - * Create a new experiment. Alias for require("outplan").create() - * - * @param {String} name - * The name of the experiment. - * @param {String[]|Object[]} choices - * A list of variations, e.g. ["A", "B"], - * or variation objects, e.g. [{ name: "A", color: "#AAA" }, { name: "B", color: "#BBB" }] - * @param {Object} [option] - * Options for the experiment. This may also include - * arguments for the distribution operator, e.g. weight. - * @param {Function} [options.operator] - * The distribution operator, e.g. outplan.WeightedChoice. - */ - create: create, - - /** - * Get the selected variation of an experiment, and call the log function with - * an "expose" event to track its exposure. - * - * @param {String} name The experiment name. - * @param {Number} [userId] A unique identifier for the current user. - * @param {Object} [options] Options - * @param {Boolean} [options.log=true] Whether to log an "exposure event" - */ - expose: expose, - - /** - * Helper to determine if the current user was created after the start of an experiment. - * - * @throws {Error} when a date in the future (~20 days from now) is passed. - * This error is thrown as a sanity check to make sure `new Date()` - * is called with a zero-based month argument (and a one-based day). - * - * @param {Date} experimentDate - */ - isUserCreatedAfter: isUserCreatedAfter, - }); - - register(null, { - "abtesting": plugin - }); - } -}); diff --git a/plugins/c9.ide.experiment/mock_experiment.js b/plugins/c9.ide.experiment/mock_experiment.js new file mode 100644 index 00000000..e3b80734 --- /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": { + configure: function() {}, + onStart: function() { + var chain = { + variation: function() { + return chain; + } + }; + return chain; + } + } + }); +} \ No newline at end of file diff --git a/plugins/c9.ide.server/plugins.js b/plugins/c9.ide.server/plugins.js index d8ef4ca4..64c2fe89 100644 --- a/plugins/c9.ide.server/plugins.js +++ b/plugins/c9.ide.server/plugins.js @@ -41,7 +41,6 @@ define(function(require, exports, module) { ui: "lib/ui", c9: "lib/c9", frontdoor: "lib/frontdoor", - outplan: "lib/outplan/dist/outplan", }; if (whitelist === "*") { @@ -71,7 +70,6 @@ define(function(require, exports, module) { "ui", "emmet", "frontdoor", - "outplan", "mocha", // TESTING "chai", // TESTING ].forEach(function(name) { From f0426e539a1541a3f0c95b6a884f5e25a3d93608 Mon Sep 17 00:00:00 2001 From: c9bot Date: Thu, 21 Apr 2016 15:07:16 +0200 Subject: [PATCH 4/5] c9-auto-bump 3.1.2306 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9613ac17..183ef827 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "c9", "description": "New Cloud9 Client", - "version": "3.1.2305", + "version": "3.1.2306", "author": "Ajax.org B.V. ", "private": true, "main": "bin/c9", From 0e8b21a8bbc14c020f42b955350aaec0e8af924b Mon Sep 17 00:00:00 2001 From: c9bot Date: Thu, 21 Apr 2016 21:44:37 +0200 Subject: [PATCH 5/5] c9-auto-bump 3.1.2307 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 183ef827..b8b8306d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "c9", "description": "New Cloud9 Client", - "version": "3.1.2306", + "version": "3.1.2307", "author": "Ajax.org B.V. ", "private": true, "main": "bin/c9",