@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.2
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.
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { createNodeHost, Bootstrap_createProgramForCLI } from "./Hosting.js";
|
|
3
|
-
import
|
|
3
|
+
import { readFileSync, existsSync } from "fs";
|
|
4
4
|
import { disposeSafe, getEnumerator, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
5
5
|
import { concat } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
6
|
-
import { toString } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
7
6
|
import { printFileWith, Printer_$ctor } from "./Printer.js";
|
|
8
7
|
import { readSourceFile } from "./Read.js";
|
|
9
8
|
import { error as error_1, warn } from "./Log.js";
|
|
10
9
|
import { applyWith } from "./Transform.js";
|
|
11
10
|
import { defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
12
11
|
import { empty } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
12
|
+
import { toString } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
13
13
|
import { generateWith, defaultOptions } from "./Packages.js";
|
|
14
14
|
|
|
15
15
|
export function createProgramForCLI(fileName, source) {
|
|
@@ -24,10 +24,10 @@ export function generateBindingFile(filePath) {
|
|
|
24
24
|
* Generate the binding of a single declaration file as the module <c>moduleName</c>
|
|
25
25
|
*/
|
|
26
26
|
export function generateBindingFileWith(moduleName, filePath) {
|
|
27
|
-
if (!
|
|
27
|
+
if (!existsSync(filePath)) {
|
|
28
28
|
throw new Exception(concat("File does not exist: ", filePath));
|
|
29
29
|
}
|
|
30
|
-
const program = createProgramForCLI(filePath,
|
|
30
|
+
const program = createProgramForCLI(filePath, readFileSync(filePath, "utf8"));
|
|
31
31
|
const checker = program.getTypeChecker();
|
|
32
32
|
const sourceFile = program.getSourceFile(filePath);
|
|
33
33
|
const printer = Printer_$ctor();
|
|
@@ -139,8 +139,8 @@ export function createFileSystemHost(fileSystem, cwd) {
|
|
|
139
139
|
createProject(compilerOptions) {
|
|
140
140
|
return createProjectSync({
|
|
141
141
|
compilerOptions: compilerOptions,
|
|
142
|
-
fileSystem: fileSystem,
|
|
143
142
|
skipAddingFilesFromTsConfig: true,
|
|
143
|
+
fileSystem: fileSystem,
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -823,10 +823,10 @@ export function Npm_installPackage(fileSystem, spec, options) {
|
|
|
823
823
|
}
|
|
824
824
|
|
|
825
825
|
export function Bootstrap_createProgramForCLI(_fileName, source) {
|
|
826
|
+
const compilerOptions = {};
|
|
827
|
+
compilerOptions.strict = true;
|
|
826
828
|
const project = createProjectSync({
|
|
827
|
-
compilerOptions:
|
|
828
|
-
strict: true,
|
|
829
|
-
},
|
|
829
|
+
compilerOptions: compilerOptions,
|
|
830
830
|
});
|
|
831
831
|
project.createSourceFile(_fileName, source);
|
|
832
832
|
return project.createProgram();
|
|
@@ -836,13 +836,12 @@ export function Bootstrap_createProgramForCLI(_fileName, source) {
|
|
|
836
836
|
* Create a program from declaration files of the host, following their imports
|
|
837
837
|
*/
|
|
838
838
|
export function Bootstrap_createProgramFromFiles(host, entryFiles, withoutDomLib, noLib) {
|
|
839
|
-
const compilerOptions = {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
};
|
|
839
|
+
const compilerOptions = {};
|
|
840
|
+
compilerOptions.target = 99;
|
|
841
|
+
compilerOptions.module = 99;
|
|
842
|
+
compilerOptions.moduleResolution = 100;
|
|
843
|
+
compilerOptions.types = [];
|
|
844
|
+
compilerOptions.strict = true;
|
|
846
845
|
if (withoutDomLib) {
|
|
847
846
|
compilerOptions.lib = ["lib.esnext.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts"];
|
|
848
847
|
}
|
|
@@ -7,12 +7,13 @@ import { trimStart, interpolate, substring, join, replace, concat, isNullOrWhite
|
|
|
7
7
|
import { isDigit2 } from "../fable_modules/fable-library-js.5.17.2/Char.js";
|
|
8
8
|
import { splitLines, replace as replace_1, removeSingleQuote, removeDoubleQuote, capitalizeFirstLetter } from "./Utils/String.js";
|
|
9
9
|
import { tail as tail_1, cons, head, mapIndexed, empty, forAll, ofArray, concat as concat_1, partition, singleton, append, choose, filter, iterateIndexed, isEmpty, iterate, map, length, exists } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
10
|
-
import { disposeSafe, getEnumerator, int32ToString, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
10
|
+
import { stringHash, disposeSafe, getEnumerator, int32ToString, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
11
11
|
import { sanitizeTypeParameterName } from "./Utils/Naming.js";
|
|
12
12
|
import { escape, create, isMatch, replace as replace_2 } from "../fable_modules/fable-library-js.5.17.2/RegExp.js";
|
|
13
13
|
import { removeConsecutiveEmptyLines, trimEmptyLines } from "./Utils/List.js";
|
|
14
14
|
import { singleton as singleton_1, append as append_1, delay, toList } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
15
15
|
import { FSharpOutFile, FSharpInterface, FSharpAttribute } from "./FsharpAST.js";
|
|
16
|
+
import { List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
16
17
|
|
|
17
18
|
export class Printer {
|
|
18
19
|
constructor() {
|
|
@@ -1037,12 +1038,12 @@ function print(printer_mut, fsharpTypes_mut) {
|
|
|
1037
1038
|
Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(extensionInfo.TargetName, extensionInfo.TypeParameters), " with"));
|
|
1038
1039
|
Printer__get_NewLine(printer);
|
|
1039
1040
|
Printer__get_Indent(printer);
|
|
1040
|
-
const
|
|
1041
|
+
const enumerator_1 = getEnumerator(extensionInfo.Members);
|
|
1041
1042
|
try {
|
|
1042
|
-
while (
|
|
1043
|
-
const extensionMember =
|
|
1043
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1044
|
+
const extensionMember = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1044
1045
|
const parameters = join(", ", map((parameter) => concat(parameter.Name, ": ", printParameterType(parameter.Type)), extensionMember.Parameters));
|
|
1045
|
-
const arguments$ = join(", ", map((
|
|
1046
|
+
const arguments$ = join(", ", map((_arg_2) => _arg_2.Name, extensionMember.Parameters));
|
|
1046
1047
|
Printer__Write_Z721C83C5(printer, `member inline this.${extensionMember.Name}(${parameters}) : ${printType(extensionMember.ReturnType)} =`);
|
|
1047
1048
|
Printer__get_NewLine(printer);
|
|
1048
1049
|
Printer__get_Indent(printer);
|
|
@@ -1052,7 +1053,7 @@ function print(printer_mut, fsharpTypes_mut) {
|
|
|
1052
1053
|
}
|
|
1053
1054
|
}
|
|
1054
1055
|
finally {
|
|
1055
|
-
disposeSafe(
|
|
1056
|
+
disposeSafe(enumerator_1);
|
|
1056
1057
|
}
|
|
1057
1058
|
Printer__get_Unindent(printer);
|
|
1058
1059
|
Printer__get_Unindent(printer);
|
|
@@ -1112,6 +1113,43 @@ function print(printer_mut, fsharpTypes_mut) {
|
|
|
1112
1113
|
Printer__Write_Z721C83C5(printer, `static member inline ${constant.Name}: ${unionInfo.Name} = ${unionInfo.Name}.${constant.Case} ${constant.Value}`);
|
|
1113
1114
|
Printer__get_NewLine(printer);
|
|
1114
1115
|
}, unionInfo.Constants);
|
|
1116
|
+
if (exists((_arg) => {
|
|
1117
|
+
switch (_arg.tag) {
|
|
1118
|
+
case 6:
|
|
1119
|
+
case 7:
|
|
1120
|
+
return true;
|
|
1121
|
+
default:
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1124
|
+
}, unionInfo.Attributes)) {
|
|
1125
|
+
const returnType = printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters);
|
|
1126
|
+
iterate((caseType) => {
|
|
1127
|
+
const enumerator = getEnumerator(["op_Implicit", "op_ErasedCast"]);
|
|
1128
|
+
try {
|
|
1129
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1130
|
+
const name_2 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1131
|
+
Printer__get_NewLine(printer);
|
|
1132
|
+
Printer__Write_Z721C83C5(printer, "[<Emit(\"$0\")>]");
|
|
1133
|
+
Printer__get_NewLine(printer);
|
|
1134
|
+
Printer__Write_Z721C83C5(printer, `static member ${name_2}(value: ${caseType}) : ${returnType} = nativeOnly`);
|
|
1135
|
+
Printer__get_NewLine(printer);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
finally {
|
|
1139
|
+
disposeSafe(enumerator);
|
|
1140
|
+
}
|
|
1141
|
+
}, List_distinct(choose((_arg_1) => {
|
|
1142
|
+
if (_arg_1.tag === 2) {
|
|
1143
|
+
return printType(_arg_1.fields[1]);
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
return undefined;
|
|
1147
|
+
}
|
|
1148
|
+
}, unionInfo.Cases), {
|
|
1149
|
+
Equals: (x, y) => (x === y),
|
|
1150
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
1151
|
+
}));
|
|
1152
|
+
}
|
|
1115
1153
|
Printer__get_Unindent(printer);
|
|
1116
1154
|
}
|
|
1117
1155
|
}
|
|
@@ -3,16 +3,16 @@ import { bool_type, array_type, option_type, record_type, list_type, union_type,
|
|
|
3
3
|
import { FSharpRef, Record, Union } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
4
4
|
import { replace as replace_1, trim, toText, printf, toFail, interpolate, join, concat, substring, trimStart } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
5
5
|
import { orElse, toArray, value as value_9, unwrap, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
6
|
-
import { FSharpTypeExtension, FSharpDelegateExtension, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpUnionConstant, FSharpEnumCase, FSharpUnionCaseNamed, FSharpTypeParameterInfo, FSharpConstructor, FSharpExplicitField, FSharpStaticMemberInfo, FSharpAccessor, FSharpMemberInfoBody, FSharpAccessibility,
|
|
7
|
-
import { Lazy, structuralHash, numberHash, clear, curry2,
|
|
6
|
+
import { FSharpTypeExtension, FSharpDelegateExtension, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpUnionConstant, FSharpEnumCase, FSharpUnionCaseNamed, FSharpTypeParameterInfo, FSharpConstructor, FSharpExplicitField, FSharpStaticMemberInfo, FSharpAccessor, FSharpMemberInfoBody, FSharpAccessibility, FSharpParameter, FSharpFunctionType, FSharpTypeReference, FSharpThisType, FSharpTypeParameterInfo_Create_Z6CFD3565, FSharpUnionCase, FSharpTypeParameter, FSharpMapped, FSharpPrimitive, FSharpLiteral, FSharpCommentTypeParam, FSharpCommentParam, FSharpXmlDoc, FSharpModule, FSharpTypeAlias, FSharpEnum, FSharpUnion, FSharpDelegate, FSharpClass, FSharpInterface, FSharpAttribute, FSharpMember, FSharpMemberInfo, FSharpType, FSharpTypeParameter_$reflection, FSharpType_$reflection, FSharpXmlDoc_$reflection, FSharpAttribute_$reflection } from "./FsharpAST.js";
|
|
7
|
+
import { Lazy, structuralHash, numberHash, clear, curry2, stringHash, disposeSafe, getEnumerator, Exception, comparePrimitives, defaultOf, safeHash, equals, int32ToString } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
8
|
+
import { mapFold, concat as concat_1, reverse, tryItem, item, ofSeq as ofSeq_1, take, takeWhile, tryFindIndex as tryFindIndex_1, zip, cons, foldBack, fold, tryFind, tryPick, unzip, forAll, exists, truncate, mapIndexed, partition, filter, ofArray, collect as collect_2, length, iterate, choose, tryHead, sortBy, append as append_1, head as head_2, tail as tail_3, isEmpty, empty, singleton, contains, map as map_2 } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
8
9
|
import { addToSet, getItemFromDict, tryGetValue } from "../fable_modules/fable-library-js.5.17.2/MapUtil.js";
|
|
9
10
|
import { map as map_4, forAll as forAll_1, empty as empty_1, singleton as singleton_1, collect as collect_1, append, delay, toList, tryFindIndex } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
10
11
|
import { contains as contains_2, addRangeInPlace, setItem } from "../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
11
|
-
import { mapFold, concat as concat_1, reverse, tryItem, item, ofSeq as ofSeq_1, take, takeWhile, tryFindIndex as tryFindIndex_1, zip, cons, foldBack, fold, tryFind, tryPick, unzip, forAll, exists, truncate, mapIndexed, partition, contains, filter, ofArray, collect as collect_2, length, iterate, choose, tryHead, sortBy, map as map_2, append as append_1, head as head_2, tail as tail_3, isEmpty, empty, singleton } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
12
12
|
import { FSharpSet__Add, contains as contains_1, empty as empty_2, union as union_1, singleton as singleton_2, add, ofList, FSharpSet__Contains, ofSeq } from "../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
13
13
|
import { sanitizeTypeNameWithResult, removeSurroundingQuotes, sanitizeTypeName, sanitizeName } from "./Utils/Naming.js";
|
|
14
14
|
import { List_distinctBy, List_groupBy, List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
15
|
-
import { GlueClassDeclaration, GlueReExport, GlueLiteral__ToText, GlueIndexSignature, GlueSubstitution_substituteMember, GlueCallSignature, GlueIndexedAccessType, GlueSubstitution_mentionedTypeParameters,
|
|
15
|
+
import { GlueClassDeclaration, GlueReExport, GlueLiteral__ToText, GlueIndexSignature, GlueSubstitution_substituteMember, GlueCallSignature, GlueIndexedAccessType, GlueSubstitution_mentionedTypeParameters, GlueConstructSignature, GlueMember__TryGetAccessor, GlueMember__get_Documentation, GlueProperty, GlueAccessor, GlueMethod, GlueMethodSignature, GlueFunctionType, GlueParameter, GlueTypeUnion, GlueVariable, GlueType__get_Name, GlueConstructor, GlueFunctionDeclaration, GlueInterface, GlueSubstitution_substituteParameter, GlueTypeReference, GlueTypeLiteral, GlueMember, GlueSubstitution_substitute, GlueType, GluePrimitive, GlueTypeParameter } from "./GlueAST.js";
|
|
16
16
|
import { add as add_1, fold as fold_1, exists as exists_1, empty as empty_3, remove, map as map_3, FSharpMap__ContainsKey, FSharpMap__get_Item, ofList as ofList_1 } from "../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
17
17
|
import { apply as apply_3, parametersSignature, distinctBySignature } from "./Merge.js";
|
|
18
18
|
import { isLetterOrDigit } from "../fable_modules/fable-library-js.5.17.2/Char.js";
|
|
@@ -221,11 +221,40 @@ function withCountSuffix(name, count) {
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
function withoutSelfReference(members) {
|
|
225
|
+
return map_2((_arg) => {
|
|
226
|
+
let matchResult, method_1, member_;
|
|
227
|
+
if (_arg.tag === 0) {
|
|
228
|
+
if (contains(FSharpAttribute.ParamObject, _arg.fields[0].Attributes, {
|
|
229
|
+
Equals: equals,
|
|
230
|
+
GetHashCode: (x) => (safeHash(x) | 0),
|
|
231
|
+
})) {
|
|
232
|
+
matchResult = 0;
|
|
233
|
+
method_1 = _arg.fields[0];
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
matchResult = 1;
|
|
237
|
+
member_ = _arg;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
matchResult = 1;
|
|
242
|
+
member_ = _arg;
|
|
243
|
+
}
|
|
244
|
+
switch (matchResult) {
|
|
245
|
+
case 0:
|
|
246
|
+
return new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(method_1.Attributes, method_1.Name, method_1.OriginalName, method_1.TypeParameters, method_1.Parameters, FSharpType.Discard, method_1.IsOptional, method_1.IsStatic, method_1.Accessor, method_1.Accessibility, method_1.XmlDoc, method_1.Body)]);
|
|
247
|
+
default:
|
|
248
|
+
return member_;
|
|
249
|
+
}
|
|
250
|
+
}, members);
|
|
251
|
+
}
|
|
252
|
+
|
|
224
253
|
function withoutName(typ) {
|
|
225
254
|
switch (typ.tag) {
|
|
226
255
|
case 5: {
|
|
227
256
|
const info = typ.fields[0];
|
|
228
|
-
return new FSharpType(/* Interface */ 5, [new FSharpInterface(info.Attributes, "", info.XmlDoc, info.OriginalName, info.TypeParameters, info.Members, info.Inheritance)]);
|
|
257
|
+
return new FSharpType(/* Interface */ 5, [new FSharpInterface(info.Attributes, "", info.XmlDoc, info.OriginalName, info.TypeParameters, withoutSelfReference(info.Members), info.Inheritance)]);
|
|
229
258
|
}
|
|
230
259
|
case 17: {
|
|
231
260
|
const info_1 = typ.fields[0];
|
|
@@ -1938,8 +1967,20 @@ function transformType(context_mut, glueType_mut) {
|
|
|
1938
1967
|
GetHashCode: (x_6) => (stringHash(x_6) | 0),
|
|
1939
1968
|
});
|
|
1940
1969
|
const name_12 = TypeLiteralsMemory__GetTypeName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), TransformContext__get_CurrentScopeName(context));
|
|
1941
|
-
|
|
1942
|
-
|
|
1970
|
+
const creates_1 = forAll((_arg_4) => {
|
|
1971
|
+
switch (_arg_4.tag) {
|
|
1972
|
+
case 6:
|
|
1973
|
+
case 1:
|
|
1974
|
+
case 2:
|
|
1975
|
+
case 3:
|
|
1976
|
+
case 0:
|
|
1977
|
+
return true;
|
|
1978
|
+
default:
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
}, members) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(name_12, map_2((arg_3) => (new FSharpTypeParameter(/* FSharpType */ 0, [new FSharpType(/* TypeParameter */ 13, [arg_3])])), typeParameterNames_4))]), members) : empty();
|
|
1982
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Interface */ 5, [new FSharpInterface(ofArray([FSharpAttribute.AllowNullLiteral, FSharpAttribute.Interface]), name_12, empty(), TransformContext__get_OriginalScopeName(context), map_2((name_13) => (new FSharpTypeParameter(/* FSharpTypeParameter */ 1, [FSharpTypeParameterInfo_Create_Z6CFD3565(name_13)])), typeParameterNames_4), append_1(TransformMembers_toFSharpMember(context, members), creates_1), empty())]));
|
|
1983
|
+
return new FSharpType(/* Mapped */ 7, [new FSharpMapped(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_12), map_2((arg_4) => (new FSharpTypeParameter(/* FSharpType */ 0, [new FSharpType(/* TypeParameter */ 13, [arg_4])])), typeParameterNames_4))]);
|
|
1943
1984
|
}
|
|
1944
1985
|
case 32: {
|
|
1945
1986
|
let matchResult_4, interfaceInfo_1, recordInfo, innerType, members_1, readonlyInfo;
|
|
@@ -2005,7 +2046,7 @@ function transformType(context_mut, glueType_mut) {
|
|
|
2005
2046
|
GetHashCode: (x_7) => (stringHash(x_7) | 0),
|
|
2006
2047
|
}) : empty();
|
|
2007
2048
|
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Interface */ 5, [Interface_makePartial(name_14, transformInterface(context, new GlueInterface(interfaceInfo_1.Documentation, interfaceInfo_1.FullName, interfaceInfo_1.Name, interfaceInfo_1.Members, append_1(interfaceInfo_1.TypeParameters, map_2((name_15) => (new GlueTypeParameter(name_15, undefined, undefined)), freeTypeParameterNames)), interfaceInfo_1.HeritageClauses)))]));
|
|
2008
|
-
return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_14), TransformContext__get_FullName(context), empty(), map_2((
|
|
2049
|
+
return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_14), TransformContext__get_FullName(context), empty(), map_2((Item_41) => (new FSharpType(/* TypeParameter */ 13, [Item_41])), freeTypeParameterNames), FSharpType.Discard)]);
|
|
2009
2050
|
}
|
|
2010
2051
|
case 1:
|
|
2011
2052
|
return FSharpType.Object$;
|
|
@@ -2016,7 +2057,7 @@ function transformType(context_mut, glueType_mut) {
|
|
|
2016
2057
|
GetHashCode: (x_8) => (stringHash(x_8) | 0),
|
|
2017
2058
|
});
|
|
2018
2059
|
TransformContext__ExposeType_Z1D58A540(context, transformRecord(context, name_16, map_2((name_17) => (new GlueTypeParameter(name_17, undefined, undefined)), freeTypeParameterNames_1), recordInfo));
|
|
2019
|
-
return new FSharpType(/* Mapped */ 7, [new FSharpMapped(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_16), map_2((
|
|
2060
|
+
return new FSharpType(/* Mapped */ 7, [new FSharpMapped(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_16), map_2((arg_5) => (new FSharpTypeParameter(/* FSharpType */ 0, [new FSharpType(/* TypeParameter */ 13, [arg_5])])), freeTypeParameterNames_1))]);
|
|
2020
2061
|
}
|
|
2021
2062
|
case 3: {
|
|
2022
2063
|
context_mut = context;
|
|
@@ -2050,7 +2091,7 @@ function transformType(context_mut, glueType_mut) {
|
|
|
2050
2091
|
GetHashCode: (x_10) => (stringHash(x_10) | 0),
|
|
2051
2092
|
});
|
|
2052
2093
|
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Interface */ 5, [new FSharpInterface(ofArray([FSharpAttribute.AllowNullLiteral, FSharpAttribute.Interface]), name_20, empty(), TransformContext__get_OriginalScopeName(context), map_2((name_21) => (new FSharpTypeParameter(/* FSharpTypeParameter */ 1, [FSharpTypeParameterInfo_Create_Z6CFD3565(name_21)])), freeTypeParameterNames_2), members_3, empty())]));
|
|
2053
|
-
return new FSharpType(/* Mapped */ 7, [new FSharpMapped(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_20), map_2((
|
|
2094
|
+
return new FSharpType(/* Mapped */ 7, [new FSharpMapped(TypeLiteralsMemory__ReferenceName_Z384F8060(TransformContext__get_TypeLiteralsMemory(context), TransformContext__get_FullName(context), name_20), map_2((arg_6) => (new FSharpTypeParameter(/* FSharpType */ 0, [new FSharpType(/* TypeParameter */ 13, [arg_6])])), freeTypeParameterNames_2))]);
|
|
2054
2095
|
}
|
|
2055
2096
|
}
|
|
2056
2097
|
case 35:
|
|
@@ -3129,6 +3170,10 @@ function transformAccessor(accessor) {
|
|
|
3129
3170
|
}
|
|
3130
3171
|
}
|
|
3131
3172
|
|
|
3173
|
+
function methodFunctionType(context, documentation, typeParameters, parameters, returnType) {
|
|
3174
|
+
return transformType(context, new GlueType(/* FunctionType */ 15, [new GlueFunctionType(documentation, returnType, typeParameters, map_2((_arg) => _arg.Name, typeParameters), parameters)]));
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3132
3177
|
function TransformMembers_withoutReferenceConstraints(typeParameters) {
|
|
3133
3178
|
return map_2((typeParameter) => {
|
|
3134
3179
|
const matchValue = typeParameter.Constraint;
|
|
@@ -3768,7 +3813,7 @@ function TransformMembers_toFSharpParameters(context, members) {
|
|
|
3768
3813
|
case 6: {
|
|
3769
3814
|
const methodSignature = glueMember.fields[0];
|
|
3770
3815
|
const patternInput_5 = sanitizeNameAndPushScope(methodSignature.Name, context);
|
|
3771
|
-
return new FSharpParameter(empty(), patternInput_5[0], false,
|
|
3816
|
+
return new FSharpParameter(empty(), patternInput_5[0], false, methodFunctionType(patternInput_5[1], methodSignature.Documentation, methodSignature.TypeParameters, methodSignature.Parameters, methodSignature.Type), glueMember);
|
|
3772
3817
|
}
|
|
3773
3818
|
case 4: {
|
|
3774
3819
|
const patternInput_6 = sanitizeNameAndPushScope("Invoke", context);
|
|
@@ -3781,7 +3826,7 @@ function TransformMembers_toFSharpParameters(context, members) {
|
|
|
3781
3826
|
default: {
|
|
3782
3827
|
const methodInfo = glueMember.fields[0];
|
|
3783
3828
|
const patternInput = sanitizeNameAndPushScope(methodInfo.Name, context);
|
|
3784
|
-
return new FSharpParameter(empty(), patternInput[0], methodInfo.IsOptional,
|
|
3829
|
+
return new FSharpParameter(empty(), patternInput[0], methodInfo.IsOptional, methodFunctionType(patternInput[1], methodInfo.Documentation, methodInfo.TypeParameters, methodInfo.Parameters, methodInfo.Type), glueMember);
|
|
3785
3830
|
}
|
|
3786
3831
|
}
|
|
3787
3832
|
}, TransformMembers_withoutComputedNames(members)));
|
|
@@ -9662,7 +9707,7 @@ function transformClassDeclaration(context, classDeclaration) {
|
|
|
9662
9707
|
const defaultAliases = exposeSpecializedAlias(name, empty(), empty(), reverse(typeParametersResult.TypeParameters));
|
|
9663
9708
|
specialiazedAlias = append_1(defaultAliases, ofArray(toArray(makeSealedTypeAlias(name, aliasArities(typeParametersResult.TypeParameters, defaultAliases), typeParametersResult))));
|
|
9664
9709
|
const xmlDoc = transformComment(classDeclaration.Documentation);
|
|
9665
|
-
return cons(new FSharpType(/* Interface */ 5, [new FSharpInterface(toList(delay(() => append(singleton_1(FSharpAttribute.AllowNullLiteral), delay(() => append(hasErrorInheritance ? singleton_1(FSharpAttribute.AbstractClass) : singleton_1(FSharpAttribute.Interface), delay(() => xmlDoc.ObsoleteAttributes)))))), name, xmlDoc.XmlDoc, classDeclaration.Name, typeParametersResult.TypeParameters, TransformMembers_toFSharpMember(context_1, Conditionals_resolveMembers(classDeclaration.TypeParameters, (members_1 = withoutBaseClassProperties(TransformContext__get_TypeMemory(context_1), classDeclaration.HeritageClauses, classDeclaration.Members), CallableProperties_asMethods(TransformContext__get_TypeMemory(context_1), members_1)))), inheritance)]), specialiazedAlias);
|
|
9710
|
+
return cons(new FSharpType(/* Interface */ 5, [new FSharpInterface(toList(delay(() => append(singleton_1(FSharpAttribute.AllowNullLiteral), delay(() => append(hasErrorInheritance ? append(singleton_1(FSharpAttribute.AbstractClass), delay(() => importAttribute(classDeclaration.Name, TransformContext__get_ImportSource(context_1)))) : singleton_1(FSharpAttribute.Interface), delay(() => xmlDoc.ObsoleteAttributes)))))), name, xmlDoc.XmlDoc, classDeclaration.Name, typeParametersResult.TypeParameters, TransformMembers_toFSharpMember(context_1, Conditionals_resolveMembers(classDeclaration.TypeParameters, (members_1 = withoutBaseClassProperties(TransformContext__get_TypeMemory(context_1), classDeclaration.HeritageClauses, classDeclaration.Members), CallableProperties_asMethods(TransformContext__get_TypeMemory(context_1), members_1)))), inheritance)]), specialiazedAlias);
|
|
9666
9711
|
}
|
|
9667
9712
|
|
|
9668
9713
|
function aggregatedExports(types) {
|
package/dist/Program.js
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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 {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import { defaultOf } from "./fable_modules/fable-library-js.5.17.2/Util.js";
|
|
9
|
+
import { GenerateOptions } from "./Glutinum.Converter/Packages.js";
|
|
10
|
+
import { generateBindingFileWith, generatePackagesFromDisk } from "./Glutinum.Converter/Generate.js";
|
|
11
|
+
import { exists, length, head, tail, isEmpty, empty } from "./fable_modules/fable-library-js.5.17.2/List.js";
|
|
12
|
+
import { defaultArg } from "./fable_modules/fable-library-js.5.17.2/Option.js";
|
|
13
|
+
import { success, error, info } from "./Glutinum.Converter/Log.js";
|
|
14
|
+
import { program as program_1 } from "commander";
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
+
function getVersion() {
|
|
17
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
let packageJson;
|
|
19
|
+
const text = readFileSync(path.join(moduleDir, "..", "package.json"), "utf8");
|
|
20
|
+
packageJson = JSON.parse(text);
|
|
21
|
+
return packageJson.version;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
const pkg = JSON.parse(fs.readFileSync(new URL('./../package.json', import.meta.url)));
|
|
24
|
+
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
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
function toGenerateOptions(options) {
|
|
27
|
+
const externals = toList(map((value) => {
|
|
28
|
+
const matchValue = split(value, ["="], undefined, 0);
|
|
29
|
+
if (!equalsWith((x, y) => (x === y), matchValue, defaultOf()) && (matchValue.length === 2)) {
|
|
30
|
+
return [item(0, matchValue), item(1, matchValue)];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return [value, undefined];
|
|
34
|
+
}
|
|
35
|
+
}, options.external));
|
|
36
|
+
const includes = toList(collect((value_1) => split(value_1, [","], undefined, 0), options.include));
|
|
37
|
+
return new GenerateOptions(options.externals, externals, options.moduleName, includes, !options.lib);
|
|
23
38
|
}
|
|
24
39
|
|
|
25
|
-
function generate(options, inputs) {
|
|
40
|
+
function generate(options, isAll, inputs) {
|
|
26
41
|
let matchResult, input_1, inputs_1;
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else {
|
|
33
|
-
matchResult = 2;
|
|
34
|
-
inputs_1 = inputs;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else if (isEmpty(tail_5(inputs))) {
|
|
42
|
+
if (isAll) {
|
|
43
|
+
matchResult = 0;
|
|
44
|
+
}
|
|
45
|
+
else if (!isEmpty(inputs)) {
|
|
46
|
+
if (isEmpty(tail(inputs))) {
|
|
38
47
|
if (head(inputs).endsWith(".d.ts")) {
|
|
39
48
|
matchResult = 1;
|
|
40
49
|
input_1 = head(inputs);
|
|
@@ -63,227 +72,73 @@ function generate(options, inputs) {
|
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
}
|
|
75
|
+
function write(outFile, content) {
|
|
76
|
+
if (outFile == null) {
|
|
77
|
+
const stdout = process.stdout;
|
|
78
|
+
stdout.write(content, "utf8");
|
|
88
79
|
}
|
|
89
80
|
else {
|
|
90
|
-
|
|
81
|
+
const outFile_1 = outFile;
|
|
82
|
+
const mkdirOptions = {};
|
|
83
|
+
mkdirOptions.recursive = true;
|
|
84
|
+
mkdirSync(path.dirname(outFile_1), mkdirOptions);
|
|
85
|
+
writeFileSync(outFile_1, content);
|
|
86
|
+
info(concat("Bindings written to: ", path.resolve(outFile_1)));
|
|
91
87
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function run(argv) {
|
|
91
|
+
const program = program_1;
|
|
92
|
+
program.name("glutinum").description("Generate Fable bindings from TypeScript definitions - https://github.com/glutinum-org/cli").version(getVersion());
|
|
93
|
+
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");
|
|
94
|
+
program.option("--external <package>", "reference <package> from its own binding, as <package> or <package>=<Module>", (value_3, previous_1) => {
|
|
95
|
+
void (previous_1.push(value_3));
|
|
96
|
+
return previous_1;
|
|
97
|
+
}, []).option("--include <names>", "comma separated declarations to keep, the others are dropped", (value_2, previous) => {
|
|
98
|
+
void (previous.push(value_2));
|
|
99
|
+
return previous;
|
|
100
|
+
}, []).addHelpText("after", helpText).showHelpAfterError();
|
|
101
|
+
const parseOptions = {
|
|
102
|
+
from: "user",
|
|
103
|
+
};
|
|
104
|
+
program.parse(Array.from(argv), parseOptions);
|
|
105
|
+
const options = program.opts();
|
|
106
|
+
const inputs = toList(program.args);
|
|
107
|
+
const isAll = defaultArg(options.all, false);
|
|
108
|
+
const mixesFileAndPackages = (length(inputs) > 1) && exists((input) => input.endsWith(".d.ts"), inputs);
|
|
109
|
+
if (isEmpty(inputs) && !isAll) {
|
|
110
|
+
error("Give at least one input, or --all");
|
|
111
|
+
program.outputHelp({
|
|
112
|
+
error: true,
|
|
113
|
+
});
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
116
|
+
else if (mixesFileAndPackages) {
|
|
117
|
+
error("A .d.ts file is generated alone, it can\'t be combined with other inputs");
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
if (isAll) {
|
|
122
|
+
info("Generating binding file for every installed package");
|
|
96
123
|
}
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
else {
|
|
125
|
+
info(concat("Generating binding file for ", join(", ", inputs)));
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const content = generate(toGenerateOptions(options), isAll, inputs);
|
|
129
|
+
write(options.outFile, content);
|
|
130
|
+
success("Success!");
|
|
99
131
|
return 0;
|
|
100
132
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
}
|
|
133
|
+
catch (ex) {
|
|
134
|
+
error(ex.message);
|
|
135
|
+
return 1;
|
|
281
136
|
}
|
|
282
137
|
}
|
|
283
138
|
}
|
|
284
139
|
|
|
285
140
|
(function (argv) {
|
|
286
|
-
const exitCode = run(
|
|
141
|
+
const exitCode = run(argv) | 0;
|
|
287
142
|
process.exitCode = exitCode;
|
|
288
143
|
return exitCode | 0;
|
|
289
144
|
})(typeof process === 'object' ? process.argv.slice(2) : []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glutinum/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
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
|
}
|