Skip to content

Commit 50c3a7f

Browse files
committed
fix: make logFile optional in config
1 parent 097d0a1 commit 50c3a7f

File tree

5 files changed

+66
-63
lines changed

5 files changed

+66
-63
lines changed

packages/openapi-ts/bin/index.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ async function start() {
118118
userConfig.logs.level = 'silent';
119119
}
120120

121+
userConfig.logs.file = userConfig.logFile;
122+
121123
if (typeof params.watch === 'string') {
122124
userConfig.watch = Number.parseInt(params.watch, 10);
123125
}

packages/openapi-ts/src/getLogs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Config, UserConfig } from './types/config';
22

33
export const getLogs = (userConfig: UserConfig | undefined): Config['logs'] => {
44
let logs: Config['logs'] = {
5+
file: true,
56
level: 'info',
67
path: process.cwd(),
78
};

packages/openapi-ts/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ export const createClient = async (
6767
} catch (error) {
6868
const config = configs[0] as Config | undefined;
6969
const dryRun = config ? config.dryRun : resolvedConfig?.dryRun;
70-
const writeLogFile = config ? config.logFile : resolvedConfig?.logFile;
70+
7171
// TODO: add setting for log output
7272
if (!dryRun) {
7373
const logs = config?.logs ?? getLogs(resolvedConfig);
74-
if (logs.level !== 'silent' && writeLogFile) {
74+
if (logs.level !== 'silent' && logs.file) {
7575
const logName = `openapi-ts-error-${Date.now()}.log`;
7676
const logsDir = path.resolve(process.cwd(), logs.path ?? '');
7777
ensureDirSync(logsDir);

packages/openapi-ts/src/initConfigs.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ export const initConfigs = async (
269269
dryRun = false,
270270
experimentalParser = true,
271271
exportCore = true,
272-
logFile = true,
273272
name,
274273
request,
275274
useOptions = true,
@@ -312,7 +311,6 @@ export const initConfigs = async (
312311
experimentalParser,
313312
exportCore: false,
314313
input,
315-
logFile,
316314
logs,
317315
name,
318316
output,

packages/openapi-ts/src/types/config.d.ts

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,6 @@ export interface UserConfig {
135135
| (string & {})
136136
| Record<string, unknown>
137137
| Input;
138-
/**
139-
* @deprecated
140-
*
141-
* Opt in to the experimental parser?
142-
*
143-
* @default true
144-
*/
145-
experimentalParser?: boolean;
146-
147-
/**
148-
* @deprecated
149-
*
150-
* Generate core client classes?
151-
*
152-
* @default true
153-
*/
154-
exportCore?: boolean;
155138
/**
156139
* The relative location of the logs folder
157140
*
@@ -160,6 +143,12 @@ export interface UserConfig {
160143
logs?:
161144
| string
162145
| {
146+
/**
147+
* Whether or not error logs should be written to a file or not
148+
*
149+
* @default true
150+
* */
151+
file?: boolean;
163152
/**
164153
* The logging level to control the verbosity of log output.
165154
* Determines which messages are logged based on their severity.
@@ -185,55 +174,14 @@ export interface UserConfig {
185174
| 'silent'
186175
| 'trace'
187176
| 'warn';
177+
188178
/**
189179
* The relative location of the logs folder
190180
*
191181
* @default process.cwd()
192182
*/
193183
path?: string;
194184
};
195-
/**
196-
* Whether or not error logs should be written to a file or not
197-
* */
198-
logFile: boolean;
199-
/**
200-
* Regenerate the client when the input file changes? You can alternatively
201-
* pass a numeric value for the interval in ms.
202-
*
203-
* @default false
204-
*/
205-
watch?:
206-
| boolean
207-
| number
208-
| {
209-
/**
210-
* Regenerate the client when the input file changes?
211-
*
212-
* @default false
213-
*/
214-
enabled?: boolean;
215-
/**
216-
* How often should we attempt to detect the input file change? (in ms)
217-
*
218-
* @default 1000
219-
*/
220-
interval?: number;
221-
/**
222-
* How long will we wait before the request times out?
223-
*
224-
* @default 60_000
225-
*/
226-
timeout?: number;
227-
};
228-
/**
229-
* @deprecated
230-
*
231-
* Custom client class name. Please note this option is deprecated and
232-
* will be removed in favor of clients.
233-
*
234-
* @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-name
235-
*/
236-
name?: string;
237185
/**
238186
* The relative location of the output folder
239187
*/
@@ -289,13 +237,67 @@ export interface UserConfig {
289237
* @default ['@hey-api/typescript', '@hey-api/sdk']
290238
*/
291239
plugins?: ReadonlyArray<UserPlugins['name'] | UserPlugins>;
240+
/**
241+
* Regenerate the client when the input file changes? You can alternatively
242+
* pass a numeric value for the interval in ms.
243+
*
244+
* @default false
245+
*/
246+
watch?:
247+
| boolean
248+
| number
249+
| {
250+
/**
251+
* Regenerate the client when the input file changes?
252+
*
253+
* @default false
254+
*/
255+
enabled?: boolean;
256+
/**
257+
* How often should we attempt to detect the input file change? (in ms)
258+
*
259+
* @default 1000
260+
*/
261+
interval?: number;
262+
/**
263+
* How long will we wait before the request times out?
264+
*
265+
* @default 60_000
266+
*/
267+
timeout?: number;
268+
};
292269
/**
293270
* @deprecated
294271
*
295272
* Manually set base in OpenAPI config instead of inferring from server value
296273
*/
297274
// eslint-disable-next-line typescript-sort-keys/interface
298275
base?: string;
276+
/**
277+
* @deprecated
278+
*
279+
* Opt in to the experimental parser?
280+
*
281+
* @default true
282+
*/
283+
experimentalParser?: boolean;
284+
/**
285+
* @deprecated
286+
*
287+
* Generate core client classes?
288+
*
289+
* @default true
290+
*/
291+
exportCore?: boolean;
292+
/**
293+
* @deprecated
294+
*
295+
* Custom client class name. Please note this option is deprecated and
296+
* will be removed in favor of clients.
297+
*
298+
* @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-name
299+
*/
300+
name?: string;
299301
/**
300302
* @deprecated
301303
*

0 commit comments

Comments
 (0)