UNPKG

5.45 kBTypeScriptView Raw
1import { ConfigFile } from './config/configFile';
2import { ConfigContents } from './config/configStore';
3import { JsonMap } from '@salesforce/ts-types';
4export declare type PackageDirDependency = {
5 package: string;
6 versionNumber?: string;
7 [k: string]: unknown;
8};
9export declare type PackageDir = {
10 ancestorId?: string;
11 ancestorVersion?: string;
12 default?: boolean;
13 definitionFile?: string;
14 dependencies?: PackageDirDependency[];
15 includeProfileUserLicenses?: boolean;
16 package?: string;
17 path: string;
18 postInstallScript?: string;
19 postInstallUrl?: string;
20 releaseNotesUrl?: string;
21 uninstallScript?: string;
22 versionDescription?: string;
23 versionName?: string;
24 versionNumber?: string;
25};
26export declare type ProjectJson = ConfigContents & {
27 packageDirectories: PackageDir[];
28 namespace?: string;
29 sourceApiVersion?: string;
30 sfdcLoginUrl?: string;
31 signupTargetLoginUrl?: string;
32 oauthLocalPort?: number;
33 plugins?: {
34 [k: string]: unknown;
35 };
36 packageAliases?: {
37 [k: string]: string;
38 };
39};
40/**
41 * The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.
42 *
43 * *Note:* Any non-standard (not owned by Salesforce) properties stored in sfdx-project.json should
44 * be in a top level property that represents your project or plugin.
45 *
46 * ```
47 * const project = await SfdxProjectJson.retrieve();
48 * const myPluginProperties = project.get('myplugin') || {};
49 * myPluginProperties.myprop = 'someValue';
50 * project.set('myplugin', myPluginProperties);
51 * await project.write();
52 * ```
53 *
54 * **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
55 */
56export declare class SfdxProjectJson extends ConfigFile<ConfigFile.Options> {
57 static BLACKLIST: string[];
58 static getFileName(): string;
59 static getDefaultOptions(isGlobal?: boolean): ConfigFile.Options;
60 constructor(options: ConfigFile.Options);
61 read(): Promise<ConfigContents>;
62 write(newContents?: ConfigContents): Promise<ConfigContents>;
63 getContents(): ProjectJson;
64 getDefaultOptions(options?: ConfigFile.Options): ConfigFile.Options;
65 /**
66 * Validates sfdx-project.json against the schema.
67 *
68 * Set the `SFDX_PROJECT_JSON_VALIDATION` environment variable to `true` to throw an error when schema validation fails.
69 * A warning is logged by default when the file is invalid.
70 *
71 * ***See*** [sfdx-project.schema.json] (https://raw.githubusercontent.com/forcedotcom/schemas/master/schemas/sfdx-project.schema.json)
72 */
73 schemaValidate(): Promise<void>;
74 /**
75 * Returns the `packageDirectories` within sfdx-project.json, first reading
76 * and validating the file if necessary.
77 */
78 getPackageDirectories(): Promise<PackageDir[]>;
79}
80/**
81 * Represents an SFDX project directory. This directory contains a {@link SfdxProjectJson} config file as well as
82 * a hidden .sfdx folder that contains all the other local project config files.
83 *
84 * ```
85 * const project = await SfdxProject.resolve();
86 * const projectJson = await project.resolveProjectConfig();
87 * console.log(projectJson.sfdcLoginUrl);
88 * ```
89 */
90export declare class SfdxProject {
91 private path;
92 /**
93 * Get a Project from a given path or from the working directory.
94 * @param path The path of the project.
95 *
96 * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
97 */
98 static resolve(path?: string): Promise<SfdxProject>;
99 /**
100 * Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
101 *
102 * @param dir The directory path to start traversing from.
103 *
104 * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
105 *
106 * **See** {@link traverseForFile}
107 *
108 * **See** [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd)
109 */
110 static resolveProjectPath(dir?: string): Promise<string>;
111 private static instances;
112 private projectConfig;
113 private sfdxProjectJson;
114 private sfdxProjectJsonGlobal;
115 /**
116 * Do not directly construct instances of this class -- use {@link SfdxProject.resolve} instead.
117 *
118 * @ignore
119 */
120 private constructor();
121 /**
122 * Returns the project path.
123 */
124 getPath(): string;
125 /**
126 * Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
127 * that are not checked in to the project specific file.
128 *
129 * *Note:* When reading values from {@link SfdxProjectJson}, it is recommended to use
130 * {@link SfdxProject.resolveProjectConfig} instead.
131 *
132 * @param isGlobal True to get the global project file, otherwise the local project config.
133 */
134 retrieveSfdxProjectJson(isGlobal?: boolean): Promise<SfdxProjectJson>;
135 /**
136 * The project config is resolved from local and global {@link SfdxProjectJson},
137 * {@link ConfigAggregator}, and a set of defaults. It is recommended to use
138 * this when reading values from SfdxProjectJson.
139 * @returns A resolved config object that contains a bunch of different
140 * properties, including some 3rd party custom properties.
141 */
142 resolveProjectConfig(): Promise<JsonMap>;
143}
144
\No newline at end of file