public Task AddAsync(string directory, NpmPackageInfo npmPackage)
        {
            var packageJsonFilePath = Path.Combine(directory, "package.json");

            if (!File.Exists(packageJsonFilePath) || File.ReadAllText(packageJsonFilePath).Contains($"\"{npmPackage.Name}\""))
            {
                return(Task.CompletedTask);
            }

            Logger.LogInformation($"Installing '{npmPackage.Name}' package to the project '{packageJsonFilePath}'...");

            using (DirectoryHelper.ChangeCurrentDirectory(directory))
            {
                Logger.LogInformation("yarn add " + npmPackage.Name);
                CmdHelper.RunCmd("yarn add " + npmPackage.Name);

                Logger.LogInformation("gulp");
                CmdHelper.RunCmd("gulp");
            }

            return(Task.CompletedTask);
        }
        public Task AddMvcPackageAsync(string directory, NpmPackageInfo npmPackage, string version = null,
                                       bool skipGulpCommand = false)
        {
            var packageJsonFilePath = Path.Combine(directory, "package.json");

            if (!File.Exists(packageJsonFilePath) ||
                File.ReadAllText(packageJsonFilePath).Contains($"\"{npmPackage.Name}\""))
            {
                return(Task.CompletedTask);
            }

            Logger.LogInformation($"Installing '{npmPackage.Name}' package to the project '{packageJsonFilePath}'...");


            if (version == null)
            {
                version = DetectAbpVersionOrNull(Path.Combine(directory, "package.json"));
            }

            var versionPostfix = version != null ? $"@{version}" : string.Empty;

            using (DirectoryHelper.ChangeCurrentDirectory(directory))
            {
                Logger.LogInformation("yarn add " + npmPackage.Name + versionPostfix);
                CmdHelper.RunCmd("yarn add " + npmPackage.Name + versionPostfix);

                if (skipGulpCommand)
                {
                    return(Task.CompletedTask);
                }

                Logger.LogInformation("gulp");
                CmdHelper.RunCmd("gulp");
            }

            return(Task.CompletedTask);
        }
Beispiel #3
0
        public Task AddAsync(string directory, NpmPackageInfo npmPackage)
        {
            var packageJsonFilePath = Path.Combine(directory, "package.json");

            if (!File.Exists(packageJsonFilePath))
            {
                return(Task.CompletedTask);
            }

            Logger.LogInformation($"Installing '{npmPackage.Name}' package to the project '{packageJsonFilePath}'...");

            using (DirectoryHelper.ChangeCurrentDirectory(directory))
            {
                Logger.LogInformation("yarn add " + npmPackage.Name + "... " + Directory.GetCurrentDirectory());
                var procStartInfo = new ProcessStartInfo("cmd.exe", "/C yarn add " + npmPackage.Name);
                Process.Start(procStartInfo).WaitForExit();

                Logger.LogInformation("gulp... " + Directory.GetCurrentDirectory());
                procStartInfo = new ProcessStartInfo("cmd.exe", "/C gulp");
                Process.Start(procStartInfo).WaitForExit();
            }

            return(Task.CompletedTask);
        }
        protected virtual async Task DownloadAngularSourceCode(string angularDirectory, NpmPackageInfo package,
                                                               string version = null)
        {
            var targetFolder = Path.Combine(angularDirectory, "projects",
                                            package.Name.RemovePreFix("@").Replace("/", "-"));

            if (Directory.Exists(targetFolder))
            {
                Directory.Delete(targetFolder, true);
            }

            await SourceCodeDownloadService.DownloadNpmPackageAsync(
                package.Name,
                targetFolder,
                version
                );
        }