mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
remove some support for old versions.json files
This commit is contained in:
@@ -909,7 +909,7 @@ package.js file.
|
||||
Meteor promises repeatable builds for both packages and applications. This means
|
||||
that, if you built your package on a machine, then checked the code into a
|
||||
repository and checked it out elsewhere, you should get the same result. In your
|
||||
package directory, you will find an automatically generated versions.json
|
||||
package directory, you will find an automatically generated `.versions`
|
||||
file. This file specifies the versions of all packages used to build your
|
||||
package and is part of the source. Check it into version control to ensure
|
||||
repeatable builds across machines.
|
||||
@@ -919,10 +919,10 @@ repeatable builds across machines.
|
||||
Sometimes, packages do not just stand on their own, but function in the context
|
||||
of an app (specifically, packages in the packages directory of an app). In that
|
||||
case, the app's context will take precedence. Rather than using the
|
||||
versions.json file as a guide, we will build the package with the same
|
||||
`.versions` file as a guide, we will build the package with the same
|
||||
dependencies as used by the app (we think that, in practice, it would be
|
||||
confusing to find your local packages built with different versions of
|
||||
things). However, we will still write the new versions.json file.
|
||||
things).
|
||||
|
||||
{{/note}}
|
||||
|
||||
|
||||
@@ -2153,9 +2153,7 @@ exports.buildJsImage = function (options) {
|
||||
sources: options.sources || [],
|
||||
serveRoot: path.sep,
|
||||
npmDependencies: options.npmDependencies,
|
||||
npmDir: options.npmDir,
|
||||
dependencyVersions: options.dependencyVersions,
|
||||
noVersionFile: true
|
||||
npmDir: options.npmDir
|
||||
});
|
||||
|
||||
var isopack = compiler.compile(packageSource, {
|
||||
|
||||
@@ -261,12 +261,6 @@ var PackageSource = function (catalog) {
|
||||
// as a string.
|
||||
self.cordovaDependencies = {};
|
||||
|
||||
// Dependency versions that we used last time that we built this package. If
|
||||
// the constraint solver thinks that they are still a valid set of
|
||||
// dependencies, we will use them again to build this package. This makes
|
||||
// building packages slightly more efficient and ensures repeatable builds.
|
||||
self.dependencyVersions = {dependencies: {}, pluginDependencies: {}};
|
||||
|
||||
// If this package has a corresponding test package (for example,
|
||||
// underscore-test), defined in the same package.js file, store its value
|
||||
// here.
|
||||
@@ -286,13 +280,6 @@ var PackageSource = function (catalog) {
|
||||
// built copies of all known isopackets.
|
||||
self.includeTool = false;
|
||||
|
||||
// If this is true, the package source comes from the package server, and
|
||||
// should be treated as immutable. The only reason that we have it is so we
|
||||
// can build it, and we should expect to use exactly the same inputs
|
||||
// (package.js and version lock file) as we did when it was created. If we
|
||||
// ever need to modify it, we should throw instead.
|
||||
self.immutable = false;
|
||||
|
||||
// Is this a core package? Core packages don't record version files, because
|
||||
// core packages are only ever run from checkout. For the preview release,
|
||||
// core packages do not need to specify their versions at publication (since
|
||||
@@ -301,12 +288,6 @@ var PackageSource = function (catalog) {
|
||||
// XXX: 0.90 package versions.
|
||||
self.isCore = false;
|
||||
|
||||
// Alternatively, we can also specify noVersionFile directly. Useful for not
|
||||
// recording version files for js images of plugins, since those go into the
|
||||
// overall package versions file (if one exists). In the future, we can make
|
||||
// this option transparent to the user in package.js.
|
||||
self.noVersionFile = false;
|
||||
|
||||
// The list of archs that we can target. Doesn't include 'web' because
|
||||
// it is expanded into 'web.*'.
|
||||
self.allArchs = ['os', 'web.browser', 'web.cordova'];
|
||||
@@ -344,7 +325,6 @@ _.extend(PackageSource.prototype, {
|
||||
// - npmDependencies
|
||||
// - cordovaDependencies
|
||||
// - npmDir
|
||||
// - dependencyVersions
|
||||
initFromOptions: function (name, options) {
|
||||
var self = this;
|
||||
self.name = name;
|
||||
@@ -382,11 +362,6 @@ _.extend(PackageSource.prototype, {
|
||||
|
||||
if (! self._checkCrossUnibuildVersionConstraints())
|
||||
throw new Error("only one unibuild, so how can consistency check fail?");
|
||||
|
||||
self.dependencyVersions = options.dependencyVersions ||
|
||||
{dependencies: {}, pluginDependencies: {}};
|
||||
|
||||
self.noVersionFile = options.noVersionFile;
|
||||
},
|
||||
|
||||
// Initialize a PackageSource from a package.js-style package directory. Uses
|
||||
@@ -402,9 +377,6 @@ _.extend(PackageSource.prototype, {
|
||||
// example, a program)
|
||||
// -defaultVersion: The default version if none is specified. Only assigned
|
||||
// if the version is required.
|
||||
// -immutable: This package source is immutable. Do not write anything,
|
||||
// including version files. Instead, its only purpose is to be used as
|
||||
// guideline for a repeatable build.
|
||||
// -name: override the name of this package with a different name.
|
||||
initFromPackageDir: function (dir, options) {
|
||||
var self = this;
|
||||
@@ -1470,36 +1442,6 @@ _.extend(PackageSource.prototype, {
|
||||
}));
|
||||
});
|
||||
|
||||
// If we have built this before, read the versions that we ended up using.
|
||||
var versionsFile = self.versionsFilePath();
|
||||
if (versionsFile && fs.existsSync(versionsFile)) {
|
||||
try {
|
||||
var data = fs.readFileSync(versionsFile, 'utf8');
|
||||
var dependencyData = JSON.parse(data);
|
||||
self.dependencyVersions = {
|
||||
"pluginDependencies": _.object(dependencyData.pluginDependencies),
|
||||
"dependencies": _.object(dependencyData.dependencies),
|
||||
"toolVersion": dependencyData.toolVersion
|
||||
};
|
||||
} catch (err) {
|
||||
// We 'recover' by not reading the dependency versions. Log a line about
|
||||
// it in case it is unexpected. We don't buildmessage because it doesn't
|
||||
// really interrupt our workflow, but the user might want to know about
|
||||
// it anyway. We shouldn't get here unless, for example, the user tried
|
||||
// to manually edit the json file incorrectly, or there is some bizarre
|
||||
// ondisk corruption.
|
||||
console.log("Could not read versions file for " + self.name +
|
||||
". Recomputing dependency versions from scratch.");
|
||||
}
|
||||
};
|
||||
|
||||
// If immutable is set, then we should make a note to never mutate this
|
||||
// packageSource. We should never change its dependency versions, for
|
||||
// example.
|
||||
if (options.immutable) {
|
||||
self.immutable = true;
|
||||
};
|
||||
|
||||
// Serve root of the package.
|
||||
self.serveRoot = path.join(path.sep, 'packages', self.name);
|
||||
|
||||
@@ -1785,124 +1727,6 @@ _.extend(PackageSource.prototype, {
|
||||
return _.keys(packages);
|
||||
},
|
||||
|
||||
// Record the versions of the dependencies that we used to actually build the
|
||||
// package on disk and save them into the packageSource. Next time we build
|
||||
// the package, we will look at them for optimization & repeatable builds.
|
||||
//
|
||||
// constraints:
|
||||
// - dependencies: results of running the constraint solver on the dependency
|
||||
// metadata of this package
|
||||
// - pluginDependenciess: results of running the constraint solver on the
|
||||
// plugin dependency data for this package.
|
||||
// currentTool: string of the tool version that we are using
|
||||
// (ex: meteor-tool@1.0.0)
|
||||
recordDependencyVersions: function (constraints, currentTool) {
|
||||
var self = this;
|
||||
var versions = _.extend(constraints, {"toolVersion": currentTool });
|
||||
|
||||
// If we don't have a versions file path (because, probably, we are not
|
||||
// supposed to record one for this package), then we clearly cannot record
|
||||
// on.
|
||||
var versionsFile = self.versionsFilePath();
|
||||
if (!versionsFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If nothing has changed, don't bother rewriting the versions file.
|
||||
if (_.isEqual(self.dependencyVersions, versions)) return;
|
||||
|
||||
// If something has changed, and this is an immutable package source, then
|
||||
// we have done something terribly, terribly wrong. Throw.
|
||||
if (self.immutable) {
|
||||
throw new Error(
|
||||
"Version lock for " + self.name + " should never change. Recorded as "
|
||||
+ JSON.stringify(self.dependencyVersions) + ", calculated as "
|
||||
+ JSON.stringify(versions));
|
||||
};
|
||||
|
||||
// In case we need to rebuild from this package Source, it will be
|
||||
// convenient to keep the results on hand and not reread from disk.
|
||||
self.dependencyVersions = _.clone(versions);
|
||||
|
||||
// There is always a possibility that we might want to change the format of
|
||||
// this file, so let's keep track of what it is.
|
||||
versions["format"] = "1.0";
|
||||
|
||||
// When we write versions to disk, we want to alphabetize by package name,
|
||||
// both for readability and also for consistency (so two packages built with
|
||||
// the same versions have the exact same versions file).
|
||||
//
|
||||
// This takes in an object mapping key to value and returns an array of
|
||||
// <key, value> pairs, alphabetized by key.
|
||||
var alphabetize = function (object) {
|
||||
return _.sortBy(_.pairs(object),
|
||||
function (pair) {
|
||||
return pair[0];
|
||||
});
|
||||
};
|
||||
|
||||
// Both plugins and direct dependencies are objectsmapping package name to
|
||||
// version number. When we write them on disk, we will convert them to
|
||||
// arrays of <packageName, version> and alphabetized by packageName.
|
||||
versions["dependencies"] = alphabetize(versions["dependencies"]);
|
||||
versions["pluginDependencies"]
|
||||
= alphabetize(versions["pluginDependencies"]);
|
||||
|
||||
try {
|
||||
// Currently, unnamed packages are apps, and apps have a different
|
||||
// versions file format and semantics. So, we don't need to and cannot
|
||||
// record dependencyVersions for those, and that's OK for now.
|
||||
//
|
||||
// Uniload (the precursor to isopackets) used to set it sourceRoot to
|
||||
// "/", which is a little strange. That's what we're working around here,
|
||||
// though we can probably avoid this in the future.
|
||||
if (self.name && self.sourceRoot !== "/") {
|
||||
fs.writeFileSync(versionsFile, JSON.stringify(versions, null, 2), 'utf8');
|
||||
}
|
||||
} catch (e) {
|
||||
// We 'recover' by not saving the dependency versions. Log a line about it
|
||||
// in case it is unexpected. We don't buildmessage because it doesn't
|
||||
// really interrupt our workflow, but the user might want to know about it
|
||||
// anyway.
|
||||
console.log("Could not write versions file for ", self.name);
|
||||
}
|
||||
},
|
||||
|
||||
// Returns the filepath to the file containing the version lock for this
|
||||
// package, or null if we don't think that this package should have
|
||||
// a versions file.
|
||||
// XXX #3006 drop all this stuff
|
||||
versionsFilePath: function () {
|
||||
var self = this;
|
||||
// If we are running from checkout and looking at a core package,
|
||||
// don't record its versions. We know what its versions are, and having
|
||||
// those extra version lock files is kind of annoying.
|
||||
//
|
||||
// (This is a medium-term hack. We can build something more modular if
|
||||
// there is any demand for it)
|
||||
// See #PackageVersionFilesHack
|
||||
if (self.isCore) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If we have specified to not record a version file for this package,
|
||||
// don't. Currently used to avoid recording version files for separately
|
||||
// compiled plugins.
|
||||
if (self.noVersionFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Lastly, we don't record versions files for test packages because we don't
|
||||
// see any particularly good reason to do it, and it is confusing to the
|
||||
// users.
|
||||
if (self.isTest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// All right, fine, return a path to the versions file.
|
||||
return path.join(self.sourceRoot, "versions.json");
|
||||
},
|
||||
|
||||
// If dependencies aren't consistent across unibuilds, return false and
|
||||
// also log a buildmessage error if inside a buildmessage job. Else
|
||||
// return true.
|
||||
|
||||
Reference in New Issue
Block a user