@ps-aux/api-client-gen 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. package/dist/go.js +8 -1
  2. package/package.json +2 -2
  3. package/src/go.ts +15 -2
package/dist/go.js CHANGED
@@ -136,9 +136,16 @@ const getSpecPath = (urlOrPath, dir, log) => __awaiter(void 0, void 0, void 0, f
136
136
  return specPath;
137
137
  });
138
138
 
139
+ process.argv;
140
+ const profile = process.argv[2];
141
+ if (!profile)
142
+ throw new Error(`No profile specified`);
139
143
  const conf = cosmiconfig.cosmiconfigSync('api-client-gen')
140
144
  .search();
141
145
  // TODO validate config
142
146
  if (!conf)
143
147
  throw new Error(`No config provided`);
144
- generateModel(conf.config);
148
+ const profileConf = conf.config[profile];
149
+ if (!profile)
150
+ throw new Error(`Profile ${profile} not present in the configuration`);
151
+ generateModel(profileConf).catch(console.error);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ps-aux/api-client-gen",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
7
- "generate-api-client": "dist/go.js"
7
+ "gen-api-client": "dist/go.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "rollup -c",
package/src/go.ts CHANGED
@@ -2,12 +2,25 @@
2
2
  import { generateModel } from './gen-model'
3
3
  import { cosmiconfigSync } from 'cosmiconfig'
4
4
 
5
+
6
+ const arg = process.argv
7
+
8
+ const profile = process.argv[2]
9
+
10
+ if (!profile)
11
+ throw new Error(`No profile specified`)
12
+
5
13
  const conf = cosmiconfigSync('api-client-gen')
6
14
  .search()
7
15
 
8
16
  // TODO validate config
9
-
10
17
  if (!conf)
11
18
  throw new Error(`No config provided`)
12
19
 
13
- generateModel(conf.config)
20
+
21
+ const profileConf = conf.config[profile]
22
+
23
+ if (!profile)
24
+ throw new Error(`Profile ${profile} not present in the configuration`)
25
+
26
+ generateModel(profileConf).catch(console.error)