feat: dynamic template lists by fetching them from registry url#111
feat: dynamic template lists by fetching them from registry url#111
Conversation
4ac4c0f to
03eb536
Compare
03eb536 to
65330fa
Compare
65330fa to
7919ae9
Compare
|
7919ae9 to
fd9c28c
Compare
ef63acc to
7b5dfea
Compare
7b5dfea to
24bb466
Compare
beeman
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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[] = [ |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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'], |
There was a problem hiding this comment.
We look in any of these groups...
| description: 'A React framework by Vercel', | ||
| groups: ['templates', 'legacy', 'gill', 'web3js'], | ||
| id: 'next', | ||
| keywords: ['nextjs'], |
There was a problem hiding this comment.
...and take the templates with these keywords.
| }, | ||
| { | ||
| description: 'React with Vite and React Router', | ||
| groups: ['templates', 'legacy', 'gill', 'web3js'], |
There was a problem hiding this comment.
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'], |
There was a problem hiding this comment.
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[] }) { |
There was a problem hiding this comment.
This function used to live in src/templates/templates.ts and iterated over the templates array that was defined globally.
24bb466 to
da8c197
Compare
* 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>
* 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>
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:
By moving the CLI to work with a template registry, we get a few benefits: