-
Notifications
You must be signed in to change notification settings - Fork 6
chore: Update MD files #388
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Project Overview | ||
|
|
||
| This is `@hubspot/local-dev-lib` — a shared TypeScript library that provides core functionality for HubSpot local development tooling. It replaces the deprecated `@hubspot/cli-lib`. | ||
|
|
||
| **IMPORTANT** - Always make a plan and confirm the plan with the user before implementation. | ||
|
|
||
| # What This Library Does | ||
|
|
||
| - **Config utils** (`config/`) — manage HubSpot account configuration files. `getConfig()` resolves config using: env vars → global config (`~/.hscli/config.yml`) → local config (findup). Key functions: `getConfig()`, `updateConfigAccount()`, `getConfigAccountById()`, `getConfigAccountByName()`, `getLinkedOrAllConfigAccounts()`. | ||
| - **Per-directory linking** (`config/hsSettings.ts`) — `.hs/settings.json` scopes which accounts are active for a directory. Created by `hs account link`. Contains `accounts` (array of linked account IDs) and `localDefaultAccount`. | ||
| - **API utils** (`api/`) — HTTP calls to HubSpot public API endpoints. Requires a parsed config in memory. The HTTP wrapper handles auth headers and token refreshes automatically. | ||
| - **Lib utils** (`lib/`) — exported functions and modules: filesystem navigation, HubSpot account connections (sandboxes), file parsing, and GitHub integration. Anything exported from the repo should live here (excluding special cases like `config/`). | ||
| - **Internal utils** (`utils/`) — internal helper functions that are NOT exported from the repo. | ||
| - **Error utils** (`errors/`) — standardized error handling. This library throws errors rather than logging them — consumers catch and handle. Custom errors: `HubSpotHttpError` (HTTP failures with status/method/payload metadata), `HubSpotConfigError` (config issues), `FileSystemError` (FS operations with read/write context). Type predicates help identify timeouts, auth errors, and missing scopes. | ||
|
|
||
| # Key Consumers | ||
|
|
||
| - **HubSpot CLI** (`hubspot-cli`) — the primary consumer | ||
| - **VS Code extension** — uses config and API functions | ||
|
|
||
| Changes here affect all consumers. Be careful with breaking changes to exported function signatures. | ||
|
|
||
| # Testing Changes Against the CLI | ||
|
|
||
| ## Option 1: Local linking (for active development) | ||
|
|
||
| 1. In LDL: `yarn local-dev` — builds, runs `yarn link`, and watches for changes | ||
| 2. In CLI: `yarn local-link` — interactive prompt to symlink local packages | ||
| 3. Changes in LDL are reflected in the CLI after `yarn build` | ||
|
|
||
| To stop: run `yarn unlink` in LDL, then `yarn install --force` in CLI. | ||
|
|
||
| ## Option 2: Experimental NPM release (for CI testing or sharing) | ||
|
|
||
| 1. In LDL: `yarn release -v=prerelease -t=experimental` | ||
| 2. In CLI: update `package.json` to the experimental version (e.g., `"@hubspot/local-dev-lib": "0.7.5-experimental.0"`) and run `yarn install --force` | ||
|
|
||
| Experimental releases are tagged on NPM so they won't be installed by default. See [PUBLISHING.md](../../PUBLISHING.md) for full details. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # General Rules for @hubspot/local-dev-lib | ||
|
|
||
| These rules apply to ALL work in this repository. They override the managed org-wide general rules, which target HubSpot's Java/frontend stack and do not apply here. | ||
|
|
||
| ## Stack | ||
|
|
||
| This is a **shared Node.js library** consumed by the HubSpot CLI and VS Code extension: | ||
|
|
||
| - **Language**: TypeScript (strict mode, ESM) | ||
| - **Testing**: Vitest (NOT Jest, NOT jasmine, NOT bend) | ||
| - **Package manager**: yarn (NOT npm, NOT Maven) | ||
| - **Build**: `yarn build` (NOT `mcp__devex-mcp-server__build_java`, NOT `bend`) | ||
| - **Linting**: `yarn lint` (eslint + prettier, zero warnings) | ||
| - **Formatting**: `yarn prettier:write` | ||
|
|
||
| Do NOT use Java, Maven, CHIRP, bend, Trellis, or other HubSpot backend/frontend platform tools in this repo. | ||
|
|
||
| ## This is a Library, Not a CLI | ||
|
|
||
| This repo is consumed via `@hubspot/local-dev-lib` by the CLI and other tools. Key implications: | ||
|
|
||
| - No `process.exit()` — throw errors instead and let consumers handle them | ||
| - No direct user prompts — return data and let the CLI prompt | ||
| - No default exports — named exports only (enforced by ESLint `import/no-default-export`) | ||
| - All exports must be declared in `package.json` `exports` field to be consumable | ||
|
|
||
| ## Look First, Then Build | ||
|
|
||
| Before creating or modifying anything, study how the codebase already does it. | ||
|
|
||
| ### Before adding a new function | ||
|
|
||
| 1. Check if it already exists in `lib/`, `config/`, `api/`, or `utils/` | ||
| 2. Read comparable functions to understand the pattern | ||
| 3. Follow the same structure exactly | ||
|
|
||
| ### Before adding a new type | ||
|
|
||
| 1. Check `types/` for existing type definitions | ||
| 2. Follow the discriminated union pattern used for account types | ||
chiragchadha1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 3. Ensure the type is exported from the repo via `package.json` `exports` | ||
|
|
||
| ### Before adding user-facing strings | ||
|
|
||
| 1. All strings go in `lang/en.json` using nested keys | ||
| 2. Use the `i18n()` function with `{{ variable }}` interpolation | ||
| 3. Check existing keys for similar patterns | ||
|
|
||
| ### When you find discrepancies | ||
|
|
||
| Stop and alert the user. Do NOT silently pick one pattern over another. | ||
|
|
||
| ## Code Organization | ||
|
|
||
| - `api/` — HTTP calls to HubSpot services. Return `HubSpotPromise<T>`. | ||
| - `config/` — Config file read/write (YAML). Core account resolution logic. | ||
| - `constants/` — Shared constants | ||
| - `errors/` — Custom error classes (`HubSpotHttpError`, `HubSpotConfigError`, `FileSystemError`) | ||
| - `http/` — Axios wrapper with HubSpot auth | ||
| - `lang/` — i18n strings (`en.json`) | ||
| - `lib/` — Exported functions and modules (path, fileManager, logger, oauth, etc.). Anything exported from the repo should live here (excluding special cases like `config/`). | ||
| - `utils/` — Internal helper functions that are NOT exported from the repo | ||
| - `models/` — Business logic classes | ||
| - `types/` — TypeScript type definitions | ||
|
|
||
| ## Error Handling | ||
|
|
||
| - Throw custom error classes from `errors/`, never return error objects | ||
| - Use `HubSpotHttpError` for API failures, `HubSpotConfigError` for config issues, `FileSystemError` for FS operations | ||
| - Never call `process.exit()` — that's the consumer's responsibility | ||
|
|
||
| ## Build and Test Commands | ||
|
|
||
| - Build: `yarn build` | ||
| - All tests: `yarn test` | ||
| - Specific test: `yarn test <path>` | ||
| - Lint: `yarn lint` | ||
| - Format: `yarn prettier:write` | ||
| - Circular deps: `yarn circular-deps` | ||
| - Local dev (symlink): `yarn local-dev` | ||
|
|
||
| ## After Making Code Changes | ||
|
|
||
| Always run these steps after modifying code: | ||
|
|
||
| 1. `yarn prettier:write` — format all changed files | ||
| 2. `yarn build` — verify TypeScript compiles | ||
| 3. `yarn test <paths>` — run tests for changed files | ||
|
|
||
| ## Code Style | ||
|
|
||
| - No `any` types | ||
| - No default exports | ||
| - No comments unless explicitly asked | ||
| - No classes where functions work | ||
| - Early returns for readability | ||
| - Single quotes, 2-space indent, trailing commas, 80-char lines | ||
| - NEVER use the word "comprehensive" | ||
|
|
||
| ## What NOT to Use From Managed Rules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, good idea 👍 |
||
|
|
||
| The following tools and patterns from the org-wide managed rules do NOT apply here: | ||
|
|
||
| - `mcp__devex-mcp-server__build_java` — this is a yarn/node project | ||
| - `mcp__devex-mcp-server__get_onepager` — not required before edits in this repo | ||
| - `mcp__devex-mcp-server__search_docs` — not required before edits in this repo | ||
| - `bend` tools — not applicable | ||
| - `TrellisTools` — not applicable | ||
| - CHIRP discovery tools — not applicable | ||
| - `local_build_log_analyzer` agent — use `yarn test` / `yarn build` output directly | ||
| - `build_status_reporter` agent — use `yarn test` / `yarn build` output directly | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| paths: | ||
| - '**/__tests__/**/*.ts' | ||
| - '!node_modules/**' | ||
| - '!dist/**' | ||
| --- | ||
|
|
||
| # Test Guidelines | ||
|
|
||
| **Framework**: Vitest with globals enabled (all tests in `__tests__/` directories, co-located with source) | ||
|
|
||
| ## Rules | ||
|
|
||
| - No try/catch blocks — use `expect().toThrow()` for error testing | ||
| - All cleanup in `afterEach()` using `vi.restoreAllMocks()` | ||
| - Never skip tests — fix or remove them | ||
| - Follow the naming convention of `[file-being-tested].test.ts` | ||
|
|
||
| ## Mocking | ||
|
|
||
| - Use `vi.mock()` at module level for dependency mocking | ||
| - Use `vi.mocked()` for type-safe access to mocked functions | ||
| - When mock return values depend on input, use `mockImplementation()` over static `mockReturnValue()` | ||
| - Shared test helpers live in `__tests__/__utils__/` (e.g., `mockAxiosResponse()`) | ||
|
|
||
| ## Structure | ||
|
|
||
| ```typescript | ||
| import { vi, describe, it, expect } from 'vitest'; | ||
|
|
||
| vi.mock('../dependency.js'); | ||
|
|
||
| describe('moduleName', () => { | ||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('should do the thing', () => { | ||
| // arrange, act, assert | ||
| }); | ||
| }); | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Publishing Releases | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed |
||
|
|
||
| Only contributors who are members of the HubSpot NPM organization can publish releases. | ||
|
|
||
| ## Release Command | ||
|
|
||
| ```bash | ||
| yarn release -v=<increment> -t=<tag> | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `-v, --versionIncrement` (required): `patch`, `minor`, `major`, or `prerelease` | ||
| - `-t, --tag` (required): `latest`, `next`, or `experimental` | ||
| - `-d, --dryRun`: Run through the process without actually publishing | ||
|
|
||
| ### Examples | ||
|
|
||
| ```bash | ||
| # Patch release to latest | ||
| yarn release -v=patch -t=latest | ||
|
|
||
| # Minor release to latest | ||
| yarn release -v=minor -t=latest | ||
|
|
||
| # Major release with breaking changes | ||
| yarn release -v=major -t=latest | ||
|
|
||
| # Experimental release from a feature branch | ||
| yarn release -v=prerelease -t=experimental | ||
|
|
||
| # Dry run (test without publishing) | ||
| yarn release -v=patch -t=latest -d | ||
| ``` | ||
|
|
||
| The script handles version bumping, git tagging, and publishing to NPM. It also validates the branch, checks the version against published versions, and opens the GitHub PR/release pages. | ||
|
|
||
| ## Experimental Releases | ||
|
|
||
| Use experimental releases to test changes before merging, or to share in-progress work with the CLI team for CI validation. | ||
|
|
||
| 1. From your feature branch: `yarn release -v=prerelease -t=experimental` | ||
| 2. This publishes a version like `0.7.5-experimental.0` tagged as `experimental` on NPM | ||
| 3. It won't be installed by default — consumers must explicitly reference the version | ||
|
|
||
| To use in the CLI: | ||
|
|
||
| ```json | ||
| "@hubspot/local-dev-lib": "0.7.5-experimental.0" | ||
| ``` | ||
|
|
||
| Then run `yarn install --force` in the CLI repo. | ||
|
|
||
| ## Local Testing (without publishing) | ||
|
|
||
| For active development, use local linking instead of publishing. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details. | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.