Skip to content

Remove JS/Res Templates#811

Merged
DZakh merged 2 commits into
mainfrom
feat/templates
Nov 6, 2025
Merged

Remove JS/Res Templates#811
DZakh merged 2 commits into
mainfrom
feat/templates

Conversation

@nikbhintade

@nikbhintade nikbhintade commented Nov 5, 2025

Copy link
Copy Markdown
Member

As discussed by the team, we are removing JS/Res Templates from the CLI for both EVM & Fuel.

Ref: #790 (review)

Sorry for the ambiguous branch name; the branch should've named it something better

Summary by CodeRabbit

Release Notes

  • Breaking Changes
    • Removed JavaScript as a supported language option. Only TypeScript and ReScript are now available for initialization.
    • Removed all JavaScript template examples, including ERC20, Greeter, and GreeterOnFuel templates.
    • Removed JavaScript event handler and test generation templates.

@nikbhintade nikbhintade requested a review from DZakh November 5, 2025 11:52
@coderabbitai

coderabbitai Bot commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This PR removes JavaScript language support from the CLI code generator and template infrastructure. The Language enum is reduced to TypeScript and ReScript, and all JavaScript-specific template files, code paths, and configurations are deleted from the codebase.

Changes

Cohort / File(s) Summary
Language enum and event handler paths
codegenerator/cli/src/cli_args/init_config.rs, codegenerator/cli/src/config_parsing/graph_migration/mod.rs
Removed Language::JavaScript variant from public enum and eliminated JavaScript-specific match arms in get_event_handler_directory, leaving only TypeScript and ReScript paths.
Template data structures
codegenerator/cli/src/hbs_templating/init_templates.rs
Removed is_javascript: bool field from InitTemplates struct and all related initializations and usages.
Contract import templates
codegenerator/cli/src/hbs_templating/contract_import_templates.rs
Removed Language::JavaScript match arms from get_entity_id_code and get_create_mock_code functions; TypeScript and ReScript branches remain.
Template directory tests
codegenerator/cli/src/template_dirs.rs
Updated tests to constrain language iterations to TypeScript only via local template array; adjusted loop structure to perform per-language per-template validation within nested loops.
Help documentation
codegenerator/cli/CommandLineHelp.md
Removed JavaScript from initialization language choices and option references.
JavaScript contract import templates
codegenerator/cli/templates/dynamic/contract_import_templates/javascript/src/EventHandlers.js.hbs, codegenerator/cli/templates/dynamic/contract_import_templates/javascript/test/Test.js.hbs
Deleted JavaScript-specific contract import template files for event handlers and test generation.
JavaScript ERC20 template
codegenerator/cli/templates/static/erc20_template/javascript/config.yaml, codegenerator/cli/templates/static/erc20_template/javascript/src/EventHandlers.js, codegenerator/cli/templates/static/erc20_template/javascript/test/test.js
Removed JavaScript ERC20 template configuration, event handlers (Approval and Transfer), and test suite.
ReScript ERC20 template cleanup
codegenerator/cli/templates/static/erc20_template/rescript/config.yaml, codegenerator/cli/templates/static/erc20_template/rescript/rescript.json, codegenerator/cli/templates/static/erc20_template/rescript/src/EventHandlers.bs.js, codegenerator/cli/templates/static/erc20_template/rescript/src/EventHandlers.res, codegenerator/cli/templates/static/erc20_template/rescript/test/Test.res
Deleted ReScript ERC20 template configuration file, rescript.json, build artifact comments, event handlers, and test suite.
Blank template ReScript cleanup
codegenerator/cli/templates/static/blank_template/rescript/rescript.json, codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
Removed rescript.json configuration and unnecessary module open statements from ReScript test file.
JavaScript Greeter template
codegenerator/cli/templates/static/greeter_template/javascript/README.md, codegenerator/cli/templates/static/greeter_template/javascript/config.yaml, codegenerator/cli/templates/static/greeter_template/javascript/src/EventHandlers.js, codegenerator/cli/templates/static/greeter_template/javascript/test/test.js
Removed JavaScript Greeter template documentation, configuration, event handlers (NewGreeting and ClearGreeting), and test suite.
ReScript Greeter template cleanup
codegenerator/cli/templates/static/greeter_template/rescript/README.md, codegenerator/cli/templates/static/greeter_template/rescript/config.yaml, codegenerator/cli/templates/static/greeter_template/rescript/rescript.json, codegenerator/cli/templates/static/greeter_template/rescript/src/EventHandlers.res, codegenerator/cli/templates/static/greeter_template/rescript/test/Test.res
Deleted ReScript Greeter template documentation, configuration, build manifest, event handlers, and test suite.
JavaScript Greeter on Fuel template
codegenerator/cli/templates/static/greeteronfuel_template/javascript/README.md, codegenerator/cli/templates/static/greeteronfuel_template/javascript/config.yaml, codegenerator/cli/templates/static/greeteronfuel_template/javascript/src/EventHandlers.js, codegenerator/cli/templates/static/greeteronfuel_template/javascript/test/test.js
Removed JavaScript Greeter on Fuel template documentation, configuration, event handlers (NewGreeting and ClearGreeting), and test suite.
ReScript Greeter on Fuel template cleanup
codegenerator/cli/templates/static/greeteronfuel_template/rescript/README.md, codegenerator/cli/templates/static/greeteronfuel_template/rescript/config.yaml, codegenerator/cli/templates/static/greeteronfuel_template/rescript/rescript.json, codegenerator/cli/templates/static/greeteronfuel_template/rescript/src/EventHandlers.res, codegenerator/cli/templates/static/greeteronfuel_template/rescript/test/Test.res
Deleted ReScript Greeter on Fuel template documentation, configuration, build manifest, event handlers, and test suite.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Files with logic removals requiring verification: init_config.rs, contract_import_templates.rs, hbs_templating/init_templates.rs — confirm all JavaScript-related code paths are cleanly removed and no orphaned references remain.
  • Test file updates: template_dirs.rs — verify loop restructuring and language constraints are correct and don't break existing coverage.
  • Template deletions: While mostly straightforward file removals, confirm no template generation logic elsewhere still references deleted JavaScript templates or handlers.
  • ReScript template files: Several ReScript template files removed entirely (configs, tests, handlers) — verify this does not break ReScript template generation or regeneration workflows.

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • DZakh
  • JonoPrest

Poem

🐰 JavaScript bids its farewell today,
TypeScript and ReScript now hold the way,
Templates deleted with care and with grace,
Cleaner codebase—a tidier place! ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Remove JS/Res Templates' accurately summarizes the main change: removal of JavaScript and ReScript templates from the CLI for both EVM and Fuel chains.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/templates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b85a78 and 8b8caed.

📒 Files selected for processing (36)
  • codegenerator/cli/CommandLineHelp.md (1 hunks)
  • codegenerator/cli/src/cli_args/init_config.rs (0 hunks)
  • codegenerator/cli/src/config_parsing/graph_migration/mod.rs (2 hunks)
  • codegenerator/cli/src/hbs_templating/contract_import_templates.rs (1 hunks)
  • codegenerator/cli/src/hbs_templating/init_templates.rs (0 hunks)
  • codegenerator/cli/src/template_dirs.rs (3 hunks)
  • codegenerator/cli/templates/dynamic/contract_import_templates/javascript/src/EventHandlers.js.hbs (0 hunks)
  • codegenerator/cli/templates/dynamic/contract_import_templates/javascript/test/Test.js.hbs (0 hunks)
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json (0 hunks)
  • codegenerator/cli/templates/static/blank_template/rescript/test/Test.res (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/javascript/config.yaml (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/javascript/src/EventHandlers.js (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/javascript/test/test.js (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/rescript/config.yaml (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/rescript/rescript.json (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/rescript/src/EventHandlers.bs.js (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/rescript/src/EventHandlers.res (0 hunks)
  • codegenerator/cli/templates/static/erc20_template/rescript/test/Test.res (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/javascript/README.md (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/javascript/config.yaml (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/javascript/src/EventHandlers.js (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/javascript/test/test.js (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/rescript/README.md (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/rescript/config.yaml (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/rescript/rescript.json (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/rescript/src/EventHandlers.res (0 hunks)
  • codegenerator/cli/templates/static/greeter_template/rescript/test/Test.res (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/README.md (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/config.yaml (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/src/EventHandlers.js (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/test/test.js (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/README.md (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/config.yaml (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/rescript.json (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/src/EventHandlers.res (0 hunks)
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/test/Test.res (0 hunks)
💤 Files with no reviewable changes (32)
  • codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/README.md
  • codegenerator/cli/src/hbs_templating/init_templates.rs
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/test/Test.res
  • codegenerator/cli/templates/static/greeter_template/rescript/config.yaml
  • codegenerator/cli/templates/static/erc20_template/rescript/rescript.json
  • codegenerator/cli/templates/static/greeter_template/javascript/config.yaml
  • codegenerator/cli/templates/static/greeter_template/rescript/src/EventHandlers.res
  • codegenerator/cli/templates/static/greeter_template/javascript/README.md
  • codegenerator/cli/templates/dynamic/contract_import_templates/javascript/test/Test.js.hbs
  • codegenerator/cli/templates/static/erc20_template/javascript/src/EventHandlers.js
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/config.yaml
  • codegenerator/cli/templates/static/erc20_template/rescript/src/EventHandlers.bs.js
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/src/EventHandlers.js
  • codegenerator/cli/templates/static/erc20_template/rescript/src/EventHandlers.res
  • codegenerator/cli/src/cli_args/init_config.rs
  • codegenerator/cli/templates/dynamic/contract_import_templates/javascript/src/EventHandlers.js.hbs
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/src/EventHandlers.res
  • codegenerator/cli/templates/static/greeter_template/rescript/test/Test.res
  • codegenerator/cli/templates/static/erc20_template/rescript/config.yaml
  • codegenerator/cli/templates/static/greeter_template/javascript/src/EventHandlers.js
  • codegenerator/cli/templates/static/greeter_template/rescript/rescript.json
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/README.md
  • codegenerator/cli/templates/static/erc20_template/javascript/test/test.js
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/config.yaml
  • codegenerator/cli/templates/static/greeteronfuel_template/rescript/rescript.json
  • codegenerator/cli/templates/static/greeter_template/rescript/README.md
  • codegenerator/cli/templates/static/greeter_template/javascript/test/test.js
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • codegenerator/cli/templates/static/greeteronfuel_template/javascript/test/test.js
  • codegenerator/cli/templates/static/erc20_template/rescript/test/Test.res
  • codegenerator/cli/templates/static/erc20_template/javascript/config.yaml
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/**

📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)

The Rust CLI lives in codegenerator/cli

Files:

  • codegenerator/cli/CommandLineHelp.md
  • codegenerator/cli/src/config_parsing/graph_migration/mod.rs
  • codegenerator/cli/src/hbs_templating/contract_import_templates.rs
  • codegenerator/cli/src/template_dirs.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/** : The Rust CLI lives in codegenerator/cli

Applied to files:

  • codegenerator/cli/src/config_parsing/graph_migration/mod.rs
  • codegenerator/cli/src/hbs_templating/contract_import_templates.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates

Applied to files:

  • codegenerator/cli/src/hbs_templating/contract_import_templates.rs
  • codegenerator/cli/src/template_dirs.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static

Applied to files:

  • codegenerator/cli/src/hbs_templating/contract_import_templates.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to {codegenerator/cli/templates/static/codegen/src/**,codegenerator/cli/templates/dynamic/codegen/src/**} : Template versions of runtime live under templates/{static,dynamic}/codegen/src and are the recommended editing targets

Applied to files:

  • codegenerator/cli/src/template_dirs.rs
🧬 Code graph analysis (3)
codegenerator/cli/src/config_parsing/graph_migration/mod.rs (1)
codegenerator/cli/src/cli_args/init_config.rs (1)
  • get_event_handler_directory (346-351)
codegenerator/cli/src/hbs_templating/contract_import_templates.rs (1)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
  • Language (144-146)
codegenerator/cli/src/template_dirs.rs (2)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
  • Language (144-146)
codegenerator/cli/src/hbs_templating/init_templates.rs (1)
  • new (22-56)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (5)
codegenerator/cli/CommandLineHelp.md (1)

74-74: LGTM!

Documentation correctly updated to reflect that JavaScript is no longer a supported language option.

codegenerator/cli/src/config_parsing/graph_migration/mod.rs (1)

552-560: LGTM!

The test correctly validates the local get_event_handler_directory function. However, note that this doesn't test the public method with the same name in init_config.rs, which returns a different path format for TypeScript.

codegenerator/cli/src/hbs_templating/contract_import_templates.rs (2)

254-272: LGTM!

The int_as_string closure correctly handles the language differences: TypeScript relies on template literal auto-coercion while ReScript requires explicit Belt.Int.toString conversion. The JavaScript branch has been cleanly removed.


274-297: LGTM!

The JavaScript branch has been cleanly removed from the language match expression. The remaining TypeScript and ReScript branches correctly handle Fuel mock event creation.

codegenerator/cli/src/template_dirs.rs (1)

432-460: No issues found—test changes correctly reflect template availability.

The verification confirms that init templates (greeter_template, erc20_template, blank_template, greeteronfuel_template) only have TypeScript language directories and no ReScript directories. The test constraint to [Language::TypeScript] on line 437 is therefore correct and intentional. Dynamic templates (contract_import_templates, subgraph_migration_templates) continue to support multiple languages, so tests correctly use Language::iter() for those templates. The asymmetry is accurate and the code requires no changes.

Comment on lines 115 to 120
fn get_event_handler_directory(language: &Language) -> String {
match language {
Language::ReScript => "./src/EventHandlers.res.js".to_string(),
Language::TypeScript => "src/EventHandlers.ts".to_string(),
Language::JavaScript => "./src/EventHandlers.js".to_string(),
Language::TypeScript => "./src/EventHandlers.ts".to_string(),
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify path consistency across functions with the same name.

The local get_event_handler_directory function returns "./src/EventHandlers.ts" for TypeScript (with ./ prefix), but the public method Language::get_event_handler_directory in codegenerator/cli/src/cli_args/init_config.rs returns "src/EventHandlers.ts" (without ./ prefix). Having two functions with the same name returning different paths is confusing and error-prone.

Run the following script to verify usage patterns and confirm which path format is expected:


🏁 Script executed:

#!/bin/bash
# Search for usages of get_event_handler_directory to understand which path format is needed
rg -nP --type=rust -C3 'get_event_handler_directory\(\)'

# Search for references to EventHandlers.ts to see which path format is used
rg -nP --type=rust -C3 'EventHandlers\.ts'

Length of output: 4446


Based on the script output, I can now verify the issue. The local function get_event_handler_directory in codegenerator/cli/src/config_parsing/graph_migration/mod.rs (lines 115-120) returns "./src/EventHandlers.ts" for TypeScript, while the public method Language::get_event_handler_directory in codegenerator/cli/src/cli_args/init_config.rs (lines 346-351) returns "src/EventHandlers.ts" without the ./ prefix.

The production code actually uses the public method (at lines 64 and 287 in init_config.rs), so the TypeScript handler path being used is "src/EventHandlers.ts". However, the local function in graph_migration/mod.rs is only used in its own unit test (line 556-559), which validates the local function's return value.


Unify TypeScript path format across get_event_handler_directory functions.

Two functions with the same name return different paths for TypeScript. The public method Language::get_event_handler_directory() in init_config.rs:349 returns "src/EventHandlers.ts", but the local function in graph_migration/mod.rs:118 returns "./src/EventHandlers.ts". Since production code uses the public method, align the local function or remove it if unused.

🤖 Prompt for AI Agents
In codegenerator/cli/src/config_parsing/graph_migration/mod.rs around lines 115
to 120, the local function get_event_handler_directory returns
"./src/EventHandlers.ts" for Language::TypeScript which conflicts with the
public Language::get_event_handler_directory in
codegenerator/cli/src/cli_args/init_config.rs (lines ~346-351) that returns
"src/EventHandlers.ts"; update the local function to return the same path string
"src/EventHandlers.ts" for TypeScript (remove the "./" prefix) so both
implementations match, or if the local function is only used by its unit test
and nowhere else, remove the local function and update the test to call the
public Language::get_event_handler_directory instead.

@nikbhintade

Copy link
Copy Markdown
Member Author

@DZakh I have split that big PR into smaller pieces, and this is the first one for removing JS/Res templates and fixing tests that removing those templates broke.

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice 🔥

@DZakh DZakh enabled auto-merge (squash) November 6, 2025 16:12
@DZakh DZakh merged commit 2ffff06 into main Nov 6, 2025
2 checks passed
@DZakh DZakh deleted the feat/templates branch November 6, 2025 16:21
@coderabbitai coderabbitai Bot mentioned this pull request Nov 27, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Apr 2, 2026
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