Skip to content

Commit

Permalink
feat: init wizard v2 improvements (#25)
Browse files Browse the repository at this point in the history
* chore: wip

* chore: test

* chore: test

* chore: test

* chore: test

* chore: test

* chore: test

* chore: wip

* chore: minor tweaks

* chore: removing default answers

* refactor: tests structure

* chore: using algokit from preview branch

* chore: refining preset question

* chore: minor refinements

* chore: minor tweaks

* chore: minor tweaks in copier

* chore: remove zendesk yamls; refine tests

* refactor: addressing pr comments

* chore: patching ci

* chore: defaulting vscode answer to yes

* chore: refining ci dependencies

* chore: fixing aiohttp 3.12 compatibility

* chore: removing explicit pin on aiohttp
  • Loading branch information
aorumbayev authored Feb 26, 2024
1 parent b1cd177 commit 3981e53
Show file tree
Hide file tree
Showing 308 changed files with 4,075 additions and 602 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
needs: ci-check-python
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Tag release
id: tag
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ jobs:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Install algokit
run: pipx install algokit
run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/init_wizard_v2 --force

- name: Set up Python 3.10
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
cache: 'poetry'

- name: Install dependencies
Expand Down Expand Up @@ -51,6 +51,6 @@ jobs:
shell: bash
run: |
# Add untracked files as empty so they come up in diff
git add -N ./tests_generated
git add -N ./examples
# Look for changes in generated templates and error if there are any
git diff --exit-code --minimal ./tests_generated ':(exclude)package-lock.json'
git diff --exit-code --minimal ./examples ':(exclude)package-lock.json'
12 changes: 0 additions & 12 deletions .github/workflows/issue_closed.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/issue_commented.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/issue_labelled.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/zendesk_github_add_comment.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/zendesk_github_close_issue.yml

This file was deleted.

9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,10 @@ cython_debug/
# NPM
node_modules

# Ignore package-lock.json in all directories and subdirectories under tests_generated
tests_generated/*/package-lock.json
# Ignore lockfiles in all directories and subdirectories under examples, recursively
examples/**/package-lock.json
examples/**/poetry.lock

# playground folder for previewing templates
.playground/*
!.playground/.gitkeep
Empty file added .playground/.gitkeep
Empty file.
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# AlgoKit Official Template for contributors

This repository is a template for creating new AlgoKit projects. It includes a basic structure for creating a front end project.

## Pre-requisites

`poetry install` - Install the dependencies for the project.

## Testing

```bash
poetry run pytest
```

This will regenerate the tests for default `starter` and `production` presets as well as default tests for `generators` available on the template.

## Development

```bash
poetry run copier copy . .playground/{some_dummy_folder_name} --vcs-ref=HEAD --trust
```

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`.

## Contributing

### Commits

We are using the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) standard for commit messages. This allows us to automatically generate release notes and version numbers. We do this via [Python Semantic Release](https://python-semantic-release.readthedocs.io/en/latest/) and [GitHub actions](.github/workflows/cd.yaml).

### Guiding Principles

AlgoKit development is done within the [AlgoKit Guiding Principles](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/algokit.md#guiding-principles).

### Pull Requests

1. Submit a pull request to the `main` branch. Fork the repo if you are an external contributor.
2. Ensure that the pull request is up to date with the `main` branch.
3. Ensure that the pull request has a clear title and description.
4. Pass PR reviews and wait for approval.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a target="_blank" href="https://github.com/algorandfoundation/algokit-cli"><img src="https://img.shields.io/badge/docs-repository-00dc94?logo=github&style=flat.svg" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://img.shields.io/badge/learn-AlgoKit-00dc94?logo=algorand&mac=flat.svg" /></a>
<a target="_blank" href="https://github.com/algorandfoundation/algokit-react-frontend-template"><img src="https://img.shields.io/github/stars/algorandfoundation/algokit-react-frontend-template?color=00dc94&logo=star&style=flat" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://vbr.wocr.tk/badge?page_id=algorandfoundation%2Falgokit-react-frontend-template&color=%2300dc94&style=flat" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Falgorandfoundation%2Falgokit-react-frontend-template&countColor=%2300dc94&style=flat" /></a>
</p>

---
Expand All @@ -30,6 +30,20 @@ This template supports the following features:
- Dotenv support for environment variables, as well as a local only KMD provider that can be used for connecting the frontend component to an `algokit localnet` instance (docker required).
- CI/CD pipeline using GitHub Actions (Vercel or Netlify for hosting)

# Getting started
## Getting started

Once the template is instantiated you can follow the [README.md](template_content/README.md.jinja) file to see instructions for how to use the template.

### Interactive Wizard

**To initialize using the `algokit` CLI**:

- Execute the command `algokit init`. This initiates an interactive wizard that assists in selecting the most appropriate template for your project requirements.

**To initialize within GitHub Codespaces**:

- Follow these steps to leverage GitHub Codespaces for template selection:

1. Go to the [algokit-base-template](https://github.com/algorandfoundation/algokit-base-template) repository.
2. Initiate a new codespace by selecting the `Create codespace on main` option. This can be found by clicking the `Code` button, then navigating to the `Codespaces` tab.
3. Upon codespace preparation, `algokit` will automatically start `LocalNet` and present a prompt with the next steps. Executing `algokit init` will initiate the interactive wizard.
70 changes: 27 additions & 43 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_subdirectory: template_content
_templates_suffix: '.jinja'

# questions
# project_name should never get prompted, AlgoKit should always pass it by convention
Expand All @@ -17,47 +18,62 @@ author_email:
help: Package author email
placeholder: '[email protected]'

preset_name:
type: str
help: Name of the template preset to use.
choices:
'Starter - for a simpler starting point ideal for prototyping': 'starter'
'Production - for confidently deploying to MainNet and/or more complex projects': 'production'
'Custom - for tailoring the template output to your needs': 'custom'
default: 'starter'

ide_vscode:
type: bool
help: Do you want to add VSCode configuration?
when: "{{ preset_name == 'custom' }}"
default: yes

ide_jetbrains:
type: bool
help: Do you want to add JetBrains configuration (primarily optimized for WebStorm)?
when: '{{ ide_vscode == false }}'
default: no
when: "{{ preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

use_eslint_prettier:
type: bool
help: Do you want to use ESLint and Prettier for code linting and formatting?
default: yes
when: "{{ preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

use_tailwind:
type: bool
help: Do you want to use Tailwind CSS? A utility-first CSS framework for rapidly building custom designs.
default: yes
when: "{{ preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

use_daisy_ui:
type: bool
help: Do you want to use a daisyUI? Framework agnostic CSS component library for building modern websites and web applications fast.
default: yes
when: '{{ use_tailwind != false }}'
help: Do you want to use daisyUI? Framework agnostic CSS component library for building modern websites and web applications fast.
when: "{{ use_tailwind != false and preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

use_jest:
type: bool
help: Do you want to include unit tests (via Jest)?
default: yes
when: "{{ preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

use_playwright:
type: bool
help: Do you want to include end to end tests (via Playwright)?
default: yes
when: "{{ preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

use_github_actions:
type: bool
help: Do you want to include Github Actions workflows for build validation?
default: yes
when: "{{ preset_name == 'custom' }}"
default: "{{ 'yes' if preset_name == 'production' else 'no' }}"

cloud_provider:
type: str
Expand All @@ -67,36 +83,4 @@ cloud_provider:
Netlify: 'netlify'
Vercel: 'vercel'
Skip CD setup: 'none'
default: 'netlify'

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

algod_token:
type: str
help: Default Algod Token
default: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

algod_server:
type: str
help: Default Algod server
default: 'http://localhost'

algod_port:
type: int
help: Default Algod port
default: 4001

indexer_token:
type: str
help: Default Indexer token
default: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

indexer_server:
type: str
help: Default Indexer server
default: 'http://localhost'

indexer_port:
type: int
help: Default Indexer port
default: 8980
default: "{{ 'netlify' if preset_name == 'production' else 'none' }}"
Empty file added examples/.gitkeep
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions examples/cloud_provider/production_react_netlify/.algokit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[algokit]
min_version = "v1.3.0b1"

[generate.import_contract]
description = "Import a typed client from your smart contracts project"
path = ".algokit/generators/import_contract"

[project]
type = "frontend"
name = "production_react_netlify"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: <commit>
_src_path: <src>
author_email: None
author_name: None
cloud_provider: netlify
preset_name: production
project_name: production_react_netlify

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Check code base

on:
workflow_call:
inputs:
run-build:
required: false
type: boolean
default: false
push:
branches:
- main

jobs:
checks:
runs-on: 'ubuntu-latest'
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm ci

- name: Run linters
run: npm run lint

- name: Run unit tests
run: npm run test

- name: Create placeholder .env file
if: ${{ inputs.run-build }}
uses: makerxstudio/shared-config/.github/actions/env-to-placeholders@main
with:
env-output-path: './.env'
env-template-path: './.env.template'
env-variable-prefix: VITE_

- name: Build
if: ${{ inputs.run-build }}
run: npm run build

- name: Archive
if: ${{ inputs.run-build }}
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# test_all_default_parameters_on_vercel
# production_react_netlify

This starter React project has been generated using AlgoKit. See below for default getting started instructions.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test_all_default_parameters_on_vercel",
"name": "production_react_netlify",
"version": "0.1.0",
"author": {
"name": "None",
Expand Down
Loading

0 comments on commit 3981e53

Please sign in to comment.