1 | import { JsonMap, Nullable, Optional } from '@salesforce/ts-types';
|
2 | import { ConfigFile } from './config/configFile';
|
3 | import { ConfigContents } from './config/configStore';
|
4 | export declare type PackageDirDependency = {
|
5 | [k: string]: unknown;
|
6 | package: string;
|
7 | versionNumber?: string;
|
8 | };
|
9 | export 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 | };
|
26 | export declare type NamedPackageDir = PackageDir & {
|
27 | /**
|
28 | * The [normalized](https://nodejs.org/api/path.html#path_path_normalize_path) path used as the package name.
|
29 | */
|
30 | name: string;
|
31 | /**
|
32 | * The absolute path of the package.
|
33 | */
|
34 | fullPath: string;
|
35 | };
|
36 | export declare type ProjectJson = ConfigContents & {
|
37 | packageDirectories: PackageDir[];
|
38 | namespace?: string;
|
39 | sourceApiVersion?: string;
|
40 | sfdcLoginUrl?: string;
|
41 | signupTargetLoginUrl?: string;
|
42 | oauthLocalPort?: number;
|
43 | plugins?: {
|
44 | [k: string]: unknown;
|
45 | };
|
46 | packageAliases?: {
|
47 | [k: string]: string;
|
48 | };
|
49 | };
|
50 | /**
|
51 | * The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.
|
52 | *
|
53 | * *Note:* Any non-standard (not owned by Salesforce) properties stored in sfdx-project.json should
|
54 | * be in a top level property that represents your project or plugin.
|
55 | *
|
56 | * ```
|
57 | * const project = await SfdxProject.resolve();
|
58 | * const projectJson = await project.resolveProjectConfig();
|
59 | * const myPluginProperties = projectJson.get('myplugin') || {};
|
60 | * myPluginProperties.myprop = 'someValue';
|
61 | * projectJson.set('myplugin', myPluginProperties);
|
62 | * await projectJson.write();
|
63 | * ```
|
64 | *
|
65 | * **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
|
66 | */
|
67 | export declare class SfdxProjectJson extends ConfigFile<ConfigFile.Options> {
|
68 | static BLOCKLIST: string[];
|
69 | constructor(options: ConfigFile.Options);
|
70 | static getFileName(): string;
|
71 | static getDefaultOptions(isGlobal?: boolean): ConfigFile.Options;
|
72 | read(): Promise<ConfigContents>;
|
73 | readSync(): ConfigContents;
|
74 | write(newContents?: ConfigContents): Promise<ConfigContents>;
|
75 | writeSync(newContents?: ConfigContents): ConfigContents;
|
76 | getContents(): ProjectJson;
|
77 | getDefaultOptions(options?: ConfigFile.Options): ConfigFile.Options;
|
78 | /**
|
79 | * Validates sfdx-project.json against the schema.
|
80 | *
|
81 | * Set the `SFDX_PROJECT_JSON_VALIDATION` environment variable to `true` to throw an error when schema validation fails.
|
82 | * A warning is logged by default when the file is invalid.
|
83 | *
|
84 | * ***See*** [sfdx-project.schema.json] (https://github.com/forcedotcom/schemas/blob/main/sfdx-project.schema.json)
|
85 | */
|
86 | schemaValidate(): Promise<void>;
|
87 | /**
|
88 | * Returns the `packageDirectories` within sfdx-project.json, first reading
|
89 | * and validating the file if necessary.
|
90 | */
|
91 | getPackageDirectories(): Promise<PackageDir[]>;
|
92 | /**
|
93 | * Validates sfdx-project.json against the schema.
|
94 | *
|
95 | * Set the `SFDX_PROJECT_JSON_VALIDATION` environment variable to `true` to throw an error when schema validation fails.
|
96 | * A warning is logged by default when the file is invalid.
|
97 | *
|
98 | * ***See*** [sfdx-project.schema.json] (https://github.com/forcedotcom/schemas/blob/main/sfdx-project.schema.json)
|
99 | */
|
100 | schemaValidateSync(): void;
|
101 | /**
|
102 | * Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
|
103 | * and validating the file if necessary. i.e. modifying this array will not affect the
|
104 | * sfdx-project.json file.
|
105 | */
|
106 | getPackageDirectoriesSync(): NamedPackageDir[];
|
107 | /**
|
108 | * Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
|
109 | * and validating the file if necessary. i.e. modifying this array will not affect the
|
110 | * sfdx-project.json file.
|
111 | *
|
112 | * There can be multiple packages in packageDirectories that point to the same directory.
|
113 | * This method only returns one packageDirectory entry per unique directory path. This is
|
114 | * useful when doing source operations based on directories but probably not as useful
|
115 | * for packaging operations that want to do something for each package entry.
|
116 | */
|
117 | getUniquePackageDirectories(): NamedPackageDir[];
|
118 | /**
|
119 | * Get a list of the unique package names from within sfdx-project.json. Use {@link SfdxProject.getUniquePackageDirectories}
|
120 | * for data other than the names.
|
121 | */
|
122 | getUniquePackageNames(): string[];
|
123 | /**
|
124 | * Has package directories defined in the project.
|
125 | */
|
126 | hasPackages(): boolean;
|
127 | /**
|
128 | * Has multiple package directories (MPD) defined in the project.
|
129 | */
|
130 | hasMultiplePackages(): boolean;
|
131 | private doesPackageExist;
|
132 | private validateKeys;
|
133 | }
|
134 | /**
|
135 | * Represents an SFDX project directory. This directory contains a {@link SfdxProjectJson} config file as well as
|
136 | * a hidden .sfdx folder that contains all the other local project config files.
|
137 | *
|
138 | * ```
|
139 | * const project = await SfdxProject.resolve();
|
140 | * const projectJson = await project.resolveProjectConfig();
|
141 | * console.log(projectJson.sfdcLoginUrl);
|
142 | * ```
|
143 | */
|
144 | export declare class SfdxProject {
|
145 | private path;
|
146 | private static instances;
|
147 | private projectConfig;
|
148 | private sfdxProjectJson;
|
149 | private sfdxProjectJsonGlobal;
|
150 | private packageDirectories?;
|
151 | private activePackage;
|
152 | /**
|
153 | * Do not directly construct instances of this class -- use {@link SfdxProject.resolve} instead.
|
154 | *
|
155 | * @ignore
|
156 | */
|
157 | private constructor();
|
158 | /**
|
159 | * Get a Project from a given path or from the working directory.
|
160 | *
|
161 | * @param path The path of the project.
|
162 | *
|
163 | * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
|
164 | */
|
165 | static resolve(path?: string): Promise<SfdxProject>;
|
166 | /**
|
167 | * Get a Project from a given path or from the working directory.
|
168 | *
|
169 | * @param path The path of the project.
|
170 | *
|
171 | * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
|
172 | */
|
173 | static getInstance(path?: string): SfdxProject;
|
174 | /**
|
175 | * Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
|
176 | *
|
177 | * @param dir The directory path to start traversing from.
|
178 | *
|
179 | * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
|
180 | *
|
181 | * **See** {@link traverseForFile}
|
182 | *
|
183 | * **See** [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd)
|
184 | */
|
185 | static resolveProjectPath(dir?: string): Promise<string>;
|
186 | /**
|
187 | * Performs a synchronous upward directory search for an sfdx project file. Returns the absolute path to the project.
|
188 | *
|
189 | * @param dir The directory path to start traversing from.
|
190 | *
|
191 | * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace.
|
192 | *
|
193 | * **See** {@link traverseForFileSync}
|
194 | *
|
195 | * **See** [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd)
|
196 | */
|
197 | static resolveProjectPathSync(dir?: string): string;
|
198 | /**
|
199 | * Returns the project path.
|
200 | */
|
201 | getPath(): string;
|
202 | /**
|
203 | * Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
|
204 | * that are not checked in to the project specific file.
|
205 | *
|
206 | * *Note:* When reading values from {@link SfdxProjectJson}, it is recommended to use
|
207 | * {@link SfdxProject.resolveProjectConfig} instead.
|
208 | *
|
209 | * @param isGlobal True to get the global project file, otherwise the local project config.
|
210 | */
|
211 | retrieveSfdxProjectJson(isGlobal?: boolean): Promise<SfdxProjectJson>;
|
212 | /**
|
213 | * Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
|
214 | * that are not checked in to the project specific file.
|
215 | *
|
216 | * *Note:* When reading values from {@link SfdxProjectJson}, it is recommended to use
|
217 | * {@link SfdxProject.resolveProjectConfig} instead.
|
218 | *
|
219 | * This is the sync method of {@link SfdxProject.resolveSfdxProjectJson}
|
220 | *
|
221 | * @param isGlobal True to get the global project file, otherwise the local project config.
|
222 | */
|
223 | getSfdxProjectJson(isGlobal?: boolean): SfdxProjectJson;
|
224 | /**
|
225 | * Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
|
226 | * and validating the file if necessary. i.e. modifying this array will not affect the
|
227 | * sfdx-project.json file.
|
228 | */
|
229 | getPackageDirectories(): NamedPackageDir[];
|
230 | /**
|
231 | * Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
|
232 | * and validating the file if necessary. i.e. modifying this array will not affect the
|
233 | * sfdx-project.json file.
|
234 | *
|
235 | * There can be multiple packages in packageDirectories that point to the same directory.
|
236 | * This method only returns one packageDirectory entry per unique directory path. This is
|
237 | * useful when doing source operations based on directories but probably not as useful
|
238 | * for packaging operations that want to do something for each package entry.
|
239 | */
|
240 | getUniquePackageDirectories(): NamedPackageDir[];
|
241 | /**
|
242 | * Get a list of the unique package names from within sfdx-project.json. Use {@link SfdxProject.getUniquePackageDirectories}
|
243 | * for data other than the names.
|
244 | */
|
245 | getUniquePackageNames(): string[];
|
246 | /**
|
247 | * Returns the package from a file path.
|
248 | *
|
249 | * @param path A file path. E.g. /Users/jsmith/projects/ebikes-lwc/force-app/apex/my-cls.cls
|
250 | */
|
251 | getPackageFromPath(path: string): Optional<NamedPackageDir>;
|
252 | /**
|
253 | * Returns the package name, E.g. 'force-app', from a file path.
|
254 | *
|
255 | * @param path A file path. E.g. /Users/jsmith/projects/ebikes-lwc/force-app/apex/my-cls.cls
|
256 | */
|
257 | getPackageNameFromPath(path: string): Optional<string>;
|
258 | /**
|
259 | * Returns the package directory.
|
260 | *
|
261 | * @param packageName Name of the package directory. E.g., 'force-app'
|
262 | */
|
263 | getPackage(packageName: string): Optional<NamedPackageDir>;
|
264 | /**
|
265 | * Returns the absolute path of the package directory ending with the path separator.
|
266 | * E.g., /Users/jsmith/projects/ebikes-lwc/force-app/
|
267 | *
|
268 | * @param packageName Name of the package directory. E.g., 'force-app'
|
269 | */
|
270 | getPackagePath(packageName: string): Optional<string>;
|
271 | /**
|
272 | * Has package directories defined in the project.
|
273 | */
|
274 | hasPackages(): boolean;
|
275 | /**
|
276 | * Has multiple package directories (MPD) defined in the project.
|
277 | */
|
278 | hasMultiplePackages(): boolean;
|
279 | /**
|
280 | * Get the currently activated package on the project. This has no implication on sfdx-project.json
|
281 | * but is useful for keeping track of package and source specific options in a process.
|
282 | */
|
283 | getActivePackage(): Nullable<NamedPackageDir>;
|
284 | /**
|
285 | * Set the currently activated package on the project. This has no implication on sfdx-project.json
|
286 | * but is useful for keeping track of package and source specific options in a process.
|
287 | *
|
288 | * @param pkgName The package name to activate. E.g. 'force-app'
|
289 | */
|
290 | setActivePackage(packageName: Nullable<string>): void;
|
291 | /**
|
292 | * Get the project's default package directory defined in sfdx-project.json using first 'default: true'
|
293 | * found. The first entry is returned if no default is specified.
|
294 | */
|
295 | getDefaultPackage(): NamedPackageDir;
|
296 | /**
|
297 | * The project config is resolved from local and global {@link SfdxProjectJson},
|
298 | * {@link ConfigAggregator}, and a set of defaults. It is recommended to use
|
299 | * this when reading values from SfdxProjectJson.
|
300 | *
|
301 | * The global {@link SfdxProjectJson} is used to allow the user to provide default values they
|
302 | * may not want checked into their project's source.
|
303 | *
|
304 | * @returns A resolved config object that contains a bunch of different
|
305 | * properties, including some 3rd party custom properties.
|
306 | */
|
307 | resolveProjectConfig(): Promise<JsonMap>;
|
308 | }
|
309 |
|
\ | No newline at end of file |