This repository serves as a "starter" repository for creating a new block.
- Using the command line, navigate to your nio project's blocks folder:
cd nio/projects/<project_name>/blocks git clone --depth=1 https://github.com/nio-blocks/block_template.git <new_block_name>- Navigate into the new block folder:
cd <new_block_name>
- Rename
example_block.pyto whatever your block name will be. - In your new block Python file, rename the
Exampleclass to the new block's name. Avoid puttingBlockin the class name, this is implied of the filename which should end in_block.py - Rename
test_example_block.pyto match your new block's class name. - Rename
BLOCK_README.mdtoREADME.md(mv BLOCK_README.md README.md) and update the documentation accordingly.
- Create a new GitHub repository, often this will have the same name as
<new_block_name>, and copy the URL - Your new block will no longer track the template:
git remote remove origin - Stage your new files:
git add -A - Take ownership:
git commit --amend --reset-author -m "Inital Commit" - Set up your block to track your remote repository:
git remote add origin <new_repo_url> - Push your work to a branch (usually
master):git push --set-upstream origin master
- example_block.py : This is the block code. Additional Python classes and files are definitely welcome. If the file contains a Block class, make sure the filename ends with
_block.py. If the file represents a Base Block that is not discoverable by itself, have the filename end with_base.py. - requirements.txt : List out any Python dependencies this block requires. This file will be installed by pip when the block is installed. The command for installing the dependencies is
pip install -r requirements.txt. - spec.json : Define the specification for a block, this is the metadata which is used for block discovery.
- release.json : The release data for one or more blocks.
- tests/test_example_block.py : Always submit accompanying unit tests in the
testsfolder. - requirements.txt : List out any Python dependencies this block requires. This file will be installed by pip when the block is installed. The command for installing the dependencies is
pip install -r requirements.txt.