-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdw-json-source.ts
More file actions
46 lines (40 loc) · 1.3 KB
/
dw-json-source.ts
File metadata and controls
46 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Copyright (c) 2025, Salesforce, Inc.
* SPDX-License-Identifier: Apache-2
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
*/
/**
* dw.json configuration source.
*
* @internal This module is internal to the SDK. Use ConfigResolver instead.
*/
import * as path from 'node:path';
import {loadDwJson} from '../dw-json.js';
import {mapDwJsonToNormalizedConfig} from '../mapping.js';
import type {ConfigSource, NormalizedConfig, ResolveConfigOptions} from '../types.js';
/**
* Configuration source that loads from dw.json files.
*
* @internal
*/
export class DwJsonSource implements ConfigSource {
readonly name = 'dw.json';
private lastPath?: string;
load(options: ResolveConfigOptions): NormalizedConfig | undefined {
const dwConfig = loadDwJson({
instance: options.instance,
path: options.configPath,
startDir: options.startDir,
});
if (!dwConfig) {
this.lastPath = undefined;
return undefined;
}
// Track the path for diagnostics - use explicit path or default location
this.lastPath = options.configPath ?? path.join(options.startDir || process.cwd(), 'dw.json');
return mapDwJsonToNormalizedConfig(dwConfig);
}
getPath(): string | undefined {
return this.lastPath;
}
}