Example #1
0
        public bool Match(string suppliedValue, RolloutStrategyAttribute attr)
        {
            var vals    = attr.Values.Where(v => v != null).Select(v => new Version(v.ToString())).ToList();
            var version = new Version(suppliedValue);

            switch (attr.Conditional)
            {
            case RolloutStrategyAttributeConditional.EQUALS:
            case RolloutStrategyAttributeConditional.INCLUDES:
                return(vals.Any(v => version.Equals(v)));

            case RolloutStrategyAttributeConditional.ENDSWITH:
                break;

            case RolloutStrategyAttributeConditional.STARTSWITH:
                break;

            case RolloutStrategyAttributeConditional.GREATER:
                return(vals.Any(v => version.CompareTo(v) > 0));

            case RolloutStrategyAttributeConditional.GREATEREQUALS:
                return(vals.Any(v => version.CompareTo(v) >= 0));

            case RolloutStrategyAttributeConditional.LESS:
                return(vals.Any(v => version.CompareTo(v) < 0));

            case RolloutStrategyAttributeConditional.LESSEQUALS:
                return(vals.Any(v => version.CompareTo(v) <= 0));

            case RolloutStrategyAttributeConditional.NOTEQUALS:
            case RolloutStrategyAttributeConditional.EXCLUDES:
                return(!vals.Any(v => version.Equals(v)));

            case RolloutStrategyAttributeConditional.REGEX:
                break;

            case null:
                return(false);

            default:
                return(false);
            }

            return(false);
        }
Example #2
0
        /// <inheritdoc/>
        public BuildScriptSnippet GenerateBashBuildScriptSnippet(
            BuildScriptGeneratorContext ctx,
            PlatformDetectorResult detectorResult)
        {
            var javaPlatformDetectorResult = detectorResult as JavaPlatformDetectorResult;

            if (javaPlatformDetectorResult == null)
            {
                throw new ArgumentException(
                          $"Expected '{nameof(detectorResult)}' argument to be of type " +
                          $"'{typeof(JavaPlatformDetectorResult)}' but got '{detectorResult.GetType()}'.");
            }

            var manifestFileProperties = new Dictionary <string, string>();

            // Write the platform name and version to the manifest file
            manifestFileProperties[ManifestFilePropertyKeys.JavaVersion] = detectorResult.PlatformVersion;

            string command = string.Empty;

            if (javaPlatformDetectorResult.UsesMavenWrapperTool)
            {
                if (_commonOptions.ShouldPackage)
                {
                    command = JavaConstants.CreatePackageCommandUsingMavenWrapper;
                }
                else
                {
                    command = JavaConstants.CompileCommandUsingMavenWrapper;
                }
            }
            else if (javaPlatformDetectorResult.UsesMaven)
            {
                if (_commonOptions.ShouldPackage)
                {
                    command = JavaConstants.CreatePackageCommandUsingMaven;
                }
                else
                {
                    command = JavaConstants.CompileCommandUsingMaven;
                }

                // Maven spits out lot of information related to downloading of packages which is too verbose.
                // Since the --quiet option is too quiet, we are trying to use a new switch below to just mute the
                // messages related to transfer progress of these downloads.
                // https://maven.apache.org/docs/3.6.1/release-notes.html#user-visible-changes
                var currentMavenVersion = new SemVer.Version(javaPlatformDetectorResult.MavenVersion);
                if (currentMavenVersion.CompareTo(JavaConstants.MinMavenVersionWithNoTransferProgressSupport) >= 0)
                {
                    command = $"{command} --no-transfer-progress";
                }
            }

            var scriptProps = new JavaBashBuildSnippetProperties();

            scriptProps.UsesMaven            = javaPlatformDetectorResult.UsesMaven;
            scriptProps.UsesMavenWrapperTool = javaPlatformDetectorResult.UsesMavenWrapperTool;
            scriptProps.Command = command;

            string script = TemplateHelper.Render(
                TemplateHelper.TemplateResource.JavaBuildSnippet,
                scriptProps,
                _logger);

            return(new BuildScriptSnippet
            {
                BashBuildScriptSnippet = script,
                BuildProperties = manifestFileProperties,
            });
        }
Example #3
0
 public int CompareTo(ExiledLibrary other) => Version.CompareTo(other.Version);
Example #4
0
        public async Task StartAsync()
        {
            Release latestRelease = null;

            SemVer.Version latestVersion;
            if (!_localInstall)
            {
                if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "LMS.Setup.exe")))
                {
                    Log.Debug("Setup file exists. let's go ahead and remove that.");
                    File.Delete("LMS.Setup.exe");
                }

                latestRelease = await GitHubOperations.GetLatestRelease();

                latestVersion = GitHubOperations.GetLatestVersion(latestRelease);
            }
            else
            {
                latestVersion = new SemVer.Version(FileVersionInfo.GetVersionInfo(_setupFilename).ProductVersion);
            }


            SemVer.Version currentVersion = GetCurrentInstalledVersion();

            Log.Information($"Installed: {currentVersion}    Available: {latestVersion}");

            if (currentVersion.CompareTo(latestVersion) < 0)
            {
                if (currentVersion.Equals(new SemVer.Version(1, 0, 0)))
                {
                    Log.Debug("New installation.");
                    if (_localInstall)
                    {
                        UpdateRequired();
                    }
                    else
                    {
                        await UpdateRequired(latestRelease);
                    }

                    return;
                }

                Log.Debug("Existing installation.");
                Uninstall();
                if (_localInstall)
                {
                    UpdateRequired();
                }
                else
                {
                    await UpdateRequired(latestRelease);
                }
                return;
            }

            if (currentVersion.CompareTo(latestVersion) > 0)
            {
                Log.Warning("The installed version is newer than what is currently available.");
                Log.Warning("I'm going to uninstall the program.");

                Uninstall();
                if (_localInstall)
                {
                    UpdateRequired();
                }
                else
                {
                    await UpdateRequired(latestRelease);
                }
                return;
            }

            if (currentVersion.CompareTo(latestVersion) == 0)
            {
                Log.Information("No update is required at this time.");
                Log.Information("Checking installation folder integrity.");
                if (File.Exists(Path.Combine(GetProgramFilesPath(), "License Monitoring System", "LMS.exe")))
                {
                    Log.Information("All looks good!");
                    return;
                }

                Log.Warning("Executable is missing from the installation folder.");
                Log.Warning("Attempting to reinstall the application.");

                Uninstall();
                if (_localInstall)
                {
                    UpdateRequired();
                }
                else
                {
                    await UpdateRequired(latestRelease);
                }
            }
        }