Remove checked-in view configs and js1 build viewconfigs

Summary:
Now that we have the babel plugin, we can remove the checked in view configs

Note that this requires switching the old NativeComponent.js files back to `requireNativeComponent` for open source support (until the babel plugin and codegen are published to a package)

The babel plugin replaces this export with the inline view config

Reviewed By: cpojer

Differential Revision: D15524779

fbshipit-source-id: ab819ce6f24cb2f15a1897ed6d510a0db6aff3a1
This commit is contained in:
Rick Hanlon
2019-06-07 12:31:36 -07:00
committed by Facebook Github Bot
parent 504fc0c7d0
commit 97d439e0ba
3 changed files with 0 additions and 134 deletions
@@ -1,38 +0,0 @@
/**
* 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 generate = require('./generate-view-configs');
const yargs = require('yargs');
const yargv = yargs.strict().option('t', {
alias: 'test',
describe: 'Test the changes and do not write files',
requiresArg: false,
type: 'boolean',
});
const argv = yargv.argv;
const fileList = argv._[0].split('\n');
const CURRENT_VIEW_CONFIG_FILES = [];
generate(
fileList.filter(fileName =>
CURRENT_VIEW_CONFIG_FILES.find(supportedFileName =>
fileName.endsWith(supportedFileName),
),
),
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.99 was deployed. To see the error, delete this
* comment and run Flow. */
{test: argv.test, parser: 'flow'},
);
@@ -1,81 +0,0 @@
/**
* 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('../../generators/RNCodegen.js');
const SchemaParser = require('../../parsers/schema');
const FlowParser = require('../../parsers/flow');
const path = require('path');
type Result = $ReadOnly<{|
libraryName: string,
success: boolean,
|}>;
type Config = $ReadOnly<{|
test?: boolean,
parser?: 'schema' | 'flow',
|}>;
function generateFilesWithResults(
files: Array<string>,
config: Config,
): Array<Result> {
return files.reduce((aggregated, filename) => {
const schema =
config.parser === 'flow'
? FlowParser.parseFile(filename)
: SchemaParser.parse(filename);
if (schema && schema.modules) {
const libraryName = path
.basename(filename)
.replace(/NativeComponent\.js$/, '');
const success = RNCodegen.generate(
{
schema,
libraryName,
outputDirectory: path.dirname(filename),
},
{generators: ['view-configs'], test: config.test},
);
aggregated.push({
libraryName,
success,
});
}
return aggregated;
}, []);
}
function generate(files: Array<string>, config: Config): void {
console.log(`${config.test ? 'Testing' : 'Generating'} view configs`);
const results = generateFilesWithResults(files, config);
const failed = results.filter(result => !result.success);
const totalCount = results.length;
console.log(
`\n${config.test ? 'Tested' : 'Generated'} ${totalCount} view configs`,
);
if (failed.length) {
if (config.test === true) {
console.error(`${failed.length} configs changed`);
console.error("Please re-run 'js1 build viewconfigs'");
}
process.exit(1);
}
}
module.exports = generate;
@@ -1,15 +0,0 @@
#!/bin/bash
# set -euo pipefail
set -e
set -u
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
FILES=$(find "$JS_DIR/" -name "*NativeComponent.js" -print -type f)
# shellcheck source=xplat/js/env-utils/setup_env_vars.sh
source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh"
exec "$FLOW_NODE_BINARY" "$THIS_DIR/generate-view-configs-cli.js" "$@" "$FILES"