Commit 6b12cba
Dynamic template fetching from GitHub repos (#279)
* test charm lib impelentation for cre init
* Add shared UI package with Charm ecosystem for styled CLI output
- Create internal/ui/ package with centralized Lipgloss styles (styles.go)
- Add output helpers for consistent styling: Title, Box, Success, Dim, etc.
- Implement Bubble Tea spinner with reference counting for async operations
- Add GlobalSpinner singleton for seamless spinner across CLI lifecycle
- Update PersistentPreRunE to show spinner during initialization
- Migrate cre init and cre whoami to use shared UI package
* Add spinner to cre init and fix layout issues
- Add spinner during file generation (copying, generating templates, contracts)
- Show spinner during Go dependencies installation
- Display dependencies in styled box after spinner completes
- Fix Next steps box spacing and formatting
- Refactor initializeGoModule to return deps instead of printing
* Style help page with Lipgloss
- Add styled template functions (styleTitle, styleSection, styleCommand, styleDim, styleSuccess, styleCode)
- Update help template to use Lipgloss styling
- Style section headers, command names, tips, and URLs
- Improve visual hierarchy and readability
* Apply Chainlink Blocks color palette to CLI
- Add complete Blocks palette constants (Gray, Blue, Green, Red, Orange, Yellow, Teal, Purple)
- Use high-contrast colors for dark terminal readability
- Style titles/commands with Blue 400-500 for visibility
- Style secondary info with Gray 500 (dimmed)
- Create custom Huh theme with Blocks colors for forms
- Update spinner to use Blue 500
* Modernize cre login command with Charm UI components
- Add styled title and welcome message using Chainlink theme
- Add Bubble Tea spinner with progress states throughout auth flow:
- Preparing authentication
- Opening browser
- Waiting for authentication
- Exchanging authorization code
- Saving credentials
- Show styled URL fallback when browser cannot open automatically
- Display success message with next steps in branded box
- Update spinner message during org membership retry flow
- Update tests to include spinner in handler instantiations
* Add styled error display for CLI using ui.Error()
- Add SilenceErrors: true to root command to disable Cobra's default error output
- Display all user-facing errors with styled ui.Error() in Execute()
- Errors now show with red color and ✗ prefix consistent with Chainlink theme
- Internal debug logging via zerolog remains unchanged
* Improve CLI error display with styled output and smart usage handling
- Add SilenceErrors: true to disable Cobra's default error output
- Display errors with styled ui.Error() (red with ✗ prefix)
- Set SilenceUsage in PersistentPreRunE to hide usage for runtime errors
- Keep usage/suggestions visible for command typos and flag errors
* Add login prompt when authentication is required
* Fix tests broken by Charm UI changes
* Fix cre logout to skip credential check and handle nil credentials
* Modernize cre version command with Charm UI styling
* Modernize cre update command with progress bar and Charm UI
* Fix creinit tests to provide all inputs via flags
* Update the list-key command to use the shared Charm UI components for
consistent styling across the CLI
* Update test assertions for Charm UI output changes
* Update the generate-bindings command to use the shared Charm UI
* Update the secrets list command to use the shared Charm UI component
* Update the secrets delete command to use the shared Charm UI components
* Modernize workflow pause, activate, delete with Charm UI
* updated styling for workflow deploy, pause, delete and transaction
* mondernized link and unlink command using charm lib
* updated missing charm console output in creinit.go
* fixed build output ui
* updated fmt.print with new ui that were not replaced
* mondernized simulate command with charm ui output
* 1. Updated internal/settings/settings_generate.go:
- Replaced prompt.YesNoPrompt with huh.NewConfirm forms
- Removed stdin io.Reader parameter
2. Updated cmd/creinit/creinit.go:
- Updated call sites to match new function signatures
3. Updated cmd/secrets/common/handler.go:
- Replaced ~25 fmt.Print* calls with ui.* functions
4. Updated cmd/workflow/simulate/telemetry_writer.go:
- Replaced fmt.Printf with ui.Printf
- Removed unused fmt import
5. Deleted internal/prompt/ directory:
- Removed entire old promptui-based package
6. Cleaned cmd/common/utils.go:
- Removed unused MustGetUserInputWithPrompt function
- Removed unused bufio and errors imports
7. Dependencies cleaned (go mod tidy):
- Removed github.com/manifoldco/promptui
- Removed github.com/chzyer/readline
* improved prompt behavior with autocomplete and default value
* added error helpers
* improved login command with cancellation / escape
* fixed logout issue that was not flushing credentials
* updated login to remove the esc logic
* updated secret tests that were failing
* fixed lint error: unused functions and returns
* Refactored credentials.go for deploy access status and added deploy access display to cre whoami command
* Updated gated message with the command to request access
* added new account access command
* added account access command to settings exclusion
* access command logic to submit form to zendesk
* added prompt to request access when running cre account access cmd
* Refactor access request logic into shared package and add deploy access check to workflow deploy command
* Fix background goroutine error appearing during deploy access prompt
* Update account command description to mention deploy access
* Show deploy access hint after successful workflow simulation
* Add deploy access hint to global help template for gated users
* Added prompt to describe use cases when request access request
* update code so that request is sent to a proxy that will take care of submitting the request to zendesk
* updated deploy request changes to be compatible with new charm lib refactor
* updated simulator deploy message to use box layout
* Yes is now selected by default for cre deploy access request prompt
* updated creinit to use bubbletea wizard
* fixed linter issues
* fixed weird spacing in creinit.go
* cre init: wizard now display files created in <workflow directory> and
- Contracts generated in <contracts directory>
* restored original comments in creinit.go
* fixed update cmd progress indicator issue
* Temp mock access request behavior before API implementation
* Added ascii logo in creinit wizard
* Spinner do not display in verbose mode to avoid stdout and stderr conflict and visual display issue in verbose mode
* replaced temp REST HTTP client with GraphQL client
* added tests for access cmd
* Replace embedded templates with dynamic GitHub-based template fetching
Templates are now discovered and downloaded from GitHub repositories at
runtime instead of being embedded in the CLI binary via go:embed. This
enables template updates without CLI releases and supports multiple
template sources.
New packages:
- internal/templaterepo/ - GitHub API client, file cache, and registry
for discovering, caching, and scaffolding templates
- internal/config/ - CLI config (~/.cre/config.yaml) for template
repository sources with env var and flag overrides
Changes:
- cmd/creinit: rewritten to use registry-based template fetching with
RegistryInterface for testability. Wizard simplified to 3 steps
(project name, template selection, workflow name)
- cmd/creinit/template/workflow/ removed (all embedded templates)
- cmd/creinit/go_module_init.go removed (templates are self-contained)
- SDK version constants moved to internal/constants/
- cmd/generate-bindings updated to import from constants package
- E2E tests updated: --template-id flag replaced with --template using
template name strings (kv-store-go, cre-custom-data-feed-go, etc.)
Template sources configurable via:
- --template-repo flag
- CRE_TEMPLATE_REPOS env var
- ~/.cre/config.yaml
- Default: smartcontractkit/cre-templates@main
* fix & log for extracing templates
* Built-in hello-world template — always available, even offline:
- internal/templaterepo/builtin/hello-world-go/ — embedded files (main.go, workflow.yaml, README.md, configs, secrets.yaml)
- internal/templaterepo/builtin.go — //go:embed, BuiltInTemplate var, ScaffoldBuiltIn() function
- TemplateSummary.BuiltIn bool field to distinguish embedded vs remote
- ListTemplates() always prepends the built-in template (no network needed)
- ScaffoldTemplate() uses ScaffoldBuiltIn() for built-in templates instead of downloading
* Remove template-repo flag from cre init, added template-id as a deprecated flag for backward compatibility
* Added back builtin TS hello world template, updated template-id behavior
* Added networks field to template metadata (internal/templaterepo/types.go) — An optional []string of chain names in template.yaml.
Dynamic project.yaml RPC generation (internal/settings/):
- project.yaml.tpl now uses a {{RPCsList}} placeholder instead of hardcoded chains
- BuildRPCsListYAML() generates the rpcs YAML block from networks + URLs
- Falls back to ethereum-testnet-sepolia with default public RPC when no networks specified
New wizard step (cmd/creinit/wizard.go):
- stepNetworkRPCs between template selection and workflow name
- Prompts for each network's RPC URL sequentially
- Empty input accepted (fill later), non-empty input validated as valid HTTP/HTTPS URL
- Step is skipped if template has no networks or all RPCs provided via flags
--rpc-url flag (cmd/creinit/creinit.go):
- Repeatable StringArray flag: --rpc-url chain-name=url
- Parsed in ResolveInputs(), merged with wizard results in Execute()
- Flag values override wizard input
* Patch RPC when template arleady have rpc configured in project.yaml
* Fixed go init for default embed template
* Fixed TS template default template (same as main branch now)
* Updated init wizard for better layout
* Add multi-workflow support and preserve template-shipped workflow.yaml
- Add WorkflowDirEntry struct and Workflows/PostInit fields to
TemplateMetadata in types.go
- Rewrite renameWorkflowDir in registry.go to branch on workflow count:
skip renaming for multi-workflow, rename single workflow, heuristic
fallback for legacy
- Update wizard to skip workflow name prompt for multi-workflow
templates and default placeholder from Workflows[0].Dir
- Default workflowName from Workflows[0].Dir in non-interactive mode
- Loop GenerateWorkflowSettingsFile for each declared workflow dir in
multi-workflow templates
- Skip workflow.yaml generation when template already ships one
(prevents overwriting custom config paths)
- Rewrite printSuccessMessage to show per-workflow summary and postInit
instructions
- Add 6 new test cases covering multi-workflow, single-workflow
defaults, rename with flag, and built-in backwards compat
* added in wizard check for cre init - folder and rpc url
* updated cre init list layout
* cre init search wizard stay displayed
* updated template.yaml local to .cre/template.yaml
* added a flag to pass new repository url, made ~/.cre/template.yaml source of truth for template source
* Root-level template repo extraction fix
* added cre templates list/add/remove to manage repo sources
* template.yaml now has projectDir to specify the cre project dir, updated copy logic
* Added prediction market repo as default
* fix go mod tidy for dynamic template in go
* fix linter
* cre init create .env file if not present
* updated default template source repo to main
* handle error for relative path in builtin.go
* Sanitize template repo external values
* prevent zip slip
* Fixed setAuthHeader for fetching template metadata
* gendoc
* Fix dir rename that was failing tests
* Updated tests now that templates are dynamic
* Fix linter issues
* fixed linter
* Fix deprecated template id
* Fix zip slip warning
* Fix zip slip
* updated tests
* Fixed linter and go mod tidy
* Add tracking to template id when using cre init (#284)
* Always track flag --template even when not provided
* linter fixes
* fix path extraction on windows
---------
Co-authored-by: Tarcísio Zotelli Ferraz <tar-2008.ferraz@hotmail.com>1 parent 72002a3 commit 6b12cba
111 files changed
Lines changed: 4262 additions & 6081 deletions
File tree
- cmd
- creinit
- template/workflow
- blankTemplate
- contracts/evm/src
- abi
- keystone
- porExampleDev
- contracts/evm/src
- abi
- generated
- balance_reader
- ierc20
- message_emitter
- reserve_manager
- keystone
- typescriptConfHTTP
- typescriptPorExampleDev
- contracts
- abi
- typescriptSimpleExample
- generate-bindings
- templates
- add
- list
- remove
- docs
- internal
- constants
- settings
- template
- templateconfig
- templaterepo
- builtin
- hello-world-go
- workflow
- hello-world-ts
- workflow
- test
- multi_command_flows
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 11 | + | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
| |||
26 | 21 | | |
27 | 22 | | |
28 | 23 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
| |||
40 | 35 | | |
41 | 36 | | |
42 | 37 | | |
43 | | - | |
| 38 | + | |
44 | 39 | | |
45 | 40 | | |
46 | | - | |
| 41 | + | |
47 | 42 | | |
48 | 43 | | |
49 | | - | |
| 44 | + | |
50 | 45 | | |
51 | 46 | | |
52 | | - | |
| 47 | + | |
53 | 48 | | |
54 | 49 | | |
55 | 50 | | |
| |||
75 | 70 | | |
76 | 71 | | |
77 | 72 | | |
78 | | - | |
| 73 | + | |
79 | 74 | | |
80 | 75 | | |
81 | 76 | | |
| |||
This file was deleted.
Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 0 additions & 1 deletion
This file was deleted.
Whitespace-only changes.
Whitespace-only changes.
This file was deleted.
Lines changed: 0 additions & 14 deletions
This file was deleted.
0 commit comments