mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
generate-specs-cli: Parse arguments using yargs
Summary: Make `generate-specs-cli.js` use named arguments. Updated all `generate-specs-cli.js` callsites to make use of named arguments. Changelog: [Internal] Reviewed By: sota000 Differential Revision: D31908041 fbshipit-source-id: f2cb5967db3c3b847e1095e35e8d5d21585be27b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
58c9d8eda7
commit
70785e3d5a
+5
@@ -68,10 +68,15 @@ abstract class GenerateCodegenArtifactsTask : Exec() {
|
||||
windowsAwareYarn(
|
||||
*nodeExecutableAndArgs.get().toTypedArray(),
|
||||
reactRoot.file("scripts/generate-specs-cli.js").get().asFile.absolutePath,
|
||||
"--platform",
|
||||
"android",
|
||||
"--schemaPath",
|
||||
generatedSchemaFile.get().asFile.absolutePath,
|
||||
"--outputDir",
|
||||
generatedSrcDir.get().asFile.absolutePath,
|
||||
"--libraryName",
|
||||
libraryName.get(),
|
||||
"--javaPackageName",
|
||||
codegenJavaPackageName.get()))
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -100,10 +100,15 @@ class GenerateCodegenArtifactsTaskTest {
|
||||
"yarn",
|
||||
"--verbose",
|
||||
File(reactRoot, "scripts/generate-specs-cli.js").toString(),
|
||||
"--platform",
|
||||
"android",
|
||||
"--schemaPath",
|
||||
File(outputDir, "schema.json").toString(),
|
||||
"--outputDir",
|
||||
outputDir.toString(),
|
||||
"--libraryName",
|
||||
"example-test",
|
||||
"--javaPackageName",
|
||||
"com.example.test",
|
||||
),
|
||||
task.commandLine.toMutableList())
|
||||
|
||||
@@ -881,7 +881,7 @@ SPEC CHECKSUMS:
|
||||
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
|
||||
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
|
||||
FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949
|
||||
FBReactNativeSpec: 8c199be18a891a49a1e24b3501e953a51311a46c
|
||||
FBReactNativeSpec: c72b6aa43f36a4bfa45376f24ac5d10339070635
|
||||
Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733
|
||||
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
|
||||
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c
|
||||
@@ -923,10 +923,10 @@ SPEC CHECKSUMS:
|
||||
React-RCTTest: 12bbd7fc2e72bd9920dc7286c5b8ef96639582b6
|
||||
React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7
|
||||
React-RCTVibration: 50be9c390f2da76045ef0dfdefa18b9cf9f35cfa
|
||||
React-rncore: f592388ccb12d9317609bdb1d8dda236e6c0a2be
|
||||
React-rncore: 95c628b2be148269a3189ad1c9f4390b6c73a7d7
|
||||
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
|
||||
ReactCommon: 7a2714d1128f965392b6f99a8b390e3aa38c9569
|
||||
ScreenshotManager: dd14e8064e4e3e84c7f568431c8439cb7c1df81e
|
||||
ScreenshotManager: 965ca5b82e28f0d7baac83c275521770407c60a4
|
||||
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
|
||||
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
|
||||
|
||||
|
||||
@@ -178,7 +178,9 @@ function main(appRootDir) {
|
||||
RN_ROOT,
|
||||
'scripts',
|
||||
'generate-specs-cli.js',
|
||||
)} ios ${pathToSchema} ${pathToTempOutputDir} ${library.config.name}`,
|
||||
)} --platform ios --schemaPath ${pathToSchema} --outputDir ${pathToTempOutputDir} --libraryName ${
|
||||
library.config.name
|
||||
}`,
|
||||
);
|
||||
fs.mkdirSync(pathToOutputDirIOS, {recursive: true});
|
||||
execSync(`cp -R ${pathToTempOutputDir}/* ${pathToOutputDirIOS}`);
|
||||
|
||||
@@ -22,6 +22,42 @@ try {
|
||||
const fs = require('fs');
|
||||
const mkdirp = require('mkdirp');
|
||||
const path = require('path');
|
||||
const yargs = require('yargs');
|
||||
|
||||
const argv = yargs
|
||||
.option('p', {
|
||||
alias: 'platform',
|
||||
describe: 'Platform to generate native code artifacts for.',
|
||||
})
|
||||
.option('s', {
|
||||
alias: 'schemaPath',
|
||||
describe: 'The path to the schema file.',
|
||||
})
|
||||
.option('o', {
|
||||
alias: 'outputDir',
|
||||
describe:
|
||||
'Path to directory where native code source files should be saved.',
|
||||
})
|
||||
.option('n', {
|
||||
alias: 'libraryName',
|
||||
describe: 'Name of specs library.',
|
||||
default: 'FBReactNativeSpec',
|
||||
})
|
||||
.option('j', {
|
||||
alias: 'javaPackageName',
|
||||
describe: 'Name of Java package.',
|
||||
default: 'com.facebook.fbreact.specs',
|
||||
})
|
||||
.option('t', {
|
||||
alias: 'libraryType',
|
||||
describe: 'all, components, or modules.',
|
||||
default: 'all',
|
||||
})
|
||||
.usage('Usage: $0 <args>')
|
||||
.demandOption(
|
||||
['platform', 'schemaPath', 'outputDir'],
|
||||
'Please provide platform, schema path, and output directory.',
|
||||
).argv;
|
||||
|
||||
const GENERATORS = {
|
||||
all: {
|
||||
@@ -97,20 +133,13 @@ function generateSpec(
|
||||
}
|
||||
|
||||
function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const platform = args[0];
|
||||
const schemaPath = args[1];
|
||||
const outputDir = args[2];
|
||||
const libraryName = args[3] || 'FBReactNativeSpec';
|
||||
const javaPackageName = args[4] || 'com.facebook.fbreact.specs';
|
||||
const libraryType = args[5] || 'all'; // all, components, or modules
|
||||
generateSpec(
|
||||
platform,
|
||||
schemaPath,
|
||||
outputDir,
|
||||
libraryName,
|
||||
javaPackageName,
|
||||
libraryType,
|
||||
argv.platform,
|
||||
argv.schemaPath,
|
||||
argv.outputDir,
|
||||
argv.libraryName,
|
||||
argv.javaPackageName,
|
||||
argv.libraryType,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ generateCodegenSchemaFromJavaScript () {
|
||||
generateCodegenArtifactsFromSchema () {
|
||||
describe "Generating codegen artifacts from schema"
|
||||
pushd "$RN_DIR" >/dev/null || exit 1
|
||||
"$NODE_BINARY" "scripts/generate-specs-cli.js" ios "$GENERATED_SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$LIBRARY_NAME" "" "$LIBRARY_TYPE"
|
||||
"$NODE_BINARY" "scripts/generate-specs-cli.js" --platform ios --schemaPath "$GENERATED_SCHEMA_FILE" --outputDir "$TEMP_OUTPUT_DIR" --libraryName "$LIBRARY_NAME" --libraryType "$LIBRARY_TYPE"
|
||||
popd >/dev/null || exit 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user