Merge branch 'packaging' into devel

This commit is contained in:
David Glasser
2013-03-29 23:00:06 -07:00
9 changed files with 136 additions and 72 deletions

View File

@@ -234,6 +234,23 @@ var main = function () {
return readJSONFile(noticesFilename);
});
// Every "official" release needs to be in notices.json, even those without
// notices, so that the notice-printing code knows how far back to look.
if (!_.contains(_.pluck(notices, 'release'), blessedReleaseName)) {
die("notices.json must contain release " +
blessedReleaseName + "! (It does not need to have notices.)");
}
_.each(notices, function (record) {
if (!record.release)
die("An element of notices.json lacks a release.");
_.each(record.notices, function (line) {
if (line.length + record.release.length + 2 > 80) {
die("notices.json: notice line too long: " + line);
}
});
});
var bannerFilename = path.resolve(__dirname, 'banner.txt');
var banner = doOrDie("Can't read banner file " + bannerFilename, function () {
return fs.readFileSync(bannerFilename, 'utf8');

View File

@@ -1,10 +1,22 @@
[
{
"release": "0.6.0",
"tagline": "The engine!",
"changes": [
"Use 'Npm.require' instead of '__meteor_bootstrap__.require'",
"release": "0.6.0"
},
{
"release": "0.6.1",
"notices": [
"hi",
"This has a very very veryveryvery very very very long long long line",
"more..."
]
},
{
"release": "0.6.2"
},
{
"release": "0.6.3",
"notices": [
"ok here is a notice"
]
}
]

View File

@@ -30,7 +30,7 @@ if [ "$METEOR_WAREHOUSE_DIR" ]; then
# the current tools, in which case you can build and publish a new release
# and set it here.
export METEOR_TEST_NO_SPRINGBOARD=t
TEST_RELEASE="0.6.0-alpha1"
TEST_RELEASE="0.6.0"
METEOR="$METEOR --release=$TEST_RELEASE" # some random non-official release
fi

View File

@@ -90,7 +90,7 @@ var deployToServer = function (app_dir, bundleOptions, deployOptions) {
var build_dir = path.join(app_dir, '.meteor', 'local', 'build_tar');
var bundle_path = path.join(build_dir, 'bundle');
process.stdout.write('Deploying to ' + site + '. Bundling ... ');
process.stdout.write('Deploying to ' + site + '. Bundling...\n');
var bundler = require('./bundler.js');
var errors = bundler.bundle(app_dir, bundle_path, bundleOptions);
if (errors) {
@@ -102,7 +102,7 @@ var deployToServer = function (app_dir, bundleOptions, deployOptions) {
process.exit(1);
}
process.stdout.write('uploading ... ');
process.stdout.write('Uploading...\n');
var rpcOptions = {};
if (password) rpcOptions.password = password;
@@ -120,8 +120,6 @@ var deployToServer = function (app_dir, bundleOptions, deployOptions) {
process.exit(1);
}
process.stdout.write('done.\n');
var hostname = null;
var response = null;
try {

View File

@@ -347,7 +347,7 @@ Fiber(function () {
Commands.push({
name: "update",
help: "Upgrade to the latest version of Meteor",
help: "Upgrade this project to the latest version of Meteor",
func: function (argv) {
// reparse args
var opt = require('optimist').usage(
@@ -447,11 +447,13 @@ Fiber(function () {
// This is the right spot to do any other changes we need to the app in
// order to update it for the new release (new metadata file formats,
// etc, or maybe even updating renamed APIs).
// XXX should we really print the full path here (appDir)? (use pretty)
console.log("%s: updated to Meteor %s.",
context.appDir, context.releaseVersion);
path.basename(context.appDir), context.releaseVersion);
warehouse.printNotices(appRelease, context.releaseVersion);
// Print any notices relevant to this upgrade. (We don't do this on an
// initial upgrade to Engine Meteor.
if (appRelease)
warehouse.printNotices(appRelease, context.releaseVersion);
}
});
@@ -971,6 +973,9 @@ Fiber(function () {
process.exit(0);
};
// Implements "meteor --get-ready", which you run to ensure that your
// checkout's Meteor is "complete" (dev bundle downloaded and all NPM modules
// installed).
var getReady = function () {
if (files.usesWarehouse()) {
logging.die("meteor --get-ready only works in a checkout");
@@ -1003,8 +1008,6 @@ Fiber(function () {
if (!files.in_checkout() && !process.env.METEOR_TEST_NO_SPRINGBOARD)
toolsSpringboard();
// Run this to ensure that your checkout's Meteor is "complete" (dev bundle
// downloaded and all NPM modules installed).
if (argv['get-ready']) {
getReady();
return;

View File

@@ -60,16 +60,6 @@ _.extend(exports, {
// randomize the name, in case we're bundling this package
// multiple times in parallel.
var newPackageNpmDir = packageNpmDir + '-new-' + self._randomToken();
self._tmpDirs.push(newPackageNpmDir); // keep track so that we can remove them on process exit
fs.mkdirSync(newPackageNpmDir);
// create .gitignore -- node_modules shouldn't be in git since we
// recreate it as needed by using `npm install`. since we use `npm
// shrinkwrap` we're guaranteed to have the same version installed
// each time.
fs.writeFileSync(
path.join(newPackageNpmDir, '.gitignore'),
['node_modules', ''/*git diff complains without trailing newline*/].join('\n'));
try {
if (fs.existsSync(packageNpmDir)) {
@@ -89,6 +79,20 @@ _.extend(exports, {
}
},
_makeNewPackageNpmDir: function (newPackageNpmDir) {
var self = this;
self._tmpDirs.push(newPackageNpmDir); // keep track so that we can remove them on process exit
fs.mkdirSync(newPackageNpmDir);
// create .gitignore -- node_modules shouldn't be in git since we
// recreate it as needed by using `npm install`. since we use `npm
// shrinkwrap` we're guaranteed to have the same version installed
// each time.
fs.writeFileSync(
path.join(newPackageNpmDir, '.gitignore'),
['node_modules', ''/*git diff complains without trailing newline*/].join('\n'));
},
_updateExistingNpmDirectory: function(
packageName, newPackageNpmDir, packageNpmDir, npmDependencies, quiet) {
var self = this;
@@ -103,7 +107,6 @@ _.extend(exports, {
var installedDependencies = self._installedDependencies(packageNpmDir);
// If we already have the right things installed, life is good.
// XXX avoid creating and deleting newPackageNpmDir in this case?
if (_.isEqual(installedDependencies, npmDependencies))
return;
@@ -123,6 +126,8 @@ _.extend(exports, {
}
});
self._makeNewPackageNpmDir(newPackageNpmDir);
if (!_.isEmpty(preservedShrinkwrap.dependencies)) {
// There are some unchanged packages here. Install from shrinkwrap.
fs.writeFileSync(path.join(newPackageNpmDir, 'npm-shrinkwrap.json'),
@@ -164,6 +169,7 @@ _.extend(exports, {
if (!quiet)
self._logUpdateDependencies(packageName, npmDependencies);
self._makeNewPackageNpmDir(newPackageNpmDir);
// install dependencies
_.each(npmDependencies, function(version, name) {
self._installNpmModule(name, version, newPackageNpmDir);
@@ -353,10 +359,8 @@ _.extend(exports, {
},
_logUpdateDependencies: function(packageName, npmDependencies) {
var npmDependenciesStr = _.map(npmDependencies, function(version, name) {
return name + '@' + version;
}).join(', ');
console.log(packageName + ': updating npm dependencies -- ' + npmDependenciesStr + '...');
console.log('%s: updating npm dependencies -- %s...',
packageName, _.keys(npmDependencies).join(', '));
},
_randomToken: function() {

View File

@@ -217,7 +217,6 @@ var log_to_clients = function (msg) {
// mongoURL
// onExit
// [onListen]
// [onStdio]
// [nodeOptions]
// [settingsFile]
@@ -261,7 +260,6 @@ var start_server = function (options) {
if (data.length != originalLength)
options.onListen && options.onListen();
if (data) {
options.onStdio && options.onStdio();
log_to_clients({stdout: data});
}
});
@@ -269,7 +267,6 @@ var start_server = function (options) {
proc.stderr.setEncoding('utf8');
proc.stderr.on('data', function (data) {
if (data) {
options.onStdio && options.onStdio();
log_to_clients({stderr: data});
}
});
@@ -560,8 +557,6 @@ exports.run = function (context, options) {
var mongo_url = process.env.MONGO_URL ||
("mongodb://127.0.0.1:" + mongo_port + "/meteor");
var firstRun = true;
var lastThingThatPrintedWasRestartMessage;
var silentRuns = 0;
var deps_info = null;
var warned_about_no_deps_info = false;
@@ -569,6 +564,34 @@ exports.run = function (context, options) {
var server_handle;
var watcher;
var lastThingThatPrintedWasRestartMessage = false;
var silentRuns = 0;
// Hijack process.stdout and process.stderr so that whenever anything is
// written to one of them, if the last thing we printed as the "Meteor server
// restarted" message with no newline, we (a) print that newline and (b)
// remember that *something* was printed (and so we shouldn't try to erase and
// rewrite the line on the next restart).
var realStdoutWrite = process.stdout.write;
var realStderrWrite = process.stderr.write;
// Call this function before printing anything to stdout or stderr.
var onStdio = function () {
if (lastThingThatPrintedWasRestartMessage) {
realStdoutWrite.call(process.stdout, "\n");
lastThingThatPrintedWasRestartMessage = false;
silentRuns = 0;
}
};
process.stdout.write = function () {
onStdio();
return realStdoutWrite.apply(process.stdout, arguments);
};
process.stderr.write = function () {
onStdio();
return realStderrWrite.apply(process.stderr, arguments);
};
if (options.once) {
Status.shouldRestart = false;
}
@@ -682,12 +705,12 @@ exports.run = function (context, options) {
// The last run was not the "Running on: " run, and it didn't print
// anything. So the last thing that printed was the restart message.
// Overwrite it.
process.stdout.write('\r');
realStdoutWrite.call(process.stdout, '\r');
}
process.stdout.write("=> Meteor server restarted");
realStdoutWrite.call(process.stdout, "=> Meteor server restarted");
if (lastThingThatPrintedWasRestartMessage) {
++silentRuns;
process.stdout.write(" (x" + (silentRuns+1) + ")");
realStdoutWrite.call(process.stdout, " (x" + (silentRuns+1) + ")");
}
lastThingThatPrintedWasRestartMessage = true;
}
@@ -712,13 +735,6 @@ exports.run = function (context, options) {
_.each(request_queue, function (f) { f(); });
request_queue = [];
},
onStdio: function () {
if (lastThingThatPrintedWasRestartMessage) {
process.stdout.write("\n");
lastThingThatPrintedWasRestartMessage = false;
silentRuns = 0;
}
},
nodeOptions: getNodeOptionsFromEnvironment(),
settingsFile: options.settingsFile
});

View File

@@ -46,7 +46,9 @@ exports.startUpdateChecks = function (context) {
if (manifest.releases.stable.banner &&
warehouse.lastPrintedBannerRelease() !== manifestLatestRelease) {
// XXX onStdio
console.log();
console.log(manifest.releases.stable.banner);
console.log();
warehouse.writeLastPrintedBannerRelease(manifestLatestRelease);
} else {
// Already printed this banner, or maybe there is no banner.

View File

@@ -363,35 +363,47 @@ _.extend(warehouse, {
var noticesPath = path.join(
warehouse.getWarehouseDir(), 'releases', toRelease + '.notices.json');
if (fs.existsSync(path.join(noticesPath))) {
try {
var notices = JSON.parse(fs.readFileSync(noticesPath));
var foundFromRelease = false;
var newChanges = []; // acculumate change until we hit 'fromRelease'
_.find(notices, function(change) {
if (change.release === fromRelease) {
foundFromRelease = true;
return true; // exit _.find
} else {
newChanges.push(change);
return false;
}
});
if (foundFromRelease) {
console.log("Important changes from " + fromRelease + ":");
_.each(newChanges, function(change) {
console.log(change.release + ": " + change.tagline);
_.each(change.changes, function (changeline) {
console.log('* ' + changeline);
});
console.log();
});
} else {
// didn't find 'fromRelease' in the notices. must have been
// an unofficial release. don't print anything.
// XXX probably print the latest only or something
}
} catch (e) {
// It's valid for this file to not exist (if it's an unblessed version)
// and eh, if the JSON is bad then the user doesn't really care.
return;
}
var noticesToPrint = [];
var foundFromRelease = false;
for (var i = 0; i < notices.length; ++i) {
var record = notices[i];
// We want to print the notices for releases newer than fromRelease, and
// we always want to print toRelease even if we're updating from something
// that's not in the notices file at all.
if (record.notices &&
(foundFromRelease || record.release === toRelease)) {
noticesToPrint.push(record);
}
// Nothing newer than toRelease.
if (record.release === toRelease)
break;
if (record.release === fromRelease)
foundFromRelease = true;
}
if (_.isEmpty(noticesToPrint))
return;
console.log();
console.log("-- Notice --");
console.log();
_.each(noticesToPrint, function (record) {
var header = record.release + ': ';
_.each(record.notices, function (line, i) {
console.log(header + line);
if (i === 0)
header = header.replace(/./g, ' ');
});
console.log();
});
},
// this function is also used by bless-release.js