Пример #1
0
        public virtual async Task AddAsync(
            [NotNull] string solutionFile,
            [NotNull] string moduleName,
            string startupProject,
            bool skipDbMigrations = false)
        {
            Check.NotNull(solutionFile, nameof(solutionFile));
            Check.NotNull(moduleName, nameof(moduleName));

            var module = await FindModuleInfoAsync(moduleName);

            Logger.LogInformation($"Installing module '{module.Name}' to the solution '{Path.GetFileNameWithoutExtension(solutionFile)}'");

            var projectFiles = ProjectFinder.GetProjectFiles(solutionFile);

            foreach (var nugetPackage in module.NugetPackages)
            {
                var targetProjectFile = ProjectFinder.FindNuGetTargetProjectFile(projectFiles, nugetPackage.Target);
                if (targetProjectFile == null)
                {
                    Logger.LogDebug($"Target project is not available for NuGet package '{nugetPackage.Name}'");
                    continue;
                }

                await ProjectNugetPackageAdder.AddAsync(targetProjectFile, nugetPackage);
            }

            if (!module.NpmPackages.IsNullOrEmpty())
            {
                var targetProjects = ProjectFinder.FindNpmTargetProjectFile(projectFiles);
                if (targetProjects.Any())
                {
                    NpmGlobalPackagesChecker.Check();

                    foreach (var targetProject in targetProjects)
                    {
                        foreach (var npmPackage in module.NpmPackages.Where(p => p.ApplicationType.HasFlag(NpmApplicationType.Mvc)))
                        {
                            await ProjectNpmPackageAdder.AddAsync(Path.GetDirectoryName(targetProject), npmPackage);
                        }
                    }
                }
                else
                {
                    Logger.LogDebug("Target project is not available for NPM packages.");
                }
            }

            ModifyDbContext(projectFiles, module, startupProject, skipDbMigrations);
        }
Пример #2
0
 public ProjectNugetPackageAdder(
     IJsonSerializer jsonSerializer,
     ProjectNpmPackageAdder npmPackageAdder,
     DerivedClassFinder moduleClassFinder,
     ModuleClassDependcyAdder moduleClassDependcyAdder,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
 {
     JsonSerializer                = jsonSerializer;
     NpmPackageAdder               = npmPackageAdder;
     ModuleClassFinder             = moduleClassFinder;
     ModuleClassDependcyAdder      = moduleClassDependcyAdder;
     RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
     Logger = NullLogger <ProjectNugetPackageAdder> .Instance;
 }
Пример #3
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationAdder efCoreMigrationAdder,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
 {
     JsonSerializer                     = jsonSerializer;
     ProjectNugetPackageAdder           = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder = dbContextFileBuilderConfigureAdder;
     EfCoreMigrationAdder               = efCoreMigrationAdder;
     DerivedClassFinder                 = derivedClassFinder;
     ProjectNpmPackageAdder             = projectNpmPackageAdder;
     NpmGlobalPackagesChecker           = npmGlobalPackagesChecker;
     RemoteServiceExceptionHandler      = remoteServiceExceptionHandler;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }