Exemplo n.º 1
0
            public void Should_Throw_If_Arguments_Are_WhiteSpace()
            {
                // Given
                var settings = new NpmRunScriptSettings();

                // When
                var result = Record.Exception(() => settings.WithArguments(" "));

                // Then
                result.IsArgumentNullException("arguments");
            }
Exemplo n.º 2
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                NpmRunScriptSettings settings = null;

                // When
                var result = Record.Exception(() => settings.WithArguments("foo"));

                // Then
                result.IsArgumentNullException("settings");
            }
Exemplo n.º 3
0
        public static void TaskBuild(ICakeContext context)
        {
            Version(context);
            RestorePackages(context);

            var path = context.MakeAbsolute(context.File("./ENT.UI/Properties/PublishProfiles/FolderProfile.pubxml"));

            var msBuildSettings = new MSBuildSettings()
                                  .SetConfiguration("Release")
                                  .WithProperty("DeployOnBuild", "true")
                                  .WithProperty("PublishProfile", path.ToString());

            if (!string.IsNullOrEmpty(MsBuildLogger))
            {
                msBuildSettings.ArgumentCustomization = arguments =>
                                                        arguments.Append(string.Format("/logger:{0}", MsBuildLogger));
            }

            context.MSBuild("ENT.sln", msBuildSettings);

            var npmRunSettings = new NpmRunScriptSettings()
            {
                ScriptName       = "build-prod",
                WorkingDirectory = "ENT.UI/",
            };

            context.NpmRunScript(npmRunSettings);

            //Information("Backup node modules folder to " + NodeBackupPath);

            if (context.DirectoryExists("ENT.UI/node_modules"))
            {
                if (context.DirectoryExists(NodeBackupPath))
                {
                    //Information("Delete existing node modules backup");

                    context.DeleteDirectory(NodeBackupPath,
                                            new DeleteDirectorySettings
                    {
                        Recursive = true
                    });
                }

                //Information("Move working node modules to backup folder");
                try
                {
                    context.MoveDirectory("ENT.UI/node_modules", NodeBackupPath);
                }
                catch (Exception ex)
                {
                    context.Warning("Failed to move node modules to backup " + ex.ToString());
                }
            }
        }
Exemplo n.º 4
0
            public void Should_Set_Arguments()
            {
                // Given
                var settings  = new NpmRunScriptSettings();
                var arguments = "foo";

                // When
                settings.WithArguments(arguments);

                // Then
                settings.Arguments.Count.ShouldBe(1);
                settings.Arguments.ShouldContain(arguments);
            }
        public static void FrontEndNpmBuild(this ICakeContext context, string frontEndPath)
        {
            var directories = context.GetDirectories(frontEndPath);

            foreach (var directory in directories)
            {
                // TODO: Remove when we clean up old themes in Platform
                if (directory.GetDirectoryName().StartsWith("-"))
                {
                    continue;
                }

                var settings = new NpmRunScriptSettings
                {
                    ScriptName       = "build",
                    LogLevel         = NpmLogLevel.Info,
                    WorkingDirectory = directory
                };
                context.NpmRunScript(settings);
            }
        }
Exemplo n.º 6
0
        public Build()
        {
            Cake.Log.Verbosity = Verbosity.Diagnostic;

            const string solutionName     = "CK-Glouton";
            const string solutionFileName = "../" + solutionName + ".sln";

            var releasesDir = Cake.Directory("CodeCakeBuilder/Releases");

            var projects = Cake.ParseSolution(solutionFileName)
                           .Projects
                           .Where(p => !(p is SolutionFolder) &&
                                  p.Name != "CodeCakeBuilder");

            // We do not publish .Tests projects for this solution.
            var projectsToPublish = projects
                                    .Where(p => !p.Path.Segments.Contains("Tests"));

            SimpleRepositoryInfo gitInfo = Cake.GetSimpleRepositoryInfo();

            // Configuration is either "Debug" or "Release".
            string configuration = "Debug";

            Task("Check-Repository")
            .Does(() =>
            {
                if (!gitInfo.IsValid)
                {
                    if (Cake.IsInteractiveMode() &&
                        Cake.ReadInteractiveOption("Repository is not ready to be published. Proceed anyway?", 'Y', 'N') == 'Y')
                    {
                        Cake.Warning("GitInfo is not valid, but you choose to continue...");
                    }
                    else if (!Cake.AppVeyor().IsRunningOnAppVeyor)
                    {
                        throw new Exception("Repository is not ready to be published.");
                    }
                }

                if (gitInfo.IsValidRelease &&
                    (gitInfo.PreReleaseName.Length == 0 || gitInfo.PreReleaseName == "rc"))
                {
                    configuration = "Release";
                }

                Cake.Information("Publishing {0} projects with version={1} and configuration={2}: {3}",
                                 projectsToPublish.Count(),
                                 gitInfo.SafeSemVersion,
                                 configuration,
                                 projectsToPublish.Select(p => p.Name).Concatenate());
            });

            Task("Clean")
            .IsDependentOn("Check-Repository")
            .Does(() =>
            {
                Cake.CleanDirectories(projects.Select(p => p.Path.GetDirectory().Combine("bin")));
                Cake.CleanDirectories(releasesDir);
            });


            Task("Restore-NPM-Package")
            .IsDependentOn("Clean")
            .Does(() =>
            {
                var settings = new NpmInstallSettings();

                settings.LogLevel         = NpmLogLevel.Warn;
                settings.WorkingDirectory = "../src/CK.Glouton.Web/app";
                settings.InstallLocally();

                NpmInstallAliases.NpmInstall(this.Cake, settings);
            });
            Task("NPM-Build")
            .IsDependentOn("Restore-NPM-Package")
            .IsDependentOn("Clean")
            .Does(() =>
            {
                var settings = new NpmRunScriptSettings();

                settings.LogLevel         = NpmLogLevel.Info;
                settings.WorkingDirectory = "../src/CK.Glouton.Web/app";
                settings.ScriptName       = "build";

                NpmRunScriptAliases.NpmRunScript(this.Cake, settings);
            });

            Task("Build-With-Version")
            .IsDependentOn("Check-Repository")
            .IsDependentOn("Clean")
            .IsDependentOn("Restore-NPM-package")
            .IsDependentOn("NPM-Build")
            .Does(() =>
            {
                using (var tempSln = Cake.CreateTemporarySolutionFile(solutionFileName))
                {
                    tempSln.ExcludeProjectsFromBuild("CodeCakeBuilder");
                    Cake.DotNetCoreBuild(tempSln.FullPath.FullPath,
                                         new DotNetCoreBuildSettings().AddVersionArguments(gitInfo, s =>
                    {
                        s.Configuration = configuration;
                    }));
                }
            });

            Task("Unit-Testing")
            .IsDependentOn("Build-With-Version")
            .Does(() =>
            {
                var testProjects = projects.Where(p => p.Path.Segments.Contains("Tests"));

                var testNetFrameworkDlls = testProjects
                                           .Where(p => p.Name.EndsWith(".NetFramework"))
                                           .Select(p => p.Path.GetDirectory().CombineWithFilePath("bin/" + configuration + "/net461/" + p.Name + ".dll"));
                Cake.Information("Testing: {0}", string.Join(", ", testNetFrameworkDlls.Select(p => p.GetFilename().ToString())));
                Cake.NUnit(testNetFrameworkDlls);

                var testNetCoreDirectories = testProjects
                                             .Where(p => p.Name.EndsWith(".NetCore"))
                                             .Select(p => p.Path.GetDirectory());
                Cake.Information("Testing: {0}", string.Join(", ", testNetCoreDirectories.Select(p => p.GetDirectoryName().ToString())));
                foreach (var testNetCoreDirectory in testNetCoreDirectories)
                {
                    Cake.DotNetCoreRun(testNetCoreDirectory.FullPath);
                }
            });

            Task("Create-NuGet-Packages")
            .WithCriteria(() => gitInfo.IsValid)
            .IsDependentOn("Unit-Testing")
            .Does(() =>
            {
                Cake.CreateDirectory(releasesDir);
                foreach (SolutionProject p in projectsToPublish)
                {
                    Cake.Warning(p.Path.GetDirectory().FullPath);
                    var s = new DotNetCorePackSettings();
                    s.ArgumentCustomization = args => args.Append("--include-symbols");
                    s.NoBuild         = true;
                    s.Configuration   = configuration;
                    s.OutputDirectory = releasesDir;
                    s.AddVersionArguments(gitInfo);
                    Cake.DotNetCorePack(p.Path.GetDirectory().FullPath, s);
                }
            });

            Task("Push-NuGet-Packages")
            .WithCriteria(() => gitInfo.IsValid)
            .IsDependentOn("Create-NuGet-Packages")
            .Does(() =>
            {
                IEnumerable <FilePath> nugetPackages = Cake.GetFiles(releasesDir.Path + "/*.nupkg");
                if (Cake.IsInteractiveMode())
                {
                    var localFeed = Cake.FindDirectoryAbove("LocalFeed");
                    if (localFeed != null)
                    {
                        Cake.Information("LocalFeed directory found: {0}", localFeed);
                        if (Cake.ReadInteractiveOption("Do you want to publish to LocalFeed?", 'Y', 'N') == 'Y')
                        {
                            Cake.CopyFiles(nugetPackages, localFeed);
                        }
                    }
                }
                if (gitInfo.IsValidRelease)
                {
                    // All Version
                    PushNuGetPackages("MYGET_PREVIEW_API_KEY", "https://www.myget.org/F/glouton-preview/api/v2/package", nugetPackages);
                }
                else
                {
                    Debug.Assert(gitInfo.IsValidCIBuild);
                    PushNuGetPackages("MYGET_CI_API_KEY", "https://www.myget.org/F/glouton-ci/api/v2/package", nugetPackages);
                }
                if (Cake.AppVeyor().IsRunningOnAppVeyor)
                {
                    Cake.AppVeyor().UpdateBuildVersion(gitInfo.SafeSemVersion);
                }
            });

            // The Default task for this script can be set here.
            Task("Default")
            .IsDependentOn("Push-NuGet-Packages");
        }