Skip to content

Commit 8cddaf5

Browse files
committed
docs and nit
1 parent a821e4a commit 8cddaf5

2 files changed

Lines changed: 89 additions & 4 deletions

File tree

packages/b2c-tooling/src/cli/index.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,88 @@
1+
/**
2+
* CLI utilities and base command classes for building B2C Commerce CLI commands.
3+
*
4+
* This module provides reusable base classes, configuration loading, and table
5+
* rendering utilities for oclif-based CLI applications.
6+
*
7+
* ## Base Command Classes
8+
*
9+
* Extend these classes to create CLI commands with pre-configured functionality:
10+
*
11+
* - {@link BaseCommand} - Foundation class with logging, JSON output, and error handling
12+
* - {@link OAuthCommand} - Adds OAuth authentication setup
13+
* - {@link InstanceCommand} - Adds B2C Commerce instance configuration
14+
* - {@link CartridgeCommand} - Adds cartridge path configuration for code operations
15+
* - {@link JobCommand} - Adds job execution configuration
16+
* - {@link MrtCommand} - Adds Managed Runtime API authentication
17+
* - {@link OdsCommand} - Adds On-Demand Sandbox configuration
18+
*
19+
* ## Command Hierarchy
20+
*
21+
* Commands inherit in a chain, each adding specific functionality:
22+
*
23+
* ```
24+
* BaseCommand
25+
* └─ OAuthCommand (adds OAuth)
26+
* └─ InstanceCommand (adds instance config)
27+
* ├─ CartridgeCommand (adds cartridge paths)
28+
* └─ JobCommand (adds job config)
29+
* └─ MrtCommand (adds MRT API auth)
30+
* └─ OdsCommand (adds ODS config)
31+
* ```
32+
*
33+
* ## Example Usage
34+
*
35+
* ```typescript
36+
* import { InstanceCommand, createTable, type ColumnDef } from '@salesforce/b2c-tooling/cli';
37+
*
38+
* export default class ListSites extends InstanceCommand {
39+
* static description = 'List all sites on the instance';
40+
*
41+
* async run() {
42+
* const client = await this.createOcapiClient();
43+
* const sites = await client.getSites();
44+
*
45+
* const columns: Record<string, ColumnDef<Site>> = {
46+
* id: { header: 'ID', get: (s) => s.id },
47+
* name: { header: 'Name', get: (s) => s.display_name },
48+
* };
49+
*
50+
* createTable(columns).render(sites, ['id', 'name']);
51+
* }
52+
* }
53+
* ```
54+
*
55+
* ## Configuration Loading
56+
*
57+
* Use {@link loadConfig} to resolve configuration from multiple sources:
58+
*
59+
* ```typescript
60+
* import { loadConfig } from '@salesforce/b2c-tooling/cli';
61+
*
62+
* const config = await loadConfig({
63+
* flags: { hostname: 'example.com' },
64+
* configPath: './dw.json',
65+
* });
66+
* ```
67+
*
68+
* ## Table Rendering
69+
*
70+
* Use {@link createTable} for consistent tabular output:
71+
*
72+
* ```typescript
73+
* import { createTable, type ColumnDef } from '@salesforce/b2c-tooling/cli';
74+
*
75+
* const columns: Record<string, ColumnDef<Item>> = {
76+
* id: { header: 'ID', get: (item) => item.id },
77+
* status: { header: 'Status', get: (item) => item.status },
78+
* };
79+
*
80+
* createTable(columns).render(items, ['id', 'status']);
81+
* ```
82+
*
83+
* @module cli
84+
*/
85+
186
// Base command classes
287
export {BaseCommand} from './base-command.js';
388
export type {Flags, Args} from './base-command.js';

packages/b2c-tooling/src/operations/code/watch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export async function watchCartridges(
140140

141141
logger.debug({count: cartridges.length}, `Watching ${cartridges.length} cartridge(s)`);
142142
for (const c of cartridges) {
143-
logger.debug({cartridge: c.name, path: c.src}, ` ${c.name}`);
143+
logger.info({cartridge: c.name, path: c.src}, ` ${c.name}`);
144144
}
145145

146146
const webdav = instance.webdav;
@@ -196,7 +196,7 @@ export async function watchCartridges(
196196
const content = await fs.promises.readFile(f.src);
197197
zip.file(f.dest, content);
198198
} catch (error) {
199-
logger.debug({file: f.src, error}, 'Failed to add file to archive');
199+
logger.warn({file: f.src, error}, 'Failed to add file to archive');
200200
}
201201
}
202202

@@ -248,7 +248,7 @@ export async function watchCartridges(
248248
const deletePath = `${webdavLocation}/${f.dest}`;
249249
try {
250250
await webdav.delete(deletePath);
251-
logger.debug({file: deletePath}, `Deleted: ${deletePath}`);
251+
logger.info({file: deletePath}, `Deleted: ${deletePath}`);
252252
} catch (error) {
253253
logger.debug({file: deletePath, error}, `Failed to delete ${deletePath}`);
254254
}
@@ -269,7 +269,7 @@ export async function watchCartridges(
269269

270270
watcher.on('all', (event, p) => {
271271
const fullPath = path.resolve(cwd, p);
272-
logger.debug({event, path: fullPath}, `File event: ${event} ${fullPath}`);
272+
logger.info({event, path: fullPath}, `File event: ${event} ${fullPath}`);
273273

274274
if (event === 'change' || event === 'add') {
275275
filesToUpload.add(fullPath);

0 commit comments

Comments
 (0)