1111 */
1212import { existsSync , readFileSync } from 'node:fs' ;
1313import { join } from 'node:path' ;
14- import type { ConfigSource , NormalizedConfig , ResolveConfigOptions } from '@salesforce/b2c-tooling-sdk/config' ;
14+ import type { ConfigSource , ConfigLoadResult , ResolveConfigOptions } from '@salesforce/b2c-tooling-sdk/config' ;
1515
1616/**
1717 * ConfigSource implementation that loads from .env.b2c files.
@@ -53,8 +53,6 @@ import type {ConfigSource, NormalizedConfig, ResolveConfigOptions} from '@salesf
5353export class EnvFileSource implements ConfigSource {
5454 readonly name = 'env-file (.env.b2c)' ;
5555
56- private envFilePath ?: string ;
57-
5856 /**
5957 * Load configuration from .env.b2c file.
6058 *
@@ -64,48 +62,45 @@ export class EnvFileSource implements ConfigSource {
6462 * 3. .env.b2c in current working directory
6563 *
6664 * @param options - Resolution options (startDir used for file lookup)
67- * @returns Parsed configuration or undefined if file not found
65+ * @returns Parsed configuration and location, or undefined if file not found
6866 */
69- load ( options : ResolveConfigOptions ) : NormalizedConfig | undefined {
67+ load ( options : ResolveConfigOptions ) : ConfigLoadResult | undefined {
7068 // Check for explicit path override via environment variable
7169 const envOverride = process . env . B2C_ENV_FILE_PATH ;
70+ let envFilePath : string ;
7271 if ( envOverride ) {
73- this . envFilePath = envOverride ;
72+ envFilePath = envOverride ;
7473 } else {
7574 const searchDir = options . startDir ?? process . cwd ( ) ;
76- this . envFilePath = join ( searchDir , '.env.b2c' ) ;
75+ envFilePath = join ( searchDir , '.env.b2c' ) ;
7776 }
7877
79- if ( ! existsSync ( this . envFilePath ) ) {
78+ if ( ! existsSync ( envFilePath ) ) {
8079 return undefined ;
8180 }
8281
83- const content = readFileSync ( this . envFilePath , 'utf-8' ) ;
82+ const content = readFileSync ( envFilePath , 'utf-8' ) ;
8483 const vars = this . parseEnvFile ( content ) ;
8584
8685 return {
87- hostname : vars . HOSTNAME ,
88- webdavHostname : vars . WEBDAV_HOSTNAME ,
89- codeVersion : vars . CODE_VERSION ,
90- username : vars . USERNAME ,
91- password : vars . PASSWORD ,
92- clientId : vars . CLIENT_ID ,
93- clientSecret : vars . CLIENT_SECRET ,
94- scopes : vars . SCOPES ? vars . SCOPES . split ( ',' ) . map ( ( s ) => s . trim ( ) ) : undefined ,
95- shortCode : vars . SHORT_CODE ,
96- mrtProject : vars . MRT_PROJECT ,
97- mrtEnvironment : vars . MRT_ENVIRONMENT ,
98- mrtApiKey : vars . MRT_API_KEY ,
86+ config : {
87+ hostname : vars . HOSTNAME ,
88+ webdavHostname : vars . WEBDAV_HOSTNAME ,
89+ codeVersion : vars . CODE_VERSION ,
90+ username : vars . USERNAME ,
91+ password : vars . PASSWORD ,
92+ clientId : vars . CLIENT_ID ,
93+ clientSecret : vars . CLIENT_SECRET ,
94+ scopes : vars . SCOPES ? vars . SCOPES . split ( ',' ) . map ( ( s ) => s . trim ( ) ) : undefined ,
95+ shortCode : vars . SHORT_CODE ,
96+ mrtProject : vars . MRT_PROJECT ,
97+ mrtEnvironment : vars . MRT_ENVIRONMENT ,
98+ mrtApiKey : vars . MRT_API_KEY ,
99+ } ,
100+ location : envFilePath ,
99101 } ;
100102 }
101103
102- /**
103- * Get the path to the env file (for diagnostics).
104- */
105- getPath ( ) : string | undefined {
106- return this . envFilePath ;
107- }
108-
109104 /**
110105 * Parse a .env file format into key-value pairs.
111106 *
0 commit comments