Files
react-native/packages/react-native-codegen/buck_tests/generate-tests.js
T
Rick Hanlon c9d9f8cc2a Add js1 build viewconfigs
Summary:
This diff adds a new `js1` script `js1 build viewconfigs` which will generate the view configs for generated components in xplat/js

Note that the view configs are not currently valid so I'm not checking them in or adding them to a test, that work will follow

Reviewed By: TheSavior

Differential Revision: D15239656

fbshipit-source-id: d15776f36a7d7684f50beafd783bccb02352afc0
2019-05-16 10:51:05 -07:00

49 lines
1.1 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.
*
* @flow
* @format
*/
'use strict';
const RNCodegen = require('../src/generators/RNCodegen.js');
const fs = require('fs');
const mkdirp = require('mkdirp');
const args = process.argv.slice(2);
if (args.length !== 3) {
throw new Error(
`Expected to receive path to schema, library name, and output directory. Received ${args.join(
', ',
)}`,
);
}
const schemaPath = args[0];
const libraryName = args[1];
const outputDirectory = args[2];
const schemaText = fs.readFileSync(schemaPath, 'utf-8');
if (schemaText == null) {
throw new Error(`Can't find schema at ${schemaPath}`);
}
mkdirp.sync(outputDirectory);
let schema;
try {
schema = JSON.parse(schemaText);
} catch (err) {
throw new Error(`Can't parse schema to JSON. ${schemaPath}`);
}
RNCodegen.generate(
{libraryName, schema, outputDirectory},
{generators: ['descriptors', 'events', 'props', 'tests', 'shadow-nodes']},
);