Skip to content

feat: Setup TypeScript, migrate libs with tests, migrate basic commands #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: prerelease/v1.0.0
Choose a base branch
from

Conversation

sbosio
Copy link
Contributor

@sbosio sbosio commented Jul 17, 2025

Description

This is the third PR on a series of pull requests required to migrate the Heroku Connect CLI Plugin to @oclif/core and TypeScript.

On our initial PRs: #205 and #210 we just setup the repository according to our production standards for open sourced repositories and fixed the existing Mocha tests to ensure a smooth migration without introducing regressions, at least to the extent of the things that were tested (which is far less than ideal).

This third PR was meant to provide the required acceptance criteria on the linked work item at the bottom: namely the TypeScript configuration setup, migration of existing shared lib functions and adding tests were required to ensure the correct behavior. That proved to be challenging because:

  • We didn't have on the team someone with domain knowledge or exposure to Heroku Connect add-ons and APIs.
  • The plugin is still listed as experimental, with what looks like a ton of dead, unused code (more on this later).
  • The plugin didn't use our base API client implementation (from @heroku-cli/command) but leveraged Axios.
  • There isn't documentation on schemas for the relevant APIs.
  • The plugin used standard for linting purposes instead of ESLint.

With all of that, this is the work done to meet the acceptance criteria (and a little more, for reasons):

  • Added all the boilerplate for TypeScript, ESLint and Mocha configurations, along with the changes to package.json to add required dependencies, upgrade versions to remove all vulnerabilities and remove dependencies on standard (replaced by ESLint), unexpected (in favor of chai) and co (use native async/await). That's what the first three commits on this PR are about.
  • Added interfaces and types for relevant API response schemas in /src/lib/types.ts. There are still some unknowns that will need further refinement based on context requested to the Heroku Connect engineers.
  • Migrated all shared lib functions from /lib/**/*.js to their destinations under /src/lib/*.ts. File names and function names were preserved, but each one of those functions required refactoring to:
    • remove the dependency on Axios and use our base API client for external requests.
    • remove the dependency on co and use native async/await.
    • add typing.
  • Added missing tests for shared lib functions. Just a caveat that there are a few functions on /src/lib/api.ts still purposely untested, awaiting on the same context requested to Heroku Connect engineers. There's a whole series of commands (connect-event:*) that are listed as commands for some pilot being conducted that doesn't seem to have been promoted to GA at any point and we might want to remove all that dead code, reducing the migration effort scope on a 40%.
  • Last, but not least, I'm providing a couple command migrations with their tests, that are just a straightforward call to one of the shared lib functions. This was done for the following reasons: they were a low-hanging fruit to implement, they can be used as examples for the remaining command migrations and they provided a way for me to smoke test the shared lib function behaviors were correct.

Testing

This is also a little messy. But you don't have to suffer that much as I did.

  • Checkout this branch. Ensure you're running a compatible Node version (20.x or 22.x). Run yarn && yarn build.
  • Create a test app:
    heroku apps:create my-heroku-connect-test-app
  • Add a PostgreSQL add-on:
    heroku addons:create heroku-postgresql -a my-heroku-connect-test-app
  • Add the Heroku connect add-on:
    heroku addons:create herokuconnect -a my-heroku-connect-test-app
  • Install the Heroku Connect CLI plugin if you don't have it:
    heroku plugins:install @heroku-cli/heroku-connect-plugin
  • Now the part were I suffered, but you shouldn't. Unless you have a prod Salesforce Org that you can access, ask Arthur Louie on this Slack thread to be added to the same test Salesforce Org they added me. You'll receive an email to setup your account on the org and set a new password.
  • Go to your Heroku Connect add-on dashboard (heroku addons:open herokuconnect -a my-heroku-connect-test-app) and connect your add-on to the Salesforce Org with the credentials you just set. Create also a read-only Mapping to some Salesforce Org object, I chose Foo__c because it only has 1 record.
  • Exercise the migrated commands (connect:write-errors and connect:mapping:write-errors) both with the current plugin implementation and with the migrated commands (using ./bin/run ... instead of heroku ...).

Merging

This PR is meant to be merged on the long-lived branch prerelease/v1.0.0.

Screenshots (if applicable)

A couple screenshots with the usage of the implemented commands connect:write-errors and connect:mapping:write-errors ran both with the current plugin implementation and the migrated ones:

Captura de pantalla 2025-07-17 a la(s) 10 36 30 a  m Captura de pantalla 2025-07-17 a la(s) 10 39 57 a  m

SOC2 Compliance

Gus Work Item: W-17567704 (Heroku internal)

@sbosio sbosio requested a review from a team as a code owner July 17, 2025 14:49
Copy link

@k80bowman k80bowman left a comment

Choose a reason for hiding this comment

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

I have a couple of small comments, but overall this is amazing. Thank you for doing all of this and adding the tests. This is a big improvement.

@sbosio sbosio requested a review from k80bowman July 17, 2025 22:25
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