Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 16 additions & 29 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
#!/usr/bin/env node

import { Command } from 'commander';
import { createCommand } from './commands/create.js';
import chalk from 'chalk';

const program = new Command();

program
.name('celo-composer')
.description('CLI tool for generating customizable Celo blockchain starter kits')
.version('1.0.0');
import getChalk from './utils/getChalk.js';

program
.command('create')
.description('Create a new Celo project')
.argument('[project-name]', 'Name of the project')
.option('-d, --description <description>', 'Project description')
.option('-t, --template <type>', 'Template type (basic, farcaster-miniapp, minipay, ai-chat)')
.option('--wallet-provider <provider>', 'Wallet provider (rainbowkit, thirdweb, none)')
.option('-c, --contracts <framework>', 'Smart contract framework (hardhat, foundry, none)')
.option('--skip-install', 'Skip package installation')
.option('-y, --yes', 'Skip all prompts and use defaults')
.action(createCommand);
(async function main() {
const chalk = await getChalk();

const program = new Command();

program.on('command:*', () => {
console.error(chalk.red(`Invalid command: ${program.args.join(' ')}`));
console.log(chalk.yellow('See --help for a list of available commands.'));
process.exit(1);
});
program
.name('celo-composer')
.description('CLI tool for generating customizable Celo blockchain starter kits')
.version('1.0.0');

if (process.argv.length === 2) {
program.help();
}
program.on('command:*', () => {
console.error(chalk.red('Invalid command: ' + program.args.join(' ')));
console.log(chalk.yellow('See --help for a list of available commands.'));
process.exit(1);
});

program.parse(process.argv);
await program.parseAsync(process.argv);
})();
22 changes: 22 additions & 0 deletions src/utils/getChalk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Lightweight dynamic loader for ESM-only 'chalk'.
// Returns the chalk default export (or a minimal no-op shim if import fails).
export default async function getChalk(): Promise<any> {
try {
const mod = await import('chalk');
return mod && (mod.default || mod);
} catch (err) {
// Minimal shim preserving common style functions.
const noop = (s: any) => String(s);
const base = {
bold: noop, dim: noop, red: noop, green: noop, yellow: noop,
blue: noop, cyan: noop, magenta: noop, white: noop, gray: noop
};
return new Proxy(base, {
get(target: any, prop: string) {
if (prop in target) return target[prop];
// allow chalk.green.bold('x') — return function that returns the string
return (s: any) => String(s);
}
});
}
}