static IPackageInfo GetExistingPackage(ISupportPublishing destinationRepository, ResolvedPackage foundPackage, Func <Version, bool> versionSelector)
 {
     return(destinationRepository.PackagesByName.Contains(foundPackage.Identifier.Name)
                    ? destinationRepository.PackagesByName[foundPackage.Identifier.Name]
            .Where(x => foundPackage.Identifier.Version != null && versionSelector(x.Version))
            .OrderByDescending(x => x.Version)
            .FirstOrDefault()
                    : null);
 }
示例#2
0
        IEnumerable<ICommandOutput> ValidateInputs()
        {
            var namedRepository = GetRemoteRepository(Remote);

            if (namedRepository == null)
            {
                yield return new Errors.UnknownRemoteRepository(Remote);
                foreach (var _ in HintRemoteRepositories()) yield return _;
                yield break;
            }
            _remoteRepository = namedRepository as ISupportPublishing;

            if (_remoteRepository == null)
            {
                yield return new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name);
                yield break;
            }
            if (Path != null)
            {
                var packageFile = FileSystem.GetFile(Path);
                if (!packageFile.Exists)
                {
                    yield return new Errors.FileNotFound(Path);
                    yield break;
                }
                else
                {
                    _packageStream = () => packageFile.OpenRead();
                    _packageFileName = packageFile.Name;
                    var package = new CachedZipPackage(null, packageFile, null, null);
                    _packageName = package.Name;
                    _packageVersion = package.Version;
                }
            }
            else if (Name != null)
            {
                // get latest version of the Named package
                if (!Environment.CurrentDirectoryRepository.PackagesByName.Contains(Name))
                {
                    yield return new Error("No package named '{0}' was found.", Name);
                    yield break;
                }
                var packageToCopy = Environment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x=>x.Version).First();
                _packageStream = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName = packageToCopy.Name;
                _packageVersion = packageToCopy.Version;
            }
            else
            {
                yield return new Error("Please specify either a file path using the -Path input, or a name using -Name.");
            }
        }
示例#3
0
 public PackageAddedResult(IPackageInfo package, ISupportPublishing repository)
 {
     Package = package;
     Repository = repository;
 }
 public void DeployDependency(IPackageInfo resolvedPackage,
     ISupportPublishing destinationRepository)
 {
     var source = resolvedPackage.Load();
     using (var packageStream = source.OpenStream())
         destinationRepository.Publish(resolvedPackage.FullName + ".wrap", packageStream);
     destinationRepository.RefreshPackages();
 }
 public PackageUpdatedResult(IPackageInfo previousPackage, IPackageInfo package, ISupportPublishing repository)
     : base(package, repository)
 {
     PreviousPackage = previousPackage;
 }
 IPackageInfo GetExistingPackage(ISupportPublishing destinationRepository, ResolvedPackage foundPackage, Func<Version, bool> versionSelector)
 {
     return destinationRepository.PackagesByName.Contains(foundPackage.Identifier.Name)
                    ? destinationRepository.PackagesByName[foundPackage.Identifier.Name]
                              .Where(x => foundPackage.Identifier.Version != null && versionSelector(x.Version))
                              .OrderByDescending(x => x.Version)
                              .FirstOrDefault()
                    : null;
 }
 public PackageUpToDateResult(IPackageInfo existingUpToDateVersion, ISupportPublishing repository)
 {
     _existingUpToDateVersion = existingUpToDateVersion;
     _repository = repository;
 }
 public PackageUpdatedResult(IPackageInfo previousPackage, IPackageInfo package, ISupportPublishing repository)
     : base(package, repository)
 {
     PreviousPackage = previousPackage;
 }
示例#9
0
 public PackageAddedResult(IPackageInfo package, ISupportPublishing repository)
 {
     Package    = package;
     Repository = repository;
 }
示例#10
0
        IEnumerable <ICommandOutput> ValidateInputs()
        {
            var namedRepository = GetRemoteRepository(Remote);

            if (namedRepository == null)
            {
                yield return(new Errors.UnknownRemoteRepository(Remote));

                foreach (var _ in HintRemoteRepositories())
                {
                    yield return(_);
                }
                yield break;
            }

            if (User != null && Pwd == null)
            {
                yield return(new Errors.IncompleteAuthentication());

                yield break;
            }

            _authenticationSupport = namedRepository as ISupportAuthentication;

            if (_authenticationSupport == null)
            {
                yield return(new Warning("Remote repository '{0}' does not support authentication, ignoring authentication info.", namedRepository.Name));

                _authenticationSupport = new NullAuthentication();
            }

            _remoteRepository = namedRepository as ISupportPublishing;

            if (_remoteRepository == null)
            {
                yield return(new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name));

                yield break;
            }
            if (Path != null)
            {
                var packageFile = FileSystem.GetFile(Path);
                if (!packageFile.Exists)
                {
                    yield return(new Errors.FileNotFound(Path));

                    yield break;
                }
                else
                {
                    _packageStream   = () => packageFile.OpenRead();
                    _packageFileName = packageFile.Name;
                    var package = new CachedZipPackage(null, packageFile, null);
                    _packageName    = package.Name;
                    _packageVersion = package.Version;
                }
            }
            else if (Name != null)
            {
                // get latest version of the Named package
                if (!HostEnvironment.CurrentDirectoryRepository.PackagesByName.Contains(Name))
                {
                    yield return(new Error("No package named '{0}' was found.", Name));

                    yield break;
                }
                var packageToCopy = HostEnvironment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x => x.Version).First();
                _packageStream   = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName     = packageToCopy.Name;
                _packageVersion  = packageToCopy.Version;
            }
            else
            {
                yield return(new Error("Please specify either a file path using the -Path input, or a name using -Name."));
            }
        }
示例#11
0
 public PackageUpToDateResult(IPackageInfo existingUpToDateVersion, ISupportPublishing repository)
 {
     _existingUpToDateVersion = existingUpToDateVersion;
     _repository = repository;
 }