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 interactivelyjts-multifile-plugins-guide
parent
61ae161501
commit
c24878651a
|
|
@ -64,15 +64,11 @@ function log(message, color = 'reset') {
|
||||||
* Prompt user for input (works in TTY and non-TTY environments)
|
* Prompt user for input (works in TTY and non-TTY environments)
|
||||||
*/
|
*/
|
||||||
async function promptUser(question) {
|
async function promptUser(question) {
|
||||||
// For non-TTY environments, return empty string
|
|
||||||
if (!process.stdin.isTTY) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const readline = await import('readline');
|
const readline = await import('readline');
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout,
|
output: process.stdout,
|
||||||
|
terminal: process.stdin.isTTY !== undefined ? process.stdin.isTTY : true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|
@ -150,6 +146,8 @@ ${colors.bright}Options:${colors.reset}
|
||||||
<draft-path> Path to draft markdown file (positional argument)
|
<draft-path> Path to draft markdown file (positional argument)
|
||||||
--from-draft <path> Path to draft markdown file
|
--from-draft <path> Path to draft markdown file
|
||||||
--url <url> Documentation URL for new content location
|
--url <url> Documentation URL for new content location
|
||||||
|
--products <list> Comma-separated product keys (required for stdin)
|
||||||
|
Examples: influxdb3_core, influxdb3_enterprise
|
||||||
--follow-external Include external (non-docs.influxdata.com) URLs
|
--follow-external Include external (non-docs.influxdata.com) URLs
|
||||||
when extracting links from draft. Without this flag,
|
when extracting links from draft. Without this flag,
|
||||||
only local documentation links are followed.
|
only local documentation links are followed.
|
||||||
|
|
@ -161,8 +159,10 @@ ${colors.bright}Options:${colors.reset}
|
||||||
--help Show this help message
|
--help Show this help message
|
||||||
|
|
||||||
${colors.bright}Stdin Support:${colors.reset}
|
${colors.bright}Stdin Support:${colors.reset}
|
||||||
cat draft.md | yarn docs:create Read draft from stdin
|
When piping content from stdin, you must specify target products:
|
||||||
echo "# Content" | yarn docs:create Create from piped content
|
|
||||||
|
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}
|
${colors.bright}Link Following:${colors.reset}
|
||||||
By default, the script extracts links from your draft and prompts you
|
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
|
# Include external links for selection
|
||||||
yarn docs:create --follow-external drafts/api-guide.md
|
yarn docs:create --follow-external drafts/api-guide.md
|
||||||
|
|
||||||
# Pipe content from stdin
|
# Pipe content from stdin (requires --products)
|
||||||
cat drafts/quick-note.md | yarn docs:create
|
cat drafts/quick-note.md | yarn docs:create --products influxdb3_core
|
||||||
echo "# Test Content" | yarn docs:create
|
echo "# Test Content" | yarn docs:create --products influxdb3_core
|
||||||
|
|
||||||
# Preview changes
|
# Preview changes
|
||||||
yarn docs:create --from-draft drafts/new-feature.md --dry-run
|
yarn docs:create --from-draft drafts/new-feature.md --dry-run
|
||||||
|
|
@ -1132,6 +1132,16 @@ async function main() {
|
||||||
let stdinContent = null;
|
let stdinContent = null;
|
||||||
|
|
||||||
if (hasStdin && !options.draft) {
|
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
|
// Import readDraftFromStdin
|
||||||
const { readDraftFromStdin } = await import('./lib/file-operations.js');
|
const { readDraftFromStdin } = await import('./lib/file-operations.js');
|
||||||
log('📥 Reading draft from stdin...', 'cyan');
|
log('📥 Reading draft from stdin...', 'cyan');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue