build-in-public-bot
Version:
AI-powered CLI bot for automating build-in-public tweets with code screenshots
207 lines (206 loc) • 7.61 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dotenv = __importStar(require("dotenv"));
const path = __importStar(require("path"));
dotenv.config({ path: path.resolve(__dirname, '../.env') });
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const logger_1 = require("./utils/logger");
const errors_1 = require("./utils/errors");
const init_1 = require("./commands/init");
const post_1 = require("./commands/post");
const code_1 = require("./commands/code");
const style_1 = require("./commands/style");
const history_1 = require("./commands/history");
const draft_1 = require("./commands/draft");
const watch_1 = require("./commands/watch");
const summary_1 = require("./commands/summary");
const auto_1 = require("./commands/auto");
const setup_api_1 = require("./commands/setup-api");
const config_1 = __importDefault(require("./commands/config"));
const screenshot_1 = __importDefault(require("./commands/screenshot"));
const doctor_1 = __importDefault(require("./commands/doctor"));
const completion_1 = __importDefault(require("./commands/completion"));
const terminal_1 = __importDefault(require("./commands/terminal"));
const auto_alias_1 = __importDefault(require("./commands/auto-alias"));
const setup_1 = __importDefault(require("./commands/setup"));
const config_automation_1 = require("./commands/config-automation");
const package_json_1 = __importDefault(require("../package.json"));
const program = new commander_1.Command();
process.on('unhandledRejection', (error) => {
(0, errors_1.handleError)(error);
});
process.on('uncaughtException', (error) => {
(0, errors_1.handleError)(error);
});
program
.name('bip')
.description('AI-powered CLI bot for automating build-in-public tweets')
.version(package_json_1.default.version, '-V, --version', 'output the version number')
.option('-v, --verbose', 'verbose output')
.option('-q, --quiet', 'quiet output (errors only)')
.option('-d, --debug', 'enable debug mode')
.option('--dry-run', 'show what would be done without executing')
.option('--config <file>', 'use custom config file')
.option('--no-color', 'disable colored output')
.option('--json', 'output in JSON format where applicable')
.hook('preAction', (thisCommand) => {
const opts = thisCommand.opts();
if (opts.debug) {
process.env.DEBUG = 'true';
logger_1.logger.debug('Debug mode enabled');
}
if (opts.quiet) {
process.env.LOG_LEVEL = 'error';
}
else if (opts.verbose) {
process.env.LOG_LEVEL = 'debug';
}
if (opts.noColor) {
chalk_1.default.level = 0;
}
})
.configureHelp({
sortSubcommands: true,
subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.usage()
});
program
.command('init')
.description('Initialize build-in-public bot configuration')
.action(async () => {
try {
await (0, init_1.initCommand)();
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
program
.command('post <message>')
.description('Generate and post a build-in-public tweet')
.option('-n, --no-confirm', 'skip confirmation before posting')
.action(async (message, options) => {
try {
await (0, post_1.postCommand)(message, options);
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
program
.command('code <file> [caption]')
.description('Post code screenshot with caption')
.option('-l, --lines <range>', 'line range to capture (e.g., "1-10")')
.option('-n, --no-confirm', 'skip confirmation before posting')
.action(async (file, caption, options) => {
try {
await (0, code_1.codeCommand)(file, caption, options);
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
program
.command('style')
.description('Configure tweet style preferences')
.option('-r, --reset', 'reset to default style')
.action(async (options) => {
try {
await (0, style_1.styleCommand)(options);
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
program
.command('history')
.description('View recent posts')
.option('-l, --limit <number>', 'number of posts to show', '10')
.action(async (options) => {
try {
await (0, history_1.historyCommand)(options);
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
program
.command('draft <message>')
.description('Generate tweet without posting')
.option('-s, --save', 'save draft for later')
.action(async (message, options) => {
try {
await (0, draft_1.draftCommand)(message, options);
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
program.addCommand(watch_1.watchCommand);
program.addCommand(summary_1.summaryCommand);
program.addCommand(auto_1.autoCommand);
program.addCommand(setup_1.default);
program.addCommand(setup_api_1.setupApiCommand);
program.addCommand(config_1.default);
program.addCommand(screenshot_1.default);
program.addCommand(doctor_1.default);
program.addCommand(completion_1.default);
program.addCommand(terminal_1.default);
program.addCommand(auto_alias_1.default);
program.addCommand(config_automation_1.configAutomationCommand);
program.addCommand(config_automation_1.showAutomationCommand);
program.addHelpText('after', `
Examples:
$ bip init Initialize configuration
$ bip auto-alias Set up helpful command shortcuts
$ bip post "Just fixed a bug" Generate and post a tweet
$ bip code app.js Post code screenshot
$ bip screenshot src/app.ts Generate screenshot only
$ bip terminal --select 5-10 Capture terminal with selection
$ bip config show Show current configuration
$ bip doctor Run health checks
For more help on a specific command:
$ bip <command> --help
`);
program.parse();
if (!process.argv.slice(2).length) {
program.outputHelp();
}
//# sourceMappingURL=cli.js.map
;