{"id":20495146,"url":"https://github.com/fmcorz/mdk","last_synced_at":"2025-03-31T11:06:46.167Z","repository":{"id":4242570,"uuid":"5367290","full_name":"FMCorz/mdk","owner":"FMCorz","description":"Moodle Development Kit. A collection of tools meant to make developers' lives easier.","archived":false,"fork":false,"pushed_at":"2024-04-22T08:12:48.000Z","size":1296,"stargazers_count":83,"open_issues_count":47,"forks_count":46,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-04-22T22:25:40.613Z","etag":null,"topics":["moodle","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FMCorz.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-08-10T09:23:53.000Z","updated_at":"2024-08-03T05:30:24.003Z","dependencies_parsed_at":"2023-11-16T04:28:00.793Z","dependency_job_id":"e277969e-9e43-4c81-8207-aa1b587960e2","html_url":"https://github.com/FMCorz/mdk","commit_stats":{"total_commits":664,"total_committers":26,"mean_commits":25.53846153846154,"dds":"0.37048192771084343","last_synced_commit":"5f0a0d5be8ccc74fc20d38ed21531a4fbb4475cd"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FMCorz%2Fmdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FMCorz%2Fmdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FMCorz%2Fmdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FMCorz%2Fmdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FMCorz","download_url":"https://codeload.github.com/FMCorz/mdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246457969,"owners_count":20780676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["moodle","python"],"created_at":"2024-11-15T17:44:46.087Z","updated_at":"2025-03-31T11:06:46.146Z","avatar_url":"https://github.com/FMCorz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Moodle Development Kit\n======================\n\nA collection of tools to make developers' lives easier.\n\nRequirements\n============\n\n- Linux or Mac OS\n- Python 3.6\n- MySQL, MariaDB or PostgreSQL\n- Git v1.7.7 or greater\n\nMost of the tools work on Moodle 1.9 onwards, but some CLI scripts required by MDK might not be available in all versions.\n\nUsage\n=====\n\nThe commands are called using that form::\n\n    mdk \u003ccommand\u003e \u003carguments\u003e\n\nGet some help on a command using::\n\n    mdk \u003ccommand\u003e --help\n\nAlso check the `wiki \u003chttps://github.com/FMCorz/mdk/wiki\u003e`_.\n\nDocker support\n==============\n\nAs at MDK 2.1, partial support for Moodle running in Docker is available. Some commands like ``phpunit``, ``upgrade``, ``run``, ``cron`` are run in the container. The ``behat`` command can also work but still requires some fiddling around. Other commands such as ``install`` will not work.\n\nSet the environment variable ``MDK_DOCKER_NAME`` to the name of the running container, or enable the config ``docker.automaticContainerLookup`` to let MDK look for a matching running container automatically.\n\nUsage examples::\n\n    # One command.\n    $ MDK_DOCKER_NAME=sm mdk phpunit\n\n    # Multiple commands.\n    $ set -x MDK_DOCKER_NAME sm\n    $ mdk run dev\n    $ mdk phpunit\n\n    # Enable automatic resolution.\n    $ mdk config set docker.automaticContainerLookup true\n\n    # With automatic resolution.\n    $ cd /path/to/sm\n    $ mdk phpunit\n\nCompatible containers\n---------------------\n\nThe Docker container must be created using `moodlehq/moodle-php-apache \u003chttps://github.com/moodlehq/moodle-php-apache\u003e`_, here is an example::\n\n    # Replace `sm` with the name of your instance.\n    set -x INSTANCE_NAME sm\n\n    # This computes the paths of the instance.\n    set -x MDK_INSTANCE_DIR (mdk info -v path $INSTANCE_NAME)\n    set -x MDK_STORAGE_DIR (mdk config show dirs.storage | python -c 'import sys, pathlib; print(pathlib.Path(sys.stdin.read()).expanduser().resolve(), end=\"\")')\n\n    # Create a Docker network called `moodle`.\n    docker network create moodle 2\u003e /dev/null\n\n    # Create and start the docker container, change the port, name and PHP version as needed.\n    docker run -d \\\n        --name $INSTANCE_NAME \\\n        --network moodle \\\n        -v $MDK_INSTANCE_DIR:/var/www/html \\\n        -v $MDK_STORAGE_DIR/$INSTANCE_NAME/moodledata:/var/www/moodledata \\\n        -v $MDK_STORAGE_DIR/$INSTANCE_NAME/extra/behat:/var/www/behatfaildumps \\\n        -p 8800:80 moodlehq/moodle-php-apache:8.1\n\nYou will want to create databases in the same network, and other services like selenium.\n\nPHP executable\n==============\n\nMDK can work with multiple PHP versions through Docker instances. This can cause conflicts in IDEs which refer to the host PHP executable. To correct this, you can reference ``mdk php`` as the PHP executable. And if the path to the PHP executable is required, create an executable as suggested `below \u003c#custom-php-executable\u003e`_.\n\nNote that ``mdk php`` must be called from within the Moodle instance directory tree.\n\nVScode settings\n---------------\n\n::\n\n    {\n        \"php.validate.executablePath\": \"/path/to/custom/executable/php-mdk\"\n        \"mdlcode.cli.phpPath\": \"mdk php\",\n    }\n\nCustom PHP executable\n---------------------\n\nOn Ubuntu, you could create the file ``php-mdk`` in ``~/.local/bin`` with the following content::\n\n    #!/bin/bash\n    mdk php $@\n\nThen make it executable::\n\n    chmod 0700 ~/.local/bin/php-mdk\n\n\nInstallation\n============\n\nPython package\n--------------\n\nOn Debian-based systems, install the following packages::\n\n    sudo apt-get install python-pip libmysqlclient-dev libpq-dev python-dev unixodbc-dev\n\nUse `pip \u003chttp://www.pip-installer.org/en/latest/installing.html\u003e`_::\n\n    pip install moodle-sdk --user\n    mdk init\n\nNotes\n^^^^^\n\nThis method does not require ``sudo`` as it installs MDK for the current user. It is assumed that ``~/.local/bin`` is in your PATH (or `equivalent \u003chttps://docs.python.org/3/library/site.html#site.USER_BASE\u003e`_).\n\nIf it isn't, this snippet for ``~/.profile`` might be useful::\n\n    # Set PATH so it includes user's private local bin if it exists.\n    if [ -d \"$HOME/.local/bin\" ] ; then\n        PATH=\"$HOME/.local/bin:$PATH\"\n    fi\n\nHomebrew\n--------\n\nUsing `Homebrew \u003chttp://brew.sh/\u003e`_, please refer to this `formula \u003chttps://github.com/danpoltawski/homebrew-mdk\u003e`_.\n\n\nFor development\n---------------\n\nClone the repository::\n\n    git clone https://github.com/FMCorz/mdk.git moodle-sdk\n\nOn Debian-based systems, you will need to install the following packages::\n\n    sudo apt-get install python-pip libmysqlclient-dev libpq-dev python-dev unixodbc-dev\n\nThen from the directory where you cloned the repository::\n\n    python setup.py develop --user\n    mdk init\n\n\nShell completion\n----------------\n\nFish completion\n^^^^^^^^^^^^^^^\n\nTo activate fish completion::\n\n    sudo ln -s /path/to/moodle-sdk/extra/fish_completion ~/config/fish/completions/mdk.fish\n\nBash completion\n^^^^^^^^^^^^^^^\n\nTo activate bash completion::\n\n    sudo ln -s /path/to/moodle-sdk/extra/bash_completion /etc/bash_completion.d/moodle-sdk\n\nTo activate goto commands (``gt`` and ``gtd``), add the following to ~/.bashrc::\n\n    if [ -f /path/to/moodle-sdk/extra/goto_instance ]; then\n        . /path/to/moodle-sdk/extra/goto_instance\n        . /path/to/moodle-sdk/extra/goto_instance.bash_completion\n    fi\n\n\nUpgrading\n=========\n\nIf you installed MDK using PIP, run the following command::\n\n    pip install --user --upgrade moodle-sdk\n\nIt 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::\n\n    mdk doctor --all\n\n\nCommand list\n============\n\n* `alias`_\n* `backport`_\n* `behat`_\n* `config`_\n* `create`_\n* `doctor`_\n* `fix`_\n* `info`_\n* `install`_\n* `php`_\n* `phpunit`_\n* `plugin`_\n* `precheck`_\n* `purge`_\n* `pull`_\n* `push`_\n* `rebase`_\n* `remove`_\n* `run`_\n* `tracker`_\n* `uninstall`_\n* `update`_\n* `upgrade`_\n\nalias\n-----\n\nSet up aliases of your Moodle commands.\n\n**Example**\n\nThis line defines the alias 'upall', for 'moodle update --all'\n\n::\n\n    mdk alias add upall \"update --all\"\n\nbackport\n--------\n\nBackport a branch to another instance of Moodle.\n\n**Examples**\n\nAssuming we are in a Moodle instance, this backports the current branch to the version 2.2 and 2.3\n\n::\n\n    mdk backport --version 22 23\n\nBackports the branch MDL-12345-23 from the instance stable_23 to the instance stable_22, and pushes the new branch to your remote\n\n::\n\n    mdk backport stable_23 --branch MDL-12345-23 --version 22 --push\n\n\nbehat\n-----\n\nGet the instance ready for acceptance testing (Behat), and run the test feature(s).\n\n**Examples**\n\n::\n\n    mdk behat -r --tags=@core_completion\n\n\ncreate\n------\n\nCreate a new instance of Moodle. It will be named according to your config file.\n\n**Examples**\n\nCreate a new instance of Moodle 2.1\n\n::\n\n    mdk create --version 21\n\nCreate an instance of Moodle 2.2 using PostgreSQL from the integration remote, and run the installation script.\n\n::\n\n    mdk create --version 22 --engine pgsql --integration --install\n\nconfig\n------\n\nSet your MDK settings from the command line.\n\n**Examples**\n\nShow the list of your settings\n\n::\n\n    mdk config list\n\nChange the value of the setting ``dirs.storage`` to ``/var/www/repositories``\n\n::\n\n    mdk config set dirs.storage /var/www/repositories\n\n\ndoctor\n------\n\nPerform some checks on the environment to identify possible problems, and attempt to fix them automatically.\n\n\nfix\n---\n\nCreate a branch from an issue number on the tracker (MDL-12345) and sets it to track the right branch.\n\n**Examples**\n\nIn a Moodle 2.2 instance, this will create (and checkout) a branch named MDL-12345-22 which will track upstream/MOODLE_22_STABLE.\n\n::\n\n    mdk fix MDL-12345\n    mdk fix 12345\n\n\ninfo\n----\n\nDisplay information about the instances on the system.\n\n**Examples**\n\nList the instances\n\n::\n\n    mdk info --list\n\nDisplay the information known about the instance *stable_main*\n\n::\n\n    mdk info stable_main\n\n\ninstall\n-------\n\nRun the command line installation script with all parameters set on an existing instance.\n\n**Examples**\n\n::\n\n    mdk install --engine mysqli stable_main\n\n\n\nphp\n---\n\nInvoke a PHP command in the context of the instance.\n\n**Examples**\n\n::\n\n    mdk php admin/cli/purge_caches.php\n\nphpunit\n-------\n\nGet the instance ready for PHPUnit tests, and run the test(s).\n\n**Examples**\n\n::\n\n    mdk phpunit -u repository/tests/repository_test.php\n\n\nplugin\n------\n\nLook for a plugin on moodle.org and downloads it into your instance.\n\n**Example**\n\n::\n\n    mdk plugin download repository_evernote\n\n\nprecheck\n--------\n\nPre-checks a patch on the CI server.\n\n**Example**\n\n::\n\n    mdk precheck\n\n\npurge\n-----\n\nPurge the cache.\n\n**Example**\n\nTo purge the cache of all the instances\n\n::\n\n    mdk purge --all\n\n\npull\n----\n\nPulls a patch using the information from a tracker issue.\n\n**Example**\n\nAssuming we type that command on a 2.3 instance, pulls the corresponding patch from the issue MDL-12345 in a testing branch\n\n::\n\n    mdk pull --testing 12345\n\n\npush\n----\n\nShortcut to push a branch to your remote.\n\n**Examples**\n\nPush the current branch to your repository\n\n::\n\n    mdk push\n\nForce a push of the branch MDL-12345-22 from the instance stable_22 to your remote\n\n::\n\n    mdk push --force --branch MDL-12345-22 stable_22\n\n\nrebase\n------\n\nFetch the latest branches from the upstream remote and rebase your local branches.\n\n**Examples**\n\nThis will rebase the branches MDL-12345-xx and MDL-56789-xx on the instances stable_22, stable_23 and stable_main. And push them to your remote if successful.\n\n::\n\n    mdk rebase --issues 12345 56789 --version 22 23 main --push\n    mdk rebase --issues MDL-12345 MDL-56789 --push stable_22 stable_23 stable_main\n\n\nremove\n------\n\nRemove an instance, deleting every thing including the database.\n\n**Example**\n\n::\n\n    mdk remove stable_main\n\n\nrun\n---\n\nExecute a script on an instance. The scripts are stored in the scripts directory.\n\n**Example**\n\nSet the instance stable_main ready for development\n\n::\n\n    mdk run dev stable_main\n\n\ntracker\n-------\n\nGets some information about the issue on the tracker.\n\n**Example**\n\n::\n\n    $ mdk tracker 34543\n    ------------------------------------------------------------------------\n      MDL-34543: New assignment module - Feedback file exists for an\n        assignment but not shown in the Feedback files picker\n      Bug - Critical - https://tracker.moodle.org/browse/MDL-34543\n      Closed (Fixed) 2012-08-17 07:25\n    -------------------------------------------------------[ V: 7 - W: 7 ]--\n    Reporter            : Paul Hague (paulhague) on 2012-07-26 08:30\n    Assignee            : Eric Merrill (emerrill)\n    Peer reviewer       : Damyon Wiese (damyon)\n    Integrator          : Dan Poltawski (poltawski)\n    Tester              : Tim Barker (timb)\n    ------------------------------------------------------------------------\n\n\nuninstall\n---------\n\nUninstall an instance: removes config file, drops the database, deletes dataroot content, ...\n\n\nupdate\n------\n\nFetch the latest stables branches from the upstream remote and pull the changes into the local stable branch.\n\n**Examples**\n\nThis updates the instances stable_22 and stable_23\n\n::\n\n    mdk update stable_22 stable_23\n\nThis updates all your integration instances and runs the upgrade script of Moodle.\n\n::\n\n    mdk update --integration --upgrade\n\n\nupgrade\n-------\n\nRun the upgrade script of your instance.\n\n**Examples**\n\nThe following runs an upgrade on your stable branches\n\n::\n\n    mdk upgrade --stable\n\nThis will run an update an each instance before performing the upgrade process\n\n::\n\n    mdk upgrade --all --update\n\nScripts\n=======\n\nYou 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.\n\n::\n\n    # From anywhere on the system\n    $ mdk run helloworld stable_main\n\n    # Is similar to typing the following command\n    $ cp /path/to/script/helloworld.php /path/to/moodle/instances/stable_main\n    $ cd /path/to/moodle/instances/stable_main\n    $ php helloworld.php\n\nScripts are very handy when it comes to performing more complexed tasks.\n\nShipped scripts\n---------------\n\nThe following scripts are available with MDK:\n\n* ``dev``: Changes a portion of Moodle settings to enable development mode\n* ``enrol``: Enrols users in any existing course\n* ``external_functions``: Refreshes the definitions of services and external functions\n* ``makecourse``: Creates a test course\n* ``mindev``: Minimalist set of development settings (performance friendly)\n* ``setup``: Setup for development by running a succession of other scripts\n* ``tokens``: Lists the webservice tokens\n* ``undev``: Reverts the changes made by ``dev`` and ``mindev``\n* ``users``: Creates a set of users\n* ``version``: Fixes downgrade version conflicts\n* ``webservices``: Does all the set up of webservices for you\n\nLicense\n=======\n\nLicensed under the `GNU GPL License \u003chttp://www.gnu.org/copyleft/gpl.html\u003e`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmcorz%2Fmdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffmcorz%2Fmdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmcorz%2Fmdk/lists"}