1 | #!/usr/bin/env node
|
2 | "use strict";
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.outdated = exports.install = exports.createStub = exports.createDef = void 0;
|
8 | exports.runCLI = runCLI;
|
9 | exports.validateDefs = exports.updateCache = exports.update = exports.search = exports.runTests = void 0;
|
10 |
|
11 | var _yargs = _interopRequireDefault(require("yargs"));
|
12 |
|
13 | var _node = require("./lib/node");
|
14 |
|
15 | var Install = _interopRequireWildcard(require("./commands/install"));
|
16 |
|
17 | var CreateDef = _interopRequireWildcard(require("./commands/create-def"));
|
18 |
|
19 | var CreateStub = _interopRequireWildcard(require("./commands/create-stub"));
|
20 |
|
21 | var Outdated = _interopRequireWildcard(require("./commands/outdated"));
|
22 |
|
23 | var RunTests = _interopRequireWildcard(require("./commands/runTests"));
|
24 |
|
25 | var Search = _interopRequireWildcard(require("./commands/search"));
|
26 |
|
27 | var Update = _interopRequireWildcard(require("./commands/update"));
|
28 |
|
29 | var UpdateCache = _interopRequireWildcard(require("./commands/update-cache"));
|
30 |
|
31 | var ValidateDefs = _interopRequireWildcard(require("./commands/validateDefs"));
|
32 |
|
33 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
34 |
|
35 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
36 |
|
37 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
38 |
|
39 | const install = Install.run;
|
40 | exports.install = install;
|
41 | const createDef = CreateDef.run;
|
42 | exports.createDef = createDef;
|
43 | const createStub = CreateStub.run;
|
44 | exports.createStub = createStub;
|
45 | const outdated = Outdated.run;
|
46 | exports.outdated = outdated;
|
47 | const runTests = RunTests.run;
|
48 | exports.runTests = runTests;
|
49 | const search = Search.run;
|
50 | exports.search = search;
|
51 | const update = Update.run;
|
52 | exports.update = update;
|
53 | const updateCache = UpdateCache.run;
|
54 | exports.updateCache = updateCache;
|
55 | const validateDefs = ValidateDefs.run;
|
56 | exports.validateDefs = validateDefs;
|
57 |
|
58 | const identity = x => x;
|
59 |
|
60 | function runCLI() {
|
61 | const commands = [CreateDef, CreateStub, Install, Outdated, RunTests, Search, Update, UpdateCache, ValidateDefs];
|
62 | commands.reduce((cmdYargs, cmd) => cmdYargs.command(cmd.name, cmd.description, cmd.setup || identity, args => cmd
|
63 | .run(args, _yargs.default).catch(err => {
|
64 | if (err.stack) {
|
65 | console.log('UNCAUGHT ERROR: %s', err.stack);
|
66 | } else if (typeof err === 'object' && err !== null) {
|
67 | console.log('UNCAUGHT ERROR: %s', JSON.stringify(err, null, 2));
|
68 | } else {
|
69 | console.log('UNCAUGHT ERROR:', err);
|
70 | }
|
71 |
|
72 | process.exit(1);
|
73 | }).then(code => process.exit(code))), _yargs.default).demand(1).strict().recommendCommands().help('h').alias('h', 'help').argv;
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | if (require.main === module) {
|
83 | const CWD = process.cwd();
|
84 | let currDir = CWD;
|
85 | let lastDir = null;
|
86 | let run = runCLI;
|
87 |
|
88 | while (currDir !== lastDir) {
|
89 | const localCLIPath = _node.path.join(currDir, 'node_modules', '.bin', 'flow-typed');
|
90 |
|
91 | try {
|
92 | if (_node.fs.statSync(localCLIPath).isFile()) {
|
93 | run = require.call(null, localCLIPath).runCLI;
|
94 | break;
|
95 | }
|
96 | } catch (e) {
|
97 |
|
98 | }
|
99 |
|
100 | lastDir = currDir;
|
101 | currDir = _node.path.resolve(currDir, '..');
|
102 | }
|
103 |
|
104 | run();
|
105 | } |
\ | No newline at end of file |