Skip to content

@salesforce/b2c-tooling-sdk / cli / InstanceCommand

Abstract Class: InstanceCommand<T>

Defined in: packages/b2c-tooling-sdk/src/cli/instance-command.ts:41

Base command for B2C instance operations. Use this for commands that interact with a specific B2C instance (sites, code upload, jobs, etc.)

Environment variables:

  • SFCC_SERVER: B2C instance hostname
  • SFCC_WEBDAV_SERVER: Separate WebDAV hostname (optional)
  • SFCC_CODE_VERSION: Code version
  • SFCC_USERNAME: Username for Basic Auth
  • SFCC_PASSWORD: Password/access key for Basic Auth
  • Plus all from OAuthCommand (SFCC_CLIENT_ID, SFCC_CLIENT_SECRET)

Provides:

  • Server/hostname connection flags
  • Both Basic auth and OAuth support
  • Unified B2CInstance with typed API clients

Example

ts
export default class MySiteCommand extends InstanceCommand<typeof MySiteCommand> {
  async run(): Promise<void> {
    // Single instance for all operations
    const { data } = await this.instance.ocapi.GET('/sites', {});
    await this.instance.webdav.mkcol('Cartridges/v1');
  }
}

Extends

Extended by

Type Parameters

T

T extends typeof Command

Constructors

Constructor

new InstanceCommand<T>(argv, config): InstanceCommand<T>

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:77

Parameters

argv

string[]

config

Config

Returns

InstanceCommand<T>

Inherited from

OAuthCommand.constructor

Properties

argv

argv: string[]

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:12

Inherited from

OAuthCommand.argv


config

config: Config

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:13

Inherited from

OAuthCommand.config


id

id: string | undefined

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:75

Inherited from

OAuthCommand.id


parsed

parsed: boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:76

Inherited from

OAuthCommand.parsed


aliases

static aliases: string[]

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:16

An array of aliases for this command.

Inherited from

OAuthCommand.aliases


args

static args: ArgInput

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:18

An order-dependent object of arguments for the command

Inherited from

OAuthCommand.args


baseFlags

static baseFlags: object

Defined in: packages/b2c-tooling-sdk/src/cli/instance-command.ts:42

account-manager-host

account-manager-host: OptionFlag<string, CustomOptions>

auth-methods

auth-methods: OptionFlag<string[] | undefined, CustomOptions>

client-id

client-id: OptionFlag<string | undefined, CustomOptions>

client-secret

client-secret: OptionFlag<string | undefined, CustomOptions>

code-version

code-version: OptionFlag<string | undefined, CustomOptions>

config

config: OptionFlag<string | undefined, CustomOptions>

debug

debug: BooleanFlag<boolean>

extra-body

extra-body: OptionFlag<string | undefined, CustomOptions>

extra-query

extra-query: OptionFlag<string | undefined, CustomOptions>

instance

instance: OptionFlag<string | undefined, CustomOptions>

json

json: BooleanFlag<boolean>

lang

lang: OptionFlag<string | undefined, CustomOptions>

log-level

log-level: OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, CustomOptions>

password

password: OptionFlag<string | undefined, CustomOptions>

scope

scope: OptionFlag<string[] | undefined, CustomOptions>

server

server: OptionFlag<string | undefined, CustomOptions>

short-code

short-code: OptionFlag<string | undefined, CustomOptions>

username

username: OptionFlag<string | undefined, CustomOptions>

webdav-server

webdav-server: OptionFlag<string | undefined, CustomOptions>

Overrides

OAuthCommand.baseFlags


deprecateAliases?

static optional deprecateAliases: boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:23

Emit deprecation warning when a command alias is used

Inherited from

OAuthCommand.deprecateAliases


deprecationOptions?

static optional deprecationOptions: Deprecation

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:24

Inherited from

OAuthCommand.deprecationOptions


description

static description: string | undefined

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:30

A full description of how to use the command.

If no summary, the first line of the description will be used as the summary.

Inherited from

OAuthCommand.description


enableJsonFlag

static enableJsonFlag: boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:31

Inherited from

OAuthCommand.enableJsonFlag


examples

static examples: Example[]

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:46

An array of examples to show at the end of the command's help.

IF only a string is provided, it will try to look for a line that starts with the cmd.bin as the example command and the rest as the description. If found, the command will be formatted appropriately.

EXAMPLES:
  A description of a particular use case.

    $ <%= config.bin => command flags

Inherited from

OAuthCommand.examples


flags

static flags: FlagInput

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:48

A hash of flags for the command

Inherited from

OAuthCommand.flags


hasDynamicHelp

static hasDynamicHelp: boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:49

Inherited from

OAuthCommand.hasDynamicHelp


help

static help: string | undefined

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:50

Inherited from

OAuthCommand.help


hidden

static hidden: boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:52

Hide the command from help

Inherited from

OAuthCommand.hidden


hiddenAliases

static hiddenAliases: string[]

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:54

An array of aliases for this command that are hidden from help.

Inherited from

OAuthCommand.hiddenAliases


id

static id: string

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:56

A command ID, used mostly in error or verbose reporting.

Inherited from

OAuthCommand.id


plugin

static plugin: Plugin | undefined

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:57

Inherited from

OAuthCommand.plugin


pluginAlias?

readonly static optional pluginAlias: string

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:58

Inherited from

OAuthCommand.pluginAlias


pluginName?

readonly static optional pluginName: string

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:59

Inherited from

OAuthCommand.pluginName


pluginType?

readonly static optional pluginType: string

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:60

Inherited from

OAuthCommand.pluginType


state?

static optional state: string

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:62

Mark the command as a given state (e.g. beta or deprecated) in help

Inherited from

OAuthCommand.state


strict

static strict: boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:64

When set to false, allows a variable amount of arguments

Inherited from

OAuthCommand.strict


summary?

static optional summary: string

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:69

The tweet-sized description for your class, used in a parent-commands sub-command listing and as the header for the command help.

Inherited from

OAuthCommand.summary


usage

static usage: string | string[] | undefined

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:73

An override string (or strings) for the default usage documentation.

Inherited from

OAuthCommand.usage

Methods

error()

Call Signature

error(input, options): void

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:90

Parameters
input

string | Error

options

object & PrettyPrintableError

Returns

void

Inherited from

OAuthCommand.error

Call Signature

error(input, options?): never

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:94

Parameters
input

string | Error

options?

object & PrettyPrintableError

Returns

never

Inherited from

OAuthCommand.error


exit()

exit(code?): never

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:98

Parameters

code?

number

Returns

never

Inherited from

OAuthCommand.exit


init()

init(): Promise<void>

Defined in: packages/b2c-tooling-sdk/src/cli/base-command.ts:80

Returns

Promise<void>

Inherited from

OAuthCommand.init


jsonEnabled()

jsonEnabled(): boolean

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:106

Determine if the command is being run with the --json flag in a command that supports it.

Returns

boolean

true if the command supports json and the --json flag is present

Inherited from

OAuthCommand.jsonEnabled


log()

log(message?, ...args?): void

Defined in: packages/b2c-tooling-sdk/src/cli/base-command.ts:144

Override oclif's log() to use pino.

Parameters

message?

string

args?

...unknown[]

Returns

void

Inherited from

OAuthCommand.log


logToStderr()

logToStderr(message?, ...args?): void

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:109

Parameters

message?

string

args?

...any[]

Returns

void

Inherited from

OAuthCommand.logToStderr


run()

abstract run(): Promise<any>

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:114

actual command run code goes here

Returns

Promise<any>

Inherited from

OAuthCommand.run


warn()

warn(input): string | Error

Defined in: packages/b2c-tooling-sdk/src/cli/base-command.ts:153

Override oclif's warn() to use pino.

Parameters

input

string | Error

Returns

string | Error

Inherited from

OAuthCommand.warn


run()

static run<T>(this, argv?, opts?): Promise<ReturnType<T["run"]>>

Defined in: node_modules/.pnpm/@oclif+core@4.8.0/node_modules/@oclif/core/lib/command.d.ts:86

instantiate and run the command

Type Parameters

T

T extends Command

Parameters

this

(argv, config) => T

the command class

argv?

string[]

argv

opts?

LoadOptions

options

Returns

Promise<ReturnType<T["run"]>>

result

Inherited from

OAuthCommand.run

All rights reserved.