示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#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);
        }
示例#4
0
        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
                );
        }