Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. // Updates SDK overrides dependencies.
  65. for (const key in packageJSON.overrides) {
  66. if (SDKPackageJSON.overrides.hasOwnProperty(key)) {
  67. SDKPackageJSON.overrides[key] = packageJSON.overrides[key];
  68. }
  69. }
  70. const data = JSON.stringify(SDKPackageJSON, null, 4);
  71. fs.writeFileSync('package.json', data);
  72. }
  73. // TODO: put this in a seperate step
  74. mergeDependencyVersions();
  75. copyFolderRecursiveSync(
  76. '../images',
  77. '.'
  78. );
  79. copyFolderRecursiveSync(
  80. '../sounds',
  81. '.'
  82. );
  83. copyFolderRecursiveSync(
  84. '../lang',
  85. '.'
  86. );
  87. copyFolderRecursiveSync(
  88. '../modules',
  89. '.'
  90. );
  91. copyFolderRecursiveSync(
  92. '../react',
  93. '.'
  94. );
  95. copyFolderRecursiveSync(
  96. '../service',
  97. '.'
  98. );
  99. copyFolderRecursiveSync(
  100. '../ios/sdk/sdk.xcodeproj',
  101. './ios'
  102. );
  103. copyFolderRecursiveSync(
  104. `${iosSrcPath}/callkit`,
  105. iosDestPath
  106. );
  107. copyFolderRecursiveSync(
  108. `${iosSrcPath}/dropbox`,
  109. iosDestPath
  110. );
  111. fs.copyFileSync(
  112. `${iosSrcPath}/AppInfo.m`,
  113. `${iosDestPath}/AppInfo.m`
  114. );
  115. fs.copyFileSync(
  116. `${iosSrcPath}/AudioMode.m`,
  117. `${iosDestPath}/AudioMode.m`
  118. );
  119. fs.copyFileSync(
  120. `${iosSrcPath}/InfoPlistUtil.m`,
  121. `${iosDestPath}/InfoPlistUtil.m`
  122. );
  123. fs.copyFileSync(
  124. `${iosSrcPath}/InfoPlistUtil.h`,
  125. `${iosDestPath}/InfoPlistUtil.h`
  126. );
  127. fs.copyFileSync(
  128. `${iosSrcPath}/JavaScriptSandbox.m`,
  129. `${iosDestPath}/JavaScriptSandbox.m`
  130. );
  131. fs.copyFileSync(
  132. `${iosSrcPath}/JitsiAudioSession.m`,
  133. `${iosDestPath}/JitsiAudioSession.m`
  134. );
  135. fs.copyFileSync(
  136. `${iosSrcPath}/JitsiAudioSession.h`,
  137. `${iosDestPath}/JitsiAudioSession.h`
  138. );
  139. fs.copyFileSync(
  140. `${iosSrcPath}/JitsiAudioSession+Private.h`,
  141. `${iosDestPath}/JitsiAudioSession+Private.h`
  142. );
  143. fs.copyFileSync(
  144. `${iosSrcPath}/LocaleDetector.m`,
  145. `${iosDestPath}/LocaleDetector.m`
  146. );
  147. fs.copyFileSync(
  148. `${iosSrcPath}/POSIX.m`,
  149. `${iosDestPath}/POSIX.m`
  150. );
  151. fs.copyFileSync(
  152. `${iosSrcPath}/Proximity.m`,
  153. `${iosDestPath}/Proximity.m`
  154. );
  155. copyFolderRecursiveSync(
  156. `${androidSourcePath}/log`,
  157. `${androidTargetPath}/log`
  158. );
  159. copyFolderRecursiveSync(
  160. `${androidMainSourcePath}/values`,
  161. `${androidMainTargetPath}`
  162. );
  163. copyFolderRecursiveSync(
  164. `${androidMainSourcePath}/drawable-hdpi`,
  165. `${androidMainTargetPath}`
  166. );
  167. copyFolderRecursiveSync(
  168. `${androidMainSourcePath}/drawable-mdpi`,
  169. `${androidMainTargetPath}`
  170. );
  171. copyFolderRecursiveSync(
  172. `${androidMainSourcePath}/drawable-xhdpi`,
  173. `${androidMainTargetPath}`
  174. );
  175. copyFolderRecursiveSync(
  176. `${androidMainSourcePath}/drawable-xxhdpi`,
  177. `${androidMainTargetPath}`
  178. );
  179. copyFolderRecursiveSync(
  180. `${androidMainSourcePath}/drawable-xxxhdpi`,
  181. `${androidMainTargetPath}`
  182. );
  183. copyFolderRecursiveSync(
  184. `${androidSourcePath}/net`,
  185. `${androidTargetPath}/log`
  186. );
  187. fs.copyFileSync(
  188. `${androidSourcePath}/AndroidSettingsModule.java`,
  189. `${androidTargetPath}/AndroidSettingsModule.java`
  190. );
  191. fs.copyFileSync(
  192. `${androidSourcePath}/AppInfoModule.java`,
  193. `${androidTargetPath}/AppInfoModule.java`
  194. );
  195. fs.copyFileSync(
  196. `${androidSourcePath}/AudioDeviceHandlerConnectionService.java`,
  197. `${androidTargetPath}/AudioDeviceHandlerConnectionService.java`
  198. );
  199. fs.copyFileSync(
  200. `${androidSourcePath}/AudioDeviceHandlerGeneric.java`,
  201. `${androidTargetPath}/AudioDeviceHandlerGeneric.java`
  202. );
  203. fs.copyFileSync(
  204. `${androidSourcePath}/AudioModeModule.java`,
  205. `${androidTargetPath}/AudioModeModule.java`
  206. );
  207. fs.copyFileSync(
  208. `${androidSourcePath}/ConnectionService.java`,
  209. `${androidTargetPath}/ConnectionService.java`
  210. );
  211. fs.copyFileSync(
  212. `${androidSourcePath}/JavaScriptSandboxModule.java`,
  213. `${androidTargetPath}/JavaScriptSandboxModule.java`
  214. );
  215. fs.copyFileSync(
  216. `${androidSourcePath}/LocaleDetector.java`,
  217. `${androidTargetPath}/LocaleDetector.java`
  218. );
  219. fs.copyFileSync(
  220. `${androidSourcePath}/LogBridgeModule.java`,
  221. `${androidTargetPath}/LogBridgeModule.java`
  222. );
  223. fs.copyFileSync(
  224. `${androidSourcePath}/PictureInPictureModule.java`,
  225. `${androidTargetPath}/PictureInPictureModule.java`
  226. );
  227. fs.copyFileSync(
  228. `${androidSourcePath}/ProximityModule.java`,
  229. `${androidTargetPath}/ProximityModule.java`
  230. );
  231. fs.copyFileSync(
  232. `${androidSourcePath}/RNConnectionService.java`,
  233. `${androidTargetPath}/RNConnectionService.java`
  234. );