Skip to content

chore(cli): migrate index, scaffoldHandler, baremetalHandler, and deploy templates from JS to TS#2018

Merged
Tobbe merged 4 commits into
cedarjs:mainfrom
lisa-assistant:lisa/js-to-ts-cli-migration-20260630
Jul 1, 2026
Merged

chore(cli): migrate index, scaffoldHandler, baremetalHandler, and deploy templates from JS to TS#2018
Tobbe merged 4 commits into
cedarjs:mainfrom
lisa-assistant:lisa/js-to-ts-cli-migration-20260630

Conversation

@lisa-assistant

Copy link
Copy Markdown
Contributor

Summary

Converts 10 JavaScript files in packages/cli/src to TypeScript:

  • src/index.jssrc/index.ts — typed getTomlDir param, error narrowing in catch
  • commands/generate/scaffold/scaffoldHandler.js.tsScaffoldField/ScaffoldModel interfaces, ListrTaskWrapper types, proper error narrowing
  • commands/deploy/baremetal/baremetalHandler.js.tsServerConfig, BaremetalYargs, LifecycleHooks interfaces, error narrowing in all catch blocks
  • commands/setup/deploy/templates/baremetal.js.ts
  • commands/setup/deploy/templates/flightcontrol.js.ts
  • commands/setup/deploy/templates/netlify.js.ts
  • commands/setup/deploy/templates/netlifyUD.js.ts
  • commands/setup/deploy/templates/render.js.ts — typed database: string param
  • commands/setup/deploy/templates/serverless/api.js.ts
  • commands/setup/deploy/templates/serverless/web.js.ts

Also removes @ts-expect-error suppression comments from 4 handler files that were silencing missing types from these now-converted template files.

Type safety

  • No as any, no @ts-ignore
  • Error narrowing follows e instanceof Error ? e.message : String(e) throughout
  • as casts are limited to genuine typing boundaries (e.g. DMMF models from getSchema() return an opaque union type)
  • Local interfaces (ScaffoldField, ScaffoldModel, ServerConfig, etc.) describe the actual shapes used

Test plan

  • yarn workspace @cedarjs/cli tsc --noEmit passes (no new errors)
  • Scaffold generator: yarn cedar generate scaffold Post
  • Baremetal deploy handler unit tests: yarn workspace @cedarjs/cli test baremetal
  • Deploy template imports verified in netlifyHandler, renderHandler, serverlessHandler, baremetalHandler setup

🤖 Generated with Claude Code

…loy templates from JS to TS

Convert 10 files in packages/cli/src from JavaScript to TypeScript:
- src/index.js → index.ts (add types, fix error narrowing)
- commands/generate/scaffold/scaffoldHandler.js → .ts (ScaffoldField/ScaffoldModel interfaces, ListrTaskWrapper types)
- commands/deploy/baremetal/baremetalHandler.js → .ts (ServerConfig/BaremetalYargs/LifecycleHooks interfaces)
- commands/setup/deploy/templates/{baremetal,flightcontrol,netlify,netlifyUD,render}.js → .ts
- commands/setup/deploy/templates/serverless/{api,web}.js → .ts

Remove @ts-expect-error suppressions from netlifyHandler, renderHandler,
serverlessHandler, and baremetalHandler (setup) that referenced these files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 30, 2026

Copy link
Copy Markdown

👷 Deploy request for cedarjs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b45f1e0

@github-actions github-actions Bot added this to the chore milestone Jun 30, 2026
@nx-cloud

nx-cloud Bot commented Jun 30, 2026

Copy link
Copy Markdown

🤖 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 b45f1e0

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 4s View ↗
nx run-many -t build ✅ Succeeded 4s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-30 08:10:19 UTC

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR converts several CLI files from JavaScript to TypeScript. The main changes are:

  • TypeScript migrations for the CLI entrypoint and deploy handlers.
  • TypeScript migrations for scaffold generation logic.
  • TypeScript migrations for deploy setup templates.
  • Removal of obsolete import suppression comments for converted template files.
  • Narrower error handling in the changed CLI catch blocks.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
packages/cli/src/commands/deploy/baremetal/baremetalHandler.ts Migrates the baremetal deploy handler to TypeScript and preserves remote command exit codes in the deploy catch block.
packages/cli/src/commands/generate/scaffold/scaffoldHandler.ts Migrates the scaffold handler to TypeScript and preserves generator exit codes in the scaffold catch block.
packages/cli/src/commands/deploy/baremetal.ts Removes an obsolete suppression around the imported baremetal handler.
packages/cli/src/commands/setup/deploy/providers/baremetalHandler.ts Removes an obsolete suppression for the converted baremetal deploy template import.
packages/cli/src/commands/setup/deploy/providers/netlifyHandler.ts Removes obsolete suppressions for converted Netlify deploy template imports.
packages/cli/src/commands/setup/deploy/providers/renderHandler.ts Removes an obsolete suppression for the converted Render deploy template import.
packages/cli/src/commands/setup/deploy/providers/serverlessHandler.ts Removes obsolete suppressions for converted Serverless deploy template imports.
packages/cli/src/index.ts Migrates the CLI entrypoint to TypeScript and narrows catch-block error output.
packages/cli/src/global.d.ts Renames the global declaration file after the entrypoint migration.

Reviews (4): Last reviewed commit: "fix(cli): run prettier with project conf..." | Re-trigger Greptile

Comment thread packages/cli/src/commands/deploy/baremetal/baremetalHandler.ts
Comment thread packages/cli/src/commands/generate/scaffold/scaffoldHandler.ts
Greptile identified that baremetalHandler and scaffoldHandler were
reading errno instead of exitCode when exiting on error, causing SSH
command failures to always exit 1 instead of preserving actual status.
@lisa-assistant

Copy link
Copy Markdown
Contributor Author

Greptile P1/P2 on exit code handling are false positives — both baremetalHandler.ts and scaffoldHandler.ts already read exitCode, not errno:

const exitCode =
  e instanceof Error && 'exitCode' in e
    ? ((e as Error & { exitCode?: number | null }).exitCode ?? 1)
    : 1

This matches the original JS (e?.exitCode || 1). The NodeJS.ErrnoException in the error message block is just used as a type with a known stderr field — the errno property itself is never read.

- baremetalHandler.ts: add blank line between parent and sibling import groups
- scaffoldHandler.ts: Array<T> -> T[], remove unnecessary `as string` assertion
- index.ts: split destructuring so cwd uses `let`, telemetry/help/version use `const`
- Rename index.d.ts -> global.d.ts to avoid conflict with index.ts (TS skips
  index.d.ts when index.ts exists, causing ESLint parserOptions.project error)
- Run prettier on baremetal.ts, baremetalHandler.ts, index.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lisa-assistant

Copy link
Copy Markdown
Contributor Author

Fixed CI failures in 1e94bb5:

Lint errors:

  • baremetalHandler.ts: Added blank line between parent (../../../lib) and sibling (./SshExecutor) import groups (import-x/order)
  • scaffoldHandler.ts: Array<{ name: string }>{ name: string }[] (@typescript-eslint/array-type); removed unnecessary as string assertion on validationDef (@typescript-eslint/no-unnecessary-type-assertion)
  • index.ts: Split destructuring — cwd stays let (reassigned later), telemetry/help/versionconst (prefer-const)
  • Renamed index.d.tsglobal.d.ts: TypeScript skips index.d.ts when index.ts exists in the same directory, which caused the parserOptions.project ESLint error

Prettier:

  • Ran on baremetal.ts, baremetalHandler.ts, index.ts

…Handler.ts, index.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Tobbe Tobbe merged commit 4958301 into cedarjs:main Jul 1, 2026
75 of 79 checks passed
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 5.0.0-canary.2567

Or try it in a new app with yarn dlx create-cedar-app@5.0.0-canary.2567

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