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 #1877 from Matsuuu/main

feat: disable writing a log file via a --no-log-file flag

authored by

Lubos and committed by
GitHub
069bb0da c557e04e

+39 -1
+5
.changeset/dull-pianos-enjoy.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + feat: ability to disable writing a log file via a `--no-log-file` flag or `logs.file` = `false`
+7
packages/openapi-ts/bin/index.cjs
··· 35 35 ) 36 36 .option('-s, --silent', 'Set log level to silent') 37 37 .option( 38 + '--no-log-file', 39 + 'Disable writing a log file. Works like --silent but without supressing console output', 40 + ) 41 + .option( 38 42 '-w, --watch [value]', 39 43 'Regenerate the client when the input file changes?', 40 44 ) ··· 83 87 84 88 userConfig = processParams(params, [ 85 89 'dryRun', 90 + 'logFile', 86 91 'experimentalParser', 87 92 'exportCore', 88 93 'useOptions', ··· 112 117 } else if (userConfig.silent) { 113 118 userConfig.logs.level = 'silent'; 114 119 } 120 + 121 + userConfig.logs.file = userConfig.logFile; 115 122 116 123 if (typeof params.watch === 'string') { 117 124 userConfig.watch = Number.parseInt(params.watch, 10);
+1
packages/openapi-ts/src/generate/__tests__/class.test.ts
··· 20 20 path: '', 21 21 }, 22 22 logs: { 23 + file: true, 23 24 level: 'info', 24 25 path: process.cwd(), 25 26 },
+3
packages/openapi-ts/src/generate/__tests__/core.test.ts
··· 35 35 path: '', 36 36 }, 37 37 logs: { 38 + file: true, 38 39 level: 'info', 39 40 path: process.cwd(), 40 41 }, ··· 127 128 path: '', 128 129 }, 129 130 logs: { 131 + file: true, 130 132 level: 'info', 131 133 path: process.cwd(), 132 134 }, ··· 202 204 path: '', 203 205 }, 204 206 logs: { 207 + file: true, 205 208 level: 'info', 206 209 path: process.cwd(), 207 210 },
+1
packages/openapi-ts/src/generate/__tests__/index.test.ts
··· 20 20 path: '', 21 21 }, 22 22 logs: { 23 + file: true, 23 24 level: 'info', 24 25 path: process.cwd(), 25 26 },
+1
packages/openapi-ts/src/generate/__tests__/output.test.ts
··· 21 21 path: '', 22 22 }, 23 23 logs: { 24 + file: true, 24 25 level: 'info', 25 26 path: process.cwd(), 26 27 },
+1
packages/openapi-ts/src/getLogs.ts
··· 2 2 3 3 export const getLogs = (userConfig: UserConfig | undefined): Config['logs'] => { 4 4 let logs: Config['logs'] = { 5 + file: true, 5 6 level: 'info', 6 7 path: process.cwd(), 7 8 };
+2 -1
packages/openapi-ts/src/index.ts
··· 67 67 } catch (error) { 68 68 const config = configs[0] as Config | undefined; 69 69 const dryRun = config ? config.dryRun : resolvedConfig?.dryRun; 70 + 70 71 // TODO: add setting for log output 71 72 if (!dryRun) { 72 73 const logs = config?.logs ?? getLogs(resolvedConfig); 73 - if (logs.level !== 'silent') { 74 + if (logs.level !== 'silent' && logs.file) { 74 75 const logName = `openapi-ts-error-${Date.now()}.log`; 75 76 const logsDir = path.resolve(process.cwd(), logs.path ?? ''); 76 77 ensureDirSync(logsDir);
+1
packages/openapi-ts/src/openApi/__tests__/index.test.ts
··· 18 18 vi.mock('../../utils/config', () => { 19 19 const config: Partial<Config> = { 20 20 logs: { 21 + file: false, 21 22 level: 'silent', 22 23 path: '', 23 24 },
+2
packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts
··· 21 21 path: '', 22 22 }, 23 23 logs: { 24 + file: true, 24 25 level: 'info', 25 26 path: process.cwd(), 26 27 }, ··· 109 110 path: '', 110 111 }, 111 112 logs: { 113 + file: true, 112 114 level: 'info', 113 115 path: process.cwd(), 114 116 },
+4
packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts
··· 24 24 path: '', 25 25 }, 26 26 logs: { 27 + file: true, 27 28 level: 'info', 28 29 path: process.cwd(), 29 30 }, ··· 184 185 path: '', 185 186 }, 186 187 logs: { 188 + file: true, 187 189 level: 'info', 188 190 path: process.cwd(), 189 191 }, ··· 266 268 path: '', 267 269 }, 268 270 logs: { 271 + file: true, 269 272 level: 'info', 270 273 path: process.cwd(), 271 274 }, ··· 351 354 path: '', 352 355 }, 353 356 logs: { 357 + file: true, 354 358 level: 'info', 355 359 path: process.cwd(), 356 360 },
+1
packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts
··· 21 21 path: '', 22 22 }, 23 23 logs: { 24 + file: true, 24 25 level: 'info', 25 26 path: process.cwd(), 26 27 },
+7
packages/openapi-ts/src/types/config.d.ts
··· 144 144 | string 145 145 | { 146 146 /** 147 + * Whether or not error logs should be written to a file or not 148 + * 149 + * @default true 150 + * */ 151 + file?: boolean; 152 + /** 147 153 * The logging level to control the verbosity of log output. 148 154 * Determines which messages are logged based on their severity. 149 155 * ··· 168 174 | 'silent' 169 175 | 'trace' 170 176 | 'warn'; 177 + 171 178 /** 172 179 * The relative location of the logs folder 173 180 *
+2
packages/openapi-ts/src/utils/__tests__/handlebars.test.ts
··· 18 18 path: '', 19 19 }, 20 20 logs: { 21 + file: true, 21 22 level: 'info', 22 23 path: process.cwd(), 23 24 }, ··· 84 85 path: '', 85 86 }, 86 87 logs: { 88 + file: true, 87 89 level: 'info', 88 90 path: process.cwd(), 89 91 },
+1
packages/openapi-ts/src/utils/__tests__/parse.test.ts
··· 13 13 path: '', 14 14 }, 15 15 logs: { 16 + file: true, 16 17 level: 'info', 17 18 path: process.cwd(), 18 19 },