@react-native/codegen 0.80.0-nightly-20250319-adbcaef1e → 0.80.0-nightly-20250320-146d809b6
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.
|
@@ -52,7 +52,7 @@ function expandDirectoriesIntoFiles(fileList, platform, exclude) {
|
|
|
52
52
|
return [file];
|
|
53
53
|
}
|
|
54
54
|
const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
|
55
|
-
return glob.sync(`${filePattern}
|
|
55
|
+
return glob.sync(`${filePattern}/**/*{,.fb}.{js,ts,tsx}`, {
|
|
56
56
|
nodir: true,
|
|
57
57
|
// TODO: This will remove the need of slash substitution above for Windows,
|
|
58
58
|
// but it requires glob@v9+; with the package currenlty relying on
|
|
@@ -59,7 +59,7 @@ function expandDirectoriesIntoFiles(
|
|
|
59
59
|
return [file];
|
|
60
60
|
}
|
|
61
61
|
const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
|
62
|
-
return glob.sync(`${filePattern}
|
|
62
|
+
return glob.sync(`${filePattern}/**/*{,.fb}.{js,ts,tsx}`, {
|
|
63
63
|
nodir: true,
|
|
64
64
|
// TODO: This will remove the need of slash substitution above for Windows,
|
|
65
65
|
// but it requires glob@v9+; with the package currenlty relying on
|
|
@@ -14,26 +14,30 @@
|
|
|
14
14
|
const path = require('path');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* This function is used by the CLI to decide whether a JS/TS file has to be
|
|
18
|
-
*
|
|
19
|
-
* - file: the path to the file
|
|
20
|
-
* - currentPlatform: the current platform for which we are creating the specs
|
|
21
|
-
* Returns: `true` if the file can be used to generate some code; `false` otherwise
|
|
17
|
+
* This function is used by the CLI to decide whether a JS/TS file has to be
|
|
18
|
+
* processed or not by the Codegen.
|
|
22
19
|
*
|
|
20
|
+
* Parameters:
|
|
21
|
+
* - originalFilePath: the path to the file
|
|
22
|
+
* - currentPlatform: the platform for which we are creating the specs
|
|
23
|
+
* Returns: `true` if the file can be used to generate code; `false` otherwise
|
|
23
24
|
*/
|
|
24
|
-
function filterJSFile(
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
25
|
+
function filterJSFile(originalFilePath, currentPlatform, excludeRegExp) {
|
|
26
|
+
// Remove `.fb` if it exists (see `react-native.cconf`).
|
|
27
|
+
const filePath = originalFilePath.replace(/\.fb(\.|$)/, '$1');
|
|
28
|
+
const basename = path.basename(filePath);
|
|
29
|
+
const isSpecFile = /^(Native.+|.+NativeComponent)/.test(basename);
|
|
30
|
+
const isNotNativeUIManager = !filePath.endsWith('NativeUIManager.js');
|
|
31
|
+
const isNotTest = !filePath.includes('__tests');
|
|
32
|
+
const isNotExcluded = excludeRegExp == null || !excludeRegExp.test(filePath);
|
|
33
|
+
const isNotTSTypeDefinition = !filePath.endsWith('.d.ts');
|
|
30
34
|
const isValidCandidate =
|
|
31
35
|
isSpecFile &&
|
|
32
36
|
isNotNativeUIManager &&
|
|
33
37
|
isNotExcluded &&
|
|
34
38
|
isNotTest &&
|
|
35
39
|
isNotTSTypeDefinition;
|
|
36
|
-
const filenameComponents =
|
|
40
|
+
const filenameComponents = basename.split('.');
|
|
37
41
|
const isPlatformAgnostic = filenameComponents.length === 2;
|
|
38
42
|
if (currentPlatform == null) {
|
|
39
43
|
// need to accept only files that are platform agnostic
|
|
@@ -14,23 +14,28 @@
|
|
|
14
14
|
const path = require('path');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* This function is used by the CLI to decide whether a JS/TS file has to be
|
|
18
|
-
*
|
|
19
|
-
* - file: the path to the file
|
|
20
|
-
* - currentPlatform: the current platform for which we are creating the specs
|
|
21
|
-
* Returns: `true` if the file can be used to generate some code; `false` otherwise
|
|
17
|
+
* This function is used by the CLI to decide whether a JS/TS file has to be
|
|
18
|
+
* processed or not by the Codegen.
|
|
22
19
|
*
|
|
20
|
+
* Parameters:
|
|
21
|
+
* - originalFilePath: the path to the file
|
|
22
|
+
* - currentPlatform: the platform for which we are creating the specs
|
|
23
|
+
* Returns: `true` if the file can be used to generate code; `false` otherwise
|
|
23
24
|
*/
|
|
24
25
|
function filterJSFile(
|
|
25
|
-
|
|
26
|
+
originalFilePath: string,
|
|
26
27
|
currentPlatform: ?string,
|
|
27
28
|
excludeRegExp: ?RegExp,
|
|
28
29
|
): boolean {
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
30
|
+
// Remove `.fb` if it exists (see `react-native.cconf`).
|
|
31
|
+
const filePath = originalFilePath.replace(/\.fb(\.|$)/, '$1');
|
|
32
|
+
const basename = path.basename(filePath);
|
|
33
|
+
|
|
34
|
+
const isSpecFile = /^(Native.+|.+NativeComponent)/.test(basename);
|
|
35
|
+
const isNotNativeUIManager = !filePath.endsWith('NativeUIManager.js');
|
|
36
|
+
const isNotTest = !filePath.includes('__tests');
|
|
37
|
+
const isNotExcluded = excludeRegExp == null || !excludeRegExp.test(filePath);
|
|
38
|
+
const isNotTSTypeDefinition = !filePath.endsWith('.d.ts');
|
|
34
39
|
|
|
35
40
|
const isValidCandidate =
|
|
36
41
|
isSpecFile &&
|
|
@@ -39,7 +44,7 @@ function filterJSFile(
|
|
|
39
44
|
isNotTest &&
|
|
40
45
|
isNotTSTypeDefinition;
|
|
41
46
|
|
|
42
|
-
const filenameComponents =
|
|
47
|
+
const filenameComponents = basename.split('.');
|
|
43
48
|
const isPlatformAgnostic = filenameComponents.length === 2;
|
|
44
49
|
|
|
45
50
|
if (currentPlatform == null) {
|