@@ -516,10 +516,54 @@ _.extend(CompleteCatalog.prototype, {
516
516
} ) ;
517
517
}
518
518
519
+ < << << << HEAD
519
520
var patience = new utils . Patience ( {
520
521
messageAfterMs : 1000 ,
521
522
message : "Figuring out the best package versions to use. This may take a moment."
522
523
} ) ;
524
+ = === ===
525
+ // XXX:hack Before we run the constraint solver, let's do an 80% check for
526
+ // invalid packages. Specifically, if I am using a local package that
527
+ // depends on 'hogwash', I should be told that hogwash doesn't exist
528
+ // (because constraint solver errors are not there yet, and, also, because
529
+ // realistically, it is a rather common error, especially when starting
530
+ // migration. This won't cover weirdly invalid packages on the server, for
531
+ // example, but it is going to give us 80% for 2% effort, so it is worth it.
532
+ var depsToCheck = { } ;
533
+ // Make a hash map of packages that we are going to have.
534
+ _ . each ( deps , function ( d ) {
535
+ depsToCheck [ d ] = false ;
536
+ } ) ;
537
+
538
+ // Checks the package & its dependencies (if it is local) for existing.
539
+ // This function is recursive, but it only checks each package once; it marks
540
+ // that the check is done before recursing and it will stop upon hitting a
541
+ // nonexistent package dependency.
542
+ var isValidDep = function ( pack ) {
543
+ if ( depsToCheck [ pack ] ) return ;
544
+ // Do we even know about this package -- does it exist?
545
+ if ( ! self . getPackage ( pack ) ) {
546
+ throw new Error (
547
+ "Trying to depend on a nonexistent package : " + pack + "\n" ) ;
548
+ }
549
+ depsToCheck [ pack ] = true ;
550
+ // If it does, is it local?
551
+ if ( self . isLocalPackage ( pack ) ) {
552
+ var vr = self . getLatestVersion ( pack ) ;
553
+ var dirDeps = _ . keys ( vr . dependencies ) ;
554
+ _ . each ( vr . dependencies , function ( dep , name ) {
555
+ if ( _ . where ( dep . references , { weak : true } ) . length !==
556
+ dep . references . length )
557
+ isValidDep ( name ) ;
558
+ } ) ;
559
+ }
560
+ } ;
561
+
562
+ _ . each ( depsToCheck , function ( checked , pack ) {
563
+ if ( checked ) return ;
564
+ isValidDep ( pack ) ;
565
+ } ) ;
566
+
523
567
try {
524
568
// Then, call the constraint solver, to get the valid transitive subset of
525
569
// those versions to record for our solution. (We don't just return the
0 commit comments