typia 5.0.4 → 5.0.5-dev.20230921
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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/IRandomGenerator.ts +35 -35
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +135 -135
- package/src/Resolved.ts +116 -116
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/TypiaGenerateWizard.ts +85 -85
- package/src/executable/TypiaSetupWizard.ts +153 -153
- package/src/executable/setup/ArgumentParser.ts +45 -45
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +22 -22
- package/src/executable/setup/PackageManager.ts +71 -71
- package/src/executable/setup/PluginConfigurator.ts +70 -70
- package/src/executable/typia.ts +52 -52
- package/src/factories/CommentFactory.ts +84 -84
- package/src/factories/ExpressionFactory.ts +159 -159
- package/src/factories/IdentifierFactory.ts +74 -74
- package/src/factories/JsonMetadataFactory.ts +43 -43
- package/src/factories/LiteralFactory.ts +47 -47
- package/src/factories/MetadataCollection.ts +269 -269
- package/src/factories/MetadataCommentTagFactory.ts +629 -629
- package/src/factories/MetadataFactory.ts +214 -214
- package/src/factories/MetadataTypeTagFactory.ts +313 -313
- package/src/factories/NumericRangeFactory.ts +33 -33
- package/src/factories/ProtobufFactory.ts +272 -272
- package/src/factories/StatementFactory.ts +72 -72
- package/src/factories/TemplateFactory.ts +58 -58
- package/src/factories/TypeFactory.ts +119 -119
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
- package/src/factories/internal/metadata/emend_metadata_atomics.ts +40 -40
- package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_object.ts +150 -150
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +60 -60
- package/src/factories/internal/metadata/explore_metadata.ts +32 -32
- package/src/factories/internal/metadata/iterate_metadata.ts +101 -101
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +35 -35
- package/src/factories/internal/metadata/iterate_metadata_array.ts +37 -37
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +141 -141
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +197 -197
- package/src/factories/internal/metadata/iterate_metadata_map.ts +57 -57
- package/src/factories/internal/metadata/iterate_metadata_native.ts +210 -210
- package/src/factories/internal/metadata/iterate_metadata_object.ts +44 -44
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
- package/src/factories/internal/metadata/iterate_metadata_set.ts +42 -42
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
- package/src/factories/internal/metadata/iterate_metadata_template.ts +47 -47
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +37 -37
- package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
- package/src/functional/$ProtobufReader.ts +201 -201
- package/src/functional/$ProtobufSizer.ts +147 -147
- package/src/functional/$ProtobufWriter.ts +151 -151
- package/src/functional/$any.ts +4 -4
- package/src/functional/$clone.ts +4 -4
- package/src/functional/$dictionary.ts +25 -25
- package/src/functional/$every.ts +11 -11
- package/src/functional/$guard.ts +35 -35
- package/src/functional/$is_between.ts +2 -2
- package/src/functional/$join.ts +46 -46
- package/src/functional/$number.ts +13 -13
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +50 -50
- package/src/functional/$strlen.ts +7 -7
- package/src/functional/$tail.ts +5 -5
- package/src/functional/$varint.ts +130 -130
- package/src/functional/$zigzag.ts +39 -39
- package/src/functional/IProtobufWriter.ts +18 -18
- package/src/functional/Namespace.ts +133 -133
- package/src/index.ts +4 -4
- package/src/json.ts +648 -648
- package/src/misc.ts +651 -651
- package/src/module.ts +656 -656
- package/src/programmers/AssertProgrammer.ts +317 -317
- package/src/programmers/CheckerProgrammer.ts +1137 -1137
- package/src/programmers/FeatureProgrammer.ts +478 -478
- package/src/programmers/IsProgrammer.ts +252 -252
- package/src/programmers/RandomProgrammer.ts +878 -878
- package/src/programmers/TypiaProgrammer.ts +163 -163
- package/src/programmers/ValidateProgrammer.ts +346 -346
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/CloneJoiner.ts +144 -144
- package/src/programmers/helpers/FunctionImporeter.ts +91 -91
- package/src/programmers/helpers/ICheckEntry.ts +13 -13
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/OptionPredicator.ts +15 -15
- package/src/programmers/helpers/ProtobufUtil.ts +125 -125
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/helpers/PruneJoiner.ts +143 -143
- package/src/programmers/helpers/RandomJoiner.ts +151 -151
- package/src/programmers/helpers/RandomRanger.ts +173 -173
- package/src/programmers/helpers/StringifyJoinder.ts +113 -113
- package/src/programmers/helpers/StringifyPredicator.ts +12 -12
- package/src/programmers/helpers/UnionExplorer.ts +305 -305
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/helpers/disable_function_importer_declare.ts +32 -32
- package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
- package/src/programmers/internal/application_alias.ts +65 -65
- package/src/programmers/internal/application_array.ts +53 -53
- package/src/programmers/internal/application_boolean.ts +15 -15
- package/src/programmers/internal/application_constant.ts +26 -26
- package/src/programmers/internal/application_default.ts +17 -17
- package/src/programmers/internal/application_default_string.ts +37 -37
- package/src/programmers/internal/application_escaped.ts +55 -55
- package/src/programmers/internal/application_native.ts +39 -39
- package/src/programmers/internal/application_number.ts +88 -88
- package/src/programmers/internal/application_object.ts +162 -162
- package/src/programmers/internal/application_schema.ts +175 -175
- package/src/programmers/internal/application_string.ts +51 -51
- package/src/programmers/internal/application_templates.ts +25 -25
- package/src/programmers/internal/application_tuple.ts +58 -58
- package/src/programmers/internal/check_array_length.ts +41 -41
- package/src/programmers/internal/check_bigint.ts +45 -45
- package/src/programmers/internal/check_dynamic_properties.ts +194 -194
- package/src/programmers/internal/check_everything.ts +28 -28
- package/src/programmers/internal/check_native.ts +21 -21
- package/src/programmers/internal/check_number.ts +105 -105
- package/src/programmers/internal/check_object.ts +55 -55
- package/src/programmers/internal/check_string.ts +45 -45
- package/src/programmers/internal/check_template.ts +61 -61
- package/src/programmers/internal/check_union_array_like.ts +323 -323
- package/src/programmers/internal/decode_union_object.ts +84 -84
- package/src/programmers/internal/feature_object_entries.ts +58 -58
- package/src/programmers/internal/metadata_to_pattern.ts +34 -34
- package/src/programmers/internal/prune_object_properties.ts +60 -60
- package/src/programmers/internal/random_custom.ts +37 -37
- package/src/programmers/internal/stringify_dynamic_properties.ts +171 -171
- package/src/programmers/internal/stringify_native.ts +7 -7
- package/src/programmers/internal/stringify_regular_properties.ts +83 -83
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +20 -20
- package/src/programmers/json/JsonApplicationProgrammer.ts +50 -50
- package/src/programmers/json/JsonAssertParseProgrammer.ts +71 -71
- package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
- package/src/programmers/json/JsonIsParseProgrammer.ts +77 -77
- package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
- package/src/programmers/json/JsonStringifyProgrammer.ts +964 -964
- package/src/programmers/json/JsonValidateParseProgrammer.ts +68 -68
- package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
- package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
- package/src/programmers/misc/MiscCloneProgrammer.ts +774 -774
- package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
- package/src/programmers/misc/MiscIsPruneProgrammer.ts +73 -73
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +69 -69
- package/src/programmers/misc/MiscPruneProgrammer.ts +550 -550
- package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
- package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +655 -655
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +883 -883
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +85 -85
- package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +165 -165
- package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
- package/src/protobuf.ts +881 -881
- package/src/schemas/json/IJsonApplication.ts +8 -8
- package/src/schemas/json/IJsonComponents.ts +33 -33
- package/src/schemas/json/IJsonSchema.ts +110 -110
- package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
- package/src/schemas/metadata/IMetadata.ts +34 -34
- package/src/schemas/metadata/IMetadataAlias.ts +12 -12
- package/src/schemas/metadata/IMetadataApplication.ts +7 -7
- package/src/schemas/metadata/IMetadataArray.ts +7 -7
- package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
- package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
- package/src/schemas/metadata/IMetadataCollection.ts +11 -11
- package/src/schemas/metadata/IMetadataConstant.ts +16 -16
- package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
- package/src/schemas/metadata/IMetadataEntry.ts +6 -6
- package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
- package/src/schemas/metadata/IMetadataObject.ts +18 -18
- package/src/schemas/metadata/IMetadataProperty.ts +9 -9
- package/src/schemas/metadata/IMetadataTuple.ts +7 -7
- package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
- package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
- package/src/schemas/metadata/Metadata.ts +685 -685
- package/src/schemas/metadata/MetadataAlias.ts +61 -61
- package/src/schemas/metadata/MetadataArray.ts +49 -49
- package/src/schemas/metadata/MetadataArrayType.ts +57 -57
- package/src/schemas/metadata/MetadataAtomic.ts +42 -42
- package/src/schemas/metadata/MetadataConstant.ts +3 -3
- package/src/schemas/metadata/MetadataEscaped.ts +51 -51
- package/src/schemas/metadata/MetadataObject.ts +139 -139
- package/src/schemas/metadata/MetadataProperty.ts +59 -59
- package/src/schemas/metadata/MetadataTuple.ts +32 -32
- package/src/schemas/metadata/MetadataTupleType.ts +67 -67
- package/src/tags/ExclusiveMaximum.ts +13 -13
- package/src/tags/ExclusiveMinimum.ts +13 -13
- package/src/tags/Format.ts +30 -30
- package/src/tags/MaxItems.ts +9 -9
- package/src/tags/MaxLength.ts +9 -9
- package/src/tags/Maximum.ts +13 -13
- package/src/tags/MinItems.ts +9 -9
- package/src/tags/MinLength.ts +9 -9
- package/src/tags/Minimum.ts +13 -13
- package/src/tags/MultipleOf.ts +15 -15
- package/src/tags/Pattern.ts +8 -8
- package/src/tags/TagBase.ts +68 -68
- package/src/tags/Type.ts +27 -27
- package/src/tags/index.ts +13 -13
- package/src/transform.ts +35 -35
- package/src/transformers/CallExpressionTransformer.ts +243 -243
- package/src/transformers/FileTransformer.ts +57 -57
- package/src/transformers/IProject.ts +15 -15
- package/src/transformers/ITransformOptions.ts +62 -62
- package/src/transformers/ImportTransformer.ts +66 -66
- package/src/transformers/NodeTransformer.ts +13 -13
- package/src/transformers/TransformerError.ts +55 -55
- package/src/transformers/features/AssertTransformer.ts +11 -11
- package/src/transformers/features/CreateAssertTransformer.ts +13 -13
- package/src/transformers/features/CreateIsTransformer.ts +11 -11
- package/src/transformers/features/CreateRandomTransformer.ts +43 -43
- package/src/transformers/features/CreateValidateTransformer.ts +13 -13
- package/src/transformers/features/IsTransformer.ts +11 -11
- package/src/transformers/features/RandomTransformer.ts +46 -46
- package/src/transformers/features/ValidateTransformer.ts +11 -11
- package/src/transformers/features/json/JsonApplicationTransformer.ts +118 -118
- package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
- package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/misc/MetadataTransformer.ts +61 -61
- package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
- package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
- package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +12 -12
- package/src/transformers/internal/GenericTransformer.ts +104 -104
- package/src/typings/Atomic.ts +18 -18
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/Customizable.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/ProtobufAtomic.ts +19 -19
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/ValidationPipe.ts +9 -9
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +45 -45
- package/src/utils/Escaper.ts +46 -46
- package/src/utils/MapUtil.ts +12 -12
- package/src/utils/NameEncoder.ts +32 -32
- package/src/utils/PatternUtil.ts +33 -33
- package/src/utils/RandomGenerator.ts +83 -83
- package/src/utils/Singleton.ts +17 -17
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
export namespace FileRetriever {
|
|
5
|
-
export const directory =
|
|
6
|
-
(name: string) =>
|
|
7
|
-
(dir: string, depth: number = 0): string | null => {
|
|
8
|
-
const location: string = path.join(dir, name);
|
|
9
|
-
if (fs.existsSync(location)) return dir;
|
|
10
|
-
else if (depth > 2) return null;
|
|
11
|
-
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const file =
|
|
15
|
-
(name: string) =>
|
|
16
|
-
(directory: string, depth: number = 0): string | null => {
|
|
17
|
-
const location: string = path.join(directory, name);
|
|
18
|
-
if (fs.existsSync(location)) return location;
|
|
19
|
-
else if (depth > 2) return null;
|
|
20
|
-
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export namespace FileRetriever {
|
|
5
|
+
export const directory =
|
|
6
|
+
(name: string) =>
|
|
7
|
+
(dir: string, depth: number = 0): string | null => {
|
|
8
|
+
const location: string = path.join(dir, name);
|
|
9
|
+
if (fs.existsSync(location)) return dir;
|
|
10
|
+
else if (depth > 2) return null;
|
|
11
|
+
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const file =
|
|
15
|
+
(name: string) =>
|
|
16
|
+
(directory: string, depth: number = 0): string | null => {
|
|
17
|
+
const location: string = path.join(directory, name);
|
|
18
|
+
if (fs.existsSync(location)) return location;
|
|
19
|
+
else if (depth > 2) return null;
|
|
20
|
+
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { CommandExecutor } from "./CommandExecutor";
|
|
5
|
-
import { FileRetriever } from "./FileRetriever";
|
|
6
|
-
|
|
7
|
-
export class PackageManager {
|
|
8
|
-
public manager: string = "npm";
|
|
9
|
-
public get file(): string {
|
|
10
|
-
return path.join(this.directory, "package.json");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public static async mount(): Promise<PackageManager> {
|
|
14
|
-
const location: string | null = await FileRetriever.directory(
|
|
15
|
-
"package.json",
|
|
16
|
-
)(process.cwd());
|
|
17
|
-
if (location === null)
|
|
18
|
-
throw new URIError(`Unable to find "package.json" file`);
|
|
19
|
-
|
|
20
|
-
return new PackageManager(
|
|
21
|
-
location,
|
|
22
|
-
await this.load(path.join(location, "package.json")),
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async save(modifier: (data: Package.Data) => void): Promise<void> {
|
|
27
|
-
const content: string = await fs.promises.readFile(this.file, "utf8");
|
|
28
|
-
this.data = JSON.parse(content);
|
|
29
|
-
modifier(this.data);
|
|
30
|
-
|
|
31
|
-
return fs.promises.writeFile(
|
|
32
|
-
this.file,
|
|
33
|
-
JSON.stringify(this.data, null, 2),
|
|
34
|
-
"utf8",
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public install(props: {
|
|
39
|
-
dev: boolean;
|
|
40
|
-
modulo: string;
|
|
41
|
-
version: string;
|
|
42
|
-
}): boolean {
|
|
43
|
-
const middle: string =
|
|
44
|
-
this.manager === "yarn"
|
|
45
|
-
? `add${props.dev ? " -D" : ""}`
|
|
46
|
-
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
47
|
-
CommandExecutor.run(
|
|
48
|
-
`${this.manager} ${middle} ${props.modulo}${
|
|
49
|
-
props.version ? `@${props.version}` : ""
|
|
50
|
-
}`,
|
|
51
|
-
);
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private constructor(
|
|
56
|
-
public readonly directory: string,
|
|
57
|
-
public data: Package.Data,
|
|
58
|
-
) {}
|
|
59
|
-
|
|
60
|
-
private static async load(file: string): Promise<Package.Data> {
|
|
61
|
-
const content: string = await fs.promises.readFile(file, "utf8");
|
|
62
|
-
return JSON.parse(content);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export namespace Package {
|
|
66
|
-
export interface Data {
|
|
67
|
-
scripts?: Record<string, string>;
|
|
68
|
-
dependencies?: Record<string, string>;
|
|
69
|
-
devDependencies?: Record<string, string>;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { CommandExecutor } from "./CommandExecutor";
|
|
5
|
+
import { FileRetriever } from "./FileRetriever";
|
|
6
|
+
|
|
7
|
+
export class PackageManager {
|
|
8
|
+
public manager: string = "npm";
|
|
9
|
+
public get file(): string {
|
|
10
|
+
return path.join(this.directory, "package.json");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public static async mount(): Promise<PackageManager> {
|
|
14
|
+
const location: string | null = await FileRetriever.directory(
|
|
15
|
+
"package.json",
|
|
16
|
+
)(process.cwd());
|
|
17
|
+
if (location === null)
|
|
18
|
+
throw new URIError(`Unable to find "package.json" file`);
|
|
19
|
+
|
|
20
|
+
return new PackageManager(
|
|
21
|
+
location,
|
|
22
|
+
await this.load(path.join(location, "package.json")),
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async save(modifier: (data: Package.Data) => void): Promise<void> {
|
|
27
|
+
const content: string = await fs.promises.readFile(this.file, "utf8");
|
|
28
|
+
this.data = JSON.parse(content);
|
|
29
|
+
modifier(this.data);
|
|
30
|
+
|
|
31
|
+
return fs.promises.writeFile(
|
|
32
|
+
this.file,
|
|
33
|
+
JSON.stringify(this.data, null, 2),
|
|
34
|
+
"utf8",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public install(props: {
|
|
39
|
+
dev: boolean;
|
|
40
|
+
modulo: string;
|
|
41
|
+
version: string;
|
|
42
|
+
}): boolean {
|
|
43
|
+
const middle: string =
|
|
44
|
+
this.manager === "yarn"
|
|
45
|
+
? `add${props.dev ? " -D" : ""}`
|
|
46
|
+
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
47
|
+
CommandExecutor.run(
|
|
48
|
+
`${this.manager} ${middle} ${props.modulo}${
|
|
49
|
+
props.version ? `@${props.version}` : ""
|
|
50
|
+
}`,
|
|
51
|
+
);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private constructor(
|
|
56
|
+
public readonly directory: string,
|
|
57
|
+
public data: Package.Data,
|
|
58
|
+
) {}
|
|
59
|
+
|
|
60
|
+
private static async load(file: string): Promise<Package.Data> {
|
|
61
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
62
|
+
return JSON.parse(content);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export namespace Package {
|
|
66
|
+
export interface Data {
|
|
67
|
+
scripts?: Record<string, string>;
|
|
68
|
+
dependencies?: Record<string, string>;
|
|
69
|
+
devDependencies?: Record<string, string>;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import comments from "comment-json";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
|
|
4
|
-
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
5
|
-
|
|
6
|
-
export namespace PluginConfigurator {
|
|
7
|
-
export async function configure(
|
|
8
|
-
args: TypiaSetupWizard.IArguments,
|
|
9
|
-
): Promise<void> {
|
|
10
|
-
// GET COMPILER-OPTIONS
|
|
11
|
-
const config: comments.CommentObject = comments.parse(
|
|
12
|
-
await fs.promises.readFile(args.project!, "utf8"),
|
|
13
|
-
) as comments.CommentObject;
|
|
14
|
-
const compilerOptions = config.compilerOptions as
|
|
15
|
-
| comments.CommentObject
|
|
16
|
-
| undefined;
|
|
17
|
-
if (compilerOptions === undefined)
|
|
18
|
-
throw new ReferenceError(
|
|
19
|
-
`${args.project} file does not have "compilerOptions" property.`,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// PREPARE PLUGINS
|
|
23
|
-
const plugins: comments.CommentArray<comments.CommentObject> = (() => {
|
|
24
|
-
const plugins = compilerOptions.plugins as
|
|
25
|
-
| comments.CommentArray<comments.CommentObject>
|
|
26
|
-
| undefined;
|
|
27
|
-
if (plugins === undefined)
|
|
28
|
-
return (compilerOptions.plugins = [] as any);
|
|
29
|
-
else if (!Array.isArray(plugins))
|
|
30
|
-
throw new TypeError(
|
|
31
|
-
`"plugins" property of ${args.project} must be array type.`,
|
|
32
|
-
);
|
|
33
|
-
return plugins;
|
|
34
|
-
})();
|
|
35
|
-
|
|
36
|
-
const strict: boolean | undefined = compilerOptions.strict as
|
|
37
|
-
| boolean
|
|
38
|
-
| undefined;
|
|
39
|
-
const strictNullChecks: boolean | undefined =
|
|
40
|
-
compilerOptions.strictNullChecks as boolean | undefined;
|
|
41
|
-
const oldbie: comments.CommentObject | undefined = plugins.find(
|
|
42
|
-
(p) =>
|
|
43
|
-
typeof p === "object" &&
|
|
44
|
-
p !== null &&
|
|
45
|
-
p.transform === "typia/lib/transform",
|
|
46
|
-
);
|
|
47
|
-
if (
|
|
48
|
-
strictNullChecks !== false &&
|
|
49
|
-
(strict === true || strictNullChecks === true) &&
|
|
50
|
-
oldbie !== undefined
|
|
51
|
-
)
|
|
52
|
-
return;
|
|
53
|
-
|
|
54
|
-
// DO CONFIGURE
|
|
55
|
-
compilerOptions.strictNullChecks = true;
|
|
56
|
-
if (strict === undefined && strictNullChecks === undefined)
|
|
57
|
-
compilerOptions.strict = true;
|
|
58
|
-
if (oldbie === undefined)
|
|
59
|
-
plugins.push(
|
|
60
|
-
comments.parse(`
|
|
61
|
-
{
|
|
62
|
-
"transform": "typia/lib/transform"
|
|
63
|
-
}`) as comments.CommentObject,
|
|
64
|
-
);
|
|
65
|
-
await fs.promises.writeFile(
|
|
66
|
-
args.project!,
|
|
67
|
-
comments.stringify(config, null, 2),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
import comments from "comment-json";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
5
|
+
|
|
6
|
+
export namespace PluginConfigurator {
|
|
7
|
+
export async function configure(
|
|
8
|
+
args: TypiaSetupWizard.IArguments,
|
|
9
|
+
): Promise<void> {
|
|
10
|
+
// GET COMPILER-OPTIONS
|
|
11
|
+
const config: comments.CommentObject = comments.parse(
|
|
12
|
+
await fs.promises.readFile(args.project!, "utf8"),
|
|
13
|
+
) as comments.CommentObject;
|
|
14
|
+
const compilerOptions = config.compilerOptions as
|
|
15
|
+
| comments.CommentObject
|
|
16
|
+
| undefined;
|
|
17
|
+
if (compilerOptions === undefined)
|
|
18
|
+
throw new ReferenceError(
|
|
19
|
+
`${args.project} file does not have "compilerOptions" property.`,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// PREPARE PLUGINS
|
|
23
|
+
const plugins: comments.CommentArray<comments.CommentObject> = (() => {
|
|
24
|
+
const plugins = compilerOptions.plugins as
|
|
25
|
+
| comments.CommentArray<comments.CommentObject>
|
|
26
|
+
| undefined;
|
|
27
|
+
if (plugins === undefined)
|
|
28
|
+
return (compilerOptions.plugins = [] as any);
|
|
29
|
+
else if (!Array.isArray(plugins))
|
|
30
|
+
throw new TypeError(
|
|
31
|
+
`"plugins" property of ${args.project} must be array type.`,
|
|
32
|
+
);
|
|
33
|
+
return plugins;
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
const strict: boolean | undefined = compilerOptions.strict as
|
|
37
|
+
| boolean
|
|
38
|
+
| undefined;
|
|
39
|
+
const strictNullChecks: boolean | undefined =
|
|
40
|
+
compilerOptions.strictNullChecks as boolean | undefined;
|
|
41
|
+
const oldbie: comments.CommentObject | undefined = plugins.find(
|
|
42
|
+
(p) =>
|
|
43
|
+
typeof p === "object" &&
|
|
44
|
+
p !== null &&
|
|
45
|
+
p.transform === "typia/lib/transform",
|
|
46
|
+
);
|
|
47
|
+
if (
|
|
48
|
+
strictNullChecks !== false &&
|
|
49
|
+
(strict === true || strictNullChecks === true) &&
|
|
50
|
+
oldbie !== undefined
|
|
51
|
+
)
|
|
52
|
+
return;
|
|
53
|
+
|
|
54
|
+
// DO CONFIGURE
|
|
55
|
+
compilerOptions.strictNullChecks = true;
|
|
56
|
+
if (strict === undefined && strictNullChecks === undefined)
|
|
57
|
+
compilerOptions.strict = true;
|
|
58
|
+
if (oldbie === undefined)
|
|
59
|
+
plugins.push(
|
|
60
|
+
comments.parse(`
|
|
61
|
+
{
|
|
62
|
+
"transform": "typia/lib/transform"
|
|
63
|
+
}`) as comments.CommentObject,
|
|
64
|
+
);
|
|
65
|
+
await fs.promises.writeFile(
|
|
66
|
+
args.project!,
|
|
67
|
+
comments.stringify(config, null, 2),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
package/src/executable/typia.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
-
|
|
4
|
-
npx typia setup \\
|
|
5
|
-
--manager (npm|pnpm|yarn) \\
|
|
6
|
-
--project {tsconfig.json file path}
|
|
7
|
-
|
|
8
|
-
- npx typia setup
|
|
9
|
-
- npx typia setup --manager pnpm
|
|
10
|
-
- npx typia setup --project tsconfig.test.json
|
|
11
|
-
|
|
12
|
-
npx typia generate
|
|
13
|
-
--input {directory} \\
|
|
14
|
-
--output {directory}
|
|
15
|
-
|
|
16
|
-
--npx typia generate --input src/templates --output src/functinoal
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
const halt = (desc: string): never => {
|
|
20
|
-
console.error(desc);
|
|
21
|
-
process.exit(-1);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const main = async (): Promise<void> => {
|
|
25
|
-
try {
|
|
26
|
-
await import("comment-json");
|
|
27
|
-
await import("inquirer");
|
|
28
|
-
await import("commander");
|
|
29
|
-
} catch {
|
|
30
|
-
halt(`typia has not been installed. Run "npm i typia" before.`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const type: string | undefined = process.argv[2];
|
|
34
|
-
if (type === "setup") {
|
|
35
|
-
const { TypiaSetupWizard } = await import("./TypiaSetupWizard");
|
|
36
|
-
await TypiaSetupWizard.setup();
|
|
37
|
-
} else if (type === "generate") {
|
|
38
|
-
try {
|
|
39
|
-
await import("typescript");
|
|
40
|
-
} catch {
|
|
41
|
-
halt(
|
|
42
|
-
`typescript has not been installed. Run "npm i -D typescript" before.`,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
|
|
46
|
-
await TypiaGenerateWizard.generate();
|
|
47
|
-
} else halt(USAGE);
|
|
48
|
-
};
|
|
49
|
-
main().catch((exp) => {
|
|
50
|
-
console.error(exp);
|
|
51
|
-
process.exit(-1);
|
|
52
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
+
|
|
4
|
+
npx typia setup \\
|
|
5
|
+
--manager (npm|pnpm|yarn) \\
|
|
6
|
+
--project {tsconfig.json file path}
|
|
7
|
+
|
|
8
|
+
- npx typia setup
|
|
9
|
+
- npx typia setup --manager pnpm
|
|
10
|
+
- npx typia setup --project tsconfig.test.json
|
|
11
|
+
|
|
12
|
+
npx typia generate
|
|
13
|
+
--input {directory} \\
|
|
14
|
+
--output {directory}
|
|
15
|
+
|
|
16
|
+
--npx typia generate --input src/templates --output src/functinoal
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const halt = (desc: string): never => {
|
|
20
|
+
console.error(desc);
|
|
21
|
+
process.exit(-1);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const main = async (): Promise<void> => {
|
|
25
|
+
try {
|
|
26
|
+
await import("comment-json");
|
|
27
|
+
await import("inquirer");
|
|
28
|
+
await import("commander");
|
|
29
|
+
} catch {
|
|
30
|
+
halt(`typia has not been installed. Run "npm i typia" before.`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const type: string | undefined = process.argv[2];
|
|
34
|
+
if (type === "setup") {
|
|
35
|
+
const { TypiaSetupWizard } = await import("./TypiaSetupWizard");
|
|
36
|
+
await TypiaSetupWizard.setup();
|
|
37
|
+
} else if (type === "generate") {
|
|
38
|
+
try {
|
|
39
|
+
await import("typescript");
|
|
40
|
+
} catch {
|
|
41
|
+
halt(
|
|
42
|
+
`typescript has not been installed. Run "npm i -D typescript" before.`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
|
|
46
|
+
await TypiaGenerateWizard.generate();
|
|
47
|
+
} else halt(USAGE);
|
|
48
|
+
};
|
|
49
|
+
main().catch((exp) => {
|
|
50
|
+
console.error(exp);
|
|
51
|
+
process.exit(-1);
|
|
52
|
+
});
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export namespace CommentFactory {
|
|
4
|
-
export const description = (
|
|
5
|
-
symbol: ts.Symbol,
|
|
6
|
-
includeTags: boolean = false,
|
|
7
|
-
): string | undefined => {
|
|
8
|
-
const node = symbol.declarations?.[0];
|
|
9
|
-
if (!node) return undefined;
|
|
10
|
-
|
|
11
|
-
// FOR LEGACY TS < 5.2
|
|
12
|
-
const [major, minor] = ts.versionMajorMinor.split(".").map(Number) as [
|
|
13
|
-
number,
|
|
14
|
-
number,
|
|
15
|
-
];
|
|
16
|
-
if (major < 5 || (major === 5 && minor < 1)) {
|
|
17
|
-
const content: string[] = [];
|
|
18
|
-
const main: string = ts.displayPartsToString(
|
|
19
|
-
symbol.getDocumentationComment(undefined),
|
|
20
|
-
);
|
|
21
|
-
if (main.length) {
|
|
22
|
-
content.push(main);
|
|
23
|
-
if (includeTags && symbol.getJsDocTags().length)
|
|
24
|
-
content.push("");
|
|
25
|
-
}
|
|
26
|
-
if (includeTags)
|
|
27
|
-
for (const tag of symbol.getJsDocTags()) {
|
|
28
|
-
content.push(
|
|
29
|
-
tag.text
|
|
30
|
-
? `@${tag.name} ${ts.displayPartsToString(
|
|
31
|
-
tag.text,
|
|
32
|
-
)}`
|
|
33
|
-
: `@${tag.name}`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return content.length
|
|
37
|
-
? content
|
|
38
|
-
.map((line) => line.split("\r\n").join("\n"))
|
|
39
|
-
.join("\n")
|
|
40
|
-
: undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// NEW FEATURE OF TS 5.2
|
|
44
|
-
const elements: readonly (ts.JSDoc | ts.JSDocTag)[] =
|
|
45
|
-
ts.getJSDocCommentsAndTags(node);
|
|
46
|
-
if (elements.length === 0) return undefined;
|
|
47
|
-
|
|
48
|
-
const content: string[] = [];
|
|
49
|
-
for (const comment of elements) {
|
|
50
|
-
if (ts.isJSDoc(comment)) {
|
|
51
|
-
const parsed: string | undefined = ts.getTextOfJSDocComment(
|
|
52
|
-
comment.comment,
|
|
53
|
-
);
|
|
54
|
-
if (parsed?.length) {
|
|
55
|
-
content.push(parsed);
|
|
56
|
-
if (includeTags && comment.tags?.length) content.push("");
|
|
57
|
-
}
|
|
58
|
-
if (includeTags)
|
|
59
|
-
for (const tag of comment.tags ?? [])
|
|
60
|
-
content.push(parseJSDocTag(tag));
|
|
61
|
-
} else if (includeTags) content.push(parseJSDocTag(comment));
|
|
62
|
-
}
|
|
63
|
-
const output: string = content
|
|
64
|
-
.map((line) => line.split("\r\n").join("\n"))
|
|
65
|
-
.join("\n");
|
|
66
|
-
return output.length ? output : undefined;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const merge = (comments: ts.SymbolDisplayPart[]): string =>
|
|
70
|
-
comments
|
|
71
|
-
.map((part) => part.text)
|
|
72
|
-
.map((str) => str.split("\r\n").join("\n"))
|
|
73
|
-
.join("");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const parseJSDocTag = (tag: ts.JSDocTag): string => {
|
|
77
|
-
const name: string | undefined = (
|
|
78
|
-
tag as ts.JSDocParameterTag
|
|
79
|
-
).name?.getText();
|
|
80
|
-
const parsed: string | undefined = ts.getTextOfJSDocComment(tag.comment);
|
|
81
|
-
return [`@${tag.tagName.text}`, name, parsed]
|
|
82
|
-
.filter((str) => !!str?.length)
|
|
83
|
-
.join(" ");
|
|
84
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export namespace CommentFactory {
|
|
4
|
+
export const description = (
|
|
5
|
+
symbol: ts.Symbol,
|
|
6
|
+
includeTags: boolean = false,
|
|
7
|
+
): string | undefined => {
|
|
8
|
+
const node = symbol.declarations?.[0];
|
|
9
|
+
if (!node) return undefined;
|
|
10
|
+
|
|
11
|
+
// FOR LEGACY TS < 5.2
|
|
12
|
+
const [major, minor] = ts.versionMajorMinor.split(".").map(Number) as [
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
];
|
|
16
|
+
if (major < 5 || (major === 5 && minor < 1)) {
|
|
17
|
+
const content: string[] = [];
|
|
18
|
+
const main: string = ts.displayPartsToString(
|
|
19
|
+
symbol.getDocumentationComment(undefined),
|
|
20
|
+
);
|
|
21
|
+
if (main.length) {
|
|
22
|
+
content.push(main);
|
|
23
|
+
if (includeTags && symbol.getJsDocTags().length)
|
|
24
|
+
content.push("");
|
|
25
|
+
}
|
|
26
|
+
if (includeTags)
|
|
27
|
+
for (const tag of symbol.getJsDocTags()) {
|
|
28
|
+
content.push(
|
|
29
|
+
tag.text
|
|
30
|
+
? `@${tag.name} ${ts.displayPartsToString(
|
|
31
|
+
tag.text,
|
|
32
|
+
)}`
|
|
33
|
+
: `@${tag.name}`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return content.length
|
|
37
|
+
? content
|
|
38
|
+
.map((line) => line.split("\r\n").join("\n"))
|
|
39
|
+
.join("\n")
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// NEW FEATURE OF TS 5.2
|
|
44
|
+
const elements: readonly (ts.JSDoc | ts.JSDocTag)[] =
|
|
45
|
+
ts.getJSDocCommentsAndTags(node);
|
|
46
|
+
if (elements.length === 0) return undefined;
|
|
47
|
+
|
|
48
|
+
const content: string[] = [];
|
|
49
|
+
for (const comment of elements) {
|
|
50
|
+
if (ts.isJSDoc(comment)) {
|
|
51
|
+
const parsed: string | undefined = ts.getTextOfJSDocComment(
|
|
52
|
+
comment.comment,
|
|
53
|
+
);
|
|
54
|
+
if (parsed?.length) {
|
|
55
|
+
content.push(parsed);
|
|
56
|
+
if (includeTags && comment.tags?.length) content.push("");
|
|
57
|
+
}
|
|
58
|
+
if (includeTags)
|
|
59
|
+
for (const tag of comment.tags ?? [])
|
|
60
|
+
content.push(parseJSDocTag(tag));
|
|
61
|
+
} else if (includeTags) content.push(parseJSDocTag(comment));
|
|
62
|
+
}
|
|
63
|
+
const output: string = content
|
|
64
|
+
.map((line) => line.split("\r\n").join("\n"))
|
|
65
|
+
.join("\n");
|
|
66
|
+
return output.length ? output : undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const merge = (comments: ts.SymbolDisplayPart[]): string =>
|
|
70
|
+
comments
|
|
71
|
+
.map((part) => part.text)
|
|
72
|
+
.map((str) => str.split("\r\n").join("\n"))
|
|
73
|
+
.join("");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const parseJSDocTag = (tag: ts.JSDocTag): string => {
|
|
77
|
+
const name: string | undefined = (
|
|
78
|
+
tag as ts.JSDocParameterTag
|
|
79
|
+
).name?.getText();
|
|
80
|
+
const parsed: string | undefined = ts.getTextOfJSDocComment(tag.comment);
|
|
81
|
+
return [`@${tag.tagName.text}`, name, parsed]
|
|
82
|
+
.filter((str) => !!str?.length)
|
|
83
|
+
.join(" ");
|
|
84
|
+
};
|