This CLI tool allows you to generate new projects from customizable templates. It provides an interactive interface for selecting templates and inputting project-specific variables, with support for both local and remote generation via GitHub.
- Local Mode: Interactive project generation with template selection
- Remote Mode: Automatic generation + GitHub repository creation
- File Configuration: YAML and JSON support for automation
- Smart Validation: Project and package names with appropriate validation
- Automatic Installation: Dependency installation after generation
- Dynamic Replacement: Customizable variables in templates
- GitHub Integration: Automatic repository creation with initial push
- Ensure you have Rust and Cargo installed on your system.
- Clone this repository:
git clone [repository_url] cd [repository_name] - Build the project:
cargo build --release
Options:
-d, --debug Enable debug output
-f, --config <CONFIG> Path to configuration file (YAML or JSON)
-c, --category <CATEGORY> Template category
-n, --template <TEMPLATE> Template name
--remote GitHub mode (generation + repository creation)
--token <TOKEN> GitHub token for remote mode
-h, --help Show help
-V, --version Show version
Pour tester rapidement vos templates, utilisez les commandes Make automatisées :
# Afficher les templates disponibles et les commandes
make show-templates
# Générer une configuration pour le template Library
make config-library
# Générer une configuration pour le template Astro
make config-astro
# Tester le template Library (génère config + lance le test)
make test-library
# Tester le template Astro (génère config + lance le test)
make test-astro
# Nettoyer les fichiers de configuration de test
make clean-configsLe script scripts/generate-config.sh analyse automatiquement les template_config.json et génère des fichiers de configuration prêts à l'emploi :
# Générer une configuration pour un template spécifique
./scripts/generate-config.sh library
./scripts/generate-config.sh astro
# Avec un nom de fichier personnalisé
./scripts/generate-config.sh library ma-config-custom.yamlAvantages :
- ✅ Extraction automatique des placeholders depuis
template_config.json - ✅ Valeurs par défaut intelligentes selon le type de template
- ✅ Noms uniques avec timestamp pour éviter les conflits
- ✅ Configuration complète prête à l'utilisation
Remote mode generates a project locally then automatically creates a GitHub repository with the code.
- GitHub Token: You must have a GitHub token with appropriate permissions
- Configuration File: A YAML or JSON file is required
- Environment Variables: Optional, can be used instead of the
--tokenflag
Create a configuration file (e.g., config.yaml):
# Required configuration
project_name: "my-awesome-project" # Project name (used for folder)
name: "@myorg/my-awesome-project" # Package name (for package.json, etc.)
description: "Description of my project" # GitHub repository description
# Template configuration
template_category: "apps" # Category: "apps", "packages", or "utils"
template_name: "nextjs-app" # Specific template name
# Additional variables (optional, depends on template)
author: "My Name"
license: "MIT"
version: "1.0.0"
keywords: "nextjs,react,webapp"You can set your GitHub token in the environment:
export GITHUB_TOKEN="ghp_your_token_here"cargo run -- --remote --config config.yaml --token ghp_your_token_hereexport GITHUB_TOKEN="ghp_your_token_here"
cargo run -- --remote --config config.yamlWhen you execute the command, the tool:
- ✅ Reads your configuration file
- ✅ Validates required data
- ✅ Generates the project in a temporary folder
- ✅ Replaces all variables in template files
- ✅ Installs dependencies (npm, pnpm, etc.)
- ✅ Asks for the GitHub repository name (default: project name)
- ✅ Creates the GitHub repository in the organization
- ✅ Initializes Git, makes initial commit and pushes code
- ✅ Cleans up temporary folder
- ✅ Displays the new repository URL
# 1. Create the config file
cat > my-project.yaml << EOF
project_name: "portfolio-client"
name: "@nextnode/portfolio-client"
description: "Modern portfolio site with Next.js"
template_category: "apps"
template_name: "nextjs-app"
author: "NextNode Team"
license: "MIT"
version: "0.1.0"
EOF
# 2. Execute remote generation
export GITHUB_TOKEN="ghp_your_personal_token"
cargo run -- --remote --config my-project.yaml
# 3. The tool will ask:
# > Project name: portfolio-client
# > Do you want to use the project name as the repository name? (Y/n)Local mode offers several generation options based on your needs.
The simplest method to get started:
cargo runInteractive process:
- Template selection from a list
- Project name input (automatic validation)
- Package name input (automatic validation)
- Custom variables input according to template
- Generation in parent folder (
../) - Automatic dependency installation
Example session:
? Select a template: › nextjs-app (apps)
? Enter value for project_name: › my-new-site
? Enter value for name: › @myorg/my-new-site
? Enter value for description: › My modern website
? Enter value for author: › My Name
✓ Project generated successfully!
✓ Dependencies installed successfully!
Use a config file but stay local:
cargo run -- --config config.yamlAdvantages:
- No manual interaction
- Reproducible and scriptable
- Ideal for automation
Configuration file example:
project_name: "my-local-project"
name: "@myorg/my-local-project"
description: "Automatically generated project"
template_category: "packages"
template_name: "library"
author: "Developer"
license: "Apache-2.0"
version: "0.1.0"
# Custom variables according to template
main_export: "index.ts"
typescript: "true"Directly specify the desired template:
cargo run -- --category apps --template nextjs-appProcess:
- Pre-selected template
- Interactive input only for variables
- Immediate generation
To diagnose or understand the process:
cargo run -- --debug --config config.yamlInformation displayed:
- Configuration file parsing
- Extracted variables and their values
- Processed files and replacements made
- Dependency installation steps
- Details of each operation
# config-partial.yaml
project_name: "base-project"
template_category: "apps"
template_name: "react-app"
# Other variables will be asked interactivelycargo run -- --config config-partial.yamlcargo run -- --debug --category packages --template librarySupported categories:
apps: Complete applications (Next.js, React, etc.)packages: NPM libraries and packagesutils: Development utilities and tools
Templates Repository: You can find all available templates at: https://github.com/NextNodeSolutions/utils_project-templates
Template structure:
templates/
├── apps/
│ ├── nextjs-app/
│ │ ├── template_config.json
│ │ ├── package.json
│ │ ├── src/
│ │ └── ...
│ └── react-app/
├── packages/
│ └── library/
└── utils/
└── cli-tool/
All these variables can be used in your templates:
{{project_name}}: Project name (validated: lowercase, hyphens, underscores){{name}}: Package name (validated: npm standard format){{description}}: Project description{{author}}: Project author{{license}}: License type{{version}}: Initial version{{keywords}}: Keywords (transformed to array for JSON)
Each template contains a template_config.json:
{
"files_to_replace": [
"package.json",
"README.md",
"src/config.ts"
],
"replacements": [
{
"name": "project_name",
"key": "name",
"value": "{{project_name}}",
"type": "string"
},
{
"name": "keywords",
"key": "keywords",
"value": "{{keywords}}",
"type": "array"
}
]
}Local Mode: Projects are generated in ../project-name/
Structure after generation:
../
├── my-new-project/
│ ├── package.json # Variables replaced
│ ├── README.md # Variables replaced
│ ├── src/
│ ├── node_modules/ # Dependencies installed
│ └── ...
For remote mode, you can use:
# Option 1: Environment variable
export GITHUB_TOKEN="ghp_your_token"
# Option 2: .env file (if supported)
echo "GITHUB_TOKEN=ghp_your_token" >> .env
# Option 3: CLI argument
cargo run -- --remote --token ghp_your_token --config config.yaml# Enable debug for all operations
export DEBUG=1
cargo run# Complete interactive mode
cargo run
# Select: nextjs-app (apps)
# Fill in the requested variables# With predefined configuration
cat > lib-config.yaml << EOF
project_name: "utils-math"
name: "@myorg/utils-math"
description: "Reusable mathematical utilities"
template_category: "packages"
template_name: "library"
author: "My Team"
license: "MIT"
EOF
cargo run -- --config lib-config.yaml# Remote mode with repository creation
export GITHUB_TOKEN="ghp_your_token"
cargo run -- --remote --config production-config.yaml# See all process details
cargo run -- --debug --category apps --template nextjs-app- Project names: Strict validation (lowercase, letters, numbers, hyphens, underscores)
- Package names: NPM standard format validation
- GitHub tokens: Never displayed in plain text, secure handling
- Temporary files: Automatic cleanup after remote generation
- Permissions: Rights verification before repository creation
"GitHub token is required"
export GITHUB_TOKEN="your_token"
# or
cargo run -- --token your_token --remote --config config.yaml"Config file is required for remote mode"
# Remote mode always requires a config file
cargo run -- --remote --config your-config.yaml"Failed to parse config file"
# Check YAML/JSON syntax
cargo run -- --debug --config your-config.yaml"Template not found"
# Check available categories and templates
cargo run -- --debugContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GPL-3.0-only License.