-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathwithAndroidLegal.ts
More file actions
32 lines (27 loc) · 1.32 KB
/
withAndroidLegal.ts
File metadata and controls
32 lines (27 loc) · 1.32 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
import path from 'node:path';
import { scanDependencies, writeAboutLibrariesNPMOutput } from '@callstack/licenses';
import { type ConfigPlugin, withAndroidManifest } from 'expo/config-plugins';
import type { PlatformPluginOptions } from '../types';
import { addListActivity } from './addListActivity';
import { applyAndConfigureAboutLibrariesPlugin } from './applyAndConfigureAboutLibrariesPlugin';
import { declareAboutLibrariesPlugin } from './declareAboutLibrariesPlugin';
/**
* Implementation of config plugin for Android setup
*
* It scans the NPM dependencies, generates AboutLibraries-compatible metadata,
* installs & configures AboutLibraries Gradle plugin and adds Android Activity with a list of dependencies and their licenses
*/
export const withAndroidLegal: ConfigPlugin<PlatformPluginOptions> = (config, { scanOptionsFactory }) => {
withAndroidManifest(config, async (exportedConfig) => {
const licenses = scanDependencies(
path.join(exportedConfig.modRequest.projectRoot, 'package.json'),
scanOptionsFactory,
);
writeAboutLibrariesNPMOutput(licenses, exportedConfig.modRequest.platformProjectRoot);
return exportedConfig;
});
config = declareAboutLibrariesPlugin(config);
config = applyAndConfigureAboutLibrariesPlugin(config);
config = addListActivity(config);
return config;
};