-
Notifications
You must be signed in to change notification settings - Fork 32
/
dodo.py
174 lines (142 loc) · 4.91 KB
/
dodo.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
'''
DoIt (http://pydoit.org/) main Python module. Tasks are automatically generated for all projects from
ALL_PROJECTS list. Template directory is scanned for the templates. When adding new template, no
changes to this file are needed in case BaseProject implementations of all tasks are satisfying.
In case the actions of some tasks need to be customized, the new BaseProject subclass must be imported.
'''
import os
import sys
from project import BaseProject, TEMPLATEDIR
from project.akeneo import Akeneo
from project.backdrop import Backdrop
from project.drupal import Drupal9, Drupal9_multisite, Contentacms, Drupal9_govcms9, Drupal10
from project.elasticapm import Elastic_apm
from project.gatsby import Gatsby
from project.hugo import Hugo
from project.laravel import Laravel
from project.magento import Magento2ce
from project.pimcore import Pimcore
from project.laravel import Laravel
from project.magento import Magento2ce
from project.mattermost import Mattermost
from project.mautic import Mautic
from project.nextjs import Nextjs
from project.nuxtjs import Nuxtjs
from project.rails import Rails
from project.sculpin import Sculpin
from project.strapi import Strapi
from project.sylius import Sylius
from project.symfony import Symfony4, Symfony5
from project.typo3 import Typo3
from project.wordpress import Wordpress_composer, Wordpress_bedrock, Wordpress_woocommerce, Wordpress_vanilla
DOIT_CONFIG = {
"verbosity": 2,
}
# Blacklist of projects to ignore.
IGNORED = []
def project_factory(name):
'''Instantiate a project object. Class selection is based on the following naming convention:
Project class matches template directory name with the first letter capitalized.
laravel -> Laravel,
drupal7_vanilla -> Drupal7_vanilla.
The BaseProject class is used by default (class with the matching name is not imported)
'''
targetclass = name.capitalize().replace('-', '_')
try:
return globals()[targetclass](name)
except KeyError:
return BaseProject(name)
if ':' in sys.argv[1]:
ALL_PROJECTS = [project_factory(f.name) for f in os.scandir(TEMPLATEDIR)
if f.is_dir() and f.name not in IGNORED and f.name == sys.argv[1].split(':')[1]]
else:
ALL_PROJECTS = [project_factory(f.name) for f in os.scandir(TEMPLATEDIR)
if f.is_dir() and f.name not in IGNORED]
def task_cleanup():
"""
DoIt Task: Removes all generated files for a project.
Usage: doit cleanup:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'actions': project.cleanup,
}
def task_init():
"""
DoIt Task: Initializes a project directory so it can be built.
Usage: doit init:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'task_dep': ['cleanup:{0}'.format(project.name)],
'actions': project.init,
}
def task_update():
"""
DoIt Task: Updates the build repository from upstream sources.
Usage: doit update:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'actions': project.update,
}
def task_platformify():
"""
DoIt Task: Applies necessary changes to a project,
such as adding configuration files, applying patches, etc.
Usage: doit platformify:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'actions': project.platformify,
}
def task_branch():
"""
DoIt Task: Creates a new Git branch for pushing updates to the template repo.
Usage: doit branch:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'actions': project.branch,
}
def task_push():
"""
DoIt Task: Pushes a prepared branch to GitHub.
Usage: doit push:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'actions': project.push,
}
def task_rebuild():
"""
DoIt Task: Aggregates the update, platformify, and branch tasks for one-stop shopping.
Usage: doit rebuild:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'task_dep': ["{0}:{1}".format(action, project.name)
for action in ['update', 'platformify', 'branch']
],
'actions': [],
}
def task_full():
"""
DoIt Task: Aggregates the init, rebuild, and push tasks for one-stop shopping.
Usage: doit full:<project>
"""
for project in ALL_PROJECTS:
yield {
'name': project.name,
'task_dep': ["{0}:{1}".format(action, project.name)
for action in ['cleanup', 'init', 'update', 'platformify', 'branch', 'push']
],
'actions': [],
}