Developing Packages for the Master Project
Initializing Development Environment
We've recently created a development environment named main
for master
project in the previous step. Let’s start
initializing it by typing meco
command with development flag, like so;
# meco-init
meco -de main
By executing the command above we initialized master
project with the development environment named main
.
In the displayed information you can see that a new section has been added named DEVELOPMENT
. This section informs
you about the environment, which has been set based on the packages in your development environment.
There is an important difference between the environment when we initialized only master
project, and the environment
when we initialized our development environment along with it. Take a look at the DEVELOPMENT
section of the
displayed information. You can see the name of the packages available in our development environment. These packages
are also existed in the master project environment, yet they did not get initialized from their respective location
at all. This is because packages in development environment have priorities over those packages in project environment.
Using Existing Packages
All we have to do is to copy the package that we want to work on into our development environment. We can also clone any package from a repositories. We can give the following example as an illustration of such process.
Firstly lets navigate to the active development environment. In order to do this we can run the following command.
mmeco-cd-dev
We can now clone a repo directly in to the development environment like so;
git clone <PATH>repo.git
Creating a New Package
Meco™ provides mmecopackage-create
command, which we use in order to create a new package. Let's create our first new
package by typing the following command;
mmecopackage-create aDisplayMessage
Upon successful execution a message like the one below will be displayed.
Package has been created: /<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage
What Actually is a Package?
Meco Ecosystem™ uses packages to provide scripts, plug-ins, applications and more. A package essentially is a folder structure, which contains source code, additional files and images, that builds the production environment.
However, with the provided comprehensive Meco™ Package API, a package in Meco Ecosystem™ is more than a folder structure. You can customize packages, the way it would fit in your production pipeline and operate on them easily. Transitioning a tool, plug-in or application from one system to Meco™, or other way around is straightforward since Meco Ecosystem™ uses environment variables to operate. Please check Packaging section for more information.
Re-Initializing the Development Environment
As expected Meco™ will not recognize a package, if it wasn’t in the development environment by the time the development environment is initialized, whether you created or cloned it from a repository. Therefore, we have to re-initialize the development environment to get our brand-new package initialized.
After you terminate the environment as it's explained in the bottom of Initializing Master Project page you can run the same command to initialize the development environment, like so;
meco -de main
You can now see in the DEVELOPMENT
section of the displayed information that our package aDisplayMessage
is initialized.
----------------------------------------------------------------------------------------------------
DEVELOPMENT
----------------------------------------------------------------------------------------------------
aDisplayMessage > /<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage
DYLD_FALLBACK_LIBRARY_PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/lib/darwin
PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/bin/darwin
PYTHONPATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/python
Please note: Re-initialization of a development environment is only required when a new package created or its folder structure is changed.
Creating Python Modules
Meco™ navigates to root of the development environment once we initialize one. We can type the following command to change directory to root of our package.
cd aDisplayMessage
Once we are in the root of the package we can use the following command to create a Python module for it.
mmecopackage-create-python-module displayMessage
Upon creation of the Python modules a message like the one below is displayed.
Created Python modules (Existing modules are untouched):
/<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/python/aDisplayMessage/displayMessage.py
/<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/python/aDisplayMessage/tests/displayMessageTest.py
Done.
As you can see, along with the module we've created, another module has also been created for unit test implementations (TDD rocks!).
Open the following Python module in your favourite editor.
/<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/python/aDisplayMessage/displayMessage.py
Let's create the following functions.
import sys
def displayProject():
return 'Hello from Master Project'
def display():
sys.stdout.write(displayProject())
After you implement the functions above run the following command on the terminal, where we initialized the development environment.
python -c "import aDisplayMessage.displayMessage;aDisplayMessage.displayMessage.display();"
Now you can see the printed message:
Hello from Master Project
Test Driven Development
Meco™ allows you to do work with TDD out of the box thanks to its architecture and implementations. Even thought we started writing code instead of a test first in this tutorial, we can implement a test now to illustrate how we can use provided command to run our tests.
Open the following Python module in your editor.
/<PATH>/meco/master/developers/<USER_NAME>/development/main/aDisplayMessage/python/aDisplayMessage/tests/displayMessageTest.py
You can see the module already has a unit test class implementation for you to use as a mockup. Let's replace the entire class with the one below.
import unittest
import aDisplayMessage.displayMessage
class Test(unittest.TestCase):
def test_displayProject(self):
self.assertEqual(aDisplayMessage.displayMessage.displayProject(), 'Hello from Master Project')
Go to terminal/PowerShell window after you save the changes. You must still be in the root of our package. Run the following command if not;
mmeco-cd-dev; cd aDisplayMessage;
Now we can run the unit test we just implemented by executing the following command.
mmecopackage-run-unittest
We’ll see a similar message like the one below since we expected no error, and our test passed.
aDisplayMessage.tests.displayMessageTest.Test 1 Tests
Success.
Initializing Other Developer's Development Environments
Meco™ allows you to initialize development environments of other developers, so you can collaborate with your colleagues in your development work.
In order to initialize a development environment of another developer just provide the developer flag to the command, like so;
meco -d wade -de main
Please note: developer flag -d
must be provided before development -de
flag. Values of these flags are
auto-completed as well.
Execute the command, and you can now see that you initialized the master project with a development environment named
main
that belongs to developer named wade
. Inspect the displayed messages to get a feeling of the architecture.