mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
rip out changelog, even though it hurts
This commit is contained in:
@@ -475,7 +475,6 @@ _.extend(CompleteCatalog.prototype, {
|
||||
version: version,
|
||||
publishedBy: null,
|
||||
earliestCompatibleVersion: packageSource.earliestCompatibleVersion,
|
||||
changelog: null, // XXX get actual changelog when we have it?
|
||||
description: packageSource.metadata.summary,
|
||||
dependencies: packageSource.getDependencyMetadata(),
|
||||
source: null,
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var _ = require('underscore');
|
||||
var files = require('./files.js');
|
||||
var utils = require('./utils.js');
|
||||
|
||||
// This file deals with writing and reading the changelog.
|
||||
//
|
||||
// The changelog is not a part of an app -- currently only packages have
|
||||
// changelog support, and project.js is built to support apps as projects (ie:
|
||||
// it looks for the .meteor directory etc). It is not really part of the package
|
||||
// source either though, for a lot of packages. So, it is separate... for now.
|
||||
//
|
||||
// In the future of unified treatment of app&package projects, this would be
|
||||
// moved to project.js.
|
||||
|
||||
// Given the source directory, get the changelog file.
|
||||
exports.getChangelogFile = function (sourceDir) {
|
||||
return path.join(sourceDir, 'History.md');
|
||||
}
|
||||
|
||||
// Parse the changelog file. Takes in a filename.
|
||||
//
|
||||
// Returns an object, mapping the version string to an array of lines,
|
||||
// represneting its changelog contents.
|
||||
exports.readChangelog = function (filename) {
|
||||
var lines = files.getLines(filename);
|
||||
|
||||
// Remove leading & trailing whitespace off a line.
|
||||
var trimWhitespace = function (line) {
|
||||
return line.replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
|
||||
var ret = {};
|
||||
var malformed = false;
|
||||
var currentVersion = "";
|
||||
_.each(lines, function (line) {
|
||||
// Lines starting with ## denote a version, usually in the format of ##
|
||||
// v<versionN>. So, we should start a new version when we encounter the ##
|
||||
// and if we don't get what we want, we should return an error.
|
||||
if (line.slice(0, 2) == "##") {
|
||||
// We just read a bunch of stuff, let's save it.
|
||||
var sl = _.indexOf(line, "v");
|
||||
if (sl === -1) {
|
||||
malformed = true;
|
||||
}
|
||||
currentVersion = trimWhitespace(line.slice(sl+2, line.length));
|
||||
ret[currentVersion] = [];
|
||||
} else if (currentVersion) {
|
||||
// Process this line. Not sure how for now.
|
||||
ret[currentVersion].push(trimWhitespace(line));
|
||||
}
|
||||
});
|
||||
|
||||
// If the changelog is malformed, return an empty object.
|
||||
if (malformed) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Prepend a version & a brief change to the changelog.
|
||||
//
|
||||
// Returns true on success and false on failure.
|
||||
exports.prependChangelog = function (filename, version, changelogLines) {
|
||||
var logLines = files.getLines(filename);
|
||||
if (!logLines) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var title = "## v." + version;
|
||||
_.each(changelogLines, function (logline) {
|
||||
logLines.unshift("* " + logline);
|
||||
});
|
||||
logLines.unshift(title);
|
||||
|
||||
fs.writeFileSync(filename, logLines.join('\n'), 'utf8');
|
||||
return true;
|
||||
};
|
||||
|
||||
// Change v.NEXT in the changelog to the current version.
|
||||
exports.rewriteNextChangelog = function (filename, version) {
|
||||
var logLines = files.getLines(filename);
|
||||
if (!logLines) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logLines.shift();
|
||||
var title = "## v." + version;
|
||||
logLines.unshift(title);
|
||||
|
||||
fs.writeFileSync(filename, logLines.join('\n'), 'utf8');
|
||||
return true;
|
||||
};
|
||||
|
||||
// Remove v.NEXT in the changelog.
|
||||
exports.eraseNextChangelog = function (filename, version) {
|
||||
var logLines = files.getLines(filename);
|
||||
if (!logLines) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logLines.shift();
|
||||
|
||||
fs.writeFileSync(filename, logLines.join('\n'), 'utf8');
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
exports.printLines = function (lines, openning) {
|
||||
_.each(lines, function (l) {
|
||||
console.log(openning + l);
|
||||
});
|
||||
};
|
||||
@@ -727,7 +727,6 @@ main.registerCommand({
|
||||
catalog.official.refresh();
|
||||
|
||||
if (options.details) {
|
||||
var changelog = require('./changelog.js');
|
||||
var packageName = options.args[0];
|
||||
var packageRecord = catalog.official.getPackage(packageName);
|
||||
if (!packageRecord) {
|
||||
@@ -743,23 +742,13 @@ main.registerCommand({
|
||||
_.pluck(packageRecord.maintainers, 'username')
|
||||
+ " at " + packageRecord.repositoryUrl);
|
||||
return 1;
|
||||
} else if (!lastVersion || !lastVersion.changelog) {
|
||||
console.log("No details available.");
|
||||
} else if (!lastVersion) {
|
||||
console.log("No versions are available.");
|
||||
} else {
|
||||
|
||||
/* var changelogUrl = lastVersion.changelog;
|
||||
var myChangelog = httpHelpers.getUrl({
|
||||
url: changelogUrl,
|
||||
encoding: null
|
||||
});
|
||||
|
||||
var sourcePath = "/tmp/change";
|
||||
fs.writeFileSync(sourcePath, myChangelog);
|
||||
var ch = changelog.readChangelog(sourcePath); */
|
||||
_.each(versions, function (v) {
|
||||
var versionRecord = catalog.official.getVersion(packageName, v);
|
||||
console.log("Version " + v + " : " + versionRecord.earliestCompatibleVersion);
|
||||
// changelog.printLines(ver, " ");
|
||||
// XXX: should we print out something other than decription here?
|
||||
console.log("Version " + v + " : " + versionRecord.description);
|
||||
});
|
||||
console.log("\n");
|
||||
}
|
||||
|
||||
@@ -25,63 +25,6 @@ var getLoadedPackages = _.once(function () {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Read the changelog, if applicable & prompt the user to fill it out if it is
|
||||
// blank (once again, if applicable). Return the lines for the current version.
|
||||
var dealWithChangelog = function(packageSource) {
|
||||
var changelog = require('./changelog.js');
|
||||
var version = packageSource.version;
|
||||
var name = packageSource.name;
|
||||
var changeFile = changelog.getChangelogFile(packageSource.sourceRoot);
|
||||
var changeLines = changelog.readChangelog(changeFile);
|
||||
var changeExists = !_.isEqual(changeLines, {});
|
||||
// XXX: For now, if there is no changelog, we won't nag you about it.
|
||||
if (changeExists && !changeLines[version]) {
|
||||
process.stdout.write("-------\n");
|
||||
if (_.has(changeLines,"NEXT") && !_.isEqual(changeLines["NEXT"], [])) {
|
||||
changelog.rewriteNextChangelog(changeFile, version);
|
||||
process.stdout.write(" changelog: Changing v.NEXT to current version.\n");
|
||||
} else {
|
||||
// There is a stub of v.NEXT, but there is nothing there. Kill it.
|
||||
if (_.has(changeLines, "NEXT")) {
|
||||
changelog.eraseNextChangelog(changeFile);
|
||||
}
|
||||
// Changelog data is invalid and we have to rewrite it.
|
||||
process.stderr.write(" You are publishing version " + version +
|
||||
", but your changelog has no information about it! \n");
|
||||
process.stderr.write(" Please enter a changelog entry. \n");
|
||||
|
||||
// Use '*' as the command on the prompt and read from prompt.
|
||||
var readMyPrompt = function () {
|
||||
return utils.readLine({
|
||||
echo: true,
|
||||
prompt: " * ",
|
||||
stream: process.stderr
|
||||
});
|
||||
};
|
||||
|
||||
var foo = readMyPrompt();
|
||||
var lines = [];
|
||||
while (foo !== "q") {
|
||||
lines.unshift(foo);
|
||||
process.stderr.write(" Anything else? ( or q to quit) \n");
|
||||
foo = readMyPrompt();
|
||||
}
|
||||
changelog.prependChangelog(changeFile, version, lines);
|
||||
process.stdout.write(" Thanks! Changelog edited.\n");
|
||||
}
|
||||
|
||||
// Regardless of what the changelog status was, show what it says.
|
||||
changeLines = changelog.readChangelog(changeFile);
|
||||
process.stdout.write(" According to your History.md file," + name +
|
||||
"@" + version +" contains the following changes: \n");
|
||||
changelog.printLines(changeLines[version], " ");
|
||||
process.stdout.write("\n");
|
||||
process.stdout.write("-------\n");
|
||||
changelog.prependChangelog(changeFile, "NEXT", []);
|
||||
};
|
||||
};
|
||||
|
||||
// Opens a DDP connection to a package server. Loads the packages needed for a
|
||||
// DDP connection, then calls DDP connect to the package server URL in config,
|
||||
// using a current user-agent header composed by http-helpers.js.
|
||||
@@ -497,9 +440,6 @@ exports.publishPackage = function (packageSource, compileResult, conn, options)
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Get the changeLines from the changelog.
|
||||
var changeLines = dealWithChangelog(packageSource);
|
||||
|
||||
// We need to build the test package to get all of its sources.
|
||||
var testFiles = [];
|
||||
var messages = buildmessage.capture(
|
||||
@@ -560,7 +500,7 @@ exports.publishPackage = function (packageSource, compileResult, conn, options)
|
||||
earliestCompatibleVersion: packageSource.earliestCompatibleVersion,
|
||||
compilerVersion: compiler.BUILT_BY,
|
||||
containsPlugins: packageSource.containsPlugins(),
|
||||
dependencies: packageDeps,
|
||||
dependencies: packageDeps
|
||||
};
|
||||
var uploadInfo = conn.call('createPackageVersion', uploadRec);
|
||||
|
||||
@@ -572,10 +512,6 @@ exports.publishPackage = function (packageSource, compileResult, conn, options)
|
||||
uploadTarball(uploadInfo.uploadUrl,
|
||||
bundleResult.sourceTarball);
|
||||
|
||||
if (changeLines) {
|
||||
process.stdout.write('Uploading changelog...\n');
|
||||
}
|
||||
|
||||
process.stdout.write('Publishing package version...\n');
|
||||
conn.call('publishPackageVersion',
|
||||
uploadInfo.uploadToken, bundleResult.tarballHash);
|
||||
|
||||
Reference in New Issue
Block a user