예제 #1
0
        private void ProcessRun1(IRepositoryGeneratorParameters parameters, string targetDirectory, string solutionFilePath)
        {
            var files = Directory.GetFiles(targetDirectory, "*.*", SearchOption.AllDirectories).Select(x => new FileInfo(x));

            foreach (var file in files)
            {
                switch (file.Name)
                {
                case "ArcadeRepo.sln":
                {
                    File.Copy(file.FullName, solutionFilePath);
                    File.Delete(file.FullName);
                    break;
                }

                case "ArcadeRepo.csproj":
                {
                    string newDir = Path.Combine(targetDirectory, "src", parameters.ProjectName);
                    Directory.CreateDirectory(newDir);
                    string newPath = Path.Combine(targetDirectory, "src", parameters.ProjectName, $"{parameters.ProjectName}.csproj");
                    File.Move(file.FullName, newPath);
                    file.Directory.Delete(true);
                    break;
                }
                }
            }
        }
 /// <summary>
 /// The Create.
 /// </summary>
 /// <param name="parameters">The parameters<see cref="IRepositoryGeneratorParameters"/>.</param>
 /// <returns>The <see cref="Dictionary{string, string}"/>.</returns>
 public Dictionary <string, string> Create(IRepositoryGeneratorParameters parameters)
 {
     return(CreateReplacementsDictionary(
                parameters.ProjectName,
                parameters.Description,
                parameters.RootNamespace,
                parameters.RepositoryName,
                parameters.TargetFramework));
 }
예제 #3
0
        public async Task CreateRepositoryAsync(IRepositoryGeneratorParameters parameters, CancellationToken cancellationToken = default)
        {
            string zipFileName      = Guid.NewGuid().ToString("N");
            string zipFilePath      = Path.Combine(parameters.Output, $"{zipFileName}.zip");
            string targetDirectory  = Path.Combine(parameters.Output, parameters.RepositoryName);
            string solutionFilePath = Path.Combine(targetDirectory, $"{parameters.SolutionName}.sln");

            SlowlyRemoveAndRecreateDirectory(targetDirectory);

            await Services.Downloader.DownloadFileAsync(DownloadUrls.Arcade, zipFilePath);

            await Services.Expander.ExpandFileAsync(zipFilePath, targetDirectory);

            ProcessRun1(parameters, targetDirectory, solutionFilePath);

            var replacements = Services.Replace.Create(parameters);

            ProcessRun2(targetDirectory, replacements);

            if (File.Exists(solutionFilePath))
            {
                await Services.Opener.OpenRepositoryAsync(solutionFilePath);
            }
        }