typia 7.6.0-dev.20241229 → 7.7.0-dev.20250130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/lib/TypeGuardError.mjs +26 -0
  2. package/lib/TypeGuardError.mjs.map +1 -0
  3. package/lib/executable/setup/PluginConfigurator.js +3 -3
  4. package/lib/executable/typia.js +15 -15
  5. package/lib/functional.mjs +120 -0
  6. package/lib/functional.mjs.map +1 -0
  7. package/lib/http.d.ts +15 -15
  8. package/lib/http.mjs +165 -0
  9. package/lib/http.mjs.map +1 -0
  10. package/lib/index.mjs +27 -1142
  11. package/lib/index.mjs.map +1 -1
  12. package/lib/json.mjs +105 -0
  13. package/lib/json.mjs.map +1 -0
  14. package/lib/llm.mjs +33 -0
  15. package/lib/llm.mjs.map +1 -0
  16. package/lib/misc.mjs +111 -0
  17. package/lib/misc.mjs.map +1 -0
  18. package/lib/module.d.ts +4 -4
  19. package/lib/module.mjs +139 -0
  20. package/lib/module.mjs.map +1 -0
  21. package/lib/notations.mjs +153 -0
  22. package/lib/notations.mjs.map +1 -0
  23. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +12 -0
  24. package/lib/programmers/json/JsonApplicationProgrammer.js +22 -22
  25. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  26. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js +15 -7
  27. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js.map +1 -1
  28. package/lib/programmers/llm/LlmApplicationProgrammer.js +39 -15
  29. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  30. package/lib/protobuf.d.ts +9 -9
  31. package/lib/protobuf.mjs +111 -0
  32. package/lib/protobuf.mjs.map +1 -0
  33. package/lib/reflect.mjs +18 -0
  34. package/lib/reflect.mjs.map +1 -0
  35. package/lib/schemas/llm/ILlmApplicationOfValidate.mjs +6 -0
  36. package/lib/schemas/llm/ILlmApplicationOfValidate.mjs.map +1 -0
  37. package/lib/schemas/llm/ILlmFunctionOfValidate.mjs +6 -0
  38. package/lib/schemas/llm/ILlmFunctionOfValidate.mjs.map +1 -0
  39. package/lib/tags/TagBase.d.ts +1 -1
  40. package/lib/tags/Type.d.ts +0 -1
  41. package/lib/tags/index.mjs +2 -0
  42. package/lib/tags/index.mjs.map +1 -0
  43. package/package.json +10 -8
  44. package/src/AssertionGuard.ts +1 -1
  45. package/src/CamelCase.ts +75 -75
  46. package/src/PascalCase.ts +71 -71
  47. package/src/Primitive.ts +92 -92
  48. package/src/Resolved.ts +74 -74
  49. package/src/SnakeCase.ts +126 -126
  50. package/src/TypeGuardError.ts +37 -37
  51. package/src/executable/setup/CommandExecutor.ts +8 -8
  52. package/src/executable/setup/PluginConfigurator.ts +69 -69
  53. package/src/executable/typia.ts +55 -55
  54. package/src/factories/CommentFactory.ts +79 -79
  55. package/src/factories/ValueFactory.ts +12 -12
  56. package/src/factories/internal/metadata/emend_metadata_atomics.ts +45 -45
  57. package/src/http.ts +15 -15
  58. package/src/index.ts +4 -4
  59. package/src/module.ts +4 -4
  60. package/src/programmers/helpers/ICheckEntry.ts +13 -13
  61. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  62. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  63. package/src/programmers/internal/stringify_native.ts +7 -7
  64. package/src/programmers/json/JsonApplicationProgrammer.ts +27 -27
  65. package/src/programmers/llm/LlmApplicationOfValidateProgrammer.ts +16 -2
  66. package/src/programmers/llm/LlmApplicationProgrammer.ts +50 -12
  67. package/src/protobuf.ts +9 -9
  68. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  69. package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
  70. package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
  71. package/src/schemas/metadata/IMetadataConstant.ts +18 -18
  72. package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
  73. package/src/schemas/metadata/IMetadataFunction.ts +8 -8
  74. package/src/schemas/metadata/IMetadataParameter.ts +9 -9
  75. package/src/schemas/metadata/IMetadataProperty.ts +9 -9
  76. package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
  77. package/src/schemas/metadata/MetadataArrayType.ts +57 -57
  78. package/src/schemas/metadata/MetadataConstant.ts +34 -34
  79. package/src/schemas/metadata/MetadataEscaped.ts +51 -51
  80. package/src/schemas/metadata/MetadataFunction.ts +49 -49
  81. package/src/schemas/metadata/MetadataTupleType.ts +67 -67
  82. package/src/tags/Constant.ts +15 -15
  83. package/src/tags/ContentMediaType.ts +10 -10
  84. package/src/tags/Default.ts +22 -22
  85. package/src/tags/ExclusiveMaximum.ts +25 -25
  86. package/src/tags/ExclusiveMinimum.ts +25 -25
  87. package/src/tags/MaxItems.ts +12 -12
  88. package/src/tags/MaxLength.ts +12 -12
  89. package/src/tags/Maximum.ts +19 -19
  90. package/src/tags/MinItems.ts +12 -12
  91. package/src/tags/MinLength.ts +12 -12
  92. package/src/tags/Minimum.ts +19 -19
  93. package/src/tags/MultipleOf.ts +21 -21
  94. package/src/tags/Pattern.ts +31 -31
  95. package/src/tags/TagBase.ts +1 -1
  96. package/src/tags/Type.ts +0 -1
  97. package/src/tags/internal/FormatCheatSheet.ts +73 -73
  98. package/src/typings/Atomic.ts +13 -13
  99. package/src/typings/ClassProperties.ts +5 -5
  100. package/src/typings/Customizable.ts +5 -5
  101. package/src/typings/Equal.ts +18 -18
  102. package/src/typings/IsTuple.ts +9 -9
  103. package/src/typings/NativeClass.ts +23 -23
  104. package/src/typings/OmitNever.ts +3 -3
  105. package/src/typings/ProtobufAtomic.ts +19 -19
  106. package/src/typings/SpecialFields.ts +3 -3
  107. package/src/typings/ValidationPipe.ts +9 -9
  108. package/src/typings/ValueOf.ts +20 -20
  109. package/src/typings/Writable.ts +11 -11
  110. package/src/utils/ArrayUtil.ts +41 -41
  111. package/src/utils/Escaper.ts +50 -50
  112. package/src/utils/PatternUtil.ts +29 -29
  113. package/src/utils/Singleton.ts +16 -16
package/src/SnakeCase.ts CHANGED
@@ -1,126 +1,126 @@
1
- import { Equal } from "./typings/Equal";
2
- import { NativeClass } from "./typings/NativeClass";
3
- import { ValueOf } from "./typings/ValueOf";
4
-
5
- /**
6
- * Snake case type.
7
- *
8
- * `SnakeCase` type is a type that all keys of an object are converted to snake case.
9
- *
10
- * It also erase every method properties like {@link Resolved} type.
11
- *
12
- * @template T Target type to be snake cased
13
- * @author Jeongho Nam - https://github.com/samchon
14
- */
15
- export type SnakeCase<T> =
16
- Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
17
-
18
- /* -----------------------------------------------------------
19
- OBJECT CONVERSION
20
- ----------------------------------------------------------- */
21
-
22
- type SnakageMain<T> = T extends [never]
23
- ? never // special trick for (jsonable | null) type
24
- : T extends { valueOf(): boolean | bigint | number | string }
25
- ? ValueOf<T>
26
- : T extends Function
27
- ? never
28
- : T extends object
29
- ? SnakageObject<T>
30
- : T;
31
-
32
- type SnakageObject<T extends object> =
33
- T extends Array<infer U>
34
- ? IsTuple<T> extends true
35
- ? SnakageTuple<T>
36
- : SnakageMain<U>[]
37
- : T extends Set<infer U>
38
- ? Set<SnakageMain<U>>
39
- : T extends Map<infer K, infer V>
40
- ? Map<SnakageMain<K>, SnakageMain<V>>
41
- : T extends WeakSet<any> | WeakMap<any, any>
42
- ? never
43
- : T extends NativeClass
44
- ? T
45
- : {
46
- [Key in keyof T as SnakageString<Key & string>]: SnakageMain<
47
- T[Key]
48
- >;
49
- };
50
-
51
- /* -----------------------------------------------------------
52
- SPECIAL CASES
53
- ----------------------------------------------------------- */
54
- type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
55
- never,
56
- ]
57
- ? false
58
- : T extends readonly any[]
59
- ? number extends T["length"]
60
- ? false
61
- : true
62
- : false;
63
- type SnakageTuple<T extends readonly any[]> = T extends []
64
- ? []
65
- : T extends [infer F]
66
- ? [SnakageMain<F>]
67
- : T extends [infer F, ...infer Rest extends readonly any[]]
68
- ? [SnakageMain<F>, ...SnakageTuple<Rest>]
69
- : T extends [(infer F)?]
70
- ? [SnakageMain<F>?]
71
- : T extends [(infer F)?, ...infer Rest extends readonly any[]]
72
- ? [SnakageMain<F>?, ...SnakageTuple<Rest>]
73
- : [];
74
-
75
- /* -----------------------------------------------------------
76
- STRING CONVERTER
77
- ----------------------------------------------------------- */
78
- type SnakageString<Key extends string> = Key extends `${infer _}`
79
- ? SnakageStringRepeatedly<Key, "">
80
- : Key;
81
- type SnakageStringRepeatedly<
82
- S extends string,
83
- Previous extends string,
84
- > = S extends `${infer First}${infer Second}${infer Rest}`
85
- ? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
86
- First,
87
- Second
88
- >}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
89
- : S extends `${infer First}`
90
- ? `${Underscore<Previous, First>}${Lowercase<First>}`
91
- : "";
92
- type Underscore<First extends string, Second extends string> = First extends
93
- | UpperAlphabetic
94
- | ""
95
- | "_"
96
- ? ""
97
- : Second extends UpperAlphabetic
98
- ? "_"
99
- : "";
100
- type UpperAlphabetic =
101
- | "A"
102
- | "B"
103
- | "C"
104
- | "D"
105
- | "E"
106
- | "F"
107
- | "G"
108
- | "H"
109
- | "I"
110
- | "J"
111
- | "K"
112
- | "L"
113
- | "M"
114
- | "N"
115
- | "O"
116
- | "P"
117
- | "Q"
118
- | "R"
119
- | "S"
120
- | "T"
121
- | "U"
122
- | "V"
123
- | "W"
124
- | "X"
125
- | "Y"
126
- | "Z";
1
+ import { Equal } from "./typings/Equal";
2
+ import { NativeClass } from "./typings/NativeClass";
3
+ import { ValueOf } from "./typings/ValueOf";
4
+
5
+ /**
6
+ * Snake case type.
7
+ *
8
+ * `SnakeCase` type is a type that all keys of an object are converted to snake case.
9
+ *
10
+ * It also erase every method properties like {@link Resolved} type.
11
+ *
12
+ * @template T Target type to be snake cased
13
+ * @author Jeongho Nam - https://github.com/samchon
14
+ */
15
+ export type SnakeCase<T> =
16
+ Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
17
+
18
+ /* -----------------------------------------------------------
19
+ OBJECT CONVERSION
20
+ ----------------------------------------------------------- */
21
+
22
+ type SnakageMain<T> = T extends [never]
23
+ ? never // special trick for (jsonable | null) type
24
+ : T extends { valueOf(): boolean | bigint | number | string }
25
+ ? ValueOf<T>
26
+ : T extends Function
27
+ ? never
28
+ : T extends object
29
+ ? SnakageObject<T>
30
+ : T;
31
+
32
+ type SnakageObject<T extends object> =
33
+ T extends Array<infer U>
34
+ ? IsTuple<T> extends true
35
+ ? SnakageTuple<T>
36
+ : SnakageMain<U>[]
37
+ : T extends Set<infer U>
38
+ ? Set<SnakageMain<U>>
39
+ : T extends Map<infer K, infer V>
40
+ ? Map<SnakageMain<K>, SnakageMain<V>>
41
+ : T extends WeakSet<any> | WeakMap<any, any>
42
+ ? never
43
+ : T extends NativeClass
44
+ ? T
45
+ : {
46
+ [Key in keyof T as SnakageString<Key & string>]: SnakageMain<
47
+ T[Key]
48
+ >;
49
+ };
50
+
51
+ /* -----------------------------------------------------------
52
+ SPECIAL CASES
53
+ ----------------------------------------------------------- */
54
+ type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
55
+ never,
56
+ ]
57
+ ? false
58
+ : T extends readonly any[]
59
+ ? number extends T["length"]
60
+ ? false
61
+ : true
62
+ : false;
63
+ type SnakageTuple<T extends readonly any[]> = T extends []
64
+ ? []
65
+ : T extends [infer F]
66
+ ? [SnakageMain<F>]
67
+ : T extends [infer F, ...infer Rest extends readonly any[]]
68
+ ? [SnakageMain<F>, ...SnakageTuple<Rest>]
69
+ : T extends [(infer F)?]
70
+ ? [SnakageMain<F>?]
71
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
72
+ ? [SnakageMain<F>?, ...SnakageTuple<Rest>]
73
+ : [];
74
+
75
+ /* -----------------------------------------------------------
76
+ STRING CONVERTER
77
+ ----------------------------------------------------------- */
78
+ type SnakageString<Key extends string> = Key extends `${infer _}`
79
+ ? SnakageStringRepeatedly<Key, "">
80
+ : Key;
81
+ type SnakageStringRepeatedly<
82
+ S extends string,
83
+ Previous extends string,
84
+ > = S extends `${infer First}${infer Second}${infer Rest}`
85
+ ? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
86
+ First,
87
+ Second
88
+ >}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
89
+ : S extends `${infer First}`
90
+ ? `${Underscore<Previous, First>}${Lowercase<First>}`
91
+ : "";
92
+ type Underscore<First extends string, Second extends string> = First extends
93
+ | UpperAlphabetic
94
+ | ""
95
+ | "_"
96
+ ? ""
97
+ : Second extends UpperAlphabetic
98
+ ? "_"
99
+ : "";
100
+ type UpperAlphabetic =
101
+ | "A"
102
+ | "B"
103
+ | "C"
104
+ | "D"
105
+ | "E"
106
+ | "F"
107
+ | "G"
108
+ | "H"
109
+ | "I"
110
+ | "J"
111
+ | "K"
112
+ | "L"
113
+ | "M"
114
+ | "N"
115
+ | "O"
116
+ | "P"
117
+ | "Q"
118
+ | "R"
119
+ | "S"
120
+ | "T"
121
+ | "U"
122
+ | "V"
123
+ | "W"
124
+ | "X"
125
+ | "Y"
126
+ | "Z";
@@ -1,37 +1,37 @@
1
- export class TypeGuardError<T = any> extends Error {
2
- public readonly method: string;
3
- public readonly path: string | undefined;
4
- public readonly expected: string;
5
- public readonly value: any;
6
- protected readonly fake_expected_typed_value_?: T | undefined;
7
-
8
- public constructor(props: TypeGuardError.IProps) {
9
- // MESSAGE CONSTRUCTION
10
- super(
11
- props.message ||
12
- `Error on ${props.method}(): invalid type${
13
- props.path ? ` on ${props.path}` : ""
14
- }, expect to be ${props.expected}`,
15
- );
16
-
17
- // INHERITANCE POLYFILL
18
- const proto = new.target.prototype;
19
- if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
20
- else (this as any).__proto__ = proto;
21
-
22
- // ASSIGN MEMBERS
23
- this.method = props.method;
24
- this.path = props.path;
25
- this.expected = props.expected;
26
- this.value = props.value;
27
- }
28
- }
29
- export namespace TypeGuardError {
30
- export interface IProps {
31
- method: string;
32
- path?: undefined | string;
33
- expected: string;
34
- value: any;
35
- message?: undefined | string;
36
- }
37
- }
1
+ export class TypeGuardError<T = any> extends Error {
2
+ public readonly method: string;
3
+ public readonly path: string | undefined;
4
+ public readonly expected: string;
5
+ public readonly value: any;
6
+ protected readonly fake_expected_typed_value_?: T | undefined;
7
+
8
+ public constructor(props: TypeGuardError.IProps) {
9
+ // MESSAGE CONSTRUCTION
10
+ super(
11
+ props.message ||
12
+ `Error on ${props.method}(): invalid type${
13
+ props.path ? ` on ${props.path}` : ""
14
+ }, expect to be ${props.expected}`,
15
+ );
16
+
17
+ // INHERITANCE POLYFILL
18
+ const proto = new.target.prototype;
19
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
20
+ else (this as any).__proto__ = proto;
21
+
22
+ // ASSIGN MEMBERS
23
+ this.method = props.method;
24
+ this.path = props.path;
25
+ this.expected = props.expected;
26
+ this.value = props.value;
27
+ }
28
+ }
29
+ export namespace TypeGuardError {
30
+ export interface IProps {
31
+ method: string;
32
+ path?: undefined | string;
33
+ expected: string;
34
+ value: any;
35
+ message?: undefined | string;
36
+ }
37
+ }
@@ -1,8 +1,8 @@
1
- import cp from "child_process";
2
-
3
- export namespace CommandExecutor {
4
- export const run = (str: string): void => {
5
- console.log(`\n$ ${str}`);
6
- cp.execSync(str, { stdio: "inherit" });
7
- };
8
- }
1
+ import cp from "child_process";
2
+
3
+ export namespace CommandExecutor {
4
+ export const run = (str: string): void => {
5
+ console.log(`\n$ ${str}`);
6
+ cp.execSync(str, { stdio: "inherit" });
7
+ };
8
+ }
@@ -1,69 +1,69 @@
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) return (compilerOptions.plugins = [] as any);
28
- else if (!Array.isArray(plugins))
29
- throw new TypeError(
30
- `"plugins" property of ${args.project} must be array type.`,
31
- );
32
- return plugins;
33
- })();
34
-
35
- const strict: boolean | undefined = compilerOptions.strict as
36
- | boolean
37
- | undefined;
38
- const strictNullChecks: boolean | undefined =
39
- compilerOptions.strictNullChecks as boolean | undefined;
40
- const oldbie: comments.CommentObject | undefined = plugins.find(
41
- (p) =>
42
- typeof p === "object" &&
43
- p !== null &&
44
- p.transform === "typia/lib/transform",
45
- );
46
- if (
47
- strictNullChecks !== false &&
48
- (strict === true || strictNullChecks === true) &&
49
- oldbie !== undefined
50
- )
51
- return;
52
-
53
- // DO CONFIGURE
54
- compilerOptions.strictNullChecks = true;
55
- if (strict === undefined && strictNullChecks === undefined)
56
- compilerOptions.strict = true;
57
- if (oldbie === undefined)
58
- plugins.push(
59
- comments.parse(`
60
- {
61
- "transform": "typia/lib/transform"
62
- }`) as comments.CommentObject,
63
- );
64
- await fs.promises.writeFile(
65
- args.project!,
66
- comments.stringify(config, null, 2),
67
- );
68
- }
69
- }
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) return (compilerOptions.plugins = [] as any);
28
+ else if (!Array.isArray(plugins))
29
+ throw new TypeError(
30
+ `"plugins" property of ${args.project} must be array type.`,
31
+ );
32
+ return plugins;
33
+ })();
34
+
35
+ const strict: boolean | undefined = compilerOptions.strict as
36
+ | boolean
37
+ | undefined;
38
+ const strictNullChecks: boolean | undefined =
39
+ compilerOptions.strictNullChecks as boolean | undefined;
40
+ const oldbie: comments.CommentObject | undefined = plugins.find(
41
+ (p) =>
42
+ typeof p === "object" &&
43
+ p !== null &&
44
+ p.transform === "typia/lib/transform",
45
+ );
46
+ if (
47
+ strictNullChecks !== false &&
48
+ (strict === true || strictNullChecks === true) &&
49
+ oldbie !== undefined
50
+ )
51
+ return;
52
+
53
+ // DO CONFIGURE
54
+ compilerOptions.strictNullChecks = true;
55
+ if (strict === undefined && strictNullChecks === undefined)
56
+ compilerOptions.strict = true;
57
+ if (oldbie === undefined)
58
+ plugins.push(
59
+ comments.parse(`
60
+ {
61
+ "transform": "typia/lib/transform"
62
+ }`) as comments.CommentObject,
63
+ );
64
+ await fs.promises.writeFile(
65
+ args.project!,
66
+ comments.stringify(config, null, 2),
67
+ );
68
+ }
69
+ }
@@ -1,55 +1,55 @@
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 === "patch") {
38
- const { TypiaPatchWizard } = await import("./TypiaPatchWizard");
39
- await TypiaPatchWizard.main();
40
- } else if (type === "generate") {
41
- try {
42
- await import("typescript");
43
- } catch {
44
- halt(
45
- `typescript has not been installed. Run "npm i -D typescript" before.`,
46
- );
47
- }
48
- const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
49
- await TypiaGenerateWizard.generate();
50
- } else halt(USAGE);
51
- };
52
- main().catch((exp) => {
53
- console.error(exp);
54
- process.exit(-1);
55
- });
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 === "patch") {
38
+ const { TypiaPatchWizard } = await import("./TypiaPatchWizard");
39
+ await TypiaPatchWizard.main();
40
+ } else if (type === "generate") {
41
+ try {
42
+ await import("typescript");
43
+ } catch {
44
+ halt(
45
+ `typescript has not been installed. Run "npm i -D typescript" before.`,
46
+ );
47
+ }
48
+ const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
49
+ await TypiaGenerateWizard.generate();
50
+ } else halt(USAGE);
51
+ };
52
+ main().catch((exp) => {
53
+ console.error(exp);
54
+ process.exit(-1);
55
+ });