Skip to content

Commit

Permalink
Merge pull request #18351 from abpframework/ProjectNpmPackageAdder-re…
Browse files Browse the repository at this point in the history
…movemvcpackage-2

Adjust ProjectNpmPackageAdder & Add npm package info to web projects
  • Loading branch information
yekalkan committed Dec 4, 2023
2 parents 92d4383 + 0db741c commit 9040e0e
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
2 changes: 2 additions & 0 deletions common.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<Pack>true</Pack>
<PackagePath>content\</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<None Remove="*.abppkg" />
<Content Include="*.abppkg">
<Pack>true</Pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,34 @@ public class ProjectNpmPackageAdder : ITransientDependency
}
}

public async Task RemoveMvcPackageAsync(string directory, NpmPackageInfo npmPackage,
bool skipInstallingLibs = false)
{
var packageJsonFilePath = Path.Combine(directory, "package.json");
if (!File.Exists(packageJsonFilePath) ||
!File.ReadAllText(packageJsonFilePath).Contains($"\"{npmPackage.Name}\""))
{
return;
}

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


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

if (skipInstallingLibs)
{
return;
}

Logger.LogInformation("Installing client-side packages...");
await InstallLibsService.InstallLibsAsync(directory);
}
}

private string DetectAbpVersionOrNull(string packageJsonFile)
{
if (string.IsNullOrEmpty(packageJsonFile) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"role": "lib.mvc"
"role": "lib.mvc",
"npmDependencies": {
"@abp/blogging": {
"version": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"role": "lib.mvc"
"role": "lib.mvc",
"npmDependencies": {
"@abp/cms-kit.admin": {
"version": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"role": "lib.mvc"
"role": "lib.mvc",
"npmDependencies": {
"@abp/cms-kit.public": {
"version": ""
}
}
}
7 changes: 6 additions & 1 deletion modules/cms-kit/src/Volo.CmsKit.Web/Volo.CmsKit.Web.abppkg
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"role": "lib.mvc"
"role": "lib.mvc",
"npmDependencies": {
"@abp/cms-kit": {
"version": ""
}
}
}
7 changes: 6 additions & 1 deletion modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.abppkg
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"role": "lib.mvc"
"role": "lib.mvc",
"npmDependencies": {
"@abp/docs": {
"version": ""
}
}
}

0 comments on commit 9040e0e

Please sign in to comment.