react-native-legal 1.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/ReactNativeLegal.podspec +46 -0
  4. package/android/build.gradle +75 -0
  5. package/android/react-native-helpers.gradle +45 -0
  6. package/android/src/main/java/com/reactnativelegal/ReactNativeLegalActivity.kt +98 -0
  7. package/android/src/main/java/com/reactnativelegal/ReactNativeLegalModuleImpl.kt +19 -0
  8. package/android/src/main/java/com/reactnativelegal/ReactNativeLegalTurboPackage.kt +38 -0
  9. package/android/src/main/res/layout/activity_licenses.xml +28 -0
  10. package/android/src/main/res/values/styles.xml +7 -0
  11. package/android/src/main/res/values-v29/styles.xml +8 -0
  12. package/android/src/newarch/java/com/reactnativelegal/ReactNativeLegalModule.kt +17 -0
  13. package/android/src/oldarch/java/com/reactnativelegal/ReactNativeLegalModule.kt +23 -0
  14. package/app.plugin.js +1 -0
  15. package/bare-plugin/build/android/addListActivity.d.ts +4 -0
  16. package/bare-plugin/build/android/addListActivity.js +22 -0
  17. package/bare-plugin/build/android/androidCommand.d.ts +7 -0
  18. package/bare-plugin/build/android/androidCommand.js +25 -0
  19. package/bare-plugin/build/android/applyAndConfigureAboutLibrariesPlugin.d.ts +6 -0
  20. package/bare-plugin/build/android/applyAndConfigureAboutLibrariesPlugin.js +27 -0
  21. package/bare-plugin/build/android/declareAboutLibrariesPlugin.d.ts +6 -0
  22. package/bare-plugin/build/android/declareAboutLibrariesPlugin.js +27 -0
  23. package/bare-plugin/build/android/utils.d.ts +14 -0
  24. package/bare-plugin/build/android/utils.js +37 -0
  25. package/bare-plugin/build/index.d.ts +2 -0
  26. package/bare-plugin/build/index.js +9 -0
  27. package/bare-plugin/build/ios/addSettingsBundle.d.ts +4 -0
  28. package/bare-plugin/build/ios/addSettingsBundle.js +27 -0
  29. package/bare-plugin/build/ios/iosCommand.d.ts +7 -0
  30. package/bare-plugin/build/ios/iosCommand.js +23 -0
  31. package/bare-plugin/build/ios/registerLicensePlistBuildPhase.d.ts +7 -0
  32. package/bare-plugin/build/ios/registerLicensePlistBuildPhase.js +24 -0
  33. package/bare-plugin/build/ios/utils.d.ts +33 -0
  34. package/bare-plugin/build/ios/utils.js +98 -0
  35. package/bare-plugin/src/android/addListActivity.ts +22 -0
  36. package/bare-plugin/src/android/androidCommand.ts +23 -0
  37. package/bare-plugin/src/android/applyAndConfigureAboutLibrariesPlugin.ts +21 -0
  38. package/bare-plugin/src/android/declareAboutLibrariesPlugin.ts +21 -0
  39. package/bare-plugin/src/android/utils.ts +34 -0
  40. package/bare-plugin/src/index.ts +9 -0
  41. package/bare-plugin/src/ios/addSettingsBundle.ts +27 -0
  42. package/bare-plugin/src/ios/iosCommand.ts +21 -0
  43. package/bare-plugin/src/ios/registerLicensePlistBuildPhase.ts +22 -0
  44. package/bare-plugin/src/ios/utils.ts +120 -0
  45. package/bare-plugin/tsconfig.json +20 -0
  46. package/ios/ReactNativeLegal-Bridging-Header.h +1 -0
  47. package/ios/ReactNativeLegalDetailViewController.swift +156 -0
  48. package/ios/ReactNativeLegalLicenseMetadata.swift +4 -0
  49. package/ios/ReactNativeLegalModule.h +7 -0
  50. package/ios/ReactNativeLegalModule.mm +29 -0
  51. package/ios/ReactNativeLegalModuleImpl.swift +78 -0
  52. package/ios/ReactNativeLegalTableViewController.swift +72 -0
  53. package/lib/commonjs/NativeReactNativeLegal.js +10 -0
  54. package/lib/commonjs/NativeReactNativeLegal.js.map +1 -0
  55. package/lib/commonjs/ReactNativeLegal.android.js +18 -0
  56. package/lib/commonjs/ReactNativeLegal.android.js.map +1 -0
  57. package/lib/commonjs/ReactNativeLegal.ios.js +18 -0
  58. package/lib/commonjs/ReactNativeLegal.ios.js.map +1 -0
  59. package/lib/commonjs/ReactNativeLegal.js +13 -0
  60. package/lib/commonjs/ReactNativeLegal.js.map +1 -0
  61. package/lib/commonjs/index.js +13 -0
  62. package/lib/commonjs/index.js.map +1 -0
  63. package/lib/module/NativeReactNativeLegal.js +3 -0
  64. package/lib/module/NativeReactNativeLegal.js.map +1 -0
  65. package/lib/module/ReactNativeLegal.android.js +10 -0
  66. package/lib/module/ReactNativeLegal.android.js.map +1 -0
  67. package/lib/module/ReactNativeLegal.ios.js +10 -0
  68. package/lib/module/ReactNativeLegal.ios.js.map +1 -0
  69. package/lib/module/ReactNativeLegal.js +6 -0
  70. package/lib/module/ReactNativeLegal.js.map +1 -0
  71. package/lib/module/index.js +2 -0
  72. package/lib/module/index.js.map +1 -0
  73. package/lib/typescript/NativeReactNativeLegal.d.ts +7 -0
  74. package/lib/typescript/NativeReactNativeLegal.d.ts.map +1 -0
  75. package/lib/typescript/ReactNativeLegal.android.d.ts +4 -0
  76. package/lib/typescript/ReactNativeLegal.android.d.ts.map +1 -0
  77. package/lib/typescript/ReactNativeLegal.d.ts +4 -0
  78. package/lib/typescript/ReactNativeLegal.d.ts.map +1 -0
  79. package/lib/typescript/ReactNativeLegal.ios.d.ts +4 -0
  80. package/lib/typescript/ReactNativeLegal.ios.d.ts.map +1 -0
  81. package/lib/typescript/index.d.ts +2 -0
  82. package/lib/typescript/index.d.ts.map +1 -0
  83. package/package.json +97 -0
  84. package/plugin/build/android/addListActivity.d.ts +5 -0
  85. package/plugin/build/android/addListActivity.js +17 -0
  86. package/plugin/build/android/applyAndConfigureAboutLibrariesPlugin.d.ts +7 -0
  87. package/plugin/build/android/applyAndConfigureAboutLibrariesPlugin.js +22 -0
  88. package/plugin/build/android/declareAboutLibrariesPlugin.d.ts +7 -0
  89. package/plugin/build/android/declareAboutLibrariesPlugin.js +22 -0
  90. package/plugin/build/android/withAndroidLegal.d.ts +8 -0
  91. package/plugin/build/android/withAndroidLegal.js +30 -0
  92. package/plugin/build/index.d.ts +3 -0
  93. package/plugin/build/index.js +11 -0
  94. package/plugin/build/ios/addSettingsBundle.d.ts +5 -0
  95. package/plugin/build/ios/addSettingsBundle.js +28 -0
  96. package/plugin/build/ios/registerLicensePlistBuildPhase.d.ts +8 -0
  97. package/plugin/build/ios/registerLicensePlistBuildPhase.js +23 -0
  98. package/plugin/build/ios/withIosLegal.d.ts +8 -0
  99. package/plugin/build/ios/withIosLegal.js +28 -0
  100. package/plugin/jest.config.js +1 -0
  101. package/plugin/src/android/addListActivity.ts +19 -0
  102. package/plugin/src/android/applyAndConfigureAboutLibrariesPlugin.ts +23 -0
  103. package/plugin/src/android/declareAboutLibrariesPlugin.ts +21 -0
  104. package/plugin/src/android/withAndroidLegal.ts +28 -0
  105. package/plugin/src/index.ts +14 -0
  106. package/plugin/src/ios/addSettingsBundle.ts +29 -0
  107. package/plugin/src/ios/registerLicensePlistBuildPhase.ts +24 -0
  108. package/plugin/src/ios/withIosLegal.ts +26 -0
  109. package/plugin/tsconfig.json +9 -0
  110. package/plugin-utils/build/android.d.ts +12 -0
  111. package/plugin-utils/build/android.js +91 -0
  112. package/plugin-utils/build/common.d.ts +45 -0
  113. package/plugin-utils/build/common.js +312 -0
  114. package/plugin-utils/build/ios.d.ts +11 -0
  115. package/plugin-utils/build/ios.js +86 -0
  116. package/plugin-utils/src/android.ts +99 -0
  117. package/plugin-utils/src/common.ts +398 -0
  118. package/plugin-utils/src/ios.ts +102 -0
  119. package/plugin-utils/tsconfig.json +20 -0
  120. package/react-native.config.js +13 -0
  121. package/src/NativeReactNativeLegal.ts +8 -0
  122. package/src/ReactNativeLegal.android.ts +10 -0
  123. package/src/ReactNativeLegal.ios.ts +10 -0
  124. package/src/ReactNativeLegal.ts +5 -0
  125. package/src/index.ts +1 -0
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "react-native-legal",
3
+ "version": "1.0.0-next.1",
4
+ "description": "Acknowledge OSS libraries used in your React Native app",
5
+ "keywords": [
6
+ "react-native",
7
+ "oss",
8
+ "license",
9
+ "acknowledgements",
10
+ "license-management"
11
+ ],
12
+ "main": "lib/commonjs/index",
13
+ "module": "lib/module/index",
14
+ "types": "lib/typescript/index.d.ts",
15
+ "react-native": "src/index",
16
+ "source": "src/index",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/callstackincubator/react-native-legal.git",
20
+ "directory": "packages/react-native-legal"
21
+ },
22
+ "author": "Mateusz Mędrek <luigimario1913@gmail.com> (https://github.com/mateusz1913)",
23
+ "license": "MIT",
24
+ "bugs": {
25
+ "url": "https://github.com/callstackincubator/react-native-legal/issues"
26
+ },
27
+ "homepage": "https://github.com/callstackincubator/react-native-legal#readme",
28
+ "publishConfig": {
29
+ "registry": "https://registry.npmjs.org/"
30
+ },
31
+ "files": [
32
+ "android/src",
33
+ "android/build.gradle",
34
+ "android/react-native-helpers.gradle",
35
+ "bare-plugin",
36
+ "ios",
37
+ "lib",
38
+ "plugin",
39
+ "plugin-utils",
40
+ "src",
41
+ "LICENSE",
42
+ "app.plugin.js",
43
+ "react-native.config.js",
44
+ "ReactNativeLegal.podspec"
45
+ ],
46
+ "scripts": {
47
+ "build-library": "bob build",
48
+ "build-plugins": "tsc -p plugin-utils/tsconfig.json && tsc -p bare-plugin/tsconfig.json && tsc -p plugin/tsconfig.json",
49
+ "prepare": "yarn build-plugins && yarn build-library && cp ../../README.md ../../LICENSE .",
50
+ "tsc": "tsc"
51
+ },
52
+ "devDependencies": {
53
+ "@types/xml2js": "^0.4.11",
54
+ "expo": "~52.0.36",
55
+ "expo-module-scripts": "^4.0.0",
56
+ "react": "18.3.1",
57
+ "react-native": "0.76.7",
58
+ "react-native-builder-bob": "0.23.1"
59
+ },
60
+ "dependencies": {
61
+ "glob": "^7.1.3",
62
+ "xcode": "^3.0.1",
63
+ "xml2js": "^0.6.2"
64
+ },
65
+ "peerDependencies": {
66
+ "expo": ">=52.0.0",
67
+ "react-native": ">=0.76.0"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "expo": {
71
+ "optional": true
72
+ }
73
+ },
74
+ "react-native-builder-bob": {
75
+ "source": "src",
76
+ "output": "lib",
77
+ "targets": [
78
+ "commonjs",
79
+ "module",
80
+ [
81
+ "typescript",
82
+ {
83
+ "project": "tsconfig.json",
84
+ "tsc": "../../node_modules/typescript/bin/tsc"
85
+ }
86
+ ]
87
+ ]
88
+ },
89
+ "codegenConfig": {
90
+ "name": "ReactNativeLegal",
91
+ "type": "all",
92
+ "jsSrcsDir": "./src",
93
+ "android": {
94
+ "javaPackageName": "com.reactnativelegal"
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,5 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ /**
3
+ * Adds an Android Activity with list of dependencies and their licenses to project's AndroidManifest.xml
4
+ */
5
+ export declare function addListActivity(config: ExpoConfig): ExpoConfig;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addListActivity = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ const android_1 = require("../../../plugin-utils/build/android");
6
+ /**
7
+ * Adds an Android Activity with list of dependencies and their licenses to project's AndroidManifest.xml
8
+ */
9
+ function addListActivity(config) {
10
+ return (0, config_plugins_1.withAndroidManifest)(config, (exportedConfig) => {
11
+ if (exportedConfig.modResults.manifest.application?.[0].activity) {
12
+ exportedConfig.modResults.manifest.application[0].activity = (0, android_1.addListActivityUtil)(exportedConfig.modResults.manifest.application[0].activity);
13
+ }
14
+ return exportedConfig;
15
+ });
16
+ }
17
+ exports.addListActivity = addListActivity;
@@ -0,0 +1,7 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ /**
3
+ * Modifies application's build.gradle with AboutLibraries plugin
4
+ *
5
+ * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
6
+ */
7
+ export declare function applyAndConfigureAboutLibrariesPlugin(config: ExpoConfig): ExpoConfig;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyAndConfigureAboutLibrariesPlugin = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ const android_1 = require("../../../plugin-utils/build/android");
6
+ /**
7
+ * Modifies application's build.gradle with AboutLibraries plugin
8
+ *
9
+ * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
10
+ */
11
+ function applyAndConfigureAboutLibrariesPlugin(config) {
12
+ return (0, config_plugins_1.withAppBuildGradle)(config, (exportedConfig) => {
13
+ if (exportedConfig.modResults.language === 'groovy') {
14
+ exportedConfig.modResults.contents = (0, android_1.applyAndConfigureAboutLibrariesPluginUtil)(exportedConfig.modResults.contents);
15
+ }
16
+ else {
17
+ console.warn('Gradle Kotlin scripts are not supported yet');
18
+ }
19
+ return exportedConfig;
20
+ });
21
+ }
22
+ exports.applyAndConfigureAboutLibrariesPlugin = applyAndConfigureAboutLibrariesPlugin;
@@ -0,0 +1,7 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ /**
3
+ * Modifies root build.gradle with a declaration for AboutLibraries Gradle plugin
4
+ *
5
+ * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
6
+ */
7
+ export declare function declareAboutLibrariesPlugin(config: ExpoConfig): ExpoConfig;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.declareAboutLibrariesPlugin = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ const android_1 = require("../../../plugin-utils/build/android");
6
+ /**
7
+ * Modifies root build.gradle with a declaration for AboutLibraries Gradle plugin
8
+ *
9
+ * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
10
+ */
11
+ function declareAboutLibrariesPlugin(config) {
12
+ return (0, config_plugins_1.withProjectBuildGradle)(config, (exportedConfig) => {
13
+ if (exportedConfig.modResults.language === 'groovy') {
14
+ exportedConfig.modResults.contents = (0, android_1.declareAboutLibrariesPluginUtil)(exportedConfig.modResults.contents);
15
+ }
16
+ else {
17
+ console.warn('Gradle Kotlin scripts are not supported yet');
18
+ }
19
+ return exportedConfig;
20
+ });
21
+ }
22
+ exports.declareAboutLibrariesPlugin = declareAboutLibrariesPlugin;
@@ -0,0 +1,8 @@
1
+ import { type ConfigPlugin } from 'expo/config-plugins';
2
+ /**
3
+ * Implementation of config plugin for Android setup
4
+ *
5
+ * It scans the NPM dependencies, generates AboutLibraries-compatible metadata,
6
+ * installs & configures AboutLibraries Gradle plugin and adds Android Activity with a list of dependencies and their licenses
7
+ */
8
+ export declare const withAndroidLegal: ConfigPlugin;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withAndroidLegal = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const config_plugins_1 = require("expo/config-plugins");
9
+ const common_1 = require("../../../plugin-utils/build/common");
10
+ const addListActivity_1 = require("./addListActivity");
11
+ const applyAndConfigureAboutLibrariesPlugin_1 = require("./applyAndConfigureAboutLibrariesPlugin");
12
+ const declareAboutLibrariesPlugin_1 = require("./declareAboutLibrariesPlugin");
13
+ /**
14
+ * Implementation of config plugin for Android setup
15
+ *
16
+ * It scans the NPM dependencies, generates AboutLibraries-compatible metadata,
17
+ * installs & configures AboutLibraries Gradle plugin and adds Android Activity with a list of dependencies and their licenses
18
+ */
19
+ const withAndroidLegal = (config) => {
20
+ (0, config_plugins_1.withAndroidManifest)(config, async (exportedConfig) => {
21
+ const licenses = (0, common_1.scanDependencies)(path_1.default.join(exportedConfig.modRequest.projectRoot, 'package.json'));
22
+ (0, common_1.generateAboutLibrariesNPMOutput)(licenses, exportedConfig.modRequest.platformProjectRoot);
23
+ return exportedConfig;
24
+ });
25
+ config = (0, declareAboutLibrariesPlugin_1.declareAboutLibrariesPlugin)(config);
26
+ config = (0, applyAndConfigureAboutLibrariesPlugin_1.applyAndConfigureAboutLibrariesPlugin)(config);
27
+ config = (0, addListActivity_1.addListActivity)(config);
28
+ return config;
29
+ };
30
+ exports.withAndroidLegal = withAndroidLegal;
@@ -0,0 +1,3 @@
1
+ import type { ConfigPlugin } from 'expo/config-plugins';
2
+ declare const _default: ConfigPlugin<void>;
3
+ export default _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("expo/config-plugins");
4
+ const withAndroidLegal_1 = require("./android/withAndroidLegal");
5
+ const withIosLegal_1 = require("./ios/withIosLegal");
6
+ // eslint-disable-next-line import/no-extraneous-dependencies
7
+ const pak = require('react-native-legal/package.json');
8
+ const withReactNativeLegal = (config) => {
9
+ return (0, config_plugins_1.withPlugins)(config, [withAndroidLegal_1.withAndroidLegal, withIosLegal_1.withIosLegal]);
10
+ };
11
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withReactNativeLegal, pak.name, pak.version);
@@ -0,0 +1,5 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ /**
3
+ * Creates a Settings.bundle and links it to all application native targets
4
+ */
5
+ export declare function addSettingsBundle(config: ExpoConfig): ExpoConfig;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSettingsBundle = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ const ios_1 = require("../../../plugin-utils/build/ios");
6
+ /**
7
+ * Creates a Settings.bundle and links it to all application native targets
8
+ */
9
+ function addSettingsBundle(config) {
10
+ return (0, config_plugins_1.withXcodeProject)(config, (exportedConfig) => {
11
+ (0, ios_1.addSettingsBundleUtil)(exportedConfig.modRequest.platformProjectRoot, ({ settingsBundleFilename }) => {
12
+ const projectName = config_plugins_1.IOSConfig.XcodeUtils.getProjectName(exportedConfig.modRequest.projectRoot);
13
+ const projectTargetId = config_plugins_1.IOSConfig.XcodeUtils.getApplicationNativeTarget({
14
+ project: exportedConfig.modResults,
15
+ projectName,
16
+ }).uuid;
17
+ exportedConfig.modResults = config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
18
+ filepath: settingsBundleFilename,
19
+ groupName: projectName,
20
+ isBuildFile: true,
21
+ project: exportedConfig.modResults,
22
+ targetUuid: projectTargetId,
23
+ });
24
+ });
25
+ return exportedConfig;
26
+ });
27
+ }
28
+ exports.addSettingsBundle = addSettingsBundle;
@@ -0,0 +1,8 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ /**
3
+ * Registers a shell script that invokes generation of license metadata with LicensePlist
4
+ *
5
+ * It looks for the first application native target (Expo projects will only have single native target)
6
+ * for which it creates & links a shell script build phase responsible for iOS native deps license metadata
7
+ */
8
+ export declare function registerLicensePlistBuildPhase(config: ExpoConfig): ExpoConfig;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerLicensePlistBuildPhase = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ const ios_1 = require("../../../plugin-utils/build/ios");
6
+ /**
7
+ * Registers a shell script that invokes generation of license metadata with LicensePlist
8
+ *
9
+ * It looks for the first application native target (Expo projects will only have single native target)
10
+ * for which it creates & links a shell script build phase responsible for iOS native deps license metadata
11
+ */
12
+ function registerLicensePlistBuildPhase(config) {
13
+ return (0, config_plugins_1.withXcodeProject)(config, (exportedConfig) => {
14
+ const projectName = config_plugins_1.IOSConfig.XcodeUtils.getProjectName(exportedConfig.modRequest.projectRoot);
15
+ const projectTargetId = config_plugins_1.IOSConfig.XcodeUtils.getApplicationNativeTarget({
16
+ project: exportedConfig.modResults,
17
+ projectName,
18
+ }).uuid;
19
+ exportedConfig.modResults = (0, ios_1.registerLicensePlistBuildPhaseUtil)(projectTargetId, exportedConfig.modResults);
20
+ return exportedConfig;
21
+ });
22
+ }
23
+ exports.registerLicensePlistBuildPhase = registerLicensePlistBuildPhase;
@@ -0,0 +1,8 @@
1
+ import { type ConfigPlugin } from 'expo/config-plugins';
2
+ /**
3
+ * Implementation of config plugin for iOS setup
4
+ *
5
+ * It scans the NPM dependencies, generates LicensePlist-compatible metadata,
6
+ * configures Settings.bundle and registers a shell script generating LicensePlist metadata for iOS dependencies
7
+ */
8
+ export declare const withIosLegal: ConfigPlugin;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withIosLegal = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const config_plugins_1 = require("expo/config-plugins");
9
+ const common_1 = require("../../../plugin-utils/build/common");
10
+ const addSettingsBundle_1 = require("./addSettingsBundle");
11
+ const registerLicensePlistBuildPhase_1 = require("./registerLicensePlistBuildPhase");
12
+ /**
13
+ * Implementation of config plugin for iOS setup
14
+ *
15
+ * It scans the NPM dependencies, generates LicensePlist-compatible metadata,
16
+ * configures Settings.bundle and registers a shell script generating LicensePlist metadata for iOS dependencies
17
+ */
18
+ const withIosLegal = (config) => {
19
+ (0, config_plugins_1.withXcodeProject)(config, async (exportedConfig) => {
20
+ const licenses = (0, common_1.scanDependencies)(path_1.default.join(exportedConfig.modRequest.projectRoot, 'package.json'));
21
+ (0, common_1.generateLicensePlistNPMOutput)(licenses, exportedConfig.modRequest.platformProjectRoot);
22
+ return exportedConfig;
23
+ });
24
+ config = (0, addSettingsBundle_1.addSettingsBundle)(config);
25
+ config = (0, registerLicensePlistBuildPhase_1.registerLicensePlistBuildPhase)(config);
26
+ return config;
27
+ };
28
+ exports.withIosLegal = withIosLegal;
@@ -0,0 +1 @@
1
+ module.exports = require('expo-module-scripts/jest-preset-plugin');
@@ -0,0 +1,19 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ import { withAndroidManifest } from 'expo/config-plugins';
3
+
4
+ import { addListActivityUtil } from '../../../plugin-utils/build/android';
5
+
6
+ /**
7
+ * Adds an Android Activity with list of dependencies and their licenses to project's AndroidManifest.xml
8
+ */
9
+ export function addListActivity(config: ExpoConfig): ExpoConfig {
10
+ return withAndroidManifest(config, (exportedConfig) => {
11
+ if (exportedConfig.modResults.manifest.application?.[0].activity) {
12
+ exportedConfig.modResults.manifest.application[0].activity = addListActivityUtil(
13
+ exportedConfig.modResults.manifest.application[0].activity,
14
+ );
15
+ }
16
+
17
+ return exportedConfig;
18
+ });
19
+ }
@@ -0,0 +1,23 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ import { withAppBuildGradle } from 'expo/config-plugins';
3
+
4
+ import { applyAndConfigureAboutLibrariesPluginUtil } from '../../../plugin-utils/build/android';
5
+
6
+ /**
7
+ * Modifies application's build.gradle with AboutLibraries plugin
8
+ *
9
+ * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
10
+ */
11
+ export function applyAndConfigureAboutLibrariesPlugin(config: ExpoConfig): ExpoConfig {
12
+ return withAppBuildGradle(config, (exportedConfig) => {
13
+ if (exportedConfig.modResults.language === 'groovy') {
14
+ exportedConfig.modResults.contents = applyAndConfigureAboutLibrariesPluginUtil(
15
+ exportedConfig.modResults.contents,
16
+ );
17
+ } else {
18
+ console.warn('Gradle Kotlin scripts are not supported yet');
19
+ }
20
+
21
+ return exportedConfig;
22
+ });
23
+ }
@@ -0,0 +1,21 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ import { withProjectBuildGradle } from 'expo/config-plugins';
3
+
4
+ import { declareAboutLibrariesPluginUtil } from '../../../plugin-utils/build/android';
5
+
6
+ /**
7
+ * Modifies root build.gradle with a declaration for AboutLibraries Gradle plugin
8
+ *
9
+ * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
10
+ */
11
+ export function declareAboutLibrariesPlugin(config: ExpoConfig): ExpoConfig {
12
+ return withProjectBuildGradle(config, (exportedConfig) => {
13
+ if (exportedConfig.modResults.language === 'groovy') {
14
+ exportedConfig.modResults.contents = declareAboutLibrariesPluginUtil(exportedConfig.modResults.contents);
15
+ } else {
16
+ console.warn('Gradle Kotlin scripts are not supported yet');
17
+ }
18
+
19
+ return exportedConfig;
20
+ });
21
+ }
@@ -0,0 +1,28 @@
1
+ import path from 'path';
2
+
3
+ import { type ConfigPlugin, withAndroidManifest } from 'expo/config-plugins';
4
+
5
+ import { generateAboutLibrariesNPMOutput, scanDependencies } from '../../../plugin-utils/build/common';
6
+
7
+ import { addListActivity } from './addListActivity';
8
+ import { applyAndConfigureAboutLibrariesPlugin } from './applyAndConfigureAboutLibrariesPlugin';
9
+ import { declareAboutLibrariesPlugin } from './declareAboutLibrariesPlugin';
10
+
11
+ /**
12
+ * Implementation of config plugin for Android setup
13
+ *
14
+ * It scans the NPM dependencies, generates AboutLibraries-compatible metadata,
15
+ * installs & configures AboutLibraries Gradle plugin and adds Android Activity with a list of dependencies and their licenses
16
+ */
17
+ export const withAndroidLegal: ConfigPlugin = (config) => {
18
+ withAndroidManifest(config, async (exportedConfig) => {
19
+ const licenses = scanDependencies(path.join(exportedConfig.modRequest.projectRoot, 'package.json'));
20
+
21
+ generateAboutLibrariesNPMOutput(licenses, exportedConfig.modRequest.platformProjectRoot);
22
+ return exportedConfig;
23
+ });
24
+ config = declareAboutLibrariesPlugin(config);
25
+ config = applyAndConfigureAboutLibrariesPlugin(config);
26
+ config = addListActivity(config);
27
+ return config;
28
+ };
@@ -0,0 +1,14 @@
1
+ import type { ConfigPlugin } from 'expo/config-plugins';
2
+ import { createRunOncePlugin, withPlugins } from 'expo/config-plugins';
3
+
4
+ import { withAndroidLegal } from './android/withAndroidLegal';
5
+ import { withIosLegal } from './ios/withIosLegal';
6
+
7
+ // eslint-disable-next-line import/no-extraneous-dependencies
8
+ const pak = require('react-native-legal/package.json');
9
+
10
+ const withReactNativeLegal: ConfigPlugin = (config) => {
11
+ return withPlugins(config, [withAndroidLegal, withIosLegal]);
12
+ };
13
+
14
+ export default createRunOncePlugin(withReactNativeLegal, pak.name, pak.version);
@@ -0,0 +1,29 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ import { IOSConfig, withXcodeProject } from 'expo/config-plugins';
3
+
4
+ import { addSettingsBundleUtil } from '../../../plugin-utils/build/ios';
5
+
6
+ /**
7
+ * Creates a Settings.bundle and links it to all application native targets
8
+ */
9
+ export function addSettingsBundle(config: ExpoConfig): ExpoConfig {
10
+ return withXcodeProject(config, (exportedConfig) => {
11
+ addSettingsBundleUtil(exportedConfig.modRequest.platformProjectRoot, ({ settingsBundleFilename }) => {
12
+ const projectName = IOSConfig.XcodeUtils.getProjectName(exportedConfig.modRequest.projectRoot);
13
+ const projectTargetId = IOSConfig.XcodeUtils.getApplicationNativeTarget({
14
+ project: exportedConfig.modResults,
15
+ projectName,
16
+ }).uuid;
17
+
18
+ exportedConfig.modResults = IOSConfig.XcodeUtils.addResourceFileToGroup({
19
+ filepath: settingsBundleFilename,
20
+ groupName: projectName,
21
+ isBuildFile: true,
22
+ project: exportedConfig.modResults,
23
+ targetUuid: projectTargetId,
24
+ });
25
+ });
26
+
27
+ return exportedConfig;
28
+ });
29
+ }
@@ -0,0 +1,24 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ import { IOSConfig, withXcodeProject } from 'expo/config-plugins';
3
+
4
+ import { registerLicensePlistBuildPhaseUtil } from '../../../plugin-utils/build/ios';
5
+
6
+ /**
7
+ * Registers a shell script that invokes generation of license metadata with LicensePlist
8
+ *
9
+ * It looks for the first application native target (Expo projects will only have single native target)
10
+ * for which it creates & links a shell script build phase responsible for iOS native deps license metadata
11
+ */
12
+ export function registerLicensePlistBuildPhase(config: ExpoConfig): ExpoConfig {
13
+ return withXcodeProject(config, (exportedConfig) => {
14
+ const projectName = IOSConfig.XcodeUtils.getProjectName(exportedConfig.modRequest.projectRoot);
15
+ const projectTargetId = IOSConfig.XcodeUtils.getApplicationNativeTarget({
16
+ project: exportedConfig.modResults,
17
+ projectName,
18
+ }).uuid;
19
+
20
+ exportedConfig.modResults = registerLicensePlistBuildPhaseUtil(projectTargetId, exportedConfig.modResults);
21
+
22
+ return exportedConfig;
23
+ });
24
+ }
@@ -0,0 +1,26 @@
1
+ import path from 'path';
2
+
3
+ import { type ConfigPlugin, withXcodeProject } from 'expo/config-plugins';
4
+
5
+ import { generateLicensePlistNPMOutput, scanDependencies } from '../../../plugin-utils/build/common';
6
+
7
+ import { addSettingsBundle } from './addSettingsBundle';
8
+ import { registerLicensePlistBuildPhase } from './registerLicensePlistBuildPhase';
9
+
10
+ /**
11
+ * Implementation of config plugin for iOS setup
12
+ *
13
+ * It scans the NPM dependencies, generates LicensePlist-compatible metadata,
14
+ * configures Settings.bundle and registers a shell script generating LicensePlist metadata for iOS dependencies
15
+ */
16
+ export const withIosLegal: ConfigPlugin = (config) => {
17
+ withXcodeProject(config, async (exportedConfig) => {
18
+ const licenses = scanDependencies(path.join(exportedConfig.modRequest.projectRoot, 'package.json'));
19
+
20
+ generateLicensePlistNPMOutput(licenses, exportedConfig.modRequest.platformProjectRoot);
21
+ return exportedConfig;
22
+ });
23
+ config = addSettingsBundle(config);
24
+ config = registerLicensePlistBuildPhase(config);
25
+ return config;
26
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "expo-module-scripts/tsconfig.plugin",
3
+ "compilerOptions": {
4
+ "outDir": "build",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Applies Gradle Plugin Portal & AboutLibraries Gradle plugin repositories (if needed) inside root build.gradle
3
+ */
4
+ export declare function declareAboutLibrariesPluginUtil(androidBuildGradleContent: string): string;
5
+ /**
6
+ * Applies and configures AboutLibraries Grale plugin (if needed) inside app's build.gradle
7
+ */
8
+ export declare function applyAndConfigureAboutLibrariesPluginUtil(androidAppBuildGradleContent: string): string;
9
+ /**
10
+ * adds a list activity to the list of application's activities
11
+ */
12
+ export declare function addListActivityUtil<T>(activities: T[]): T[];