You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

prepare_sdk.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. const fs = require('fs');
  2. const path = require('path');
  3. const packageJSON = require('../package.json');
  4. const SDKPackageJSON = require('./package.json');
  5. const androidSourcePath = '../android/sdk/src/main/java/org/jitsi/meet/sdk';
  6. const androidMainSourcePath = '../android/sdk/src/main/res';
  7. const androidTargetPath = './android/src/main/java/org/jitsi/meet/sdk';
  8. const androidMainTargetPath = './android/src/main/res';
  9. const iosSrcPath = '../ios/sdk/src';
  10. const iosDestPath = './ios/src';
  11. /**
  12. * Copies a specified file in a way that recursive copy is possible.
  13. */
  14. function copyFileSync(source, target) {
  15. let targetFile = target;
  16. // If target is a directory, a new file with the same name will be created
  17. if (fs.existsSync(target)) {
  18. if (fs.lstatSync(target).isDirectory()) {
  19. targetFile = path.join(target, path.basename(source));
  20. }
  21. }
  22. fs.copyFileSync(source, targetFile);
  23. }
  24. /**
  25. * Copies a specified directory recursively.
  26. */
  27. function copyFolderRecursiveSync(source, target) {
  28. let files = [];
  29. const targetFolder = path.join(target, path.basename(source));
  30. if (!fs.existsSync(targetFolder)) {
  31. fs.mkdirSync(targetFolder, { recursive: true });
  32. }
  33. if (fs.lstatSync(source).isDirectory()) {
  34. files = fs.readdirSync(source);
  35. files.forEach(file => {
  36. const curSource = path.join(source, file);
  37. if (fs.lstatSync(curSource).isDirectory()) {
  38. copyFolderRecursiveSync(curSource, targetFolder);
  39. } else {
  40. copyFileSync(curSource, targetFolder);
  41. }
  42. });
  43. }
  44. }
  45. /**
  46. * Merges the dependency versions from the root package.json with the dependencies of the SDK package.json.
  47. */
  48. function mergeDependencyVersions() {
  49. // Updates SDK dependencies to match project dependencies.
  50. for (const key in SDKPackageJSON.dependencies) {
  51. if (SDKPackageJSON.dependencies.hasOwnProperty(key)) {
  52. SDKPackageJSON.dependencies[key] = packageJSON.dependencies[key] || packageJSON.devDependencies[key];
  53. }
  54. }
  55. // Updates SDK peer dependencies.
  56. for (const key in packageJSON.dependencies) {
  57. if (SDKPackageJSON.peerDependencies.hasOwnProperty(key)) {
  58. // Updates all peer dependencies except react and react-native.
  59. if (key !== 'react' && key !== 'react-native') {
  60. SDKPackageJSON.peerDependencies[key] = packageJSON.dependencies[key];
  61. }
  62. }
  63. }
  64. const data = JSON.stringify(SDKPackageJSON, null, 4);
  65. fs.writeFileSync('package.json', data);
  66. }
  67. // TODO: put this in a seperate step
  68. mergeDependencyVersions();
  69. copyFolderRecursiveSync(
  70. '../images',
  71. '.'
  72. );
  73. copyFolderRecursiveSync(
  74. '../sounds',
  75. '.'
  76. );
  77. copyFolderRecursiveSync(
  78. '../lang',
  79. '.'
  80. );
  81. copyFolderRecursiveSync(
  82. '../modules',
  83. '.'
  84. );
  85. copyFolderRecursiveSync(
  86. '../react',
  87. '.'
  88. );
  89. copyFolderRecursiveSync(
  90. '../service',
  91. '.'
  92. );
  93. copyFolderRecursiveSync(
  94. '../ios/sdk/sdk.xcodeproj',
  95. './ios'
  96. );
  97. copyFolderRecursiveSync(
  98. `${iosSrcPath}/callkit`,
  99. iosDestPath
  100. );
  101. copyFolderRecursiveSync(
  102. `${iosSrcPath}/dropbox`,
  103. iosDestPath
  104. );
  105. fs.copyFileSync(
  106. `${iosSrcPath}/AppInfo.m`,
  107. `${iosDestPath}/AppInfo.m`
  108. );
  109. fs.copyFileSync(
  110. `${iosSrcPath}/AudioMode.m`,
  111. `${iosDestPath}/AudioMode.m`
  112. );
  113. fs.copyFileSync(
  114. `${iosSrcPath}/InfoPlistUtil.m`,
  115. `${iosDestPath}/InfoPlistUtil.m`
  116. );
  117. fs.copyFileSync(
  118. `${iosSrcPath}/InfoPlistUtil.h`,
  119. `${iosDestPath}/InfoPlistUtil.h`
  120. );
  121. fs.copyFileSync(
  122. `${iosSrcPath}/JavaScriptSandbox.m`,
  123. `${iosDestPath}/JavaScriptSandbox.m`
  124. );
  125. fs.copyFileSync(
  126. `${iosSrcPath}/JitsiAudioSession.m`,
  127. `${iosDestPath}/JitsiAudioSession.m`
  128. );
  129. fs.copyFileSync(
  130. `${iosSrcPath}/JitsiAudioSession.h`,
  131. `${iosDestPath}/JitsiAudioSession.h`
  132. );
  133. fs.copyFileSync(
  134. `${iosSrcPath}/JitsiAudioSession+Private.h`,
  135. `${iosDestPath}/JitsiAudioSession+Private.h`
  136. );
  137. fs.copyFileSync(
  138. `${iosSrcPath}/LocaleDetector.m`,
  139. `${iosDestPath}/LocaleDetector.m`
  140. );
  141. fs.copyFileSync(
  142. `${iosSrcPath}/POSIX.m`,
  143. `${iosDestPath}/POSIX.m`
  144. );
  145. fs.copyFileSync(
  146. `${iosSrcPath}/Proximity.m`,
  147. `${iosDestPath}/Proximity.m`
  148. );
  149. copyFolderRecursiveSync(
  150. `${androidSourcePath}/log`,
  151. `${androidTargetPath}/log`
  152. );
  153. copyFolderRecursiveSync(
  154. `${androidMainSourcePath}/values`,
  155. `${androidMainTargetPath}`
  156. );
  157. copyFolderRecursiveSync(
  158. `${androidMainSourcePath}/drawable-hdpi`,
  159. `${androidMainTargetPath}`
  160. );
  161. copyFolderRecursiveSync(
  162. `${androidMainSourcePath}/drawable-mdpi`,
  163. `${androidMainTargetPath}`
  164. );
  165. copyFolderRecursiveSync(
  166. `${androidMainSourcePath}/drawable-xhdpi`,
  167. `${androidMainTargetPath}`
  168. );
  169. copyFolderRecursiveSync(
  170. `${androidMainSourcePath}/drawable-xxhdpi`,
  171. `${androidMainTargetPath}`
  172. );
  173. copyFolderRecursiveSync(
  174. `${androidMainSourcePath}/drawable-xxxhdpi`,
  175. `${androidMainTargetPath}`
  176. );
  177. copyFolderRecursiveSync(
  178. `${androidSourcePath}/net`,
  179. `${androidTargetPath}/log`
  180. );
  181. fs.copyFileSync(
  182. `${androidSourcePath}/AndroidSettingsModule.java`,
  183. `${androidTargetPath}/AndroidSettingsModule.java`
  184. );
  185. fs.copyFileSync(
  186. `${androidSourcePath}/AppInfoModule.java`,
  187. `${androidTargetPath}/AppInfoModule.java`
  188. );
  189. fs.copyFileSync(
  190. `${androidSourcePath}/AudioDeviceHandlerConnectionService.java`,
  191. `${androidTargetPath}/AudioDeviceHandlerConnectionService.java`
  192. );
  193. fs.copyFileSync(
  194. `${androidSourcePath}/AudioDeviceHandlerGeneric.java`,
  195. `${androidTargetPath}/AudioDeviceHandlerGeneric.java`
  196. );
  197. fs.copyFileSync(
  198. `${androidSourcePath}/AudioModeModule.java`,
  199. `${androidTargetPath}/AudioModeModule.java`
  200. );
  201. fs.copyFileSync(
  202. `${androidSourcePath}/ConnectionService.java`,
  203. `${androidTargetPath}/ConnectionService.java`
  204. );
  205. fs.copyFileSync(
  206. `${androidSourcePath}/JavaScriptSandboxModule.java`,
  207. `${androidTargetPath}/JavaScriptSandboxModule.java`
  208. );
  209. fs.copyFileSync(
  210. `${androidSourcePath}/LocaleDetector.java`,
  211. `${androidTargetPath}/LocaleDetector.java`
  212. );
  213. fs.copyFileSync(
  214. `${androidSourcePath}/LogBridgeModule.java`,
  215. `${androidTargetPath}/LogBridgeModule.java`
  216. );
  217. fs.copyFileSync(
  218. `${androidSourcePath}/PictureInPictureModule.java`,
  219. `${androidTargetPath}/PictureInPictureModule.java`
  220. );
  221. fs.copyFileSync(
  222. `${androidSourcePath}/ProximityModule.java`,
  223. `${androidTargetPath}/ProximityModule.java`
  224. );
  225. fs.copyFileSync(
  226. `${androidSourcePath}/RNConnectionService.java`,
  227. `${androidTargetPath}/RNConnectionService.java`
  228. );