Skip to content

feat: dynamic template lists by fetching them from registry url#111

Merged
beeman merged 1 commit intomainfrom
beeman/template-registry
Aug 4, 2025
Merged

feat: dynamic template lists by fetching them from registry url#111
beeman merged 1 commit intomainfrom
beeman/template-registry

Conversation

@beeman
Copy link
Collaborator

@beeman beeman commented Feb 27, 2025

This PR changes the way how templates are handled by this CLI.

Currently, we have 6 hard-coded templates in this CLI. If we want to add a new template, we need to:

  • we create a new template in its own repo
  • ship an update to the CLI that includes that template
  • manually ensure the template is kept in sync, is tested, etc.

By moving the CLI to work with a template registry, we get a few benefits:

  • we create a new template in the registry
  • we don't have to update the CLI but instead it will fetch the registry and list what's there
  • we can have scripts that ensure templates are kept in sync, we can do tests for all templates at once.

frankykevin

This comment was marked as spam.

@beeman beeman force-pushed the beeman/template-registry branch from 03eb536 to 65330fa Compare June 6, 2025 15:01
@beeman beeman force-pushed the beeman/template-registry branch from 65330fa to 7919ae9 Compare June 16, 2025 22:19
@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2025

⚠️ No Changeset found

Latest commit: fd9c28c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@beeman beeman force-pushed the beeman/template-registry branch from 7919ae9 to fd9c28c Compare July 13, 2025 18:47
@beeman beeman force-pushed the beeman/template-registry branch 5 times, most recently from ef63acc to 7b5dfea Compare August 1, 2025 18:42
@beeman beeman marked this pull request as ready for review August 1, 2025 18:43
@beeman beeman force-pushed the beeman/template-registry branch from 7b5dfea to 24bb466 Compare August 1, 2025 18:45
@beeman beeman changed the title feat: add support for a template registry feat: dynamic template lists by fetching them from registry url Aug 1, 2025
Copy link
Collaborator Author

@beeman beeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I annotated the changes here.

gill-react-vite-tailwind-basic,
gill-react-vite-tailwind-counter,
template: [
# TODO: Make these values dynamic by adding a parameter to CLI
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow up I'll update this test and make it similar to how it works here but instead of a hardcoded templates.json I'll add an option to create-solana-dapp to generate this list based on the templates from the registry url.

},
"packageManager": "pnpm@10.5.2",
"dependencies": {
"@beeman/repokit": "0.0.0-canary-20250801172233",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We depend on repokit for fetching and parsing the template.json file.

This will make it easier to iterate over the data structures and helpers (in repokit) without having to maintain a copy of similar logic here.

templates: Template[]
}

export const frameworks: Framework[] = [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept of frameworks is gone as it no longer covers what it stands for.

The CLI now asks you to Select a group instead of Select a framework, before asking you to Select a template..

The structure of these groups and the templates is now defined as the "menu config" in src/utils/get-menu-config.ts

repository: string
}

export function findTemplate(name: string): Template {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to src/utils/find-template.ts, and now takes templates as a property instead of taking it from the global scope.

if (!args.template.repository) {
taskFail('No template repository specified')
if (!args.template.id) {
taskFail('No template id specified')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'template.id' is what we pass into giget (gh:owner/repo/path/to/template).

return [
{
description: 'A React framework by Vercel',
groups: ['templates', 'legacy', 'gill', 'web3js'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We look in any of these groups...

description: 'A React framework by Vercel',
groups: ['templates', 'legacy', 'gill', 'web3js'],
id: 'next',
keywords: ['nextjs'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and take the templates with these keywords.

},
{
description: 'React with Vite and React Router',
groups: ['templates', 'legacy', 'gill', 'web3js'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple groups: it will look in all of these groups.

description: 'React with Vite and React Router',
groups: ['templates', 'legacy', 'gill', 'web3js'],
id: 'react-vite',
keywords: ['react', 'vite'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple keywords: it will only return templates that have all of these keywords.

import { TemplateJsonTemplate } from '@beeman/repokit'
import { log } from '@clack/prompts'

export function listTemplates({ templates }: { templates: TemplateJsonTemplate[] }) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function used to live in src/templates/templates.ts and iterated over the templates array that was defined globally.

@beeman beeman force-pushed the beeman/template-registry branch from 24bb466 to da8c197 Compare August 2, 2025 22:01
@beeman beeman merged commit bd604d3 into main Aug 4, 2025
99 checks passed
@beeman beeman deleted the beeman/template-registry branch August 4, 2025 16:34
@github-actions github-actions bot mentioned this pull request Aug 4, 2025
Dargon789 added a commit to Dargon789/create-solana-dapp that referenced this pull request Jan 14, 2026
* feat: add message to final note to install dependencies with skip install arg

* refactor: remove dummy test

* refactor: create helper to fetch package.json path from target dir

* feat: added changeset

* feat: pr build and test

* fix: pnpm version

* ci: scaffold publish

* ci: temp run on pr

* chore: update action version

* feat: publish

* docs: update the README to show different package managers and include @latest tag

* feat: rename template name based on package.json name property

* docs: update maintainers

* ci: remove old ci workflow

* refactor: update framework descriptions

* chore: add more examples to csd.sh

* chore: enable gill-next-tailwind-basic and gill-next-tailwind-counter templates

* refactor: clean up init script version check

* feat: add bun support

* refactor: clean up init script utils

* Version Packages (solana-foundation#158)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: remove 'concurrency' parameter from build-step-decider

* fix: move publish-canary-releases script to .github/workflows

* Version Packages (solana-foundation#163)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: add build step to publish-packages workflow

* Version Packages (solana-foundation#165)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: enable e2e-test for gill-next-tailwind-basic and gill-next-tailwind-counter

* fix: add build step before publish-packages in canary workflow

* chore: enable template-react-vite-tailwind-{basic,counter} template

* Version Packages (solana-foundation#169)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: gracefully handle git commits with no configured name and email

* chore: add Dockerfile for running ephemeral dev containers

* docs: add bun command to readme (solana-foundation#176)

Thanks!

* fix: update picocolors import to resolve SyntaxError in ESM module

* refactor: don't show the start script if instructions are provided

* feat: add Solana Mobile templates

* chore: add changeset

* Version Packages (solana-foundation#173)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: tip alert in README (solana-foundation#182)

* chore: apply automated updates

* chore: don't run e2e tests when Markdown files are changed

* feat: add update notifier and skip version check option

* chore: rename github org solana-developers -> solana-foundation

* Version Packages (solana-foundation#186)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: remove autofix github workflow script (solana-foundation#188)

* chore: remove autofix github workflow script

* fix: tip alert in README

* fix: tip alert in README

* feat: dynamic template lists by fetching them from registry url (solana-foundation#111)

* Version Packages (solana-foundation#190)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: add list-template-ids option

* chore: use list-template-ids to dynamically populate template list

* chore: run e2e test nightly and with dispatch

* chore: update dependencies

* chore: add eslint-plugin-sort and eslint-plugin-prettier

* chore: add lefthook to automate linting/formatting

* fix: file/folder renaming and content replacement in init script (solana-foundation#196)

* fix: fully support file/folder renaming and content replacement in init script

* chore: remove extra underscrore

* fix: logging and avoid inline if-statements

* Revert "fix: file/folder renaming and content replacement in init script (solana-foundation#196)" (solana-foundation#203)

This reverts commit 096f365.

* chore: publish PRs to pkg.pr.new (solana-foundation#204)

* feat: add --minimal flag to that selects 'gill-next-tailwind-minimal'

* fix: update solana docs url

* Version Packages (solana-foundation#206)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(test): error handling in search-and-replace test

Description
-----------
The "should handle errors gracefully" test was intentionally
triggering errors to verify error handling, but `console.error`
was not mocked to suppress output, causing noisy `stderr` logs
during test despite all tests passing.

Testing the introduced fix
--------------------------
```
npm run test
```
All tests will now pass cleanly without `stderr` error output.

* refactor: remove repokit dependency and replace with local utilities

* fix: update imports and Zod types for compatibility

* Version Packages

* fix: run ci script as part of e2e test

* test: skip community in regular tests

* skip again test workflow on PR since we tested it now skips community

* feat: make Kit Framework templates the default

* fix: remove buggy deduplication in init-script-rename

* chore: remove test templates job (solana-foundation#221)

* fix: apply path rename only to entry name, not full path

* Version Packages

* fix: enable automated npm publish to latest tag

* Version Packages

* feat: show setup progress for anchor templates

Add a dedicated task that runs the `setup` script (if present) with a descriptive message "Running setup (building program, generating client)" to improve UX during anchor template installation.

* Version Packages

* feat: support local template install for testing

* feat: add warning for installing local templates

---------

Co-authored-by: Tobey Codes <tobey@tobey.codes>
Co-authored-by: Bram Borggreve <beeman@beeman.nl>
Co-authored-by: nickfrosty <75431177+nickfrosty@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: tobey <3613405+tobeycodes@users.noreply.github.com>
Co-authored-by: hyckomatej <158080691+hyckomatej@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: 0x7EAB07 <teapotparadise@gmail.com>
Co-authored-by: Arjun Porwal <65214523+ap211unitech@users.noreply.github.com>
Co-authored-by: 0xObsidian <131651958+0xObsidian@users.noreply.github.com>
Co-authored-by: guibibeau <g.bibeaulaviolette@gmail.com>
Co-authored-by: Gui Bibeau <GuiBibeau@gmail.com>
Co-authored-by: Sourav Mishra <sourav.m.bt@gmail.com>
Dargon789 added a commit to Dargon789/create-solana-dapp that referenced this pull request Jan 14, 2026
* feat: add message to final note to install dependencies with skip install arg

* refactor: remove dummy test

* refactor: create helper to fetch package.json path from target dir

* feat: added changeset

* feat: pr build and test

* fix: pnpm version

* ci: scaffold publish

* ci: temp run on pr

* chore: update action version

* feat: publish

* docs: update the README to show different package managers and include @latest tag

* feat: rename template name based on package.json name property

* docs: update maintainers

* ci: remove old ci workflow

* refactor: update framework descriptions

* chore: add more examples to csd.sh

* chore: enable gill-next-tailwind-basic and gill-next-tailwind-counter templates

* refactor: clean up init script version check

* feat: add bun support

* refactor: clean up init script utils

* Version Packages (solana-foundation#158)



* fix: remove 'concurrency' parameter from build-step-decider

* fix: move publish-canary-releases script to .github/workflows

* Version Packages (solana-foundation#163)



* fix: add build step to publish-packages workflow

* Version Packages (solana-foundation#165)



* chore: enable e2e-test for gill-next-tailwind-basic and gill-next-tailwind-counter

* fix: add build step before publish-packages in canary workflow

* chore: enable template-react-vite-tailwind-{basic,counter} template

* Version Packages (solana-foundation#169)



* fix: gracefully handle git commits with no configured name and email

* chore: add Dockerfile for running ephemeral dev containers

* docs: add bun command to readme (solana-foundation#176)

Thanks!

* fix: update picocolors import to resolve SyntaxError in ESM module

* refactor: don't show the start script if instructions are provided

* feat: add Solana Mobile templates

* chore: add changeset

* Version Packages (solana-foundation#173)



* fix: tip alert in README (solana-foundation#182)

* chore: apply automated updates

* chore: don't run e2e tests when Markdown files are changed

* feat: add update notifier and skip version check option

* chore: rename github org solana-developers -> solana-foundation

* Version Packages (solana-foundation#186)



* chore: remove autofix github workflow script (solana-foundation#188)

* chore: remove autofix github workflow script

* fix: tip alert in README

* fix: tip alert in README

* feat: dynamic template lists by fetching them from registry url (solana-foundation#111)

* Version Packages (solana-foundation#190)



* feat: add list-template-ids option

* chore: use list-template-ids to dynamically populate template list

* chore: run e2e test nightly and with dispatch

* chore: update dependencies

* chore: add eslint-plugin-sort and eslint-plugin-prettier

* chore: add lefthook to automate linting/formatting

* fix: file/folder renaming and content replacement in init script (solana-foundation#196)

* fix: fully support file/folder renaming and content replacement in init script

* chore: remove extra underscrore

* fix: logging and avoid inline if-statements

* Revert "fix: file/folder renaming and content replacement in init script (solana-foundation#196)" (solana-foundation#203)

This reverts commit 096f365.

* chore: publish PRs to pkg.pr.new (solana-foundation#204)

* feat: add --minimal flag to that selects 'gill-next-tailwind-minimal'

* fix: update solana docs url

* Version Packages (solana-foundation#206)



* fix(test): error handling in search-and-replace test

Description
-----------
The "should handle errors gracefully" test was intentionally
triggering errors to verify error handling, but `console.error`
was not mocked to suppress output, causing noisy `stderr` logs
during test despite all tests passing.

Testing the introduced fix
--------------------------
```
npm run test
```
All tests will now pass cleanly without `stderr` error output.

* refactor: remove repokit dependency and replace with local utilities

* fix: update imports and Zod types for compatibility

* Version Packages

* fix: run ci script as part of e2e test

* test: skip community in regular tests

* skip again test workflow on PR since we tested it now skips community

* feat: make Kit Framework templates the default

* fix: remove buggy deduplication in init-script-rename

* chore: remove test templates job (solana-foundation#221)

* fix: apply path rename only to entry name, not full path

* Version Packages

* fix: enable automated npm publish to latest tag

* Version Packages

* feat: show setup progress for anchor templates

Add a dedicated task that runs the `setup` script (if present) with a descriptive message "Running setup (building program, generating client)" to improve UX during anchor template installation.

* Version Packages

* feat: support local template install for testing

* feat: add warning for installing local templates

---------

Co-authored-by: Tobey Codes <tobey@tobey.codes>
Co-authored-by: Bram Borggreve <beeman@beeman.nl>
Co-authored-by: nickfrosty <75431177+nickfrosty@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: tobey <3613405+tobeycodes@users.noreply.github.com>
Co-authored-by: hyckomatej <158080691+hyckomatej@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: 0x7EAB07 <teapotparadise@gmail.com>
Co-authored-by: Arjun Porwal <65214523+ap211unitech@users.noreply.github.com>
Co-authored-by: 0xObsidian <131651958+0xObsidian@users.noreply.github.com>
Co-authored-by: guibibeau <g.bibeaulaviolette@gmail.com>
Co-authored-by: Gui Bibeau <GuiBibeau@gmail.com>
Co-authored-by: Sourav Mishra <sourav.m.bt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants