-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d042b9
commit c6ea25c
Showing
19 changed files
with
4,361 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
node_modules | ||
dev | ||
.history | ||
.history | ||
.templates | ||
.repos | ||
test/basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Contributors | ||
|
||
## Adding your own template repo | ||
To contribute new templates to the project, you need to create a configuration for it that matches our TemplateRepoConfig type. The configuration is added to `config.js`. | ||
|
||
You can contribute two types of template repositories: `single` and `directory`. `single` contains one main template. `directory`, on the other hand, houses multiple templates, each in its own subdirectory. | ||
|
||
Here are examples of TemplateRepoConfig objects for each type: | ||
|
||
### Single template repo | ||
```javascript | ||
{ | ||
"url": "github:user/repo", | ||
"path": "optional/path/inside/repo", | ||
"name": "My Custom Template", | ||
"description": "This is a custom template contributed to the project.", | ||
"templateType": "single", | ||
"author": "Your Name", | ||
} | ||
``` | ||
|
||
### Directory templates repo | ||
```javascript | ||
{ | ||
"url": "github:user/repo", | ||
"path": "optional/path/inside/repo", | ||
"templateType": "directory", | ||
"author": "Your Name", | ||
"requireManifest": false // folders without a manifest will be skipped | ||
} | ||
``` | ||
|
||
## Template Manifest | ||
Manifests are optional and located at `<template>/manifest.js`. They enhance the template with extra information and features. | ||
|
||
Here's a Template manifest example | ||
```javascript | ||
{ | ||
name: 'my starter template', | ||
description: 'description of my template', | ||
test: { | ||
// adding tests will enable the `test` feature option | ||
// if users enable tests, this will automatically install vitest to the project | ||
tests: [{ page: '/', contains: 'Welcome to my starter template' }], | ||
}, | ||
// features are selectable by the user after selecting the template | ||
features: [ | ||
{ | ||
label: 'My Super Feature', | ||
value: 'my-super-feature', | ||
hint: 'This adds a super feature to the projet', | ||
initial: true, // should the user opt in or opt out | ||
}, | ||
], | ||
// runs after `npm install`, whether install is skipped or not | ||
// options contains the options selected by the user | ||
postInstall: async (options)=>{ | ||
// it's often easier to remove a feature than add a feature | ||
if (!options.features.includes('my-super-feature')) { | ||
const { rm } = await import('fs/promises'); | ||
await rm(`${options.projectDir}/src/components/superFeature.js`); | ||
} | ||
} | ||
// same as postInstall, but runs before `npm install` | ||
// preInstall: (options)=>{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const features = { | ||
prettier: { | ||
label: 'prettier', | ||
value: 'prettier', | ||
hint: 'Add prettier config', | ||
initial: true, | ||
}, | ||
}; | ||
|
||
/** @type {TemplateConfig} */ | ||
export default { | ||
versions: { | ||
2: { | ||
defaultTemplate: 'v2 starter template', | ||
templatesRepos: [ | ||
{ | ||
url: 'roxiness/routify-starter', | ||
name: 'v2 starter template', | ||
description: 'Routify v2 starter template', | ||
templateType: 'single', | ||
author: 'Roxi (official)', | ||
includeByDefault: true, | ||
}, | ||
], | ||
features: [features.prettier], | ||
}, | ||
3: { | ||
defaultTemplate: 'basic-starter', | ||
templatesRepos: [ | ||
{ | ||
url: 'roxiness/routify#next', | ||
// url: 'local:../routify', | ||
path: 'examples', | ||
templateType: 'directory', | ||
author: 'Roxi (official)', | ||
includeByDefault: true, | ||
requireManifest: true, | ||
}, | ||
], | ||
features: [features.prettier], | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.