@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +9 -32
  3. package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
  4. package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
  5. package/dist/Glutinum.Converter/FsharpAST.js +116 -65
  6. package/dist/Glutinum.Converter/Generate.js +38 -25
  7. package/dist/Glutinum.Converter/GlueAST.js +79 -41
  8. package/dist/Glutinum.Converter/Hosting.js +141 -167
  9. package/dist/Glutinum.Converter/Merge.js +369 -337
  10. package/dist/Glutinum.Converter/Packages.js +391 -92
  11. package/dist/Glutinum.Converter/Printer.js +398 -387
  12. package/dist/Glutinum.Converter/Read.js +387 -88
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  14. package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
  15. package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
  16. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
  17. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
  18. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
  19. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
  20. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
  21. package/dist/Glutinum.Converter/Reader/Node.js +8 -11
  22. package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
  23. package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
  24. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
  25. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
  26. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
  27. package/dist/Glutinum.Converter/Reader/Types.js +290 -15
  28. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
  29. package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
  30. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  31. package/dist/Glutinum.Converter/Transform.js +3572 -8415
  32. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  33. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  34. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  35. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
  36. package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
  37. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  38. package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
  39. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  40. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
  41. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  42. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
  43. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  44. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  45. package/dist/Glutinum.Converter/Utils/String.js +14 -3
  46. package/dist/Program.js +102 -239
  47. package/package.json +3 -2
@@ -1,6 +1,4 @@
1
1
 
2
- import { ofArray, iterate } from "../fable_modules/fable-library-js.5.17.2/List.js";
3
- import { printf, toConsole } from "../fable_modules/fable-library-js.5.17.2/String.js";
4
2
 
5
3
  export function TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(this$) {
6
4
  switch (this$) {
@@ -727,11 +725,3 @@ export function TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(this$) {
727
725
  }
728
726
  }
729
727
 
730
- export function TypeScript_Ts_TypeFlags__TypeFlags_Debug(this$) {
731
- iterate((tupledArg) => {
732
- if ((this$ & tupledArg[0]) !== 0) {
733
- toConsole(printf("%s"))(tupledArg[1]);
734
- }
735
- }, ofArray([[1, "Any"], [2, "Unknown"], [32, "String"], [64, "Number"], [256, "Boolean"], [65536, "Enum"], [128, "BigInt"], [1024, "StringLiteral"], [2048, "NumberLiteral"], [8192, "BooleanLiteral"], [32768, "EnumLiteral"], [4096, "BigIntLiteral"], [512, "ESSymbol"], [16384, "UniqueESSymbol"], [16, "Void"], [4, "Undefined"], [8, "Null"], [262144, "Never"], [524288, "TypeParameter"], [1048576, "Object"], [134217728, "Union"], [268435456, "Intersection"], [2097152, "Index"], [33554432, "IndexedAccess"], [67108864, "Conditional"], [16777216, "Substitution"], [131072, "NonPrimitive"], [4194304, "TemplateLiteral"], [8388608, "StringMapping"], [15360, "Literal"], [97292, "Unit"], [80896, "Freshable"], [3072, "StringOrNumberLiteral"], [15868, "PossiblyFalsy"], [12583968, "StringLike"], [67648, "NumberLike"], [4224, "BigIntLike"], [8448, "BooleanLike"], [98304, "EnumLike"], [16896, "ESSymbolLike"], [20, "VoidLike"], [402653184, "UnionOrIntersection"], [403701760, "StructuredType"], [34078720, "TypeVariable"], [117964800, "InstantiableNonPrimitive"], [14680064, "InstantiablePrimitive"], [132644864, "Instantiable"], [536346624, "StructuredOrInstantiable"]]));
736
- }
737
-
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { split, trim, replace as replace_1 } from "../../fable_modules/fable-library-js.5.17.2/String.js";
3
+ import { replace as replace_2 } from "../../fable_modules/fable-library-js.5.17.2/RegExp.js";
3
4
  import { ofArray } from "../../fable_modules/fable-library-js.5.17.2/List.js";
4
5
 
5
6
  export function replace(oldValue, newValue, input) {
@@ -22,11 +23,21 @@ export function capitalizeFirstLetter(text) {
22
23
  return text[0].toLocaleUpperCase() + text.slice(1, text.length);
23
24
  }
24
25
 
25
- export function lowercaseFirstLetter(text) {
26
- return text[0].toLocaleLowerCase() + text.slice(1, text.length);
26
+ /**
27
+ * `index.d.ts`, `index.d.mts` and `index.d.cts` without their extension
28
+ */
29
+ export function withoutDeclarationExtension(fileName) {
30
+ return replace_2(fileName, "\\.d\\.[cm]?ts$", "");
31
+ }
32
+
33
+ /**
34
+ * A declaration file written on Windows ends its lines with `\r\n`
35
+ */
36
+ export function normalizeLineEndings(text) {
37
+ return replace_1(replace_1(text, "\r\n", "\n"), "\r", "\n");
27
38
  }
28
39
 
29
40
  export function splitLines(text) {
30
- return ofArray(split(replace_1(replace_1(text, "\r\n", "\n"), "\r", "\n"), ["\n"], undefined, 0));
41
+ return ofArray(split(normalizeLineEndings(text), ["\n"], undefined, 0));
31
42
  }
32
43
 
package/dist/Program.js CHANGED
@@ -1,40 +1,57 @@
1
1
 
2
- import { success, info, error, log } from "./Glutinum.Converter/Log.js";
3
- import { generateBindingFileWith, generatePackagesFromDisk } from "./Glutinum.Converter/Generate.js";
4
- import { length, exists, filter, contains, cons, ofArray, singleton, append, reverse, tail as tail_5, head, isEmpty, empty } from "./fable_modules/fable-library-js.5.17.2/List.js";
5
- import { defaultArg } from "./fable_modules/fable-library-js.5.17.2/Option.js";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { writeFileSync, mkdirSync, readFileSync } from "fs";
5
+ import { collect, map, toList } from "./fable_modules/fable-library-js.5.17.2/Seq.js";
6
6
  import { join, concat, split } from "./fable_modules/fable-library-js.5.17.2/String.js";
7
7
  import { item, equalsWith } from "./fable_modules/fable-library-js.5.17.2/Array.js";
8
- import { stringHash, defaultOf } from "./fable_modules/fable-library-js.5.17.2/Util.js";
9
- import { defaultOptions, GenerateOptions } from "./Glutinum.Converter/Packages.js";
10
- import * as path from "path";
11
- import * as fs from "fs";
8
+ import { defaultOf } from "./fable_modules/fable-library-js.5.17.2/Util.js";
9
+ import { defaultArg } from "./fable_modules/fable-library-js.5.17.2/Option.js";
10
+ import { parse } from "./fable_modules/fable-library-js.5.17.2/Int32.js";
11
+ import { defaultMaxOverloads } from "./Glutinum.Converter/Transformer/UnionOverloads.js";
12
+ import { GenerateOptions } from "./Glutinum.Converter/Packages.js";
13
+ import { generateBindingFileWithOptions, generatePackagesFromDisk } from "./Glutinum.Converter/Generate.js";
14
+ import { exists, length, head, tail, isEmpty, empty } from "./fable_modules/fable-library-js.5.17.2/List.js";
15
+ import { success, error, info } from "./Glutinum.Converter/Log.js";
16
+ import { program as program_1 } from "commander";
12
17
 
13
- export function printHelp() {
14
- const helpText = "\nGenerate Fable bindings from TypeScript definitions - https://github.com/glutinum-org/cl\n\nUSAGE\n\n glutinum <input>... [--out-file <output>]\n glutinum --all [--out-file <output>]\n glue <input>... [--out-file <output>]\n\n <input> can be:\n - an installed package name (e.g. chalk, @types/vscode)\n - a path to a package directory (e.g. ./node_modules/chalk)\n - a path to a .d.ts file (e.g. ./node_modules/chalk/source/index.d.ts)\n\n Several packages are generated in the same file, each one with every\n package it depends on. A .d.ts file is generated alone.\n --all generates every package installed in the nearest node_modules.\n\n The types of @types/node and @types/web (the DOM) are referenced from the\n Glutinum.Node and Glutinum.Web bindings, unless asked for or --no-externals.\n\nOPTIONS\n\n --out-file <output> Destination file to write in\n If not specified, the result will be printed to stdout\n --no-externals Generate @types/node and @types/web with the packages\n using them instead of referencing their bindings\n --external <package> Reference <package> from its own binding instead of\n generating it, `Glutinum.<Module>` is derived from its\n name unless given as <package>=<Module>\n Can be repeated\n --module-name <name> Full name of the generated module, `Glutinum.Types.TypeScript`,\n instead of `Glutinum.<Module>` derived from the package name\n --include <names> Comma-separated declarations to keep, the others are dropped\n Can be repeated\n --no-lib Create the program without the TypeScript library, for a\n package made of its files\n -h, --help Print this help message\n\nEXAMPLES\n\n glutinum chalk --out-file ./Glutinum.Chalk.fs\n glutinum vscode vscode-languageclient --out-file ./Glutinum.Vscode.fs\n glutinum leaflet --external @types/geojson --out-file ./Glutinum.Leaflet.fs\n glutinum --all --out-file ./Glutinum.fs\n glutinum ./node_modules/my-lib/index.d.ts\n ";
15
- log(helpText);
16
- }
18
+ const nodeProcess = process;
17
19
 
18
20
  function getVersion() {
19
- const pkg = JSON.parse(fs.readFileSync(new URL('./../package.json', import.meta.url)));
21
+ const moduleDir = path.dirname(fileURLToPath(import.meta.url));
22
+ let packageJson;
23
+ const text = readFileSync(path.join(moduleDir, "..", "package.json"), "utf8");
24
+ packageJson = JSON.parse(text);
25
+ return packageJson.version;
26
+ }
27
+
28
+ const helpText = "\n <input> can be:\n - an installed package name (e.g. chalk, @types/vscode)\n - a path to a package directory (e.g. ./node_modules/chalk)\n - a path to a .d.ts file (e.g. ./node_modules/chalk/source/index.d.ts)\n\n Several packages are generated in the same file, each one with every\n package it depends on. A .d.ts file is generated alone.\n\n The types of @types/node and @types/web (the DOM) are referenced from the\n Glutinum.Node and Glutinum.Web bindings, unless asked for or --no-externals.\n\nExamples:\n glutinum chalk --out-file ./Glutinum.Chalk.fs\n glutinum vscode vscode-languageclient --out-file ./Glutinum.Vscode.fs\n glutinum leaflet --external @types/geojson --out-file ./Glutinum.Leaflet.fs\n glutinum --all --out-file ./Glutinum.fs\n glutinum ./node_modules/my-lib/index.d.ts\n";
20
29
 
21
- return pkg.version;
22
- ;
30
+ function toGenerateOptions(options) {
31
+ let option_2;
32
+ const externals = toList(map((value) => {
33
+ const matchValue = split(value, ["="], undefined, 0);
34
+ if (!equalsWith((x, y) => (x === y), matchValue, defaultOf()) && (matchValue.length === 2)) {
35
+ return [item(0, matchValue), item(1, matchValue)];
36
+ }
37
+ else {
38
+ return [value, undefined];
39
+ }
40
+ }, options.external));
41
+ const includes = toList(collect((value_1) => split(value_1, [","], undefined, 0), options.include));
42
+ const ExternalPackages = options.externals;
43
+ const ModuleName = options.moduleName;
44
+ const NoLib = !options.lib;
45
+ return new GenerateOptions(ExternalPackages, externals, ModuleName, defaultArg(options.global, false), defaultArg((option_2 = options.maxOverloads, (option_2 != null) ? parse(option_2, 511, false, 32) : undefined), defaultMaxOverloads), includes, NoLib);
23
46
  }
24
47
 
25
- function generate(options, inputs) {
48
+ function generate(options, isAll, inputs) {
26
49
  let matchResult, input_1, inputs_1;
27
- if (!isEmpty(inputs)) {
28
- if (head(inputs) === "--all") {
29
- if (isEmpty(tail_5(inputs))) {
30
- matchResult = 0;
31
- }
32
- else {
33
- matchResult = 2;
34
- inputs_1 = inputs;
35
- }
36
- }
37
- else if (isEmpty(tail_5(inputs))) {
50
+ if (isAll) {
51
+ matchResult = 0;
52
+ }
53
+ else if (!isEmpty(inputs)) {
54
+ if (isEmpty(tail(inputs))) {
38
55
  if (head(inputs).endsWith(".d.ts")) {
39
56
  matchResult = 1;
40
57
  input_1 = head(inputs);
@@ -57,234 +74,80 @@ function generate(options, inputs) {
57
74
  case 0:
58
75
  return generatePackagesFromDisk(options, empty());
59
76
  case 1:
60
- return generateBindingFileWith(defaultArg(options.ModuleName, "Glutinum"), input_1);
77
+ return generateBindingFileWithOptions(defaultArg(options.ModuleName, "Glutinum"), options.GlobalScript, options.MaxOverloads, input_1);
61
78
  default:
62
79
  return generatePackagesFromDisk(options, inputs_1);
63
80
  }
64
81
  }
65
82
 
66
- function run(argv) {
67
- let matchResult;
68
- if (!isEmpty(argv)) {
69
- switch (head(argv)) {
70
- case "-h":
71
- case "--help":
72
- case "help": {
73
- matchResult = 0;
74
- break;
75
- }
76
- case "--version": {
77
- if (isEmpty(tail_5(argv))) {
78
- matchResult = 1;
79
- }
80
- else {
81
- matchResult = 2;
82
- }
83
- break;
84
- }
85
- default:
86
- matchResult = 2;
87
- }
83
+ function write(outFile, content) {
84
+ if (outFile == null) {
85
+ const stdout = nodeProcess.stdout;
86
+ stdout.write(content, "utf8");
88
87
  }
89
88
  else {
90
- matchResult = 0;
89
+ const outFile_1 = outFile;
90
+ mkdirSync(path.dirname(outFile_1), {
91
+ recursive: true,
92
+ });
93
+ writeFileSync(outFile_1, content);
94
+ info(concat("Bindings written to: ", path.resolve(outFile_1)));
91
95
  }
92
- switch (matchResult) {
93
- case 0: {
94
- printHelp();
95
- return 0;
96
+ }
97
+
98
+ function run(argv) {
99
+ const program = program_1;
100
+ program.name("glutinum").description("Generate Fable bindings from TypeScript definitions - https://github.com/glutinum-org/cli").version(getVersion());
101
+ program.argument("[inputs...]", "packages, a package directory, or a .d.ts file to generate").option("--out-file <path>", "destination file to write in, stdout otherwise").option("--all", "generate every package installed in the nearest node_modules").option("--module-name <name>", "full name of the generated module, instead of `Glutinum.<Module>`").option("--no-externals", "generate @types/node and @types/web instead of referencing them").option("--no-lib", "create the program without the TypeScript library").option("--global", "the .d.ts declares the globals of a script, nothing is imported").option("--max-overloads <count>", "overloads a signature gets at most from its union parameters, 16 by default");
102
+ program.option("--external <package>", "reference <package> from its own binding, as <package> or <package>=<Module>", (value_3, previous_1) => {
103
+ void (previous_1.push(value_3));
104
+ return previous_1;
105
+ }, []).option("--include <names>", "comma separated declarations to keep, the others are dropped", (value_2, previous) => {
106
+ void (previous.push(value_2));
107
+ return previous;
108
+ }, []).addHelpText("after", helpText).showHelpAfterError();
109
+ const parseOptions = {
110
+ from: "user",
111
+ };
112
+ program.parse(Array.from(argv), parseOptions);
113
+ const options = program.opts();
114
+ const inputs = toList(program.args);
115
+ const isAll = defaultArg(options.all, false);
116
+ const mixesFileAndPackages = (length(inputs) > 1) && exists((input) => input.endsWith(".d.ts"), inputs);
117
+ if (isEmpty(inputs) && !isAll) {
118
+ error("Give at least one input, or --all");
119
+ program.outputHelp({
120
+ error: true,
121
+ });
122
+ return 1;
123
+ }
124
+ else if (mixesFileAndPackages) {
125
+ error("A .d.ts file is generated alone, it can\'t be combined with other inputs");
126
+ return 1;
127
+ }
128
+ else {
129
+ if (isAll) {
130
+ info("Generating binding file for every installed package");
96
131
  }
97
- case 1: {
98
- log(getVersion());
132
+ else {
133
+ info(concat("Generating binding file for ", join(", ", inputs)));
134
+ }
135
+ try {
136
+ const content = generate(toGenerateOptions(options), isAll, inputs);
137
+ write(options.outFile, content);
138
+ success("Success!");
99
139
  return 0;
100
140
  }
101
- default: {
102
- let patternInput;
103
- const matchValue = reverse(argv);
104
- let matchResult_1, inputs, outFile;
105
- if (!isEmpty(matchValue)) {
106
- if (!isEmpty(tail_5(matchValue))) {
107
- if (head(tail_5(matchValue)) === "--out-file") {
108
- matchResult_1 = 0;
109
- inputs = tail_5(tail_5(matchValue));
110
- outFile = head(matchValue);
111
- }
112
- else {
113
- matchResult_1 = 1;
114
- }
115
- }
116
- else {
117
- matchResult_1 = 1;
118
- }
119
- }
120
- else {
121
- matchResult_1 = 1;
122
- }
123
- switch (matchResult_1) {
124
- case 0: {
125
- patternInput = [reverse(inputs), outFile];
126
- break;
127
- }
128
- default:
129
- patternInput = [argv, undefined];
130
- }
131
- const outFile_1 = patternInput[1];
132
- const takeOptions = (args_mut, options_mut, rest_mut) => {
133
- takeOptions:
134
- while (true) {
135
- const args = args_mut, options = options_mut, rest = rest_mut;
136
- let matchValue_1;
137
- let matchResult_2, tail, value, tail_1, value_1, tail_2, tail_3, value_2, arg, tail_4;
138
- if (isEmpty(args)) {
139
- matchResult_2 = 5;
140
- }
141
- else {
142
- switch (head(args)) {
143
- case "--external": {
144
- if (!isEmpty(tail_5(args))) {
145
- matchResult_2 = 0;
146
- tail = tail_5(tail_5(args));
147
- value = head(tail_5(args));
148
- }
149
- else {
150
- matchResult_2 = 4;
151
- arg = head(args);
152
- tail_4 = tail_5(args);
153
- }
154
- break;
155
- }
156
- case "--module-name": {
157
- if (!isEmpty(tail_5(args))) {
158
- matchResult_2 = 1;
159
- tail_1 = tail_5(tail_5(args));
160
- value_1 = head(tail_5(args));
161
- }
162
- else {
163
- matchResult_2 = 4;
164
- arg = head(args);
165
- tail_4 = tail_5(args);
166
- }
167
- break;
168
- }
169
- case "--no-lib": {
170
- matchResult_2 = 2;
171
- tail_2 = tail_5(args);
172
- break;
173
- }
174
- case "--include": {
175
- if (!isEmpty(tail_5(args))) {
176
- matchResult_2 = 3;
177
- tail_3 = tail_5(tail_5(args));
178
- value_2 = head(tail_5(args));
179
- }
180
- else {
181
- matchResult_2 = 4;
182
- arg = head(args);
183
- tail_4 = tail_5(args);
184
- }
185
- break;
186
- }
187
- default: {
188
- matchResult_2 = 4;
189
- arg = head(args);
190
- tail_4 = tail_5(args);
191
- }
192
- }
193
- }
194
- switch (matchResult_2) {
195
- case 0: {
196
- args_mut = tail;
197
- options_mut = (new GenerateOptions(options.ExternalPackages, append(options.Externals, singleton((matchValue_1 = split(value, ["="], undefined, 0), (!equalsWith((x, y) => (x === y), matchValue_1, defaultOf()) && (matchValue_1.length === 2)) ? [item(0, matchValue_1), item(1, matchValue_1)] : [value, undefined]))), options.ModuleName, options.Include, options.NoLib));
198
- rest_mut = rest;
199
- continue takeOptions;
200
- }
201
- case 1: {
202
- args_mut = tail_1;
203
- options_mut = (new GenerateOptions(options.ExternalPackages, options.Externals, value_1, options.Include, options.NoLib));
204
- rest_mut = rest;
205
- continue takeOptions;
206
- }
207
- case 2: {
208
- args_mut = tail_2;
209
- options_mut = (new GenerateOptions(options.ExternalPackages, options.Externals, options.ModuleName, options.Include, true));
210
- rest_mut = rest;
211
- continue takeOptions;
212
- }
213
- case 3: {
214
- args_mut = tail_3;
215
- options_mut = (new GenerateOptions(options.ExternalPackages, options.Externals, options.ModuleName, append(options.Include, ofArray(split(value_2, [","], undefined, 0))), options.NoLib));
216
- rest_mut = rest;
217
- continue takeOptions;
218
- }
219
- case 4: {
220
- args_mut = tail_4;
221
- options_mut = options;
222
- rest_mut = cons(arg, rest);
223
- continue takeOptions;
224
- }
225
- default:
226
- return [options, reverse(rest)];
227
- }
228
- break;
229
- }
230
- };
231
- const patternInput_1 = takeOptions(patternInput[0], defaultOptions, empty());
232
- const options_1 = patternInput_1[0];
233
- const inputs_2 = patternInput_1[1];
234
- const options_2 = new GenerateOptions(!contains("--no-externals", inputs_2, {
235
- Equals: (x_1, y_1) => (x_1 === y_1),
236
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
237
- }), options_1.Externals, options_1.ModuleName, options_1.Include, options_1.NoLib);
238
- const inputs_3 = filter((input) => (input !== "--no-externals"), inputs_2);
239
- const hasUnknownOption = exists((input_1) => {
240
- if (input_1.startsWith("-")) {
241
- return input_1 !== "--all";
242
- }
243
- else {
244
- return false;
245
- }
246
- }, inputs_3);
247
- const mixesFileAndPackages = (length(inputs_3) > 1) && exists((input_2) => input_2.endsWith(".d.ts"), inputs_3);
248
- if (isEmpty(inputs_3) ? true : hasUnknownOption) {
249
- error("Invalid arguments");
250
- printHelp();
251
- return 1;
252
- }
253
- else if (mixesFileAndPackages) {
254
- error("A .d.ts file is generated alone, it can\'t be combined with other inputs");
255
- return 1;
256
- }
257
- else {
258
- info(concat("Generating binding file for ", join(", ", inputs_3)));
259
- try {
260
- const res = generate(options_2, inputs_3);
261
- if (outFile_1 == null) {
262
- process.stdout.write(res);
263
- }
264
- else {
265
- const outFile_2 = outFile_1;
266
- const outFileDir = path.dirname(outFile_2);
267
- fs.mkdirSync(outFileDir, {
268
- recursive: true,
269
- });
270
- fs.writeFileSync(outFile_2, res);
271
- info(concat("Bindings written to: ", path.join(process.cwd(), outFile_2)));
272
- }
273
- success("Success!");
274
- return 0;
275
- }
276
- catch (ex) {
277
- error(ex.message);
278
- return 1;
279
- }
280
- }
141
+ catch (ex) {
142
+ error(ex.message);
143
+ return 1;
281
144
  }
282
145
  }
283
146
  }
284
147
 
285
148
  (function (argv) {
286
- const exitCode = run(ofArray(argv)) | 0;
287
- process.exitCode = exitCode;
149
+ const exitCode = run(argv) | 0;
150
+ nodeProcess.exitCode = exitCode;
288
151
  return exitCode | 0;
289
152
  })(typeof process === 'object' ? process.argv.slice(2) : []);
290
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glutinum/cli",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "TypeScript definition to F# bindings converter",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -52,6 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@ts-morph/bootstrap": "^0.29.0",
55
- "chalk": "^5.3.0"
55
+ "chalk": "^5.3.0",
56
+ "commander": "^15.0.0"
56
57
  }
57
58
  }