Merge branch 'master' of github.com:c9/newclient into feature/teams-signup

Conflicts:
	.gitignore
	configs/client-account.js
pull/85/head
Nikolai Onken 2015-04-28 11:00:59 +00:00
commit b4a5c0db74
12 zmienionych plików z 168 dodań i 84 usunięć

Wyświetl plik

@ -122,7 +122,7 @@ var supportedModes = {
Pascal: ["pas|p"], Pascal: ["pas|p"],
Perl: ["pl|pm"], Perl: ["pl|pm"],
pgSQL: ["pgsql"], pgSQL: ["pgsql"],
PHP: ["php|phtml"], PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
Powershell: ["ps1"], Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"], Praat: ["praat|praatscript|psc|proc"],
Prolog: ["plg|prolog"], Prolog: ["plg|prolog"],

Wyświetl plik

@ -144,6 +144,16 @@ module.exports = {
exec("selectleft", 1); exec("selectleft", 1);
exec("insertstring", 1, '"'); exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '("foo")'); assert.equal(editor.getValue(), '("foo")');
editor.setValue("", 1);
exec("selectleft", 1);
exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '""');
exec("insertstring", 1, '\\');
exec("insertstring", 1, 'n');
exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '"\\n"');
}, },
"test: xml": function() { "test: xml": function() {
editor = new Editor(new MockRenderer()); editor = new Editor(new MockRenderer());

Wyświetl plik

@ -269,8 +269,8 @@ var CstyleBehaviour = function() {
if (leftChar == "\\" && token && /escape/.test(token.type)) if (leftChar == "\\" && token && /escape/.test(token.type))
return null; return null;
var stringBefore = token && /string/.test(token.type); var stringBefore = token && /string|escape/.test(token.type);
var stringAfter = !rightToken || /string/.test(rightToken.type); var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
var pair; var pair;
if (rightChar == quote) { if (rightChar == quote) {

Wyświetl plik

@ -17,7 +17,7 @@ function compress(sources, opts) {
if (pkg.file) console.log("Adding '" + pkg.file + "'."); if (pkg.file) console.log("Adding '" + pkg.file + "'.");
toplevel = UglifyJS.parse(pkg.source, { toplevel = UglifyJS.parse(pkg.source, {
filename: pkg.file.replace(new RegExp("^" + opts.basepath + "/"), ""), //@todo remove prefix filename: (pkg.file || pkg.id).replace(new RegExp("^" + opts.basepath + "/"), ""), //@todo remove prefix
toplevel: toplevel toplevel: toplevel
}); });
}); });

Wyświetl plik

@ -199,19 +199,21 @@ dest = "/build/webkitbuilds/app.nw"
var args = ["local","-s", "local"]; var args = ["local","-s", "local"];
*/ */
module.exports = function(options, cb) { module.exports = function(options, cb) {
var dest = convertPath(options.dest); var dest = options.dest && convertPath(options.dest);
var root = convertPath(options.root); var root = convertPath(options.root);
var args = options.args; var args = options.args;
ignore = options.ignore && function(id) { ignore = options.ignore && function(id) {
return options.ignore.test(id); return options.ignore.test(id);
}; };
build(root, args, function(err, result) { build(root, args, function(err, result) {
if (dest) {
var serverSource = fs.readFileSync(root + "/server.js", "utf8"); var serverSource = fs.readFileSync(root + "/server.js", "utf8");
serverSource = serverSource.replace(/^(#.*|"use strict";?|\s)*/, function(a) { serverSource = serverSource.replace(/^(#.*|"use strict";?|\s)*/, function(a) {
return a.trim() + "\n\n" + patchTemplate + "\n\n"; return a.trim() + "\n\n" + patchTemplate + "\n\n";
}); });
fs.writeFileSync(dest + "/server.js", serverSource, "utf8"); fs.writeFileSync(dest + "/server.js", serverSource, "utf8");
fs.writeFileSync(dest + "/module-map.json", JSON.stringify(result.moduleMap), "utf8"); fs.writeFileSync(dest + "/module-map.json", JSON.stringify(result.moduleMap), "utf8");
}
cb(null, result); cb(null, result);
}); });

Wyświetl plik

@ -73,7 +73,7 @@
"c9.ide.ace.repl": "#ada99852fa", "c9.ide.ace.repl": "#ada99852fa",
"c9.ide.ace.split": "#0ae0151c78", "c9.ide.ace.split": "#0ae0151c78",
"c9.ide.ace.statusbar": "#d7b45bb7c3", "c9.ide.ace.statusbar": "#d7b45bb7c3",
"c9.ide.ace.stripws": "#34426a03d1", "c9.ide.ace.stripws": "#cf0f42ac59",
"c9.ide.behaviors": "#6aad7006a0", "c9.ide.behaviors": "#6aad7006a0",
"c9.ide.closeconfirmation": "#a28bfd8272", "c9.ide.closeconfirmation": "#a28bfd8272",
"c9.ide.configuration": "#adf50fdaa2", "c9.ide.configuration": "#adf50fdaa2",
@ -83,7 +83,7 @@
"c9.ide.help.support": "#60e88f5680", "c9.ide.help.support": "#60e88f5680",
"c9.ide.imgeditor": "#08bbc53578", "c9.ide.imgeditor": "#08bbc53578",
"c9.ide.immediate": "#6845a93705", "c9.ide.immediate": "#6845a93705",
"c9.ide.installer": "#4c25b26f70", "c9.ide.installer": "#f8f0d11bff",
"c9.ide.mount": "#32e79866ee", "c9.ide.mount": "#32e79866ee",
"c9.ide.navigate": "#64156c7f4a", "c9.ide.navigate": "#64156c7f4a",
"c9.ide.newresource": "#f1f0624768", "c9.ide.newresource": "#f1f0624768",

Wyświetl plik

@ -1,13 +1,13 @@
PACKAGE_PATH=$1 VERSION="$1"
VERSION=$2 PACKAGE_PATH="$2"
CWD=${PWD} CWD="${PWD}"
if [ ! -d .git ]; then if [ ! -d .git ]; then
echo "$CWD is not a git repository" 1>&2 echo "$CWD is not a git repository" 1>&2
exit 1 exit 1
fi fi
if [ ! -e $PACKAGE_PATH ]; then if [ ! -f "$PACKAGE_PATH" ]; then
echo "Could not find package.json" 1>&2 echo "Could not find package.json" 1>&2
exit 1 exit 1
fi fi

Wyświetl plik

@ -43,6 +43,7 @@ define(function(require, exports, module) {
var verbose = false; var verbose = false;
var force = false; var force = false;
var dryRun = false; var dryRun = false;
var createTag = false;
// Set up basic auth for api if needed // Set up basic auth for api if needed
if (BASICAUTH) api.basicAuth = BASICAUTH; if (BASICAUTH) api.basicAuth = BASICAUTH;
@ -78,16 +79,23 @@ define(function(require, exports, module) {
"description": "Only build a test version", "description": "Only build a test version",
"default": false, "default": false,
"boolean": true "boolean": true
},
"tag" : {
"description": "Create git tag for published version",
"alias": "t",
"default": false,
"boolean": true
} }
}, },
check: function(argv) { check: function(argv) {
if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"]) // if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"])
throw new Error("Missing version"); // throw new Error("Missing version");
}, },
exec: function(argv) { exec: function(argv) {
verbose = argv["verbose"]; verbose = argv["verbose"];
force = argv["force"]; force = argv["force"];
dryRun = argv["dry-run"]; dryRun = argv["dry-run"];
createTag = argv["tag"];
publish( publish(
argv._[1], argv._[1],
@ -372,7 +380,7 @@ define(function(require, exports, module) {
var version = options.version; var version = options.version;
var cwd = process.cwd(); var cwd = process.cwd();
var packagePath = cwd + "/package.json"; var packagePath = cwd + "/package.json";
fs.readFile(packagePath, function(err, data){ fs.readFile(packagePath, "utf8", function(err, data){
if (err) return callback(new Error("ERROR: Could not find package.json in " + cwd)); if (err) return callback(new Error("ERROR: Could not find package.json in " + cwd));
var json; var json;
@ -437,7 +445,7 @@ define(function(require, exports, module) {
if (warned && !force && !dryRun) if (warned && !force && !dryRun)
return callback(new Error("Use --force to ignore these warnings.")); return callback(new Error("Use --force to ignore these warnings."));
if (!dryRun) { if (version) {
var v = (json.version || "0.0.1").split("."); var v = (json.version || "0.0.1").split(".");
// Update the version field in the package.json file // Update the version field in the package.json file
if (version == "major") { if (version == "major") {
@ -458,47 +466,26 @@ define(function(require, exports, module) {
json.version = v.join("."); json.version = v.join(".");
} }
if (dryRun)
return build(); return build();
function updatePackageJSON(next) {
if (!version)
return next();
// Write the package.json file // Write the package.json file
fs.writeFile(packagePath, JSON.stringify(json, null, " "), function(err){ var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2;
var newData = JSON.stringify(json, null, indent);
fs.writeFile(cwd + "/.c9/.build/pacage.json", newData, function(err){
if (dryRun)
return next(); // if dry-run is passed only update path in .build
fs.writeFile(packagePath, newData, function(err){
if (err) return callback(err); if (err) return callback(err);
return next();
if (dryRun) return build();
SHELLSCRIPT = SHELLSCRIPT
.replace(/\$1/, packagePath)
.replace(/\$2/, json.version);
// commit
proc.spawn("bash", {
args: ["-c", SHELLSCRIPT]
}, function(err, p){
if (err) return callback(err);
if (verbose) {
p.stdout.on("data", function(c){
process.stdout.write(c.toString("utf8"));
}); });
p.stderr.on("data", function(c){
process.stderr.write(c.toString("utf8"));
}); });
} }
p.on("exit", function(code, stderr, stdout){
if (code !== 0)
return callback(new Error("ERROR: publish failed with exit code " + code));
console.log("Created tag and updated package.json to version", json.version);
build();
});
});
});
// Build the package // Build the package
// @TODO use a proper package tool
// @TODO add a .c9exclude file that excludes files // @TODO add a .c9exclude file that excludes files
var zipFilePath; var zipFilePath;
function build(){ function build(){
@ -718,38 +705,62 @@ define(function(require, exports, module) {
}); });
}, },
function(next) { function(next) {
var filename = options.local ? "__installed__.js" : "__packed__.js"; if (options.local)
fs.writeFile(filename, result.code, "utf8", next); fs.writeFile(cwd + "__installed__.js", result.code, "utf8", callback);
next();
}, },
function(next) { function(next) {
// console.log(packedFiles) proc.execFile("rm", {
if (options.local) args: ["-rf", ".c9/.build"],
return callback(); cwd: cwd
zip(packedFiles); }, function() {
mkdirP(cwd + "/.c9/.build");
fs.writeFile(cwd + "/.c9/.build/__installed__.js", result.code, "utf8", next);
});
},
function(next) {
var copy = require("architect-build/copy");
var excludeRe = /^\.(gitignore|hgignore|git|c9|hg)$/;
var excludeMap = Object.create(null);
packedFiles.push(cwd + "/__installed__.js");
packedFiles.forEach(function(p) {
p = "/" + normalizePath(Path.relative(cwd, p));
excludeMap[p] = 1;
});
copy(cwd, cwd + "/.c9/.build", {
exclude: function(name, parent) {
if (excludeRe.test(name))
return true;
var fullPath = parent.substr(cwd.length) + "/" + name;
if (excludeMap[fullPath])
return true;
return false;
}
});
next();
},
updatePackageJSON,
function(next) {
zip();
} }
]); ]);
} }
function zip(ignore){ function zip(){
zipFilePath = join(os.tmpDir(), json.name + "@" + json.version) + ".tar.gz"; zipFilePath = join(os.tmpDir(), json.name + "@" + json.version) + ".tar.gz";
var tarArgs = ["-zcvf", normalizePath(zipFilePath), "."]; var tarArgs = ["-zcvf", normalizePath(zipFilePath)];
var c9ignore = normalizePath(process.env.HOME + "/.c9/.c9ignore"); var c9ignore = normalizePath(process.env.HOME + "/.c9/.c9ignore");
fs.exists(c9ignore, function (exists) { fs.exists(c9ignore, function (exists) {
if (exists) { if (exists) {
tarArgs.push("--exclude-from=" + c9ignore); tarArgs.push("--exclude-from=" + c9ignore);
} }
ignore.forEach(function(p) { tarArgs.push(".");
p = Path.relative(cwd, p);
if (!/^\.+\//.test(p)) {
tarArgs.push("--exclude=./" + normalizePath(p));
}
});
tarArgs.push("--transform='flags=r;s|__packed__|__installed__|'");
// console.log(tarArgs)
proc.spawn(TAR, { proc.spawn(TAR, {
args: tarArgs, args: tarArgs,
cwd: cwd cwd: cwd + "/.c9/.build"
}, function(err, p){ }, function(err, p){
if (err) return callback(err); if (err) return callback(err);
@ -840,7 +851,7 @@ define(function(require, exports, module) {
return callback(new Error("ERROR: Failed to update existing package - " return callback(new Error("ERROR: Failed to update existing package - "
+ stringifyError(err))); + stringifyError(err)));
if (verbose) if (verbose)
console.log("Successfully updated existing package"); console.log("Successfully updated metadata of existing package");
next(pkg); next(pkg);
}); });
@ -875,15 +886,47 @@ define(function(require, exports, module) {
form.pipe(request); form.pipe(request);
request.on('response', function(res) { request.on('response', function(res) {
// TODO better handle version exists error
if (res.statusCode == 412 && !version)
console.error("ERROR: most likely version " + json.version + " already exisits, try increasing version");
if (res.statusCode != 200) if (res.statusCode != 200)
return callback(new Error("ERROR: Unknown Error:" + res.statusCode)); return callback(new Error("ERROR: Unknown Error:" + res.statusCode));
// Create Version Complete commitAndPush();
callback(null, json);
}); });
} }
}); });
} }
function commitAndPush() {
// Create Version Complete
if (!createTag)
callback(null, json);
proc.spawn("bash", {
args: ["-c", SHELLSCRIPT, "--", json.version, normalizePath(packagePath)]
}, function(err, p){
if (err) return callback(err);
if (verbose) {
p.stdout.on("data", function(c){
process.stdout.write(c.toString("utf8"));
});
p.stderr.on("data", function(c){
process.stderr.write(c.toString("utf8"));
});
}
p.on("exit", function(code, stderr, stdout){
if (code !== 0)
return callback(new Error("ERROR: publish failed with exit code " + code));
console.log("Created tag and updated package.json to version", json.version);
callback(null, json);
});
});
}
}); });
} }
@ -1192,7 +1235,7 @@ define(function(require, exports, module) {
force = false; force = false;
}); });
/***** Register and define API *****/ /***** Register and definfe API *****/
/** /**
* *

Wyświetl plik

@ -0,0 +1,26 @@
/**
* Dummy implementation of experiments.
*/
"use strict";
plugin.consumes = [];
plugin.provides = ["experiment"];
module.exports = plugin;
function plugin(options, imports, register) {
register(null, {
"experiment": {
configure: function() {},
onStart: function() {
var chain = {
variation: function() {
return chain;
}
};
return chain;
}
}
});
}

Wyświetl plik

@ -82,6 +82,11 @@ function main(options, imports, register) {
}] }]
}]); }]);
statics.addStatics([{
path: dirname(require.resolve("architect-build/build_support/mini_require")),
mount: "/"
}]);
} }
/***** Lifecycle *****/ /***** Lifecycle *****/

Wyświetl plik

@ -34,11 +34,6 @@ function plugin(options, imports, register) {
mount: "/" mount: "/"
}]); }]);
statics.addStatics([{
path: __dirname + "/../../node_modules/architect-build/build_support",
mount: "/"
}]);
statics.addStatics([{ statics.addStatics([{
path: __dirname + "/../../configs", path: __dirname + "/../../configs",
mount: "/configs" mount: "/configs"

Wyświetl plik

@ -155,6 +155,9 @@ require([
prefs.add = function(){}; prefs.add = function(){};
return prefs; return prefs;
})(), })(),
analytics: {
addTrait: function() {}
},
commands: (function(){ commands: (function(){
var commands = {}; var commands = {};