Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template deprecation #14

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# AlgoKit Playground Template

---
# DEPRECATED
This template has been deprecated. Beaker for Algorand Smart Contract development is no longer supported. Please use Algorand Python instead. The Algorand Python template can be found at https://github.com/algorandfoundation/algokit-python-template.

## Introduction

This template provides a good starting point to quickly play with writing, building and deploying/calling Beaker and PyTEAL contracts.

This is one of the default templates used by AlgoKit to initialise an Algorand smart contract project. It's a [Copier template](https://copier.readthedocs.io/en/stable/).
Expand Down
18 changes: 18 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
_subdirectory: template_content

use_deprecated_template:
type: bool
help: |
WARNING: This template has been deprecated. Beaker for Algorand Smart Contract development is no longer supported.
Please use Algorand Python instead. The Algorand Python template can be found at https://github.com/algorandfoundation/algokit-python-template
Do you still want to proceed with using the deprecated template?
default: no

_tasks:
- '"{{ python_path if python_path else _copier_python }}" post_init.py {{ use_deprecated_template }} {{ use_workspace }}'

# Auto determined by algokit-cli from v1.11.3 to allow execution of python script
# in binary mode.
python_path:
type: str
help: Path to the sys.executable.
when: false

# The following should never get prompted; algokit should always pass these values through by convention

algod_token:
Expand Down
1,745 changes: 930 additions & 815 deletions poetry.lock

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions template_content/post_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import shutil
import sys
from pathlib import Path
import os


def main():
# Get the use_deprecated_template argument
use_deprecated_template = sys.argv[1].lower() in ("true", "yes", "1", "t", "y")
use_workspace = sys.argv[2].lower() in ("true", "yes", "1", "t", "y")

if not use_deprecated_template:
# Get the parent directory of this script which should be the generated project root
project_dir = Path(__file__).parent
project_dir = project_dir.parent.parent if use_workspace else project_dir

# Print warning
print("WARNING: Template generation cancelled!\n")
print(
"This template is deprecated. Use Algorand Python instead: https://github.com/algorandfoundation/algokit-python-template\n"
)

if project_dir.exists():
try:
os.chdir(project_dir.parent)
shutil.rmtree(project_dir)
except Exception as e:
print(
f"Failed to clean up {project_dir}. You will have to manually delete the project folder. Error: {str(e)}",
file=sys.stderr,
)

sys.exit(1)

# If we get here, template was approved to be used
print("Proceeding with deprecated template generation...")


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ def run_init(
return result


@pytest.mark.skip(reason="This test is deprecated since the template is deprecated")
def test_default_parameters(working_dir: Path) -> None:
response = run_init(working_dir, "test_default_parameters")

assert response.returncode == 0


def test_template_fail(working_dir: Path) -> None:
response = run_init(working_dir, "test_template_fail")

assert response.returncode == 1
22 changes: 22 additions & 0 deletions tests_generated/test_template_fail/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# test_template_fail

Welcome to your new AlgoKit project!

This is your workspace root. A `workspace` in AlgoKit is an orchestrated collection of standalone projects (backends, smart contracts, frontend apps and etc).

By default, `projects_root_path` parameter is set to `projects`. Which instructs AlgoKit CLI to create a new directory under `projects` directory when new project is instantiated via `algokit init` at the root of the workspace.

## Getting Started

To get started refer to `README.md` files in respective sub-projects in the `projects` directory.

To learn more about algokit, visit [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/algokit.md).

### GitHub Codespaces

To get started execute:

1. `algokit generate devcontainer` - invoking this command from the root of this repository will create a `devcontainer.json` file with all the configuration needed to run this project in a GitHub codespace. [Run the repository inside a codespace](https://docs.github.com/en/codespaces/getting-started/quickstart) to get started.
2. `algokit init` - invoke this command inside a github codespace to launch an interactive wizard to guide you through the process of creating a new AlgoKit project

Powered by [Copier templates](https://copier.readthedocs.io/en/stable/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"folders": [
{
"path": "./",
"name": "ROOT"
}
],
"settings": {
"files.exclude": {
"projects/": true
},
"jest.disabledWorkspaceFolders": ["ROOT", "projects"]
},
"extensions": {
"recommendations": ["joshx.workspace-terminals"]
},
"tasks": {
"version": "2.0.0",
"tasks": []
},
"launch": {
"configurations": []
}
}
Loading