Skip to content

Commit 526407f

Browse files
authored
docs: minor refinements in readme (#9)
* docs: refining readme instructions + codetours * fix: patching xdist * fix: pyright warnings in codespace mode
1 parent 7a0a87c commit 526407f

File tree

35 files changed

+145
-157
lines changed

35 files changed

+145
-157
lines changed

.github/workflows/check-python.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
shell: bash
4949
run: |
5050
set -o pipefail
51-
poetry run pytest --junitxml=pytest-junit.xml -n auto
51+
poetry run pytest --junitxml=pytest-junit.xml
5252
5353
- name: Check generated templates have been reviewed
5454
shell: bash

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ examples/**/package-lock.json
175175
examples/**/poetry.lock
176176

177177
# playground folder for previewing templates
178-
.playground/*
178+
playground
179179

180180
# Misc
181181
examples/**/smart_contracts/artifacts

.vscode/clear.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Remove-Item -Recurse -Force .playground -ErrorAction Ignore
1+
Remove-Item -Recurse -Force playground -ErrorAction Ignore

.vscode/tasks.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"-v",
99
"init",
1010
"--name",
11-
".playground",
11+
"playground",
1212
"--no-git",
1313
"--defaults",
1414
"--UNSAFE-SECURITY-accept-template-url",
@@ -23,7 +23,7 @@
2323
"kind": "build",
2424
"isDefault": true
2525
},
26-
"dependsOn": ["Cleanup .playground folder"],
26+
"dependsOn": ["Cleanup playground folder"],
2727
"problemMatcher": []
2828
},
2929
{
@@ -33,7 +33,7 @@
3333
"-v",
3434
"init",
3535
"--name",
36-
".playground",
36+
"playground",
3737
"--no-git",
3838
"--defaults",
3939
"--UNSAFE-SECURITY-accept-template-url",
@@ -51,7 +51,7 @@
5151
"kind": "build",
5252
"isDefault": true
5353
},
54-
"dependsOn": ["Cleanup .playground folder"],
54+
"dependsOn": ["Cleanup playground folder"],
5555
"problemMatcher": []
5656
},
5757
{
@@ -61,7 +61,7 @@
6161
"-v",
6262
"init",
6363
"--name",
64-
".playground",
64+
"playground",
6565
"--no-git",
6666
"--UNSAFE-SECURITY-accept-template-url",
6767
"--template-url",
@@ -71,13 +71,13 @@
7171
"--no-bootstrap"
7272
],
7373
"type": "shell",
74-
"dependsOn": ["Cleanup .playground folder"],
74+
"dependsOn": ["Cleanup playground folder"],
7575
"problemMatcher": []
7676
},
7777
{
78-
"label": "Cleanup .playground folder",
78+
"label": "Cleanup playground folder",
7979
"command": "rm",
80-
"args": ["-rf", ".playground"],
80+
"args": ["-rf", "playground"],
8181
"type": "shell",
8282
"windows": {
8383
"command": "./.vscode/clear.ps1"

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repository is a template for creating new AlgoKit projects. It includes a b
1212
Ensure localnet is running by executing `algokit localnet reset`.
1313

1414
```bash
15-
poetry run pytest -n auto
15+
poetry run pytest
1616
```
1717

1818
This will regenerate the tests for default `starter` and `production` presets as well as default tests for `generators` available on the template.
@@ -22,20 +22,20 @@ This will regenerate the tests for default `starter` and `production` presets as
2222
### Manual
2323

2424
```bash
25-
poetry run copier copy . .playground --vcs-ref=HEAD --trust
25+
poetry run copier copy . playground --vcs-ref=HEAD --trust
2626
```
2727

28-
To generate a dummy project into the `.playground` folder. This is useful for testing the template to quickly preview the output of the template before testing via `pytest`.
28+
To generate a dummy project into the `playground` folder. This is useful for testing the template to quickly preview the output of the template before testing via `pytest`.
2929

3030
### Using VSCode Tasks
3131

3232
In VSCode IDE, you can find the tasks in the `.vscode/tasks.json` file. To run them:
3333

3434
1. Open the command palette (`Cmd+Shift+P` on macOS, `Ctrl+Shift+P` on Windows/Linux) and type `> Run Task`
3535
2. Select the task you want to run
36-
3. It will be generated for you under the .playground folder
36+
3. It will be generated for you under the playground folder
3737

38-
To cleanup the .playground folder run dedicated cleanup task.
38+
To cleanup the playground folder run dedicated cleanup task.
3939

4040
## Contributing
4141

examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportMissingModuleSource=false
12
from algopy import ARC4Contract, arc4
23

34

examples/generators/production_python_smart_contract_python/.tours/getting-started-with-your-algokit-project.tour

+5-10
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"line": 9
1414
},
1515
{
16-
"file": "smart_contracts/__main__.py",
17-
"description": "This is the main entry point for building your smart contracts. The default template includes a starter 'Hello World' contract that is deployed via the `algokit-utils` package (either `ts` or `py`, depending on your choice). To create a new smart contract, you can use the [`algokit generate`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) command and invoke a pre-bundled generator template by running `algokit generate smart-contract`. This action will create a new folder in the `smart_contracts` directory, named after your project. Each folder contains a `contract.py` file, which is the entry point for your contract implementation, and `deploy_config.py` | `deployConfig.ts` files (depending on the language chosen for the template), that perform the deployment of the contract.",
18-
"line": 26
16+
"file": ".algokit.toml",
17+
"description": "This is the main configuration file used by algokit-cli to manage the project. The default template includes a starter 'Hello World' contract that is deployed via the `algokit-utils` package (either `ts` or `py`, depending on your choice). To create a new smart contract, you can use the [`algokit generate`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) command and invoke a pre-bundled generator template by running `algokit generate smart-contract` (see how it is defined in the `.algokit.toml`, you can create your own generators if needed). This action will create a new folder in the `smart_contracts` directory, named after your project. Each folder contains a `contract.py` file, which is the entry point for your contract implementation, and `deploy_config.py` | `deployConfig.ts` files (depending on the language chosen for the template), that perform the deployment of the contract. Additionally you can define custom commands to run (similar to `npm` scripts), see definitions under `[project]` section in `.algokit.toml`.",
18+
"line": 1
1919
},
2020
{
2121
"file": "smart_contracts/hello_world/deploy_config.py",
22-
"description": "The default deployment scripts invoke a sample method on the starter contract that demonstrates how to interact with your deployed Algorand on-chain applications using the [`AlgoKit Typed Clients`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) feature.",
22+
"description": "The default deployment scripts invoke a sample method on the starter contract that demonstrates how to interact with your deployed Algorand on-chain applications using the [`AlgoKit Typed Clients`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) feature. The invocation if deploy is aliased in `.algokit.toml` file, allowing simple deployments via `algokit project deploy` command.",
2323
"line": 32
2424
},
2525
{
@@ -32,14 +32,9 @@
3232
"description": "Environment files are a crucial mechanism that allows you to set up the [`algokit deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md) feature to simplify deploying your contracts in CI/CD environments (please note we still recommend careful evaluation when it comes to deployment to MainNet). Clone the file and remove the `.template` suffix to apply the changes to deployment scripts and launch configurations. The network prefix `localnet|testnet|mainnet` is primarily optimized for `algokit deploy`. The order of loading the variables is `.env.{network}` < `.env`.",
3333
"line": 2
3434
},
35-
{
36-
"file": ".algokit.toml",
37-
"description": "This is the configuration file used by AlgoKit to determine version requirements, `algokit deploy` settings, and references to custom generators.",
38-
"line": 5
39-
},
4035
{
4136
"file": ".vscode/launch.json",
42-
"description": "Refer to the pre-bundled Visual Studio launch configurations, offering various options on how to execute the build and deployment of your smart contracts.",
37+
"description": "Refer to the pre-bundled Visual Studio launch configurations, offering various options on how to execute the build and deployment of your smart contracts. Alternatively execute `algokit project run` to see list of available custom commands.",
4338
"line": 5
4439
},
4540
{

examples/generators/production_python_smart_contract_python/README.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@ This project has been generated using AlgoKit. See below for default getting sta
99
- [Python 3.12](https://www.python.org/downloads/) or later
1010
- [Docker](https://www.docker.com/) (only required for LocalNet)
1111

12+
> For interactive tour over the codebase, download [vsls-contrib.codetour](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) extension for VS Code, then open the [`.codetour.json`](./.tours/getting-started-with-your-algokit-project.tour) file in code tour extension.
13+
1214
### Initial setup
1315

1416
1. Clone this repository locally
1517
2. Install pre-requisites:
1618
- Make sure to have [Docker](https://www.docker.com/) installed and running on your machine.
17-
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The recommended version is `1.7.3`. Ensure you can execute `algokit --version` and get `1.7.1` or later.
19+
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The recommended version is the latest available. Ensure you can execute `algokit --version` and get `2.0.0` or later.
1820
- Bootstrap your local environment; run `algokit bootstrap all` within this folder, which will:
1921
- Install `Poetry` - [Link](https://python-poetry.org/docs/#installation): The minimum required version is `^1.7`. Ensure you can execute `poetry -V` and get `1.2`+
2022
- Run `poetry install` in the root directory, which will set up a `.venv` folder with a Python virtual environment and also install all Python dependencies
2123
- Copy `.env.template` to `.env`
2224
- Run `algokit localnet start` to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you.
25+
- Run `algokit project bootstrap all` to install all project dependencies (unless executed during `algokit init`).
2326
3. Open the project and start debugging / developing via:
24-
- VS Code
27+
- Terminal
28+
1. Run `algokit project run build` to build all contracts in the project
29+
2. Run `algokit project deploy localnet` to deploy all contracts to the local Algorand network.
30+
- VS Code (Launch Configurations)
2531
1. Open the repository root in VS Code
2632
2. Install recommended extensions
2733
3. Hit F5 (or whatever you have debug mapped to) and it should start running with breakpoint debugging.
@@ -34,10 +40,6 @@ This project has been generated using AlgoKit. See below for default getting sta
3440
1. Open the repository root in the IDE
3541
2. It should automatically detect it's a Poetry project and set up a Python interpreter and virtual environment.
3642
3. Hit Shift+F10|Ctrl+R (or whatever you have debug mapped to) and it should start running with breakpoint debugging. Please note, JetBrains IDEs on Windows have a known bug that in some cases may prevent executing shell scripts as pre-launch tasks, for workarounds refer to [JetBrains forums](https://youtrack.jetbrains.com/issue/IDEA-277486/Shell-script-configuration-cannot-run-as-before-launch-task).
37-
- Other
38-
1. Open the repository root in your text editor of choice
39-
2. In a terminal run `poetry shell`
40-
3. Run `python -m smart_contracts` through your debugger of choice
4143

4244
### Subsequently
4345

@@ -50,6 +52,10 @@ This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-gith
5052

5153
> Please note, if you instantiated the project with --workspace flag in `algokit init` it will automatically attempt to move the contents of the `.github` folder to the root of the workspace.
5254
55+
### AlgoKit Workspaces
56+
57+
To define custom `algokit project run` commands refer to [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md). This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).
58+
5359
### Debugging Smart Contracts
5460

5561
This project is optimized to work with AlgoKit AVM Debugger extension. To activate it:
@@ -109,6 +115,6 @@ This project makes use of Algorand Python to build Algorand smart contracts. The
109115
- [mypy](https://mypy-lang.org/): Static type checker.
110116
- [pytest](https://docs.pytest.org/): Automated testing.
111117
- [pip-audit](https://pypi.org/project/pip-audit/): Tool for scanning Python environments for packages with known vulnerabilities.
112-
- [pre-commit](https://pre-commit.com/): A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run `pre-commit install` in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, use `pre-commit run --all-files`.
118+
- [pre-commit](https://pre-commit.com/): A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run `pre-commit install` in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, use `pre-commit run --all-files`.
113119
It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [.vscode](./.vscode) folder.
114120

examples/generators/production_python_smart_contract_python/smart_contracts/__main__.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
logger = logging.getLogger(__name__)
2121
logger.info("Loading .env")
2222
load_dotenv()
23+
load_dotenv(".env.localnet")
2324
root_path = Path(__file__).parent
2425

2526

examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/contract.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportMissingModuleSource=false
12
from algopy import ARC4Contract, arc4
23

34

examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportMissingModuleSource=false
12
from algopy import ARC4Contract, arc4
23

34

examples/generators/production_python_smart_contract_typescript/.tours/getting-started-with-your-algokit-project.tour

+5-15
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,23 @@
1313
"line": 9
1414
},
1515
{
16-
"file": "smart_contracts/__main__.py",
17-
"description": "This is the main entry point for building your smart contracts. The default template includes a starter 'Hello World' contract that is deployed via the `algokit-utils` package (either `ts` or `py`, depending on your choice). To create a new smart contract, you can use the [`algokit generate`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) command and invoke a pre-bundled generator template by running `algokit generate smart-contract`. This action will create a new folder in the `smart_contracts` directory, named after your project. Each folder contains a `contract.py` file, which is the entry point for your contract implementation, and `deploy_config.py` | `deployConfig.ts` files (depending on the language chosen for the template), that perform the deployment of the contract.",
18-
"line": 26
16+
"file": ".algokit.toml",
17+
"description": "This is the main configuration file used by algokit-cli to manage the project. The default template includes a starter 'Hello World' contract that is deployed via the `algokit-utils` package (either `ts` or `py`, depending on your choice). To create a new smart contract, you can use the [`algokit generate`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) command and invoke a pre-bundled generator template by running `algokit generate smart-contract` (see how it is defined in the `.algokit.toml`, you can create your own generators if needed). This action will create a new folder in the `smart_contracts` directory, named after your project. Each folder contains a `contract.py` file, which is the entry point for your contract implementation, and `deploy_config.py` | `deployConfig.ts` files (depending on the language chosen for the template), that perform the deployment of the contract. Additionally you can define custom commands to run (similar to `npm` scripts), see definitions under `[project]` section in `.algokit.toml`.",
18+
"line": 1
1919
},
2020
{
2121
"file": "smart_contracts/hello_world/deploy-config.ts",
22-
"description": "The default deployment scripts invoke a sample method on the starter contract that demonstrates how to interact with your deployed Algorand on-chain applications using the [`AlgoKit Typed Clients`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) feature.",
22+
"description": "The default deployment scripts invoke a sample method on the starter contract that demonstrates how to interact with your deployed Algorand on-chain applications using the [`AlgoKit Typed Clients`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) feature. The invocation if deploy is aliased in `.algokit.toml` file, allowing simple deployments via `algokit project deploy` command.",
2323
"line": 32
2424
},
25-
{
26-
"file": "tests/hello-world.spec.ts",
27-
"description": "If you opted to include unit tests, the default tests provided demonstrate an example of mocking, setting up fixtures, and testing smart contract calls on an AlgoKit typed client.",
28-
"line": 39
29-
},
3025
{
3126
"file": ".env.localnet.template",
3227
"description": "Environment files are a crucial mechanism that allows you to set up the [`algokit deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md) feature to simplify deploying your contracts in CI/CD environments (please note we still recommend careful evaluation when it comes to deployment to MainNet). Clone the file and remove the `.template` suffix to apply the changes to deployment scripts and launch configurations. The network prefix `localnet|testnet|mainnet` is primarily optimized for `algokit deploy`. The order of loading the variables is `.env.{network}` < `.env`.",
3328
"line": 2
3429
},
35-
{
36-
"file": ".algokit.toml",
37-
"description": "This is the configuration file used by AlgoKit to determine version requirements, `algokit deploy` settings, and references to custom generators.",
38-
"line": 5
39-
},
4030
{
4131
"file": ".vscode/launch.json",
42-
"description": "Refer to the pre-bundled Visual Studio launch configurations, offering various options on how to execute the build and deployment of your smart contracts.",
32+
"description": "Refer to the pre-bundled Visual Studio launch configurations, offering various options on how to execute the build and deployment of your smart contracts. Alternatively execute `algokit project run` to see list of available custom commands.",
4333
"line": 5
4434
},
4535
{

0 commit comments

Comments
 (0)