1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | const typescript = require("typescript");
|
10 | const application_1 = require("./application");
|
11 | const component_1 = require("./utils/component");
|
12 | const declaration_1 = require("./utils/options/declaration");
|
13 | const help_1 = require("./utils/options/help");
|
14 | var ExitCode;
|
15 | (function (ExitCode) {
|
16 | ExitCode[ExitCode["OptionError"] = 1] = "OptionError";
|
17 | ExitCode[ExitCode["NoInputFiles"] = 2] = "NoInputFiles";
|
18 | ExitCode[ExitCode["NoOutput"] = 3] = "NoOutput";
|
19 | ExitCode[ExitCode["CompileError"] = 4] = "CompileError";
|
20 | ExitCode[ExitCode["OutputError"] = 5] = "OutputError";
|
21 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
22 | class CliApplication extends application_1.Application {
|
23 | bootstrap(options) {
|
24 | const result = super.bootstrap(options);
|
25 | if (result.hasErrors) {
|
26 | return process.exit(1);
|
27 | }
|
28 | if (this.version) {
|
29 | typescript.sys.write(this.toString());
|
30 | }
|
31 | else if (this.help) {
|
32 | typescript.sys.write(help_1.getOptionsHelp(this.options));
|
33 | }
|
34 | else if (result.inputFiles.length === 0) {
|
35 | typescript.sys.write(help_1.getOptionsHelp(this.options));
|
36 | process.exit(2);
|
37 | }
|
38 | else {
|
39 | const src = this.expandInputFiles(result.inputFiles);
|
40 | const project = this.convert(src);
|
41 | if (project) {
|
42 | if (this.out) {
|
43 | this.generateDocs(project, this.out);
|
44 | }
|
45 | if (this.json) {
|
46 | this.generateJson(project, this.json);
|
47 | }
|
48 | if (!this.out && !this.json) {
|
49 | this.logger.log("No 'out' or 'json' option has been set");
|
50 | this.logger.log("The './docs' directory has be set as the output location by default");
|
51 | this.generateDocs(project, './docs');
|
52 | }
|
53 | if (this.logger.hasErrors()) {
|
54 | process.exit(5);
|
55 | }
|
56 | }
|
57 | else {
|
58 | process.exit(4);
|
59 | }
|
60 | }
|
61 | return result;
|
62 | }
|
63 | get isCLI() {
|
64 | return true;
|
65 | }
|
66 | }
|
67 | __decorate([
|
68 | component_1.Option({
|
69 | name: 'out',
|
70 | help: 'Specifies the location the documentation should be written to.',
|
71 | hint: declaration_1.ParameterHint.Directory
|
72 | })
|
73 | ], CliApplication.prototype, "out", void 0);
|
74 | __decorate([
|
75 | component_1.Option({
|
76 | name: 'json',
|
77 | help: 'Specifies the location and file name a json file describing the project is written to.',
|
78 | hint: declaration_1.ParameterHint.File
|
79 | })
|
80 | ], CliApplication.prototype, "json", void 0);
|
81 | __decorate([
|
82 | component_1.Option({
|
83 | name: 'version',
|
84 | short: 'v',
|
85 | help: 'Print the TypeDoc\'s version.',
|
86 | type: declaration_1.ParameterType.Boolean
|
87 | })
|
88 | ], CliApplication.prototype, "version", void 0);
|
89 | __decorate([
|
90 | component_1.Option({
|
91 | name: 'help',
|
92 | short: 'h',
|
93 | help: 'Print this message.',
|
94 | type: declaration_1.ParameterType.Boolean
|
95 | })
|
96 | ], CliApplication.prototype, "help", void 0);
|
97 | exports.CliApplication = CliApplication;
|
98 |
|
\ | No newline at end of file |