legalgen
v0.1.1
Published
A CLI tool that generates legal documents for web projects
Maintainers
Readme
LegalGen
A CLI tool and npm package that generates legal documents for web projects, including Terms of Service, Privacy Policy, Cookie Policy, and GDPR Compliance Statement.
Features
- 📄 Generates legally sound templates for common web documents
- 🔧 Interactive CLI workflow with prompts to customize your documents
- 💾 Save your configuration for future use
- �� Output in Markdown, HTML, or as React/Next.js/Vue components
- 🔄 Updates easily with new template versions
- 🧩 Generate components directly for your web application
Installation
Global Installation (recommended)
npm install -g legalgenLocal Installation
npm install legalgenUsage
Interactive Setup
The easiest way to get started is to run the interactive setup:
legalgen initThis will guide you through a series of questions to configure your legal documents.
Generate Documents
After completing the setup, generate your documents with:
legalgen generateSkip Interactive Prompts
You can skip all prompts and use defaults:
legalgen init --yesGenerate All Document Types
To generate all document types including GDPR:
legalgen init --allor
legalgen generate --allQuick Generation with Defaults
To skip configuration and immediately generate all documents with default values:
legalgen generate --skip-prompts --allUse a Custom Config File
legalgen generate --config path/to/custom-config.jsonSpecify Output Format
legalgen generate --format htmlFor component generation:
legalgen generate --format react
legalgen generate --format nextjs
legalgen generate --format vueChange Output Directory
legalgen generate --output path/to/outputConfiguration
LegalGen uses a configuration file (legal.config.json) to store your settings. Here's an example configuration:
{
"appName": "My App",
"companyName": "My Company",
"websiteUrl": "https://example.com",
"contactEmail": "[email protected]",
"generateTerms": true,
"generatePrivacy": true,
"generateCookies": true,
"generateGdpr": false,
"collectsUserData": true,
"collectsEmails": true,
"usesCookies": true,
"usesAnalytics": true,
"thirdPartyServices": [
{
"name": "Google Analytics",
"purpose": "Analytics",
"dataShared": ["Usage Data", "IP Address"],
"privacyPolicyUrl": "https://policies.google.com/privacy"
}
],
"jurisdiction": "United States",
"effectiveDate": "2023-06-01",
"outputFormat": "md",
"outputDir": "./legal",
"componentName": "Legal"
}Command Line Options
Init Command
legalgen init [options]| Option | Description |
|--------|-------------|
| -c, --config <path> | Path to save the config file |
| -y, --yes | Skip all prompts and use defaults |
| -a, --all | Enable all document types including GDPR |
Generate Command
legalgen generate [options]| Option | Description |
|--------|-------------|
| -c, --config <path> | Path to config file |
| -f, --format <format> | Output format (md, html, react, nextjs, or vue) |
| -o, --output <dir> | Output directory |
| -s, --skip-prompts | Skip all prompts and use config values |
| -a, --all | Generate all document types (including GDPR) |
Generated Documents
The tool generates the following legal documents:
- Terms of Service: User agreement for your website or application
- Privacy Policy: How you collect, use, and share user data
- Cookie Policy: How you use cookies and similar technologies
- GDPR Compliance Statement (optional): Details on GDPR compliance
Component Generation
LegalGen can generate UI components for different JavaScript frameworks:
React Components
Generated as .jsx files that can be imported into your React application:
import LegalTerms from './components/legal/LegalTerms';
function App() {
return (
<div className="app">
<LegalTerms />
</div>
);
}Next.js Components
Generated as client components (with 'use client' directive) that can be imported into your Next.js application:
import LegalPrivacy from './components/legal/LegalPrivacy';
export default function PrivacyPage() {
return (
<div className="container">
<LegalPrivacy />
</div>
);
}Vue Components
Generated as .vue files that can be imported into your Vue application:
<template>
<div>
<LegalCookies />
</div>
</template>
<script>
import LegalCookies from './components/legal/LegalCookies.vue';
export default {
components: {
LegalCookies
}
}
</script>Important Note
While LegalGen provides a good starting point for your legal documents, it is not a substitute for professional legal advice. Always have your legal documents reviewed by a qualified attorney to ensure they meet your specific needs and comply with all applicable laws.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
