forked from react/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-rncore.js
More file actions
53 lines (44 loc) · 1.17 KB
/
Copy pathgenerate-rncore.js
File metadata and controls
53 lines (44 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* 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.
*
* @format
*/
'use strict';
const path = require('path');
const fs = require('fs');
const glob = require('glob');
const RNCodegen = require('react-native-codegen/lib/generators/RNCodegen');
const combine = require('react-native-codegen/lib/cli/combine/combine-js-to-schema');
function generate(schema, outputDirectory) {
fs.mkdirSync(outputDirectory, {recursive: true});
RNCodegen.generate(
{
libraryName: 'rncore',
schema,
outputDirectory,
},
{generators: ['descriptors', 'events', 'props', 'shadow-nodes']},
);
}
function main() {
const rnDir = path.resolve(__dirname, '..');
const outputDirectory = path.resolve(
rnDir,
'ReactCommon',
'react',
'renderer',
'components',
'rncore',
);
const files = glob.sync('Libraries/**/*NativeComponent.js', {
cwd: path.resolve(__dirname, '..'),
});
const schema = combine(
files.map(file => path.resolve(__dirname, '..', file)),
);
generate(schema, outputDirectory);
}
main();