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 9cfa702fd7..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 @@ -67,6 +67,12 @@ namespace Volo.Abp.Cli.Commands Logger.LogInformation("UI Framework: " + uiFramework); } + var mobileApp = GetMobilePreference(commandLineArgs); + if (mobileApp != MobileApp.None) + { + Logger.LogInformation("Mobile App: " + mobileApp); + } + var gitHubLocalRepositoryPath = commandLineArgs.Options.GetOrNull(Options.GitHubLocalRepositoryPath.Long); if (gitHubLocalRepositoryPath != null) { @@ -94,6 +100,7 @@ namespace Volo.Abp.Cli.Commands version, databaseProvider, uiFramework, + mobileApp, gitHubLocalRepositoryPath, commandLineArgs.Options ) @@ -208,6 +215,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-native": + return MobileApp.ReactNative; + default: + return MobileApp.ReactNative; + } + } + public static class Options { public static class Template @@ -244,6 +265,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..1a85471529 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Volo.Abp.Cli.ProjectBuilding.Building +{ + public enum MobileApp + { + 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); + } } } }