Exemple #1
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationAdder efCoreMigrationAdder,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
     SourceCodeDownloadService sourceCodeDownloadService,
     SolutionFileModifier solutionFileModifier,
     NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
     VirtualFileProvider virtualFileProvider
     )
     : base(jsonSerializer,
            projectNugetPackageAdder,
            dbContextFileBuilderConfigureAdder,
            efCoreMigrationAdder,
            derivedClassFinder,
            projectNpmPackageAdder,
            npmGlobalPackagesChecker,
            remoteServiceExceptionHandler,
            sourceCodeDownloadService,
            solutionFileModifier,
            nugetPackageToLocalReferenceConverter)
 {
     VirtualFileProvider = virtualFileProvider;
 }
Exemple #2
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationManager efCoreMigrationManager,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
     SourceCodeDownloadService sourceCodeDownloadService,
     SolutionFileModifier solutionFileModifier,
     NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
     AngularSourceCodeAdder angularSourceCodeAdder,
     NewCommand newCommand,
     BundleCommand bundleCommand,
     CliHttpClientFactory cliHttpClientFactory,
     ICmdHelper cmdHelper,
     ILocalEventBus localEventBus)
 {
     JsonSerializer                        = jsonSerializer;
     ProjectNugetPackageAdder              = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder    = dbContextFileBuilderConfigureAdder;
     EfCoreMigrationManager                = efCoreMigrationManager;
     DerivedClassFinder                    = derivedClassFinder;
     ProjectNpmPackageAdder                = projectNpmPackageAdder;
     NpmGlobalPackagesChecker              = npmGlobalPackagesChecker;
     RemoteServiceExceptionHandler         = remoteServiceExceptionHandler;
     SourceCodeDownloadService             = sourceCodeDownloadService;
     SolutionFileModifier                  = solutionFileModifier;
     NugetPackageToLocalReferenceConverter = nugetPackageToLocalReferenceConverter;
     AngularSourceCodeAdder                = angularSourceCodeAdder;
     NewCommand            = newCommand;
     BundleCommand         = bundleCommand;
     CmdHelper             = cmdHelper;
     LocalEventBus         = localEventBus;
     _cliHttpClientFactory = cliHttpClientFactory;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }
Exemple #3
0
    public virtual async Task <ModuleWithMastersInfo> AddAsync([NotNull] string solutionFile,
                                                               [NotNull] string moduleName,
                                                               string version,
                                                               bool skipDbMigrations            = false,
                                                               bool withSourceCode              = false,
                                                               bool addSourceCodeToSolutionFile = false,
                                                               bool newTemplate    = false,
                                                               bool newProTemplate = false)
    {
        Check.NotNull(solutionFile, nameof(solutionFile));
        Check.NotNull(moduleName, nameof(moduleName));

        await PublishEventAsync(1, "Retriving module info...");

        var module = await GetModuleInfoAsync(moduleName, newTemplate, newProTemplate);


        await PublishEventAsync(2, "Removing incompatible packages from module...");

        module = RemoveIncompatiblePackages(module, version);

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

        var projectFiles = ProjectFinder.GetProjectFiles(solutionFile);

        await AddNugetAndNpmReferences(module, projectFiles, !(newTemplate || newProTemplate));

        if (withSourceCode || newTemplate || newProTemplate)
        {
            var modulesFolderInSolution = Path.Combine(Path.GetDirectoryName(solutionFile), "modules");

            await PublishEventAsync(5, $"Downloading source code of {moduleName}");
            await DownloadSourceCodesToSolutionFolder(module, modulesFolderInSolution, version, newTemplate, newProTemplate);

            await PublishEventAsync(6, $"Deleting incompatible projects from the module source code");
            await RemoveUnnecessaryProjectsAsync(Path.GetDirectoryName(solutionFile), module, projectFiles);

            if (addSourceCodeToSolutionFile)
            {
                await PublishEventAsync(7, $"Adding module to solution file");

                await SolutionFileModifier.AddModuleToSolutionFileAsync(module, solutionFile);
            }

            await PublishEventAsync(8, $"Changing nuget references to local references");

            if (newTemplate || newProTemplate)
            {
                await NugetPackageToLocalReferenceConverter.Convert(module, solutionFile, $"{module.Name}.");
            }
            else
            {
                await NugetPackageToLocalReferenceConverter.Convert(module, solutionFile);
            }

            await AddAngularSourceCode(modulesFolderInSolution, solutionFile, module.Name, newTemplate || newProTemplate);
        }
        else
        {
            await AddAngularPackages(solutionFile, module);
        }

        await RunBundleForBlazorAsync(projectFiles, module);

        await ModifyDbContext(projectFiles, module, skipDbMigrations);

        var documentationLink = module.GetFirstDocumentationLinkOrNull();

        if (documentationLink != null)
        {
            CmdHelper.OpenWebPage(documentationLink);
        }

        return(module);
    }