From c3cfa6b1ed29472f64d52f10959c3f0bf16f8da9 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 24 Feb 2020 16:32:06 +0300 Subject: [PATCH 1/3] added Mobile app option --- .../Volo/Abp/Cli/Commands/NewCommand.cs | 26 +++++++++++++++++++ .../Services/AbpNuGetIndexUrlService.cs | 5 +--- .../Cli/ProjectBuilding/Building/MobileApp.cs | 12 +++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index 9cfa702fd7..b8406902a3 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -67,6 +67,12 @@ namespace Volo.Abp.Cli.Commands Logger.LogInformation("UI Framework: " + uiFramework); } + var mobileApp = GetMobilePreference(commandLineArgs); + if (uiFramework != UiFramework.NotSpecified) + { + Logger.LogInformation("Mobile App: " + mobileApp); + } + var gitHubLocalRepositoryPath = commandLineArgs.Options.GetOrNull(Options.GitHubLocalRepositoryPath.Long); if (gitHubLocalRepositoryPath != null) { @@ -208,6 +214,20 @@ namespace Volo.Abp.Cli.Commands } } + private MobileApp GetMobilePreference(CommandLineArgs commandLineArgs) + { + var optionValue = commandLineArgs.Options.GetOrNull(Options.Mobile.Short, Options.Mobile.Long); + switch (optionValue) + { + case "none": + return MobileApp.None; + case "react": + return MobileApp.ReactNative; + default: + return MobileApp.ReactNative; + } + } + public static class Options { public static class Template @@ -244,6 +264,12 @@ namespace Volo.Abp.Cli.Commands public const string Short = "u"; public const string Long = "ui"; } + + public static class Mobile + { + public const string Short = "m"; + public const string Long = "mobile"; + } } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/AbpNuGetIndexUrlService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/AbpNuGetIndexUrlService.cs index 0e1f987d4e..314c568030 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/AbpNuGetIndexUrlService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/AbpNuGetIndexUrlService.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Licensing; diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs new file mode 100644 index 0000000000..0529f4b60d --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Volo.Abp.Cli.ProjectBuilding.Building +{ + public enum MobileApp + { + None, + ReactNative + } +} From fa3ed6545024e1de31018e3c9ceaea667f17b943 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 28 Feb 2020 12:33:33 +0300 Subject: [PATCH 2/3] Allow to download react native mobile https://github.com/abpframework/abp/issues/2771 --- .../Www/Localization/Resources/en.json | 4 +++- .../Volo/Abp/Cli/Commands/GetSourceCommand.cs | 1 + .../Volo/Abp/Cli/Commands/NewCommand.cs | 3 ++- .../Cli/ProjectBuilding/Building/MobileApp.cs | 13 ++++++++++++ .../Cli/ProjectBuilding/ProjectBuildArgs.cs | 4 ++++ .../ProjectBuilding/TemplateProjectBuilder.cs | 2 ++ .../Templates/App/AppTemplateBase.cs | 7 ++++++- .../Templates/TemplateRandomSslPortStep.cs | 20 +++++++++++++++++++ 8 files changed, 51 insertions(+), 3 deletions(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json index be193b7396..2502dce76a 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json @@ -154,6 +154,8 @@ "SeeTheDocumentForMoreInformation": "See the {0} document for more information", "IndexPageHeroSection": "open sourceWeb Application
Framework
for asp.net core", "UiFramework": "UI Framework", - "EmailAddress": "Email address" + "EmailAddress": "Email address", + "Mobile": "Mobile", + "ReactNative": "React Native" } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs index e1536c2973..9ad7eb5b49 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs @@ -76,6 +76,7 @@ namespace Volo.Abp.Cli.Commands version, DatabaseProvider.NotSpecified, UiFramework.NotSpecified, + MobileApp.None, gitHubLocalRepositoryPath, commandLineArgs.Options ) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index b8406902a3..0f0281851c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -68,7 +68,7 @@ namespace Volo.Abp.Cli.Commands } var mobileApp = GetMobilePreference(commandLineArgs); - if (uiFramework != UiFramework.NotSpecified) + if (mobileApp != MobileApp.None) { Logger.LogInformation("Mobile App: " + mobileApp); } @@ -100,6 +100,7 @@ namespace Volo.Abp.Cli.Commands version, databaseProvider, uiFramework, + mobileApp, gitHubLocalRepositoryPath, commandLineArgs.Options ) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs index 0529f4b60d..1a85471529 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs @@ -9,4 +9,17 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building None, ReactNative } + + public static class MobileAppExtensions{ + public static string GetFolderName(this MobileApp mobileApp) + { + switch (mobileApp) + { + case MobileApp.ReactNative: + return "react-native"; + default: + return null; + } + } + } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ProjectBuildArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ProjectBuildArgs.cs index 5586321010..bb20c19e80 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ProjectBuildArgs.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ProjectBuildArgs.cs @@ -19,6 +19,8 @@ namespace Volo.Abp.Cli.ProjectBuilding public UiFramework UiFramework { get; set; } + public MobileApp MobileApp { get; set; } + [CanBeNull] public string AbpGitHubLocalRepositoryPath { get; set; } @@ -31,6 +33,7 @@ namespace Volo.Abp.Cli.ProjectBuilding [CanBeNull] string version = null, DatabaseProvider databaseProvider = DatabaseProvider.NotSpecified, UiFramework uiFramework = UiFramework.NotSpecified, + MobileApp mobileApp = MobileApp.ReactNative, [CanBeNull] string abpGitHubLocalRepositoryPath = null, Dictionary extraProperties = null) { @@ -39,6 +42,7 @@ namespace Volo.Abp.Cli.ProjectBuilding Version = version; DatabaseProvider = databaseProvider; UiFramework = uiFramework; + MobileApp = mobileApp; AbpGitHubLocalRepositoryPath = abpGitHubLocalRepositoryPath; ExtraProperties = extraProperties ?? new Dictionary(); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index 9d31e10200..80a25660fc 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -88,6 +88,8 @@ namespace Volo.Abp.Cli.ProjectBuilding !x.Key.Equals(NewCommand.Options.OutputFolder.Short, StringComparison.InvariantCultureIgnoreCase)) .Where(x => !x.Key.Equals(NewCommand.Options.UiFramework.Long, StringComparison.InvariantCultureIgnoreCase) && !x.Key.Equals(NewCommand.Options.UiFramework.Short, StringComparison.InvariantCultureIgnoreCase)) + .Where(x => !x.Key.Equals(NewCommand.Options.Mobile.Long, StringComparison.InvariantCultureIgnoreCase) && + !x.Key.Equals(NewCommand.Options.Mobile.Short, StringComparison.InvariantCultureIgnoreCase)) .Where(x => !x.Key.Equals(NewCommand.Options.Version.Long, StringComparison.InvariantCultureIgnoreCase) && !x.Key.Equals(NewCommand.Options.Version.Short, StringComparison.InvariantCultureIgnoreCase)) .Select(x => x.Key).ToList(); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index 254e8d80ae..9df2c03ee4 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -74,6 +74,11 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App { steps.Add(new RemoveFolderStep("/angular")); } + + if (context.BuildArgs.MobileApp != MobileApp.ReactNative) + { + steps.Add(new RemoveFolderStep(MobileApp.ReactNative.GetFolderName()?.EnsureStartsWith('/'))); + } } private static void ConfigureWithoutUi(ProjectBuildContext context, List steps) @@ -156,7 +161,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App private static void CleanupFolderHierarchy(ProjectBuildContext context, List steps) { - if (context.BuildArgs.UiFramework == UiFramework.Mvc) + if (context.BuildArgs.UiFramework == UiFramework.Mvc && context.BuildArgs.MobileApp == MobileApp.None) { steps.Add(new MoveFolderStep("/aspnet-core/", "/")); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/TemplateRandomSslPortStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/TemplateRandomSslPortStep.cs index 8b30ca2519..c5f5292e1a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/TemplateRandomSslPortStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/TemplateRandomSslPortStep.cs @@ -44,6 +44,12 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates ) .ToList(); + var reactNativeEnvironments = context.Files.Where(x => + !x.IsDirectory && + x.Name.EndsWith($"{MobileApp.ReactNative.GetFolderName()}/Environment.js", StringComparison.InvariantCultureIgnoreCase) + ) + .ToList(); + if (AppTemplateBase.IsAppTemplate(context.Template.Name)) { // no tiered @@ -127,6 +133,20 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates environment.SetLines(environmentLines); } + foreach (var environment in reactNativeEnvironments) + { + environment.NormalizeLineEndings(); + + var environmentLines = environment.GetLines(); + for (var i = 0; i < environmentLines.Length; i++) + { + if (environmentLines[i].Contains(buildInUrl)) + { + environmentLines[i] = environmentLines[i].Replace(buildInUrl, $"{buildInUrlWithoutPort}:{newPort}"); + } + } + environment.SetLines(environmentLines); + } } } } From 145d46fe3b53bdcbec2fb79d8c68f2994fda09c2 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 28 Feb 2020 12:49:00 +0300 Subject: [PATCH 3/3] Update NewCommand.cs --- .../src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index 0f0281851c..d39a333860 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -222,7 +222,7 @@ namespace Volo.Abp.Cli.Commands { case "none": return MobileApp.None; - case "react": + case "react-native": return MobileApp.ReactNative; default: return MobileApp.ReactNative;