kopia lustrzana https://github.com/c9/core
do not automatically create tag from publish
rodzic
3962a9c04f
commit
182577009f
|
@ -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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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],
|
||||||
|
@ -108,7 +116,7 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cmd.addCommand({
|
cmd.addCommand({
|
||||||
name: "build",
|
name: "build",
|
||||||
info: " Builds development version of package to load in non-debug mode.",
|
info: " Builds development version of package to load in non-debug mode.",
|
||||||
usage: "[--devel]",
|
usage: "[--devel]",
|
||||||
|
@ -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,48 +466,16 @@ define(function(require, exports, module) {
|
||||||
json.version = v.join(".");
|
json.version = v.join(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dryRun)
|
if (!version)
|
||||||
return build();
|
return build();
|
||||||
|
|
||||||
// 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;
|
||||||
|
fs.writeFile(packagePath, JSON.stringify(json, null, indent), function(err){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
return build();
|
||||||
if (dryRun) return build();
|
|
||||||
|
|
||||||
commit();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
// Build the package
|
||||||
// @TODO add a .c9exclude file that excludes files
|
// @TODO add a .c9exclude file that excludes files
|
||||||
var zipFilePath;
|
var zipFilePath;
|
||||||
|
@ -862,7 +838,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);
|
||||||
});
|
});
|
||||||
|
@ -897,15 +873,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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue