Example #1
0
        public string AbbreviatePackageSourceType(PackageSourceType type)
        {
            string abbreviation;

            if (!PackageSourceTypes.TryGetValue(type, out abbreviation))
            {
                throw new ArgumentException($"The package source type '{type}' does not have an abbreviation.");
            }

            return(abbreviation);
        }
 public PackageSource(
     PackageSourceType type,
     string sourceUri,
     string pushUri,
     IFeedAuthorization sourceAuth,
     IFeedAuthorization pushAuth)
 {
     Type                = type;
     SourceUri           = sourceUri;
     PushUri             = pushUri;
     SourceAuthorization = sourceAuth;
     PushAuthorization   = pushAuth;
 }
Example #3
0
        private string GetDownloadFilePath(PackageSourceType CompatibilityCheckerType, string packageToDownload)
        {
            var fileToDownload   = $"{packageToDownload}.json.gz";
            var downloadFilePath = fileToDownload;

            switch (CompatibilityCheckerType)
            {
            case PackageSourceType.NUGET:
                break;

            case PackageSourceType.SDK:
                downloadFilePath = "namespaces/" + fileToDownload;
                break;

            default:
                break;
            }

            return(downloadFilePath);
        }
Example #4
0
 public static PackageVersionPair ReferenceToPackageVersionPair(ExternalReference reference, PackageSourceType sourceType = PackageSourceType.NUGET)
 {
     if (reference != null)
     {
         string version = reference.Version ?? "";
         if (NuGetVersion.TryParse(reference.Version, out var parsedVersion))
         {
             version = parsedVersion.ToNormalizedString();
         }
         return(new PackageVersionPair {
             PackageId = reference.Identity, Version = version, PackageSourceType = sourceType
         });
     }
     return(null);
 }
Example #5
0
        public List <PackageListInfo> ListPackages(bool includeUninstalled = false, PackageListState showState = PackageListState.All, PackageSourceType showSource = PackageSourceType.All)
        {
            // list packages [options] filter
            // start [options] intent
            var builder = new ProcessArgumentBuilder();

            runner.AddSerial(AdbSerial, builder);

            builder.Append("shell");
            builder.Append("pm");

            builder.Append("list");
            builder.Append("packages");
            builder.Append("-f");
            builder.Append("-i");

            if (showState == PackageListState.OnlyDisabled)
            {
                builder.Append("-d");
            }
            else if (showState == PackageListState.OnlyEnabled)
            {
                builder.Append("-e");
            }

            if (showSource == PackageSourceType.OnlySystem)
            {
                builder.Append("-s");
            }
            else if (showSource == PackageSourceType.OnlyThirdParty)
            {
                builder.Append("-3");
            }

            if (includeUninstalled)
            {
                builder.Append("-u");
            }

            var r = runner.RunAdb(AndroidSdkHome, builder);

            var results = new List <PackageListInfo>();

            const string rxPackageListInfo = "^package:(?<path>.*?)=(?<package>.*?)\\s+installer=(?<installer>.*?)$";

            foreach (var line in r.StandardOutput)
            {
                var m = Regex.Match(line, rxPackageListInfo, RegexOptions.Singleline);

                var installPath = m?.Groups?["path"]?.Value;
                var packageName = m?.Groups?["package"]?.Value;
                var installer   = m?.Groups?["installer"]?.Value;

                if (!string.IsNullOrEmpty(installPath) && !string.IsNullOrEmpty(packageName))
                {
                    results.Add(new PackageListInfo
                    {
                        InstallPath = new FileInfo(installPath),
                        PackageName = packageName,
                        Installer   = installer,
                    });
                }
            }
            return(results);
        }
        public static List <AdbPackageListInfo> PmListPackages(this ICakeContext context, bool includeUninstalled = false, PackageListState showState = PackageListState.All, PackageSourceType showSource = PackageSourceType.All, AdbToolSettings settings = null)
        {
            var t = GetAdbTool(context);

            return(t.ListPackages(includeUninstalled, showState, showSource, settings));
        }