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
21 changes: 10 additions & 11 deletions docs/guide/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,28 @@ export default hook;
// src/sources/my-custom-source.ts
import type {
ConfigSource,
NormalizedConfig,
ConfigLoadResult,
ResolveConfigOptions
} from '@salesforce/b2c-tooling-sdk/config';

export class MyCustomSource implements ConfigSource {
readonly name = 'my-custom-source';

load(options: ResolveConfigOptions): NormalizedConfig | undefined {
load(options: ResolveConfigOptions): ConfigLoadResult | undefined {
// Load config from your custom source
// Return undefined if source is not available

return {
hostname: 'example.sandbox.us03.dx.commercecloud.salesforce.com',
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
codeVersion: 'version1',
config: {
hostname: 'example.sandbox.us03.dx.commercecloud.salesforce.com',
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
codeVersion: 'version1',
},
// Location is used for diagnostics - can be a file path, keychain entry, URL, etc.
location: '/path/to/config/source',
};
}

// Optional: return path for diagnostics
getPath(): string | undefined {
return '/path/to/config/source';
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export default class CodeActivate extends InstanceCommand<typeof CodeActivate> {
this.requireOAuthCredentials();

const codeVersionArg = this.args.codeVersion;
const hostname = this.resolvedConfig.hostname!;
const hostname = this.resolvedConfig.values.hostname!;

// Get code version from arg, flag, or config
const codeVersion = codeVersionArg ?? this.resolvedConfig.codeVersion;
const codeVersion = codeVersionArg ?? this.resolvedConfig.values.codeVersion;

if (this.flags.reload) {
// Reload mode - re-activate the code version
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/code/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class CodeDelete extends InstanceCommand<typeof CodeDelete> {
this.requireOAuthCredentials();

const codeVersion = this.args.codeVersion;
const hostname = this.resolvedConfig.hostname!;
const hostname = this.resolvedConfig.values.hostname!;

// Confirm deletion unless --force is used
if (!this.flags.force) {
Expand Down
12 changes: 7 additions & 5 deletions packages/b2c-cli/src/commands/code/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
this.requireWebDavCredentials();
this.requireOAuthCredentials();

const hostname = this.resolvedConfig.hostname!;
let version = this.resolvedConfig.codeVersion;
const hostname = this.resolvedConfig.values.hostname!;
let version = this.resolvedConfig.values.codeVersion;

// If no code version specified, discover the active one
if (!version) {
Expand Down Expand Up @@ -102,7 +102,8 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
this.error(t('commands.code.deploy.noCartridges', 'No cartridges found in {{path}}', {path: this.cartridgePath}));
}

this.log(
this.logger?.info(
{path: this.cartridgePath, server: hostname, codeVersion: version},
t('commands.code.deploy.deploying', 'Deploying {{path}} to {{hostname}} ({{version}})', {
path: this.cartridgePath,
hostname,
Expand All @@ -112,7 +113,7 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {

// Log found cartridges
for (const c of cartridges) {
this.logger?.debug(` ${c.name} (${c.src})`);
this.logger?.debug({cartridgeName: c.name, path: c.src}, ` ${c.name}`);
}

try {
Expand Down Expand Up @@ -141,7 +142,8 @@ export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
reloaded,
};

this.log(
this.logger?.info(
{codeVersion: result.codeVersion, cartridgeCount: result.cartridges.length},
t('commands.code.deploy.summary', 'Deployed {{count}} cartridge(s) to {{codeVersion}}', {
count: result.cartridges.length,
codeVersion: result.codeVersion,
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/code/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class CodeList extends InstanceCommand<typeof CodeList> {
async run(): Promise<CodeVersionResult> {
this.requireOAuthCredentials();

const hostname = this.resolvedConfig.hostname!;
const hostname = this.resolvedConfig.values.hostname!;

this.log(t('commands.code.list.fetching', 'Fetching code versions from {{hostname}}...', {hostname}));

Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default class CodeWatch extends CartridgeCommand<typeof CodeWatch> {
this.requireWebDavCredentials();
this.requireOAuthCredentials();

const hostname = this.resolvedConfig.hostname!;
const version = this.resolvedConfig.codeVersion;
const hostname = this.resolvedConfig.values.hostname!;
const version = this.resolvedConfig.values.codeVersion;

this.log(t('commands.code.watch.starting', 'Starting watcher for {{path}}', {path: this.cartridgePath}));
this.log(t('commands.code.watch.target', 'Target: {{hostname}}', {hostname}));
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/docs/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class DocsDownload extends InstanceCommand<typeof DocsDownload> {

this.log(
t('commands.docs.download.downloading', 'Downloading documentation from {{hostname}}...', {
hostname: this.resolvedConfig.hostname,
hostname: this.resolvedConfig.values.hostname,
}),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/job/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default class JobExport extends JobCommand<typeof JobExport> {
'show-log': showLog,
} = this.flags;

const hostname = this.resolvedConfig.hostname!;
const hostname = this.resolvedConfig.values.hostname!;

// Build data units configuration
const dataUnits = this.buildDataUnits({
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/job/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class JobImport extends JobCommand<typeof JobImport> {
const {target} = this.args;
const {'keep-archive': keepArchive, remote, timeout, 'show-log': showLog} = this.flags;

const hostname = this.resolvedConfig.hostname!;
const hostname = this.resolvedConfig.values.hostname!;

// Create lifecycle context
const context = this.createContext('job:import', {
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/job/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class JobRun extends JobCommand<typeof JobRun> {
parameters: rawBody ? undefined : parameters,
body: rawBody,
wait,
hostname: this.resolvedConfig.hostname,
hostname: this.resolvedConfig.values.hostname,
});

// Run beforeOperation hooks - check for skip
Expand All @@ -100,7 +100,7 @@ export default class JobRun extends JobCommand<typeof JobRun> {
this.log(
t('commands.job.run.executing', 'Executing job {{jobId}} on {{hostname}}...', {
jobId,
hostname: this.resolvedConfig.hostname!,
hostname: this.resolvedConfig.values.hostname!,
}),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/job/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class JobSearch extends InstanceCommand<typeof JobSearch> {

this.log(
t('commands.job.search.searching', 'Searching job executions on {{hostname}}...', {
hostname: this.resolvedConfig.hostname!,
hostname: this.resolvedConfig.values.hostname!,
}),
);

Expand Down
6 changes: 3 additions & 3 deletions packages/b2c-cli/src/commands/mrt/env/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default class MrtEnvCreate extends MrtCommand<typeof MrtEnvCreate> {
this.requireMrtCredentials();

const {slug} = this.args;
const {mrtProject: project} = this.resolvedConfig;
const {mrtProject: project} = this.resolvedConfig.values;

if (!project) {
this.error(
Expand Down Expand Up @@ -242,7 +242,7 @@ export default class MrtEnvCreate extends MrtCommand<typeof MrtEnvCreate> {
allowCookies: allowCookies || undefined,
enableSourceMaps: enableSourceMaps || undefined,
proxyConfigs,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
},
this.getMrtAuth(),
);
Expand All @@ -256,7 +256,7 @@ export default class MrtEnvCreate extends MrtCommand<typeof MrtEnvCreate> {
{
projectSlug: project,
slug,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
onPoll: (env) => {
if (!this.jsonEnabled()) {
const elapsed = Math.round((Date.now() - waitStartTime) / 1000);
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/mrt/env/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class MrtEnvDelete extends MrtCommand<typeof MrtEnvDelete> {
this.requireMrtCredentials();

const {slug} = this.args;
const {mrtProject: project} = this.resolvedConfig;
const {mrtProject: project} = this.resolvedConfig.values;

if (!project) {
this.error(
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class MrtEnvDelete extends MrtCommand<typeof MrtEnvDelete> {
{
projectSlug: project,
slug,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
},
this.getMrtAuth(),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/mrt/env/var/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class MrtEnvVarDelete extends MrtCommand<typeof MrtEnvVarDelete>
this.requireMrtCredentials();

const {key} = this.args;
const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig;
const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig.values;

if (!project) {
this.error(
Expand All @@ -57,7 +57,7 @@ export default class MrtEnvVarDelete extends MrtCommand<typeof MrtEnvVarDelete>
projectSlug: project,
environment,
key,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
},
this.getMrtAuth(),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/mrt/env/var/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class MrtEnvVarList extends MrtCommand<typeof MrtEnvVarList> {
async run(): Promise<ListEnvVarsResult> {
this.requireMrtCredentials();

const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig;
const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig.values;

if (!project) {
this.error(
Expand All @@ -80,7 +80,7 @@ export default class MrtEnvVarList extends MrtCommand<typeof MrtEnvVarList> {
{
projectSlug: project,
environment,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
},
this.getMrtAuth(),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/mrt/env/var/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class MrtEnvVarSet extends MrtCommand<typeof MrtEnvVarSet> {
this.requireMrtCredentials();

const {argv} = await this.parse(MrtEnvVarSet);
const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig;
const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig.values;

if (!project) {
this.error(
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class MrtEnvVarSet extends MrtCommand<typeof MrtEnvVarSet> {
projectSlug: project,
environment,
variables,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
},
this.getMrtAuth(),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/mrt/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class MrtPush extends MrtCommand<typeof MrtPush> {
async run(): Promise<PushResult> {
this.requireMrtCredentials();

const {mrtProject: project, mrtEnvironment: target} = this.resolvedConfig;
const {mrtProject: project, mrtEnvironment: target} = this.resolvedConfig.values;
const {message} = this.flags;

if (!project) {
Expand Down Expand Up @@ -116,7 +116,7 @@ export default class MrtPush extends MrtCommand<typeof MrtPush> {
ssrOnly,
ssrShared,
ssrParameters,
origin: this.resolvedConfig.mrtOrigin,
origin: this.resolvedConfig.values.mrtOrigin,
},
this.getMrtAuth(),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/ods/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class OdsCreate extends OdsCommand<typeof OdsCreate> {
t(
'commands.ods.create.settingPermissions',
'Setting OCAPI and WebDAV permissions for client ID: {{clientId}}',
{clientId: this.resolvedConfig.clientId!},
{clientId: this.resolvedConfig.values.clientId!},
),
);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ export default class OdsCreate extends OdsCommand<typeof OdsCreate> {
return undefined;
}

const clientId = this.resolvedConfig.clientId;
const clientId = this.resolvedConfig.values.clientId;
if (!clientId) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/scapi/custom/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default class ScapiCustomStatus extends ScapiCustomCommand<typeof ScapiCu
this.requireOAuthCredentials();

const {'tenant-id': tenantId, status, 'group-by': groupBy} = this.flags;
const {shortCode} = this.resolvedConfig;
const {shortCode} = this.resolvedConfig.values;

if (!shortCode) {
this.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/sites/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class SitesList extends InstanceCommand<typeof SitesList> {
async run(): Promise<Sites> {
this.requireOAuthCredentials();

const hostname = this.resolvedConfig.hostname!;
const hostname = this.resolvedConfig.values.hostname!;

this.log(t('commands.sites.list.fetching', 'Fetching sites from {{hostname}}...', {hostname}));

Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/slas/client/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class SlasClientOpen extends BaseCommand<typeof SlasClientOpen> {
const {'tenant-id': tenantId, 'short-code': shortCodeFlag} = this.flags;
const {clientId} = this.args;

const shortCode = shortCodeFlag ?? this.resolvedConfig.shortCode;
const shortCode = shortCodeFlag ?? this.resolvedConfig.values.shortCode;

if (!shortCode) {
this.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export {
loadConfig,
findDwJson,
} from '@salesforce/b2c-tooling-sdk/cli';
export type {ResolvedConfig, LoadConfigOptions} from '@salesforce/b2c-tooling-sdk/cli';
export type {LoadConfigOptions} from '@salesforce/b2c-tooling-sdk/cli';
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/utils/slas/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export abstract class SlasClientCommand<T extends typeof Command> extends OAuthC
* Get the SLAS client, ensuring short code is configured.
*/
protected getSlasClient(): SlasClient {
const {shortCode} = this.resolvedConfig;
const {shortCode} = this.resolvedConfig.values;
if (!shortCode) {
this.error(
t(
Expand Down
8 changes: 6 additions & 2 deletions packages/b2c-cli/test/helpers/ods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export function stubOdsClient(command: any, client: Partial<{GET: any; POST: any
});
}

export function stubResolvedConfig(command: any, resolvedConfig: Record<string, unknown>): void {
export function stubResolvedConfig(command: any, values: Record<string, unknown>): void {
Object.defineProperty(command, 'resolvedConfig', {
get: () => resolvedConfig,
get: () => ({
values,
warnings: [],
sources: [],
}),
configurable: true,
});
}
Expand Down
Loading