/// <summary> /// Generate Azure NodeJS client code /// </summary> /// <param name="cm"></param> /// <returns></returns> public override async Task Generate(CodeModel cm) { GeneratorSettingsJs generatorSettings = Singleton <GeneratorSettingsJs> .Instance; var codeModel = cm as CodeModelJsa; if (codeModel == null) { throw new InvalidCastException("CodeModel is not a Azure NodeJS code model."); } codeModel.PopulateFromSettings(generatorSettings); // Service client await GenerateServiceClientJs(() => new AzureServiceClientTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false); //Models if (codeModel.ModelTypes.Any()) { await GenerateModelIndexJs(() => new AzureModelIndexTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false); await GenerateModelIndexDts(() => new AzureModelIndexTemplateTS { Model = codeModel }, generatorSettings).ConfigureAwait(false); // Paged Models foreach (var pageModel in codeModel.PageTemplateModels) { var pageTemplate = new PageModelTemplate { Model = pageModel }; await Write(pageTemplate, GetModelSourceCodeFilePath(generatorSettings, pageModel.Name.ToCamelCase() + ".js")).ConfigureAwait(false); } foreach (var modelType in codeModel.ModelTemplateModels) { await GenerateModelJs(modelType, generatorSettings).ConfigureAwait(false); } } //MethodGroups if (codeModel.MethodGroupModels.Any()) { await GenerateRouteEntryTemplateJs(codeModel, generatorSettings).ConfigureAwait(false); foreach (var methodGroupModel in codeModel.MethodGroupModels) { await GenerateRouteGroupJs(() => new AzureMethodGroupTemplate { Model = methodGroupModel }, generatorSettings).ConfigureAwait(false); } } await GeneratePackageJson(codeModel, generatorSettings).ConfigureAwait(false); await GenerateReadmeMd(() => new AzureReadmeTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false); await GenerateLicenseTxt(codeModel, generatorSettings).ConfigureAwait(false); }
public void PopulateFromSettings(GeneratorSettingsJs generatorSettings) { PackageName = generatorSettings.PackageName; PackageVersion = generatorSettings.PackageVersion; OutputFolder = generatorSettings.OutputFolder; }