do not automatically create tag from publish

pull/85/head
nightwing 2015-04-25 03:24:10 +04:00
rodzic 3962a9c04f
commit 182577009f
3 zmienionych plików z 57 dodań i 49 usunięć

Wyświetl plik

@ -17,7 +17,7 @@ function compress(sources, opts) {
if (pkg.file) console.log("Adding '" + pkg.file + "'.");
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
});
});

Wyświetl plik

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

Wyświetl plik

@ -43,6 +43,7 @@ define(function(require, exports, module) {
var verbose = false;
var force = false;
var dryRun = false;
var createTag = false;
// Set up basic auth for api if needed
if (BASICAUTH) api.basicAuth = BASICAUTH;
@ -78,16 +79,23 @@ define(function(require, exports, module) {
"description": "Only build a test version",
"default": false,
"boolean": true
},
"tag" : {
"description": "Create git tag for published version",
"alias": "t",
"default": false,
"boolean": true
}
},
check: function(argv) {
if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"])
throw new Error("Missing version");
// if (argv._.length < 2 && !argv["newversion"] && !argv["dry-run"])
// throw new Error("Missing version");
},
exec: function(argv) {
verbose = argv["verbose"];
force = argv["force"];
dryRun = argv["dry-run"];
createTag = argv["tag"];
publish(
argv._[1],
@ -108,7 +116,7 @@ define(function(require, exports, module) {
}
});
cmd.addCommand({
cmd.addCommand({
name: "build",
info: " Builds development version of package to load in non-debug mode.",
usage: "[--devel]",
@ -372,7 +380,7 @@ define(function(require, exports, module) {
var version = options.version;
var cwd = process.cwd();
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));
var json;
@ -437,7 +445,7 @@ define(function(require, exports, module) {
if (warned && !force && !dryRun)
return callback(new Error("Use --force to ignore these warnings."));
if (!dryRun) {
if (version) {
var v = (json.version || "0.0.1").split(".");
// Update the version field in the package.json file
if (version == "major") {
@ -458,48 +466,16 @@ define(function(require, exports, module) {
json.version = v.join(".");
}
if (dryRun)
if (!version)
return build();
// Write the package.json file
fs.writeFile(packagePath, JSON.stringify(json, null, " "), function(err){
var indent = data.match(/{\n\r?^ {4}"/) ? 4 : 2;
fs.writeFile(packagePath, JSON.stringify(json, null, indent), function(err){
if (err) return callback(err);
if (dryRun) return build();
commit();
return build();
});
function commit() {
SHELLSCRIPT = SHELLSCRIPT
.replace(/\$1/, packagePath)
.replace(/\$2/, json.version);
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
// @TODO add a .c9exclude file that excludes files
var zipFilePath;
@ -862,7 +838,7 @@ define(function(require, exports, module) {
return callback(new Error("ERROR: Failed to update existing package - "
+ stringifyError(err)));
if (verbose)
console.log("Successfully updated existing package");
console.log("Successfully updated metadata of existing package");
next(pkg);
});
@ -897,15 +873,47 @@ define(function(require, exports, module) {
form.pipe(request);
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)
return callback(new Error("ERROR: Unknown Error:" + res.statusCode));
// Create Version Complete
callback(null, json);
commitAndPush();
});
}
});
}
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);
});
});
}
});
}