kopia lustrzana https://github.com/c9/core
Revert "Revert "Merge pull request +6023 from c9/profile-integration""
This reverts commit e6fc5d467d
.
pull/39/head^2
rodzic
e6fc5d467d
commit
3f2dd4cf25
|
@ -1,44 +1,16 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Url = require("url");
|
require("amd-loader");
|
||||||
|
|
||||||
var Fs = require("fs");
|
var Fs = require("fs");
|
||||||
var Path = require("path");
|
var Path = require("path");
|
||||||
var exec = require("child_process").exec;
|
var exec = require("child_process").exec;
|
||||||
|
exports.parse = require("./git_url_parse");
|
||||||
|
|
||||||
exports.isValidUrl = function(url) {
|
exports.isValidUrl = function(url) {
|
||||||
return !!exports.parse(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) {
|
exports.getHeadRevision = function(path, callback) {
|
||||||
exec("git rev-parse HEAD", {
|
exec("git rev-parse HEAD", {
|
||||||
|
|
|
@ -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 {
|
try {
|
||||||
|
removeFromList();
|
||||||
fileWatchers[path] = fileWatchers[path] || [];
|
fileWatchers[path] = fileWatchers[path] || [];
|
||||||
fileWatchers[path].push(_self);
|
fileWatchers[path].push(_self);
|
||||||
|
|
||||||
|
@ -1234,14 +1235,15 @@ module.exports = function setup(fsOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWatchEvent(event, filename) {
|
var handleWatchEvent = this.handleWatchEvent = function(event, filename, isVfsWrite) {
|
||||||
console.log("watch event", event, filename, path);
|
|
||||||
// it is a temp file
|
// it is a temp file
|
||||||
if (filename && filename.substr(-1) == "~"
|
if (filename && filename.substr(-1) == "~"
|
||||||
&& filename.charAt(0) == ".")
|
&& filename.charAt(0) == ".")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
createStatEntry(pathBasename(path), path, function(entry) {
|
createStatEntry(pathBasename(path), path, function(entry) {
|
||||||
|
entry.vfsWrite = isVfsWrite || false;
|
||||||
|
|
||||||
if (entry.err) {
|
if (entry.err) {
|
||||||
event = "delete";
|
event = "delete";
|
||||||
close();
|
close();
|
||||||
|
@ -1292,7 +1294,7 @@ module.exports = function setup(fsOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var sendToAllListeners = this.sendToAllListeners = function(event, filename, entry, files) {
|
var sendToAllListeners = this.sendToAllListeners = function(event, filename, entry, files) {
|
||||||
listeners.forEach(function(fn){
|
listeners.forEach(function(fn) {
|
||||||
fn(event, filename, entry, files);
|
fn(event, filename, entry, files);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1368,25 +1370,31 @@ module.exports = function setup(fsOptions) {
|
||||||
function writeToWatchedFile(path, callback) {
|
function writeToWatchedFile(path, callback) {
|
||||||
if (!fileWatchers[path])
|
if (!fileWatchers[path])
|
||||||
return callback(function(c) { c(); });
|
return callback(function(c) { c(); });
|
||||||
|
|
||||||
var watchers = fileWatchers[path].slice();
|
var watchers = fileWatchers[path].slice();
|
||||||
|
var parentDir = dirname(path) + "/";
|
||||||
|
var dirWatchers = (fileWatchers[parentDir] || []).slice();
|
||||||
|
|
||||||
watchers.forEach(function(w) {
|
watchers.forEach(function(w) {
|
||||||
w.pause();
|
w.pause();
|
||||||
});
|
});
|
||||||
callback(done);
|
callback(done);
|
||||||
|
|
||||||
function done(callback) {
|
function loop(watchers, path, event, callback) {
|
||||||
if (!watchers.length)
|
if (!watchers.length)
|
||||||
return callback();
|
return callback();
|
||||||
|
|
||||||
// Notify each watcher of changes and reactivate it
|
|
||||||
var watcher = watchers.pop();
|
var watcher = watchers.pop();
|
||||||
fs.stat(path, function(err, stat) {
|
watcher.handleWatchEvent(event, basename(path), true);
|
||||||
if (err || !stat) return;
|
|
||||||
stat.vfsWrite = true;
|
|
||||||
watcher.sendToAllListeners("change", basename(path), stat);
|
|
||||||
});
|
|
||||||
watcher.resume(function() {
|
watcher.resume(function() {
|
||||||
done(callback);
|
loop(watchers, path, event, callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function done(callback) {
|
||||||
|
loop(watchers, path, "change", function() {
|
||||||
|
loop(dirWatchers, parentDir, "directory", callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,9 +175,14 @@ define(function(require, exports, module) {
|
||||||
if (WAIT_FOR_SIGNAL)
|
if (WAIT_FOR_SIGNAL)
|
||||||
ignore(path, 200);
|
ignore(path, 200);
|
||||||
// console.warn("[watchers] ignored event for", path, stat.vfsWrite ? "(was vfsWrite)" : "(was on ignore list)");
|
// console.warn("[watchers] ignored event for", path, stat.vfsWrite ? "(was vfsWrite)" : "(was on ignore list)");
|
||||||
return;
|
|
||||||
|
fireWatcherEvent(".all");
|
||||||
|
} else {
|
||||||
|
fireWatcherEvent("");
|
||||||
|
fireWatcherEvent(".all");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fireWatcherEvent(eventSuffix) {
|
||||||
if (event == "error") {
|
if (event == "error") {
|
||||||
// console.error("[watchers] received error for", path, err, stat);
|
// console.error("[watchers] received error for", path, err, stat);
|
||||||
}
|
}
|
||||||
|
@ -185,10 +190,10 @@ define(function(require, exports, module) {
|
||||||
fs.unwatch(path, handler);
|
fs.unwatch(path, handler);
|
||||||
delete handlers[path];
|
delete handlers[path];
|
||||||
// console.log("[watchers] received", event, "event for", path, stat);
|
// console.log("[watchers] received", event, "event for", path, stat);
|
||||||
emit("delete", { path : path });
|
emit("delete" + eventSuffix, { path : path });
|
||||||
}
|
}
|
||||||
else if (event == "directory") {
|
else if (event == "directory") {
|
||||||
emit("directory", {
|
emit("directory" + eventSuffix, {
|
||||||
path: path,
|
path: path,
|
||||||
files: files,
|
files: files,
|
||||||
stat: stat
|
stat: stat
|
||||||
|
@ -196,13 +201,14 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// console.log("[watchers] received", event, "event for", path, stat);
|
// console.log("[watchers] received", event, "event for", path, stat);
|
||||||
emit("change", {
|
emit("change" + eventSuffix, {
|
||||||
type: event, //change || rename
|
type: event, // change || rename
|
||||||
filename: filename,
|
filename: filename,
|
||||||
path: path,
|
path: path,
|
||||||
stat: stat
|
stat: stat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,12 +206,7 @@ function main(options, imports, register) {
|
||||||
|
|
||||||
function sharedModules() {
|
function sharedModules() {
|
||||||
return [
|
return [
|
||||||
"lib/architect/architect",
|
"lib/architect/architect"
|
||||||
"ace/mode/html",
|
|
||||||
"ace/mode/javascript",
|
|
||||||
"ace/mode/css",
|
|
||||||
"ace/mode/c9search",
|
|
||||||
"ace/multi_select"
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ if (!module.parent) {
|
||||||
.boolean("symlink")
|
.boolean("symlink")
|
||||||
.describe("compress", "Compress output files")
|
.describe("compress", "Compress output files")
|
||||||
.boolean("compress")
|
.boolean("compress")
|
||||||
|
.describe("react-style", "compile react less CSS")
|
||||||
|
.boolean("react-style")
|
||||||
.describe("dest", "destination folder for the static files")
|
.describe("dest", "destination folder for the static files")
|
||||||
.boolean("help")
|
.boolean("help")
|
||||||
.describe("help", "Show command line options.");
|
.describe("help", "Show command line options.");
|
||||||
|
@ -106,6 +108,12 @@ function main(config, settings, options, callback) {
|
||||||
app.services.makestatic.getMounts(options.dest, callback);
|
app.services.makestatic.getMounts(options.dest, callback);
|
||||||
else if (options.symlink)
|
else if (options.symlink)
|
||||||
app.services.makestatic.symlink(options.dest, callback);
|
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
|
else
|
||||||
app.services.makestatic.copy(options.dest, callback);
|
app.services.makestatic.copy(options.dest, callback);
|
||||||
});
|
});
|
||||||
|
|
Ładowanie…
Reference in New Issue