|
1 | 1 | import * as fs from 'fs-extra'; |
2 | | -import { config } from './models/config.model'; |
3 | | -import { argumentsInstance } from './services/arguments.service'; |
| 2 | +import { config, ConfigI } from './models/config.model'; |
4 | 3 | import { FileReaderService } from './services/parsers/file-reader.service'; |
5 | 4 | import { APIParserService } from './services/parsers/open-api-v3/api-parser.service'; |
6 | 5 | import { ComponentsParserService } from './services/parsers/open-api-v3/components-parser.service'; |
7 | 6 | import { ApiWritterService } from './services/writters/api-writter.service'; |
8 | 7 | import { ModelWritterService } from './services/writters/model-writter.service'; |
9 | 8 | import { Store } from './stores/entities.store'; |
10 | 9 |
|
11 | | -config.parseYargs(argumentsInstance); |
12 | | - |
13 | | -// FOLDERS INFORMATION |
14 | | -console.info('Output folders:'); |
15 | | -console.table({ |
16 | | - OUTPUT_PATH: config.outputPath, |
17 | | - BASE_FOLDER: config.exportPath, |
18 | | - MODELS: config.exportPath, |
19 | | - APIS: config.exportPath, |
20 | | -}); |
21 | | - |
22 | 10 | // Read the file |
23 | | -async function run() { |
| 11 | +export async function generateAPIFiles(config: ConfigI) { |
24 | 12 | try { |
25 | 13 | // Check if the template does not exist |
26 | 14 | config.templatePath; |
27 | 15 |
|
28 | 16 | console.log(''); |
29 | | - if (argumentsInstance.clean) { |
| 17 | + if (config.cleanFolder) { |
30 | 18 | console.log('Removing previously generated data...'); |
31 | 19 | fs.removeSync(config.exportPath); |
32 | 20 | } else { |
33 | 21 | console.log('no-clean flag recevived, clean folder skipped'); |
34 | 22 | } |
35 | 23 | console.log(''); |
36 | 24 |
|
37 | | - console.log('Opening file:', argumentsInstance.file); |
38 | | - const fileParser = new FileReaderService(argumentsInstance.file, config); |
| 25 | + console.log('Opening file:', config.fileURI); |
| 26 | + const fileParser = new FileReaderService(config.fileURI, config); |
39 | 27 | console.log('Parsing file...'); |
40 | 28 | console.log(''); |
41 | 29 | const documentParsed = await fileParser.readFile(); |
@@ -68,5 +56,3 @@ async function run() { |
68 | 56 | console.error('Application stopped'); |
69 | 57 | } |
70 | 58 | } |
71 | | - |
72 | | -run(); |
0 commit comments