Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into dev

pull/4498/head
Halil İbrahim Kalkan 6 years ago
parent
commit
2baf68ccb9
  1. 12
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs
  2. 6
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep.cs
  3. 45
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs

12
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs

@ -51,7 +51,7 @@ namespace Volo.Abp.Cli.Commands
var apiUrl = commandLineArgs.Options.GetOrNull(Options.ApiUrl.Short, Options.ApiUrl.Long);
if (string.IsNullOrWhiteSpace(apiUrl))
{
var environmentJson = File.ReadAllText("src/environments/environment.ts").Split("export const environment = ")[1].Replace(";", " ");
var environmentJson = File.ReadAllText("projects/dev-app/src/environments/environment.ts").Split("export const environment = ")[1].Replace(";", " ");
var environment = JObject.Parse(environmentJson);
apiUrl = environment["apis"]["default"]["url"].ToString();
}
@ -61,7 +61,7 @@ namespace Volo.Abp.Cli.Commands
output = commandLineArgs.Options.GetOrNull(Options.Output.Short, Options.Output.Long);
if (!string.IsNullOrWhiteSpace(output) && !(output.EndsWith("/") || output.EndsWith("\\")))
{
{
output += "/";
}
@ -110,7 +110,7 @@ namespace Volo.Abp.Cli.Commands
if (rootPath != "app")
{
Logger.LogInformation($"{rootPath} directory is creating");
}
}
if (rootPath == "app")
{
@ -536,7 +536,7 @@ namespace Volo.Abp.Cli.Commands
modelFileText.AppendLine(Environment.NewLine);
modelFileText.AppendLine($"import {{ {baseTypeName} }} from '{baseTypeKebabCase}';");
extends = "extends " + (!string.IsNullOrWhiteSpace(customBaseTypeName) ? customBaseTypeName : baseTypeName);
var modelIndex = CreateType(data, baseType, rootPath, modelIndexList, controllerPathName);
@ -628,7 +628,7 @@ namespace Volo.Abp.Cli.Commands
{
from = "./" + propertyTypeKebabCase;
}
modelFileText.Insert(0, $"import {{ {propertyType} }} from '{from}';");
modelFileText.Insert(0, Environment.NewLine);
modelIndexList.Add(modelIndex);
@ -816,4 +816,4 @@ namespace Volo.Abp.Cli.Commands
public bool IsOptional { get; set; }
public string BindingSourceId { get; set; }
}
}
}

6
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep.cs

@ -10,9 +10,9 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
{
var fileEntries = context.Files.Where(x =>
!x.IsDirectory &&
(x.Name.EndsWith("angular/src/environments/environment.ts", StringComparison.InvariantCultureIgnoreCase) ||
x.Name.EndsWith("angular/src/environments/environment.hmr.ts", StringComparison.InvariantCultureIgnoreCase) ||
x.Name.EndsWith("angular/src/environments/environment.prod.ts", StringComparison.InvariantCultureIgnoreCase))
(x.Name.EndsWith("angular/projects/dev-app/src/environments/environment.ts", StringComparison.InvariantCultureIgnoreCase) ||
x.Name.EndsWith("angular/projects/dev-app/src/environments/environment.hmr.ts", StringComparison.InvariantCultureIgnoreCase) ||
x.Name.EndsWith("angular/projects/dev-app/src/environments/environment.prod.ts", StringComparison.InvariantCultureIgnoreCase))
)
.ToList();

45
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs

@ -54,11 +54,12 @@ namespace Volo.Abp.Cli.ProjectModification
_npmGlobalPackagesChecker.Check();
var packagesUpdated = new ConcurrentDictionary<string, bool>();
async Task UpdateAsync(string file)
{
var updated = await UpdatePackagesInFile(file, includePreviews, switchToStable);
packagesUpdated.TryAdd(file, updated);
};
}
Task.WaitAll(fileList.Select(UpdateAsync).ToArray());
@ -66,23 +67,20 @@ namespace Volo.Abp.Cli.ProjectModification
{
var fileDirectory = Path.GetDirectoryName(file.Key).EnsureEndsWith(Path.DirectorySeparatorChar);
if (IsAngularProject(fileDirectory))
if (includePreviews)
{
if (includePreviews)
{
await CreateNpmrcFileAsync(Path.GetDirectoryName(file.Key));
}
else if (switchToStable)
{
await DeleteNpmrcFileAsync(Path.GetDirectoryName(file.Key));
}
await CreateNpmrcFileAsync(Path.GetDirectoryName(file.Key));
RunNpmInstall(fileDirectory);
}
else if (switchToStable)
{
await DeleteNpmrcFileAsync(Path.GetDirectoryName(file.Key));
RunYarn(fileDirectory);
}
RunYarn(fileDirectory);
if (!IsAngularProject(fileDirectory))
{
Thread.Sleep(500);
Thread.Sleep(1000);
RunGulp(fileDirectory);
}
}
@ -166,7 +164,8 @@ namespace Volo.Abp.Cli.ProjectModification
return File.Exists(Path.Combine(fileDirectory, "angular.json"));
}
protected virtual async Task<bool> UpdatePackagesInFile(string filePath, bool includePreviews = false, bool switchToStable = false)
protected virtual async Task<bool> UpdatePackagesInFile(string filePath, bool includePreviews = false,
bool switchToStable = false)
{
var packagesUpdated = false;
var fileContent = File.ReadAllText(filePath);
@ -201,7 +200,7 @@ namespace Volo.Abp.Cli.ProjectModification
bool includePreviews = false,
bool switchToStable = false)
{
var currentVersion = (string)package.Value;
var currentVersion = (string) package.Value;
var version = await GetLatestVersion(package, currentVersion, includePreviews, switchToStable);
@ -214,7 +213,8 @@ namespace Volo.Abp.Cli.ProjectModification
package.Value.Replace(versionWithPrefix);
Logger.LogInformation($"Updated {package.Name} to {version} in {filePath.Replace(Directory.GetCurrentDirectory(), "")}.");
Logger.LogInformation(
$"Updated {package.Name} to {version} in {filePath.Replace(Directory.GetCurrentDirectory(), "")}.");
return true;
}
@ -256,12 +256,12 @@ namespace Volo.Abp.Cli.ProjectModification
protected virtual List<JProperty> GetAbpPackagesFromPackageJson(JObject fileObject)
{
var dependencyList = new[] { "dependencies", "devDependencies", "peerDependencies" };
var dependencyList = new[] {"dependencies", "devDependencies", "peerDependencies"};
var abpPackages = new List<JProperty>();
foreach (var dependencyListName in dependencyList)
{
var dependencies = (JObject)fileObject[dependencyListName];
var dependencies = (JObject) fileObject[dependencyListName];
if (dependencies == null)
{
@ -269,7 +269,8 @@ namespace Volo.Abp.Cli.ProjectModification
}
var properties = dependencies.Properties().ToList();
abpPackages.AddRange(properties.Where(p => p.Name.StartsWith("@abp/") || p.Name.StartsWith("@volo/")).ToList());
abpPackages.AddRange(properties.Where(p => p.Name.StartsWith("@abp/") || p.Name.StartsWith("@volo/"))
.ToList());
}
return abpPackages;
@ -286,5 +287,11 @@ namespace Volo.Abp.Cli.ProjectModification
Logger.LogInformation($"Running Yarn on {fileDirectory}");
CmdHelper.RunCmd($"cd {fileDirectory} && yarn");
}
protected virtual void RunNpmInstall(string fileDirectory)
{
Logger.LogInformation($"Running npm install on {fileDirectory}");
CmdHelper.RunCmd($"cd {fileDirectory} && npm install");
}
}
}

Loading…
Cancel
Save