Skip to content

Commit 3449551

Browse files
@W-21199544 aggressively rename startDir as workingDirectory
1 parent 3c6d7cc commit 3449551

12 files changed

Lines changed: 57 additions & 57 deletions

File tree

packages/b2c-dx-mcp/src/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export class Services {
323323
* @returns Project working directory path
324324
*/
325325
public getWorkingDirectory(): string {
326-
return this.resolvedConfig.values.startDir ?? process.cwd();
326+
return this.resolvedConfig.values.workingDirectory ?? process.cwd();
327327
}
328328

329329
/**

packages/b2c-dx-mcp/test/services.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('services', () => {
175175
describe('getWorkingDirectory', () => {
176176
it('should return working directory when provided in config', () => {
177177
const workingDir = '/path/to/project';
178-
const config = createMockResolvedConfig({startDir: workingDir});
178+
const config = createMockResolvedConfig({workingDirectory: workingDir});
179179
const services = new Services({resolvedConfig: config});
180180

181181
expect(services.getWorkingDirectory()).to.equal(workingDir);
@@ -190,7 +190,7 @@ describe('services', () => {
190190

191191
it('should return working directory from fromResolvedConfig when provided in config', () => {
192192
const workingDir = '/path/to/project';
193-
const config = createMockResolvedConfig({startDir: workingDir});
193+
const config = createMockResolvedConfig({workingDirectory: workingDir});
194194
const services = Services.fromResolvedConfig(config);
195195

196196
expect(services.getWorkingDirectory()).to.equal(workingDir);

packages/b2c-plugin-example-config/src/sources/env-file-source.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ export class EnvFileSource implements ConfigSource {
5858
*
5959
* File location priority:
6060
* 1. B2C_ENV_FILE_PATH environment variable (explicit override)
61-
* 2. .env.b2c in startDir (from options)
61+
* 2. .env.b2c in workingDirectory (from options)
6262
* 3. .env.b2c in current working directory
6363
*
64-
* @param options - Resolution options (startDir used for file lookup)
64+
* @param options - Resolution options (workingDirectory used for file lookup)
6565
* @returns Parsed configuration and location, or undefined if file not found
6666
*/
6767
load(options: ResolveConfigOptions): ConfigLoadResult | undefined {
@@ -71,7 +71,7 @@ export class EnvFileSource implements ConfigSource {
7171
if (envOverride) {
7272
envFilePath = envOverride;
7373
} else {
74-
const searchDir = options.startDir ?? process.cwd();
74+
const searchDir = options.workingDirectory ?? process.cwd();
7575
envFilePath = join(searchDir, '.env.b2c');
7676
}
7777

packages/b2c-tooling-sdk/src/cli/base-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
293293
* Gets base configuration options from common flags.
294294
*
295295
* Subclasses should spread these options when overriding loadConfiguration()
296-
* to ensure common options like startDir are always included.
296+
* to ensure common options like workingDirectory are always included.
297297
*
298298
* @example
299299
* ```typescript
@@ -310,7 +310,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
310310
return {
311311
instance: this.flags.instance,
312312
configPath: this.flags.config,
313-
startDir: this.flags['working-directory'],
313+
workingDirectory: this.flags['working-directory'],
314314
};
315315
}
316316

packages/b2c-tooling-sdk/src/cli/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export interface LoadConfigOptions {
175175
/** Explicit path to config file (skips searching if provided) */
176176
configPath?: string;
177177
/** Starting directory for config file search (default: current working directory) */
178-
startDir?: string;
178+
workingDirectory?: string;
179179
/** Cloud origin for MRT ~/.mobify lookup (e.g., https://cloud-staging.mobify.com) */
180180
cloudOrigin?: string;
181181
/** Path to custom MRT credentials file (overrides default ~/.mobify) */
@@ -236,17 +236,17 @@ export function loadConfig(
236236
): ResolvedB2CConfig {
237237
const logger = getLogger();
238238

239-
// Preserve instanceName and startDir from options if not already in flags
239+
// Preserve instanceName and workingDirectory from options if not already in flags
240240
const effectiveFlags = {
241241
...flags,
242242
instanceName: flags.instanceName ?? options.instance,
243-
startDir: flags.startDir ?? options.startDir,
243+
workingDirectory: flags.workingDirectory ?? options.workingDirectory,
244244
};
245245

246246
const resolved = resolveConfig(effectiveFlags, {
247247
instance: options.instance,
248248
configPath: options.configPath,
249-
startDir: options.startDir,
249+
workingDirectory: options.workingDirectory,
250250
hostnameProtection: true,
251251
cloudOrigin: options.cloudOrigin,
252252
credentialsFile: options.credentialsFile,

packages/b2c-tooling-sdk/src/config/dw-json.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export interface LoadDwJsonOptions {
9696
/** Explicit path to dw.json (skips searching if provided) */
9797
path?: string;
9898
/** Starting directory for search (defaults to cwd) */
99-
startDir?: string;
99+
workingDirectory?: string;
100100
}
101101

102102
/**
@@ -112,7 +112,7 @@ export interface LoadDwJsonResult {
112112
/**
113113
* Finds dw.json by searching upward from the starting directory.
114114
*
115-
* @param startDir - Directory to start searching from (defaults to cwd)
115+
* @param workingDirectory - Directory to start searching from (defaults to cwd)
116116
* @returns Path to dw.json if found, undefined otherwise
117117
*
118118
* @example
@@ -121,8 +121,8 @@ export interface LoadDwJsonResult {
121121
* console.log(`Found dw.json at ${dwPath}`);
122122
* }
123123
*/
124-
export function findDwJson(startDir: string = process.cwd()): string | undefined {
125-
let dir = startDir;
124+
export function findDwJson(workingDirectory: string = process.cwd()): string | undefined {
125+
let dir = workingDirectory;
126126
const root = path.parse(dir).root;
127127

128128
while (dir !== root) {
@@ -209,7 +209,7 @@ function selectConfig(json: DwJsonMultiConfig, instanceName?: string): DwJsonCon
209209
*/
210210
export function loadFullDwJson(options: LoadDwJsonOptions = {}): {config: DwJsonMultiConfig; path: string} | undefined {
211211
const logger = getLogger();
212-
const dwJsonPath = options.path ?? path.join(options.startDir || process.cwd(), 'dw.json');
212+
const dwJsonPath = options.path ?? path.join(options.workingDirectory || process.cwd(), 'dw.json');
213213

214214
logger.trace({path: dwJsonPath}, '[DwJsonSource] Checking for config file');
215215

@@ -247,7 +247,7 @@ export interface AddInstanceOptions {
247247
/** Path to dw.json (defaults to ./dw.json) */
248248
path?: string;
249249
/** Starting directory for search */
250-
startDir?: string;
250+
workingDirectory?: string;
251251
/** Whether to set as active instance */
252252
setActive?: boolean;
253253
}
@@ -263,7 +263,7 @@ export interface AddInstanceOptions {
263263
* @throws Error if instance with same name already exists
264264
*/
265265
export function addInstance(instance: DwJsonConfig, options: AddInstanceOptions = {}): void {
266-
const dwJsonPath = options.path ?? path.join(options.startDir || process.cwd(), 'dw.json');
266+
const dwJsonPath = options.path ?? path.join(options.workingDirectory || process.cwd(), 'dw.json');
267267

268268
let existing: DwJsonMultiConfig = {};
269269
if (fs.existsSync(dwJsonPath)) {
@@ -322,7 +322,7 @@ export interface RemoveInstanceOptions {
322322
/** Path to dw.json */
323323
path?: string;
324324
/** Starting directory for search */
325-
startDir?: string;
325+
workingDirectory?: string;
326326
}
327327

328328
/**
@@ -333,7 +333,7 @@ export interface RemoveInstanceOptions {
333333
* @throws Error if instance not found or dw.json doesn't exist
334334
*/
335335
export function removeInstance(name: string, options: RemoveInstanceOptions = {}): void {
336-
const dwJsonPath = options.path ?? path.join(options.startDir || process.cwd(), 'dw.json');
336+
const dwJsonPath = options.path ?? path.join(options.workingDirectory || process.cwd(), 'dw.json');
337337

338338
if (!fs.existsSync(dwJsonPath)) {
339339
throw new Error('No dw.json file found');
@@ -364,7 +364,7 @@ export interface SetActiveInstanceOptions {
364364
/** Path to dw.json */
365365
path?: string;
366366
/** Starting directory for search */
367-
startDir?: string;
367+
workingDirectory?: string;
368368
}
369369

370370
/**
@@ -375,7 +375,7 @@ export interface SetActiveInstanceOptions {
375375
* @throws Error if instance not found or dw.json doesn't exist
376376
*/
377377
export function setActiveInstance(name: string, options: SetActiveInstanceOptions = {}): void {
378-
const dwJsonPath = options.path ?? path.join(options.startDir || process.cwd(), 'dw.json');
378+
const dwJsonPath = options.path ?? path.join(options.workingDirectory || process.cwd(), 'dw.json');
379379

380380
if (!fs.existsSync(dwJsonPath)) {
381381
throw new Error('No dw.json file found');
@@ -418,7 +418,7 @@ export function setActiveInstance(name: string, options: SetActiveInstanceOption
418418
* Loads configuration from a dw.json file.
419419
*
420420
* If an explicit path is provided, uses that file. Otherwise, looks for dw.json
421-
* in the startDir (or cwd). Does NOT search parent directories.
421+
* in the workingDirectory (or cwd). Does NOT search parent directories.
422422
*
423423
* Use `findDwJson()` if you need to search upward through parent directories.
424424
*
@@ -434,7 +434,7 @@ export function setActiveInstance(name: string, options: SetActiveInstanceOption
434434
* }
435435
*
436436
* // Load from specific directory
437-
* const result = loadDwJson({ startDir: '/path/to/project' });
437+
* const result = loadDwJson({ workingDirectory: '/path/to/project' });
438438
*
439439
* // Use named instance
440440
* const result = loadDwJson({ instance: 'staging' });
@@ -446,7 +446,7 @@ export function loadDwJson(options: LoadDwJsonOptions = {}): LoadDwJsonResult |
446446
const logger = getLogger();
447447

448448
// If explicit path provided, use it. Otherwise default to ./dw.json (no upward search)
449-
const dwJsonPath = options.path ?? path.join(options.startDir || process.cwd(), 'dw.json');
449+
const dwJsonPath = options.path ?? path.join(options.workingDirectory || process.cwd(), 'dw.json');
450450

451451
logger.trace({path: dwJsonPath}, '[DwJsonSource] Checking for config file');
452452

packages/b2c-tooling-sdk/src/config/mapping.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export function mergeConfigsWithProtection(
316316
cipHost: overrides.cipHost ?? base.cipHost,
317317
sandboxApiHost: overrides.sandboxApiHost ?? base.sandboxApiHost,
318318
instanceName: overrides.instanceName ?? base.instanceName,
319-
startDir: overrides.startDir ?? base.startDir,
319+
workingDirectory: overrides.workingDirectory ?? base.workingDirectory,
320320
mrtProject: overrides.mrtProject ?? base.mrtProject,
321321
mrtEnvironment: overrides.mrtEnvironment ?? base.mrtEnvironment,
322322
mrtApiKey: overrides.mrtApiKey ?? base.mrtApiKey,

packages/b2c-tooling-sdk/src/config/sources/dw-json-source.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class DwJsonSource implements ConfigSource {
3434
const result = loadDwJson({
3535
instance: options.instance,
3636
path: options.configPath,
37-
startDir: options.startDir,
37+
workingDirectory: options.workingDirectory,
3838
});
3939

4040
if (!result) {
@@ -55,7 +55,7 @@ export class DwJsonSource implements ConfigSource {
5555
listInstances(options?: ResolveConfigOptions): InstanceInfo[] {
5656
const result = loadFullDwJson({
5757
path: options?.configPath,
58-
startDir: options?.startDir,
58+
workingDirectory: options?.workingDirectory,
5959
});
6060

6161
if (!result) {
@@ -101,7 +101,7 @@ export class DwJsonSource implements ConfigSource {
101101
const dwJsonConfig = mapNormalizedConfigToDwJson(options.config, options.name);
102102
addInstance(dwJsonConfig, {
103103
path: options.configPath,
104-
startDir: options.startDir,
104+
workingDirectory: options.workingDirectory,
105105
setActive: options.setActive,
106106
});
107107
}
@@ -112,7 +112,7 @@ export class DwJsonSource implements ConfigSource {
112112
removeInstance(name: string, options?: ResolveConfigOptions): void {
113113
removeInstance(name, {
114114
path: options?.configPath,
115-
startDir: options?.startDir,
115+
workingDirectory: options?.workingDirectory,
116116
});
117117
}
118118

@@ -122,7 +122,7 @@ export class DwJsonSource implements ConfigSource {
122122
setActiveInstance(name: string, options?: ResolveConfigOptions): void {
123123
setActiveInstance(name, {
124124
path: options?.configPath,
125-
startDir: options?.startDir,
125+
workingDirectory: options?.workingDirectory,
126126
});
127127
}
128128
}

packages/b2c-tooling-sdk/src/config/sources/package-json-source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export class PackageJsonSource implements ConfigSource {
6060
load(options: ResolveConfigOptions): ConfigLoadResult | undefined {
6161
const logger = getLogger();
6262

63-
// Only look in cwd (or startDir if provided)
64-
const searchDir = options.startDir ?? process.cwd();
63+
// Only look in cwd (or workingDirectory if provided)
64+
const searchDir = options.workingDirectory ?? process.cwd();
6565
const packageJsonPath = path.join(searchDir, 'package.json');
6666

6767
logger.trace({location: packageJsonPath}, '[PackageJsonSource] Checking for package.json');

packages/b2c-tooling-sdk/src/config/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export interface NormalizedConfig {
8080
/** Instance name (from multi-config supporting sources) */
8181
instanceName?: string;
8282
/** Starting directory for config file search and project-relative operations */
83-
startDir?: string;
83+
workingDirectory?: string;
8484

8585
// TLS/mTLS
8686
/** Path to PKCS12 certificate file for client mTLS (two-factor auth) */
@@ -143,7 +143,7 @@ export interface ResolveConfigOptions {
143143
/** Explicit path to config file (defaults to auto-discover) */
144144
configPath?: string;
145145
/** Starting directory for config file search */
146-
startDir?: string;
146+
workingDirectory?: string;
147147
/** Whether to apply hostname mismatch protection (default: true) */
148148
hostnameProtection?: boolean;
149149
/** Cloud origin for ~/.mobify lookup (MRT) */

0 commit comments

Comments
 (0)