Пример #1
0
        private void TransformStartupAuth(SmartAppInfo manifest)
        {
            var authenticationKeys = _context.DynamicContext.AuthenticationKeys as IDictionary <string, string>;
            var template           = new StartupAuth(manifest, authenticationKeys);

            _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath), template.TransformText());
        }
        public AuthStackNavigator(SmartAppInfo smartApp) : base(smartApp)
        {
            _rootScreenFolder = string.Empty;
            _rootScreen       = string.Empty;

            SetRootScreen(smartApp);
        }
        public AppBaseClass(SmartAppInfo smartApp) : base(smartApp)
        {
            Tuple <LayoutInfo, ConcernInfo> tuple = getRootLayout(smartApp);

            _rootLayout  = tuple.Item1;
            _rootConcern = tuple.Item2;
        }
        /// <summary>
        /// Create a spec file for each component.
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifeste.</param>
        private void TransformComponentSpecs(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Concerns.AsEnumerable() != null && smartApp.Version != null)
            {
                foreach (ConcernInfo concern in smartApp.Concerns.AsEnumerable())
                {
                    if (concern != null && concern.Id != null && concern.Layouts.AsEnumerable() != null)
                    {
                        foreach (LayoutInfo layout in concern.Layouts.AsEnumerable())
                        {
                            if (layout != null)
                            {
                                ComponentSpecTemplate componentsSpecTemplate = new ComponentSpecTemplate(smartApp.Id, concern, layout, smartApp.Languages, smartApp.Api);

                                string componentsSpecDirectoryPath = Path.Combine(componentsSpecTemplate.OutputPath, TextConverter.CamelCase(concern.Id), TextConverter.CamelCase(layout.Id));
                                string componentsSpecFilename      = TextConverter.CamelCase(concern.Id) + "-" + TextConverter.CamelCase(layout.Id) + ".spec.ts";

                                string fileToWritePath = Path.Combine(_context.BasePath, componentsSpecDirectoryPath, componentsSpecFilename);
                                string textToWrite     = componentsSpecTemplate.TransformText();

                                _writingService.WriteFile(fileToWritePath, textToWrite);
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
        public override Task <ExecutionResult> RunAsync(IStepExecutionContext context)
        {
            if (null == _context.Manifest)
            {
                throw new ArgumentNullException(nameof(_context.Manifest));
            }

            SmartAppInfo smartApp        = _context.Manifest;
            var          commonTemplates = "Platforms\\Backend\\PHP\\Common\\Templates";

            _workflowNotifier.Notify(nameof(CommonWritingSteps), NotificationType.GeneralInfo, "Generating php common files");

            if (_context.BasePath != null && _context.GeneratorPath != null)
            {
                var commonTemplatesDirectoryPath = Path.Combine(_context.GeneratorPath, commonTemplates);

                TransformStaticFiles(smartApp, commonTemplatesDirectoryPath);
                TransformEnvTemplate(smartApp);
                TransformComposerJsonTemplate(smartApp);
                TransformConfigAppTemplate(smartApp);
                TransformSidebarTemplate(smartApp);
            }

            return(Task.FromResult(ExecutionResult.Next()));
        }
Пример #6
0
        private void TransferIosStaticFiles(SmartAppInfo smartApp)
        {
            if (smartApp != null)
            {
                InfoPlistTvOSTestsTemplate infoPlistTvOSTestsTemplate = new InfoPlistTvOSTestsTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, infoPlistTvOSTestsTemplate.OutputPath), infoPlistTvOSTestsTemplate.TransformText());

                InfoPlistTvOSTemplate infoPlistTvOSTemplate = new InfoPlistTvOSTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, infoPlistTvOSTemplate.OutputPath), infoPlistTvOSTemplate.TransformText());

                InfoPlistTestsTemplate infoPlistTestsTemplate = new InfoPlistTestsTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, infoPlistTestsTemplate.OutputPath), infoPlistTestsTemplate.TransformText());

                AppDelegateHTemplate appDelegateHTemplate = new AppDelegateHTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, appDelegateHTemplate.OutputPath), appDelegateHTemplate.TransformText());

                MainTemplate mainTemplate = new MainTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, mainTemplate.OutputPath), mainTemplate.TransformText());

                ContentsTemplate contentsTemplate = new ContentsTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, contentsTemplate.OutputPath), contentsTemplate.TransformText());

                ContentsAppIconTemplate contentsAppIconTemplate = new ContentsAppIconTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, contentsAppIconTemplate.OutputPath), contentsAppIconTemplate.TransformText());
            }
        }
Пример #7
0
        private void TransferIosFiles(SmartAppInfo smartApp)
        {
            if (smartApp != null)
            {
                AppDelegateTemplate appDelegateTemplate = new AppDelegateTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, appDelegateTemplate.OutputPath), appDelegateTemplate.TransformText());

                InfoTemplate infoTemplate = new InfoTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, infoTemplate.OutputPath), infoTemplate.TransformText());

                LaunchScreenTemplate launchScreenTemplate = new LaunchScreenTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, launchScreenTemplate.OutputPath), launchScreenTemplate.TransformText());

                ProjectPbxprojTemplate projectPbxprojTemplate = new ProjectPbxprojTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, projectPbxprojTemplate.OutputPath), projectPbxprojTemplate.TransformText());

                SampleTemplate sampleTemplate = new SampleTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, sampleTemplate.OutputPath), sampleTemplate.TransformText());

                SampleTestsTemplate sampleTestsTemplate = new SampleTestsTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, sampleTestsTemplate.OutputPath), sampleTestsTemplate.TransformText());

                SampleTvOSTemplate sampleTvOSTemplate = new SampleTvOSTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, sampleTvOSTemplate.OutputPath), sampleTvOSTemplate.TransformText());
            }
        }
Пример #8
0
 private void TransformStaticFile(SmartAppInfo smartApp, string templatesDirectoryPath)
 {
     if (smartApp != null && templatesDirectoryPath != null)
     {
         _writingService.CopyDirectory(templatesDirectoryPath, _context.BasePath);
     }
 }
Пример #9
0
        public override Task <ExecutionResult> RunAsync(IStepExecutionContext context)
        {
            if (null == _context.Manifest)
            {
                throw new ArgumentNullException(nameof(_context.Manifest));
            }

            SmartAppInfo smartApp = _context.Manifest;

            var commonTemplates = "Platforms\\Frontend\\ReactNative\\Common\\Templates";


            _workflowNotifier.Notify(nameof(CommonWritingSteps), NotificationType.GeneralInfo, "Generating ReactNative common files");

            if (_context.BasePath != null && _context.GeneratorPath != null)
            {
                var commonTemplatesDirectoryPath = Path.Combine(_context.GeneratorPath, commonTemplates);

                TransformStaticFile(smartApp, commonTemplatesDirectoryPath);
                TransferRootFiles(smartApp);
                TransferAndroidFiles(smartApp);
                TransferIosFiles(smartApp);
                TransferIosStaticFiles(smartApp);
            }
            return(Task.FromResult(ExecutionResult.Next()));
        }
        /// <summary>
        /// Helper to retrieve the root Layout from the manifest.
        /// </summary>
        /// <param name="smartApp">A SmartAppInfo object.</param>
        /// <returns>A tuple of a LayoutInfo with his associated ConcernInfo.</returns>
        public static Tuple <LayoutInfo, ConcernInfo> GetRootLayout(this SmartAppInfo smartApp)
        {
            if (!smartApp.IsValid())
            {
                return(null);
            }

            if (smartApp.Concerns.IsValid())
            {
                foreach (var concern in smartApp.Concerns)
                {
                    if (concern.IsValid() &&
                        concern.Layouts.IsValid())
                    {
                        foreach (var layout in concern.Layouts)
                        {
                            if (layout.IsValid() &&
                                layout.IsRoot)
                            {
                                return(new Tuple <LayoutInfo, ConcernInfo>(
                                           layout,
                                           concern));
                            }
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Retrieve layouts from the application.
        /// </summary>
        /// <param name="smartApp">A SmartAppInfo object.</param>
        /// <returns>A LayoutList.</returns>
        public static LayoutList GetLayouts(this SmartAppInfo smartApp)
        {
            var layouts = new LayoutList();

            if (!smartApp.IsValid())
            {
                return(layouts);
            }

            var layoutComparer = new LayoutInfoComparer();

            if (smartApp.Version.IsValid() &&
                smartApp.Concerns.IsValid())
            {
                var listToRetrieve = smartApp.Concerns.GetLayouts();

                layouts = layouts
                          .Union(
                    listToRetrieve,
                    layoutComparer)
                          .ToLayoutList();
            }

            return(layouts);
        }
Пример #12
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public override string TransformText()
        {
            this.Write("\r\n");

            #line 2 "C:\Users\PC\Documents\Gits\Ionic-framework\GeneratorProject.IonicFrameworkCodeSamples\GeneratorProject\Platforms\Frontend\Ionic\Common\Templates\IonicConfig.tt"

            SmartAppInfo smartApp = (SmartAppInfo)Model;
            if (smartApp != null && smartApp.Title != null && smartApp.Id != null)
            {
            #line default
            #line hidden
                this.Write("{\r\n  \"name\": \"");

            #line 8 "C:\Users\PC\Documents\Gits\Ionic-framework\GeneratorProject.IonicFrameworkCodeSamples\GeneratorProject\Platforms\Frontend\Ionic\Common\Templates\IonicConfig.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(smartApp.Title));

            #line default
            #line hidden
                this.Write("\",\r\n  \"app_id\": \"");

            #line 9 "C:\Users\PC\Documents\Gits\Ionic-framework\GeneratorProject.IonicFrameworkCodeSamples\GeneratorProject\Platforms\Frontend\Ionic\Common\Templates\IonicConfig.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(smartApp.Id));

            #line default
            #line hidden
                this.Write("\",\r\n  \"type\": \"ionic-angular\"\r\n}\r\n");

            #line 12 "C:\Users\PC\Documents\Gits\Ionic-framework\GeneratorProject.IonicFrameworkCodeSamples\GeneratorProject\Platforms\Frontend\Ionic\Common\Templates\IonicConfig.tt"
            }


            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Пример #13
0
        private void TransformViews(SmartAppInfo manifest)
        {
            if (manifest != null)
            {
                var enabledEntities = manifest.DataModel.Entities.Where(e => !e.IsAbstract);
                var applicationId   = manifest.Id;

                foreach (var entity in enabledEntities)
                {
                    IndexTemplate  indexTemplate  = new IndexTemplate(entity, applicationId);
                    ShowTemplate   showTemplate   = new ShowTemplate(entity, applicationId);
                    CreateTemplate createTemplate = new CreateTemplate(entity, applicationId);
                    EditTemplate   editTemplate   = new EditTemplate(entity, applicationId);
                    DeleteTemplate deleteTemplate = new DeleteTemplate(entity, applicationId);

                    var folderName = TextConverter.CamelCase(entity.Id);

                    _writingService.WriteFile(Path.Combine(_context.BasePath, indexTemplate.OutputPath, folderName, "index.blade.php"), indexTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, showTemplate.OutputPath, folderName, "show.blade.php"), showTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, createTemplate.OutputPath, folderName, "create.blade.php"), createTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, editTemplate.OutputPath, folderName, "edit.blade.php"), editTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, deleteTemplate.OutputPath, folderName, "delete.blade.php"), deleteTemplate.TransformText());
                }
            }
        }
Пример #14
0
        private void TransformControllerApiParameters(SmartAppInfo manifest, ApiActionInfo action)
        {
            bool result = true;

            foreach (var param in action.Parameters.AsEnumerable())
            {
                if (!result)
                {
                    break;
                }

                Dictionary <string, string> entityTypes = GetAllReferencedTypes(param);

                if (param.DataModel != null)
                {
                    var dataTemplate = new ViewModelTemplate(param.DataModel, manifest.Id, Constants.ViewModelNamespace, entityTypes);
                    try
                    {
                        result = _writingService.WriteFile(Path.Combine(_context.BasePath, dataTemplate.OutputPath, param.DataModel.Id + ".g.cs"), dataTemplate.TransformText());
                    }
                    catch (Exception ex)
                    {
                        result = false;
                    }
                }
            }
        }
        private void TransformViewModels(SmartAppInfo manifest)
        {
            if (manifest != null)
            {
                string modelSuffix     = GetModelSuffix();
                string viewModelSuffix = GetViewModelSuffix();

                List <EntityInfo> alreadyCreated = new List <EntityInfo>();

                manifest.Api.ToList()
                .ForEach(api => api.Actions.ToList()
                         .ForEach(action =>
                {
                    if (action.ReturnType != null && !alreadyCreated.Contains(action.ReturnType))
                    {
                        alreadyCreated.Add(action.ReturnType);
                        TransformViewModel(action.ReturnType, viewModelSuffix, modelSuffix);
                    }
                    action.Parameters.ToList()
                    .ForEach(parameter =>
                    {
                        if (parameter.DataModel != null && !alreadyCreated.Contains(parameter.DataModel))
                        {
                            alreadyCreated.Add(parameter.DataModel);
                            TransformViewModel(parameter.DataModel, viewModelSuffix, modelSuffix);
                        }
                    });
                }));
            }
        }
Пример #16
0
 public AppModule(SmartAppInfo smartApp) : base(smartApp)
 {
     if (smartApp.Languages != null)
     {
         _languages = smartApp.Languages;
     }
 }
 private void TransformAuthStackNavigator(SmartAppInfo smartApp)
 {
     if (smartApp != null)
     {
         AuthStackNavigator authStackNavigator = new AuthStackNavigator(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, authStackNavigator.OutputPath), authStackNavigator.TransformText());
     }
 }
 private void TransformMainStackNavigator(SmartAppInfo smartApp)
 {
     if (smartApp != null && smartApp.Concerns != null && smartApp.Concerns.Count > 0)
     {
         AppMainStackNavigator appMainStackNavigator = new AppMainStackNavigator(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, appMainStackNavigator.OutputPath), appMainStackNavigator.TransformText());
     }
 }
 private void TransformServiceBase(SmartAppInfo smartApp)
 {
     if (smartApp != null)
     {
         RestApiTemplate serviceBaseTemplate = new RestApiTemplate(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, serviceBaseTemplate.OutputPath), serviceBaseTemplate.TransformText());
     }
 }
Пример #20
0
 private void TransformStyles(SmartAppInfo smartApp)
 {
     if (smartApp != null)
     {
         ViewStyleTemplate viewStyleTemplate = new ViewStyleTemplate(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, viewStyleTemplate.OutputPath), viewStyleTemplate.TransformText());
     }
 }
 private void TransformInitialStates(SmartAppInfo smartApp)
 {
     if (smartApp != null)
     {
         InitialStateTemplate initialStateTemplate = new InitialStateTemplate(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, initialStateTemplate.OutputPath), initialStateTemplate.TransformText());
     }
 }
 private void TransformCombineReducer(SmartAppInfo smartApp)
 {
     if (smartApp != null)
     {
         CombineReducerTemplate combineReducerTemplate = new CombineReducerTemplate(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, combineReducerTemplate.OutputPath), combineReducerTemplate.TransformText());
     }
 }
Пример #23
0
        private void TransformSidebarTemplate(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.DataModel != null)
            {
                SidebarPartialTemplate sidebarPartialTemplate = new SidebarPartialTemplate(smartApp.DataModel, smartApp.Id);

                _writingService.WriteFile(Path.Combine(_context.BasePath, sidebarPartialTemplate.OutputPath), sidebarPartialTemplate.TransformText());
            }
        }
Пример #24
0
        /// <summary>
        /// Generating manifest.json
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifest</param>
        private void TransformManifest(SmartAppInfo smartApp)
        {
            Manifest manifestTemplate      = new Manifest(smartApp);
            string   manifestDirectoryPath = manifestTemplate.OutputPath;
            string   fileToWritePath       = Path.Combine(_context.BasePath, manifestDirectoryPath);
            string   textToWrite           = manifestTemplate.TransformText();

            _writingService.WriteFile(fileToWritePath, textToWrite);
        }
Пример #25
0
        /// <summary>
        /// Generating index.html
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifest</param>
        private void TransformIndex(SmartAppInfo smartApp)
        {
            Index  indexTemplate      = new Index(smartApp);
            string indexDirectoryPath = indexTemplate.OutputPath;
            string fileToWritePath    = Path.Combine(_context.BasePath, indexDirectoryPath);
            string textToWrite        = indexTemplate.TransformText();

            _writingService.WriteFile(fileToWritePath, textToWrite);
        }
Пример #26
0
        /// <summary>
        /// Generating app.html
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifest</param>
        private void TransformAppView(SmartAppInfo smartApp)
        {
            AppView appViewTemplate      = new AppView(smartApp);
            string  appViewDirectoryPath = appViewTemplate.OutputPath;
            string  fileToWritePath      = Path.Combine(_context.BasePath, appViewDirectoryPath);
            string  textToWrite          = appViewTemplate.TransformText();

            _writingService.WriteFile(fileToWritePath, textToWrite);
        }
Пример #27
0
        /// <summary>
        /// Generating package.json
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifest</param>
        private void TransformPackage(SmartAppInfo smartApp)
        {
            Package packageTemplate      = new Package(smartApp);
            string  packageDirectoryPath = packageTemplate.OutputPath;
            string  fileToWritePath      = Path.Combine(_context.BasePath, packageDirectoryPath);
            string  textToWrite          = packageTemplate.TransformText();

            _writingService.WriteFile(fileToWritePath, textToWrite);
        }
Пример #28
0
        /// <summary>
        /// Generating ionic.config.json
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifest</param>
        private void TransformIonicConfig(SmartAppInfo smartApp)
        {
            IonicConfig ionicConfigTemplate      = new IonicConfig(smartApp);
            string      ionicConfigDirectoryPath = ionicConfigTemplate.OutputPath;
            string      fileToWritePath          = Path.Combine(_context.BasePath, ionicConfigDirectoryPath);
            string      textToWrite = ionicConfigTemplate.TransformText();

            _writingService.WriteFile(fileToWritePath, textToWrite);
        }
Пример #29
0
        public AppComponentSpecTemplate(SmartAppInfo smartApp)
        {
            _smartApp = smartApp;
            Tuple <LayoutInfo, ConcernInfo> tuple = getRootLayout(smartApp);

            _rootLayout  = tuple.Item1;
            _rootConcern = tuple.Item2;
            _isMenu      = isMenu(smartApp.Concerns);
        }
        public Project(SmartAppInfo model) : base(model)
        {
            if (model == null || string.IsNullOrEmpty(model.Id))
            {
                throw new NullReferenceException(nameof(model));
            }

            UserSecret = $"{model.Id}.Backend-{Guid.NewGuid().ToString()}";
        }