Files
react-native/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js
T
Kevin Gozali 92a3dff58a Codegen: ignore NativeUIManager.js when producing schema given a JavaScript directory
Summary:
When crawling a provided JS directory to find all .js files for NativeModules and native components, ignore `NativeUIManager.js` for now, because it will be replaced with the Fabric UIManager in the future. The existing NativeUIManagerSpec.java won't be produced by the codegen, but stays manually checked in just in case: https://github.com/facebook/react-native/blob/0199a0392c65fa72d9599262ba1b4f8e14c0fc04/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeUIManagerSpec.java

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23312859

fbshipit-source-id: 7d554fefa651732c13e478b8ec94566348ed3142
2020-08-25 10:38:14 -07:00

49 lines
1.3 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+react_native
* @flow strict-local
* @format
*/
'use strict';
const combine = require('./combine-js-to-schema');
const fs = require('fs');
// $FlowFixMe[untyped-import] glob is untyped
const glob = require('glob');
const path = require('path');
const [outfile, ...fileList] = process.argv.slice(2);
const allFiles = [];
fileList.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
const dirFiles = glob
.sync(`${file}/**/*.js`, {
nodir: true,
})
.filter(
f =>
/^(Native.+|.+NativeComponent)/.test(path.basename(f)) &&
// NativeUIManager will be deprecated by Fabric UIManager.
// For now, ignore this spec completely because the types are not fully supported.
!f.endsWith('NativeUIManager.js') &&
!f.includes('__tests'),
);
allFiles.push(...dirFiles);
} else {
allFiles.push(file);
}
});
const formattedSchema = JSON.stringify(combine(allFiles), null, 2);
if (outfile != null) {
fs.writeFileSync(outfile, formattedSchema);
} else {
console.log(formattedSchema);
}