fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #737 from hey-api/fix/config-file-path

fix: support custom config file path

authored by

Lubos and committed by
GitHub
99823d72 a3c13b30

+44 -1
+5
.changeset/heavy-melons-fry.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: support custom config file path
+4
packages/openapi-ts/bin/index.cjs
··· 23 23 .option('-d, --debug', 'Run in debug mode?') 24 24 .option('--dry-run [value]', 'Skip writing files to disk?') 25 25 .option('--exportCore [value]', 'Write core files to disk') 26 + .option('-f, --file [value]', 'Path to the config file') 26 27 .option( 27 28 '-i, --input <value>', 28 29 'OpenAPI specification (path, url, or string content)', ··· 55 56 delete obj[key]; 56 57 obj[key] = parsedValue; 57 58 } 59 + } 60 + if (obj.file) { 61 + obj.configFile = obj.file; 58 62 } 59 63 return obj; 60 64 };
+9
packages/openapi-ts/src/index.ts
··· 171 171 }; 172 172 173 173 const initConfigs = async (userConfig: UserConfig): Promise<Config[]> => { 174 + let configurationFile: string | undefined = undefined; 175 + if (userConfig.configFile) { 176 + const parts = userConfig.configFile.split('.'); 177 + configurationFile = parts.slice(0, parts.length - 1).join('.'); 178 + } 179 + 174 180 const { config: configFromFile } = await loadConfig<UserConfig>({ 181 + configFile: configurationFile, 175 182 jitiOptions: { 176 183 esmResolve: true, 177 184 }, ··· 191 198 const { 192 199 base, 193 200 client = 'fetch', 201 + configFile = '', 194 202 debug = false, 195 203 dryRun = false, 196 204 exportCore = true, ··· 233 241 return setConfig({ 234 242 base, 235 243 client, 244 + configFile, 236 245 debug, 237 246 dryRun, 238 247 exportCore: isStandaloneClient(client) ? false : exportCore,
+2
packages/openapi-ts/src/openApi/common/parser/__tests__/operation.spec.ts
··· 6 6 describe('getOperationName', () => { 7 7 const options1: Parameters<typeof setConfig>[0] = { 8 8 client: 'fetch', 9 + configFile: '', 9 10 debug: false, 10 11 dryRun: true, 11 12 exportCore: false, ··· 29 30 30 31 const options2: Parameters<typeof setConfig>[0] = { 31 32 client: 'fetch', 33 + configFile: '', 32 34 debug: false, 33 35 dryRun: true, 34 36 exportCore: false,
+1
packages/openapi-ts/src/openApi/v2/parser/__tests__/getServices.spec.ts
··· 7 7 it('should create a unnamed service if tags are empty', () => { 8 8 setConfig({ 9 9 client: 'fetch', 10 + configFile: '', 10 11 debug: false, 11 12 dryRun: true, 12 13 exportCore: true,
+1
packages/openapi-ts/src/openApi/v3/parser/__tests__/getServices.spec.ts
··· 7 7 it('should create a unnamed service if tags are empty', () => { 8 8 setConfig({ 9 9 client: 'fetch', 10 + configFile: '', 10 11 debug: false, 11 12 dryRun: true, 12 13 exportCore: true,
+4 -1
packages/openapi-ts/src/types/client.ts
··· 6 6 server: string; 7 7 services: Service[]; 8 8 /** 9 - * Map of generated types, keys are type names 9 + * Map of generated types where type names are keys. This is used to track 10 + * uniquely generated types as we may want to deduplicate if there are 11 + * multiple definitions with the same name but different value, or if we 12 + * want to transform names. 10 13 */ 11 14 types: Record<string, ModelMeta>; 12 15 version: string;
+5
packages/openapi-ts/src/types/config.ts
··· 19 19 | 'node' 20 20 | 'xhr'; 21 21 /** 22 + * Path to the config file. Set this value if you don't use the default 23 + * config file name, or it's not located in the project root. 24 + */ 25 + configFile?: string; 26 + /** 22 27 * Run in debug mode? 23 28 * @default false 24 29 */
+2
packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts
··· 11 11 it('should register the helpers', () => { 12 12 setConfig({ 13 13 client: 'fetch', 14 + configFile: '', 14 15 debug: false, 15 16 dryRun: false, 16 17 exportCore: true, ··· 40 41 it('should return correct templates', () => { 41 42 setConfig({ 42 43 client: 'fetch', 44 + configFile: '', 43 45 debug: false, 44 46 dryRun: false, 45 47 exportCore: true,
+1
packages/openapi-ts/src/utils/write/__tests__/class.spec.ts
··· 13 13 it('writes to filesystem', async () => { 14 14 setConfig({ 15 15 client: 'fetch', 16 + configFile: '', 16 17 debug: false, 17 18 dryRun: false, 18 19 exportCore: true,
+1
packages/openapi-ts/src/utils/write/__tests__/client.spec.ts
··· 13 13 it('writes to filesystem', async () => { 14 14 setConfig({ 15 15 client: 'fetch', 16 + configFile: '', 16 17 debug: false, 17 18 dryRun: false, 18 19 exportCore: true,
+3
packages/openapi-ts/src/utils/write/__tests__/core.spec.ts
··· 26 26 27 27 setConfig({ 28 28 client: 'fetch', 29 + configFile: '', 29 30 debug: false, 30 31 dryRun: false, 31 32 exportCore: true, ··· 81 82 82 83 const config = setConfig({ 83 84 client: 'fetch', 85 + configFile: '', 84 86 debug: false, 85 87 dryRun: false, 86 88 exportCore: true, ··· 119 121 const config = setConfig({ 120 122 base: 'foo', 121 123 client: 'fetch', 124 + configFile: '', 122 125 debug: false, 123 126 dryRun: false, 124 127 exportCore: true,
+1
packages/openapi-ts/src/utils/write/__tests__/index.spec.ts
··· 13 13 it('writes to filesystem', async () => { 14 14 setConfig({ 15 15 client: 'fetch', 16 + configFile: '', 16 17 debug: false, 17 18 dryRun: false, 18 19 exportCore: true,
+1
packages/openapi-ts/src/utils/write/__tests__/models.spec.ts
··· 13 13 it('writes to filesystem', async () => { 14 14 setConfig({ 15 15 client: 'fetch', 16 + configFile: '', 16 17 debug: false, 17 18 dryRun: false, 18 19 exportCore: true,
+1
packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts
··· 14 14 it('writes to filesystem', async () => { 15 15 setConfig({ 16 16 client: 'fetch', 17 + configFile: '', 17 18 debug: false, 18 19 dryRun: false, 19 20 exportCore: true,
+3
packages/openapi-ts/src/utils/write/__tests__/services.spec.ts
··· 14 14 it('writes to filesystem', async () => { 15 15 setConfig({ 16 16 client: 'fetch', 17 + configFile: '', 17 18 debug: false, 18 19 dryRun: false, 19 20 exportCore: true, ··· 107 108 it('use default name', async () => { 108 109 setConfig({ 109 110 client: 'fetch', 111 + configFile: '', 110 112 debug: false, 111 113 dryRun: false, 112 114 exportCore: true, ··· 145 147 146 148 setConfig({ 147 149 client: 'fetch', 150 + configFile: '', 148 151 debug: false, 149 152 dryRun: false, 150 153 exportCore: true,