@technicity/openapi-sdk-generator 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { generate } from "./generate";
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+
3
+ const commander = require("commander");
4
+ const _ = require("lodash/fp");
5
+ import { paramCase } from "param-case";
6
+ import { generate, schema } from "./generate";
7
+
8
+ const commands = [
9
+ {
10
+ name: "generate",
11
+ opts: Object.entries(schema.properties).map((xs) => {
12
+ const k = xs[0];
13
+ const v = xs[1] as any;
14
+ return {
15
+ name: "--" + paramCase(k),
16
+ required: schema.required.includes(k),
17
+ type: v.type,
18
+ default: v.default,
19
+ description: v.description,
20
+ optKey: k,
21
+ };
22
+ }),
23
+ action: generate,
24
+ },
25
+ ];
26
+
27
+ commands.forEach(addCommand);
28
+ commander.parse(process.argv);
29
+
30
+ if (!commander.args.length) {
31
+ commander.outputHelp();
32
+ }
33
+
34
+ function addCommand(cmd) {
35
+ const command = commander.command(cmd.name);
36
+
37
+ cmd.opts.forEach((opt) => {
38
+ command.option(
39
+ (opt.alias ? opt.alias + ", " : "") + opt.name + " <x>",
40
+ opt.description
41
+ );
42
+ });
43
+
44
+ command.action(async (c) => {
45
+ try {
46
+ const keys = cmd.opts.map((o) => o.optKey);
47
+ const opts = Object.entries(_.pick(keys, c)).reduce(
48
+ (acc, [k, v]) => ({ ...acc, [k]: v }),
49
+ {}
50
+ );
51
+ await cmd.action(opts);
52
+ process.exit(0);
53
+ } catch (err) {
54
+ // eslint-disable-next-line no-console
55
+ console.error(err.message);
56
+ process.exit(1);
57
+ }
58
+ });
59
+ }
60
+
61
+ // function parseList(str) {
62
+ // return str.split(",").map(x => x.trim());
63
+ // }
64
+
65
+ // function parseObj(str) {
66
+ // return JSON.parse(str);
67
+ // }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "sourceMap": true,
8
+ "forceConsistentCasingInFileNames": false
9
+ // "strict": true
10
+ },
11
+ "include": ["src"]
12
+ }