Ejemplo n.º 1
0
    protected virtual async Task RunInstallLibsAsync(string fileDirectory)
    {
        var args = new CommandLineArgs("install-libs");

        args.Options.Add(InstallLibsCommand.Options.WorkingDirectory.Short, fileDirectory);

        await InstallLibsCommand.ExecuteAsync(args);
    }
Ejemplo n.º 2
0
    public async Task AddMvcPackageAsync(string directory, NpmPackageInfo npmPackage, string version = null,
                                         bool skipInstallingLibs = false)
    {
        var packageJsonFilePath = Path.Combine(directory, "package.json");

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

        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 (skipInstallingLibs)
            {
                return;
            }

            await InstallLibsCommand.ExecuteAsync(
                new CommandLineArgs("install-libs")
                );
        }
    }