您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

prepare_sdk.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. const fs = require('fs');
  2. const path = require('path');
  3. const packageJSON = require('../package.json');
  4. const {
  5. androidSourcePath,
  6. androidTargetPath,
  7. iosDestPath,
  8. iosSrcPath
  9. } = require('./constants.ts');
  10. const SDKPackageJSON = require('./package.json');
  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. for (const key in SDKPackageJSON.dependencies) {
  50. if (SDKPackageJSON.dependencies.hasOwnProperty(key)) {
  51. SDKPackageJSON.dependencies[key] = packageJSON.dependencies[key] || packageJSON.devDependencies[key];
  52. }
  53. }
  54. const data = JSON.stringify(SDKPackageJSON, null, 4);
  55. fs.writeFileSync('package.json', data);
  56. }
  57. // TODO: put this in a seperate step
  58. mergeDependencyVersions();
  59. copyFolderRecursiveSync(
  60. '../images',
  61. '.'
  62. );
  63. copyFolderRecursiveSync(
  64. '../sounds',
  65. '.'
  66. );
  67. copyFolderRecursiveSync(
  68. '../lang',
  69. '.'
  70. );
  71. copyFolderRecursiveSync(
  72. '../modules',
  73. '.'
  74. );
  75. copyFolderRecursiveSync(
  76. '../react',
  77. '.'
  78. );
  79. copyFolderRecursiveSync(
  80. '../service',
  81. '.'
  82. );
  83. copyFolderRecursiveSync(
  84. '../ios/sdk/sdk.xcodeproj',
  85. './ios'
  86. );
  87. copyFolderRecursiveSync(
  88. `${iosSrcPath}/callkit`,
  89. iosDestPath
  90. );
  91. copyFolderRecursiveSync(
  92. `${iosSrcPath}/dropbox`,
  93. iosDestPath
  94. );
  95. copyFolderRecursiveSync(
  96. '../ios/sdk/src/picture-in-picture',
  97. iosDestPath
  98. );
  99. fs.copyFileSync(
  100. `${iosSrcPath}/AppInfo.m`,
  101. `${iosDestPath}/AppInfo.m`
  102. );
  103. fs.copyFileSync(
  104. `${iosSrcPath}/AudioMode.m`,
  105. `${iosDestPath}/AudioMode.m`
  106. );
  107. fs.copyFileSync(
  108. `${iosSrcPath}/InfoPlistUtil.m`,
  109. `${iosDestPath}/InfoPlistUtil.m`
  110. );
  111. fs.copyFileSync(
  112. `${iosSrcPath}/InfoPlistUtil.h`,
  113. `${iosDestPath}/InfoPlistUtil.h`
  114. );
  115. fs.copyFileSync(
  116. `${iosSrcPath}/JavaScriptSandbox.m`,
  117. `${iosDestPath}/JavaScriptSandbox.m`
  118. );
  119. fs.copyFileSync(
  120. `${iosSrcPath}/JitsiAudioSession.m`,
  121. `${iosDestPath}/JitsiAudioSession.m`
  122. );
  123. fs.copyFileSync(
  124. `${iosSrcPath}/JitsiAudioSession.h`,
  125. `${iosDestPath}/JitsiAudioSession.h`
  126. );
  127. fs.copyFileSync(
  128. `${iosSrcPath}/JitsiAudioSession+Private.h`,
  129. `${iosDestPath}/JitsiAudioSession+Private.h`
  130. );
  131. fs.copyFileSync(
  132. `${iosSrcPath}/LocaleDetector.m`,
  133. `${iosDestPath}/LocaleDetector.m`
  134. );
  135. fs.copyFileSync(
  136. `${iosSrcPath}/POSIX.m`,
  137. `${iosDestPath}/POSIX.m`
  138. );
  139. fs.copyFileSync(
  140. `${iosSrcPath}/Proximity.m`,
  141. `${iosDestPath}/Proximity.m`
  142. );
  143. copyFolderRecursiveSync(
  144. `${androidSourcePath}/log`,
  145. `${androidTargetPath}/log`
  146. );
  147. copyFolderRecursiveSync(
  148. `${androidSourcePath}/net`,
  149. `${androidTargetPath}/log`
  150. );
  151. fs.copyFileSync(
  152. `${androidSourcePath}/AndroidSettingsModule.java`,
  153. `${androidTargetPath}/AndroidSettingsModule.java`
  154. );
  155. fs.copyFileSync(
  156. `${androidSourcePath}/AppInfoModule.java`,
  157. `${androidTargetPath}/AppInfoModule.java`
  158. );
  159. fs.copyFileSync(
  160. `${androidSourcePath}/AudioDeviceHandlerConnectionService.java`,
  161. `${androidTargetPath}/AudioDeviceHandlerConnectionService.java`
  162. );
  163. fs.copyFileSync(
  164. `${androidSourcePath}/AudioDeviceHandlerGeneric.java`,
  165. `${androidTargetPath}/AudioDeviceHandlerGeneric.java`
  166. );
  167. fs.copyFileSync(
  168. `${androidSourcePath}/AudioModeModule.java`,
  169. `${androidTargetPath}/AudioModeModule.java`
  170. );
  171. fs.copyFileSync(
  172. `${androidSourcePath}/ConnectionService.java`,
  173. `${androidTargetPath}/ConnectionService.java`
  174. );
  175. fs.copyFileSync(
  176. `${androidSourcePath}/JavaScriptSandboxModule.java`,
  177. `${androidTargetPath}/JavaScriptSandboxModule.java`
  178. );
  179. fs.copyFileSync(
  180. `${androidSourcePath}/LocaleDetector.java`,
  181. `${androidTargetPath}/LocaleDetector.java`
  182. );
  183. fs.copyFileSync(
  184. `${androidSourcePath}/LogBridgeModule.java`,
  185. `${androidTargetPath}/LogBridgeModule.java`
  186. );
  187. fs.copyFileSync(
  188. `${androidSourcePath}/PictureInPictureModule.java`,
  189. `${androidTargetPath}/PictureInPictureModule.java`
  190. );
  191. fs.copyFileSync(
  192. `${androidSourcePath}/ProximityModule.java`,
  193. `${androidTargetPath}/ProximityModule.java`
  194. );
  195. fs.copyFileSync(
  196. `${androidSourcePath}/RNConnectionService.java`,
  197. `${androidTargetPath}/RNConnectionService.java`
  198. );