Updating change log
[mdk.git] / README.rst
1 Moodle Development Kit
2 ======================
3
4 A collection of tools meant to make developers' lives easier.
5
6 Requirements
7 ============
8
9 - Linux or Mac OS
10 - Python 2.7
11 - MySQL, MariaDB or PostgreSQL
12 - Git v1.7.7 or greater
13
14 Most of the tools work on Moodle 1.9 onwards, but some CLI scripts required by MDK might not be available in all versions.
15
16 Usage
17 =====
18
19 The commands are called using that form::
20
21 mdk <command> <arguments>
22
23 Get some help on a command using::
24
25 mdk <command> --help
26
27 Also check the `wiki <https://github.com/FMCorz/mdk/wiki>`_.
28
29 Installation
30 ============
31
32 Python package
33 --------------
34
35 You need the `pip <http://www.pip-installer.org/en/latest/installing.html>`_ to do this::
36
37 sudo pip install moodle-sdk
38 mdk init
39
40 That's it!
41
42 On Debian-based systems, you will probably need to install the following packages::
43
44 sudo apt-get install python-pip libmysqlclient-dev libpq-dev python-dev
45
46
47 Homebrew
48 --------
49
50 Using `Homebrew <http://brew.sh/>`_, please refer to this `formula <https://github.com/danpoltawski/homebrew-mdk>`_.
51
52
53 Git
54 ---
55
56 Clone the repository
57 ~~~~~~~~~~~~~~~~~~~~
58
59 ::
60
61 cd /opt
62 sudo git clone git://github.com/FMCorz/mdk.git moodle-sdk
63
64 Install the dependencies
65 ~~~~~~~~~~~~~~~~~~~~~~~~
66
67 You will need the tool `pip <http://www.pip-installer.org/en/latest/installing.html>`_ to install the packages required by Python.
68
69 ::
70
71 sudo pip install -r /opt/moodle-sdk/requirements.txt
72
73 On Debian-based systems, you will probably need to install the following packages::
74
75 sudo apt-get install python-pip libmysqlclient-dev libpq-dev python-dev
76
77 Make executable and accessible
78 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
80 ::
81
82 sudo chmod +x /opt/moodle-sdk/mdk.py
83 sudo ln -s /opt/moodle-sdk/mdk.py /usr/local/bin/mdk
84
85 Set up the basics
86 ~~~~~~~~~~~~~~~~~
87
88 Assuming that you are using Apache, which is set up to serve the files from /var/www, leave the default values as they are in ``mdk init``, except for your remote and the database passwords.
89
90 ::
91
92 mkdir ~/www
93 sudo ln -s ~/www /var/www/m
94 mdk init
95
96 You're all set.
97
98 Optional
99 ~~~~~~~~
100
101 To activate bash completion::
102
103 sudo ln -s /opt/moodle-sdk/extra/bash_completion /etc/bash_completion.d/moodle-sdk
104
105 To activate goto commands (``gt`` and ``gtd``), add the following to ~/.bashrc::
106
107 if [ -f /opt/moodle-sdk/extra/goto_instance ]; then
108 . /opt/moodle-sdk/extra/goto_instance
109 . /opt/moodle-sdk/extra/goto_instance.bash_completion
110 fi
111
112
113 Upgrading
114 =========
115
116 If you installed MDK using PIP, run the following command::
117
118 sudo pip install --upgrade moodle-sdk
119
120 It is possible that a new version of MDK requires new files, directories, etc... and while we try to make it easy to upgrade, it can happen that some features get broken in your environment. So after each upgrade, consider running the following to get more information::
121
122 mdk doctor --all
123
124
125 Command list
126 ============
127
128 alias
129 -----
130
131 Set up aliases of your Moodle commands.
132
133 **Example**
134
135 This line defines the alias 'upall', for 'moodle update --all'
136
137 ::
138
139 mdk alias add upall "update --all"
140
141 backport
142 --------
143
144 Backport a branch to another instance of Moodle.
145
146 **Examples**
147
148 Assuming we are in a Moodle instance, this backports the current branch to the version 2.2 and 2.3
149
150 ::
151
152 mdk backport --version 22 23
153
154 Backports the branch MDL-12345-23 from the instance stable_23 to the instance stable_22, and pushes the new branch to your remote
155
156 ::
157
158 mdk backport stable_23 --branch MDL-12345-23 --version 22 --push
159
160 backup
161 ------
162
163 Backup a whole instance so that it can be restored later.
164
165 **Examples**
166
167 Backup the instance named stable_master
168
169 ::
170
171 mdk backup stable_master
172
173 List the backups
174
175 ::
176
177 mdk backup --list
178
179 Restore the second backup of the instance stable_master
180
181 ::
182
183 mdk backup --restore stable_master_02
184
185
186 behat
187 -----
188
189 Get the instance ready for acceptance testing (Behat), and run the test feature(s).
190
191 **Examples**
192
193 ::
194
195 mdk behat -r --tags=@core_completion
196
197
198 create
199 ------
200
201 Create a new instance of Moodle. It will be named according to your config file.
202
203 **Examples**
204
205 Create a new instance of Moodle 2.1
206
207 ::
208
209 mdk create --version 21
210
211 Create an instance of Moodle 2.2 using PostgreSQL from the integration remote, and run the installation script.
212
213 ::
214
215 mdk create --version 22 --engine pgsql --integration --install
216
217 config
218 ------
219
220 Set your MDK settings from the command line.
221
222 **Examples**
223
224 Show the list of your settings
225
226 ::
227
228 mdk config list
229
230 Change the value of the setting ``dirs.storage`` to ``/var/www/repositories``
231
232 ::
233
234 mdk config set dirs.storage /var/www/repositories
235
236
237 css
238 ---
239
240 CSS related functions.
241
242 **Example**
243
244 Compile the LESS files from Bootstrapbase
245
246 ::
247
248 mdk css --compile
249
250
251 doctor
252 ------
253
254 Perform some checks on the environment to identify possible problems, and attempt to fix them automatically.
255
256
257 fix
258 ---
259
260 Create a branch from an issue number on the tracker (MDL-12345) and sets it to track the right branch.
261
262 **Examples**
263
264 In a Moodle 2.2 instance, this will create (and checkout) a branch named MDL-12345-22 which will track upstream/MOODLE_22_STABLE.
265
266 ::
267
268 mdk fix MDL-12345
269 mdk fix 12345
270
271
272 info
273 ----
274
275 Display information about the instances on the system.
276
277 **Examples**
278
279 List the instances
280
281 ::
282
283 mdk info --list
284
285 Display the information known about the instance *stable_master*
286
287 ::
288
289 mdk info stable_master
290
291
292 install
293 -------
294
295 Run the command line installation script with all parameters set on an existing instance.
296
297 **Examples**
298
299 ::
300
301 mdk install --engine mysqli stable_master
302
303
304 js
305 --
306
307 JS related functions.
308
309 **Example**
310
311 Compile the JS modules in Atto
312
313 ::
314
315 mdk js shift --plugin editor_atto
316
317
318 Generate the complete YUI API documentation
319
320 mdk js doc
321
322
323 phpunit
324 -------
325
326 Get the instance ready for PHPUnit tests, and run the test(s).
327
328 **Examples**
329
330 ::
331
332 mdk phpunit -u repository/tests/repository_test.php
333
334
335 plugin
336 ------
337
338 Look for a plugin on moodle.org and downloads it into your instance.
339
340 **Example**
341
342 ::
343
344 mdk plugin download repository_evernote
345
346
347 purge
348 -----
349
350 Purge the cache.
351
352 **Example**
353
354 To purge the cache of all the instances
355
356 ::
357
358 mdk purge --all
359
360
361 pull
362 ----
363
364 Pulls a patch using the information from a tracker issue.
365
366 **Example**
367
368 Assuming we type that command on a 2.3 instance, pulls the corresponding patch from the issue MDL-12345 in a testing branch
369
370 ::
371
372 mdk pull --testing 12345
373
374
375 push
376 ----
377
378 Shortcut to push a branch to your remote.
379
380 **Examples**
381
382 Push the current branch to your repository
383
384 ::
385
386 mdk push
387
388 Force a push of the branch MDL-12345-22 from the instance stable_22 to your remote
389
390 ::
391
392 mdk push --force --branch MDL-12345-22 stable_22
393
394
395 rebase
396 ------
397
398 Fetch the latest branches from the upstream remote and rebase your local branches.
399
400 **Examples**
401
402 This will rebase the branches MDL-12345-xx and MDL-56789-xx on the instances stable_22, stable_23 and stable_master. And push them to your remote if successful.
403
404 ::
405
406 mdk rebase --issues 12345 56789 --version 22 23 master --push
407 mdk rebase --issues MDL-12345 MDL-56789 --push stable_22 stable_23 stable_master
408
409
410 remove
411 ------
412
413 Remove an instance, deleting every thing including the database.
414
415 **Example**
416
417 ::
418
419 mdk remove stable_master
420
421
422 run
423 ---
424
425 Execute a script on an instance. The scripts are stored in the scripts directory.
426
427 **Example**
428
429 Set the instance stable_master ready for development
430
431 ::
432
433 mdk run dev stable_master
434
435
436 tracker
437 -------
438
439 Gets some information about the issue on the tracker.
440
441 **Example**
442
443 ::
444
445 $ mdk tracker 34543
446 ------------------------------------------------------------------------
447 MDL-34543: New assignment module - Feedback file exists for an
448 assignment but not shown in the Feedback files picker
449 Bug - Critical - https://tracker.moodle.org/browse/MDL-34543
450 Closed (Fixed) 2012-08-17 07:25
451 -------------------------------------------------------[ V: 7 - W: 7 ]--
452 Reporter : Paul Hague (paulhague) on 2012-07-26 08:30
453 Assignee : Eric Merrill (emerrill)
454 Peer reviewer : Damyon Wiese (damyon)
455 Integrator : Dan Poltawski (poltawski)
456 Tester : Tim Barker (timb)
457 ------------------------------------------------------------------------
458
459
460 uninstall
461 ---------
462
463 Uninstall an instance: removes config file, drops the database, deletes dataroot content, ...
464
465
466 update
467 ------
468
469 Fetch the latest stables branches from the upstream remote and pull the changes into the local stable branch.
470
471 **Examples**
472
473 This updates the instances stable_22 and stable_23
474
475 ::
476
477 mdk update stable_22 stable_23
478
479 This updates all your integration instances and runs the upgrade script of Moodle.
480
481 ::
482
483 mdk update --integration --upgrade
484
485
486 upgrade
487 -------
488
489 Run the upgrade script of your instance.
490
491 **Examples**
492
493 The following runs an upgrade on your stable branches
494
495 ::
496
497 mdk upgrade --stable
498
499 This will run an update an each instance before performing the upgrade process
500
501 ::
502
503 mdk upgrade --all --update
504
505 Scripts
506 =======
507
508 You can write custom scripts and execute them on your instances using the command ``mdk run``. MDK looks for the scripts in the *scripts* directories and identifies their type by reading their extension. For example, a script called 'helloworld.php' will be executed as a command line script from the root of an installation.
509
510 ::
511
512 # From anywhere on the system
513 $ mdk run helloworld stable_master
514
515 # Is similar to typing the following command
516 $ cp /path/to/script/helloworld.php /path/to/moodle/instances/stable_master
517 $ cd /path/to/moodle/instances/stable_master
518 $ php helloworld.php
519
520 Scripts are very handy when it comes to performing more complexed tasks.
521
522 Shipped scripts
523 ---------------
524
525 The following scripts are available with MDK:
526
527 * ``dev``: Changes a portion of Moodle settings to enable development mode
528 * ``enrol``: Enrols users in any existing course
529 * ``undev``: Reverts the changes made by ``dev``
530 * ``users``: Creates a set of users
531 * ``webservices``: Does all the set up of webservices for you
532
533 License
534 =======
535
536 Licensed under the `GNU GPL License <http://www.gnu.org/copyleft/gpl.html>`_