|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +/** |
| 4 | + * @wgtechlabs/forklift - Entry Point Runner |
| 5 | + * |
| 6 | + * This is the main CLI entry point for the Forklift dual build system. |
| 7 | + * It provides a lightweight interface that loads and executes the main |
| 8 | + * forklift.js module with the appropriate configuration. |
| 9 | + * |
| 10 | + * When forklift is extracted as a standalone npm package, this file will |
| 11 | + * become the `bin` entry point, allowing users to run `npx forklift` or |
| 12 | + * install it globally and run `forklift` from anywhere. |
| 13 | + * |
| 14 | + * @author Waren Gonzaga, WG Technology Labs |
| 15 | + * @version 1.0.0 |
| 16 | + * @license MIT |
| 17 | + */ |
| 18 | + |
| 19 | +// Import and run the forklift module |
| 20 | +import('./forklift.js').then(async (forklift) => { |
| 21 | + // Merge default configuration with runtime overrides |
| 22 | + const config = { |
| 23 | + ...forklift.defaultConfig, |
| 24 | + clean: process.argv.includes('--clean'), |
| 25 | + watch: process.argv.includes('--watch'), |
| 26 | + verbose: process.argv.includes('--verbose') || process.argv.includes('-v'), |
| 27 | + dryRun: process.argv.includes('--dry-run') || process.argv.includes('-n'), |
| 28 | + }; |
| 29 | + |
| 30 | + if (process.argv.includes('--help') || process.argv.includes('-h')) { |
| 31 | + console.log(` |
| 32 | +🚀 @wgtechlabs/forklift - Dual Build System |
| 33 | +
|
| 34 | +Usage: node scripts/forklift-runner.js [options] |
| 35 | +
|
| 36 | +Options: |
| 37 | + --clean Clean output directory before build |
| 38 | + --watch Watch mode (rebuild on file changes) |
| 39 | + --verbose, -v Enable verbose logging |
| 40 | + --dry-run, -n Show what would be done without building |
| 41 | + --help, -h Show this help message |
| 42 | + `); |
| 43 | + process.exit(0); |
| 44 | + } |
| 45 | + |
| 46 | + try { |
| 47 | + forklift.validateConfig(config); |
| 48 | + |
| 49 | + if (config.watch) { |
| 50 | + await forklift.watchMode(config); |
| 51 | + } else { |
| 52 | + const success = await forklift.build(config); |
| 53 | + process.exit(success ? 0 : 1); |
| 54 | + } |
| 55 | + } catch (error) { |
| 56 | + console.error('❌ Forklift error:', error.message); |
| 57 | + process.exit(1); |
| 58 | + } |
| 59 | +}).catch(error => { |
| 60 | + console.error('❌ Failed to load forklift:', error); |
| 61 | + process.exit(1); |
| 62 | +}); |
0 commit comments