Files
ui-ux-pro-max-skill/cli/src/commands/init.ts
Viet Tran 17d8ce53d4 feat: bundle skill assets in npm package (#12)
- Add assets folder with all skill files (.claude, .cursor, .windsurf, .agent, .shared)
- Simplify init command to copy from bundled assets instead of GitHub download
- Remove --version option (version tied to npm package)
- No more GitHub API rate limits
- Works offline
- Bump to v1.1.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-03 10:50:17 +07:00

87 lines
2.4 KiB
TypeScript

import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import chalk from 'chalk';
import ora from 'ora';
import prompts from 'prompts';
import type { AIType } from '../types/index.js';
import { AI_TYPES } from '../types/index.js';
import { copyFolders } from '../utils/extract.js';
import { detectAIType, getAITypeDescription } from '../utils/detect.js';
import { logger } from '../utils/logger.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
// From dist/index.js -> ../assets (one level up to cli/, then assets/)
const ASSETS_DIR = join(__dirname, '..', 'assets');
interface InitOptions {
ai?: AIType;
force?: boolean;
}
export async function initCommand(options: InitOptions): Promise<void> {
logger.title('UI/UX Pro Max Installer');
let aiType = options.ai;
// Auto-detect or prompt for AI type
if (!aiType) {
const { detected, suggested } = detectAIType();
if (detected.length > 0) {
logger.info(`Detected: ${detected.map(t => chalk.cyan(t)).join(', ')}`);
}
const response = await prompts({
type: 'select',
name: 'aiType',
message: 'Select AI assistant to install for:',
choices: AI_TYPES.map(type => ({
title: getAITypeDescription(type),
value: type,
})),
initial: suggested ? AI_TYPES.indexOf(suggested) : 0,
});
if (!response.aiType) {
logger.warn('Installation cancelled');
return;
}
aiType = response.aiType as AIType;
}
logger.info(`Installing for: ${chalk.cyan(getAITypeDescription(aiType))}`);
const spinner = ora('Installing files...').start();
try {
const cwd = process.cwd();
const copiedFolders = await copyFolders(ASSETS_DIR, cwd, aiType);
spinner.succeed('Installation complete!');
// Summary
console.log();
logger.info('Installed folders:');
copiedFolders.forEach(folder => {
console.log(` ${chalk.green('+')} ${folder}`);
});
console.log();
logger.success('UI/UX Pro Max installed successfully!');
// Next steps
console.log();
console.log(chalk.bold('Next steps:'));
console.log(chalk.dim(' 1. Restart your AI coding assistant'));
console.log(chalk.dim(' 2. Try: "Build a landing page for a SaaS product"'));
console.log();
} catch (error) {
spinner.fail('Installation failed');
if (error instanceof Error) {
logger.error(error.message);
}
process.exit(1);
}
}