Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:04:14 +08:00
commit 70c36b5eff
248 changed files with 47482 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
/**
* Example: Complete Project Initialization Wizard
*
* Demonstrates combining multiple prompt types to create
* a comprehensive CLI tool for project setup
*/
import inquirer from 'inquirer';
async function projectInitWizard() {
console.log('\n╔════════════════════════════════════════╗');
console.log('║ 🚀 Project Initialization Wizard 🚀 ║');
console.log('╚════════════════════════════════════════╝\n');
const config = await inquirer.prompt([
// Project basics
{
type: 'input',
name: 'name',
message: 'Project name:',
validate: (input) => {
if (!/^[a-z0-9-]+$/.test(input)) {
return 'Use lowercase letters, numbers, and hyphens only';
}
return true;
}
},
{
type: 'input',
name: 'description',
message: 'Description:',
validate: (input) => input.length > 0 || 'Description required'
},
{
type: 'list',
name: 'language',
message: 'Programming language:',
choices: ['TypeScript', 'JavaScript', 'Python', 'Go', 'Rust']
},
{
type: 'list',
name: 'framework',
message: 'Framework:',
choices: (answers) => {
const frameworks = {
TypeScript: ['Next.js', 'Nest.js', 'Express', 'Fastify'],
JavaScript: ['React', 'Vue', 'Express', 'Koa'],
Python: ['FastAPI', 'Django', 'Flask'],
Go: ['Gin', 'Echo', 'Fiber'],
Rust: ['Actix', 'Rocket', 'Axum']
};
return frameworks[answers.language] || ['None'];
}
},
{
type: 'checkbox',
name: 'features',
message: 'Select features:',
choices: [
{ name: 'Database', value: 'database', checked: true },
{ name: 'Authentication', value: 'auth' },
{ name: 'API Documentation', value: 'docs' },
{ name: 'Testing', value: 'testing', checked: true },
{ name: 'Logging', value: 'logging', checked: true }
]
},
{
type: 'confirm',
name: 'useDocker',
message: 'Use Docker?',
default: true
},
{
type: 'confirm',
name: 'setupCI',
message: 'Setup CI/CD?',
default: true
}
]);
console.log('\n✅ Configuration complete!\n');
console.log(JSON.stringify(config, null, 2));
return config;
}
if (import.meta.url === `file://${process.argv[1]}`) {
projectInitWizard()
.then(() => process.exit(0))
.catch(console.error);
}
export { projectInitWizard };

View File

@@ -0,0 +1,100 @@
"""
Example: Complete Project Initialization Wizard
Demonstrates combining multiple prompt types to create
a comprehensive CLI tool for project setup
"""
import questionary
from questionary import Choice
import json
def project_init_wizard():
"""Complete project initialization wizard"""
print('\n╔════════════════════════════════════════╗')
print('║ 🚀 Project Initialization Wizard 🚀 ║')
print('╚════════════════════════════════════════╝\n')
# Project basics
name = questionary.text(
"Project name:",
validate=lambda text: (
text and text.replace('-', '').isalnum()
or "Use lowercase letters, numbers, and hyphens only"
)
).ask()
description = questionary.text(
"Description:",
validate=lambda text: len(text) > 0 or "Description required"
).ask()
# Language selection
language = questionary.select(
"Programming language:",
choices=['TypeScript', 'JavaScript', 'Python', 'Go', 'Rust']
).ask()
# Framework selection (based on language)
frameworks = {
'TypeScript': ['Next.js', 'Nest.js', 'Express', 'Fastify'],
'JavaScript': ['React', 'Vue', 'Express', 'Koa'],
'Python': ['FastAPI', 'Django', 'Flask'],
'Go': ['Gin', 'Echo', 'Fiber'],
'Rust': ['Actix', 'Rocket', 'Axum']
}
framework = questionary.select(
"Framework:",
choices=frameworks.get(language, ['None'])
).ask()
# Feature selection
features = questionary.checkbox(
"Select features:",
choices=[
Choice('Database', value='database', checked=True),
Choice('Authentication', value='auth'),
Choice('API Documentation', value='docs'),
Choice('Testing', value='testing', checked=True),
Choice('Logging', value='logging', checked=True)
]
).ask()
# Docker
use_docker = questionary.confirm(
"Use Docker?",
default=True
).ask()
# CI/CD
setup_ci = questionary.confirm(
"Setup CI/CD?",
default=True
).ask()
# Build configuration object
config = {
'name': name,
'description': description,
'language': language,
'framework': framework,
'features': features,
'useDocker': use_docker,
'setupCI': setup_ci
}
print('\n✅ Configuration complete!\n')
print(json.dumps(config, indent=2))
return config
if __name__ == "__main__":
try:
project_init_wizard()
except KeyboardInterrupt:
print("\n\n❌ Cancelled by user")
exit(1)