Skip to content
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

Remove Lerna and (mostly) set up TypeScript #1183

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Conversation

camden11
Copy link
Contributor

@camden11 camden11 commented Sep 25, 2024

Description and Context

This PR pulls everything except the actual HubSpot CLI out of this repo, and changes it from a monorepo into a repo strictly dedicated to the CLI. It also does some basic setup for typescript, and adds a typescript build step that is integrated into local commands and the release flow. For the most part, this just moves everything that existed in packages/cli before to the root of the repo. In a few places (such as package.json) I did my best to combine the top level version with the version that existed in packages/cli.

Some other things here off the top of my head

  • Random cleanup and housekeeping, like updating readme in some places and removing references to cms-cli
  • New release scripts - they should function the same as the lerna ones (and have been tested with --dry-run!) but the actual commands themselves to release will be different
  • There were a few other side effects of not using a monorepo
    • We can't use workspaces anymore, which automatically installed deps in acceptance-tests. I added a yarn install to the beginning of the test command to make sure deps are installed when you run.
    • Previously, the CLI was technically a dependancy of the top level repo. This let us run the CLI's bin commands directly from the monorepo. Since that's not the case anymore, I set up a new script in the package.json for running commands locally. I figured we probably didn't need to run hscms locally anymore, but I can add one for that too if we want to
  • There will be merge conflicts every time anything is changed in the CLI, so at this point i'll probably wait until this is ready to merge to take care of all of those

As part of this PR, webpack-cms-plugins and serverless-dev-runtime were removed from this repo. Here are their new repos:

There have been some version updates since I made the repos, so we'll need to get those in sync with their current versions so we don't run into issues if/when we ever want to release those again. We will also need to update webpack-cms-plugins to be public

TODO

  • There is still some setup that needs to be done to get the unit tests to work with typescript files. Right now, if you attempt to actually change any files to TS, you get syntax errors in the tests (since they don't expect typescript). I tried using the ts-jest preset, but this resulted in type errors in the tests. There's probably an easy solution for this, but I figured it could wait until later since this PR is already so huge.

Testing

  • The main way to test this is to run commands locally.
  • It might also be worth npm linking serverless-dev-runtime and making sure that still works as expected.
  • I've tested the release commands using npm publish --dry-run and it seems like they work as expected. I set up this branch do test releases so feel free to check it out locally and try yourself https://github.com/HubSpot/hubspot-cli/tree/remove-lerna-test-release

Who to Notify

@joe-yeager @kemmerle @brandenrodgers

- name: Verify package dependencies
run: |
yarn check-deps
npx depcheck
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we don't have multiple packages in the repo, this is a bit simpler and we don't need the custom script. Figured it makes sense to just use npx (they suggest it on their npm docs https://www.npmjs.com/package/depcheck)


1. Run `yarn publish-prerelease`. The publish command will handle bumping the version, tagging via git, and publishing the packages to NPM under the `next` dist-tag.
1. If there are publishing errors, you can run again via `yarn lerna publish from-package --dist-tag next` ([Docs][from-package]).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to update this with the new release commands, but wasn't sure if it even made a ton of sense to have release documentation on a public repo

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'm fine with removing this 👍 we can keep it internal

} = require('../../../../hubspot-local-dev-lib/dist/config');
const {
fetchScopeData,
} = require('../../../../hubspot-local-dev-lib/dist/api/localDevAuth');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

somehow these imports got messed up on the next branch

package.json Outdated
"release:patch": "yarn check-main && yarn version --patch && yarn pub && yarn push",
"prerelease:major": "yarn check-main && yarn version --premajor --preeid=beta && yarn pub && yarn push",
"prerelease:minor": "yarn check-main && yarn version --preminor --preeid=beta && yarn pub && yarn push",
"prerelease:patch": "yarn check-main && yarn version --prepatch --preeid=beta && yarn pub && yarn push",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are our new release scripts. They match the ones in local-dev-lib but add 3 new ones to do prereleases

Base automatically changed from next to main October 1, 2024 19:35
README.md Outdated

```bash
hs hubdb delete <id or name>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to take the opportunity to give a rundown of project and sandbox commands here?

Copy link
Contributor

Choose a reason for hiding this comment

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

UPDATE after sync: Let's delete the commands list and link to the docs.

"name": "hubspot-local-dev-tools",
"version": "1.0.0",
"description": "Local development tools for working with HubSpot",
"name": "@hubspot/cli",
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh jeez, this needed an update!

"scripts": {
"check-deps": "node bin/depcheck.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remind me what's happening with depcheck? Do we not need this command anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still using it, but we didn't need a custom script anymore so we're just using npx (see my comment above on build.yml)

@camden11 camden11 changed the title Remove lerna Remove Lerna and (mostly) set up TypeScript Oct 4, 2024
@camden11 camden11 marked this pull request as ready for review October 4, 2024 17:24
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.

3 participants