From 74917e623db605680ab221ffd55a2e877246e424 Mon Sep 17 00:00:00 2001 From: ekatek Date: Sun, 15 Jun 2014 20:22:14 -0700 Subject: [PATCH] rip out changelog, even though it hurts --- tools/catalog.js | 1 - tools/changelog.js | 115 ------------------------------------- tools/commands-packages.js | 19 ++---- tools/package-client.js | 66 +-------------------- 4 files changed, 5 insertions(+), 196 deletions(-) delete mode 100644 tools/changelog.js diff --git a/tools/catalog.js b/tools/catalog.js index 5144d9a96b..ecff372e84 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -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, diff --git a/tools/changelog.js b/tools/changelog.js deleted file mode 100644 index 7c0855c1df..0000000000 --- a/tools/changelog.js +++ /dev/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. 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); - }); -}; diff --git a/tools/commands-packages.js b/tools/commands-packages.js index 1a1ad00c30..bb05281913 100644 --- a/tools/commands-packages.js +++ b/tools/commands-packages.js @@ -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"); } diff --git a/tools/package-client.js b/tools/package-client.js index b78c575fda..c90ee7c7b2 100644 --- a/tools/package-client.js +++ b/tools/package-client.js @@ -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);