UNPKG

3.48 kBTypeScriptView Raw
1import { ConfigFilePaths, ExpRc, ExpoConfig, GetConfigOptions, PackageJSONConfig, ProjectConfig, ProjectTarget, WriteConfigOptions } from './Config.types';
2/**
3 * Evaluate the config for an Expo project.
4 * If a function is exported from the `app.config.js` then a partial config will be passed as an argument.
5 * The partial config is composed from any existing app.json, and certain fields from the `package.json` like name and description.
6 *
7 *
8 * **Example**
9 * ```js
10 * module.exports = function({ config }) {
11 * // mutate the config before returning it.
12 * config.slug = 'new slug'
13 * return config;
14 * }
15 *
16 * **Supports**
17 * - `app.config.ts`
18 * - `app.config.js`
19 * - `app.config.json`
20 * - `app.json`
21 *
22 * @param projectRoot the root folder containing all of your application code
23 * @param options enforce criteria for a project config
24 */
25export declare function getConfig(projectRoot: string, options?: GetConfigOptions): ProjectConfig;
26export declare function getPackageJson(projectRoot: string, config?: Pick<ExpoConfig, 'nodeModulesPath'>): PackageJSONConfig;
27export declare function readConfigJson(projectRoot: string, skipValidation?: boolean, skipNativeValidation?: boolean): ProjectConfig;
28export declare function readConfigJsonAsync(projectRoot: string, skipValidation?: boolean, skipNativeValidation?: boolean): Promise<ProjectConfig>;
29/**
30 * Get the static and dynamic config paths for a project. Also accounts for custom paths.
31 *
32 * @param projectRoot
33 */
34export declare function getConfigFilePaths(projectRoot: string): ConfigFilePaths;
35export declare function findConfigFile(projectRoot: string): {
36 configPath: string;
37 configName: string;
38 configNamespace: 'expo';
39};
40export declare function configFilename(projectRoot: string): string;
41export declare function readExpRcAsync(projectRoot: string): Promise<ExpRc>;
42export declare function setCustomConfigPath(projectRoot: string, configPath: string): void;
43/**
44 * Attempt to modify an Expo project config.
45 * This will only fully work if the project is using static configs only.
46 * Otherwise 'warn' | 'fail' will return with a message about why the config couldn't be updated.
47 * The potentially modified config object will be returned for testing purposes.
48 *
49 * @param projectRoot
50 * @param modifications modifications to make to an existing config
51 * @param readOptions options for reading the current config file
52 * @param writeOptions If true, the static config file will not be rewritten
53 */
54export declare function modifyConfigAsync(projectRoot: string, modifications: Partial<ExpoConfig>, readOptions?: GetConfigOptions, writeOptions?: WriteConfigOptions): Promise<{
55 type: 'success' | 'warn' | 'fail';
56 message?: string;
57 config: ExpoConfig | null;
58}>;
59export declare function writeConfigJsonAsync(projectRoot: string, options: Object): Promise<ProjectConfig>;
60export declare function getWebOutputPath(config?: {
61 [key: string]: any;
62}): string;
63export declare function getNameFromConfig(exp?: ExpoConfig): {
64 appName: string;
65 webName: string;
66};
67export declare function getDefaultTarget(projectRoot: string): ProjectTarget;
68/**
69 * Returns a string describing the configurations used for the given project root.
70 * Will return null if no config is found.
71 *
72 * @param projectRoot
73 * @param projectConfig
74 */
75export declare function getProjectConfigDescription(projectRoot: string, projectConfig: ProjectConfig): string | null;
76export * from './Config.types';