Ejemplo n.º 1
0
        public void PushPackage(string packageFileName, Stream packageStream)
        {
            packageFileName = PackageNameUtility.NormalizeFileName(packageFileName);

            var packageFile = _directory.GetFile(packageFileName);
            using (var destinationStream = packageFile.OpenWrite())
                packageStream.CopyTo(destinationStream);

            #pragma warning disable 612,618
            var zipPackage = new ZipFilePackage(packageFile);
            IndexDocument.Document.Root.Add(
                    new XElement("wrap",
                                 new XAttribute("name", zipPackage.Name),
                                 new XAttribute("version", zipPackage.Version),
                                 new XAttribute("semantic-version", zipPackage.SemanticVersion),
                                 new XElement("link",
                                              new XAttribute("rel", "package"),
                                              new XAttribute("href", packageFile.Name)),
                                 zipPackage.Dependencies.Select(x => new XElement("depends", x.ToString()))
                            ));
            #pragma warning restore 612,618

            SaveIndex(IndexDocument);

            return;
        }
Ejemplo n.º 2
0
        IEnumerable<ICommandOutput> ValidateInputs()
        {
            // TODO: HACK HACK HACK
            var namedRepository = Remotes.PublishRepositories(Remote).SelectMany(_ => _).FirstOrDefault();

            if (namedRepository == null)
            {
                yield return new UnknownRemoteName(Remote);
                foreach (var _ in HintRemoteRepositories()) yield return _;
                yield break;
            }

            if ((Username != null && Password == null) || (Username == null && Password != null))
            {
                yield return new IncompleteCredentials();
                yield break;
            }

            bool hasAuth = Username != null && Password != null;
            if (hasAuth) _credentials = new NetworkCredential(Username, Password);
            _authenticationSupport = namedRepository.Feature<ISupportAuthentication>();
            if (hasAuth && _authenticationSupport == null)
            {
                yield return new RemoteAuthenticatioNotSupported(namedRepository);
                yield break;
            }

            _authenticationSupport = _authenticationSupport ?? new NullAuthentication();

            //_repositories = namedRepository.
            _remoteRepository = namedRepository;
            var publishingRepo = _remoteRepository.Feature<ISupportPublishing>();

            if (publishingRepo == 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 FileNotFound(Path);
                    yield break;
                }
                _packageStream = packageFile.OpenRead;
                _packageFileName = packageFile.Name;
                // TODO: This looks iffy at best
                var package = new ZipFilePackage(packageFile);
                _packageName = package.Name;
                _packageVersion = package.SemanticVersion;
            }
            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.SemanticVersion).First();
                _packageStream = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName = packageToCopy.Name;
                _packageVersion = packageToCopy.SemanticVersion;
            }
            else
            {
                yield return new Error("Please specify either a file path using the -Path input, or a name using -Name.");
            }
        }
Ejemplo n.º 3
0
 public override void when_creating_package()
 {
     Packager.NewFromFiles(_packageFile, _content);
     _package = new ZipFilePackage(_packageFile);
 }