UNPKG

@microsoft.azure/autorest.incubator

Version:
49 lines 2.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const locations_1 = require("../../common/locations"); const utility_1 = require("../../common/utility"); const yaml_1 = require("../../common/yaml"); const path_1 = require("path"); const generator_1 = require("./generator"); const project_1 = require("./project"); async function process(service) { try { // Get the list of files const files = await service.ListInputs(); const apifolder = await service.GetValue('api-folder') || ''; const runtimefolder = await service.GetValue('runtime-folder') || 'runtime'; const azure = await service.GetValue('azure') || await service.GetValue('azure-arm') || false; // get the openapi document if (files.length === 0) { throw new Error('Inputs missing.'); } const filename = files[0]; const codeModelText = await service.ReadFile(filename); const model = await yaml_1.deserialize(codeModelText, filename); const modelState = new generator_1.State(service, model, filename); const project = new project_1.Project(modelState); await project.init(); await project.writeFiles(async (fname, content) => service.WriteFile(path_1.join(apifolder, fname), content, undefined, 'source-file-csharp')); // recursive copy resources await utility_1.copyResources(path_1.join(locations_1.resources, 'runtime', 'csharp', 'client'), async (fname, content) => service.WriteFile(path_1.join(runtimefolder, fname), content, undefined, 'source-file-csharp')); if (project.defaultPipeline) { await utility_1.copyResources(path_1.join(locations_1.resources, 'runtime', 'csharp', 'pipeline'), async (fname, content) => service.WriteFile(path_1.join(runtimefolder, fname), content, undefined, 'source-file-csharp')); } if (project.jsonSerialization) { await utility_1.copyResources(path_1.join(locations_1.resources, 'runtime', 'csharp', 'json'), async (fname, content) => service.WriteFile(path_1.join(runtimefolder, fname), content, undefined, 'source-file-csharp')); } if (project.xmlSerialization) { await utility_1.copyResources(path_1.join(locations_1.resources, 'runtime', 'csharp', 'xml'), async (fname, content) => service.WriteFile(path_1.join(runtimefolder, fname), content, undefined, 'source-file-csharp')); } if (azure) { await utility_1.copyResources(path_1.join(locations_1.resources, 'runtime', 'csharp.azure'), async (fname, content) => service.WriteFile(path_1.join(runtimefolder, fname), content, undefined, 'source-file-csharp')); } // debug files... // service.WriteFile('code-model-v2.csharp.yaml', serialize(model), undefined, 'source-file-other'); } catch (E) { console.error(E); } } exports.process = process; //# sourceMappingURL=main.js.map