Skip to content

Commit

Permalink
Merge pull request #1183 from HubSpot/remove-lerna
Browse files Browse the repository at this point in the history
Remove Lerna and (mostly) set up TypeScript
  • Loading branch information
camden11 authored Oct 16, 2024
2 parents a503215 + e735b3d commit 3a322f9
Show file tree
Hide file tree
Showing 223 changed files with 2,097 additions and 6,797 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
tmp
dist
coverage
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ jobs:
- name: Install deps
run: |
yarn install
- name: Bootstrap packages
- name: Install acceptance test dep
run: |
yarn lerna bootstrap
- name: Force local package symlinks
run: |
yarn lerna link --force-local
yarn install --cwd=acceptance-tests
- name: Verify package dependencies
run: |
yarn check-deps
npx depcheck --ignores=semver
- name: Lint
run: |
yarn lint
- name: Circular dependency check
run: |
yarn run madge --circular packages
yarn run madge --circular .
- name: TS Build
run: |
yarn build
- name: Test
run: |
yarn test
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ coverage
hubspot.config.yml
hubspot.config.yaml
hs-acceptance-test.config.yml
lerna-debug.log
npm-debug.log
npm-debug.log.*
*.log
.DS_Store
coverage
.env
dist

# Acceptance Tests
acceptance-tests/my-project
acceptance-tests/*.yml
acceptance-tests/*.html
acceptance-tests/test-output
acceptance-tests/test-output
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tmp
dist
coverage
358 changes: 0 additions & 358 deletions CHANGELOG.md

This file was deleted.

15 changes: 3 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ To contribute, fork this repository and create a new branch. Then create a PR. F
yarn
```

* Bootstrap `lerna`

In order to manage multiple npm packages in the same Github repos, we use [lerna](https://lerna.js.org/).

```bash
yarn lerna bootstrap
````

* To test a command

First, you will need to create a config for the accounts that you want to be able to test using.
Expand All @@ -39,19 +31,19 @@ yarn link @hubspot/cli
## Local development with local-dev-lib
When contributing to hubspot-cli, you may also need to make changes to cli-local-dev-lib. To use a local version of local-dev-lib as a dependancy, use [yarn link](https://classic.yarnpkg.com/lang/en/docs/cli/link/).
1. Run `yarn local-dev` in `local-dev-lib`
2. Run `yarn link @hubspot/local-dev-lib` in the hubspot-cli root and again in `packages/cli` to use the symlinked local package.
2. Run `yarn link @hubspot/local-dev-lib` in the hubspot-cli root to use the symlinked local package.

To stop using your local `local-dev-lib`, you can follow a similar process with [yarn unlink](https://classic.yarnpkg.com/en/docs/cli/unlink).

## Testing
Ensure you are on the minimum version of Node supported by the CLI before running any tests, since that is the version of node that the build step uses. To find the minimum,
see the `engine` entry in the [cli package.json](./packages/cli/package.json).
see the `engine` entry in the [package.json](./package.json).

Using [nvm](https://github.com/nvm-sh/nvm) to switch between versions will help speed up development.

Tests on the CLI are located in two places:
- `/acceptance-tests/tests`
- `/packages/cli/lib/__tests__`
- `/lib/__tests__`

The acceptance tests are run using `yarn test-cli`. You will need to do some configuration before being able to run the acceptance tests. See the [acceptance-tests folder](./acceptance-tests/README.md) for more information.

Expand Down Expand Up @@ -102,7 +94,6 @@ To merge, either create, or have a maintainer create a blank branch, and set you
## Documentation

- [Technical Design](./docs/TechnicalDesign.md)
- [Publishing Releases](./docs/PublishingReleases.md)
- [Debugging](./docs/Debugging.md)

## Debugging tips
Expand Down
67 changes: 58 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
# HubSpot CLI
# @hubspot/cli

[![Official Release](https://img.shields.io/npm/v/@hubspot/cli/latest?label=Official%20Release)](https://www.npmjs.com/package/@hubspot/cli) [![Latest Version](https://img.shields.io/github/lerna-json/v/HubSpot/hubspot-cli?label=Latest%20Version)](https://www.npmjs.com/package/@hubspot/cli?activeTab=versions)
[![Official Release](https://img.shields.io/npm/v/@hubspot/cli/latest?label=Official%20Release)](https://www.npmjs.com/package/@hubspot/cli) [![Latest Version](https://img.shields.io/github/v/tag/hubspot/hubspot-cli?label=Latest%20Version)](https://www.npmjs.com/package/@hubspot/cli?activeTab=versions)

A CLI for HubSpot developers to enable local CMS development and automate their work.
A CLI for HubSpot developers to enable local development and automation. [Learn more about building on HubSpot](https://developers.hubspot.com).

## Getting Started
## Contributing

See the `@hubspot/cli` [README](./packages/cli/README.md)
For more information on developing, see the [Contributing Guide](CONTRIBUTING.md).

See the node.js `local-dev-lib` library [README](https://github.com/HubSpot/hubspot-local-dev-lib)
## Getting started

For information on the `hubspot.config.yml` file, see [HubspotConfigFile](./docs/HubspotConfigFile.md)
For more information on using these tools, see [Local Development Tooling: Getting Started](https://developers.hubspot.com/docs/cms/guides/getting-started-with-local-development)

## Contributing
### Installation

For more information on developing, see the [Contributing Guide](CONTRIBUTING.md).
```bash
npm install -g @hubspot/cli
```

### Configuring

Once the `@hubspot/cli` has been added to a project, a config file named [hubspot.config.yml](../../docs/HubspotConfigFile.md) will also be needed. It is recommended that the config file is kept in your `$HOME` directory.

```bash
cd ~
hs init
```

#### Auto Completion

You can set up command autocompletion by running

```bash
hs completion
```

and copying the output to either your `.bashrc` or `.zshrc`, and then sourcing that file `source ~/.bashrc` `source ~/.zshrc` or restarting your terminal.

## Commands

A full breakdown of the commands can be found on the [local development tools reference page](https://developers.hubspot.com/docs/cms/developer-reference/local-development-cli).

**Note:** When `@hubspot/cli` is installed local to a project, the commands need to be prefixed with either `yarn` if using `yarn` or `npx` if using `npm`.

## Authentication

There are two ways that the tools can authenticate with HubSpot.

### Personal Access Key (recommended)

1. Run `hs init` or `hs auth personalaccesskey` and follow the instructions

### OAuth2

1. [Create a developer app](https://developers.hubspot.com/docs/faq/how-do-i-create-an-app-in-hubspot)
2. Run `hs auth oauth2`
3. Select `OAuth2` and follow the steps

_**Note:** The Account ID used should be the Test Account ID (not the developer app ID). Client ID and Client Secret are from the developer app._
### Exit Codes

The CLI will exit with one of the following exit codes:
- `0`: A successful run
- `1`: There was a config problem or an internal error
- `2`: There are warnings or validation issues
4 changes: 2 additions & 2 deletions acceptance-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To setup these tests, there are two required arguments and one optional one:
1. The ID of a HubSpot account that you are a user in
2. Your generated personal access key in that account (available in [personal access key ui](https://app.hubspot.com/l/personal-access-key))
3. [Optional] A path to an instance of the CLI. The test runner will execute the commands against this provided instance
- The default behavior is to use `../packages/cli/bin/hs`
- The default behavior is to use `../bin/hs`

### Configuration

Expand All @@ -39,7 +39,7 @@ export CLI_PATH="hs"

### Running Locally

1. Run `lerna bootstrap` to install dependencies
1. Run `yarn` to install dependencies
2. Run `yarn test-cli` from the root of the CLI repo

**NOTE:** Include the `--debug` flag for more verbose output
Expand Down
2 changes: 1 addition & 1 deletion acceptance-tests/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const getTestConfig = (): TestConfig => {
}

if (!config.cliPath && !config.useInstalled) {
const defaultPath = path.join(process.cwd(), '../packages/cli/bin/hs');
const defaultPath = path.join(process.cwd(), '../bin/hs');

if (existsSync(defaultPath)) {
config.cliPath = defaultPath;
Expand Down
Loading

0 comments on commit 3a322f9

Please sign in to comment.