package-installer-cli 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,51 +3,69 @@
3
3
  */
4
4
  import chalk from 'chalk';
5
5
  import path from 'path';
6
- import gradient from 'gradient-string';
7
- import boxen from 'boxen';
8
- import { promptProjectName, promptFrameworkSelection, promptLanguageSelection, promptTemplateSelection, promptFrameworkOptions, promptTemplateConfirmation, promptFeatureSelection, promptFeatureProvider, hasFrameworkOptions, hasUIOptions, hasBundlerOptions, shouldShowTemplates } from '../utils/prompts.js';
6
+ import { createStandardHelp } from '../utils/helpFormatter.js';
7
+ import { promptProjectName, promptFrameworkSelection, promptLanguageSelection, promptTemplateSelection, promptFrameworkOptions, promptTemplateConfirmation, promptFeatureSelection, hasFrameworkOptions, hasUIOptions, hasBundlerOptions, shouldShowTemplates } from '../utils/prompts.js';
9
8
  import { resolveTemplatePath, generateTemplateName, templateExists, getFrameworkConfig } from '../utils/templateResolver.js';
10
9
  import { createProjectFromTemplate, installDependenciesForCreate } from '../utils/templateCreator.js';
11
- import { updateTemplateUsage, getCachedTemplateFiles, cacheTemplateFiles, getDirectorySize, cacheProjectData } from '../utils/cacheManager.js';
10
+ import { updateTemplateUsage, getCachedTemplateFiles, cacheTemplateFiles, cacheProjectData } from '../utils/cacheManager.js';
12
11
  import { CacheManager } from '../utils/cacheUtils.js';
13
- import { addFeatureToProject } from './add.js';
14
12
  /**
15
13
  * Display help for create command
16
14
  */
17
15
  export function showCreateHelp() {
18
- const piGradient = gradient(['#00c6ff', '#0072ff']);
19
- const headerGradient = gradient(['#4facfe', '#00f2fe']);
20
- console.log('\n' + boxen(headerGradient('🚀 Create Command Help') + '\n\n' +
21
- chalk.white('Create a new project from our curated collection of modern templates.') + '\n' +
22
- chalk.white('Choose from React, Next.js, Express, Nest.js, Rust, and more!') + '\n\n' +
23
- chalk.cyan('Usage:') + '\n' +
24
- chalk.white(` ${piGradient('pi')} ${chalk.hex('#10ac84')('create')} [project-name]`) + '\n\n' +
25
- chalk.cyan('Options:') + '\n' +
26
- chalk.gray(' -h, --help Display help for this command') + '\n\n' +
27
- chalk.cyan('Examples:') + '\n' +
28
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('create')} my-awesome-app # Create with specific name`) + '\n' +
29
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('create')} # Interactive mode - will prompt for name`) + '\n' +
30
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('create')} ${chalk.hex('#ff6b6b')('--show-cache')} # Show cached preferences`) + '\n' +
31
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('create')} ${chalk.hex('#ff6b6b')('--clear-cache')} # Clear cached preferences`) + '\n' +
32
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('create')} ${chalk.hex('#ff6b6b')('--help')} # Show this help message`) + '\n\n' +
33
- chalk.hex('#00d2d3')('💡 Smart Caching:') + '\n' +
34
- chalk.hex('#95afc0')(' • Remembers your preferences from previous sessions') + '\n' +
35
- chalk.hex('#95afc0')(' • Suggests framework-specific project names') + '\n' +
36
- chalk.hex('#95afc0')(' • Shows project count and usage statistics') + '\n\n' +
37
- chalk.hex('#00d2d3')('💡 Available Templates:') + '\n' +
38
- chalk.hex('#95afc0')(' • React (Vite) - JavaScript/TypeScript variants') + '\n' +
39
- chalk.hex('#95afc0')(' • Next.js - App Router with multiple configurations') + '\n' +
40
- chalk.hex('#95afc0')(' • Express - RESTful APIs with authentication') + '\n' +
41
- chalk.hex('#95afc0')(' • Nest.js - Enterprise-grade Node.js framework') + '\n' +
42
- chalk.hex('#95afc0')(' • Angular - Modern Angular applications') + '\n' +
43
- chalk.hex('#95afc0')(' • Vue.js - Progressive Vue.js applications') + '\n' +
44
- chalk.hex('#95afc0')(' • Rust - Systems programming templates') + '\n' +
45
- chalk.hex('#95afc0')(' • Django - Python web framework'), {
46
- padding: 1,
47
- borderStyle: 'round',
48
- borderColor: 'cyan',
49
- backgroundColor: '#0a0a0a'
50
- }));
16
+ const helpConfig = {
17
+ commandName: 'Create',
18
+ emoji: '🚀',
19
+ description: 'Create a new project from our curated collection of modern templates.\nChoose from React, Next.js, Express, Nest.js, Rust, and more!',
20
+ usage: [
21
+ 'create [project-name] [options]',
22
+ 'create [options]'
23
+ ],
24
+ options: [
25
+ { flag: '-h, --help', description: 'Display help for this command' },
26
+ { flag: '--show-cache', description: 'Show cached preferences' },
27
+ { flag: '--clear-cache', description: 'Clear cached preferences' }
28
+ ],
29
+ examples: [
30
+ { command: 'create my-awesome-app', description: 'Create with specific name' },
31
+ { command: 'create', description: 'Interactive mode - will prompt for name' },
32
+ { command: 'create --show-cache', description: 'Show cached preferences' },
33
+ { command: 'create --clear-cache', description: 'Clear cached preferences' }
34
+ ],
35
+ additionalSections: [
36
+ {
37
+ title: 'Smart Caching',
38
+ items: [
39
+ 'Remembers your preferences from previous sessions',
40
+ 'Suggests framework-specific project names',
41
+ 'Shows project count and usage statistics'
42
+ ]
43
+ },
44
+ {
45
+ title: 'Available Templates',
46
+ items: [
47
+ 'React (Vite) - JavaScript/TypeScript variants',
48
+ 'Next.js - App Router with multiple configurations',
49
+ 'Express - RESTful APIs with authentication',
50
+ 'Nest.js - Enterprise-grade Node.js framework',
51
+ 'Angular - Modern Angular applications',
52
+ 'Vue.js - Progressive Vue.js applications',
53
+ 'Rust - Systems programming templates',
54
+ 'Django - Python web framework',
55
+ 'Flask - Lightweight Python web apps',
56
+ 'Go - Fast and efficient web services',
57
+ 'React-Native - Mobile apps for iOS and Android',
58
+ 'Combination Templates - reactjs+express+shadcn,reactjs=nestjs+shadcn'
59
+ ]
60
+ }
61
+ ],
62
+ tips: [
63
+ 'Use interactive mode for guided project creation',
64
+ 'Templates include best practices and modern tooling',
65
+ 'All templates support both JavaScript and TypeScript'
66
+ ]
67
+ };
68
+ createStandardHelp(helpConfig);
51
69
  }
52
70
  /**
53
71
  * Main create project function with comprehensive prompt system
@@ -143,12 +161,10 @@ export async function createProject(providedName, options) {
143
161
  await installDependenciesForCreate(projectPath);
144
162
  // Step 11.5: Cache template usage and project data
145
163
  try {
146
- await updateTemplateUsage(templateName || selectedFramework, selectedFramework, selectedLanguage, [] // Features will be updated after adding them
147
- );
164
+ await updateTemplateUsage(templateName || selectedFramework, selectedFramework, selectedLanguage);
148
165
  const templateFiles = await getCachedTemplateFiles(templateName || selectedFramework);
149
- await cacheTemplateFiles(templateName || selectedFramework, templatePath, templateFiles || {}, await getDirectorySize(projectPath));
150
- await cacheProjectData(projectPath, projectName, selectedLanguage, selectedFramework, [], // Features will be added next
151
- await getDirectorySize(projectPath));
166
+ await cacheTemplateFiles(templateName || selectedFramework, templatePath, templateFiles || {});
167
+ await cacheProjectData(projectPath, projectName, selectedLanguage);
152
168
  }
153
169
  catch (error) {
154
170
  console.warn(chalk.yellow('⚠️ Could not cache project data'));
@@ -157,17 +173,22 @@ export async function createProject(providedName, options) {
157
173
  const selectedFeatures = await promptFeatureSelection();
158
174
  if (selectedFeatures.length > 0) {
159
175
  console.log(chalk.hex('#00d2d3')('\n🚀 Adding Features...\n'));
176
+ // Import the add command dynamically to avoid circular imports
177
+ const { addCommand } = await import('./add.js');
160
178
  for (const category of selectedFeatures) {
161
- const provider = await promptFeatureProvider(category, selectedFramework);
162
- if (provider) {
163
- console.log(chalk.cyan(`🔧 Adding ${provider} for ${category}...`));
164
- const success = await addFeatureToProject(projectPath, category, provider, selectedFramework);
165
- if (success) {
166
- console.log(chalk.green(`✅ Successfully added ${provider} for ${category}`));
167
- }
168
- else {
169
- console.log(chalk.yellow(`⚠️ Failed to add ${provider} for ${category}, skipping...`));
170
- }
179
+ try {
180
+ console.log(chalk.cyan(`🔧 Adding ${category} feature...`));
181
+ // Use the add command directly with the detected framework
182
+ await addCommand(category, undefined, {
183
+ framework: selectedFramework,
184
+ projectPath: projectPath,
185
+ list: false,
186
+ verbose: false
187
+ });
188
+ console.log(chalk.green(`✅ Successfully added ${category} feature`));
189
+ }
190
+ catch (error) {
191
+ console.log(chalk.yellow(`⚠️ Failed to add ${category} feature, skipping...`));
171
192
  }
172
193
  }
173
194
  }
@@ -4,32 +4,40 @@
4
4
  import chalk from 'chalk';
5
5
  import gradient from 'gradient-string';
6
6
  import boxen from 'boxen';
7
+ import { createStandardHelp } from '../utils/helpFormatter.js';
7
8
  /**
8
9
  * Display help for deploy command
9
10
  */
10
11
  export function showDeployHelp() {
11
- const piGradient = gradient(['#00c6ff', '#0072ff']);
12
- const headerGradient = gradient(['#ff9a9e', '#fecfef']);
13
- console.log('\n' + boxen(headerGradient('🚀 Deploy Command Help') + '\n\n' +
14
- chalk.white('Deploy your projects to various cloud platforms seamlessly.') + '\n' +
15
- chalk.white('This feature is currently under development!') + '\n\n' +
16
- chalk.cyan('Usage:') + '\n' +
17
- chalk.white(` ${piGradient('pi')} ${chalk.hex('#10ac84')('deploy')}`) + '\n\n' +
18
- chalk.cyan('Options:') + '\n' +
19
- chalk.gray(' -h, --help Display help for this command') + '\n\n' +
20
- chalk.cyan('Examples:') + '\n' +
21
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('deploy')} # Deploy current project`) + '\n' +
22
- chalk.gray(` ${piGradient('pi')} ${chalk.hex('#10ac84')('deploy')} ${chalk.hex('#ff6b6b')('--help')} # Show this help message`) + '\n\n' +
23
- chalk.hex('#00d2d3')('🔮 Planned Features:') + '\n' +
24
- chalk.hex('#95afc0')(' • Deploy to Vercel, Netlify, AWS') + '\n' +
25
- chalk.hex('#95afc0')(' • Docker container deployment') + '\n' +
26
- chalk.hex('#95afc0')(' • Environment variable management') + '\n' +
27
- chalk.hex('#95afc0')(' CI/CD pipeline setup'), {
28
- padding: 1,
29
- borderStyle: 'round',
30
- borderColor: 'magenta',
31
- backgroundColor: '#0a0a0a'
32
- }));
12
+ const helpConfig = {
13
+ commandName: 'deploy',
14
+ emoji: '🚀',
15
+ description: 'Deploy your projects to various cloud platforms seamlessly.\nThis feature is currently under development!',
16
+ usage: ['pi deploy'],
17
+ options: [
18
+ { flag: '-h, --help', description: 'Display help for this command' }
19
+ ],
20
+ examples: [
21
+ { command: 'pi deploy', description: 'Deploy current project' },
22
+ { command: 'pi deploy --help', description: 'Show this help message' }
23
+ ],
24
+ additionalSections: [
25
+ {
26
+ title: '🔮 Planned Features',
27
+ items: [
28
+ '• Deploy to Vercel, Netlify, AWS',
29
+ '• Docker container deployment',
30
+ '• Environment variable management',
31
+ '• CI/CD pipeline setup'
32
+ ]
33
+ }
34
+ ],
35
+ tips: [
36
+ 'This feature is currently under development - stay tuned!',
37
+ 'Follow the project on GitHub for updates and releases'
38
+ ]
39
+ };
40
+ createStandardHelp(helpConfig);
33
41
  }
34
42
  /**
35
43
  * Display coming soon animation
@@ -9,6 +9,7 @@ import path from 'path';
9
9
  import boxen from 'boxen';
10
10
  import gradient from 'gradient-string';
11
11
  import { displaySuccessMessage, displayErrorMessage } from '../utils/dashboard.js';
12
+ import { createStandardHelp } from '../utils/helpFormatter.js';
12
13
  /**
13
14
  * Check if command exists
14
15
  */
@@ -181,35 +182,33 @@ async function autoFixIssue(issue, projectPath) {
181
182
  * Display help for doctor command
182
183
  */
183
184
  export function showDoctorHelp() {
185
+ const helpConfig = {
186
+ commandName: 'doctor',
187
+ emoji: '🩺',
188
+ description: 'Diagnose and fix common development issues.\nComprehensive health check for your development environment and project setup.',
189
+ usage: ['pi doctor [options]', 'pi diagnose [options] # (alias)'],
190
+ options: [
191
+ { flag: '--fix', description: 'Automatically fix detected issues' },
192
+ { flag: '--node', description: 'Check Node.js and npm setup only' },
193
+ { flag: '--deps', description: 'Check project dependencies only' },
194
+ { flag: '--tools', description: 'Check development tools only' },
195
+ { flag: '--verbose', description: 'Show detailed diagnostic information' },
196
+ { flag: '-h, --help', description: 'Show this help message' }
197
+ ],
198
+ examples: [
199
+ { command: 'pi doctor', description: 'Complete health check' },
200
+ { command: 'pi doctor --fix', description: 'Check and auto-fix issues' },
201
+ { command: 'pi doctor --deps', description: 'Check dependencies only' },
202
+ { command: 'pi doctor --node --verbose', description: 'Detailed Node.js check' }
203
+ ],
204
+ tips: [
205
+ 'Use --fix to automatically resolve common issues',
206
+ 'Run with --verbose for detailed diagnostic information',
207
+ '\'pi diagnose\' is an alias for \'pi doctor\''
208
+ ]
209
+ };
184
210
  console.clear();
185
- const helpContent = boxen(gradient(['#ff6b6b', '#4ecdc4'])('🩺 Doctor Command Help') + '\n\n' +
186
- chalk.white('Diagnose and fix common development issues') + '\n\n' +
187
- chalk.cyan('Usage:') + '\n' +
188
- chalk.white(' pi doctor [options]') + '\n' +
189
- chalk.white(' pi diagnose [options]') + chalk.gray(' (alias)') + '\n\n' +
190
- chalk.cyan('Description:') + '\n' +
191
- chalk.white(' Comprehensive health check for your development environment') + '\n' +
192
- chalk.white(' and project setup. Detects and fixes common issues.') + '\n\n' +
193
- chalk.cyan('Options:') + '\n' +
194
- chalk.white(' --fix') + chalk.gray(' Automatically fix detected issues') + '\n' +
195
- chalk.white(' --node') + chalk.gray(' Check Node.js and npm setup only') + '\n' +
196
- chalk.white(' --deps') + chalk.gray(' Check project dependencies only') + '\n' +
197
- chalk.white(' --tools') + chalk.gray(' Check development tools only') + '\n' +
198
- chalk.white(' --verbose') + chalk.gray(' Show detailed diagnostic information') + '\n' +
199
- chalk.white(' -h, --help') + chalk.gray(' Show this help message') + '\n\n' +
200
- chalk.cyan('Examples:') + '\n' +
201
- chalk.gray(' # Complete health check') + '\n' +
202
- chalk.white(' pi doctor') + '\n\n' +
203
- chalk.gray(' # Check and auto-fix issues') + '\n' +
204
- chalk.white(' pi doctor --fix') + '\n\n' +
205
- chalk.gray(' # Check dependencies only') + '\n' +
206
- chalk.white(' pi doctor --deps'), {
207
- padding: 1,
208
- margin: 1,
209
- borderStyle: 'round',
210
- borderColor: 'green'
211
- });
212
- console.log(helpContent);
211
+ createStandardHelp(helpConfig);
213
212
  }
214
213
  /**
215
214
  * Main doctor command function
data/dist/commands/env.js CHANGED
@@ -9,6 +9,7 @@ import path from 'path';
9
9
  import boxen from 'boxen';
10
10
  import gradient from 'gradient-string';
11
11
  import inquirer from 'inquirer';
12
+ import { createStandardHelp } from '../utils/helpFormatter.js';
12
13
  import { displaySuccessMessage, displayErrorMessage } from '../utils/dashboard.js';
13
14
  import { detectProjectStack } from '../utils/featureInstaller.js';
14
15
  /**
@@ -208,37 +209,49 @@ async function validateEnvFile(projectPath) {
208
209
  * Display help for environment command
209
210
  */
210
211
  export function showEnvironmentHelp() {
211
- console.clear();
212
- const helpContent = boxen(gradient(['#ff6b6b', '#feca57'])('🌍 Environment Command Help') + '\n\n' +
213
- chalk.white('Analyze and manage your development environment') + '\n\n' +
214
- chalk.cyan('Usage:') + '\n' +
215
- chalk.white(' pi env [options]') + '\n' +
216
- chalk.white(' pi environment [options]') + chalk.gray(' (alias)') + '\n\n' +
217
- chalk.cyan('Description:') + '\n' +
218
- chalk.white(' Comprehensive environment analysis and management tools') + '\n' +
219
- chalk.white(' for development setup and configuration') + '\n\n' +
220
- chalk.cyan('Options:') + '\n' +
221
- chalk.white(' --check') + chalk.gray(' Check development tools and versions') + '\n' +
222
- chalk.white(' --generate') + chalk.gray(' Generate .env template for project') + '\n' +
223
- chalk.white(' --validate') + chalk.gray(' Validate existing .env file') + '\n' +
224
- chalk.white(' --export') + chalk.gray(' Export environment info to file') + '\n' +
225
- chalk.white(' --system') + chalk.gray(' Show system information only') + '\n' +
226
- chalk.white(' -h, --help') + chalk.gray(' Show this help message') + '\n\n' +
227
- chalk.cyan('Examples:') + '\n' +
228
- chalk.gray(' # Interactive environment analysis') + '\n' +
229
- chalk.white(' pi env') + '\n\n' +
230
- chalk.gray(' # Check development tools') + '\n' +
231
- chalk.white(' pi env --check') + '\n\n' +
232
- chalk.gray(' # Generate .env template') + '\n' +
233
- chalk.white(' pi env --generate') + '\n\n' +
234
- chalk.gray(' # Validate .env file') + '\n' +
235
- chalk.white(' pi env --validate'), {
236
- padding: 1,
237
- margin: 1,
238
- borderStyle: 'round',
239
- borderColor: 'yellow'
240
- });
241
- console.log(helpContent);
212
+ const helpConfig = {
213
+ commandName: 'Environment',
214
+ emoji: '🌍',
215
+ description: 'Analyze and manage your development environment.\nComprehensive environment analysis and management tools for development setup and configuration.',
216
+ usage: [
217
+ 'env [options]',
218
+ 'environment [options] # alias'
219
+ ],
220
+ options: [
221
+ { flag: '--check', description: 'Check development tools and versions' },
222
+ { flag: '--generate', description: 'Generate .env template for project' },
223
+ { flag: '--validate', description: 'Validate existing .env file' },
224
+ { flag: '--export', description: 'Export environment info to file' },
225
+ { flag: '--system', description: 'Show system information only' },
226
+ { flag: '-h, --help', description: 'Show this help message' }
227
+ ],
228
+ examples: [
229
+ { command: 'env', description: 'Interactive environment analysis' },
230
+ { command: 'env --check', description: 'Check development tools' },
231
+ { command: 'env --generate', description: 'Generate .env template' },
232
+ { command: 'env --validate', description: 'Validate .env file' },
233
+ { command: 'env --system', description: 'Show system information only' },
234
+ { command: 'environment --export', description: 'Export environment info to file' }
235
+ ],
236
+ additionalSections: [
237
+ {
238
+ title: 'Features',
239
+ items: [
240
+ 'Development tools version checking',
241
+ 'Environment file generation and validation',
242
+ 'System information analysis',
243
+ 'Configuration management',
244
+ 'Project environment setup'
245
+ ]
246
+ }
247
+ ],
248
+ tips: [
249
+ 'Use --generate to create .env templates for your projects',
250
+ 'Regular environment checks help maintain development consistency',
251
+ 'Validate .env files to catch configuration issues early'
252
+ ]
253
+ };
254
+ createStandardHelp(helpConfig);
242
255
  }
243
256
  /**
244
257
  * Main environment command function