From c24878651ab6f8b2ec47e301f22d7979f231a855 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Fri, 31 Oct 2025 17:31:36 -0500 Subject: [PATCH] fix: require --products flag when using stdin, remove TTY check from promptUser - stdin now requires --products flag with product keys - removed early return in promptUser() that prevented interactive prompts - updated help text with stdin + --products examples - prevents 'No products selected' error when running interactively --- scripts/docs-create.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/scripts/docs-create.js b/scripts/docs-create.js index 176cc35b0..08a6f2b7f 100644 --- a/scripts/docs-create.js +++ b/scripts/docs-create.js @@ -64,15 +64,11 @@ function log(message, color = 'reset') { * Prompt user for input (works in TTY and non-TTY environments) */ async function promptUser(question) { - // For non-TTY environments, return empty string - if (!process.stdin.isTTY) { - return ''; - } - const readline = await import('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, + terminal: process.stdin.isTTY !== undefined ? process.stdin.isTTY : true, }); return new Promise((resolve) => { @@ -150,6 +146,8 @@ ${colors.bright}Options:${colors.reset} Path to draft markdown file (positional argument) --from-draft Path to draft markdown file --url Documentation URL for new content location + --products Comma-separated product keys (required for stdin) + Examples: influxdb3_core, influxdb3_enterprise --follow-external Include external (non-docs.influxdata.com) URLs when extracting links from draft. Without this flag, only local documentation links are followed. @@ -161,8 +159,10 @@ ${colors.bright}Options:${colors.reset} --help Show this help message ${colors.bright}Stdin Support:${colors.reset} - cat draft.md | yarn docs:create Read draft from stdin - echo "# Content" | yarn docs:create Create from piped content + When piping content from stdin, you must specify target products: + + cat draft.md | yarn docs:create --products influxdb3_core + echo "# Content" | yarn docs:create --products influxdb3_core,influxdb3_enterprise ${colors.bright}Link Following:${colors.reset} By default, the script extracts links from your draft and prompts you @@ -210,9 +210,9 @@ ${colors.bright}Examples:${colors.reset} # Include external links for selection yarn docs:create --follow-external drafts/api-guide.md - # Pipe content from stdin - cat drafts/quick-note.md | yarn docs:create - echo "# Test Content" | yarn docs:create + # Pipe content from stdin (requires --products) + cat drafts/quick-note.md | yarn docs:create --products influxdb3_core + echo "# Test Content" | yarn docs:create --products influxdb3_core # Preview changes yarn docs:create --from-draft drafts/new-feature.md --dry-run @@ -1132,6 +1132,16 @@ async function main() { let stdinContent = null; if (hasStdin && !options.draft) { + // Stdin requires --products option + if (!options.products) { + log( + '\nāœ— Error: --products is required when piping content from stdin', + 'red' + ); + log('Example: echo "# Content" | yarn docs:create --products influxdb3_core', 'yellow'); + process.exit(1); + } + // Import readDraftFromStdin const { readDraftFromStdin } = await import('./lib/file-operations.js'); log('šŸ“„ Reading draft from stdin...', 'cyan');