Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,35 @@ Features:
- Supports `extended` flag on columns for optional fields
- Use `TableRenderer` class directly for column validation helpers (e.g., `--columns` flag support)

## Claude Code Skills Plugin

The `./plugins/b2c-cli/skills/` directory contains Claude Code skills that teach Claude about the CLI commands. Each skill has a `SKILL.md` file with examples and documentation.

**When modifying CLI commands:**
- Update the corresponding skill in `plugins/b2c-cli/skills/b2c-<topic>/SKILL.md` if it exists
- For breaking changes (renamed flags, removed arguments, changed behavior), update all affected examples

**Skill format:**
```markdown
---
name: b2c-<topic>
description: Brief description of what the skill teaches
---

# B2C <Topic> Skill

Overview of the command topic.

## Examples

### <Use Case>

\`\`\`bash
# comment explaining the command
b2c <topic> <command> [args] [flags]
\`\`\`
```

## Testing

Tests use Mocha + Chai with c8 for coverage. HTTP mocking uses MSW (Mock Service Worker).
Expand Down
53 changes: 31 additions & 22 deletions packages/b2c-cli/src/commands/webdav/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import * as fs from 'node:fs';
import {basename, resolve} from 'node:path';
import {Args} from '@oclif/core';
import {Args, Flags} from '@oclif/core';
import {WebDavCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {t} from '../../i18n/index.js';

Expand All @@ -21,9 +21,6 @@ export default class WebDavGet extends WebDavCommand<typeof WebDavGet> {
description: 'Remote file path relative to root',
required: true,
}),
local: Args.string({
description: 'Local destination path (defaults to filename in current directory)',
}),
};

static description = t('commands.webdav.get.description', 'Download a file from WebDAV');
Expand All @@ -32,39 +29,51 @@ export default class WebDavGet extends WebDavCommand<typeof WebDavGet> {

static examples = [
'<%= config.bin %> <%= command.id %> src/instance/export.zip',
'<%= config.bin %> <%= command.id %> src/instance/export.zip ./downloads/export.zip',
'<%= config.bin %> <%= command.id %> src/instance/export.zip -o ./downloads/export.zip',
'<%= config.bin %> <%= command.id %> --root=logs customerror.log',
'<%= config.bin %> <%= command.id %> --root=logs customerror.log -o -',
];

static flags = {
...WebDavCommand.baseFlags,
output: Flags.string({
char: 'o',
description: 'Output file path (use - for stdout, defaults to filename in current directory)',
}),
};

async run(): Promise<GetResult> {
this.ensureWebDavAuth();

const fullPath = this.buildPath(this.args.remote);

// Determine local path - default to filename in current directory
const localPath = this.args.local || basename(this.args.remote);
// Determine output path - default to filename in current directory
const outputPath = this.flags.output ?? basename(this.args.remote);
const isStdout = outputPath === '-';

this.log(t('commands.webdav.get.downloading', 'Downloading {{path}}...', {path: fullPath}));
if (!isStdout) {
this.log(t('commands.webdav.get.downloading', 'Downloading {{path}}...', {path: fullPath}));
}

const content = await this.instance.webdav.get(fullPath);

// Write to local file
const buffer = Buffer.from(content);
fs.writeFileSync(localPath, buffer);

const result: GetResult = {
if (isStdout) {
process.stdout.write(buffer);
} else {
fs.writeFileSync(outputPath, buffer);
this.log(
t('commands.webdav.get.success', 'Downloaded {{size}} bytes to {{path}}', {
size: buffer.length,
path: resolve(outputPath),
}),
);
}

return {
remotePath: fullPath,
localPath: resolve(localPath),
localPath: isStdout ? '-' : resolve(outputPath),
size: buffer.length,
};

this.log(
t('commands.webdav.get.success', 'Downloaded {{size}} bytes to {{path}}', {
size: result.size,
path: result.localPath,
}),
);

return result;
}
}
85 changes: 85 additions & 0 deletions plugins/b2c-cli/skills/b2c-code/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
name: b2c-code
description: Salesforce B2C Commerce code version deployment and management Skill
---

# B2C Code Skill

Use the `b2c` CLI plugin to deploy and manage code versions on Salesforce B2C Commerce instances.

## Examples

### Deploy Cartridges

```bash
# deploy all cartridges from current directory
b2c code deploy

# deploy cartridges from a specific directory
b2c code deploy ./my-cartridges

# deploy to a specific server and code version
b2c code deploy --server my-sandbox.demandware.net --code-version v1

# deploy and reload (re-activate) the code version
b2c code deploy --reload

# delete existing cartridges before upload and reload
b2c code deploy --delete --reload

# deploy only specific cartridges
b2c code deploy -c app_storefront_base -c plugin_applepay

# exclude specific cartridges from deployment
b2c code deploy -x test_cartridge
```

### Watch for Changes

```bash
# watch cartridges and upload changes automatically
b2c code watch

# watch a specific directory
b2c code watch ./my-cartridges

# watch with specific server and code version
b2c code watch --server my-sandbox.demandware.net --code-version v1

# watch only specific cartridges
b2c code watch -c app_storefront_base

# watch excluding specific cartridges
b2c code watch -x test_cartridge
```

### List Code Versions

```bash
# list code versions on the instance
b2c code list

# list with JSON output
b2c code list --json
```

### Activate Code Version

```bash
# activate a code version
b2c code activate <version-name>

# reload (re-activate) the current code version
b2c code activate --reload
```

### Delete Code Version

```bash
# delete a code version
b2c code delete <version-name>
```

### More Commands

See `b2c code --help` for a full list of available commands and options in the `code` topic.
76 changes: 76 additions & 0 deletions plugins/b2c-cli/skills/b2c-job/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: b2c-job
description: Salesforce B2C Commerce job execution and site archive import/export (IMPEX) Skill
---

# B2C Job Skill

Use the `b2c` CLI plugin to run jobs and import/export site archives on Salesforce B2C Commerce instances.

## Examples

### Run a Job

```bash
# run a job and return immediately
b2c job run my-custom-job

# run a job and wait for completion
b2c job run my-custom-job --wait

# run a job with a timeout (in seconds)
b2c job run my-custom-job --wait --timeout 600

# run a job with parameters
b2c job run my-custom-job -P "SiteScope={\"all_storefront_sites\":true}" -P OtherParam=value

# show job log if the job fails
b2c job run my-custom-job --wait --show-log
```

### Import Site Archives

```bash
# import a local directory as a site archive
b2c job import ./my-site-data

# import a local zip file
b2c job import ./export.zip

# keep the archive on the instance after import
b2c job import ./my-site-data --keep-archive

# import an archive that already exists on the instance (in Impex/src/instance/)
b2c job import existing-archive.zip --remote

# show job log on failure
b2c job import ./my-site-data --show-log
```

### Export Site Archives

```bash
# export site data using the job export command
b2c job export
```

### Search Job Executions

```bash
# search for job executions
b2c job search

# search with JSON output
b2c job search --json
```

### Wait for Job Completion

```bash
# wait for a specific job execution to complete
b2c job wait <execution-id>
```

### More Commands

See `b2c job --help` for a full list of available commands and options in the `job` topic.
67 changes: 67 additions & 0 deletions plugins/b2c-cli/skills/b2c-mrt/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: b2c-mrt
description: Salesforce B2C Commerce Managed Runtime (MRT) project and deployment management Skill
---

# B2C MRT Skill

Use the `b2c` CLI plugin to manage Managed Runtime (MRT) projects and deployments for PWA Kit storefronts.

## Examples

### Push Bundle to Managed Runtime

```bash
# push a bundle to MRT for a specific project
b2c mrt push --project my-storefront

# push to a specific environment (staging, production, etc.)
b2c mrt push --project my-storefront --environment staging

# push to production with a release message
b2c mrt push --project my-storefront --environment production --message "Release v1.0.0"

# push from a custom build directory
b2c mrt push --project my-storefront --build-dir ./dist

# specify Node.js version for SSR runtime
b2c mrt push --project my-storefront --node-version 20.x

# add SSR parameters
b2c mrt push --project my-storefront --ssr-param SSRProxyPath=/api

# use JSON output for automation
b2c mrt push --project my-storefront --json
```

### Manage Environments

```bash
# create a new MRT environment
b2c mrt env create

# delete an MRT environment
b2c mrt env delete
```

### Environment Variables

```bash
# manage environment variables for an MRT environment
b2c mrt env var
```

### Configuration

MRT settings can be configured in `dw.json`:
- `mrtProject`: MRT project slug
- `mrtEnvironment`: MRT environment name (staging, production, etc.)

Environment variables:
- `SFCC_MRT_PROJECT`: MRT project slug
- `SFCC_MRT_ENVIRONMENT`: MRT environment
- `SFCC_MRT_API_KEY`: MRT API key

### More Commands

See `b2c mrt --help` for a full list of available commands and options in the `mrt` topic.
33 changes: 33 additions & 0 deletions plugins/b2c-cli/skills/b2c-sites/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: b2c-sites
description: Salesforce B2C Commerce storefront sites listing and inspection Skill
---

# B2C Sites Skill

Use the `b2c` CLI plugin to list and inspect storefront sites on Salesforce B2C Commerce instances.

## Examples

### List Sites

```bash
# list all sites on the configured instance
b2c sites list

# list sites on a specific server
b2c sites list --server my-sandbox.demandware.net

# list sites with JSON output (useful for parsing/automation)
b2c sites list --json

# use a specific instance from config
b2c sites list --instance production

# enable debug logging
b2c sites list --debug
```

### More Commands

See `b2c sites --help` for a full list of available commands and options in the `sites` topic.
Loading
Loading