UNPKG

build-in-public-bot

Version:

AI-powered CLI bot for automating build-in-public tweets with code screenshots

135 lines • 7.42 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.styleCommand = styleCommand; const logger_1 = require("../utils/logger"); const config_1 = require("../services/config"); const prompts_1 = require("../utils/prompts"); const chalk_1 = __importDefault(require("chalk")); async function styleCommand(options) { const configService = config_1.ConfigService.getInstance(); try { const config = await configService.load(); if (options.reset) { const confirmReset = await (0, prompts_1.confirm)('Are you sure you want to reset style preferences to defaults?'); if (confirmReset) { const defaultStyle = { tone: 'casual-technical', emojis: { frequency: 'moderate', preferred: ['šŸš€', 'šŸ’”', 'šŸ”§', '✨', 'šŸŽÆ', 'šŸ’»', 'šŸ› ļø', '⚔'] }, hashtags: { always: ['#buildinpublic'], contextual: ['#webdev', '#typescript', '#nodejs', '#opensource'] }, examples: [ 'Just shipped a new feature that makes X 10x faster šŸš€ Used Y technique to optimize Z. The difference is wild! #buildinpublic', 'Debugging session turned into a refactoring marathon šŸ”§ Sometimes the best features come from fixing bugs. Added proper error handling and the UX is so much smoother now ✨', 'TIL: You can use X to solve Y problem. Been struggling with this for hours and the solution was so simple šŸ’” Love when things just click! #buildinpublic #webdev' ] }; await configService.update({ style: defaultStyle }); logger_1.logger.success('Style preferences reset to defaults!'); } else { logger_1.logger.info('Reset cancelled.'); } return; } console.log(chalk_1.default.bold('\nšŸŽØ Configure Tweet Style\n')); console.log(chalk_1.default.bold('Current Settings:')); console.log(` Tone: ${chalk_1.default.cyan(config.style.tone)}`); console.log(` Emoji frequency: ${chalk_1.default.cyan(config.style.emojis.frequency)}`); console.log(` Always hashtags: ${chalk_1.default.cyan(config.style.hashtags.always.join(', ') || 'none')}`); console.log(); const action = await (0, prompts_1.select)('What would you like to configure?', [ { value: 'tone', label: 'Writing tone' }, { value: 'emojis', label: 'Emoji usage' }, { value: 'hashtags', label: 'Hashtag preferences' }, { value: 'examples', label: 'Example tweets' }, { value: 'done', label: 'Done (save and exit)' } ]); if (action === 'done') { return; } switch (action) { case 'tone': { const tone = await (0, prompts_1.select)('Select writing tone:', [ { value: 'casual-technical', label: 'Casual Technical (friendly but informative)' }, { value: 'professional', label: 'Professional (formal and structured)' }, { value: 'enthusiastic', label: 'Enthusiastic (excited and energetic)' }, { value: 'minimalist', label: 'Minimalist (concise and to the point)' } ]); config.style.tone = tone; break; } case 'emojis': { const frequency = await (0, prompts_1.select)('How often should emojis be used?', [ { value: 'none', label: 'Never use emojis' }, { value: 'low', label: 'Sparingly (max 1 per tweet)' }, { value: 'moderate', label: 'Moderate (1-2 per tweet)' }, { value: 'high', label: 'Frequently (2-3 per tweet)' } ]); config.style.emojis.frequency = frequency; if (frequency !== 'none') { const customEmojis = await (0, prompts_1.confirm)('Would you like to customize preferred emojis?'); if (customEmojis) { const emojiList = await (0, prompts_1.prompt)('Enter preferred emojis (separated by spaces)', { default: config.style.emojis.preferred.join(' ') }); config.style.emojis.preferred = emojiList.split(' ').filter(e => e.trim()); } } break; } case 'hashtags': { const alwaysHashtags = await (0, prompts_1.prompt)('Hashtags to always include (separated by spaces)', { default: config.style.hashtags.always.join(' ') }); const contextualHashtags = await (0, prompts_1.prompt)('Contextual hashtags to consider (separated by spaces)', { default: config.style.hashtags.contextual.join(' ') }); config.style.hashtags.always = alwaysHashtags.split(' ') .filter(h => h.trim()) .map(h => h.startsWith('#') ? h : `#${h}`); config.style.hashtags.contextual = contextualHashtags.split(' ') .filter(h => h.trim()) .map(h => h.startsWith('#') ? h : `#${h}`); break; } case 'examples': { console.log('\nCurrent example tweets:'); config.style.examples.forEach((ex, i) => { console.log(`${i + 1}. ${ex}`); }); const addExample = await (0, prompts_1.confirm)('\nWould you like to add an example tweet?'); if (addExample) { const example = await (0, prompts_1.prompt)('Enter example tweet'); config.style.examples.push(example); } const removeExample = await (0, prompts_1.confirm)('Would you like to remove an example?'); if (removeExample && config.style.examples.length > 0) { const indexStr = await (0, prompts_1.prompt)(`Which example to remove? (1-${config.style.examples.length})`, { validate: (input) => { const num = parseInt(input, 10); if (isNaN(num) || num < 1 || num > config.style.examples.length) { return `Please enter a number between 1 and ${config.style.examples.length}`; } return true; } }); config.style.examples.splice(parseInt(indexStr, 10) - 1, 1); } break; } } await configService.save(config); logger_1.logger.success('Style preferences updated!'); const continueConfig = await (0, prompts_1.confirm)('Continue configuring?', true); if (continueConfig) { await styleCommand({}); } } catch (error) { logger_1.logger.error('Failed to update style preferences'); throw error; } } //# sourceMappingURL=style.js.map