How to Create a New License Generator
Follow these steps to add a new license generator in your preferred language to the li-cen-se project.
1. Choose Your Language
Decide which language you want to use (e.g., Python, Ruby, JavaScript, TypeScript, etc.).
2. Create Your Script
- Place your script in the project root or a suitable subdirectory (e.g.,
generators/). - Your script should:
- Prompt the user for license type, author, project name, and year.
- Load license templates (from
licenses.jsonor hardcoded). - Replace placeholders in the template with user input.
- Optionally, support "AI-generated" licenses using the OpenAI API and an
OPENAI_API_KEYfrom.env. - Write the generated license text to a
LICENSEfile.
3. Use Environment Variables
- If your generator supports AI, load the OpenAI API key from the environment or a
.envfile:OPENAI_API_KEY=your-openai-api-key-here
4. Add Required Dependencies
- List any dependencies in your language's package manager file (e.g.,
requirements.txt,Gemfile,package.json).
5. Document Your Generator
- Create a setup instruction file in
docs/Setup/(e.g.,python.md,ruby.md,javascript.md,typescript.md). - Include:
- How to install dependencies
- How to run the script
- How to use the generator
- Troubleshooting tips
6. Test Your Generator
- Run your script and verify it generates a correct
LICENSEfile for all supported license types. - Test the "AI-generated" option if implemented.
7. (Optional) Add to Documentation
- Update the main README or documentation to mention your new generator and link to its setup instructions.
For examples, see the existing generator scripts and their setup