Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YarnRunner" /> class.
 /// </summary>
 /// <param name="fileSystem">The file system</param>
 /// <param name="environment">The environment</param>
 /// <param name="processRunner">The process runner</param>
 /// <param name="toolLocator">The tool locator</param>
 public YarnRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner,
                   IToolLocator toolLocator)
     : base(fileSystem, environment, processRunner, toolLocator)
 {
     _fileSystem = fileSystem;
     _platform   = environment.Platform;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MutableCakeEnvironment" /> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="runtime">The runtime.</param>
        /// <param name="appRoot">App root path</param>
        public MutableCakeEnvironment(ICakePlatform platform, ICakeRuntime runtime, string appRoot = null)
        {
            _platform = platform;
            _runtime  = runtime;
            var rootPath = string.IsNullOrEmpty(appRoot) ? Assembly.GetExecutingAssembly().Location : appRoot;

            _applicationRoot = System.IO.Path.GetDirectoryName(rootPath);

            WorkingDirectory = new DirectoryPath(Environment.CurrentDirectory);
            var pathEnv = Environment.GetEnvironmentVariable("PATH");

            if (!string.IsNullOrEmpty(pathEnv))
            {
                _paths = pathEnv.Split(new char[] { _platform.IsUnix() ? ':' : ';' }, StringSplitOptions.RemoveEmptyEntries)
                         .Select(s => s.Trim())
                         .Where(s => s.Length > 0)
                         .ToList();
            }
            else
            {
                _paths = new List <string>();
            }
            _addedPaths   = new List <string>();
            _dynamicPaths = new List <string>();
        }
 /// <summary>
 /// Determines whether the specified platform is a Linux platform.
 /// </summary>
 /// <param name="platform">The platform.</param>
 /// <returns><c>true</c> if the platform is a Linux platform; otherwise <c>false</c>.</returns>
 public static bool IsLinux(this ICakePlatform platform)
 {
     if (platform == null)
     {
         throw new ArgumentNullException(nameof(platform));
     }
     return(EnvironmentHelper.IsLinux(platform.Family));
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CakeEnvironment" /> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="runtime">The runtime.</param>
        public CakeEnvironment(ICakePlatform platform, ICakeRuntime runtime)
        {
            _platform        = platform;
            _runtime         = runtime;
            _applicationRoot = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            WorkingDirectory = new DirectoryPath(System.IO.Directory.GetCurrentDirectory());
        }
Esempio n. 5
0
 /// <summary>
 /// Determines whether the specified platform is a Unix platform.
 /// </summary>
 /// <param name="platform">The platform.</param>
 /// <returns><c>true</c> if the platform is a Unix platform; otherwise <c>false</c>.</returns>
 public static bool IsUnix(this ICakePlatform platform)
 {
     if (platform == null)
     {
         throw new ArgumentNullException("platform");
     }
     return(Machine.IsUnix(platform.Family));
 }
Esempio n. 6
0
 public LiquibaseRunner(IProcessRunner processRunner, ICakeLog log, IToolLocator tools, IGlobber globber, ICakePlatform platform)
 {
     ProcessRunner = processRunner ?? throw new ArgumentNullException(nameof(processRunner));
     Log           = log ?? throw new ArgumentNullException(nameof(log));
     Tools         = tools ?? throw new ArgumentNullException(nameof(tools));
     Globber       = globber ?? throw new ArgumentNullException(nameof(Globber));
     Platform      = platform ?? throw new ArgumentNullException(nameof(platform));
 }
Esempio n. 7
0
        public LiquibaseRunnerTests()
        {
            _processRunner = Substitute.For <IProcessRunner>();
            _cakeLog       = Substitute.For <ICakeLog>();
            _cakeTools     = Substitute.For <IToolLocator>();
            _globber       = new PassThroughGlobber();
            _platform      = Substitute.For <ICakePlatform>();

            _settings = new LiquibaseSettings();
            _runner   = new LiquibaseRunner(_processRunner, _cakeLog, _cakeTools, _globber, _platform);
        }
 private static string GetXPlatFolderPath(ICakePlatform platform, SpecialPath path)
 {
     if (platform.IsUnix())
     {
         return(Native.Unix.GetFolder(path));
     }
     else if (platform.Family == PlatformFamily.Windows)
     {
         return(Native.Windows.GetFolder(path));
     }
     throw new PlatformNotSupportedException();
 }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CakeEnvironment" /> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="runtime">The runtime.</param>
        public CakeEnvironment(ICakePlatform platform, ICakeRuntime runtime)
        {
            Platform = platform;
            Runtime  = runtime;

            // Get the application root.
            var assembly = AssemblyHelper.GetExecutingAssembly();
            var path     = PathHelper.GetDirectoryName(assembly.Location);

            ApplicationRoot = new DirectoryPath(path);

            // Get the working directory.
            WorkingDirectory = new DirectoryPath(System.IO.Directory.GetCurrentDirectory());
        }
Esempio n. 10
0
        public static DirectoryPath GetFolderPath(ICakePlatform platform, SpecialPath path)
        {
            if (path == SpecialPath.LocalTemp)
            {
                return(new DirectoryPath(System.IO.Path.GetTempPath()));
            }

            var result = GetXPlatFolderPath(platform, path);

            if (result != null)
            {
                return(new DirectoryPath(result));
            }

            const string format = "The special path '{0}' is not supported.";

            throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, format, path));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MutableCakeEnvironment" /> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="runtime">The runtime.</param>
        public MutableCakeEnvironment( ICakePlatform platform, ICakeRuntime runtime )
        {
            _platform = platform;
            _runtime = runtime;
            _applicationRoot = System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );

            WorkingDirectory = new DirectoryPath( Environment.CurrentDirectory );
            var pathEnv = Environment.GetEnvironmentVariable( "PATH" );
            if( !string.IsNullOrEmpty( pathEnv ) )
            {
                _paths = pathEnv.Split( new char[] { _platform.IsUnix() ? ':' : ';' }, StringSplitOptions.RemoveEmptyEntries )
                                .Select( s => s.Trim() )
                                .Where( s => s.Length > 0 )
                                .ToList();
            }
            else
            {
                _paths = new List<string>();
            }
            _addedPaths = new List<string>();
            _dynamicPaths = new List<string>();
        }
        public static DirectoryPath GetFolderPath(ICakePlatform platform, SpecialPath path)
        {
            if (path == SpecialPath.LocalTemp)
            {
                return(new DirectoryPath(System.IO.Path.GetTempPath()));
            }

#if NETCORE
            var result = GetXPlatFolderPath(platform, path);
            if (result != null)
            {
                return(new DirectoryPath(result));
            }
#else
            switch (path)
            {
            case SpecialPath.ApplicationData:
                return(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)));

            case SpecialPath.CommonApplicationData:
                return(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)));

            case SpecialPath.LocalApplicationData:
                return(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)));

            case SpecialPath.ProgramFiles:
                return(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)));

            case SpecialPath.ProgramFilesX86:
                return(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)));

            case SpecialPath.Windows:
                return(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.Windows)));
            }
#endif
            const string format = "The special path '{0}' is not supported.";
            throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, format, path));
        }
        /// <summary>
        /// Automatically determines the <see cref="OSTarget"/>.
        /// </summary>
        /// <param name="source">The target specified by user, can be null.</param>
        /// <param name="platform">The Cake platform.</param>
        /// <returns>Returns a <see cref="OSTarget"/> based on input parameters.</returns>
        /// <remarks>Throws an exception if it can't determine the OS.</remarks>
        public static OSTarget GetTarget(OSTarget?source, ICakePlatform platform)
        {
            if (source.HasValue)
            {
                return(source.Value);
            }
            else
            {
                switch (platform.Family)
                {
                case PlatformFamily.Linux:
                    return(platform.Is64Bit ? OSTarget.Linux64 : OSTarget.Linux86);

                case PlatformFamily.OSX:
                    return(platform.Is64Bit ? OSTarget.MacOSX64 : OSTarget.MacOSX86);

                case PlatformFamily.Windows:
                    return(platform.Is64Bit ? OSTarget.Windows64 : OSTarget.Windows86);

                default:
                    throw new Exception($"No OSTarget is given in settings, couldn't determine the platform: {platform.Family} {(platform.Is64Bit ? "x64" : "x86")}");
                }
            }
        }
Esempio n. 14
0
 protected PulumiRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IToolLocator tools)
     : base(fileSystem, environment, processRunner, tools)
 {
     _platform = environment.Platform;
 }