-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.ts
31 lines (24 loc) · 937 Bytes
/
cli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env node
import * as program from 'commander';
import * as fs from 'fs';
import * as path from 'path';
import {MetadataGenerator} from './lib/MetadataGenerator';
import {loadConfig} from './lib/helper';
const pack = require(path.join(process.cwd(), 'package.json'));
const config = loadConfig();
program
.version(pack.version)
.description(pack.description)
.option('-e, --entry <required>', 'entry point')
.option('-o, --output <required>', 'output file')
.option('-t, --type [optional]', 'spec type')
.parse(process.argv); // end with parse to parse through the input
const metadataGenerator = new MetadataGenerator(
'./test/MetadataGenerator/microservice/index.ts',
require(path.join(process.cwd(), 'tsconfig.json'))
);
const metadata = metadataGenerator.generate(['Controller', 'JsonController']);
fs.writeFileSync(
'metadata.json',
JSON.stringify(metadata, null, ' ')
);