react-native-builder-bob 0.41.0 → 0.42.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 (187) hide show
  1. package/bin/bob +1 -1
  2. package/lib/package.json +93 -0
  3. package/lib/src/__tests__/babel.test.d.ts +1 -0
  4. package/lib/src/__tests__/babel.test.js +26 -0
  5. package/lib/src/__tests__/babel.test.js.map +1 -0
  6. package/lib/src/__tests__/init.test.d.ts +1 -0
  7. package/lib/src/__tests__/init.test.js +93 -0
  8. package/lib/src/__tests__/init.test.js.map +1 -0
  9. package/lib/src/__tests__/resolveModuleSpecifier.test.d.ts +1 -0
  10. package/lib/src/__tests__/resolveModuleSpecifier.test.js +95 -0
  11. package/lib/src/__tests__/resolveModuleSpecifier.test.js.map +1 -0
  12. package/lib/src/__tests__/typescript.test.d.ts +1 -0
  13. package/lib/src/__tests__/typescript.test.js +193 -0
  14. package/lib/src/__tests__/typescript.test.js.map +1 -0
  15. package/lib/src/__tests__/updateSourceMap.test.d.ts +1 -0
  16. package/lib/src/__tests__/updateSourceMap.test.js +84 -0
  17. package/lib/src/__tests__/updateSourceMap.test.js.map +1 -0
  18. package/lib/src/babel.d.ts +19 -0
  19. package/lib/src/babel.js +58 -0
  20. package/lib/src/babel.js.map +1 -0
  21. package/lib/src/build.d.ts +14 -0
  22. package/lib/src/build.js +122 -0
  23. package/lib/src/build.js.map +1 -0
  24. package/lib/src/configs/babel-config.cjs +46 -0
  25. package/lib/src/configs/babel-config.cjs.map +1 -0
  26. package/lib/src/configs/babel-config.d.cts +15 -0
  27. package/lib/src/configs/babel-preset.cjs +66 -0
  28. package/lib/src/configs/babel-preset.cjs.map +1 -0
  29. package/lib/src/configs/babel-preset.d.cts +19 -0
  30. package/lib/src/configs/metro-config.d.mts +4 -0
  31. package/{configs/metro-config.js → lib/src/configs/metro-config.mjs} +3 -6
  32. package/lib/src/configs/metro-config.mjs.map +1 -0
  33. package/lib/src/configs/vite-config.d.mts +2 -0
  34. package/lib/src/configs/vite-config.mjs +59 -0
  35. package/lib/src/configs/vite-config.mjs.map +1 -0
  36. package/lib/src/index.d.ts +1 -0
  37. package/lib/src/index.js +18 -0
  38. package/lib/src/index.js.map +1 -0
  39. package/lib/src/init.d.ts +1 -0
  40. package/lib/src/init.js +370 -0
  41. package/lib/src/init.js.map +1 -0
  42. package/lib/src/schema.d.ts +70 -0
  43. package/lib/src/schema.js +45 -0
  44. package/lib/src/schema.js.map +1 -0
  45. package/lib/src/targets/codegen/index.d.ts +4 -0
  46. package/lib/src/targets/codegen/index.js +54 -0
  47. package/lib/src/targets/codegen/index.js.map +1 -0
  48. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.d.ts +11 -0
  49. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.js +63 -0
  50. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.js.map +1 -0
  51. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.d.ts +1 -0
  52. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.js +103 -0
  53. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.js.map +1 -0
  54. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.d.ts +16 -0
  55. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.js +59 -0
  56. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.js.map +1 -0
  57. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.d.ts +1 -0
  58. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.js +75 -0
  59. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.js.map +1 -0
  60. package/lib/src/targets/commonjs.d.ts +9 -0
  61. package/lib/src/targets/commonjs.js +19 -0
  62. package/lib/src/targets/commonjs.js.map +1 -0
  63. package/lib/src/targets/custom.d.ts +9 -0
  64. package/lib/src/targets/custom.js +30 -0
  65. package/lib/src/targets/custom.js.map +1 -0
  66. package/lib/src/targets/module.d.ts +9 -0
  67. package/lib/src/targets/module.js +19 -0
  68. package/lib/src/targets/module.js.map +1 -0
  69. package/lib/src/targets/typescript.d.ts +11 -0
  70. package/lib/src/targets/typescript.js +340 -0
  71. package/lib/src/targets/typescript.js.map +1 -0
  72. package/lib/src/types.d.ts +24 -0
  73. package/lib/src/types.js +2 -0
  74. package/lib/src/types.js.map +1 -0
  75. package/lib/src/utils/androidAssemble.d.ts +8 -0
  76. package/lib/src/utils/androidAssemble.js +17 -0
  77. package/lib/src/utils/androidAssemble.js.map +1 -0
  78. package/lib/src/utils/compile.d.ts +16 -0
  79. package/lib/src/utils/compile.js +211 -0
  80. package/lib/src/utils/compile.js.map +1 -0
  81. package/lib/src/utils/isCodegenSpec.d.ts +1 -0
  82. package/lib/src/utils/isCodegenSpec.js +14 -0
  83. package/lib/src/utils/isCodegenSpec.js.map +1 -0
  84. package/lib/src/utils/isGitDirty.d.ts +1 -0
  85. package/lib/src/utils/isGitDirty.js +14 -0
  86. package/lib/src/utils/isGitDirty.js.map +1 -0
  87. package/lib/src/utils/loadConfig.d.ts +4 -0
  88. package/lib/src/utils/loadConfig.js +59 -0
  89. package/lib/src/utils/loadConfig.js.map +1 -0
  90. package/lib/src/utils/logger.d.ts +10 -0
  91. package/lib/src/utils/logger.js +30 -0
  92. package/lib/src/utils/logger.js.map +1 -0
  93. package/lib/src/utils/prompts.d.ts +3 -0
  94. package/lib/src/utils/prompts.js +10 -0
  95. package/lib/src/utils/prompts.js.map +1 -0
  96. package/lib/src/utils/resolveModuleSpecifier.d.ts +21 -0
  97. package/lib/src/utils/resolveModuleSpecifier.js +57 -0
  98. package/lib/src/utils/resolveModuleSpecifier.js.map +1 -0
  99. package/lib/src/utils/spawn.d.ts +2 -0
  100. package/lib/src/utils/spawn.js +41 -0
  101. package/lib/src/utils/spawn.js.map +1 -0
  102. package/lib/src/utils/updateSourceMap.d.ts +11 -0
  103. package/lib/src/utils/updateSourceMap.js +56 -0
  104. package/lib/src/utils/updateSourceMap.js.map +1 -0
  105. package/lib/src/utils/workerize.d.ts +15 -0
  106. package/lib/src/utils/workerize.js +75 -0
  107. package/lib/src/utils/workerize.js.map +1 -0
  108. package/package.json +15 -13
  109. package/configs/babel-config.js +0 -54
  110. package/configs/babel-preset.js +0 -69
  111. package/configs/vite-config.mjs +0 -62
  112. package/lib/__fixtures__/project/MyNativeComponent.js +0 -8
  113. package/lib/__fixtures__/project/MyNativeComponent.js.map +0 -1
  114. package/lib/__fixtures__/project/NativeMyLib.js +0 -2
  115. package/lib/__fixtures__/project/NativeMyLib.js.map +0 -1
  116. package/lib/__fixtures__/project/code/$exports-input.js +0 -121
  117. package/lib/__fixtures__/project/code/$exports-input.js.map +0 -1
  118. package/lib/__fixtures__/project/code/$exports-output.js +0 -121
  119. package/lib/__fixtures__/project/code/$exports-output.js.map +0 -1
  120. package/lib/__fixtures__/project/code/$imports-input.js +0 -24
  121. package/lib/__fixtures__/project/code/$imports-input.js.map +0 -1
  122. package/lib/__fixtures__/project/code/$imports-output.js +0 -20
  123. package/lib/__fixtures__/project/code/$imports-output.js.map +0 -1
  124. package/lib/__fixtures__/project/code/MyNativeComponent.js +0 -8
  125. package/lib/__fixtures__/project/code/MyNativeComponent.js.map +0 -1
  126. package/lib/__fixtures__/project/code/NativeMyLib.js +0 -2
  127. package/lib/__fixtures__/project/code/NativeMyLib.js.map +0 -1
  128. package/lib/__fixtures__/project/code/a.js +0 -2
  129. package/lib/__fixtures__/project/code/a.js.map +0 -1
  130. package/lib/__fixtures__/project/code/b.js +0 -2
  131. package/lib/__fixtures__/project/code/b.js.map +0 -1
  132. package/lib/__fixtures__/project/code/e.story.js +0 -2
  133. package/lib/__fixtures__/project/code/e.story.js.map +0 -1
  134. package/lib/__fixtures__/project/f.js +0 -2
  135. package/lib/__fixtures__/project/f.js.map +0 -1
  136. package/lib/__fixtures__/project/index.js +0 -2
  137. package/lib/__fixtures__/project/index.js.map +0 -1
  138. package/lib/__tests__/babel.test.js +0 -28
  139. package/lib/__tests__/babel.test.js.map +0 -1
  140. package/lib/__tests__/init.test.js +0 -93
  141. package/lib/__tests__/init.test.js.map +0 -1
  142. package/lib/babel.js +0 -92
  143. package/lib/babel.js.map +0 -1
  144. package/lib/build.js +0 -141
  145. package/lib/build.js.map +0 -1
  146. package/lib/index.js +0 -16
  147. package/lib/index.js.map +0 -1
  148. package/lib/init.js +0 -371
  149. package/lib/init.js.map +0 -1
  150. package/lib/schema.js +0 -49
  151. package/lib/schema.js.map +0 -1
  152. package/lib/targets/codegen/index.js +0 -60
  153. package/lib/targets/codegen/index.js.map +0 -1
  154. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.js +0 -74
  155. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.js.map +0 -1
  156. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.test.js +0 -106
  157. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.test.js.map +0 -1
  158. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.js +0 -57
  159. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.js.map +0 -1
  160. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.test.js +0 -78
  161. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.test.js.map +0 -1
  162. package/lib/targets/commonjs.js +0 -34
  163. package/lib/targets/commonjs.js.map +0 -1
  164. package/lib/targets/custom.js +0 -40
  165. package/lib/targets/custom.js.map +0 -1
  166. package/lib/targets/module.js +0 -34
  167. package/lib/targets/module.js.map +0 -1
  168. package/lib/targets/typescript.js +0 -219
  169. package/lib/targets/typescript.js.map +0 -1
  170. package/lib/types.js +0 -6
  171. package/lib/types.js.map +0 -1
  172. package/lib/utils/androidAssemble.js +0 -29
  173. package/lib/utils/androidAssemble.js.map +0 -1
  174. package/lib/utils/compile.js +0 -217
  175. package/lib/utils/compile.js.map +0 -1
  176. package/lib/utils/isCodegenSpec.js +0 -22
  177. package/lib/utils/isCodegenSpec.js.map +0 -1
  178. package/lib/utils/loadConfig.js +0 -56
  179. package/lib/utils/loadConfig.js.map +0 -1
  180. package/lib/utils/logger.js +0 -35
  181. package/lib/utils/logger.js.map +0 -1
  182. package/lib/utils/prompts.js +0 -17
  183. package/lib/utils/prompts.js.map +0 -1
  184. package/lib/utils/spawn.js +0 -48
  185. package/lib/utils/spawn.js.map +0 -1
  186. package/lib/utils/workerize.js +0 -102
  187. package/lib/utils/workerize.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchCodegenAndroidPackage.js","sourceRoot":"","sources":["../../../../../src/targets/codegen/patches/patchCodegenAndroidPackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,CAAC,MAAM,YAAY,GACvB,qFAAqF,CAAC;AAExF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,WAAmB;AACnB,8DAA8D;AAC9D,WAAgB,EAChB,MAAc;IAEd,IAAI,kBAAkB,GACpB,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC;IAChD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,iFAAiF,YAAY,EAAE,CAChG,CAAC;IACJ,CAAC;IACD,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,0DAA0D,kBAAkB,iBAAiB,CAC9F,CAAC;IACJ,CAAC;IAED,MAAM,sBAAsB,GAC1B,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,eAAe,CAAC;IACpD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,uFAAuF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CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CACf,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAEvD,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,CACH,CAAC;IAEF,IACE,MAAM,EAAE,CAAC,UAAU,CACjB,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,sCAAsC,CAAC,CACzE,EACD,CAAC;QACD,yBAAyB;QACzB,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,2BAA2B,CAAC,EAAE;YACzE,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,uCAAuC;QACvC,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,EAAE;YACjE,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,103 @@
1
+ import path from 'node:path';
2
+ import { afterEach, beforeEach, describe, expect, test } from 'vitest';
3
+ import fs from 'fs-extra';
4
+ import mockfs from 'mock-fs';
5
+ import { patchCodegenAndroidPackage } from "./patchCodegenAndroidPackage.js";
6
+ const mockPackageJson = {
7
+ codegenConfig: {
8
+ outputDir: {
9
+ android: 'android/generated',
10
+ },
11
+ android: {
12
+ javaPackageName: 'com.bobtest',
13
+ },
14
+ },
15
+ };
16
+ const mockReport = {
17
+ info: console.log,
18
+ warn: console.log,
19
+ error: console.error,
20
+ success: console.log,
21
+ };
22
+ const mockJavaModuleSpec = `
23
+ /**
24
+ * Some comment
25
+ */
26
+
27
+ package com.facebook.fbreact.specs;
28
+
29
+ import com.example.exampleimport;
30
+
31
+ class SomeClass {
32
+ public void someMethod() {
33
+ // some code
34
+ }
35
+ }`;
36
+ const mockJavaViewSpec = `
37
+ /**
38
+ * Some comment
39
+ */
40
+
41
+ package com.facebook.react.viewmanagers;
42
+
43
+ public interface SomeInterface<T extends View> {
44
+ void setColor(T view, @Nullable String value);
45
+ }
46
+ `;
47
+ const mockProjectPath = path.resolve(import.meta.dirname, 'mockProject');
48
+ const mockCodegenModuleSpecsPath = path.resolve(mockProjectPath, 'android/generated/java/com/facebook/fbreact/specs');
49
+ const mockCodegenViewSpecsPath = path.resolve(mockProjectPath, 'android/generated/java/com/facebook/react/viewmanagers');
50
+ describe('patchCodegenAndroidPackage', () => {
51
+ beforeEach(() => {
52
+ mockfs({
53
+ [mockProjectPath]: {
54
+ 'package.json': JSON.stringify(mockPackageJson),
55
+ },
56
+ [mockCodegenModuleSpecsPath]: {
57
+ 'NativeBobtestSpec.java': mockJavaModuleSpec,
58
+ },
59
+ });
60
+ });
61
+ afterEach(() => {
62
+ mockfs.restore();
63
+ });
64
+ test('moves the files to correct dir', async () => {
65
+ await patchCodegenAndroidPackage(mockProjectPath, mockPackageJson, mockReport);
66
+ const expectedDir = path.resolve(mockProjectPath, 'android/generated/java/com/bobtest');
67
+ expect(await fs.pathExists(expectedDir)).toBe(true);
68
+ });
69
+ test('replaces the package name in the files', async () => {
70
+ await patchCodegenAndroidPackage(mockProjectPath, mockPackageJson, mockReport);
71
+ const expectedDir = path.resolve(mockProjectPath, 'android/generated/java/com/bobtest');
72
+ const expectedFile = path.resolve(expectedDir, 'NativeBobtestSpec.java');
73
+ const fileContent = await fs.readFile(expectedFile, 'utf8');
74
+ expect(fileContent).toContain('package com.bobtest;');
75
+ });
76
+ test('removes the old package dir', async () => {
77
+ await patchCodegenAndroidPackage(mockProjectPath, mockPackageJson, mockReport);
78
+ expect(await fs.pathExists(mockCodegenModuleSpecsPath)).toBe(false);
79
+ });
80
+ test("doesn't delete the view manager specs", async () => {
81
+ const mockPackageJsonWithTypeAll = {
82
+ ...mockPackageJson,
83
+ codegenConfig: {
84
+ ...mockPackageJson.codegenConfig,
85
+ type: 'all',
86
+ },
87
+ };
88
+ mockfs({
89
+ [mockProjectPath]: {
90
+ 'package.json': JSON.stringify(mockPackageJsonWithTypeAll),
91
+ },
92
+ [mockCodegenModuleSpecsPath]: {
93
+ 'NativeBobtestSpec.java': mockJavaModuleSpec,
94
+ },
95
+ [mockCodegenViewSpecsPath]: {
96
+ 'BobtestViewManagerInterface.java': mockJavaViewSpec,
97
+ },
98
+ });
99
+ await patchCodegenAndroidPackage(mockProjectPath, mockPackageJsonWithTypeAll, mockReport);
100
+ expect(await fs.pathExists(path.join(mockCodegenViewSpecsPath, 'BobtestViewManagerInterface.java'))).toBeTruthy();
101
+ });
102
+ });
103
+ //# sourceMappingURL=patchCodegenAndroidPackage.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchCodegenAndroidPackage.test.js","sourceRoot":"","sources":["../../../../../src/targets/codegen/patches/patchCodegenAndroidPackage.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,MAAM,eAAe,GAAG;IACtB,aAAa,EAAE;QACb,SAAS,EAAE;YACT,OAAO,EAAE,mBAAmB;SAC7B;QACD,OAAO,EAAE;YACP,eAAe,EAAE,aAAa;SAC/B;KACF;CACF,CAAC;AAEF,MAAM,UAAU,GAAW;IACzB,IAAI,EAAE,OAAO,CAAC,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG;IACjB,KAAK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,kCAAkC,CAAC,CACxE,CACF,CAAC,UAAU,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * With React Native 0.77, calling `@react-native-community/cli codegen` generates
3
+ * some app level source files such as `RCTAppDependencyProvider.mm`.
4
+ * These files are supposed to be only generated for apps
5
+ * but the cli misbehaves and generates them for all sorts of projects.
6
+ * You can find the relevant PR here: https://github.com/facebook/react-native/pull/47650
7
+ * This patch can be removed when this gets fixed in React Native.
8
+ */
9
+ export declare function removeCodegenAppLevelCode(projectPath: string, packageJson: any): Promise<void>;
10
+ /**
11
+ * Codegen generates a different set of files if the target is an app instead.
12
+ * The following commit adds support for a --source argument to support calling codegen as a library:
13
+ * https://github.com/facebook/react-native/commit/98b8f178110472e5fed97de80766c03b0b5e988c
14
+ * Here we just check if the --source argument is supported.
15
+ */
16
+ export declare function getCodegenCLISourceSupport(): Promise<boolean>;
@@ -0,0 +1,59 @@
1
+ import path from 'node:path';
2
+ import fs from 'fs-extra';
3
+ import { spawn } from "../../../utils/spawn.js";
4
+ import { CODEGEN_DOCS } from "./patchCodegenAndroidPackage.js";
5
+ const FILES_TO_REMOVE = [
6
+ 'RCTAppDependencyProvider.h',
7
+ 'RCTAppDependencyProvider.mm',
8
+ 'RCTModulesConformingToProtocolsProvider.h',
9
+ 'RCTModulesConformingToProtocolsProvider.mm',
10
+ 'RCTThirdPartyComponentsProvider.h',
11
+ 'RCTThirdPartyComponentsProvider.mm',
12
+ 'ReactAppDependencyProvider.podspec',
13
+ ];
14
+ /**
15
+ * With React Native 0.77, calling `@react-native-community/cli codegen` generates
16
+ * some app level source files such as `RCTAppDependencyProvider.mm`.
17
+ * These files are supposed to be only generated for apps
18
+ * but the cli misbehaves and generates them for all sorts of projects.
19
+ * You can find the relevant PR here: https://github.com/facebook/react-native/pull/47650
20
+ * This patch can be removed when this gets fixed in React Native.
21
+ */
22
+ export async function removeCodegenAppLevelCode(projectPath,
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ packageJson) {
25
+ const codegenAndroidPathSetting = packageJson.codegenConfig?.outputDir?.android;
26
+ if (!codegenAndroidPathSetting) {
27
+ throw new Error(`Your package.json doesn't contain codegenConfig.outputDir.android. Please see ${CODEGEN_DOCS}`);
28
+ }
29
+ const codegenAndroidPath = path.resolve(projectPath, codegenAndroidPathSetting);
30
+ if (!(await fs.pathExists(codegenAndroidPath))) {
31
+ throw new Error(`The codegen android path defined in your package.json: ${codegenAndroidPath} doesnt' exist.`);
32
+ }
33
+ const codegenIosPathSetting = packageJson.codegenConfig?.outputDir?.ios;
34
+ if (!codegenIosPathSetting) {
35
+ throw new Error(`Your package.json doesn't contain codegenConfig.outputDir.ios. Please see ${CODEGEN_DOCS}`);
36
+ }
37
+ const codegenIosPath = path.resolve(projectPath, codegenIosPathSetting);
38
+ if (!(await fs.pathExists(codegenAndroidPath))) {
39
+ throw new Error(`The codegen iOS path defined in your package.json: ${codegenIosPathSetting} doesnt' exist.`);
40
+ }
41
+ const androidPromises = FILES_TO_REMOVE.map(async (fileName) => fs.rm(path.join(codegenAndroidPath, fileName)));
42
+ const iosPromises = FILES_TO_REMOVE.map(async (fileName) => fs.rm(path.join(codegenIosPath, fileName)));
43
+ await Promise.allSettled([...androidPromises, ...iosPromises]);
44
+ }
45
+ /**
46
+ * Codegen generates a different set of files if the target is an app instead.
47
+ * The following commit adds support for a --source argument to support calling codegen as a library:
48
+ * https://github.com/facebook/react-native/commit/98b8f178110472e5fed97de80766c03b0b5e988c
49
+ * Here we just check if the --source argument is supported.
50
+ */
51
+ export async function getCodegenCLISourceSupport() {
52
+ const codegenCLIHelpOutput = await spawn('npx', [
53
+ '@react-native-community/cli',
54
+ 'codegen',
55
+ '--help',
56
+ ]);
57
+ return codegenCLIHelpOutput.includes('--source');
58
+ }
59
+ //# sourceMappingURL=removeCodegenAppLevelCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeCodegenA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MAAM,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,sDAAsD,qBAAqB,iBAAiB,CAC7F,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC7D,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC,CAC/C,CAAC;IAEF,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CACzD,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAC3C,CAAC;IAEF,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,eAAe,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,MAAM,oBAAoB,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE;QAC9C,6BAA6B;QAC7B,SAAS;QACT,QAAQ;KACT,CAAC,CAAC;IACH,OAAO,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,75 @@
1
+ import path from 'node:path';
2
+ import { afterEach, beforeEach, describe, expect, test } from 'vitest';
3
+ import fs from 'fs-extra';
4
+ import mockfs from 'mock-fs';
5
+ import { removeCodegenAppLevelCode } from "./removeCodegenAppLevelCode.js";
6
+ const mockPackageJson = {
7
+ codegenConfig: {
8
+ outputDir: {
9
+ android: 'android/generated',
10
+ ios: 'ios/generated',
11
+ },
12
+ },
13
+ };
14
+ const mockProjectPath = path.resolve(import.meta.dirname, 'mockProject');
15
+ describe('patchCodegenAndroidPackage', () => {
16
+ beforeEach(() => {
17
+ mockfs({
18
+ [mockProjectPath]: {
19
+ 'package.json': JSON.stringify(mockPackageJson),
20
+ ios: {
21
+ generated: {
22
+ 'RCTAppDependencyProvider.h': '',
23
+ 'RCTAppDependencyProvider.mm': '',
24
+ 'RCTModulesConformingToProtocolsProvider.h': '',
25
+ 'RCTModulesConformingToProtocolsProvider.mm': '',
26
+ 'RCTThirdPartyComponentsProvider.h': '',
27
+ 'RCTThirdPartyComponentsProvider.mm': '',
28
+ 'ReactAppDependencyProvider.podspec': '',
29
+ },
30
+ },
31
+ android: {
32
+ generated: {
33
+ 'RCTAppDependencyProvider.h': '',
34
+ 'RCTAppDependencyProvider.mm': '',
35
+ 'RCTModulesConformingToProtocolsProvider.h': '',
36
+ 'RCTModulesConformingToProtocolsProvider.mm': '',
37
+ 'RCTThirdPartyComponentsProvider.h': '',
38
+ 'RCTThirdPartyComponentsProvider.mm': '',
39
+ 'ReactAppDependencyProvider.podspec': '',
40
+ },
41
+ },
42
+ },
43
+ });
44
+ });
45
+ afterEach(() => {
46
+ mockfs.restore();
47
+ });
48
+ test('removes the duplicate iOS files', async () => {
49
+ await removeCodegenAppLevelCode(mockProjectPath, mockPackageJson);
50
+ expect((await fs.promises.readdir(path.join(mockProjectPath, 'ios', 'generated'))).length).toBe(0);
51
+ });
52
+ test('removes the unnecessary Android files', async () => {
53
+ await removeCodegenAppLevelCode(mockProjectPath, mockPackageJson);
54
+ expect((await fs.promises.readdir(path.join(mockProjectPath, 'android', 'generated'))).length).toBe(0);
55
+ });
56
+ test("doesn't crash the process when there are no files to remove", async () => {
57
+ mockfs({
58
+ [mockProjectPath]: {
59
+ 'package.json': JSON.stringify(mockPackageJson),
60
+ ios: {
61
+ generated: {
62
+ someRandomFile: '',
63
+ },
64
+ },
65
+ android: {
66
+ generated: {
67
+ someRandomFile: '',
68
+ },
69
+ },
70
+ },
71
+ });
72
+ await expect(removeCodegenAppLevelCode(mockProjectPath, mockPackageJson)).resolves.not.toThrow();
73
+ });
74
+ });
75
+ //# sourceMappingURL=removeCodegenAppLevelCode.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeCodegenAppLevelCode.test.js","sourceRoot":"","sources":["../../../../../src/targets/codegen/patches/removeCodegenAppLevelCode.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,eAAe,GAAG;IACtB,aAAa,EAAE;QACb,SAAS,EAAE;YACT,OAAO,EAAE,mBAAmB;YAC5B,GAAG,EAAE,eAAe;SACrB;KACF;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAEzE,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,CAAC;YACL,CAAC,eAAe,CAAC,EAAE;gBACjB,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;gBAC/C,GAAG,EAAE;oBACH,SAAS,EAAE;wBACT,4BAA4B,EAAE,EAAE;wBAChC,6BAA6B,EAAE,EAAE;wBACjC,2CAA2C,EAAE,EAAE;wBAC/C,4CAA4C,EAAE,EAAE;wBAChD,mCAAmC,EAAE,EAAE;wBACvC,oCAAoC,EAAE,EAAE;wBACxC,oCAAoC,EAAE,EAAE;qBACzC;iBACF;gBACD,OAAO,EAAE;oBACP,SAAS,EAAE;wBACT,4BAA4B,EAAE,EAAE;wBAChC,6BAA6B,EAAE,EAAE;wBACjC,2CAA2C,EAAE,EAAE;wBAC/C,4CAA4C,EAAE,EAAE;wBAChD,mCAAmC,EAAE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,CAAC,CAC5D,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Input, Variants } from '../types.ts';
2
+ import { type CompileOptions } from '../utils/compile.ts';
3
+ type Options = Input & {
4
+ options?: CompileOptions;
5
+ variants: Variants;
6
+ exclude: string;
7
+ };
8
+ export default function build({ root, source, output, exclude, options, variants, report, }: Options): Promise<void>;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ import path from 'node:path';
2
+ import { deleteAsync } from 'del';
3
+ import kleur from 'kleur';
4
+ import compile, {} from "../utils/compile.js";
5
+ export default async function build({ root, source, output, exclude, options, variants, report, }) {
6
+ report.info(`Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`);
7
+ await deleteAsync([output]);
8
+ await compile({
9
+ ...options,
10
+ variants,
11
+ root,
12
+ source,
13
+ output,
14
+ exclude,
15
+ modules: 'commonjs',
16
+ report,
17
+ });
18
+ }
19
+ //# sourceMappingURL=commonjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonjs.js","sourceRoot":"","sources":["../../../src/targets/commonjs.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,OAAO,EAAE,EAAuB,MAAM,qBAAqB,CAAC;AAQnE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,QAAQ,EACR,MAAM,GACE;IACR,MAAM,CAAC,IAAI,CACT,iCAAiC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAC3E,CAAC;IAEF,MAAM,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5B,MAAM,OAAO,CAAC;QACZ,GAAG,OAAO;QACV,QAAQ;QACR,IAAI;QACJ,MAAM;QACN,MAAM;QACN,OAAO;QACP,OAAO,EAAE,UAAU;QACnB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Input } from '../types.ts';
2
+ type Options = Omit<Input, 'output'> & {
3
+ options?: {
4
+ script?: string;
5
+ clean?: string;
6
+ };
7
+ };
8
+ export default function customTarget({ options, root, report }: Options): Promise<void>;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ import path from 'node:path';
2
+ import { deleteAsync } from 'del';
3
+ import fs from 'fs-extra';
4
+ import kleur from 'kleur';
5
+ import { spawn } from "../utils/spawn.js";
6
+ export default async function customTarget({ options, root, report }) {
7
+ if (options?.script == null) {
8
+ throw new Error(`No 'script' was provided with the custom target. Example: ${kleur.green('{["custom", { "script": "generateTypes" }}')}`);
9
+ }
10
+ const pathToClean = options.clean
11
+ ? path.relative(root, options.clean)
12
+ : undefined;
13
+ if (pathToClean) {
14
+ report.info(`Cleaning up ${kleur.blue(pathToClean)}`);
15
+ await deleteAsync([path.resolve(root, pathToClean)]);
16
+ }
17
+ const packageManagerExecutable = process.env.npm_execpath ?? 'npm';
18
+ const packageManagerArgs = ['run', options.script];
19
+ // usr/bin/yarn -> yarn
20
+ const packageManagerName = path.basename(packageManagerExecutable);
21
+ report.info(`Running ${kleur.blue(packageManagerName)} ${kleur.blue(packageManagerArgs.join(' '))}`);
22
+ await spawn(packageManagerExecutable, packageManagerArgs, {
23
+ stdio: ['ignore', 'ignore', 'inherit'],
24
+ });
25
+ report.success(`Ran the ${kleur.blue(options.script)} script succesfully`);
26
+ if (options.clean && pathToClean && !(await fs.pathExists(pathToClean))) {
27
+ report.warn(`Custom target with the ${kleur.blue(options.script)} script has ${kleur.blue(options.clean)} as the ${kleur.bold('clean')} option but this path wasn't created after running the script. Are you sure you've defined the ${kleur.bold('clean')} path correctly?`);
28
+ }
29
+ }
30
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","sourceRoot":"","sources":["../../../src/targets/custom.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS1C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAW;IAC3E,IAAI,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,6DAA6D,KAAK,CAAC,KAAK,CACtE,4CAA4C,CAC7C,EAAE,CACJ,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK;QAC/B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC;QACpC,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAEtD,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC;IACnE,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnD,uBAAuB;IACvB,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC;IACnE,MAAM,CAAC,IAAI,CACT,WAAW,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,IAAI,CACrD,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAC7B,EAAE,CACJ,CAAC;IAEF,MAAM,KAAK,CAAC,wBAAwB,EAAE,kBAAkB,EAAE;QACxD,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC;KACvC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAE3E,IAAI,OAAO,CAAC,KAAK,IAAI,WAAW,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QACxE,MAAM,CAAC,IAAI,CACT,0BAA0B,KAAK,CAAC,IAAI,CAClC,OAAO,CAAC,MAAM,CACf,eAAe,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,KAAK,CAAC,IAAI,CAC5D,OAAO,CACR,kGAAkG,KAAK,CAAC,IAAI,CAC3G,OAAO,CACR,kBAAkB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Input, Variants } from '../types.ts';
2
+ import { type CompileOptions } from '../utils/compile.ts';
3
+ type Options = Input & {
4
+ options?: CompileOptions;
5
+ variants: Variants;
6
+ exclude: string;
7
+ };
8
+ export default function build({ root, source, output, exclude, options, variants, report, }: Options): Promise<void>;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ import path from 'node:path';
2
+ import { deleteAsync } from 'del';
3
+ import kleur from 'kleur';
4
+ import compile, {} from "../utils/compile.js";
5
+ export default async function build({ root, source, output, exclude, options, variants, report, }) {
6
+ report.info(`Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`);
7
+ await deleteAsync([output]);
8
+ await compile({
9
+ ...options,
10
+ variants,
11
+ root,
12
+ source,
13
+ output,
14
+ exclude,
15
+ modules: 'preserve',
16
+ report,
17
+ });
18
+ }
19
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/targets/module.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,OAAO,EAAE,EAAuB,MAAM,qBAAqB,CAAC;AAQnE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,QAAQ,EACR,MAAM,GACE;IACR,MAAM,CAAC,IAAI,CACT,iCAAiC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAC3E,CAAC;IAEF,MAAM,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5B,MAAM,OAAO,CAAC;QACZ,GAAG,OAAO;QACV,QAAQ;QACR,IAAI;QACJ,MAAM;QACN,MAAM;QACN,OAAO;QACP,OAAO,EAAE,UAAU;QACnB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Input, Variants } from '../types.ts';
2
+ type Options = Input & {
3
+ options?: {
4
+ project?: string;
5
+ tsc?: string;
6
+ };
7
+ esm: boolean;
8
+ variants: Variants;
9
+ };
10
+ export default function build({ source, root, output, report, options, variants, esm, }: Options): Promise<void>;
11
+ export {};