Remove JS/Res Templates#811
Conversation
WalkthroughThis 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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.mdcodegenerator/cli/src/config_parsing/graph_migration/mod.rscodegenerator/cli/src/hbs_templating/contract_import_templates.rscodegenerator/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.rscodegenerator/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.rscodegenerator/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_directoryfunction. However, note that this doesn't test the public method with the same name ininit_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_stringclosure correctly handles the language differences: TypeScript relies on template literal auto-coercion while ReScript requires explicitBelt.Int.toStringconversion. 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 useLanguage::iter()for those templates. The asymmetry is accurate and the code requires no changes.
| 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(), | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 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.
|
@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. |
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