|
1 | | - |
2 | 1 | # B2C CLI and Tooling SDK |
3 | 2 |
|
4 | | -## Features |
| 3 | +[](https://github.com/SalesforceCommerceCloud/b2c-cli/actions/workflows/ci.yml) |
5 | 4 |
|
6 | | -- Separate CLI and SDK |
7 | | -- Logging |
8 | | - - redaction |
9 | | -- Localization Support |
10 | | -- supply chain security |
| 5 | +Salesforce Commerce Cloud B2C Command Line Tools. |
| 6 | + |
| 7 | +## Features |
11 | 8 |
|
12 | | -## CLI |
| 9 | +- Separate CLI and SDK packages |
| 10 | +- Structured logging with redaction |
| 11 | +- Localization support (i18next) |
| 12 | +- Supply chain security via pnpm |
13 | 13 |
|
14 | | -See [CLI README](./packages/b2c-cli/README.md) for more details. |
| 14 | +## Packages |
15 | 15 |
|
16 | | -## Tooling SDK |
| 16 | +This is a pnpm monorepo with the following packages: |
17 | 17 |
|
18 | | -See [Tooling SDK README](./packages/b2c-tooling/README.md) for more details. |
| 18 | +| Package | Description | |
| 19 | +|---------|-------------| |
| 20 | +| [`@salesforce/b2c-cli`](./packages/b2c-cli/README.md) | Command line interface built with oclif | |
| 21 | +| [`@salesforce/b2c-tooling`](./packages/b2c-tooling/README.md) | SDK/library for B2C Commerce operations; supports the CLI and can be used standalone | |
19 | 22 |
|
20 | 23 | ## Development |
21 | 24 |
|
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +- Node.js >= 22.16.0 |
| 28 | +- pnpm 10.17.1+ |
| 29 | + |
| 30 | +### Setup |
| 31 | + |
22 | 32 | ```bash |
23 | 33 | pnpm install |
24 | | -pnpm start # start the cli in dev mode; see CLI readme for more details |
| 34 | +``` |
| 35 | + |
| 36 | +### Running the CLI in Development Mode |
| 37 | + |
| 38 | +```bash |
| 39 | +pnpm start |
| 40 | +# or directly: |
| 41 | +pnpm --filter @salesforce/b2c-cli run dev |
| 42 | +# or using convenience script: |
| 43 | +./cli |
| 44 | +``` |
| 45 | + |
| 46 | +The dev mode uses Node.js `--conditions=development` to resolve TypeScript source files directly from `@salesforce/b2c-tooling` without needing to build first. |
| 47 | + |
| 48 | +### Building |
| 49 | + |
| 50 | +```bash |
| 51 | +# Build all packages |
| 52 | +pnpm -r run build |
| 53 | + |
| 54 | +# Build individual packages |
| 55 | +pnpm --filter @salesforce/b2c-cli run build |
| 56 | +pnpm --filter @salesforce/b2c-tooling run build |
| 57 | +``` |
| 58 | + |
| 59 | +### Testing and Linting |
| 60 | + |
| 61 | +```bash |
| 62 | +# Run all tests (also runs linter after tests) |
25 | 63 | pnpm test |
| 64 | + |
| 65 | +# Run linter only |
| 66 | +pnpm --filter @salesforce/b2c-cli run lint |
| 67 | +pnpm --filter @salesforce/b2c-tooling run lint |
26 | 68 | ``` |
27 | 69 |
|
28 | | -Docs development |
| 70 | +### Code Formatting |
| 71 | + |
| 72 | +This project uses Prettier for code formatting. |
| 73 | + |
| 74 | +```bash |
| 75 | +# Format all packages |
| 76 | +pnpm -r run format |
| 77 | + |
| 78 | +# Check formatting without modifying files |
| 79 | +pnpm -r run format:check |
| 80 | +``` |
| 81 | + |
| 82 | +## Documentation |
| 83 | + |
| 84 | +Documentation is built using [TypeDoc](https://typedoc.org/) for API reference generation and [VitePress](https://vitepress.dev/) for the documentation site. |
| 85 | + |
| 86 | +### Structure |
| 87 | + |
| 88 | +- `docs/` - VitePress documentation source |
| 89 | + - `guide/` - User guide and getting started |
| 90 | + - `cli/` - CLI command reference |
| 91 | + - `api/` - Generated API documentation (do not edit manually) |
| 92 | +- `typedoc.json` - TypeDoc configuration with entry points for SDK modules |
| 93 | + |
| 94 | +### Development Server |
29 | 95 |
|
30 | 96 | ```bash |
31 | 97 | pnpm run docs:dev |
32 | 98 | ``` |
| 99 | + |
| 100 | +This runs `typedoc` to generate API docs, then starts VitePress in development mode with hot reload. |
| 101 | + |
| 102 | +### Building Documentation |
| 103 | + |
| 104 | +```bash |
| 105 | +pnpm run docs:build |
| 106 | +``` |
| 107 | + |
| 108 | +### Previewing Built Documentation |
| 109 | + |
| 110 | +```bash |
| 111 | +pnpm run docs:preview |
| 112 | +``` |
| 113 | + |
| 114 | +### API Documentation |
| 115 | + |
| 116 | +API documentation is auto-generated from JSDoc comments in the `@salesforce/b2c-tooling` package. The entry points are defined in `typedoc.json`: |
| 117 | + |
| 118 | +See the [documentation site](https://verbose-adventure-1eqmr1r.pages.github.io/) for the generated API reference. |
| 119 | + |
| 120 | +- `auth` - Authentication strategies (OAuth, API Key, Basic) |
| 121 | +- `instance` - B2C instance configuration |
| 122 | +- `platform` - MRT and ODS clients |
| 123 | +- `operations/code` - Cartridge code operations |
| 124 | +- `operations/jobs` - Job execution |
| 125 | +- `operations/sites` - Site management |
| 126 | +- `i18n` - Internationalization utilities |
| 127 | +- `logging` - Structured logging |
| 128 | + |
| 129 | +When adding new public APIs, ensure they have comprehensive JSDoc comments as these will appear in the generated documentation. |
| 130 | + |
| 131 | +## Package Exports |
| 132 | + |
| 133 | +The `@salesforce/b2c-tooling` package uses the `exports` field in package.json to define its public API surface. Each module is available as a subpath export: |
| 134 | + |
| 135 | +```typescript |
| 136 | +import { OAuthStrategy } from '@salesforce/b2c-tooling/auth'; |
| 137 | +import { B2CInstance } from '@salesforce/b2c-tooling/instance'; |
| 138 | +import { getLogger } from '@salesforce/b2c-tooling/logging'; |
| 139 | +``` |
| 140 | + |
| 141 | +The `development` condition in exports enables direct TypeScript source resolution when using `--conditions=development`, which is how `bin/dev.js` works for local development. |
0 commit comments