Project Commands
Preview
The project commands are a preview. Output fields, including --json output, and flags may change before they are stable.
Inspect the server-side entry points of a project from its source: which controller endpoints exist, what runs for each request and which cartridge it comes from, which hooks are registered and in what order, how Custom APIs are wired, and which custom job steps exist. The commands read the cartridges under the project directory (--project-directory, or the current directory; folders with a .project file), need no instance or credentials, and support --json for scripts and AI assistants.
Cartridge order
Results follow your cartridge path, the same order the platform uses for */cartridge/... requires and module.superModule. The order comes from the first of these that's available:
- The
cartridgesvalue indw.jsonorSFCC_CARTRIDGES. - A site's cartridge path from a site import in the project (
sites/<site-id>/site.xml, for example in a site template or a migration). When there are several, the newest one is used. With several sites, setsiteId(orSFCC_SITE_ID) to choose one. - The order the cartridges are found on disk, with
app_storefront_baseandmoduleslast.
b2c project index shows which one it used. For accurate results, set cartridges to your site's cartridge path. The CLI doesn't read the cartridge path from the instance; the MCP project tools can.
Only cartridges on the path are used: the site doesn't run the others, so their controllers, overlays, hooks, Custom APIs, and job steps are left out, and b2c project index lists them as not on the path. Pass --all-cartridges to any b2c project command to include them after the path cartridges, as if the site ran them all. With a guessed order, every cartridge is used.
List commands are for finding things quickly; b2c project endpoints get drills into one endpoint.
b2c project endpoints list
List storefront controller endpoints (SFRA routes and SiteGenesis guard actions) with the methods they accept, the cartridge that serves each one, and the cartridges that change it. SFRA routes are composed across cartridges (server.extend(module.superModule) with append, prepend, and replace), so each row shows the endpoint as it is served.
Usage
b2c project endpoints list [filter]Arguments
| Argument | Description | Required |
|---|---|---|
filter | Only endpoints whose ID contains this text (case-insensitive) | No |
Flags
| Flag | Description | Default |
|---|---|---|
--cartridge | Only endpoints this cartridge defines or changes | |
--uses | Only endpoints whose middleware includes this text, such as userLoggedIn or csrf | |
--extended, -x | Also show the middleware, as written in the controller, and the file that defines the route | false |
With --json, each endpoint has id, kind, methods, cartridge, cartridges (every cartridge that builds the route), middleware, relPath, line, and file.
Examples
b2c project endpoints list
b2c project endpoints list Cart-
b2c project endpoints list --cartridge int_paypal
b2c project endpoints list --uses csrfProtection.validateAjaxRequest
b2c project endpoints list --jsonb2c project endpoints get
Show what runs for one endpoint:
- Runs: the middleware and handlers in order, the cartridge each comes from, whether
server.prependorserver.appendadded it, and where each middleware is implemented. - Route event listeners: code registered with
this.on('route:BeforeComplete', ...)(orroute:Complete,route:Redirect), in the order it runs, markedconditionalwhen it's registered only in some cases.route:BeforeCompletelisteners run after the last step, just before the response is rendered, so they're easy to miss when reading the route. - Defined by: the statements across cartridges that built the route, including what a
server.replace()removed.
Usage
b2c project endpoints get <id>Example
$ b2c project endpoints get Cart-AddCoupon
Cart-AddCoupon (SFRA)
Served by: cartridges/app_storefront_base/cartridge/controllers/Cart.js:535
Accepts: GET · HTTPS required · login not required · CSRF middleware
Runs (in order):
1. server.middleware.get — GET only app_storefront_base .../Cart.js:535
2. server.middleware.https — HTTPS required app_storefront_base .../Cart.js:537
3. csrfProtection.validateAjaxRequest — CSRF check (AJAX) app_storefront_base .../Cart.js:538 → .../scripts/middleware/csrf.js:36
4. Handler app_storefront_base .../Cart.js:539
Defined by:
server.get app_storefront_base .../Cart.js:535IDs are matched case-insensitively. With --json, the result has the full endpoint (with chain, events, and steps) and its issues.
b2c project hooks list
List hook registrations by extension point, in cartridge path order.
- System extension points (
dw.*, including OCAPI/SCAPI hooks such asdw.ocapi.shop.basket.afterPOST): registrations run in cartridge path order, and the first one that returns a value (such as aStatus) skips the later registrations and the system implementation. The command flags OCAPI/SCAPI hooks that can return a value, and any system hook that would skip later registrations. When the last registration of another system hook (such asdw.order.calculate) returns a value, it is noted as replacing the system implementation. - Custom extension points: every registration runs, whatever it returns. The caller chooses the function (
HookMgr.callHook(name, functionName, ...)), so the command lists the script's exported functions, then each function the project calls with its line and number of callers.
With --json, each registration includes registeredIn (the hooks.json file and line) and, for custom hooks, calledFunctions (each function the project calls, with its line and call sites).
Usage
b2c project hooks list [filter]| Flag | Description | Default |
|---|---|---|
--issues | Only extension points or registrations with issues | false |
Examples
b2c project hooks list
b2c project hooks list dw.ocapi.shop.basket
b2c project hooks list --issues --jsonb2c project apis list
List Custom API endpoints from each cartridge's rest-apis/<api>/api.json, joined with the operation in schema.yaml (method, path, security scheme, and scopes) and the implementing function. Problems are reported: no operation with the endpoint's operationId, a missing implementation script or export, a missing .public = true, and APIs defined in more than one cartridge.
Usage
b2c project apis list [filter]| Flag | Description | Default |
|---|---|---|
--issues | Only APIs or endpoints with problems | false |
--extended, -x | Show the implementation file and line | false |
b2c project job-steps list
List custom job steps registered in each cartridge's steptypes.json, with their kind (task or chunk), parameters, and the module and function that implement them. Steps whose module can't be found or doesn't export the function are flagged.
Usage
b2c project job-steps list [filter]| Flag | Description | Default |
|---|---|---|
--cartridge | Only step types registered by this cartridge | |
--extended, -x | Show the implementing file, function, and line | false |
With --json, each step has typeId, kind, cartridge, module, function, description, registeredIn, implementationFile, parameters, and problems.
b2c project index
Build the whole project index and print a summary, or write it as JSON. The index lists controller endpoints with their composed middleware chains and the statements that built them, hooks, Custom APIs, and custom job step types. The same index drives the route rules in b2c security scan and the VS Code Endpoints view, and is available to Node.js programs as @salesforce/b2c-tooling-sdk/project-index.
Usage
b2c project index [paths...]| Argument | Description |
|---|---|
paths | Additional directories to search for cartridges (the project directory always is) |
| Flag | Description |
|---|---|
--output | Write the index JSON to this file |
Examples
b2c project index
b2c project index --json
b2c project index --output project-index.json