Skip to content
This repository

Changes to packaging #1603

Merged
merged 22 commits into from almost 2 years ago

5 participants

Garen Torikian Zef Hemel Jan Jongboom Matt Christoph Dorn
Garen Torikian

Changes here were merged from another branch for c9local: https://github.com/ajaxorg/cloud9/tree/packed_more

There were also additional changes for packaged infra in general.

server.js
((80 lines not shown))
44  
-}, function (err, app) {
45  
-    if (err) {
46  
-        console.error("While starting the '%s':", configPath);
47  
-        throw err;
48  
-    }
49  
-    console.log("Started '%s'!", configPath);
50  
-});
  67
+if (debug == false && packed == false)
  68
+	boot();
  69
+
  70
+function boot() {
  71
+	var configPath = path.resolve(__dirname, "./configs/", configName);
  72
+	var config = require(configPath);
  73
+
  74
+	config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
  75
+	   if (packed === true) {
1
Zef Hemel
zefhemel added a note May 25, 2012

Please don't do this. if(packed) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.js
((81 lines not shown))
45  
-    if (err) {
46  
-        console.error("While starting the '%s':", configPath);
47  
-        throw err;
48  
-    }
49  
-    console.log("Started '%s'!", configPath);
50  
-});
  67
+if (debug == false && packed == false)
  68
+	boot();
  69
+
  70
+function boot() {
  71
+	var configPath = path.resolve(__dirname, "./configs/", configName);
  72
+	var config = require(configPath);
  73
+
  74
+	config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
  75
+	   if (packed === true) {
  76
+	       if (
1
Zef Hemel
zefhemel added a note May 25, 2012

return !(/\/plugins-client\/cloud9.core$/.test(plugin) || ...);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.js
((103 lines not shown))
  83
+	           return false;
  84
+	       }
  85
+	   }
  86
+	   return true;
  87
+	});
  88
+
  89
+	// server plugins
  90
+	config.containers.master.plugins.forEach(function(plugin) {
  91
+	   if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
  92
+	       plugin.debug = debug;
  93
+	       plugin.packed = packed;
  94
+	       plugin.packedName = packedName;
  95
+	   }
  96
+	});
  97
+
  98
+	if (packed === true) {
1
Zef Hemel
zefhemel added a note May 25, 2012

if(packed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.js
((28 lines not shown))
  28
+		        if (error || stderr) {
  29
+		            console.error(stderr);
  30
+		            process.exit(1);
  31
+		        }
  32
+		        console.log(stdout);
  33
+		        boot();
  34
+	    	});
  35
+       }
  36
+       else
  37
+       	boot();
  38
+   }
  39
+
  40
+   else if (process.argv[p] == "-P") {
  41
+       packed = true;
  42
+       if (process.argv[p + 1] && process.argv[p + 1].indexOf("-") < 0) // use this specific packed file
  43
+       	packedName = process.argv[++p];
1
Zef Hemel
zefhemel added a note May 25, 2012

Please indent according to coding standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Zef Hemel

Other than the comments above, functionally it seems to work well. Although I still think waiting a second or two for anything to show is too long. We need a loading screen.

Garen Torikian

Re: the loading, I will talk to @javruben about it. He has been working on some DOM optimization around APF and perhaps this is the remaining problem.

server.js
@@ -2,6 +2,7 @@
2 2
 
3 3
 var path = require('path');
4 4
 var architect = require("architect");
  5
+var EXEC = require("child_process").exec;
1
Jan Jongboom
janjongboom added a note May 29, 2012

You write exec like exec and not like EXEC. That makes no sense. Also in the other files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Jan Jongboom

@gjtorikian Please change the commit range so it points to master not to beta.

Garen Torikian

@janjongboom The capitalization for EXEC has now changed.

I cannot pull this into master because it was branched off of beta. If I attempt to change the commit range, then I end up pulling 99 commits into master. That is bad.

Garen Torikian

I should requalify what I mean--until beta gets merged into master, I cannot change the source for this to master. Otherwise we get all the beta branch changes too.

The reason for this is simple: some changes were made to local by Christoph, that this branch also fixes up. In other words, this branch fixes stuff for OSS, Infra, and local, since infra and local packed depend on work here.

server.js
((77 lines not shown))
43  
-    console: ((debug)?console:null)
44  
-}, function (err, app) {
45  
-    if (err) {
46  
-        console.error("While starting the '%s':", configPath);
47  
-        throw err;
48  
-    }
49  
-    console.log("Started '%s'!", configPath);
50  
-});
  67
+if (debug == false && packed == false)
  68
+	boot();
  69
+
  70
+function boot() {
  71
+	var configPath = path.resolve(__dirname, "./configs/", configName);
  72
+	var config = require(configPath);
  73
+
  74
+	config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
2
Jan Jongboom
janjongboom added a note May 29, 2012

This is a bad idea. Create a 'packed' config that is based of the default config but doesn't have these plugins.

Garen Torikian
gjtorikian added a note May 29, 2012

Huh, that's a really good idea. The latest commit has this change: bbcd302#diff-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.js
((99 lines not shown))
  81
+                    /\/plugins-client\/lib.v8debug$/.test(plugin))
  82
+	   }
  83
+	   return true;
  84
+	});
  85
+
  86
+	// server plugins
  87
+	config.containers.master.plugins.forEach(function(plugin) {
  88
+	   if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
  89
+	       plugin.debug = debug;
  90
+	       plugin.packed = packed;
  91
+	       plugin.packedName = packedName;
  92
+	   }
  93
+	});
  94
+
  95
+	if (packed)
  96
+	   config.containers.master.plugins.push("./../plugins-client/lib.packed");
1
Jan Jongboom
janjongboom added a note May 29, 2012

This should be in the same packed config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.js
((12 lines not shown))
19 21
 for (var p = 2; p < process.argv.length; p++) {
20  
-    if (process.argv[p] == "-d") {
21  
-        debug = true;
22  
-    }
  22
+   if (process.argv[p] == "-d") {
1
Jan Jongboom
janjongboom added a note May 29, 2012

Triple ='es

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.js
((12 lines not shown))
19 21
 for (var p = 2; p < process.argv.length; p++) {
20  
-    if (process.argv[p] == "-d") {
21  
-        debug = true;
22  
-    }
  22
+   if (process.argv[p] == "-d") {
  23
+       debug = true;
  24
+       
  25
+       if(!path.existsSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js")) {
2
Jan Jongboom
janjongboom added a note May 29, 2012

Why isn't this in a makefile which is then called from here?

Garen Torikian
gjtorikian added a note May 29, 2012

This is the way @cadorn wanted it. The idea is that NPM is managing the install process, not make. The local version depends on this way while doing some install/update stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Matt mattpardee merged commit be98154 into from May 30, 2012
Matt mattpardee closed this May 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
4  Makefile
@@ -83,8 +83,8 @@ gzip:
83 83
 
84 84
 c9core: apf ace core worker mode theme
85 85
     
86  
-package: c9core ext min_ace
  86
+package: helper c9core ext min_ace
87 87
 
88 88
 test:
89 89
 	$(MAKE) -C test
90  
-	cp node_modules/ace/build/src/worker* plugins-client/cloud9.core/www/js/worker
  90
+	cp node_modules/ace/build/src/worker* plugins-client/cloud9.core/www/js/worker
11  build/app.build.js
@@ -2,12 +2,12 @@
2 2
 
3 3
 ({
4 4
 	//optimize: "none",
  5
+	preserveLicenseComments: false,
5 6
 	baseUrl: "../",
6 7
 	paths: {
7 8
 		"text" : "build/text", // plugin for pulling in text! files
8 9
 		"core" : "empty:",
9 10
 		"ext/commands" : "plugins-client/ext.commands",
10  
-		"ext/uploadfiles" : "plugins-client/ext.uploadfiles",
11 11
 		"apf" : "empty:",
12 12
 		"treehugger" : "empty:",
13 13
 		"debug": "empty:",
@@ -30,7 +30,6 @@
30 30
 	'ext/searchinfiles': 'plugins-client/ext.searchinfiles',
31 31
 	'ext/searchreplace': 'plugins-client/ext.searchreplace',
32 32
 	'ext/quickwatch': 'plugins-client/ext.quickwatch',
33  
-	'ext/quicksearch': 'plugins-client/ext.quicksearch',
34 33
 	'ext/gotoline': 'plugins-client/ext.gotoline',
35 34
 	'ext/preview': 'plugins-client/ext.preview',
36 35
 	'ext/log': 'plugins-client/ext.log',
@@ -67,8 +66,11 @@
67 66
 	'ext/closeconfirmation': 'plugins-client/ext.closeconfirmation',
68 67
 	'ext/codetools': 'plugins-client/ext.codetools',
69 68
 	'ext/colorpicker': 'plugins-client/ext.colorpicker',
  69
+	'ext/gitblame': 'plugins-client/ext.gitblame',
70 70
 	'ext/revisions': 'plugins-client/ext.revisions',
71  
-	'ext/language': 'plugins-client/ext.language'
  71
+	'ext/quicksearch': 'plugins-client/ext.quicksearch',
  72
+	'ext/language': 'plugins-client/ext.language',
  73
+	'ext/uploadfiles': 'plugins-client/ext.uploadfiles'
72 74
 	},
73 75
 	include: ["build/src/core.packed", 
74 76
 	"apf/elements/codeeditor", 
@@ -94,7 +96,6 @@
94 96
 	'ext/searchinfiles/searchinfiles',
95 97
 	'ext/searchreplace/searchreplace',
96 98
 	'ext/quickwatch/quickwatch',
97  
-	'ext/quicksearch/quicksearch',
98 99
 	'ext/gotoline/gotoline',
99 100
 	'ext/preview/preview',
100 101
 	'ext/log/log',
@@ -131,7 +132,9 @@
131 132
 	'ext/closeconfirmation/closeconfirmation',
132 133
 	'ext/codetools/codetools',
133 134
 	'ext/colorpicker/colorpicker',
  135
+	'ext/gitblame/gitblame',
134 136
 	'ext/revisions/revisions',
  137
+	'ext/quicksearch/quicksearch',
135 138
 	'ext/language/language'], 
136 139
 	out: "../plugins-client/lib.packed/www/packed.js",
137 140
 	inlineText: true,
1  build/app.build.tmpl.js
@@ -2,6 +2,7 @@
2 2
 
3 3
 ({
4 4
 	//optimize: "none",
  5
+	preserveLicenseComments: false,
5 6
 	baseUrl: "../",
6 7
 	paths: {
7 8
 		"text" : "%b/text", // plugin for pulling in text! files
2  build/core.build.js
@@ -10,7 +10,7 @@
10 10
         "apf-packaged": "plugins-client/lib.apf/www/apf-packaged"
11 11
     },
12 12
     include: [
13  
-        "node_modules/ace/build/src-uncompressed/ace",
  13
+        "node_modules/ace/build/src/ace",
14 14
         "apf-packaged/apf_release",
15 15
         "core/document", 
16 16
         "core/ext", 
3  build/packed_helper.js
@@ -20,13 +20,14 @@ for (var i in extensions) {
20 20
     }
21 21
 }
22 22
 
  23
+clientMappings.push("ext/uploadfiles': 'plugins-client/ext.uploadfiles"); // TODO: why is this not automatically added?
23 24
 clientPlugins = "'" + clientPlugins.join("',\n\t'") + "'";
24 25
 clientMappings = "'" + clientMappings.join("',\n\t'") + "'";
25 26
 
26 27
 var appTemplate = fs.readFileSync("./build/app.build.tmpl.js", "utf8");
27 28
 
28 29
 // transform all variable paths out
29  
-var appFile = appTemplate.replace(/%b/g, "build").replace(/%d/, "plugins-client").replace('"%s"', clientPlugins).replace('"%m"', clientMappings).replace('"%o"', '"../plugins-client/lib.packed/www/packed.js"');
  30
+var appFile = appTemplate.replace(/%b/g, "build").replace(/%d/g, "plugins-client").replace('"%s"', clientPlugins).replace('"%m"', clientMappings).replace('"%o"', '"../plugins-client/lib.packed/www/packed.js"');
30 31
 
31 32
 fs.writeFile("./build/app.build.js", appFile, "utf8", function(err) {
32 33
     if (err) {
2  configs/default.js
@@ -48,7 +48,6 @@ var config = {
48 48
             "./../plugins-client/lib.treehugger", 
49 49
             "./../plugins-client/lib.v8debug",
50 50
             "./../plugins-client/lib.requirejs",
51  
-            "./../plugins-client/lib.packed",
52 51
 
53 52
             // server plugins
54 53
             {
@@ -133,6 +132,7 @@ var config = {
133 132
                     "ext/gitblame/gitblame",
134 133
                     //"ext/githistory/githistory",
135 134
                     "ext/revisions/revisions",
  135
+                    "ext/quicksearch/quicksearch",
136 136
                     "ext/language/liveinspect"
137 137
                     //"ext/splitview/splitview"
138 138
                     //"ext/minimap/minimap"
22  configs/packed.js
... ...
@@ -0,0 +1,22 @@
  1
+var config = require("./default");
  2
+
  3
+config.containers.master.plugins.forEach(function(plugin) {
  4
+    if (plugin.packagePath) {
  5
+        if (/\/cloud9.core$/.test(plugin.packagePath)) {
  6
+            plugin.socketIoTransports = ["websocket", "htmlfile", "xhr-multipart", "xhr-polling"];
  7
+        }
  8
+    }
  9
+});
  10
+
  11
+config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
  12
+   // returns false of any of these plugins are detected; lib.packed will emit them
  13
+   return !(/\/plugins-client\/cloud9.core$/.test(plugin) ||
  14
+            /\/plugins-client\/lib.ace$/.test(plugin) ||
  15
+            /\/plugins-client\/lib.apf$/.test(plugin) ||
  16
+            /\/plugins-client\/lib.treehugger$/.test(plugin) ||
  17
+            /\/plugins-client\/lib.v8debug$/.test(plugin))
  18
+});
  19
+
  20
+config.containers.master.plugins.push("./../plugins-client/lib.packed");
  21
+
  22
+module.exports = config;
4  package.json
@@ -55,6 +55,8 @@
55 55
     }],
56 56
 
57 57
     "scripts": {
58  
-        "start": "sh ./bin/cloud9.sh"
  58
+        "start": "sh ./bin/cloud9.sh",
  59
+        "build-debug": "node ./scripts/build-debug",
  60
+        "build-packed": "node ./scripts/build-packed"
59 61
     }
60 62
 }
189  plugins-client/lib.ace/www/mode/mode-yaml.js
... ...
@@ -0,0 +1,189 @@
  1
+/* ***** BEGIN LICENSE BLOCK *****
  2
+* The Original Code is Ajax.org Code Editor (ACE).
  3
+*
  4
+* Contributor(s):
  5
+*      Meg Sharkey <megshark AT gmail DOT com>
  6
+*
  7
+* Alternatively, the contents of this file may be used under the terms of
  8
+* either the GNU General Public License Version 2 or later (the "GPL"), or
  9
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  10
+* in which case the provisions of the GPL or the LGPL are applicable instead
  11
+* of those above. If you wish to allow use of your version of this file only
  12
+* under the terms of either the GPL or the LGPL, and not to allow others to
  13
+* use your version of this file under the terms of the MPL, indicate your
  14
+* decision by deleting the provisions above and replace them with the notice
  15
+* and other provisions required by the GPL or the LGPL. If you do not delete
  16
+* the provisions above, a recipient may use your version of this file under
  17
+* the terms of any one of the MPL, the GPL or the LGPL.
  18
+*
  19
+* ***** END LICENSE BLOCK ***** */
  20
+
  21
+define('ace/mode/yaml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/yaml_highlight_rules', 'ace/mode/matching_brace_outdent'], function(require, exports, module) {
  22
+
  23
+
  24
+var oop = require("../lib/oop");
  25
+var TextMode = require("./text").Mode;
  26
+var Tokenizer = require("../tokenizer").Tokenizer;
  27
+var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules;
  28
+var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  29
+
  30
+var Mode = function() {
  31
+    this.$tokenizer = new Tokenizer(new YamlHighlightRules().getRules());
  32
+    this.$outdent = new MatchingBraceOutdent();
  33
+};
  34
+oop.inherits(Mode, TextMode);
  35
+
  36
+(function() {
  37
+
  38
+     this.getNextLineIndent = function(state, line, tab) {
  39
+        var indent = this.$getIndent(line);
  40
+
  41
+        if (state == "start") {
  42
+            var match = line.match(/^.*[\{\(\[]\s*$/);
  43
+            if (match) {
  44
+                indent += tab;
  45
+            }
  46
+        }
  47
+
  48
+        return indent;
  49
+    };
  50
+
  51
+    this.checkOutdent = function(state, line, input) {
  52
+        return this.$outdent.checkOutdent(line, input);
  53
+    };
  54
+
  55
+    this.autoOutdent = function(state, doc, row) {
  56
+        this.$outdent.autoOutdent(doc, row);
  57
+    };
  58
+
  59
+
  60
+}).call(Mode.prototype);
  61
+
  62
+exports.Mode = Mode;
  63
+
  64
+});
  65
+
  66
+define('ace/mode/yaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  67
+
  68
+
  69
+var oop = require("../lib/oop");
  70
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  71
+
  72
+var YamlHighlightRules = function() {
  73
+
  74
+    // regexp must not have capturing parentheses. Use (?:) instead.
  75
+    // regexps are ordered -> the first match is used
  76
+    this.$rules = {
  77
+        "start" : [
  78
+            {
  79
+                token : "comment",
  80
+                regex : "#.*$"
  81
+            }, {
  82
+                token : "comment",
  83
+                regex : "^---"
  84
+            }, {
  85
+                token: "variable",
  86
+                regex: "[&\\*][a-zA-Z0-9-_]+"
  87
+            }, {
  88
+                token: ["identifier", "text"],
  89
+                regex: "(\\w+\\s*:)(\\w*)"
  90
+            }, {
  91
+                token : "keyword.operator",
  92
+                regex : "<<\\w*:\\w*"
  93
+            }, {
  94
+                token : "keyword.operator",
  95
+                regex : "-\\s*(?=[{])"
  96
+            }, {
  97
+                token : "string", // single line
  98
+                regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  99
+            }, {
  100
+                token : "string", // multi line string start
  101
+                merge : true,
  102
+                regex : '[\\|>]\\w*',
  103
+                next : "qqstring"
  104
+            }, {
  105
+                token : "string", // single quoted string
  106
+                regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  107
+            }, {
  108
+                token : "constant.numeric", // float
  109
+                regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  110
+            }, {
  111
+                token : "constant.language.boolean",
  112
+                regex : "(?:true|false|yes|no)\\b"
  113
+            }, {
  114
+                token : "invalid.illegal", // comments are not allowed
  115
+                regex : "\\/\\/.*$"
  116
+            }, {
  117
+                token : "paren.lparen",
  118
+                regex : "[[({]"
  119
+            }, {
  120
+                token : "paren.rparen",
  121
+                regex : "[\\])}]"
  122
+            }, {
  123
+                token : "text",
  124
+                regex : "\\s+"
  125
+            }
  126
+        ],
  127
+        "qqstring" : [
  128
+            {
  129
+                token : "string",
  130
+                regex : '(?=(?:(?:\\\\.)|(?:[^:]))*?:)',
  131
+                next : "start"
  132
+            }, {
  133
+                token : "string",
  134
+                merge : true,
  135
+                regex : '.+'
  136
+            }
  137
+        ]}
  138
+
  139
+};
  140
+
  141
+oop.inherits(YamlHighlightRules, TextHighlightRules);
  142
+
  143
+exports.YamlHighlightRules = YamlHighlightRules;
  144
+});
  145
+
  146
+define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  147
+
  148
+
  149
+var Range = require("../range").Range;
  150
+
  151
+var MatchingBraceOutdent = function() {};
  152
+
  153
+(function() {
  154
+
  155
+    this.checkOutdent = function(line, input) {
  156
+        if (! /^\s+$/.test(line))
  157
+            return false;
  158
+
  159
+        return /^\s*\}/.test(input);
  160
+    };
  161
+
  162
+    this.autoOutdent = function(doc, row) {
  163
+        var line = doc.getLine(row);
  164
+        var match = line.match(/^(\s*\})/);
  165
+
  166
+        if (!match) return 0;
  167
+
  168
+        var column = match[1].length;
  169
+        var openBracePos = doc.findMatchingBracket({row: row, column: column});
  170
+
  171
+        if (!openBracePos || openBracePos.row == row) return 0;
  172
+
  173
+        var indent = this.$getIndent(doc.getLine(openBracePos.row));
  174
+        doc.replace(new Range(row, 0, row, column-1), indent);
  175
+    };
  176
+
  177
+    this.$getIndent = function(line) {
  178
+        var match = line.match(/^(\s+)/);
  179
+        if (match) {
  180
+            return match[1];
  181
+        }
  182
+
  183
+        return "";
  184
+    };
  185
+
  186
+}).call(MatchingBraceOutdent.prototype);
  187
+
  188
+exports.MatchingBraceOutdent = MatchingBraceOutdent;
  189
+});
9  plugins-client/lib.ace/www/worker/worker-xquery.js
9 additions, 0 deletions not shown
3  plugins-client/lib.apf/www/apf-packaged/apf_release.js
@@ -66594,7 +66594,8 @@ apf.webdav = function(struct, tagName){
66594 66594
         aCont.push("</D:", reportName, ">");
66595 66595
 
66596 66596
         this.method = "REPORT";
66597  
-        this.doRequest(function(data, state, extra) {
  66597
+        
  66598
+        return this.doRequest(function(data, state, extra) {
66598 66599
             var iStatus = parseInt(extra.status, 10);
66599 66600
             if (state != apf.SUCCESS) {
66600 66601
                 var oError = WebDAVError.call(this, "Unable to fetch report on '" + sPath
1  plugins-client/lib.apf/www/apf/elements/codeeditor.js
@@ -39,6 +39,7 @@
39 39
 define(function(require, exports, module) {
40 40
 "use strict";
41 41
 
  42
+var ide = require("core/ide");
42 43
 var Editor = require("ace/editor").Editor;
43 44
 var EditSession = require("ace/edit_session").EditSession;
44 45
 var VirtualRenderer = require("ace/virtual_renderer").VirtualRenderer;
2  plugins-client/lib.packed/package.json
@@ -4,7 +4,7 @@
4 4
     "main": "packed-plugin.js",
5 5
     "private": true,
6 6
     "plugin": {
7  
-        "provides": [ ],
  7
+        "provides": ["client.cloud9","client.apf","client.ace","client.treehugger","client.v8debug"],
8 8
         "consumes": [
9 9
             "static"
10 10
         ]
6  plugins-client/lib.packed/packed-plugin.js
@@ -11,6 +11,10 @@ module.exports = function setup(options, imports, register) {
11 11
     }]);
12 12
 
13 13
     register(null, {
14  
-        
  14
+        "client.cloud9": {},
  15
+        "client.apf": {},
  16
+        "client.ace": {},
  17
+        "client.treehugger": {},
  18
+        "client.v8debug": {}
15 19
     });
16 20
 };
10  plugins-server/cloud9.core/ide.js
@@ -30,7 +30,6 @@ var Ide = module.exports = function(options) {
30 30
 
31 31
     this.workspaceDir = options.workspaceDir;
32 32
 
33  
-
34 33
     options.plugins = options.plugins || [];
35 34
     this.options = {
36 35
         workspaceDir: this.workspaceDir,
@@ -57,7 +56,7 @@ var Ide = module.exports = function(options) {
57 56
     this.nodeCmd = options.exec || process.execPath;
58 57
 
59 58
     this.workspace = new Workspace(this);
60  
-
  59
+    
61 60
     var _self = this;
62 61
     this.router = connect.router(function(app) {
63 62
         app.get(/^(\/|\/index.html?)$/, function(req, res, next) {
@@ -98,7 +97,7 @@ util.inherits(Ide, EventEmitter);
98 97
                 "cache-control": "no-transform",
99 98
                 "Content-Type": "text/html"
100 99
             });
101  
-
  100
+            
102 101
             var permissions = _self.getPermissions(req);
103 102
             var plugins = c9util.arrayToMap(_self.options.plugins);
104 103
             var bundledPlugins = c9util.arrayToMap(_self.options.bundledPlugins);
@@ -133,7 +132,7 @@ util.inherits(Ide, EventEmitter);
133 132
                 readonly: (permissions.fs !== "rw"),
134 133
                 requirejsConfig: _self.options.requirejsConfig,
135 134
                 settingsXml: "",
136  
-                scripts: (_self.options.debug || _self.options.real) ? "" : aceScripts,
  135
+                scripts: (_self.options.debug || _self.options.packed) ? "" : aceScripts,
137 136
                 projectName: _self.options.projectName,
138 137
                 version: _self.options.version,
139 138
                 hosted: _self.options.hosted.toString(),
@@ -212,12 +211,13 @@ util.inherits(Ide, EventEmitter);
212 211
 
213 212
     this.getPermissions = function(req) {
214 213
         var user = this.getUser(req);
  214
+        
215 215
         if (!user)
216 216
             return User.VISITOR_PERMISSIONS;
217 217
         else
218 218
             return user.getPermissions();
219 219
     };
220  
-
  220
+    
221 221
     this.hasUser = function(username) {
222 222
         return !!this.$users[username];
223 223
     };
2  plugins-server/cloud9.core/view/ide.tmpl.html
... ...
@@ -1,5 +1,5 @@
1 1
 <!DOCTYPE html>
2  
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://ajax.org/2005/aml" skipParse=[%real%]>
  2
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://ajax.org/2005/aml" skipParse=[%packed%]>
3 3
     <head profile="http://www.w3.org/2005/10/profile">
4 4
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
5 5
         <title>[%projectName%] - Cloud9</title>
10  scripts/build-debug.js
... ...
@@ -0,0 +1,10 @@
  1
+var exec = require("child_process").exec;
  2
+
  3
+exec("make apfdebug", function (error, stdout, stderr) {
  4
+    if (error) {
  5
+        console.error(stderr);
  6
+        process.exit(1);
  7
+    }
  8
+    
  9
+    console.log(stdout);
  10
+});
15  scripts/build-packed.js
... ...
@@ -0,0 +1,15 @@
  1
+var spawn = require('child_process').spawn;
  2
+var pack = spawn('make', ['package']);
  3
+
  4
+pack.stderr.setEncoding("utf8");
  5
+
  6
+pack.stderr.on('data', function (data) {
  7
+  console.error(data);
  8
+});
  9
+
  10
+pack.on('exit', function (code) {
  11
+  if (code !== 0) {
  12
+    console.error('grep process exited with code ' + code);
  13
+    process.exit(code);
  14
+  }
  15
+});
112  server.js 100755 → 100644
@@ -2,6 +2,7 @@
2 2
 
3 3
 var path = require('path');
4 4
 var architect = require("architect");
  5
+var spawn = require("child_process").spawn;
5 6
 
6 7
 // TODO: Need better args parser.
7 8
 
@@ -10,41 +11,96 @@ var configName = process.argv[2] || "default";
10 11
 // when command line arguments are passed into this, we ignore them
11 12
 // when loading the config file.
12 13
 if (configName.indexOf("-") === 0) {
13  
-    configName = "default";
  14
+   configName = "default";
14 15
 }
15 16
 
16 17
 var debug = false;
17 18
 var packed = false;
18 19
 var packedName = "";
  20
+
19 21
 for (var p = 2; p < process.argv.length; p++) {
20  
-    if (process.argv[p] == "-d") {
21  
-        debug = true;
22  
-    }
  22
+   if (process.argv[p] === "-d") {
  23
+       debug = true;
  24
+       
  25
+       if(!path.existsSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js")) {
  26
+       		console.log("Building apfdebug for first run...");
  27
+       		
  28
+            var buildDebug = spawn("npm", ["run-script", "build-debug"]);
  29
+
  30
+            buildDebug.stderr.setEncoding("utf8");
  31
+            buildDebug.stderr.on('data', function (data) {
  32
+              console.error(data);
  33
+            });
  34
+            buildDebug.on('exit', function (code) {
  35
+              if (code !== 0) {
  36
+                console.error('build-debug process exited with code ' + code);
  37
+                process.exit(code);
  38
+              }
  39
+              boot();
  40
+            });
  41
+       }
  42
+       else
  43
+           boot();
  44
+   }
23 45
 
24  
-    else if (process.argv[p] == "-P") {
25  
-        packed = true;
26  
-        if (process.argv[p + 1].indexOf("-") < 0) // use this specific packed file
  46
+   else if (process.argv[p] === "-P") {
  47
+       packed = true;
  48
+       if (process.argv[p + 1] && process.argv[p + 1].indexOf("-") < 0) // use this specific packed file
27 49
             packedName = process.argv[++p];
28  
-    }
  50
+       else
  51
+            packedName = "packed.js";
  52
+
  53
+       configName = "packed";
  54
+
  55
+       if(!path.existsSync("plugins-client/lib.packed/www/" + packedName)) {
  56
+       		console.log("Building packed file for first run...Please wait...");
  57
+		   	console.log("   |\\      _,,,---,,_\n"+
  58
+		   				"   /,`.-'`'    -.  ;-;;,_\n" +
  59
+		  				"   |,4-  ) )-,_..;\\ (  `'-'\n" +
  60
+		 				"   '---''(_/--'  `-'\\_)  Felix Lee");
  61
+
  62
+            var buildPackage = spawn("npm", ["run-script", "build-packed"]);
  63
+            
  64
+            buildPackage.stderr.setEncoding("utf8");
  65
+            buildPackage.stderr.on('data', function (data) {
  66
+              console.error(data);
  67
+            });
  68
+            buildPackage.on('exit', function (code) {
  69
+              if (code !== 0) {
  70
+                console.error('build-package process exited with code ' + code);
  71
+                process.exit(code);
  72
+              }
  73
+              boot();
  74
+            });
  75
+       }
  76
+       else
  77
+           boot();
  78
+   }
29 79
 }
30 80
 
31  
-var configPath = path.resolve(__dirname, "./configs/", configName);
32  
-var config = require(configPath);
33  
-
34  
-config.containers.master.plugins.forEach(function(plugin) {
35  
-    if (plugin.packagePath && /\/cloud9.core$/.test(plugin.packagePath)) {
36  
-        plugin.debug = debug;
37  
-        plugin.packed = packed;
38  
-        plugin.packedName = packedName;
39  
-    }
40  
-});
41  
-
42  
-architect.createApp(config, {
43  
-    console: ((debug)?console:null)
44  
-}, function (err, app) {
45  
-    if (err) {
46  
-        console.error("While starting the '%s':", configPath);
47  
-        throw err;
48  
-    }
49  
-    console.log("Started '%s'!", configPath);
50  
-});
  81
+if (debug == false && packed == false)
  82
+	boot();
  83
+
  84
+function boot() {
  85
+	var configPath = path.resolve(__dirname, "./configs/", configName);
  86
+	var config = require(configPath);
  87
+
  88
+	// server plugins
  89
+	config.containers.master.plugins.forEach(function(plugin) {
  90
+	   if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
  91
+	       plugin.debug = debug;
  92
+	       plugin.packed = packed;
  93
+	       plugin.packedName = packedName;
  94
+	   }
  95
+	});
  96
+
  97
+	architect.createApp(config, {
  98
+	   console: ((debug)?console:null)
  99
+	}, function (err, app) {
  100
+	   if (err) {
  101
+	       console.error("While starting the '%s':", configPath);
  102
+	       throw err;
  103
+	   }
  104
+	   console.log("Started '%s'!", configPath);
  105
+	});
  106
+}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.