From ff3e4439d41569873607a44ae7a129e4dda7a05e Mon Sep 17 00:00:00 2001 From: David Glasser Date: Sun, 30 Nov 2014 22:47:11 -0800 Subject: [PATCH] PackageSource and buildJsImage don't need catalog It wasn't really being used for anything anymore except complaining about api.versionsFrom being used during isopacket builds, which is now implemented in a simpler way. --- tools/bundler.js | 7 ++----- tools/catalog-local.js | 16 +++++++++------- tools/compiler.js | 3 +-- tools/isopack.js | 3 +-- tools/isopackets.js | 7 +++---- tools/package-source.js | 14 ++++++-------- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/tools/bundler.js b/tools/bundler.js index dfdcf5ed08..647cc21d4f 100644 --- a/tools/bundler.js +++ b/tools/bundler.js @@ -167,7 +167,6 @@ var runLog = require('./run-log.js'); var PackageSource = require('./package-source.js'); var compiler = require('./compiler.js'); var tropohouse = require('./tropohouse.js'); -var catalog = require('./catalog.js'); var packageVersionParser = require('./package-version-parser.js'); // files to ignore when bundling. node has no globs, so use regexps @@ -2004,7 +2003,7 @@ exports.bundle = function (options) { }; // Create a Isopack object that represents the app - var packageSource = new PackageSource(projectContext.packageMap.catalog); + var packageSource = new PackageSource; packageSource.initFromAppDir(projectContext, exports.ignoreFiles); var app = compiler.compile(packageSource, { packageMap: projectContext.packageMap, @@ -2133,10 +2132,8 @@ exports.buildJsImage = function (options) { throw new Error("Must indicate .npm directory to use"); if (! options.name) throw new Error("Must provide a name"); - if (! options.catalog) - throw new Error("Must provide a catalog"); - var packageSource = new PackageSource(options.catalog); + var packageSource = new PackageSource; packageSource.initFromOptions(options.name, { kind: "plugin", diff --git a/tools/catalog-local.js b/tools/catalog-local.js index 83ab9e7e88..80e6101560 100644 --- a/tools/catalog-local.js +++ b/tools/catalog-local.js @@ -75,6 +75,7 @@ _.extend(LocalCatalog.prototype, { // - explicitlyAddedLocalPackageDirs: an array of paths which THEMSELVES // are package source trees. Takes precedence over packages found // via localPackageSearchDirs. + // - buildingIsopackets: true if we are building isopackets initialize: function (options) { var self = this; buildmessage.assertInCapture(); @@ -91,7 +92,7 @@ _.extend(LocalCatalog.prototype, { }); self._computeEffectiveLocalPackages(); - self._loadLocalPackages(); + self._loadLocalPackages(options.buildingIsopackets); self.initialized = true; }, @@ -240,9 +241,8 @@ _.extend(LocalCatalog.prototype, { }); }, - _loadLocalPackages: function (options) { + _loadLocalPackages: function (buildingIsopackets) { var self = this; - options = options || {}; buildmessage.assertInCapture(); // Load the package source from a directory. We don't know the names of our @@ -256,19 +256,21 @@ _.extend(LocalCatalog.prototype, { // checkout. It is not clear that you get good UX if you have two packages // with the same name in your app. We don't check that.) var initSourceFromDir = function (packageDir, definiteName) { - var packageSource = new PackageSource(self.containingCatalog); + var packageSource = new PackageSource; buildmessage.enterJob({ title: "reading package from `" + packageDir + "`", rootPath: packageDir }, function () { - var packageSourceOptions = {}; + var initFromPackageDirOptions = { + buildingIsopackets: !! buildingIsopackets + }; // If we specified a name, then we know what we want to get and should // pass that into the options. Otherwise, we will use the 'name' // attribute from package-source.js. if (definiteName) { - packageSourceOptions.name = definiteName; + initFromPackageDirOptions.name = definiteName; } - packageSource.initFromPackageDir(packageDir, packageSourceOptions); + packageSource.initFromPackageDir(packageDir, initFromPackageDirOptions); if (buildmessage.jobHasMessages()) return; // recover by ignoring diff --git a/tools/compiler.js b/tools/compiler.js index c1d5d9e478..c9266520e8 100644 --- a/tools/compiler.js +++ b/tools/compiler.js @@ -57,8 +57,7 @@ compiler.compile = function (packageSource, options) { // rest of the package, so they need their own separate npm // shrinkwrap and cache state. npmDir: path.resolve(path.join(packageSource.sourceRoot, '.npm', - 'plugin', info.name)), - catalog: packageSource.catalog + 'plugin', info.name)) }); if (buildmessage.jobHasMessages()) return; diff --git a/tools/isopack.js b/tools/isopack.js index eef573aebe..df688ec95a 100644 --- a/tools/isopack.js +++ b/tools/isopack.js @@ -1091,8 +1091,7 @@ _.extend(Isopack.prototype, { name: "isopacket-" + isopacketName, packageMap: packageMap, isopackCache: isopackCache, - use: packages, - catalog: isopacketCatalog + use: packages }).image; if (buildmessage.jobHasMessages()) return; diff --git a/tools/isopackets.js b/tools/isopackets.js index 4ff6bb4fe6..7e1509d1cd 100644 --- a/tools/isopackets.js +++ b/tools/isopackets.js @@ -182,8 +182,7 @@ var ensureIsopacketsLoadable = function () { name: "isopacket-" + isopacketName, packageMap: packageMap, isopackCache: isopackCache, - use: packages, - catalog: isopacketCatalog + use: packages }); if (buildmessage.jobHasMessages()) return; @@ -218,7 +217,6 @@ var newIsopacketBuildingCatalog = function () { var catalogLocal = require('./catalog-local.js'); var isopacketCatalog = new catalogLocal.LocalCatalog; - isopacketCatalog.isopacketBuildingCatalog = true; var messages = buildmessage.capture( { title: "Scanning local core packages" }, function () { @@ -229,7 +227,8 @@ var newIsopacketBuildingCatalog = function () { // (there's no worries about needing to springboard). isopacketCatalog.initialize({ localPackageSearchDirs: [path.join( - files.getCurrentToolsDir(), 'packages')] + files.getCurrentToolsDir(), 'packages')], + buildingIsopackets: true }); }); if (messages.hasMessages()) { diff --git a/tools/package-source.js b/tools/package-source.js index 2543268552..9169710fbb 100644 --- a/tools/package-source.js +++ b/tools/package-source.js @@ -190,14 +190,9 @@ var SourceArch = function (pkg, options) { // PackageSource /////////////////////////////////////////////////////////////////////////////// -var PackageSource = function (catalog) { +var PackageSource = function () { var self = this; - // Which catalog this PackageSource works with. - if (!catalog) - throw Error("Must provide catalog"); - self.catalog = catalog; - // The name of the package, or null for an app pseudo-package or // collection. The package's exports will reside in Package.. // When it is null it is linked like an application instead of like @@ -372,12 +367,15 @@ _.extend(PackageSource.prototype, { // name: name of the package. // dir: location of directory on disk. // options: - // -name: override the name of this package with a different name. + // - name: override the name of this package with a different name. + // - buildingIsopackets: true if this is being scanned in the process + // of building isopackets initFromPackageDir: function (dir, options) { var self = this; buildmessage.assertInCapture(); var isPortable = true; options = options || {}; + var initFromPackageDirOptions = options; // If we know what package we are initializing, we pass in a // name. Otherwise, we are intializing the base package specified by 'name:' @@ -1183,7 +1181,7 @@ _.extend(PackageSource.prototype, { // (since we may need the ddp isopacket to refresh catalog.official), // so we wouldn't actually be able to interpret the release name // anyway. - if (self.catalog.isopacketBuildingCatalog) { + if (initFromPackageDirOptions.buildingIsopackets) { buildmessage.error( "packages in isopackets may not use versionsFrom"); // recover by ignoring