From 2755f95bb636429645e75a6e2e7e04ce3dcb86c8 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 13 Aug 2014 16:37:03 -0700 Subject: [PATCH] Move uniload package list to uniload.js Actually verify that uniloaded packages are in the list. Add missing 'ejson'. Remove (ah well) test that relies on ability to uniload an app package (which shouldn't work anyway, but it would be nice to test uniload Assets...) --- packages/meteor-tool/package.js | 13 +------------ tools/package-source.js | 20 +++++++------------- tools/tests/old/test-bundler-assets.js | 9 --------- tools/uniload.js | 26 +++++++++++++++++++++++++- tools/unipackage.js | 5 +++-- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/packages/meteor-tool/package.js b/packages/meteor-tool/package.js index 0e03af0536..ce14881702 100644 --- a/packages/meteor-tool/package.js +++ b/packages/meteor-tool/package.js @@ -3,15 +3,4 @@ Package.describe({ version: '1.0.9' }); -Package.includeTool([ - 'meteor', - 'livedata', - 'minifiers', - 'dev-bundle-fetcher', - 'js-analyze', - 'logging', - 'mongo-livedata', - 'minimongo', - 'constraint-solver', - 'package-version-parser' -]); +Package.includeTool(); diff --git a/tools/package-source.js b/tools/package-source.js index 2b4dc91642..723e33b6ea 100644 --- a/tools/package-source.js +++ b/tools/package-source.js @@ -275,12 +275,11 @@ var PackageSource = function (catalog) { // to the catalog), so we need to keep track of them. self.isTest = false; - // If this is set, it should be set to an array of package names. We will take - // the currently running git checkout and bundle the meteor tool from it - // inside this package as a tool. We will include built unipackages for all - // the packages in this array as well as their transitive (strong) - // dependencies. - self.includeTool = null; + // If this is set, we will take the currently running git checkout and bundle + // the meteor tool from it inside this package as a tool. We will include + // built unipackages for all the packages in uniload.ROOT_PACKAGES as well as + // their transitive (strong) dependencies. + self.includeTool = false; // If this is true, then this package has no source files. (But the converse // is not true: this is only set to true by one particular constructor.) This @@ -580,19 +579,14 @@ _.extend(PackageSource.prototype, { self.pluginInfo[options.name] = options; }, - includeTool: function (packages) { + includeTool: function () { if (!files.inCheckout()) { buildmessage.error("Package.includeTool() can only be used with a " + "checkout of meteor"); } else if (self.includeTool) { buildmessage.error("Duplicate includeTool call"); - } else if (!_.isArray(packages)) { - buildmessage.error("Argument to Package.includeTool must be array"); - } else if (!_.all(packages, _.isString)) { - buildmessage.error( - "Elements of array passed to Package.includeTool must be strings"); } else { - self.includeTool = packages; + self.includeTool = true; } } }; diff --git a/tools/tests/old/test-bundler-assets.js b/tools/tests/old/test-bundler-assets.js index 70edeebeb2..c4ab8b850f 100644 --- a/tools/tests/old/test-bundler-assets.js +++ b/tools/tests/old/test-bundler-assets.js @@ -144,15 +144,6 @@ var runTest = function () { }); assert.strictEqual(fut.wait(), 0); }); - - console.log("Use Assets API from unipackage"); - assert.doesNotThrow(function () { - var testPackage = uniload.load({ - library: release.current.library, - packages: ['test-package'] - })['test-package'].TestAsset; - testPackage.go(false /* don't exit when done */); - }); }; var Fiber = require('fibers'); diff --git a/tools/uniload.js b/tools/uniload.js index a9df087f2c..fb597448e8 100644 --- a/tools/uniload.js +++ b/tools/uniload.js @@ -6,6 +6,23 @@ var packageLoader = require("./package-loader.js"); var files = require('./files.js'); var catalog = require('./catalog.js'); +// These are the only packages that may be directly loaded via this package. Add +// more to the list if you need to uniload more things! (You don't have to +// include the dependencies of the packages you directly load in this list.) +var ROOT_PACKAGES = [ + 'constraint-solver', + 'dev-bundle-fetcher', + 'ejson', + 'js-analyze', + 'livedata', + 'logging', + 'meteor', + 'minifiers', + 'minimongo', + 'mongo-livedata', + 'package-version-parser' +]; + // Load unipackages into the currently running node.js process. Use // this to use unipackages (such as the DDP client) from command-line // tools (such as 'meteor'). The requested packages will be loaded @@ -56,6 +73,12 @@ var load = function (options) { return cache[cacheKey]; } + var undeclaredPackages = _.difference(options.packages, ROOT_PACKAGES); + if (undeclaredPackages.length) { + throw new Error("attempt to uniload undeclared packages: " + + JSON.stringify(undeclaredPackages)); + } + // Set up a minimal server-like environment (omitting the parts that // are specific to the HTTP server). Kind of a hack. I suspect this // will get refactored before too long. Note that @@ -120,5 +143,6 @@ var load = function (options) { var uniload = exports; _.extend(exports, { - load: load + load: load, + ROOT_PACKAGES: ROOT_PACKAGES }); diff --git a/tools/unipackage.js b/tools/unipackage.js index 215c0e9911..c4f3919b08 100644 --- a/tools/unipackage.js +++ b/tools/unipackage.js @@ -11,6 +11,7 @@ var watch = require('./watch.js'); var packageLoader = require('./package-loader.js'); var catalog = require('./catalog.js'); var files = require('./files.js'); +var uniload = require('./uniload.js'); var Future = require('fibers/future'); var rejectBadPath = function (p) { @@ -263,7 +264,7 @@ var Unipackage = function () { // See description in PackageSource. If this is set, then we include a copy of // our own source, in addition to any other tools that were originally in the // unipackage. - self.includeTool = null; + self.includeTool = false; // This is tools to copy from trees on disk. This is used by the // unipackage-merge code in tropohouse. @@ -970,7 +971,7 @@ _.extend(Unipackage.prototype, { catalog: catalog.uniload }); bundler.iterateOverAllUsedUnipackages( - localPackageLoader, archinfo.host(), self.includeTool, + localPackageLoader, archinfo.host(), uniload.ROOT_PACKAGES, function (unipkg) { // XXX assert that each name shows up once unipkg.saveToPath(path.join(unipath, unipkg.name), {