-
Notifications
You must be signed in to change notification settings - Fork 934
Expand file tree
/
Copy pathconfig.ts
More file actions
39 lines (36 loc) · 1.11 KB
/
config.ts
File metadata and controls
39 lines (36 loc) · 1.11 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
import {Config, DependencyConfig} from '@react-native-community/cli-types';
function isValidRNDependency(config: DependencyConfig) {
return (
Object.keys(config.platforms).filter((key) =>
Boolean(config.platforms[key]),
).length !== 0
);
}
function filterConfig(config: Config) {
const filtered = {...config};
const dependencies: Record<string, DependencyConfig> = {};
Object.keys(filtered.dependencies).forEach((item) => {
if (isValidRNDependency(filtered.dependencies[item])) {
dependencies[item] = filtered.dependencies[item];
}
});
return {...filtered, dependencies};
}
export default {
name: 'config',
description: 'Print CLI configuration',
options: [
{
name: '--platform <platform>',
description: 'Output configuration for a specific platform',
},
{
name: '--react-native-package-name <platform>',
description:
'Optional package name to use when resolving react-native, passable by out-of-tree platforms.',
},
],
func: async (_argv: string[], ctx: Config) => {
console.log(JSON.stringify(filterConfig(ctx), null, 2));
},
};