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 #2336 from hey-api/fix/tty

fix: respect NO_INTERACTIVE and NO_INTERACTION environment variables

authored by

Lubos and committed by
GitHub
83f63a6b a382ae6c

+44 -3
+5
.changeset/green-wolves-join.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: respect NO_INTERACTIVE and NO_INTERACTION environment variables
+8
packages/openapi-ts/bin/index.cjs
··· 93 93 'useOptions', 94 94 ]); 95 95 96 + const isInteractive = 97 + process.stdin.isTTY && 98 + process.stdout.isTTY && 99 + !process.env.CI && 100 + !process.env.NO_INTERACTIVE && 101 + !process.env.NO_INTERACTION; 102 + userConfig.interactive = isInteractive; 103 + 96 104 if (params.plugins === true) { 97 105 userConfig.plugins = []; 98 106 } else if (params.plugins) {
+2
packages/openapi-ts/src/config/init.ts
··· 52 52 dryRun = false, 53 53 experimentalParser = true, 54 54 exportCore = true, 55 + interactive = false, 55 56 name, 56 57 request, 57 58 useOptions = true, ··· 113 114 experimentalParser, 114 115 exportCore: false, 115 116 input, 117 + interactive, 116 118 logs, 117 119 name, 118 120 output,
+2 -2
packages/openapi-ts/src/error.ts
··· 6 6 import { findPackageJson } from './generate/tsConfig'; 7 7 import { ensureDirSync } from './generate/utils'; 8 8 9 - export const isInteractive = process.stdin.isTTY && process.stdout.isTTY; 10 - 11 9 export class ConfigError extends Error {} 12 10 13 11 export class HeyApiError extends Error { ··· 154 152 155 153 export const shouldReportCrash = async ({ 156 154 error, 155 + isInteractive, 157 156 }: { 158 157 error: unknown; 158 + isInteractive: boolean | undefined; 159 159 }): Promise<boolean> => { 160 160 if (!isInteractive || error instanceof ConfigError) { 161 161 return false;
+1
packages/openapi-ts/src/generate/__tests__/class.test.ts
··· 25 25 timeout: 60_000, 26 26 }, 27 27 }, 28 + interactive: false, 28 29 logs: { 29 30 file: true, 30 31 level: 'info',
+3
packages/openapi-ts/src/generate/__tests__/core.test.ts
··· 40 40 timeout: 60_000, 41 41 }, 42 42 }, 43 + interactive: false, 43 44 logs: { 44 45 file: true, 45 46 level: 'info', ··· 174 175 timeout: 60_000, 175 176 }, 176 177 }, 178 + interactive: false, 177 179 logs: { 178 180 file: true, 179 181 level: 'info', ··· 291 293 timeout: 60_000, 292 294 }, 293 295 }, 296 + interactive: false, 294 297 logs: { 295 298 file: true, 296 299 level: 'info',
+1
packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts
··· 25 25 timeout: 60_000, 26 26 }, 27 27 }, 28 + interactive: false, 28 29 logs: { 29 30 file: true, 30 31 level: 'info',
+1
packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts
··· 38 38 timeout: 60_000, 39 39 }, 40 40 }, 41 + interactive: false, 41 42 logs: { 42 43 file: true, 43 44 level: 'info',
+4 -1
packages/openapi-ts/src/index.ts
··· 83 83 } catch (error) { 84 84 const config = configs[0] as Config | undefined; 85 85 const dryRun = config ? config.dryRun : resolvedConfig?.dryRun; 86 + const isInteractive = config 87 + ? config.interactive 88 + : resolvedConfig?.interactive; 86 89 const logs = config?.logs ?? getLogs(resolvedConfig); 87 90 88 91 let logPath: string | undefined; ··· 93 96 94 97 if (logs.level !== 'silent') { 95 98 printCrashReport({ error, logPath }); 96 - if (await shouldReportCrash({ error })) { 99 + if (await shouldReportCrash({ error, isInteractive })) { 97 100 await openGitHubIssueWithCrashReport(error); 98 101 } 99 102 }
+2
packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts
··· 27 27 timeout: 60_000, 28 28 }, 29 29 }, 30 + interactive: false, 30 31 logs: { 31 32 file: true, 32 33 level: 'info', ··· 162 163 timeout: 60_000, 163 164 }, 164 165 }, 166 + interactive: false, 165 167 logs: { 166 168 file: true, 167 169 level: 'info',
+4
packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts
··· 30 30 timeout: 60_000, 31 31 }, 32 32 }, 33 + interactive: false, 33 34 logs: { 34 35 file: true, 35 36 level: 'info', ··· 238 239 timeout: 60_000, 239 240 }, 240 241 }, 242 + interactive: false, 241 243 logs: { 242 244 file: true, 243 245 level: 'info', ··· 368 370 timeout: 60_000, 369 371 }, 370 372 }, 373 + interactive: false, 371 374 logs: { 372 375 file: true, 373 376 level: 'info', ··· 501 504 timeout: 60_000, 502 505 }, 503 506 }, 507 + interactive: false, 504 508 logs: { 505 509 file: true, 506 510 level: 'info',
+1
packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts
··· 27 27 timeout: 60_000, 28 28 }, 29 29 }, 30 + interactive: false, 30 31 logs: { 31 32 file: true, 32 33 level: 'info',
+7
packages/openapi-ts/src/types/config.d.ts
··· 30 30 | (Record<string, unknown> & { path?: never }) 31 31 | Input; 32 32 /** 33 + * Show an interactive error reporting tool when the program crashes? You 34 + * generally want to keep this disabled (default). 35 + * 36 + * @default false 37 + */ 38 + interactive?: boolean; 39 + /** 33 40 * The relative location of the logs folder. 34 41 * 35 42 * @default process.cwd()
+2
packages/openapi-ts/src/utils/__tests__/handlebars.test.ts
··· 23 23 timeout: 60_000, 24 24 }, 25 25 }, 26 + interactive: false, 26 27 logs: { 27 28 file: true, 28 29 level: 'info', ··· 131 132 timeout: 60_000, 132 133 }, 133 134 }, 135 + interactive: false, 134 136 logs: { 135 137 file: true, 136 138 level: 'info',
+1
packages/openapi-ts/src/utils/__tests__/parse.test.ts
··· 17 17 timeout: 60_000, 18 18 }, 19 19 }, 20 + interactive: false, 20 21 logs: { 21 22 file: true, 22 23 level: 'info',