typia 3.6.1 → 3.6.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.
- package/README.md +2 -1
- package/lib/factories/internal/metadata/emplace_metadata_object.js +8 -7
- package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
- package/lib/module.d.ts +2 -2
- package/lib/programmers/AssertCloneProgrammer.js +2 -2
- package/lib/programmers/AssertCloneProgrammer.js.map +1 -1
- package/lib/programmers/AssertParseProgrammer.js +1 -1
- package/lib/programmers/AssertParseProgrammer.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +1 -1
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/AssertPruneProgrammer.js +2 -2
- package/lib/programmers/AssertPruneProgrammer.js.map +1 -1
- package/lib/programmers/AssertStringifyProgrammer.d.ts +1 -1
- package/lib/programmers/AssertStringifyProgrammer.js +3 -3
- package/lib/programmers/AssertStringifyProgrammer.js.map +1 -1
- package/lib/programmers/IsCloneProgrammer.js +2 -2
- package/lib/programmers/IsCloneProgrammer.js.map +1 -1
- package/lib/programmers/IsParseProgrammer.js +1 -1
- package/lib/programmers/IsParseProgrammer.js.map +1 -1
- package/lib/programmers/IsPruneProgrammer.js +2 -2
- package/lib/programmers/IsPruneProgrammer.js.map +1 -1
- package/lib/programmers/IsStringifyProgrammer.js +2 -2
- package/lib/programmers/IsStringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateCloneProgrammer.js +2 -2
- package/lib/programmers/ValidateCloneProgrammer.js.map +1 -1
- package/lib/programmers/ValidateParseProgrammer.js +1 -1
- package/lib/programmers/ValidateParseProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +1 -1
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/ValidatePruneProgrammer.js +2 -2
- package/lib/programmers/ValidatePruneProgrammer.js.map +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.js +2 -2
- package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +1 -2
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +1 -2
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -1
- package/lib/transformers/internal/GenericTransformer.d.ts +0 -1
- package/lib/transformers/internal/GenericTransformer.js +8 -4
- package/lib/transformers/internal/GenericTransformer.js.map +1 -1
- package/package.json +2 -1
- package/src/IRandomGenerator.ts +16 -16
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +104 -104
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/TypiaGenerateWizard.ts +87 -87
- package/src/executable/TypiaSetupWizard.ts +142 -142
- package/src/executable/setup/ArgumentParser.ts +91 -91
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +33 -33
- package/src/executable/setup/PackageManager.ts +92 -92
- package/src/executable/setup/PluginConfigurator.ts +99 -99
- package/src/executable/typia.ts +38 -38
- package/src/factories/CommentFactory.ts +10 -10
- package/src/factories/ExpressionFactory.ts +77 -77
- package/src/factories/IdentifierFactory.ts +73 -73
- package/src/factories/LiteralFactory.ts +44 -44
- package/src/factories/MetadataCollection.ts +122 -122
- package/src/factories/MetadataFactory.ts +51 -51
- package/src/factories/MetadataTagFactory.ts +265 -265
- package/src/factories/StatementFactory.ts +60 -60
- package/src/factories/TemplateFactory.ts +56 -56
- package/src/factories/TypeFactory.ts +129 -129
- package/src/factories/TypiaFileFactory.ts +117 -117
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
- package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -140
- package/src/factories/internal/metadata/explore_metadata.ts +92 -92
- package/src/factories/internal/metadata/iterate_metadata.ts +80 -80
- package/src/factories/internal/metadata/iterate_metadata_array.ts +29 -29
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
- package/src/factories/internal/metadata/iterate_metadata_native.ts +222 -222
- package/src/factories/internal/metadata/iterate_metadata_object.ts +48 -48
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
- package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +45 -45
- package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
- package/src/functional/$any.ts +3 -3
- package/src/functional/$every.ts +11 -11
- package/src/functional/$guard.ts +35 -35
- package/src/functional/$is_between.ts +7 -7
- package/src/functional/$is_email.ts +5 -5
- package/src/functional/$is_ipv4.ts +5 -5
- package/src/functional/$is_ipv6.ts +5 -5
- package/src/functional/$is_url.ts +5 -5
- package/src/functional/$is_uuid.ts +5 -5
- package/src/functional/$join.ts +50 -50
- package/src/functional/$number.ts +12 -12
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +37 -37
- package/src/functional/$tail.ts +6 -6
- package/src/functional/Namespace.ts +121 -121
- package/src/index.ts +4 -4
- package/src/metadata/IJsDocTagInfo.ts +10 -10
- package/src/metadata/IMetadata.ts +25 -25
- package/src/metadata/IMetadataApplication.ts +7 -7
- package/src/metadata/IMetadataConstant.ts +16 -16
- package/src/metadata/IMetadataEntry.ts +6 -6
- package/src/metadata/IMetadataObject.ts +29 -29
- package/src/metadata/IMetadataProperty.ts +11 -11
- package/src/metadata/IMetadataTag.ts +113 -113
- package/src/metadata/Metadata.ts +534 -534
- package/src/metadata/MetadataConstant.ts +3 -3
- package/src/metadata/MetadataObject.ts +131 -131
- package/src/metadata/MetadataProperty.ts +64 -64
- package/src/module.ts +1946 -1946
- package/src/programmers/ApplicationProgrammer.ts +55 -55
- package/src/programmers/AssertCloneProgrammer.ts +70 -70
- package/src/programmers/AssertParseProgrammer.ts +65 -65
- package/src/programmers/AssertProgrammer.ts +232 -232
- package/src/programmers/AssertPruneProgrammer.ts +67 -67
- package/src/programmers/AssertStringifyProgrammer.ts +71 -71
- package/src/programmers/CheckerProgrammer.ts +893 -893
- package/src/programmers/CloneProgrammer.ts +386 -386
- package/src/programmers/FeatureProgrammer.ts +505 -505
- package/src/programmers/IsCloneProgrammer.ts +80 -80
- package/src/programmers/IsParseProgrammer.ts +74 -74
- package/src/programmers/IsProgrammer.ts +200 -200
- package/src/programmers/IsPruneProgrammer.ts +75 -75
- package/src/programmers/IsStringifyProgrammer.ts +81 -81
- package/src/programmers/PruneProgrammer.ts +341 -341
- package/src/programmers/RandomProgrammer.ts +391 -391
- package/src/programmers/StringifyProgrammer.ts +795 -795
- package/src/programmers/ValidateCloneProgrammer.ts +90 -90
- package/src/programmers/ValidateParseProgrammer.ts +69 -69
- package/src/programmers/ValidateProgrammer.ts +266 -266
- package/src/programmers/ValidatePruneProgrammer.ts +83 -83
- package/src/programmers/ValidateStringifyProgrammer.ts +89 -89
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/CloneJoiner.ts +134 -134
- package/src/programmers/helpers/FunctionImporeter.ts +55 -55
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/OptionPredicator.ts +19 -19
- package/src/programmers/helpers/PruneJoiner.ts +52 -52
- package/src/programmers/helpers/RandomJoiner.ts +149 -149
- package/src/programmers/helpers/RandomRanger.ts +216 -216
- package/src/programmers/helpers/StringifyJoinder.ts +114 -114
- package/src/programmers/helpers/StringifyPredicator.ts +18 -18
- package/src/programmers/helpers/UnionExplorer.ts +274 -274
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/internal/application_array.ts +37 -37
- package/src/programmers/internal/application_boolean.ts +17 -17
- package/src/programmers/internal/application_constant.ts +29 -29
- package/src/programmers/internal/application_default.ts +17 -17
- package/src/programmers/internal/application_default_string.ts +32 -32
- package/src/programmers/internal/application_native.ts +29 -29
- package/src/programmers/internal/application_number.ts +70 -70
- package/src/programmers/internal/application_object.ts +153 -153
- package/src/programmers/internal/application_schema.ts +184 -184
- package/src/programmers/internal/application_string.ts +41 -41
- package/src/programmers/internal/application_templates.ts +27 -27
- package/src/programmers/internal/application_tuple.ts +29 -29
- package/src/programmers/internal/check_array.ts +22 -22
- package/src/programmers/internal/check_array_length.ts +44 -44
- package/src/programmers/internal/check_bigint.ts +64 -64
- package/src/programmers/internal/check_dynamic_properties.ts +197 -197
- 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 +145 -145
- package/src/programmers/internal/check_object.ts +48 -48
- package/src/programmers/internal/check_string.ts +24 -24
- package/src/programmers/internal/check_string_tags.ts +63 -63
- package/src/programmers/internal/check_template.ts +50 -50
- package/src/programmers/internal/check_union_array_like.ts +260 -260
- package/src/programmers/internal/check_union_tuple.ts +33 -33
- package/src/programmers/internal/decode_union_object.ts +73 -73
- package/src/programmers/internal/feature_object_entries.ts +59 -59
- package/src/programmers/internal/metadata_to_pattern.ts +31 -31
- package/src/programmers/internal/prune_object_properties.ts +60 -60
- package/src/programmers/internal/stringify_dynamic_properties.ts +165 -165
- package/src/programmers/internal/stringify_native.ts +8 -8
- package/src/programmers/internal/stringify_regular_properties.ts +81 -81
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/schemas/IJsonApplication.ts +9 -9
- package/src/schemas/IJsonComponents.ts +26 -26
- package/src/schemas/IJsonSchema.ts +127 -127
- package/src/transform.ts +21 -21
- package/src/transformers/CallExpressionTransformer.ts +172 -172
- package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
- package/src/transformers/FileTransformer.ts +49 -49
- package/src/transformers/IProject.ts +11 -11
- package/src/transformers/ITransformOptions.ts +62 -62
- package/src/transformers/ImportTransformer.ts +60 -60
- package/src/transformers/NodeTransformer.ts +19 -19
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +120 -120
- package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +42 -43
- package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
- package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +48 -49
- package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +11 -11
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/validators/AssertTransformer.ts +11 -11
- package/src/transformers/features/validators/CreateAssertTransformer.ts +12 -12
- package/src/transformers/features/validators/CreateIsTransformer.ts +10 -10
- package/src/transformers/features/validators/CreateValidateTransformer.ts +12 -12
- package/src/transformers/features/validators/IsTransformer.ts +10 -10
- package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
- package/src/transformers/internal/GenericTransformer.ts +99 -98
- package/src/typings/Atomic.ts +17 -17
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +49 -49
- package/src/utils/Escaper.ts +50 -50
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PatternUtil.ts +30 -30
- package/src/utils/RandomGenerator.ts +90 -90
- package/src/utils/Singleton.ts +17 -17
|
@@ -1,92 +1,92 @@
|
|
|
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 Error(`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
|
-
silent?: boolean;
|
|
41
|
-
modulo: string;
|
|
42
|
-
version?: string;
|
|
43
|
-
}): boolean {
|
|
44
|
-
const container = props.dev
|
|
45
|
-
? this.data.devDependencies
|
|
46
|
-
: this.data.dependencies;
|
|
47
|
-
if (
|
|
48
|
-
!!container?.[props.modulo] &&
|
|
49
|
-
FileRetriever.file(path.join("node_modules", props.modulo))(
|
|
50
|
-
this.directory,
|
|
51
|
-
) !== null
|
|
52
|
-
)
|
|
53
|
-
return false;
|
|
54
|
-
|
|
55
|
-
const middle: string =
|
|
56
|
-
this.manager === "yarn"
|
|
57
|
-
? `add${props.dev ? " -D" : ""}`
|
|
58
|
-
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
59
|
-
CommandExecutor.run(
|
|
60
|
-
`${this.manager} ${middle} ${props.modulo}${
|
|
61
|
-
props.version ? `@${props.version}` : ""
|
|
62
|
-
}`,
|
|
63
|
-
!!props.silent,
|
|
64
|
-
);
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public erase(props: { modulo: string; silent?: boolean }): void {
|
|
69
|
-
const middle: string = this.manager === "yarn" ? "remove" : "uninstall";
|
|
70
|
-
CommandExecutor.run(
|
|
71
|
-
`${this.manager} ${middle} ${props.modulo}`,
|
|
72
|
-
!!props.silent,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private constructor(
|
|
77
|
-
public readonly directory: string,
|
|
78
|
-
public data: Package.Data,
|
|
79
|
-
) {}
|
|
80
|
-
|
|
81
|
-
private static async load(file: string): Promise<Package.Data> {
|
|
82
|
-
const content: string = await fs.promises.readFile(file, "utf8");
|
|
83
|
-
return JSON.parse(content);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
export namespace Package {
|
|
87
|
-
export interface Data {
|
|
88
|
-
scripts?: Record<string, string>;
|
|
89
|
-
dependencies?: Record<string, string>;
|
|
90
|
-
devDependencies?: Record<string, string>;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
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 Error(`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
|
+
silent?: boolean;
|
|
41
|
+
modulo: string;
|
|
42
|
+
version?: string;
|
|
43
|
+
}): boolean {
|
|
44
|
+
const container = props.dev
|
|
45
|
+
? this.data.devDependencies
|
|
46
|
+
: this.data.dependencies;
|
|
47
|
+
if (
|
|
48
|
+
!!container?.[props.modulo] &&
|
|
49
|
+
FileRetriever.file(path.join("node_modules", props.modulo))(
|
|
50
|
+
this.directory,
|
|
51
|
+
) !== null
|
|
52
|
+
)
|
|
53
|
+
return false;
|
|
54
|
+
|
|
55
|
+
const middle: string =
|
|
56
|
+
this.manager === "yarn"
|
|
57
|
+
? `add${props.dev ? " -D" : ""}`
|
|
58
|
+
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
59
|
+
CommandExecutor.run(
|
|
60
|
+
`${this.manager} ${middle} ${props.modulo}${
|
|
61
|
+
props.version ? `@${props.version}` : ""
|
|
62
|
+
}`,
|
|
63
|
+
!!props.silent,
|
|
64
|
+
);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public erase(props: { modulo: string; silent?: boolean }): void {
|
|
69
|
+
const middle: string = this.manager === "yarn" ? "remove" : "uninstall";
|
|
70
|
+
CommandExecutor.run(
|
|
71
|
+
`${this.manager} ${middle} ${props.modulo}`,
|
|
72
|
+
!!props.silent,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private constructor(
|
|
77
|
+
public readonly directory: string,
|
|
78
|
+
public data: Package.Data,
|
|
79
|
+
) {}
|
|
80
|
+
|
|
81
|
+
private static async load(file: string): Promise<Package.Data> {
|
|
82
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
83
|
+
return JSON.parse(content);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export namespace Package {
|
|
87
|
+
export interface Data {
|
|
88
|
+
scripts?: Record<string, string>;
|
|
89
|
+
dependencies?: Record<string, string>;
|
|
90
|
+
devDependencies?: Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import type Comment from "comment-json";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
6
|
-
import { FileRetriever } from "./FileRetriever";
|
|
7
|
-
import { PackageManager } from "./PackageManager";
|
|
8
|
-
|
|
9
|
-
export namespace PluginConfigurator {
|
|
10
|
-
export async function configure(
|
|
11
|
-
pack: PackageManager,
|
|
12
|
-
args: TypiaSetupWizard.IArguments,
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
// INSTALL COMMENT-JSON
|
|
15
|
-
const installed: boolean = pack.install({
|
|
16
|
-
dev: true,
|
|
17
|
-
modulo: "comment-json",
|
|
18
|
-
version: "4.2.3",
|
|
19
|
-
silent: true,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// DO CONFIGURE
|
|
23
|
-
const error: Error | null = await (async () => {
|
|
24
|
-
try {
|
|
25
|
-
await _Configure(pack, args);
|
|
26
|
-
return null;
|
|
27
|
-
} catch (exp) {
|
|
28
|
-
return exp as Error;
|
|
29
|
-
}
|
|
30
|
-
})();
|
|
31
|
-
|
|
32
|
-
// REMOVE IT
|
|
33
|
-
if (installed)
|
|
34
|
-
pack.erase({
|
|
35
|
-
modulo: "comment-json",
|
|
36
|
-
silent: true,
|
|
37
|
-
});
|
|
38
|
-
if (error !== null) throw error;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function _Configure(
|
|
42
|
-
pack: PackageManager,
|
|
43
|
-
args: TypiaSetupWizard.IArguments,
|
|
44
|
-
): Promise<void> {
|
|
45
|
-
// GET COMPILER-OPTIONS
|
|
46
|
-
const Comment: typeof import("comment-json") =
|
|
47
|
-
await FileRetriever.require(
|
|
48
|
-
path.join("node_modules", "comment-json"),
|
|
49
|
-
)(pack.directory);
|
|
50
|
-
|
|
51
|
-
const config: Comment.CommentObject = Comment.parse(
|
|
52
|
-
await fs.promises.readFile(args.project!, "utf8"),
|
|
53
|
-
) as Comment.CommentObject;
|
|
54
|
-
const compilerOptions = config.compilerOptions as
|
|
55
|
-
| Comment.CommentObject
|
|
56
|
-
| undefined;
|
|
57
|
-
if (compilerOptions === undefined)
|
|
58
|
-
throw new Error(
|
|
59
|
-
`${args.project} file does not have "compilerOptions" property.`,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// PREPARE PLUGINS
|
|
63
|
-
const plugins: Comment.CommentArray<Comment.CommentObject> = (() => {
|
|
64
|
-
const plugins = compilerOptions.plugins as
|
|
65
|
-
| Comment.CommentArray<Comment.CommentObject>
|
|
66
|
-
| undefined;
|
|
67
|
-
if (plugins === undefined)
|
|
68
|
-
return (compilerOptions.plugins = [] as any);
|
|
69
|
-
else if (!Array.isArray(plugins))
|
|
70
|
-
throw new Error(
|
|
71
|
-
`"plugins" property of ${args.project} must be array type.`,
|
|
72
|
-
);
|
|
73
|
-
return plugins;
|
|
74
|
-
})();
|
|
75
|
-
|
|
76
|
-
const strict: boolean = compilerOptions.strict === true;
|
|
77
|
-
const oldbie: Comment.CommentObject | undefined = plugins.find(
|
|
78
|
-
(p) =>
|
|
79
|
-
typeof p === "object" &&
|
|
80
|
-
p !== null &&
|
|
81
|
-
p.transform === "typia/lib/transform",
|
|
82
|
-
);
|
|
83
|
-
if (strict === true && oldbie !== undefined) return;
|
|
84
|
-
|
|
85
|
-
// DO CONFIGURE
|
|
86
|
-
compilerOptions.strict = true;
|
|
87
|
-
if (oldbie === undefined)
|
|
88
|
-
plugins.push(
|
|
89
|
-
Comment.parse(`
|
|
90
|
-
{
|
|
91
|
-
"transform": "typia/lib/transform"
|
|
92
|
-
}`) as Comment.CommentObject,
|
|
93
|
-
);
|
|
94
|
-
await fs.promises.writeFile(
|
|
95
|
-
args.project!,
|
|
96
|
-
Comment.stringify(config, null, 2),
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
import type Comment from "comment-json";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
6
|
+
import { FileRetriever } from "./FileRetriever";
|
|
7
|
+
import { PackageManager } from "./PackageManager";
|
|
8
|
+
|
|
9
|
+
export namespace PluginConfigurator {
|
|
10
|
+
export async function configure(
|
|
11
|
+
pack: PackageManager,
|
|
12
|
+
args: TypiaSetupWizard.IArguments,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
// INSTALL COMMENT-JSON
|
|
15
|
+
const installed: boolean = pack.install({
|
|
16
|
+
dev: true,
|
|
17
|
+
modulo: "comment-json",
|
|
18
|
+
version: "4.2.3",
|
|
19
|
+
silent: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// DO CONFIGURE
|
|
23
|
+
const error: Error | null = await (async () => {
|
|
24
|
+
try {
|
|
25
|
+
await _Configure(pack, args);
|
|
26
|
+
return null;
|
|
27
|
+
} catch (exp) {
|
|
28
|
+
return exp as Error;
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
|
+
// REMOVE IT
|
|
33
|
+
if (installed)
|
|
34
|
+
pack.erase({
|
|
35
|
+
modulo: "comment-json",
|
|
36
|
+
silent: true,
|
|
37
|
+
});
|
|
38
|
+
if (error !== null) throw error;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function _Configure(
|
|
42
|
+
pack: PackageManager,
|
|
43
|
+
args: TypiaSetupWizard.IArguments,
|
|
44
|
+
): Promise<void> {
|
|
45
|
+
// GET COMPILER-OPTIONS
|
|
46
|
+
const Comment: typeof import("comment-json") =
|
|
47
|
+
await FileRetriever.require(
|
|
48
|
+
path.join("node_modules", "comment-json"),
|
|
49
|
+
)(pack.directory);
|
|
50
|
+
|
|
51
|
+
const config: Comment.CommentObject = Comment.parse(
|
|
52
|
+
await fs.promises.readFile(args.project!, "utf8"),
|
|
53
|
+
) as Comment.CommentObject;
|
|
54
|
+
const compilerOptions = config.compilerOptions as
|
|
55
|
+
| Comment.CommentObject
|
|
56
|
+
| undefined;
|
|
57
|
+
if (compilerOptions === undefined)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`${args.project} file does not have "compilerOptions" property.`,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// PREPARE PLUGINS
|
|
63
|
+
const plugins: Comment.CommentArray<Comment.CommentObject> = (() => {
|
|
64
|
+
const plugins = compilerOptions.plugins as
|
|
65
|
+
| Comment.CommentArray<Comment.CommentObject>
|
|
66
|
+
| undefined;
|
|
67
|
+
if (plugins === undefined)
|
|
68
|
+
return (compilerOptions.plugins = [] as any);
|
|
69
|
+
else if (!Array.isArray(plugins))
|
|
70
|
+
throw new Error(
|
|
71
|
+
`"plugins" property of ${args.project} must be array type.`,
|
|
72
|
+
);
|
|
73
|
+
return plugins;
|
|
74
|
+
})();
|
|
75
|
+
|
|
76
|
+
const strict: boolean = compilerOptions.strict === true;
|
|
77
|
+
const oldbie: Comment.CommentObject | undefined = plugins.find(
|
|
78
|
+
(p) =>
|
|
79
|
+
typeof p === "object" &&
|
|
80
|
+
p !== null &&
|
|
81
|
+
p.transform === "typia/lib/transform",
|
|
82
|
+
);
|
|
83
|
+
if (strict === true && oldbie !== undefined) return;
|
|
84
|
+
|
|
85
|
+
// DO CONFIGURE
|
|
86
|
+
compilerOptions.strict = true;
|
|
87
|
+
if (oldbie === undefined)
|
|
88
|
+
plugins.push(
|
|
89
|
+
Comment.parse(`
|
|
90
|
+
{
|
|
91
|
+
"transform": "typia/lib/transform"
|
|
92
|
+
}`) as Comment.CommentObject,
|
|
93
|
+
);
|
|
94
|
+
await fs.promises.writeFile(
|
|
95
|
+
args.project!,
|
|
96
|
+
Comment.stringify(config, null, 2),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/executable/typia.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { TypiaGenerateWizard } from "./TypiaGenerateWizard";
|
|
3
|
-
import { TypiaSetupWizard } from "./TypiaSetupWizard";
|
|
4
|
-
|
|
5
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
6
|
-
|
|
7
|
-
npx typia setup \\
|
|
8
|
-
--compiler (ttypescript|ts-patch) \\
|
|
9
|
-
--manager (npm|pnpm|yarn) \\
|
|
10
|
-
--project {tsconfig.json file path}
|
|
11
|
-
|
|
12
|
-
- npx typia setup
|
|
13
|
-
- npx typia setup --compiler ts-patch
|
|
14
|
-
- npx typia setup --manager pnpm
|
|
15
|
-
- npx typia setup --project tsconfig.test.json
|
|
16
|
-
|
|
17
|
-
npx typia generate
|
|
18
|
-
--input {directory} \\
|
|
19
|
-
--output {directory}
|
|
20
|
-
|
|
21
|
-
--npx typia generate --input src/templates --output src/functinoal
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
function halt(desc: string): never {
|
|
25
|
-
console.error(desc);
|
|
26
|
-
process.exit(-1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function main(): Promise<void> {
|
|
30
|
-
const type: string | undefined = process.argv[2];
|
|
31
|
-
if (type === "setup") await TypiaSetupWizard.setup();
|
|
32
|
-
else if (type === "generate") await TypiaGenerateWizard.generate();
|
|
33
|
-
else halt(USAGE);
|
|
34
|
-
}
|
|
35
|
-
main().catch((exp) => {
|
|
36
|
-
console.error(exp);
|
|
37
|
-
process.exit(-1);
|
|
38
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { TypiaGenerateWizard } from "./TypiaGenerateWizard";
|
|
3
|
+
import { TypiaSetupWizard } from "./TypiaSetupWizard";
|
|
4
|
+
|
|
5
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
6
|
+
|
|
7
|
+
npx typia setup \\
|
|
8
|
+
--compiler (ttypescript|ts-patch) \\
|
|
9
|
+
--manager (npm|pnpm|yarn) \\
|
|
10
|
+
--project {tsconfig.json file path}
|
|
11
|
+
|
|
12
|
+
- npx typia setup
|
|
13
|
+
- npx typia setup --compiler ts-patch
|
|
14
|
+
- npx typia setup --manager pnpm
|
|
15
|
+
- npx typia setup --project tsconfig.test.json
|
|
16
|
+
|
|
17
|
+
npx typia generate
|
|
18
|
+
--input {directory} \\
|
|
19
|
+
--output {directory}
|
|
20
|
+
|
|
21
|
+
--npx typia generate --input src/templates --output src/functinoal
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
function halt(desc: string): never {
|
|
25
|
+
console.error(desc);
|
|
26
|
+
process.exit(-1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function main(): Promise<void> {
|
|
30
|
+
const type: string | undefined = process.argv[2];
|
|
31
|
+
if (type === "setup") await TypiaSetupWizard.setup();
|
|
32
|
+
else if (type === "generate") await TypiaGenerateWizard.generate();
|
|
33
|
+
else halt(USAGE);
|
|
34
|
+
}
|
|
35
|
+
main().catch((exp) => {
|
|
36
|
+
console.error(exp);
|
|
37
|
+
process.exit(-1);
|
|
38
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export namespace CommentFactory {
|
|
4
|
-
export function generate(comments: ts.SymbolDisplayPart[]): string {
|
|
5
|
-
return comments
|
|
6
|
-
.map((part) => part.text)
|
|
7
|
-
.map((str) => str.split("\r\n").join("\n"))
|
|
8
|
-
.join("");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export namespace CommentFactory {
|
|
4
|
+
export function generate(comments: ts.SymbolDisplayPart[]): string {
|
|
5
|
+
return comments
|
|
6
|
+
.map((part) => part.text)
|
|
7
|
+
.map((str) => str.split("\r\n").join("\n"))
|
|
8
|
+
.join("");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export namespace ExpressionFactory {
|
|
4
|
-
export function isRequired(input: ts.Expression): ts.Expression {
|
|
5
|
-
return ts.factory.createStrictInequality(
|
|
6
|
-
ts.factory.createIdentifier("undefined"),
|
|
7
|
-
input,
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function isArray(input: ts.Expression): ts.Expression {
|
|
12
|
-
return ts.factory.createCallExpression(
|
|
13
|
-
ts.factory.createIdentifier("Array.isArray"),
|
|
14
|
-
undefined,
|
|
15
|
-
[input],
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function isObject(
|
|
20
|
-
input: ts.Expression,
|
|
21
|
-
options: {
|
|
22
|
-
checkNull: boolean;
|
|
23
|
-
checkArray: boolean;
|
|
24
|
-
},
|
|
25
|
-
): ts.Expression {
|
|
26
|
-
const conditions: ts.Expression[] = [
|
|
27
|
-
ts.factory.createStrictEquality(
|
|
28
|
-
ts.factory.createStringLiteral("object"),
|
|
29
|
-
ts.factory.createTypeOfExpression(input),
|
|
30
|
-
),
|
|
31
|
-
];
|
|
32
|
-
if (options.checkNull === true)
|
|
33
|
-
conditions.push(
|
|
34
|
-
ts.factory.createStrictInequality(
|
|
35
|
-
ts.factory.createNull(),
|
|
36
|
-
input,
|
|
37
|
-
),
|
|
38
|
-
);
|
|
39
|
-
if (options.checkArray === true)
|
|
40
|
-
conditions.push(
|
|
41
|
-
ts.factory.createStrictEquality(
|
|
42
|
-
ts.factory.createFalse(),
|
|
43
|
-
ts.factory.createCallExpression(
|
|
44
|
-
ts.factory.createIdentifier("Array.isArray"),
|
|
45
|
-
undefined,
|
|
46
|
-
[input],
|
|
47
|
-
),
|
|
48
|
-
),
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
return conditions.length === 1
|
|
52
|
-
? conditions[0]!
|
|
53
|
-
: conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function isInstanceOf(
|
|
57
|
-
input: ts.Expression,
|
|
58
|
-
type: string,
|
|
59
|
-
): ts.Expression {
|
|
60
|
-
return ts.factory.createBinaryExpression(
|
|
61
|
-
input,
|
|
62
|
-
ts.factory.createToken(ts.SyntaxKind.InstanceOfKeyword),
|
|
63
|
-
ts.factory.createIdentifier(type),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function coalesce(
|
|
68
|
-
x: ts.Expression,
|
|
69
|
-
y: ts.Expression,
|
|
70
|
-
): ts.Expression {
|
|
71
|
-
return ts.factory.createBinaryExpression(
|
|
72
|
-
x,
|
|
73
|
-
ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
|
|
74
|
-
y,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export namespace ExpressionFactory {
|
|
4
|
+
export function isRequired(input: ts.Expression): ts.Expression {
|
|
5
|
+
return ts.factory.createStrictInequality(
|
|
6
|
+
ts.factory.createIdentifier("undefined"),
|
|
7
|
+
input,
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isArray(input: ts.Expression): ts.Expression {
|
|
12
|
+
return ts.factory.createCallExpression(
|
|
13
|
+
ts.factory.createIdentifier("Array.isArray"),
|
|
14
|
+
undefined,
|
|
15
|
+
[input],
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isObject(
|
|
20
|
+
input: ts.Expression,
|
|
21
|
+
options: {
|
|
22
|
+
checkNull: boolean;
|
|
23
|
+
checkArray: boolean;
|
|
24
|
+
},
|
|
25
|
+
): ts.Expression {
|
|
26
|
+
const conditions: ts.Expression[] = [
|
|
27
|
+
ts.factory.createStrictEquality(
|
|
28
|
+
ts.factory.createStringLiteral("object"),
|
|
29
|
+
ts.factory.createTypeOfExpression(input),
|
|
30
|
+
),
|
|
31
|
+
];
|
|
32
|
+
if (options.checkNull === true)
|
|
33
|
+
conditions.push(
|
|
34
|
+
ts.factory.createStrictInequality(
|
|
35
|
+
ts.factory.createNull(),
|
|
36
|
+
input,
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
if (options.checkArray === true)
|
|
40
|
+
conditions.push(
|
|
41
|
+
ts.factory.createStrictEquality(
|
|
42
|
+
ts.factory.createFalse(),
|
|
43
|
+
ts.factory.createCallExpression(
|
|
44
|
+
ts.factory.createIdentifier("Array.isArray"),
|
|
45
|
+
undefined,
|
|
46
|
+
[input],
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return conditions.length === 1
|
|
52
|
+
? conditions[0]!
|
|
53
|
+
: conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function isInstanceOf(
|
|
57
|
+
input: ts.Expression,
|
|
58
|
+
type: string,
|
|
59
|
+
): ts.Expression {
|
|
60
|
+
return ts.factory.createBinaryExpression(
|
|
61
|
+
input,
|
|
62
|
+
ts.factory.createToken(ts.SyntaxKind.InstanceOfKeyword),
|
|
63
|
+
ts.factory.createIdentifier(type),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function coalesce(
|
|
68
|
+
x: ts.Expression,
|
|
69
|
+
y: ts.Expression,
|
|
70
|
+
): ts.Expression {
|
|
71
|
+
return ts.factory.createBinaryExpression(
|
|
72
|
+
x,
|
|
73
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
|
|
74
|
+
y,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|