Skip to content

Commit 6a18281

Browse files
committed
Fix CLI Program
* Minimalize dependecy from Main app
1 parent 4f8470c commit 6a18281

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

bin/commands/FromSpec/generateDefaultConfig.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import { writeFile } from "../../../src/utils/fileSystem";
2-
import { HttpClient } from "../../../src/HttpClient";
1+
import { writeFileSync } from "fs";
32
import { StructuredOptions } from "../from_spec";
43

4+
/**
5+
* Copy of the src/HttpClient.ts file
6+
*/
7+
export enum HttpClient {
8+
FETCH = 'fetch',
9+
XHR = 'xhr',
10+
NODE = 'node',
11+
}
12+
513
export const generateDefaultConfig = async (path) => {
614
console.log('Generating default files to: ', path);
715
const default_config = getDefaultConfig();
816
const raw_string = JSON.stringify(default_config, undefined, 2);
9-
await writeFile(path, raw_string);
17+
writeFileSync(path, raw_string, {encoding: "utf8"});
1018
}
1119

1220
function getDefaultConfig (): StructuredOptions {

bin/commands/generation.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@ import { Command } from "commander";
22
import { default_config_path, StructuredOptions } from "./from_spec";
33
import { existsSync, readFileSync } from "fs";
44
import { resolve } from "path";
5-
import { GenerationOptions } from "../../src/types/default";
5+
import { HttpClient } from "./FromSpec/generateDefaultConfig";
6+
7+
/**
8+
* Copy from src/types/default.src
9+
*/
10+
export type GenerationOptions = {
11+
input: string | Record<string, any>;
12+
output: string;
13+
httpClient?: HttpClient;
14+
useOptions?: boolean;
15+
useUnionTypes?: boolean;
16+
exportCore?: boolean;
17+
exportServices?: boolean;
18+
exportModels?: boolean;
19+
exportSchemas?: boolean;
20+
request?: string;
21+
write?: boolean;
22+
};
23+
624

725
const pkg = require('../../package.json');
826

0 commit comments

Comments
 (0)