Skip to content

Commit c30f2d3

Browse files
committed
chore: add template-generators created by Turbo template
1 parent 5068469 commit c30f2d3

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

turbo/generators/config.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { PlopTypes } from '@turbo/gen'
2+
3+
export default function generator(plop: PlopTypes.NodePlopAPI): void {
4+
plop.setGenerator('example', {
5+
description: 'An example Turborepo generator - creates a new file at the root of the project',
6+
prompts: [
7+
{
8+
type: 'input',
9+
name: 'file',
10+
message: 'What is the name of the new file to create?',
11+
validate: (input: string) => {
12+
if (input.includes('.')) {
13+
return 'file name cannot include an extension'
14+
}
15+
if (input.includes(' ')) {
16+
return 'file name cannot include spaces'
17+
}
18+
if (!input) {
19+
return 'file name is required'
20+
}
21+
return true
22+
},
23+
},
24+
{
25+
type: 'list',
26+
name: 'type',
27+
message: 'What type of file should be created?',
28+
choices: ['.md', '.txt'],
29+
},
30+
{
31+
type: 'input',
32+
name: 'title',
33+
message: 'What should be the title of the new file?',
34+
},
35+
],
36+
actions: [
37+
{
38+
type: 'add',
39+
path: '{{ turbo.paths.root }}/{{ dashCase file }}{{ type }}',
40+
templateFile: 'templates/turborepo-generators.hbs',
41+
},
42+
],
43+
})
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# {{ title }}
2+
3+
### Created with Turborepo Generators
4+
5+
Read the docs at [turbo.build](https://turbo.build/repo/docs/core-concepts/monorepos/code-generation).

0 commit comments

Comments
 (0)