Extract modules/schema.js from flow and TS folders to a shared file (#34879)

Summary:
This PR reduces code duplication by ```extracting the modules/schema.js from the flow and typescript folders in a shared parsers-commons.js file. Then, have the two parsers use the same wrapModuleSchema function for modules``` as part of https://github.com/facebook/react-native/issues/34872

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - Extracts the modules/schema.js from the flow and typescript folders in a shared file.

Pull Request resolved: https://github.com/facebook/react-native/pull/34879

Test Plan:
run ```yarn jest react-native-codegen```
<img width="788" alt="image" src="https://user-images.githubusercontent.com/34857453/194232470-3ae3b99a-2556-48da-aac6-20ffc95f90a0.png">

Reviewed By: robhogan

Differential Revision: D40143266

Pulled By: robhogan

fbshipit-source-id: 417a5456c8099ad2761617e2be7cf8306c7d9ec4
This commit is contained in:
Tarun Chauhan 2022-10-07 09:20:48 -07:00 коммит произвёл Facebook GitHub Bot
Родитель c4f9556f7e
Коммит 35556dba60
4 изменённых файлов: 3 добавлений и 31 удалений

Просмотреть файл

@ -18,7 +18,7 @@ const {extractNativeModuleName} = require('../utils.js');
const {buildComponentSchema} = require('./components');
const {wrapComponentSchema} = require('./components/schema');
const {buildModuleSchema} = require('./modules');
const {wrapModuleSchema} = require('./modules/schema');
const {wrapModuleSchema} = require('../parsers-commons');
const {
createParserErrorCapturer,
visit,

Просмотреть файл

@ -10,7 +10,7 @@
'use strict';
import type {SchemaType, NativeModuleSchema} from '../../../CodegenSchema.js';
import type {SchemaType, NativeModuleSchema} from '../CodegenSchema.js';
function wrapModuleSchema(
nativeModuleSchema: NativeModuleSchema,

Просмотреть файл

@ -17,7 +17,7 @@ const {extractNativeModuleName} = require('../utils.js');
const {buildComponentSchema} = require('./components');
const {wrapComponentSchema} = require('./components/schema');
const {buildModuleSchema} = require('./modules');
const {wrapModuleSchema} = require('./modules/schema');
const {wrapModuleSchema} = require('../parsers-commons');
const {
createParserErrorCapturer,

Просмотреть файл

@ -1,28 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict
*/
'use strict';
import type {SchemaType, NativeModuleSchema} from '../../../CodegenSchema.js';
function wrapModuleSchema(
nativeModuleSchema: NativeModuleSchema,
hasteModuleName: string,
): SchemaType {
return {
modules: {
[hasteModuleName]: nativeModuleSchema,
},
};
}
module.exports = {
wrapModuleSchema,
};