|
22 | 22 | const fs = require('fs'); |
23 | 23 | const mkdirp = require('mkdirp'); |
24 | 24 | const path = require('path'); |
| 25 | +const yargs = require('yargs'); |
| 26 | + |
| 27 | +const argv = yargs |
| 28 | + .option('p', { |
| 29 | + alias: 'platform', |
| 30 | + describe: 'Platform to generate native code artifacts for.', |
| 31 | + }) |
| 32 | + .option('s', { |
| 33 | + alias: 'schemaPath', |
| 34 | + describe: 'The path to the schema file.', |
| 35 | + }) |
| 36 | + .option('o', { |
| 37 | + alias: 'outputDir', |
| 38 | + describe: |
| 39 | + 'Path to directory where native code source files should be saved.', |
| 40 | + }) |
| 41 | + .option('n', { |
| 42 | + alias: 'libraryName', |
| 43 | + describe: 'Name of specs library.', |
| 44 | + default: 'FBReactNativeSpec', |
| 45 | + }) |
| 46 | + .option('j', { |
| 47 | + alias: 'javaPackageName', |
| 48 | + describe: 'Name of Java package.', |
| 49 | + default: 'com.facebook.fbreact.specs', |
| 50 | + }) |
| 51 | + .option('t', { |
| 52 | + alias: 'libraryType', |
| 53 | + describe: 'all, components, or modules.', |
| 54 | + default: 'all', |
| 55 | + }) |
| 56 | + .usage('Usage: $0 <args>') |
| 57 | + .demandOption( |
| 58 | + ['platform', 'schemaPath', 'outputDir'], |
| 59 | + 'Please provide platform, schema path, and output directory.', |
| 60 | + ).argv; |
25 | 61 |
|
26 | 62 | const GENERATORS = { |
27 | 63 | all: { |
@@ -97,20 +133,13 @@ function generateSpec( |
97 | 133 | } |
98 | 134 |
|
99 | 135 | function main() { |
100 | | - const args = process.argv.slice(2); |
101 | | - const platform = args[0]; |
102 | | - const schemaPath = args[1]; |
103 | | - const outputDir = args[2]; |
104 | | - const libraryName = args[3] || 'FBReactNativeSpec'; |
105 | | - const javaPackageName = args[4] || 'com.facebook.fbreact.specs'; |
106 | | - const libraryType = args[5] || 'all'; // all, components, or modules |
107 | 136 | generateSpec( |
108 | | - platform, |
109 | | - schemaPath, |
110 | | - outputDir, |
111 | | - libraryName, |
112 | | - javaPackageName, |
113 | | - libraryType, |
| 137 | + argv.platform, |
| 138 | + argv.schemaPath, |
| 139 | + argv.outputDir, |
| 140 | + argv.libraryName, |
| 141 | + argv.javaPackageName, |
| 142 | + argv.libraryType, |
114 | 143 | ); |
115 | 144 | } |
116 | 145 |
|
|
0 commit comments