Learn how to contribute templates and extensions to the project
The create-awesome-node-app project welcomes contributions from the community. You can contribute by:
This guide focuses on contributing templates and extensions, which are the most common types of contributions.
Templates are the foundation of create-awesome-node-app. They provide the initial structure and configuration for new projects. This guide will walk you through the process of creating and contributing a new template.
A template is essentially a complete project structure that serves as a starting point. Here's the recommended structure for a template:
templates/ └── your-template-name/ ├── public/ # Static assets ├── src/ # Source code │ ├── components/ # React components (for frontend templates) │ ├── lib/ # Utility functions and libraries │ └── styles/ # CSS and styling ├── .gitignore # Git ignore file ├── package.json # Package dependencies and scripts ├── README.md # Template documentation └── tsconfig.json # TypeScript configuration (if applicable)
Each template must be registered in the templates.json
file. This file helps the CLI understand how to use and present your template.
{ "templates": [ // ... existing templates { "name": "Your Template Name", "slug": "your-template-name", "description": "A concise description of your template", "url": "https://github.com/Create-Node-App/cna-templates/tree/main/templates/your-template-name", "type": "template-type", "category": "category-slug", "labels": ["Label1", "Label2", "Label3"] } ] }
Here's what each property means:
Follow these steps to create a new template:
customOptions
property to your template entry in templates.json
.// Example of customOptions in templates.json "customOptions": [ { "name": "srcDir", "type": "text", "message": "Subdirectory to put all source content (e.g., `src`). Leave blank to use the root directory.", "initial": "src" }, { "name": "projectImportPath", "type": "text", "message": "Import alias to use for the project, e.g., `@/`", "initial": "@/" } ]
Once your template is ready, you can submit it for inclusion in the create-awesome-node-app project:
templates/
directory.templates.json
file as described above.Extensions enhance templates with additional functionality. They are modular and can be applied to compatible templates.
An extension typically consists of files that will be added to or modified in a template. Here's a recommended structure:
extensions/ └── your-extension-name/ ├── files/ # Files to be added to the template │ ├── src/ # Source files to be added │ └── ... # Other files ├── dependencies.json # Dependencies to be added to package.json ├── scripts.json # Scripts to be added to package.json └── README.md # Extension documentation
Each extension must be registered in the templates.json
file:
{ "extensions": [ // ... existing extensions { "name": "Your Extension Name", "slug": "your-extension-name", "description": "A concise description of your extension", "url": "https://github.com/Create-Node-App/cna-templates/tree/main/extensions/your-extension-name", "type": ["template-type1", "template-type2"], "category": "Extension Category", "labels": ["Label1", "Label2", "Label3"] } ] }
Here's what each property means:
Follow these steps to create a new extension:
dependencies.json
file listing any npm packages your extension requires.package.json
, create a scripts.json
file.// Example dependencies.json { "dependencies": { "axios": "^1.3.4", "react-query": "^3.39.3" }, "devDependencies": { "@types/axios": "^0.14.0" } } // Example scripts.json { "scripts": { "api:generate": "openapi-generator-cli generate -i api-spec.yaml -g typescript-axios -o src/api" } }
Extensions must be compatible with the templates they're designed for. Here's how to ensure compatibility:
templates.json
, list all compatible template types in the type
property.src
directory), make your extension adaptable.// Example of specifying multiple compatible template types "type": ["react", "nextjs", "webextension-react"]
The process for submitting an extension is similar to submitting a template:
extensions/
directory.templates.json
file as described above.