Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Changes to packaging #1603

Merged
merged 22 commits into from

5 participants

@gjtorikian

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))
-}, function (err, app) {
- if (err) {
- console.error("While starting the '%s':", configPath);
- throw err;
- }
- console.log("Started '%s'!", configPath);
-});
+if (debug == false && packed == false)
+ boot();
+
+function boot() {
+ var configPath = path.resolve(__dirname, "./configs/", configName);
+ var config = require(configPath);
+
+ config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
+ if (packed === true) {

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))
- if (err) {
- console.error("While starting the '%s':", configPath);
- throw err;
- }
- console.log("Started '%s'!", configPath);
-});
+if (debug == false && packed == false)
+ boot();
+
+function boot() {
+ var configPath = path.resolve(__dirname, "./configs/", configName);
+ var config = require(configPath);
+
+ config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
+ if (packed === true) {
+ if (

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))
+ return false;
+ }
+ }
+ return true;
+ });
+
+ // server plugins
+ config.containers.master.plugins.forEach(function(plugin) {
+ if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
+ plugin.debug = debug;
+ plugin.packed = packed;
+ plugin.packedName = packedName;
+ }
+ });
+
+ if (packed === true) {

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))
+ if (error || stderr) {
+ console.error(stderr);
+ process.exit(1);
+ }
+ console.log(stdout);
+ boot();
+ });
+ }
+ else
+ boot();
+ }
+
+ else if (process.argv[p] == "-P") {
+ packed = true;
+ if (process.argv[p + 1] && process.argv[p + 1].indexOf("-") < 0) // use this specific packed file
+ packedName = process.argv[++p];

Please indent according to coding standards.

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

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.

@gjtorikian

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 @@
var path = require('path');
var architect = require("architect");
+var EXEC = require("child_process").exec;

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
@janjongboom

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

@gjtorikian

@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.

@gjtorikian

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))
- console: ((debug)?console:null)
-}, function (err, app) {
- if (err) {
- console.error("While starting the '%s':", configPath);
- throw err;
- }
- console.log("Started '%s'!", configPath);
-});
+if (debug == false && packed == false)
+ boot();
+
+function boot() {
+ var configPath = path.resolve(__dirname, "./configs/", configName);
+ var config = require(configPath);
+
+ config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {

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

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))
+ /\/plugins-client\/lib.v8debug$/.test(plugin))
+ }
+ return true;
+ });
+
+ // server plugins
+ config.containers.master.plugins.forEach(function(plugin) {
+ if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
+ plugin.debug = debug;
+ plugin.packed = packed;
+ plugin.packedName = packedName;
+ }
+ });
+
+ if (packed)
+ config.containers.master.plugins.push("./../plugins-client/lib.packed");

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))
for (var p = 2; p < process.argv.length; p++) {
- if (process.argv[p] == "-d") {
- debug = true;
- }
+ if (process.argv[p] == "-d") {

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))
for (var p = 2; p < process.argv.length; p++) {
- if (process.argv[p] == "-d") {
- debug = true;
- }
+ if (process.argv[p] == "-d") {
+ debug = true;
+
+ if(!path.existsSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js")) {

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

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
@mattpardee mattpardee merged commit be98154 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 8, 2012
  1. @zefhemel

    Add dryice

    zefhemel authored
  2. @cadorn

    updated ace

    cadorn authored
  3. @cadorn
Commits on May 23, 2012
  1. @gjtorikian

    Merge d89b842

    gjtorikian authored
  2. @gjtorikian

    Semantic rename

    gjtorikian authored
  3. @gjtorikian

    add missing new files

    gjtorikian authored
  4. @gjtorikian
Commits on May 24, 2012
  1. @gjtorikian
  2. @gjtorikian

    Changes to ide.js for infra

    gjtorikian authored
  3. @gjtorikian
  4. @gjtorikian
  5. @gjtorikian

    Flip skipparse on

    gjtorikian authored
Commits on May 25, 2012
  1. @gjtorikian
  2. @gjtorikian

    Updates to coding standards

    gjtorikian authored
  3. @gjtorikian

    Remove copyright comments

    gjtorikian authored
  4. @gjtorikian
Commits on May 29, 2012
  1. @gjtorikian

    Capitalization

    gjtorikian authored
  2. @gjtorikian
  3. @gjtorikian
  4. @gjtorikian

    Create new packed config

    gjtorikian authored
  5. @gjtorikian

    Update build file

    gjtorikian authored
Commits on May 30, 2012
  1. @gjtorikian
This page is out of date. Refresh to see the latest.
View
4 Makefile
@@ -83,8 +83,8 @@ gzip:
c9core: apf ace core worker mode theme
-package: c9core ext min_ace
+package: helper c9core ext min_ace
test:
$(MAKE) -C test
- cp node_modules/ace/build/src/worker* plugins-client/cloud9.core/www/js/worker
View
11 build/app.build.js
@@ -2,12 +2,12 @@
({
//optimize: "none",
+ preserveLicenseComments: false,
baseUrl: "../",
paths: {
"text" : "build/text", // plugin for pulling in text! files
"core" : "empty:",
"ext/commands" : "plugins-client/ext.commands",
- "ext/uploadfiles" : "plugins-client/ext.uploadfiles",
"apf" : "empty:",
"treehugger" : "empty:",
"debug": "empty:",
@@ -30,7 +30,6 @@
'ext/searchinfiles': 'plugins-client/ext.searchinfiles',
'ext/searchreplace': 'plugins-client/ext.searchreplace',
'ext/quickwatch': 'plugins-client/ext.quickwatch',
- 'ext/quicksearch': 'plugins-client/ext.quicksearch',
'ext/gotoline': 'plugins-client/ext.gotoline',
'ext/preview': 'plugins-client/ext.preview',
'ext/log': 'plugins-client/ext.log',
@@ -67,8 +66,11 @@
'ext/closeconfirmation': 'plugins-client/ext.closeconfirmation',
'ext/codetools': 'plugins-client/ext.codetools',
'ext/colorpicker': 'plugins-client/ext.colorpicker',
+ 'ext/gitblame': 'plugins-client/ext.gitblame',
'ext/revisions': 'plugins-client/ext.revisions',
- 'ext/language': 'plugins-client/ext.language'
+ 'ext/quicksearch': 'plugins-client/ext.quicksearch',
+ 'ext/language': 'plugins-client/ext.language',
+ 'ext/uploadfiles': 'plugins-client/ext.uploadfiles'
},
include: ["build/src/core.packed",
"apf/elements/codeeditor",
@@ -94,7 +96,6 @@
'ext/searchinfiles/searchinfiles',
'ext/searchreplace/searchreplace',
'ext/quickwatch/quickwatch',
- 'ext/quicksearch/quicksearch',
'ext/gotoline/gotoline',
'ext/preview/preview',
'ext/log/log',
@@ -131,7 +132,9 @@
'ext/closeconfirmation/closeconfirmation',
'ext/codetools/codetools',
'ext/colorpicker/colorpicker',
+ 'ext/gitblame/gitblame',
'ext/revisions/revisions',
+ 'ext/quicksearch/quicksearch',
'ext/language/language'],
out: "../plugins-client/lib.packed/www/packed.js",
inlineText: true,
View
1  build/app.build.tmpl.js
@@ -2,6 +2,7 @@
({
//optimize: "none",
+ preserveLicenseComments: false,
baseUrl: "../",
paths: {
"text" : "%b/text", // plugin for pulling in text! files
View
2  build/core.build.js
@@ -10,7 +10,7 @@
"apf-packaged": "plugins-client/lib.apf/www/apf-packaged"
},
include: [
- "node_modules/ace/build/src-uncompressed/ace",
+ "node_modules/ace/build/src/ace",
"apf-packaged/apf_release",
"core/document",
"core/ext",
View
3  build/packed_helper.js
@@ -20,13 +20,14 @@ for (var i in extensions) {
}
}
+clientMappings.push("ext/uploadfiles': 'plugins-client/ext.uploadfiles"); // TODO: why is this not automatically added?
clientPlugins = "'" + clientPlugins.join("',\n\t'") + "'";
clientMappings = "'" + clientMappings.join("',\n\t'") + "'";
var appTemplate = fs.readFileSync("./build/app.build.tmpl.js", "utf8");
// transform all variable paths out
-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"');
+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"');
fs.writeFile("./build/app.build.js", appFile, "utf8", function(err) {
if (err) {
View
2  configs/default.js
@@ -48,7 +48,6 @@ var config = {
"./../plugins-client/lib.treehugger",
"./../plugins-client/lib.v8debug",
"./../plugins-client/lib.requirejs",
- "./../plugins-client/lib.packed",
// server plugins
{
@@ -133,6 +132,7 @@ var config = {
"ext/gitblame/gitblame",
//"ext/githistory/githistory",
"ext/revisions/revisions",
+ "ext/quicksearch/quicksearch",
"ext/language/liveinspect"
//"ext/splitview/splitview"
//"ext/minimap/minimap"
View
22 configs/packed.js
@@ -0,0 +1,22 @@
+var config = require("./default");
+
+config.containers.master.plugins.forEach(function(plugin) {
+ if (plugin.packagePath) {
+ if (/\/cloud9.core$/.test(plugin.packagePath)) {
+ plugin.socketIoTransports = ["websocket", "htmlfile", "xhr-multipart", "xhr-polling"];
+ }
+ }
+});
+
+config.containers.master.plugins = config.containers.master.plugins.filter(function(plugin) {
+ // returns false of any of these plugins are detected; lib.packed will emit them
+ return !(/\/plugins-client\/cloud9.core$/.test(plugin) ||
+ /\/plugins-client\/lib.ace$/.test(plugin) ||
+ /\/plugins-client\/lib.apf$/.test(plugin) ||
+ /\/plugins-client\/lib.treehugger$/.test(plugin) ||
+ /\/plugins-client\/lib.v8debug$/.test(plugin))
+});
+
+config.containers.master.plugins.push("./../plugins-client/lib.packed");
+
+module.exports = config;
View
4 package.json
@@ -55,6 +55,8 @@
}],
"scripts": {
- "start": "sh ./bin/cloud9.sh"
+ "start": "sh ./bin/cloud9.sh",
+ "build-debug": "node ./scripts/build-debug",
+ "build-packed": "node ./scripts/build-packed"
}
}
View
189 plugins-client/lib.ace/www/mode/mode-yaml.js
@@ -0,0 +1,189 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* The Original Code is Ajax.org Code Editor (ACE).
+*
+* Contributor(s):
+* Meg Sharkey <megshark AT gmail DOT com>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+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) {
+
+
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules;
+var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
+
+var Mode = function() {
+ this.$tokenizer = new Tokenizer(new YamlHighlightRules().getRules());
+ this.$outdent = new MatchingBraceOutdent();
+};
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+ this.getNextLineIndent = function(state, line, tab) {
+ var indent = this.$getIndent(line);
+
+ if (state == "start") {
+ var match = line.match(/^.*[\{\(\[]\s*$/);
+ if (match) {
+ indent += tab;
+ }
+ }
+
+ return indent;
+ };
+
+ this.checkOutdent = function(state, line, input) {
+ return this.$outdent.checkOutdent(line, input);
+ };
+
+ this.autoOutdent = function(state, doc, row) {
+ this.$outdent.autoOutdent(doc, row);
+ };
+
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+
+});
+
+define('ace/mode/yaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var YamlHighlightRules = function() {
+
+ // regexp must not have capturing parentheses. Use (?:) instead.
+ // regexps are ordered -> the first match is used
+ this.$rules = {
+ "start" : [
+ {
+ token : "comment",
+ regex : "#.*$"
+ }, {
+ token : "comment",
+ regex : "^---"
+ }, {
+ token: "variable",
+ regex: "[&\\*][a-zA-Z0-9-_]+"
+ }, {
+ token: ["identifier", "text"],
+ regex: "(\\w+\\s*:)(\\w*)"
+ }, {
+ token : "keyword.operator",
+ regex : "<<\\w*:\\w*"
+ }, {
+ token : "keyword.operator",
+ regex : "-\\s*(?=[{])"
+ }, {
+ token : "string", // single line
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
+ }, {
+ token : "string", // multi line string start
+ merge : true,
+ regex : '[\\|>]\\w*',
+ next : "qqstring"
+ }, {
+ token : "string", // single quoted string
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
+ }, {
+ token : "constant.numeric", // float
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+ }, {
+ token : "constant.language.boolean",
+ regex : "(?:true|false|yes|no)\\b"
+ }, {
+ token : "invalid.illegal", // comments are not allowed
+ regex : "\\/\\/.*$"
+ }, {
+ token : "paren.lparen",
+ regex : "[[({]"
+ }, {
+ token : "paren.rparen",
+ regex : "[\\])}]"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }
+ ],
+ "qqstring" : [
+ {
+ token : "string",
+ regex : '(?=(?:(?:\\\\.)|(?:[^:]))*?:)',
+ next : "start"
+ }, {
+ token : "string",
+ merge : true,
+ regex : '.+'
+ }
+ ]}
+
+};
+
+oop.inherits(YamlHighlightRules, TextHighlightRules);
+
+exports.YamlHighlightRules = YamlHighlightRules;
+});
+
+define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
+
+
+var Range = require("../range").Range;
+
+var MatchingBraceOutdent = function() {};
+
+(function() {
+
+ this.checkOutdent = function(line, input) {
+ if (! /^\s+$/.test(line))
+ return false;
+
+ return /^\s*\}/.test(input);
+ };
+
+ this.autoOutdent = function(doc, row) {
+ var line = doc.getLine(row);
+ var match = line.match(/^(\s*\})/);
+
+ if (!match) return 0;
+
+ var column = match[1].length;
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
+
+ if (!openBracePos || openBracePos.row == row) return 0;
+
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
+ doc.replace(new Range(row, 0, row, column-1), indent);
+ };
+
+ this.$getIndent = function(line) {
+ var match = line.match(/^(\s+)/);
+ if (match) {
+ return match[1];
+ }
+
+ return "";
+ };
+
+}).call(MatchingBraceOutdent.prototype);
+
+exports.MatchingBraceOutdent = MatchingBraceOutdent;
+});
View
9 plugins-client/lib.ace/www/worker/worker-xquery.js
9 additions, 0 deletions not shown
View
3  plugins-client/lib.apf/www/apf-packaged/apf_release.js
@@ -66594,7 +66594,8 @@ apf.webdav = function(struct, tagName){
aCont.push("</D:", reportName, ">");
this.method = "REPORT";
- this.doRequest(function(data, state, extra) {
+
+ return this.doRequest(function(data, state, extra) {
var iStatus = parseInt(extra.status, 10);
if (state != apf.SUCCESS) {
var oError = WebDAVError.call(this, "Unable to fetch report on '" + sPath
View
1  plugins-client/lib.apf/www/apf/elements/codeeditor.js
@@ -39,6 +39,7 @@
define(function(require, exports, module) {
"use strict";
+var ide = require("core/ide");
var Editor = require("ace/editor").Editor;
var EditSession = require("ace/edit_session").EditSession;
var VirtualRenderer = require("ace/virtual_renderer").VirtualRenderer;
View
2  plugins-client/lib.packed/package.json
@@ -4,7 +4,7 @@
"main": "packed-plugin.js",
"private": true,
"plugin": {
- "provides": [ ],
+ "provides": ["client.cloud9","client.apf","client.ace","client.treehugger","client.v8debug"],
"consumes": [
"static"
]
View
6 plugins-client/lib.packed/packed-plugin.js
@@ -11,6 +11,10 @@ module.exports = function setup(options, imports, register) {
}]);
register(null, {
-
+ "client.cloud9": {},
+ "client.apf": {},
+ "client.ace": {},
+ "client.treehugger": {},
+ "client.v8debug": {}
});
};
View
10 plugins-server/cloud9.core/ide.js
@@ -30,7 +30,6 @@ var Ide = module.exports = function(options) {
this.workspaceDir = options.workspaceDir;
-
options.plugins = options.plugins || [];
this.options = {
workspaceDir: this.workspaceDir,
@@ -57,7 +56,7 @@ var Ide = module.exports = function(options) {
this.nodeCmd = options.exec || process.execPath;
this.workspace = new Workspace(this);
-
+
var _self = this;
this.router = connect.router(function(app) {
app.get(/^(\/|\/index.html?)$/, function(req, res, next) {
@@ -98,7 +97,7 @@ util.inherits(Ide, EventEmitter);
"cache-control": "no-transform",
"Content-Type": "text/html"
});
-
+
var permissions = _self.getPermissions(req);
var plugins = c9util.arrayToMap(_self.options.plugins);
var bundledPlugins = c9util.arrayToMap(_self.options.bundledPlugins);
@@ -133,7 +132,7 @@ util.inherits(Ide, EventEmitter);
readonly: (permissions.fs !== "rw"),
requirejsConfig: _self.options.requirejsConfig,
settingsXml: "",
- scripts: (_self.options.debug || _self.options.real) ? "" : aceScripts,
+ scripts: (_self.options.debug || _self.options.packed) ? "" : aceScripts,
projectName: _self.options.projectName,
version: _self.options.version,
hosted: _self.options.hosted.toString(),
@@ -212,12 +211,13 @@ util.inherits(Ide, EventEmitter);
this.getPermissions = function(req) {
var user = this.getUser(req);
+
if (!user)
return User.VISITOR_PERMISSIONS;
else
return user.getPermissions();
};
-
+
this.hasUser = function(username) {
return !!this.$users[username];
};
View
2  plugins-server/cloud9.core/view/ide.tmpl.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://ajax.org/2005/aml" skipParse=[%real%]>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://ajax.org/2005/aml" skipParse=[%packed%]>
<head profile="http://www.w3.org/2005/10/profile">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>[%projectName%] - Cloud9</title>
View
10 scripts/build-debug.js
@@ -0,0 +1,10 @@
+var exec = require("child_process").exec;
+
+exec("make apfdebug", function (error, stdout, stderr) {
+ if (error) {
+ console.error(stderr);
+ process.exit(1);
+ }
+
+ console.log(stdout);
+});
View
15 scripts/build-packed.js
@@ -0,0 +1,15 @@
+var spawn = require('child_process').spawn;
+var pack = spawn('make', ['package']);
+
+pack.stderr.setEncoding("utf8");
+
+pack.stderr.on('data', function (data) {
+ console.error(data);
+});
+
+pack.on('exit', function (code) {
+ if (code !== 0) {
+ console.error('grep process exited with code ' + code);
+ process.exit(code);
+ }
+});
View
112 server.js 100755 → 100644
@@ -2,6 +2,7 @@
var path = require('path');
var architect = require("architect");
+var spawn = require("child_process").spawn;
// TODO: Need better args parser.
@@ -10,41 +11,96 @@ var configName = process.argv[2] || "default";
// when command line arguments are passed into this, we ignore them
// when loading the config file.
if (configName.indexOf("-") === 0) {
- configName = "default";
+ configName = "default";
}
var debug = false;
var packed = false;
var packedName = "";
+
for (var p = 2; p < process.argv.length; p++) {
- if (process.argv[p] == "-d") {
- debug = true;
- }
+ if (process.argv[p] === "-d") {
+ debug = true;
+
+ if(!path.existsSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js")) {
+ console.log("Building apfdebug for first run...");
+
+ var buildDebug = spawn("npm", ["run-script", "build-debug"]);
+
+ buildDebug.stderr.setEncoding("utf8");
+ buildDebug.stderr.on('data', function (data) {
+ console.error(data);
+ });
+ buildDebug.on('exit', function (code) {
+ if (code !== 0) {
+ console.error('build-debug process exited with code ' + code);
+ process.exit(code);
+ }
+ boot();
+ });
+ }
+ else
+ boot();
+ }
- else if (process.argv[p] == "-P") {
- packed = true;
- if (process.argv[p + 1].indexOf("-") < 0) // use this specific packed file
+ else if (process.argv[p] === "-P") {
+ packed = true;
+ if (process.argv[p + 1] && process.argv[p + 1].indexOf("-") < 0) // use this specific packed file
packedName = process.argv[++p];
- }
+ else
+ packedName = "packed.js";
+
+ configName = "packed";
+
+ if(!path.existsSync("plugins-client/lib.packed/www/" + packedName)) {
+ console.log("Building packed file for first run...Please wait...");
+ console.log(" |\\ _,,,---,,_\n"+
+ " /,`.-'`' -. ;-;;,_\n" +
+ " |,4- ) )-,_..;\\ ( `'-'\n" +
+ " '---''(_/--' `-'\\_) Felix Lee");
+
+ var buildPackage = spawn("npm", ["run-script", "build-packed"]);
+
+ buildPackage.stderr.setEncoding("utf8");
+ buildPackage.stderr.on('data', function (data) {
+ console.error(data);
+ });
+ buildPackage.on('exit', function (code) {
+ if (code !== 0) {
+ console.error('build-package process exited with code ' + code);
+ process.exit(code);
+ }
+ boot();
+ });
+ }
+ else
+ boot();
+ }
}
-var configPath = path.resolve(__dirname, "./configs/", configName);
-var config = require(configPath);
-
-config.containers.master.plugins.forEach(function(plugin) {
- if (plugin.packagePath && /\/cloud9.core$/.test(plugin.packagePath)) {
- plugin.debug = debug;
- plugin.packed = packed;
- plugin.packedName = packedName;
- }
-});
-
-architect.createApp(config, {
- console: ((debug)?console:null)
-}, function (err, app) {
- if (err) {
- console.error("While starting the '%s':", configPath);
- throw err;
- }
- console.log("Started '%s'!", configPath);
-});
+if (debug == false && packed == false)
+ boot();
+
+function boot() {
+ var configPath = path.resolve(__dirname, "./configs/", configName);
+ var config = require(configPath);
+
+ // server plugins
+ config.containers.master.plugins.forEach(function(plugin) {
+ if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
+ plugin.debug = debug;
+ plugin.packed = packed;
+ plugin.packedName = packedName;
+ }
+ });
+
+ architect.createApp(config, {
+ console: ((debug)?console:null)
+ }, function (err, app) {
+ if (err) {
+ console.error("While starting the '%s':", configPath);
+ throw err;
+ }
+ console.log("Started '%s'!", configPath);
+ });
+}
Something went wrong with that request. Please try again.