@react-native/codegen 0.74.0-nightly-20231121-a6964b362 → 0.74.0-nightly-20231122-d4399c5f1

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.
@@ -11,46 +11,13 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- const combine = require('./combine-js-to-schema');
15
- const _require = require('./combine-utils'),
16
- filterJSFile = _require.filterJSFile,
17
- parseArgs = _require.parseArgs;
18
- const fs = require('fs');
19
- const glob = require('glob');
20
- const path = require('path');
14
+ const _require = require('./combine-js-to-schema'),
15
+ combineSchemasInFileListAndWriteToFile =
16
+ _require.combineSchemasInFileListAndWriteToFile;
17
+ const _require2 = require('./combine-utils'),
18
+ parseArgs = _require2.parseArgs;
21
19
  const _parseArgs = parseArgs(process.argv),
22
20
  platform = _parseArgs.platform,
23
21
  outfile = _parseArgs.outfile,
24
22
  fileList = _parseArgs.fileList;
25
- const allFiles = [];
26
- fileList.forEach(file => {
27
- if (fs.lstatSync(file).isDirectory()) {
28
- const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
29
- const dirFiles = glob
30
- .sync(`${filePattern}/**/*.{js,ts,tsx}`, {
31
- nodir: true,
32
- // TODO: This will remove the need of slash substitution above for Windows,
33
- // but it requires glob@v9+; with the package currenlty relying on
34
- // glob@7.1.1; and flow-typed repo not having definitions for glob@9+.
35
- // windowsPathsNoEscape: true,
36
- })
37
- .filter(element => filterJSFile(element, platform));
38
- allFiles.push(...dirFiles);
39
- } else if (filterJSFile(file)) {
40
- allFiles.push(file);
41
- }
42
- });
43
- const combined = combine(allFiles);
44
-
45
- // Warn users if there is no modules to process
46
- if (Object.keys(combined.modules).length === 0) {
47
- console.error(
48
- 'No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.',
49
- );
50
- }
51
- const formattedSchema = JSON.stringify(combined, null, 2);
52
- if (outfile != null) {
53
- fs.writeFileSync(outfile, formattedSchema);
54
- } else {
55
- console.log(formattedSchema);
56
- }
23
+ combineSchemasInFileListAndWriteToFile(fileList, platform, outfile);
@@ -11,45 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- const combine = require('./combine-js-to-schema');
15
- const {filterJSFile, parseArgs} = require('./combine-utils');
16
- const fs = require('fs');
17
- const glob = require('glob');
18
- const path = require('path');
14
+ const {
15
+ combineSchemasInFileListAndWriteToFile,
16
+ } = require('./combine-js-to-schema');
17
+ const {parseArgs} = require('./combine-utils');
19
18
 
20
19
  const {platform, outfile, fileList} = parseArgs(process.argv);
21
20
 
22
- const allFiles = [];
23
- fileList.forEach(file => {
24
- if (fs.lstatSync(file).isDirectory()) {
25
- const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
26
- const dirFiles = glob
27
- .sync(`${filePattern}/**/*.{js,ts,tsx}`, {
28
- nodir: true,
29
- // TODO: This will remove the need of slash substitution above for Windows,
30
- // but it requires glob@v9+; with the package currenlty relying on
31
- // glob@7.1.1; and flow-typed repo not having definitions for glob@9+.
32
- // windowsPathsNoEscape: true,
33
- })
34
- .filter(element => filterJSFile(element, platform));
35
- allFiles.push(...dirFiles);
36
- } else if (filterJSFile(file)) {
37
- allFiles.push(file);
38
- }
39
- });
40
-
41
- const combined = combine(allFiles);
42
-
43
- // Warn users if there is no modules to process
44
- if (Object.keys(combined.modules).length === 0) {
45
- console.error(
46
- 'No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.',
47
- );
48
- }
49
- const formattedSchema = JSON.stringify(combined, null, 2);
50
-
51
- if (outfile != null) {
52
- fs.writeFileSync(outfile, formattedSchema);
53
- } else {
54
- console.log(formattedSchema);
55
- }
21
+ combineSchemasInFileListAndWriteToFile(fileList, platform, outfile);
@@ -76,7 +76,10 @@ const _require = require('../../parsers/flow/parser'),
76
76
  FlowParser = _require.FlowParser;
77
77
  const _require2 = require('../../parsers/typescript/parser'),
78
78
  TypeScriptParser = _require2.TypeScriptParser;
79
+ const _require3 = require('./combine-utils'),
80
+ filterJSFile = _require3.filterJSFile;
79
81
  const fs = require('fs');
82
+ const glob = require('glob');
80
83
  const path = require('path');
81
84
  const flowParser = new FlowParser();
82
85
  const typescriptParser = new TypeScriptParser();
@@ -107,4 +110,40 @@ function combineSchemas(files) {
107
110
  },
108
111
  );
109
112
  }
110
- module.exports = combineSchemas;
113
+ function expandDirectoriesIntoFiles(fileList, platform) {
114
+ return fileList
115
+ .flatMap(file => {
116
+ if (!fs.lstatSync(file).isDirectory()) {
117
+ return [file];
118
+ }
119
+ const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
120
+ return glob.sync(`${filePattern}/**/*.{js,ts,tsx}`, {
121
+ nodir: true,
122
+ // TODO: This will remove the need of slash substitution above for Windows,
123
+ // but it requires glob@v9+; with the package currenlty relying on
124
+ // glob@7.1.1; and flow-typed repo not having definitions for glob@9+.
125
+ // windowsPathsNoEscape: true,
126
+ });
127
+ })
128
+ .filter(element => filterJSFile(element, platform));
129
+ }
130
+ function combineSchemasInFileList(fileList, platform) {
131
+ const expandedFileList = expandDirectoriesIntoFiles(fileList, platform);
132
+ const combined = combineSchemas(expandedFileList);
133
+ if (Object.keys(combined.modules).length === 0) {
134
+ console.error(
135
+ 'No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.',
136
+ );
137
+ }
138
+ return combined;
139
+ }
140
+ function combineSchemasInFileListAndWriteToFile(fileList, platform, outfile) {
141
+ const combined = combineSchemasInFileList(fileList, platform);
142
+ const formattedSchema = JSON.stringify(combined, null, 2);
143
+ fs.writeFileSync(outfile, formattedSchema);
144
+ }
145
+ module.exports = {
146
+ combineSchemas,
147
+ combineSchemasInFileList,
148
+ combineSchemasInFileListAndWriteToFile,
149
+ };
@@ -13,7 +13,9 @@ import type {SchemaType} from '../../CodegenSchema.js';
13
13
 
14
14
  const {FlowParser} = require('../../parsers/flow/parser');
15
15
  const {TypeScriptParser} = require('../../parsers/typescript/parser');
16
+ const {filterJSFile} = require('./combine-utils');
16
17
  const fs = require('fs');
18
+ const glob = require('glob');
17
19
  const path = require('path');
18
20
 
19
21
  const flowParser = new FlowParser();
@@ -46,4 +48,53 @@ function combineSchemas(files: Array<string>): SchemaType {
46
48
  );
47
49
  }
48
50
 
49
- module.exports = combineSchemas;
51
+ function expandDirectoriesIntoFiles(
52
+ fileList: Array<string>,
53
+ platform: ?string,
54
+ ): Array<string> {
55
+ return fileList
56
+ .flatMap(file => {
57
+ if (!fs.lstatSync(file).isDirectory()) {
58
+ return [file];
59
+ }
60
+ const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
61
+ return glob.sync(`${filePattern}/**/*.{js,ts,tsx}`, {
62
+ nodir: true,
63
+ // TODO: This will remove the need of slash substitution above for Windows,
64
+ // but it requires glob@v9+; with the package currenlty relying on
65
+ // glob@7.1.1; and flow-typed repo not having definitions for glob@9+.
66
+ // windowsPathsNoEscape: true,
67
+ });
68
+ })
69
+ .filter(element => filterJSFile(element, platform));
70
+ }
71
+
72
+ function combineSchemasInFileList(
73
+ fileList: Array<string>,
74
+ platform: ?string,
75
+ ): SchemaType {
76
+ const expandedFileList = expandDirectoriesIntoFiles(fileList, platform);
77
+ const combined = combineSchemas(expandedFileList);
78
+ if (Object.keys(combined.modules).length === 0) {
79
+ console.error(
80
+ 'No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.',
81
+ );
82
+ }
83
+ return combined;
84
+ }
85
+
86
+ function combineSchemasInFileListAndWriteToFile(
87
+ fileList: Array<string>,
88
+ platform: ?string,
89
+ outfile: string,
90
+ ): void {
91
+ const combined = combineSchemasInFileList(fileList, platform);
92
+ const formattedSchema = JSON.stringify(combined, null, 2);
93
+ fs.writeFileSync(outfile, formattedSchema);
94
+ }
95
+
96
+ module.exports = {
97
+ combineSchemas,
98
+ combineSchemasInFileList,
99
+ combineSchemasInFileListAndWriteToFile,
100
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.74.0-nightly-20231121-a6964b362",
3
+ "version": "0.74.0-nightly-20231122-d4399c5f1",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {