-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtransformations.yml
65 lines (65 loc) · 2.27 KB
/
transformations.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
ignore: [".git/", "transformations.yml", ".DS_Store", ".idea/", ".tmp/", "dist/", "go-archetype"]
inputs:
- id: ProjectName # Must be a unique ID. Can be used also as CLI arg
text: What is the project name?
type: text
- id: IncludeReadme
text: Would you like to include the readme file?
type: yesno
- id: ProjectDescription
text: Please provide a long project description
type: text
- id: ProjectType
text: Select project type
type: select
options: [ "simple", "medium", "advanced" ]
before:
operations:
- sh:
- ls {{ .destination }}
transformations:
- name: include the readme file
type: include
region_marker: # When there's no marker, the entire file(s) is included
condition: IncludeReadme
files: ["README.md"]
- name: include a reference to the readme file
type: include
region_marker: __INCLUDE_README__
condition: IncludeReadme
files: ["main.go"]
- name: project long description
type: replace
pattern: Use go-archetype to transform project archetypes into existing live projects
replacement: "{{ wrap 80 .ProjectDescription }}" # Wrap input by 80 columns
files: ["cmd/root.go"]
- name: project package
type: replace
pattern: github.com/rantav/go-archetype
replacement: github.com/xxx/yyy # A simple replacement that does not require user input. Useful? Not really...
files: ["*.go", "go.mod", "**/*.go"]
- name: project name
type: replace
pattern: go-archetype
replacement: "{{ .ProjectName }}" # Reference to an input ID; go templates syntax
files: ["*.go", "**/*.go"]
- name: simple
type: include
region_marker: __ProjectType_SIMPLE__ # Instantiates Simple project
condition: eq .ProjectType "simple"
files: ["main.go"]
- name: medium
type: include
region_marker: __ProjectType_MEDIUM__ # Instantiates Medium project
condition: eq .ProjectType "medium"
files: ["main.go"]
- name: advanced
type: include
region_marker: __ProjectType_ADVANCED__ # Instantiates Advanced project
condition: eq .ProjectType "advanced"
files: ["main.go"]
after:
operations:
- sh:
- cd {{.destination}} && gofmt -s -w .
- echo Done archetyping from {{ .source }} to {{ .destination }} of project {{ .ProjectName }}