Skip to content

Conversation

@Tobbe
Copy link
Member

@Tobbe Tobbe commented Dec 28, 2025

Continue on #855

@netlify
Copy link

netlify bot commented Dec 28, 2025

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit 3017cc3
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6953c70bb8d794000803645a

@github-actions github-actions bot added this to the chore milestone Dec 28, 2025
@nx-cloud
Copy link

nx-cloud bot commented Dec 28, 2025

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 3017cc3

Command Status Duration Result
nx run-many -t test --minWorkers=1 --maxWorkers=4 ❌ Failed 1m 17s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 8s View ↗
nx run-many -t build ✅ Succeeded 8s View ↗
nx run-many -t test:types ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-30 12:53:30 UTC

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 28, 2025

Greptile Summary

This PR continues the TypeScript migration of the Cedar CLI by converting 23 JavaScript files to TypeScript. The conversion includes:

  • Command files: Converted build.ts, check.ts, console.ts, destroy.ts, exec.ts, experimental.ts, generate.ts, info.ts, lint.ts, prerender.ts, prisma.ts, test.ts, and type-check.ts with proper yargs Argv typing
  • Handler files: Migrated buildHandler.ts, consoleHandler.ts, execHandler.ts, prerenderHandler.ts, prismaHandler.ts, type-checkHandler.ts, and the large upgrade.ts file with interface definitions for options
  • Test files: Converted test files to TypeScript with proper vitest types and mocking
  • Configuration: Updated tsconfig.json to use NodeNext module resolution and tsconfig.build.json to use Node20

The conversion adds proper type safety through:

  • Interface definitions for command options (e.g., BuildOptions, ExecOptions, PrismaOptions)
  • Type guards for runtime checks (e.g., isREPLServerWithHistory in consoleHandler.ts)
  • Proper error typing with type narrowing (e instanceof Error)
  • Yargs builder functions with Argv types

Previous syntax issues from thread comments have been addressed - template literal interpolation now works correctly in both execHandler.ts and prerenderHandler.ts.

Confidence Score: 5/5

  • This PR is safe to merge - it's a straightforward JS to TS conversion with proper type definitions and no logic changes
  • Clean TypeScript conversion with consistent patterns throughout, previous syntax issues resolved, no breaking changes to functionality, comprehensive type annotations added, and test files properly migrated
  • No files require special attention

Important Files Changed

Filename Overview
packages/cli/src/commands/prerenderHandler.ts Converted from JS to TS with proper type definitions for routes and parameters
packages/cli/src/commands/execHandler.ts Converted from JS to TS with ExecOptions interface, template literal issues fixed
packages/cli/src/commands/upgrade.ts Large JS to TS conversion with proper type annotations and interface definitions
packages/cli/src/commands/consoleHandler.ts Converted from JS to TS with type guards for REPL server extensions
packages/cli/src/commands/buildHandler.ts Converted from JS to TS with BuildOptions interface
packages/cli/src/commands/prismaHandler.ts Converted from JS to TS with PrismaOptions interface and proper error handling
packages/cli/src/commands/lint.ts Converted from JS to TS with proper function type annotations
packages/cli/src/commands/type-checkHandler.ts Converted from JS to TS with type definitions for options

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant CLI as Cedar CLI
    participant TS as TypeScript Compiler
    participant Babel as Babel
    participant Yargs as Yargs Parser
    
    Note over Dev,CLI: JS to TS Conversion Process
    
    Dev->>CLI: Runs CLI command (e.g., cedar build)
    CLI->>Yargs: Parse command with typed Argv<T>
    Yargs-->>CLI: Typed command options
    
    alt Command requires handler execution
        CLI->>TS: Type-check handler with interfaces
        Note over CLI,TS: BuildOptions, ExecOptions, etc.
        TS-->>CLI: Type validation passed
        
        CLI->>Babel: Transpile TS files with @ts-expect-error
        Note over Babel: For lib/colors.js, lib/exec.js, etc.
        Babel-->>CLI: Compiled JS code
        
        CLI->>CLI: Execute handler logic
        
        alt Command involves external tools
            CLI->>CLI: Run Prisma/ESLint/Jest via execa
        end
    end
    
    Note over Dev,CLI: All commands now have type safety
    CLI-->>Dev: Command execution result
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. packages/cli/src/commands/execHandler.ts, line 177-179 (link)

    syntax: Same template literal interpolation issue

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

31 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@Tobbe
Copy link
Member Author

Tobbe commented Dec 30, 2025

@greptileai Please do a full review again and update your review summary

@Tobbe Tobbe changed the title chore(cli): Convert JS files to TS (part II) chore(cli): Convert JS files to TS (part III) Dec 30, 2025
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