Skip to main content

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.json or hardcoded).
    • Replace placeholders in the template with user input.
    • Optionally, support "AI-generated" licenses using the OpenAI API and an OPENAI_API_KEY from .env.
    • Write the generated license text to a LICENSE file.

3. Use Environment Variables

  • If your generator supports AI, load the OpenAI API key from the environment or a .env file:
    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 LICENSE file 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