UNPKG

2.74 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 *
8 * @format
9 */
10'use strict';
11
12require("@babel/polyfill");
13
14// Collect args
15var argv = require("yargs").usage('Create Relay generated files\n\n' + '$0 --schema <path> --src <path> [--watch]').options({
16 schema: {
17 describe: 'Path to schema.graphql or schema.json',
18 demandOption: true,
19 type: 'string'
20 },
21 src: {
22 describe: 'Root directory of application code',
23 demandOption: true,
24 type: 'string'
25 },
26 include: {
27 array: true,
28 "default": ['**'],
29 describe: 'Directories to include under src',
30 type: 'string'
31 },
32 exclude: {
33 array: true,
34 "default": ['**/node_modules/**', '**/__mocks__/**', '**/__tests__/**', '**/__generated__/**'],
35 describe: 'Directories to ignore under src',
36 type: 'string'
37 },
38 extensions: {
39 array: true,
40 describe: 'File extensions to compile (defaults to extensions provided by the ' + 'language plugin)',
41 type: 'string'
42 },
43 verbose: {
44 describe: 'More verbose logging',
45 type: 'boolean'
46 },
47 quiet: {
48 describe: 'No output to stdout',
49 type: 'boolean'
50 },
51 watchman: {
52 describe: 'Use watchman when not in watch mode',
53 type: 'boolean',
54 "default": true
55 },
56 watch: {
57 describe: 'If specified, watches files and regenerates on changes',
58 type: 'boolean'
59 },
60 validate: {
61 describe: 'Looks for pending changes and exits with non-zero code instead of ' + 'writing to disk',
62 type: 'boolean',
63 "default": false
64 },
65 'persist-output': {
66 describe: 'A path to a .json file where persisted query metadata should be saved'
67 },
68 noFutureProofEnums: {
69 describe: 'This option controls whether or not a catch-all entry is added to enum type definitions ' + 'for values that may be added in the future. Enabling this means you will have to update ' + 'your application whenever the GraphQL server schema adds new enum values to prevent it ' + 'from breaking.',
70 "default": false
71 },
72 language: {
73 describe: 'The name of the language plugin used for input files and artifacts',
74 type: 'string',
75 "default": 'javascript'
76 },
77 artifactDirectory: {
78 describe: 'A specific directory to output all artifacts to. When enabling this ' + 'the babel plugin needs `artifactDirectory` set as well.',
79 type: 'string',
80 "default": null
81 }
82}).help().argv; // Run script with args
83// $FlowFixMe: Invalid types for yargs. Please fix this when touching this code.
84
85
86require("./RelayCompilerMain").main(argv)["catch"](function (error) {
87 console.error(String(error.stack || error));
88 process.exit(1);
89});
\No newline at end of file