wally-ui
Version:
About Where’s Wally? Right here — bringing you ready-to-use Angular components with Wally-UI. Stop searching, start building.
100 lines (99 loc) • 4.63 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const readline_1 = __importDefault(require("readline"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const chalk_1 = __importDefault(require("chalk"));
const path_1 = __importDefault(require("path"));
console.log(chalk_1.default.whiteBright(`
██╗ ██╗ █████╗ ██╗ ██╗ ██╗ ██╗
██║ ██║██╔══██╗██║ ██║ ╚██╗ ██╔╝
██║ █╗ ██║███████║██║ ██║ ╚████╔╝
██║███╗██║██╔══██║██║ ██║ ╚██╔╝
╚███╔███╔╝██║ ██║███████╗███████╗██║
╚══╝╚══╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝
Where’s Wally? Right here with Angular UI
Stop searching, start building
`));
const program = new commander_1.Command();
const askConfirmation = (question) => {
const rl = readline_1.default.createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise(resolve => {
rl.question(question, answer => {
rl.close();
resolve(answer.toLowerCase().trim() === 'y' || answer.toLowerCase().trim() === 'yes');
});
});
};
program
.name('wally')
.description('Angular component generator')
.version('1.0.8');
program
.command('add <component>')
.description('Add a new component')
.action(async (component) => {
// Block AI components (coming soon in Chat SDK)
if (component.startsWith('ai-')) {
console.log(chalk_1.default.yellowBright(`\n AI components (${component}) are part of the Chat SDK (coming soon).`));
console.log(chalk_1.default.blueBright('These components will be available via: ') + chalk_1.default.cyan('npx wally-ui add chat-sdk'));
console.log(chalk_1.default.gray('Visit https://wally-ui.com/documentation/chat-sdk for more info.\n'));
return;
}
// Check if Angular project
if (!fs_extra_1.default.existsSync('angular.json')) {
console.log(chalk_1.default.redBright('Not an Angular project. Run this in Angular project root.'));
return;
}
const componentPath = `src/app/components/wally-ui/${component}`;
if (await fs_extra_1.default.pathExists(componentPath)) {
console.log(chalk_1.default.yellowBright(`Component '${component}' already exists at ${componentPath}`));
const shouldOverwrite = await askConfirmation(chalk_1.default.blueBright('Do you want to overwrite it? ') + chalk_1.default.cyan('(y/N): '));
if (!shouldOverwrite) {
console.log(chalk_1.default.gray('Operation cancelled.'));
return;
}
}
const playgroundPath = path_1.default.join(__dirname, '..', 'playground', 'showcase', 'src', 'app', 'components', component);
try {
if (!await fs_extra_1.default.pathExists(playgroundPath)) {
console.log(chalk_1.default.red(`Component '${component}' not found in playground`));
return;
}
await fs_extra_1.default.copy(playgroundPath, componentPath, {
overwrite: true,
errorOnExist: false
});
console.log(chalk_1.default.green('Template loaded successfully!'));
}
catch (error) {
console.log(chalk_1.default.red(`Template not found: ${component}`));
}
});
program
.command('list')
.alias('ls')
.description('List available components')
.action(async () => {
const playgroundComponentsPath = path_1.default.join(__dirname, '..', 'playground', 'showcase', 'src', 'app', 'components');
try {
const components = await fs_extra_1.default.readdir(playgroundComponentsPath);
console.log(chalk_1.default.blue('\nAvailable components:'));
components.forEach(component => {
console.log(chalk_1.default.green(` ✓ ${component}`));
});
}
catch (error) {
console.log(chalk_1.default.red('Could not access playground components.'));
console.log(chalk_1.default.yellow('Make sure playground/src/app/components/ exists.'));
}
});
program.parse();
//# sourceMappingURL=cli.js.map