kopia lustrzana https://github.com/c9/core
Merge pull request +6023 from c9/profile-integration
[WIP] Profile Pages milestone 1pull/39/head^2
rodzic
7af49ff62b
commit
584e691a3f
|
@ -1,44 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
var Url = require("url");
|
||||
require("amd-loader");
|
||||
|
||||
var Fs = require("fs");
|
||||
var Path = require("path");
|
||||
var exec = require("child_process").exec;
|
||||
exports.parse = require("./git_url_parse");
|
||||
|
||||
exports.isValidUrl = function(url) {
|
||||
return !!exports.parse(url);
|
||||
};
|
||||
|
||||
exports.parse = function(url) {
|
||||
var m = url.match(/^(git)@([\w\.\d\-\_]+)(?:\/|:)([\w\.\d\-\_\/]+)/);
|
||||
if (m) {
|
||||
return {
|
||||
protocol: "ssh:",
|
||||
auth: m[1],
|
||||
hostname: m[2],
|
||||
pathname: m[3]
|
||||
};
|
||||
}
|
||||
|
||||
var parsed = Url.parse(url);
|
||||
if (
|
||||
parsed &&
|
||||
parsed.protocol &&
|
||||
parsed.protocol.match(/^(git|http|https):$/) &&
|
||||
parsed.hostname &&
|
||||
parsed.slashes &&
|
||||
parsed.pathname
|
||||
)
|
||||
return {
|
||||
protocol: parsed.protocol,
|
||||
auth: parsed.auth || "",
|
||||
hostname: parsed.hostname,
|
||||
pathname: parsed.pathname.replace(/^\/+/, ""),
|
||||
full: url
|
||||
};
|
||||
else
|
||||
return null;
|
||||
};
|
||||
|
||||
exports.getHeadRevision = function(path, callback) {
|
||||
exec("git rev-parse HEAD", {
|
||||
|
|
|
@ -62,7 +62,7 @@ module.exports = {
|
|||
assert.equal(rev.length, 40);
|
||||
|
||||
next();
|
||||
},
|
||||
},
|
||||
|
||||
"test get head branch": function(next) {
|
||||
git.getHeadBranch(__dirname, function(err, rev) {
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Url = require("url");
|
||||
|
||||
module.exports = function(url) {
|
||||
var m = url.match(/^(git)@([\w\.\d\-\_]+)(?:\/|:)([\w\.\d\-\_\/]+)/);
|
||||
if (m) {
|
||||
return {
|
||||
protocol: "ssh:",
|
||||
auth: m[1],
|
||||
hostname: m[2],
|
||||
pathname: m[3]
|
||||
};
|
||||
}
|
||||
|
||||
var parsed = Url.parse(url);
|
||||
if (
|
||||
parsed &&
|
||||
parsed.protocol &&
|
||||
parsed.protocol.match(/^(git|http|https):$/) &&
|
||||
parsed.hostname &&
|
||||
parsed.slashes &&
|
||||
parsed.pathname
|
||||
)
|
||||
return {
|
||||
protocol: parsed.protocol,
|
||||
auth: parsed.auth || "",
|
||||
hostname: parsed.hostname,
|
||||
pathname: parsed.pathname.replace(/^\/+/, ""),
|
||||
full: url
|
||||
};
|
||||
else
|
||||
return null;
|
||||
};
|
||||
});
|
|
@ -1157,6 +1157,7 @@ module.exports = function setup(fsOptions) {
|
|||
}
|
||||
|
||||
try {
|
||||
removeFromList();
|
||||
fileWatchers[path] = fileWatchers[path] || [];
|
||||
fileWatchers[path].push(_self);
|
||||
|
||||
|
@ -1234,14 +1235,15 @@ module.exports = function setup(fsOptions) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleWatchEvent(event, filename) {
|
||||
console.log("watch event", event, filename, path);
|
||||
var handleWatchEvent = this.handleWatchEvent = function(event, filename, isVfsWrite) {
|
||||
// it is a temp file
|
||||
if (filename && filename.substr(-1) == "~"
|
||||
&& filename.charAt(0) == ".")
|
||||
return;
|
||||
|
||||
createStatEntry(pathBasename(path), path, function(entry) {
|
||||
entry.vfsWrite = isVfsWrite || false;
|
||||
|
||||
if (entry.err) {
|
||||
event = "delete";
|
||||
close();
|
||||
|
@ -1292,7 +1294,7 @@ module.exports = function setup(fsOptions) {
|
|||
}
|
||||
|
||||
var sendToAllListeners = this.sendToAllListeners = function(event, filename, entry, files) {
|
||||
listeners.forEach(function(fn){
|
||||
listeners.forEach(function(fn) {
|
||||
fn(event, filename, entry, files);
|
||||
});
|
||||
};
|
||||
|
@ -1368,27 +1370,33 @@ module.exports = function setup(fsOptions) {
|
|||
function writeToWatchedFile(path, callback) {
|
||||
if (!fileWatchers[path])
|
||||
return callback(function(c) { c(); });
|
||||
|
||||
var watchers = fileWatchers[path].slice();
|
||||
var parentDir = dirname(path) + "/";
|
||||
var dirWatchers = (fileWatchers[parentDir] || []).slice();
|
||||
|
||||
watchers.forEach(function(w) {
|
||||
w.pause();
|
||||
});
|
||||
callback(done);
|
||||
|
||||
function done(callback) {
|
||||
function loop(watchers, path, event, callback) {
|
||||
if (!watchers.length)
|
||||
return callback();
|
||||
|
||||
// Notify each watcher of changes and reactivate it
|
||||
|
||||
var watcher = watchers.pop();
|
||||
fs.stat(path, function(err, stat) {
|
||||
if (err || !stat) return;
|
||||
stat.vfsWrite = true;
|
||||
watcher.sendToAllListeners("change", basename(path), stat);
|
||||
});
|
||||
watcher.handleWatchEvent(event, basename(path), true);
|
||||
|
||||
watcher.resume(function() {
|
||||
done(callback);
|
||||
loop(watchers, path, event, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function done(callback) {
|
||||
loop(watchers, path, "change", function() {
|
||||
loop(dirWatchers, parentDir, "directory", callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function connect(port, options, callback) {
|
||||
|
|
|
@ -175,33 +175,39 @@ define(function(require, exports, module) {
|
|||
if (WAIT_FOR_SIGNAL)
|
||||
ignore(path, 200);
|
||||
// console.warn("[watchers] ignored event for", path, stat.vfsWrite ? "(was vfsWrite)" : "(was on ignore list)");
|
||||
return;
|
||||
|
||||
fireWatcherEvent(".all");
|
||||
} else {
|
||||
fireWatcherEvent("");
|
||||
fireWatcherEvent(".all");
|
||||
}
|
||||
|
||||
if (event == "error") {
|
||||
// console.error("[watchers] received error for", path, err, stat);
|
||||
}
|
||||
else if (event == "delete") {
|
||||
fs.unwatch(path, handler);
|
||||
delete handlers[path];
|
||||
// console.log("[watchers] received", event, "event for", path, stat);
|
||||
emit("delete", { path : path });
|
||||
}
|
||||
else if (event == "directory") {
|
||||
emit("directory", {
|
||||
path: path,
|
||||
files: files,
|
||||
stat: stat
|
||||
});
|
||||
}
|
||||
else {
|
||||
// console.log("[watchers] received", event, "event for", path, stat);
|
||||
emit("change", {
|
||||
type: event, //change || rename
|
||||
filename: filename,
|
||||
path: path,
|
||||
stat: stat
|
||||
});
|
||||
function fireWatcherEvent(eventSuffix) {
|
||||
if (event == "error") {
|
||||
// console.error("[watchers] received error for", path, err, stat);
|
||||
}
|
||||
else if (event == "delete") {
|
||||
fs.unwatch(path, handler);
|
||||
delete handlers[path];
|
||||
// console.log("[watchers] received", event, "event for", path, stat);
|
||||
emit("delete" + eventSuffix, { path : path });
|
||||
}
|
||||
else if (event == "directory") {
|
||||
emit("directory" + eventSuffix, {
|
||||
path: path,
|
||||
files: files,
|
||||
stat: stat
|
||||
});
|
||||
}
|
||||
else {
|
||||
// console.log("[watchers] received", event, "event for", path, stat);
|
||||
emit("change" + eventSuffix, {
|
||||
type: event, // change || rename
|
||||
filename: filename,
|
||||
path: path,
|
||||
stat: stat
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -206,12 +206,7 @@ function main(options, imports, register) {
|
|||
|
||||
function sharedModules() {
|
||||
return [
|
||||
"lib/architect/architect",
|
||||
"ace/mode/html",
|
||||
"ace/mode/javascript",
|
||||
"ace/mode/css",
|
||||
"ace/mode/c9search",
|
||||
"ace/multi_select"
|
||||
"lib/architect/architect"
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ if (!module.parent) {
|
|||
.boolean("symlink")
|
||||
.describe("compress", "Compress output files")
|
||||
.boolean("compress")
|
||||
.describe("react-style", "compile react less CSS")
|
||||
.boolean("react-style")
|
||||
.describe("dest", "destination folder for the static files")
|
||||
.boolean("help")
|
||||
.describe("help", "Show command line options.");
|
||||
|
@ -68,6 +70,19 @@ function main(config, settings, options, callback) {
|
|||
compress: options.compress,
|
||||
virtual: options.virtual
|
||||
})
|
||||
.concat({
|
||||
consumes: [],
|
||||
provides: ["cdn.build", "db"],
|
||||
setup: function(options, imports, register) {
|
||||
register(null, { "cdn.build": {}, "db": {
|
||||
"Vfs": {
|
||||
findAllAndPurge: function(maxVfsAge, callback) {
|
||||
callback(null, [{}]);
|
||||
}
|
||||
}
|
||||
} });
|
||||
}
|
||||
})
|
||||
.filter(function(p) {
|
||||
var path = p.packagePath;
|
||||
return !path || path.indexOf("c9.db.redis/redis") == -1
|
||||
|
@ -100,6 +115,12 @@ function main(config, settings, options, callback) {
|
|||
app.services.makestatic.getMounts(options.dest, callback);
|
||||
else if (options.symlink)
|
||||
app.services.makestatic.symlink(options.dest, callback);
|
||||
else if (options["react-style"])
|
||||
app.services["react.style"].compile(function(err, code) {
|
||||
if (err) return callback(err);
|
||||
console.log(code);
|
||||
callback();
|
||||
});
|
||||
else
|
||||
app.services.makestatic.copy(options.dest, callback);
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue