Skip to content

Commit 19a7fe9

Browse files
lennartclnightwing
authored andcommitted
Update to 2.1
1 parent ab69386 commit 19a7fe9

File tree

295 files changed

+95325
-53694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+95325
-53694
lines changed

.npmignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

HELP.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

bin/cloud9.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
CMD_DIR="$( cd "$( dirname "$0" )" && pwd )"
44
cd "$CMD_DIR/.."
55

6-
make update
6+
make worker
77

88
case `uname -a` in
99
Linux*x86_64*) echo "Linux 64 bit"

bin/run.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/runjs.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

build/app.build.tmpl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"msgpack-js": "empty:",
1919
"v8debug": "empty:",
2020
"apf/elements": "%d/lib.apf/www/apf/elements",
21-
"ace/worker": "%a",
21+
"ace": "%a",
2222
"%m"
2323
},
2424

build/core.build.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
packages: [
1818
{
1919
"name": "engine.io",
20-
"location": "node_modules/smith.io/node_modules/engine.io/node_modules/engine.io-client/dist",
21-
"main": "engine.io-dev.js"
20+
"location": "node_modules/engine.io-client",
21+
"main": "engine.io.js"
2222
},
2323
{
2424
"name": "smith.io",
25-
"location": "node_modules/smith.io/server-plugin/www",
25+
"location": "plugins-server/c9.smith.io/www",
2626
"main": "client.js"
2727
},
2828
{
@@ -32,7 +32,7 @@
3232
},
3333
{
3434
"name": "msgpack-js",
35-
"location": "node_modules/smith.io/node_modules/msgpack-js-browser",
35+
"location": "node_modules/msgpack-js-browser",
3636
"main": "msgpack.js"
3737
}
3838
],
@@ -66,9 +66,9 @@
6666
"core/document",
6767
"core/ext",
6868
"core/ide",
69-
"core/settings",
70-
"core/util",
71-
"ext/main/main",
69+
"core/settings",
70+
"core/util",
71+
"ext/main/main",
7272
"treehugger/traverse",
7373
"treehugger/js/parse",
7474
"v8debug/util",

build/packed_helper.cloud9.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
var fs = require('fs');
3+
4+
var config = require("../configs/default.js");
5+
var extensions;
6+
7+
for (var c in config) {
8+
if (config[c].clientPlugins) {
9+
extensions = config[c].clientPlugins;
10+
break;
11+
}
12+
}
13+
14+
var clientPlugins = [ ];
15+
var clientMappings = [ ];
16+
17+
var arguments = process.argv.splice(2);
18+
var isClean = parseInt(arguments[0]);
19+
20+
//console.log(extensions);
21+
22+
for (var e in extensions) {
23+
var name = extensions[e].split("/")[1];
24+
25+
if (name === "log")
26+
continue;
27+
28+
var dir = "plugins-client/ext." + name;
29+
var mapping = "ext/" + name;
30+
31+
clientMappings.push(mapping + "': '" + dir);
32+
clientPlugins.push(mapping + "/" + name);
33+
}
34+
35+
clientMappings.push("ext/uploadfiles': 'plugins-client/ext.uploadfiles"); // TODO: why is this not automatically added?
36+
clientPlugins = "'" + clientPlugins.join("',\n\t'") + "'";
37+
clientMappings = "'" + clientMappings.join("',\n\t'") + "'";
38+
39+
var appTemplate = fs.readFileSync("./build/app.build.tmpl.js", "utf8");
40+
41+
// transform all variable paths out
42+
var appFile = appTemplate.replace(/%b/g, "build").replace(/%d/g, "plugins-client").replace('"%a"', '"node_modules/ace/lib/ace"').replace('"%s"', clientPlugins).replace('"%m"', clientMappings).replace('"%o"', '"../plugins-client/lib.packed/www/c9os.min.js"');
43+
44+
if (isClean)
45+
appFile = appFile.replace(/\/\/\s*optimize/, 'optimize');
46+
47+
fs.writeFile("./build/app.build.js", appFile, "utf8", function(err) {
48+
if (err) {
49+
console.error("Couldn't write app.build.js!")
50+
console.error(err);
51+
process.exit(1);
52+
}
53+
});

build/packed_helper.js

Lines changed: 135 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,152 @@
1-
21
var fs = require('fs');
2+
var path = require('path');
3+
4+
var outDir = __dirname + "/src/";
5+
var arguments = process.argv.splice(2);
6+
var isClean = parseInt(arguments[0], 10);
37

4-
var config = require("../configs/default.js");
5-
var extensions;
8+
var templates = fs.readdirSync(path.resolve(__dirname + "/../configs/ide-templates"));
69

7-
for (var c in config) {
8-
if (config[c].clientPlugins) {
9-
extensions = config[c].clientPlugins;
10-
break;
10+
// create a dummy object so require(tmplPath) doesn't complain
11+
var project = {
12+
remote: {
13+
metadata: {
14+
connect: {
15+
host: ""
16+
},
17+
system: {
18+
home: ""
19+
},
20+
node: {}
21+
}
1122
}
12-
}
1323

14-
var clientPlugins = [ ];
15-
var clientMappings = [ ];
24+
};
1625

17-
var arguments = process.argv.splice(2);
18-
var isClean = parseInt(arguments[0]);
26+
var options = {
27+
collab : {
28+
env : ""
29+
},
30+
static: {
31+
staticUrlPrefix: ""
32+
}
33+
};
34+
35+
var pluginList = require(path.resolve(__dirname + "/../configs/client_plugins"));
36+
37+
for (var f in templates) {
38+
var tmplPath = path.resolve(__dirname + "/../configs/ide-templates/" + templates[f]);
39+
console.log("Reading " + tmplPath);
40+
var tmplFile = require(tmplPath)("blank", project, pluginList, options);
41+
42+
var idePlugin = tmplFile.plugins.filter(function(plugin) {
43+
return plugin.packagePath && plugin.packagePath.indexOf("cloud9.core") !== -1;
44+
})[0];
45+
var scmPluginList = idePlugin.clientPlugins;
46+
47+
if (templates[f] === "openshift.js")
48+
scmPluginList.push("ext/strongloop/strongloop");
1949

20-
//console.log(extensions);
50+
scmPluginList = scmPluginList.filter(function(p) {
51+
if (p === "ext/log/log")
52+
return false;
53+
return true;
54+
});
2155

22-
for (var e in extensions) {
23-
var name = extensions[e].split("/")[1];
56+
rewriteMappings(templates[f], scmPluginList, function(err, plugins, mappings) {
57+
if (err) {
58+
console.error(err);
59+
process.exit(1);
60+
}
2461

25-
if (name === "log")
26-
continue;
62+
createBuildFile(templates[f], plugins, eliminateDuplicates(mappings));
63+
});
64+
}
65+
66+
function rewriteMappings(type, pluginList, callback) {
67+
var pluginMappings = [ ];
68+
pluginList = eliminateDuplicates(pluginList);
69+
70+
// rewrite mappings for build file
71+
for (var l in pluginList) {
72+
var name = pluginList[l].split("/")[1];
73+
var dir = "";
74+
var c9Prefix = "../plugins-client/ext.";
75+
var infraPrefix = "../plugins-client/ext.";
76+
77+
if (!path.existsSync(path.normalize(__dirname + "/" + c9Prefix + name))) {
78+
//console.warn("Couldn't find " + path.normalize(__dirname + "/" + c9Prefix + name) + "; looking elsewhere...");
79+
if (!path.existsSync(path.normalize(__dirname + "/" + infraPrefix + name))) {
80+
//console.warn("Couldn't find " + path.normalize(__dirname + "/" + infraPrefix + name) + "; looking elsewhere...");
81+
82+
console.error("We have a problem. I have no idea where " + name + " is referenced.");
83+
console.error("I'm in " + __dirname + "!");
84+
console.error("I tried " + c9Prefix + name + "!");
85+
console.error("I tried " + infraPrefix + name + "!");
86+
process.exit(1);
87+
}
88+
else
89+
dir = infraPrefix + name;
90+
}
91+
else
92+
dir = c9Prefix + name;
93+
94+
var mapping = "ext/" + name;
2795

28-
var dir = "plugins-client/ext." + name;
29-
var mapping = "ext/" + name;
96+
pluginMappings.push("'" + mapping + "': '" + dir + "'");
97+
}
3098

31-
clientMappings.push(mapping + "': '" + dir);
32-
clientPlugins.push(mapping + "/" + name);
99+
if (type == "ftp.js") {
100+
// otherwise, packager cries and breaks for missing dependencies
101+
pluginMappings.push("'ext/gotofile': '" + c9Prefix + "gotofile'");
102+
pluginMappings.push("'ext/searchinfiles': '" + c9Prefix + "searchinfiles'");
103+
pluginMappings.push("'ext/noderunner': '" + c9Prefix + "noderunner'");
104+
pluginMappings.push("'ext/language': '" + c9Prefix + "language'");
105+
}
106+
107+
callback(null, "'" + pluginList.join("',\n\t'") + "'", pluginMappings);
33108
}
34109

35-
clientMappings.push("ext/uploadfiles': 'plugins-client/ext.uploadfiles"); // TODO: why is this not automatically added?
36-
clientPlugins = "'" + clientPlugins.join("',\n\t'") + "'";
37-
clientMappings = "'" + clientMappings.join("',\n\t'") + "'";
110+
function createBuildFile(configName, plugins, mappings) {
111+
fs.readFile("./build/app.build.tmpl.js", "utf8", function(err, template) {
112+
if (err) {
113+
console.error("Couldn't read app.build.tmpl.js!");
114+
console.error(err);
115+
process.exit(1);
116+
}
117+
var newBuildFile = template
118+
.replace(/%b/g, "../build")
119+
.replace('"%a"', '"../node_modules/ace/lib/ace"')
120+
.replace(/%d/g, '../plugins-client')
121+
.replace('"%s"', plugins)
122+
.replace('"%m"', mappings.join(",\n\t"))
123+
.replace('"%o"', '"../../plugins-client/lib.packed/www/' + configName.replace(".js", ".min.js") + '"');
38124

39-
var appTemplate = fs.readFileSync("./build/app.build.tmpl.js", "utf8");
125+
if (isClean)
126+
newBuildFile = newBuildFile.replace(/\/\/\s*optimize/, 'optimize');
40127

41-
// transform all variable paths out
42-
var appFile = appTemplate.replace(/%b/g, "build").replace(/%d/g, "plugins-client").replace('"%a"', '"node_modules/ace/lib/ace/worker"').replace('"%s"', clientPlugins).replace('"%m"', clientMappings).replace('"%o"', '"../plugins-client/lib.packed/www/c9os.min.js"');
128+
fs.writeFile(outDir + "/app.build." + configName, newBuildFile, "utf8", function(err) {
129+
if (err) {
130+
console.error("Couldn't write app.build." + configName + ".js!");
131+
console.error(err);
132+
process.exit(1);
133+
}
134+
});
135+
});
136+
}
43137

44-
if (isClean)
45-
appFile = appFile.replace(/\/\/\s*optimize/, 'optimize');
138+
// r.js hates duplicates
139+
function eliminateDuplicates(arr) {
140+
var i,
141+
len=arr.length,
142+
out=[],
143+
obj={};
46144

47-
fs.writeFile("./build/app.build.js", appFile, "utf8", function(err) {
48-
if (err) {
49-
console.error("Couldn't write app.build.js!")
50-
console.error(err);
51-
process.exit(1);
52-
}
53-
});
145+
for (i=0;i<len;i++) {
146+
obj[arr[i]]=0;
147+
}
148+
for (i in obj) {
149+
out.push(i);
150+
}
151+
return out;
152+
}

0 commit comments

Comments
 (0)