UNPKG

3.69 kBTypeScriptView Raw
1import { ConfigFile } from './config/configFile';
2import { ConfigContents } from './config/configStore';
3import { JsonMap } from '@salesforce/ts-types';
4/**
5 * The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.
6 *
7 * *Note:* Any non-standard (not owned by Salesforce) properties stored in sfdx-project.json should
8 * be in a top level property that represents your project or plugin.
9 *
10 * ```
11 * const project = await SfdxProjectJson.retrieve();
12 * const myPluginProperties = project.get('myplugin') || {};
13 * myPluginProperties.myprop = 'someValue';
14 * project.set('myplugin', myPluginProperties);
15 * await project.write();
16 * ```
17 *
18 * **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
19 */
20export declare class SfdxProjectJson extends ConfigFile<ConfigFile.Options> {
21 static getFileName(): string;
22 static getDefaultOptions(isGlobal?: boolean): ConfigFile.Options;
23 constructor(options: ConfigFile.Options);
24 read(): Promise<ConfigContents>;
25 getDefaultOptions(options?: ConfigFile.Options): ConfigFile.Options;
26}
27/**
28 * Represents an SFDX project directory. This directory contains a {@link SfdxProjectJson} config file as well as
29 * a hidden .sfdx folder that contains all the other local project config files.
30 *
31 * ```
32 * const project = await SfdxProject.resolve();
33 * const projectJson = await project.resolveProjectConfig();
34 * console.log(projectJson.sfdcLoginUrl);
35 * ```
36 */
37export declare class SfdxProject {
38 private path;
39 /**
40 * Get a Project from a given path or from the working directory.
41 * @param path The path of the project.
42 *
43 * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
44 */
45 static resolve(path?: string): Promise<SfdxProject>;
46 /**
47 * Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
48 *
49 * @param dir The directory path to start traversing from.
50 *
51 * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
52 *
53 * **See** {@link traverseForFile}
54 *
55 * **See** [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd)
56 */
57 static resolveProjectPath(dir?: string): Promise<string>;
58 private projectConfig;
59 private sfdxProjectJson;
60 private sfdxProjectJsonGlobal;
61 /**
62 * Do not directly construct instances of this class -- use {@link SfdxProject.resolve} instead.
63 *
64 * @ignore
65 */
66 private constructor();
67 /**
68 * Returns the project path.
69 */
70 getPath(): string;
71 /**
72 * Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
73 * that are not checked in to the project specific file.
74 *
75 * *Note:* When reading values from {@link SfdxProjectJson}, it is recommended to use
76 * {@link SfdxProject.resolveProjectConfig} instead.
77 *
78 * @param isGlobal True to get the global project file, otherwise the local project config.
79 */
80 retrieveSfdxProjectJson(isGlobal?: boolean): Promise<SfdxProjectJson>;
81 /**
82 * The project config is resolved from local and global {@link SfdxProjectJson},
83 * {@link ConfigAggregator}, and a set of defaults. It is recommended to use
84 * this when reading values from SfdxProjectJson.
85 * @returns A resolved config object that contains a bunch of different
86 * properties, including some 3rd party custom properties.
87 */
88 resolveProjectConfig(): Promise<JsonMap>;
89}