typia 12.0.0-dev.20260309 → 12.0.0-dev.20260311

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 (134) hide show
  1. package/lib/executable/setup/PluginConfigurator.js +3 -3
  2. package/lib/executable/setup/PluginConfigurator.mjs +3 -3
  3. package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
  4. package/lib/executable/typia.js +15 -15
  5. package/lib/executable/typia.mjs +15 -15
  6. package/package.json +5 -5
  7. package/src/TypeGuardError.ts +145 -145
  8. package/src/executable/TypiaGenerateWizard.ts +82 -82
  9. package/src/executable/TypiaPatchWizard.ts +45 -45
  10. package/src/executable/TypiaSetupWizard.ts +171 -171
  11. package/src/executable/setup/ArgumentParser.ts +42 -42
  12. package/src/executable/setup/CommandExecutor.ts +8 -8
  13. package/src/executable/setup/FileRetriever.ts +19 -19
  14. package/src/executable/setup/PackageManager.ts +87 -87
  15. package/src/executable/setup/PluginConfigurator.ts +74 -74
  16. package/src/executable/typia.ts +55 -55
  17. package/src/functional.ts +600 -600
  18. package/src/http.ts +843 -843
  19. package/src/index.ts +4 -4
  20. package/src/internal/_IProtobufWriter.ts +18 -18
  21. package/src/internal/_ProtobufReader.ts +187 -187
  22. package/src/internal/_ProtobufSizer.ts +137 -137
  23. package/src/internal/_ProtobufWriter.ts +135 -135
  24. package/src/internal/_accessExpressionAsString.ts +46 -46
  25. package/src/internal/_assertGuard.ts +13 -13
  26. package/src/internal/_coerceLlmArguments.ts +7 -7
  27. package/src/internal/_createStandardSchema.ts +133 -133
  28. package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
  29. package/src/internal/_httpFormDataReadArray.ts +4 -4
  30. package/src/internal/_httpFormDataReadBigint.ts +18 -18
  31. package/src/internal/_httpFormDataReadBlob.ts +10 -10
  32. package/src/internal/_httpFormDataReadBoolean.ts +16 -16
  33. package/src/internal/_httpFormDataReadFile.ts +10 -10
  34. package/src/internal/_httpFormDataReadNumber.ts +15 -15
  35. package/src/internal/_httpFormDataReadString.ts +10 -10
  36. package/src/internal/_httpHeaderReadBigint.ts +10 -10
  37. package/src/internal/_httpHeaderReadBoolean.ts +8 -8
  38. package/src/internal/_httpHeaderReadNumber.ts +7 -7
  39. package/src/internal/_httpParameterReadBigint.ts +10 -10
  40. package/src/internal/_httpParameterReadBoolean.ts +8 -8
  41. package/src/internal/_httpParameterReadNumber.ts +7 -7
  42. package/src/internal/_httpParameterReadString.ts +2 -2
  43. package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
  44. package/src/internal/_httpQueryReadArray.ts +4 -4
  45. package/src/internal/_httpQueryReadBigint.ts +12 -12
  46. package/src/internal/_httpQueryReadBoolean.ts +14 -14
  47. package/src/internal/_httpQueryReadNumber.ts +9 -9
  48. package/src/internal/_httpQueryReadString.ts +4 -4
  49. package/src/internal/_isBetween.ts +2 -2
  50. package/src/internal/_isBigintString.ts +8 -8
  51. package/src/internal/_isFormatByte.ts +7 -7
  52. package/src/internal/_isFormatDate.ts +3 -3
  53. package/src/internal/_isFormatDateTime.ts +4 -4
  54. package/src/internal/_isFormatDuration.ts +4 -4
  55. package/src/internal/_isFormatEmail.ts +4 -4
  56. package/src/internal/_isFormatHostname.ts +4 -4
  57. package/src/internal/_isFormatIdnEmail.ts +4 -4
  58. package/src/internal/_isFormatIdnHostname.ts +4 -4
  59. package/src/internal/_isFormatIpv4.ts +4 -4
  60. package/src/internal/_isFormatIpv6.ts +4 -4
  61. package/src/internal/_isFormatIri.ts +3 -3
  62. package/src/internal/_isFormatIriReference.ts +4 -4
  63. package/src/internal/_isFormatJsonPointer.ts +3 -3
  64. package/src/internal/_isFormatPassword.ts +1 -1
  65. package/src/internal/_isFormatRegex.ts +8 -8
  66. package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
  67. package/src/internal/_isFormatTime.ts +4 -4
  68. package/src/internal/_isFormatUri.ts +6 -6
  69. package/src/internal/_isFormatUriReference.ts +5 -5
  70. package/src/internal/_isFormatUriTemplate.ts +4 -4
  71. package/src/internal/_isFormatUrl.ts +4 -4
  72. package/src/internal/_isFormatUuid.ts +3 -3
  73. package/src/internal/_isTypeFloat.ts +5 -5
  74. package/src/internal/_isTypeInt32.ts +5 -5
  75. package/src/internal/_isTypeInt64.ts +5 -5
  76. package/src/internal/_isTypeUint32.ts +5 -5
  77. package/src/internal/_isTypeUint64.ts +5 -5
  78. package/src/internal/_isUniqueItems.ts +159 -159
  79. package/src/internal/_jsonStringifyNumber.ts +12 -12
  80. package/src/internal/_jsonStringifyRest.ts +3 -3
  81. package/src/internal/_jsonStringifyString.ts +42 -42
  82. package/src/internal/_jsonStringifyTail.ts +2 -2
  83. package/src/internal/_llmApplicationFinalize.ts +24 -24
  84. package/src/internal/_miscCloneAny.ts +46 -46
  85. package/src/internal/_notationAny.ts +37 -37
  86. package/src/internal/_notationCamel.ts +13 -13
  87. package/src/internal/_notationPascal.ts +8 -8
  88. package/src/internal/_notationSnake.ts +43 -43
  89. package/src/internal/_parseLlmArguments.ts +7 -7
  90. package/src/internal/_randomArray.ts +21 -21
  91. package/src/internal/_randomBigint.ts +6 -6
  92. package/src/internal/_randomBoolean.ts +1 -1
  93. package/src/internal/_randomFormatByte.ts +3 -3
  94. package/src/internal/_randomFormatDate.ts +18 -18
  95. package/src/internal/_randomFormatDatetime.ts +16 -16
  96. package/src/internal/_randomFormatDuration.ts +27 -27
  97. package/src/internal/_randomFormatEmail.ts +11 -11
  98. package/src/internal/_randomFormatHostname.ts +6 -6
  99. package/src/internal/_randomFormatIdnEmail.ts +3 -3
  100. package/src/internal/_randomFormatIdnHostname.ts +3 -3
  101. package/src/internal/_randomFormatIpv4.ts +11 -11
  102. package/src/internal/_randomFormatIpv6.ts +11 -11
  103. package/src/internal/_randomFormatIri.ts +3 -3
  104. package/src/internal/_randomFormatIriReference.ts +3 -3
  105. package/src/internal/_randomFormatJsonPointer.ts +7 -7
  106. package/src/internal/_randomFormatPassword.ts +8 -8
  107. package/src/internal/_randomFormatRegex.ts +4 -4
  108. package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
  109. package/src/internal/_randomFormatTime.ts +14 -14
  110. package/src/internal/_randomFormatUri.ts +3 -3
  111. package/src/internal/_randomFormatUriReference.ts +3 -3
  112. package/src/internal/_randomFormatUriTemplate.ts +3 -3
  113. package/src/internal/_randomFormatUrl.ts +11 -11
  114. package/src/internal/_randomFormatUuid.ts +6 -6
  115. package/src/internal/_randomInteger.ts +53 -53
  116. package/src/internal/_randomNumber.ts +80 -80
  117. package/src/internal/_randomPattern.ts +10 -10
  118. package/src/internal/_randomPick.ts +9 -9
  119. package/src/internal/_randomString.ts +24 -24
  120. package/src/internal/_throwTypeGuardError.ts +5 -5
  121. package/src/internal/_validateReport.ts +21 -21
  122. package/src/internal/private/__notationCapitalize.ts +2 -2
  123. package/src/internal/private/__notationUnsnake.ts +24 -24
  124. package/src/json.ts +553 -553
  125. package/src/llm.ts +408 -408
  126. package/src/misc.ts +448 -448
  127. package/src/module.ts +811 -811
  128. package/src/notations.ts +624 -624
  129. package/src/programmers/TypiaProgrammer.ts +8 -8
  130. package/src/protobuf.ts +499 -499
  131. package/src/re-exports.ts +33 -33
  132. package/src/reflect.ts +75 -75
  133. package/src/transform.ts +5 -5
  134. package/src/transformers/NoTransformConfigurationError.ts +16 -16
@@ -1,45 +1,45 @@
1
- import fs from "fs";
2
-
3
- export namespace TypiaPatchWizard {
4
- export const main = async (): Promise<void> => {
5
- console.log("----------------------------------------");
6
- console.log(" Typia Setup Wizard");
7
- console.log("----------------------------------------");
8
- console.log(
9
- [
10
- `Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments.`,
11
- ``,
12
- `Therefore, "typia" revives the JSDoc parsing feature by patching "tsc".`,
13
- ``,
14
- `This is a temporary feature of "typia", and it would be removed when "ts-patch" being updated.`,
15
- ].join("\n"),
16
- );
17
-
18
- await patch();
19
- };
20
-
21
- export const patch = async (): Promise<void> => {
22
- for (const file of ["tsc.js", "_tsc.js"])
23
- try {
24
- const location: string = require.resolve(`typescript/lib/${file}`);
25
- const content: string = await fs.promises.readFile(location, "utf8");
26
- if (content.indexOf(FROM_WITH_COMMENT) !== -1)
27
- await fs.promises.writeFile(
28
- location,
29
- content.replace(FROM_WITH_COMMENT, TO_WITH_COMMENT),
30
- "utf8",
31
- );
32
- else if (content.indexOf(FROM_ONLY) !== -1)
33
- await fs.promises.writeFile(
34
- location,
35
- content.replace(FROM_ONLY, TO_ONLY),
36
- "utf8",
37
- );
38
- } catch {}
39
- };
40
- }
41
-
42
- const FROM_WITH_COMMENT = `var defaultJSDocParsingMode = 2 /* ParseForTypeErrors */`;
43
- const TO_WITH_COMMENT = `var defaultJSDocParsingMode = 0 /* ParseAll */`;
44
- const FROM_ONLY = `var defaultJSDocParsingMode = 2`;
45
- const TO_ONLY = `var defaultJSDocParsingMode = 0`;
1
+ import fs from "fs";
2
+
3
+ export namespace TypiaPatchWizard {
4
+ export const main = async (): Promise<void> => {
5
+ console.log("----------------------------------------");
6
+ console.log(" Typia Setup Wizard");
7
+ console.log("----------------------------------------");
8
+ console.log(
9
+ [
10
+ `Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments.`,
11
+ ``,
12
+ `Therefore, "typia" revives the JSDoc parsing feature by patching "tsc".`,
13
+ ``,
14
+ `This is a temporary feature of "typia", and it would be removed when "ts-patch" being updated.`,
15
+ ].join("\n"),
16
+ );
17
+
18
+ await patch();
19
+ };
20
+
21
+ export const patch = async (): Promise<void> => {
22
+ for (const file of ["tsc.js", "_tsc.js"])
23
+ try {
24
+ const location: string = require.resolve(`typescript/lib/${file}`);
25
+ const content: string = await fs.promises.readFile(location, "utf8");
26
+ if (content.indexOf(FROM_WITH_COMMENT) !== -1)
27
+ await fs.promises.writeFile(
28
+ location,
29
+ content.replace(FROM_WITH_COMMENT, TO_WITH_COMMENT),
30
+ "utf8",
31
+ );
32
+ else if (content.indexOf(FROM_ONLY) !== -1)
33
+ await fs.promises.writeFile(
34
+ location,
35
+ content.replace(FROM_ONLY, TO_ONLY),
36
+ "utf8",
37
+ );
38
+ } catch {}
39
+ };
40
+ }
41
+
42
+ const FROM_WITH_COMMENT = `var defaultJSDocParsingMode = 2 /* ParseForTypeErrors */`;
43
+ const TO_WITH_COMMENT = `var defaultJSDocParsingMode = 0 /* ParseAll */`;
44
+ const FROM_ONLY = `var defaultJSDocParsingMode = 2`;
45
+ const TO_ONLY = `var defaultJSDocParsingMode = 0`;
@@ -1,171 +1,171 @@
1
- import fs from "fs";
2
- import { DetectResult, detect } from "package-manager-detector";
3
-
4
- import { ArgumentParser } from "./setup/ArgumentParser";
5
- import { CommandExecutor } from "./setup/CommandExecutor";
6
- import { PackageManager } from "./setup/PackageManager";
7
- import { PluginConfigurator } from "./setup/PluginConfigurator";
8
-
9
- export namespace TypiaSetupWizard {
10
- export interface IArguments {
11
- manager: "npm" | "pnpm" | "yarn" | "bun";
12
- project: string | null;
13
- }
14
-
15
- export const setup = async (): Promise<void> => {
16
- console.log("----------------------------------------");
17
- console.log(" Typia Setup Wizard");
18
- console.log("----------------------------------------");
19
-
20
- // PREPARE ASSETS
21
- const pack: PackageManager = await PackageManager.mount();
22
- const args: IArguments = await ArgumentParser.parse(pack, inquiry);
23
-
24
- // INSTALL TYPESCRIPT COMPILERS
25
- pack.install({
26
- dev: true,
27
- modulo: "typescript",
28
- version: await getTypeScriptVersion(),
29
- });
30
- pack.install({ dev: true, modulo: "ts-patch", version: "latest" });
31
- args.project ??= (() => {
32
- const runner: string = pack.manager === "npm" ? "npx" : pack.manager;
33
- CommandExecutor.run(`${runner} tsc --init`);
34
- return (args.project = "tsconfig.json");
35
- })();
36
-
37
- // SETUP TRANSFORMER
38
- await pack.save((data) => {
39
- // COMPOSE PREPARE COMMAND
40
- data.scripts ??= {};
41
- if (
42
- typeof data.scripts.prepare === "string" &&
43
- data.scripts.prepare.trim().length !== 0
44
- ) {
45
- if (data.scripts.prepare.includes("ts-patch install") === false)
46
- data.scripts.prepare = "ts-patch install && " + data.scripts.prepare;
47
- } else data.scripts.prepare = "ts-patch install";
48
-
49
- // NO MORE "typia patch" REQUIRED
50
- data.scripts.prepare = data.scripts.prepare
51
- .split("&&")
52
- .map((str) => str.trim())
53
- .filter((str) => str !== "typia patch")
54
- .join(" && ");
55
-
56
- // FOR OLDER VERSIONS
57
- if (typeof data.scripts.postinstall === "string") {
58
- data.scripts.postinstall = data.scripts.postinstall
59
- .split("&&")
60
- .map((str) => str.trim())
61
- .filter((str) => str.indexOf("ts-patch install") === -1)
62
- .join(" && ");
63
- if (data.scripts.postinstall.length === 0)
64
- delete data.scripts.postinstall;
65
- }
66
- });
67
-
68
- // CONFIGURE TYPIA
69
- await PluginConfigurator.configure(args);
70
- CommandExecutor.run(`${pack.manager} run prepare`);
71
- };
72
-
73
- const inquiry: ArgumentParser.Inquiry<IArguments> = async (
74
- pack,
75
- command,
76
- prompt,
77
- action,
78
- ) => {
79
- // PREPARE ASSETS
80
- command.option("--manager [manager", "package manager");
81
- command.option("--project [project]", "tsconfig.json file location");
82
-
83
- // INTERNAL PROCEDURES
84
- const questioned = { value: false };
85
- const select =
86
- (name: string) =>
87
- (message: string) =>
88
- async <Choice extends string>(
89
- choices: Choice[],
90
- filter?: (choice: string) => Choice,
91
- ): Promise<Choice> => {
92
- questioned.value = true;
93
- return (
94
- await prompt()({
95
- type: "list",
96
- name: name,
97
- message: message,
98
- choices: choices,
99
- ...(filter ? { filter } : {}),
100
- })
101
- )[name];
102
- };
103
- const configure = async (): Promise<string | null> => {
104
- const fileList: string[] = await (
105
- await fs.promises.readdir(process.cwd())
106
- )
107
- .filter(
108
- (str) =>
109
- str.substring(0, 8) === "tsconfig" &&
110
- str.substring(str.length - 5) === ".json",
111
- )
112
- .sort((x, y) =>
113
- x === "tsconfig.json"
114
- ? -1
115
- : y === "tsconfig.json"
116
- ? 1
117
- : x < y
118
- ? -1
119
- : 1,
120
- );
121
- if (fileList.length === 0) {
122
- if (process.cwd() !== pack.directory)
123
- throw new URIError(`Unable to find "tsconfig.json" file.`);
124
- return null;
125
- } else if (fileList.length === 1) return fileList[0]!;
126
- return select("tsconfig")("TS Config File")(fileList);
127
- };
128
-
129
- // DO CONSTRUCT
130
- return action(async (options) => {
131
- pack.manager = options.manager ??=
132
- (await detectManager()) ??
133
- (await select("manager")("Package Manager")(
134
- [
135
- "npm" as const,
136
- "pnpm" as const,
137
- "bun" as const,
138
- "yarn (berry is not supported)" as "yarn",
139
- ],
140
- (value) => value.split(" ")[0] as "yarn",
141
- ));
142
- options.project ??= await configure();
143
-
144
- if (questioned.value) console.log("");
145
- return options as IArguments;
146
- });
147
- };
148
-
149
- const detectManager = async (): Promise<
150
- "npm" | "pnpm" | "yarn" | "bun" | null
151
- > => {
152
- const result: DetectResult | null = await detect({ cwd: process.cwd() });
153
- switch (result?.name) {
154
- case "npm":
155
- case "deno":
156
- return null; // NPM case is still selectable & Deno is not supported
157
- default:
158
- return result?.name ?? null;
159
- }
160
- };
161
-
162
- const getTypeScriptVersion = async (): Promise<string> => {
163
- const content: string = await fs.promises.readFile(
164
- `${__dirname}/../../package.json`,
165
- "utf-8",
166
- );
167
- const json: { devDependencies: { typescript: string } } =
168
- JSON.parse(content);
169
- return json.devDependencies.typescript;
170
- };
171
- }
1
+ import fs from "fs";
2
+ import { DetectResult, detect } from "package-manager-detector";
3
+
4
+ import { ArgumentParser } from "./setup/ArgumentParser";
5
+ import { CommandExecutor } from "./setup/CommandExecutor";
6
+ import { PackageManager } from "./setup/PackageManager";
7
+ import { PluginConfigurator } from "./setup/PluginConfigurator";
8
+
9
+ export namespace TypiaSetupWizard {
10
+ export interface IArguments {
11
+ manager: "npm" | "pnpm" | "yarn" | "bun";
12
+ project: string | null;
13
+ }
14
+
15
+ export const setup = async (): Promise<void> => {
16
+ console.log("----------------------------------------");
17
+ console.log(" Typia Setup Wizard");
18
+ console.log("----------------------------------------");
19
+
20
+ // PREPARE ASSETS
21
+ const pack: PackageManager = await PackageManager.mount();
22
+ const args: IArguments = await ArgumentParser.parse(pack, inquiry);
23
+
24
+ // INSTALL TYPESCRIPT COMPILERS
25
+ pack.install({
26
+ dev: true,
27
+ modulo: "typescript",
28
+ version: await getTypeScriptVersion(),
29
+ });
30
+ pack.install({ dev: true, modulo: "ts-patch", version: "latest" });
31
+ args.project ??= (() => {
32
+ const runner: string = pack.manager === "npm" ? "npx" : pack.manager;
33
+ CommandExecutor.run(`${runner} tsc --init`);
34
+ return (args.project = "tsconfig.json");
35
+ })();
36
+
37
+ // SETUP TRANSFORMER
38
+ await pack.save((data) => {
39
+ // COMPOSE PREPARE COMMAND
40
+ data.scripts ??= {};
41
+ if (
42
+ typeof data.scripts.prepare === "string" &&
43
+ data.scripts.prepare.trim().length !== 0
44
+ ) {
45
+ if (data.scripts.prepare.includes("ts-patch install") === false)
46
+ data.scripts.prepare = "ts-patch install && " + data.scripts.prepare;
47
+ } else data.scripts.prepare = "ts-patch install";
48
+
49
+ // NO MORE "typia patch" REQUIRED
50
+ data.scripts.prepare = data.scripts.prepare
51
+ .split("&&")
52
+ .map((str) => str.trim())
53
+ .filter((str) => str !== "typia patch")
54
+ .join(" && ");
55
+
56
+ // FOR OLDER VERSIONS
57
+ if (typeof data.scripts.postinstall === "string") {
58
+ data.scripts.postinstall = data.scripts.postinstall
59
+ .split("&&")
60
+ .map((str) => str.trim())
61
+ .filter((str) => str.indexOf("ts-patch install") === -1)
62
+ .join(" && ");
63
+ if (data.scripts.postinstall.length === 0)
64
+ delete data.scripts.postinstall;
65
+ }
66
+ });
67
+
68
+ // CONFIGURE TYPIA
69
+ await PluginConfigurator.configure(args);
70
+ CommandExecutor.run(`${pack.manager} run prepare`);
71
+ };
72
+
73
+ const inquiry: ArgumentParser.Inquiry<IArguments> = async (
74
+ pack,
75
+ command,
76
+ prompt,
77
+ action,
78
+ ) => {
79
+ // PREPARE ASSETS
80
+ command.option("--manager [manager", "package manager");
81
+ command.option("--project [project]", "tsconfig.json file location");
82
+
83
+ // INTERNAL PROCEDURES
84
+ const questioned = { value: false };
85
+ const select =
86
+ (name: string) =>
87
+ (message: string) =>
88
+ async <Choice extends string>(
89
+ choices: Choice[],
90
+ filter?: (choice: string) => Choice,
91
+ ): Promise<Choice> => {
92
+ questioned.value = true;
93
+ return (
94
+ await prompt()({
95
+ type: "list",
96
+ name: name,
97
+ message: message,
98
+ choices: choices,
99
+ ...(filter ? { filter } : {}),
100
+ })
101
+ )[name];
102
+ };
103
+ const configure = async (): Promise<string | null> => {
104
+ const fileList: string[] = await (
105
+ await fs.promises.readdir(process.cwd())
106
+ )
107
+ .filter(
108
+ (str) =>
109
+ str.substring(0, 8) === "tsconfig" &&
110
+ str.substring(str.length - 5) === ".json",
111
+ )
112
+ .sort((x, y) =>
113
+ x === "tsconfig.json"
114
+ ? -1
115
+ : y === "tsconfig.json"
116
+ ? 1
117
+ : x < y
118
+ ? -1
119
+ : 1,
120
+ );
121
+ if (fileList.length === 0) {
122
+ if (process.cwd() !== pack.directory)
123
+ throw new URIError(`Unable to find "tsconfig.json" file.`);
124
+ return null;
125
+ } else if (fileList.length === 1) return fileList[0]!;
126
+ return select("tsconfig")("TS Config File")(fileList);
127
+ };
128
+
129
+ // DO CONSTRUCT
130
+ return action(async (options) => {
131
+ pack.manager = options.manager ??=
132
+ (await detectManager()) ??
133
+ (await select("manager")("Package Manager")(
134
+ [
135
+ "npm" as const,
136
+ "pnpm" as const,
137
+ "bun" as const,
138
+ "yarn (berry is not supported)" as "yarn",
139
+ ],
140
+ (value) => value.split(" ")[0] as "yarn",
141
+ ));
142
+ options.project ??= await configure();
143
+
144
+ if (questioned.value) console.log("");
145
+ return options as IArguments;
146
+ });
147
+ };
148
+
149
+ const detectManager = async (): Promise<
150
+ "npm" | "pnpm" | "yarn" | "bun" | null
151
+ > => {
152
+ const result: DetectResult | null = await detect({ cwd: process.cwd() });
153
+ switch (result?.name) {
154
+ case "npm":
155
+ case "deno":
156
+ return null; // NPM case is still selectable & Deno is not supported
157
+ default:
158
+ return result?.name ?? null;
159
+ }
160
+ };
161
+
162
+ const getTypeScriptVersion = async (): Promise<string> => {
163
+ const content: string = await fs.promises.readFile(
164
+ `${__dirname}/../../package.json`,
165
+ "utf-8",
166
+ );
167
+ const json: { devDependencies: { typescript: string } } =
168
+ JSON.parse(content);
169
+ return json.devDependencies.typescript;
170
+ };
171
+ }
@@ -1,42 +1,42 @@
1
- import commander from "commander";
2
- import inquirer from "inquirer";
3
-
4
- import { PackageManager } from "./PackageManager";
5
-
6
- export namespace ArgumentParser {
7
- export type Inquiry<T> = (
8
- pack: PackageManager,
9
- command: commander.Command,
10
- prompt: (opt?: inquirer.StreamOptions) => inquirer.PromptModule,
11
- action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,
12
- ) => Promise<T>;
13
-
14
- export const parse = async <T>(
15
- pack: PackageManager,
16
- inquiry: (
17
- pack: PackageManager,
18
- command: commander.Command,
19
- prompt: (opt?: inquirer.StreamOptions) => inquirer.PromptModule,
20
- action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,
21
- ) => Promise<T>,
22
- ): Promise<T> => {
23
- // TAKE OPTIONS
24
- const action = (closure: (options: Partial<T>) => Promise<T>) =>
25
- new Promise<T>((resolve, reject) => {
26
- commander.program.action(async (options) => {
27
- try {
28
- resolve(await closure(options));
29
- } catch (exp) {
30
- reject(exp);
31
- }
32
- });
33
- commander.program.parseAsync().catch(reject);
34
- });
35
- return inquiry(
36
- pack,
37
- commander.program,
38
- inquirer.createPromptModule,
39
- action,
40
- );
41
- };
42
- }
1
+ import commander from "commander";
2
+ import inquirer from "inquirer";
3
+
4
+ import { PackageManager } from "./PackageManager";
5
+
6
+ export namespace ArgumentParser {
7
+ export type Inquiry<T> = (
8
+ pack: PackageManager,
9
+ command: commander.Command,
10
+ prompt: (opt?: inquirer.StreamOptions) => inquirer.PromptModule,
11
+ action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,
12
+ ) => Promise<T>;
13
+
14
+ export const parse = async <T>(
15
+ pack: PackageManager,
16
+ inquiry: (
17
+ pack: PackageManager,
18
+ command: commander.Command,
19
+ prompt: (opt?: inquirer.StreamOptions) => inquirer.PromptModule,
20
+ action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,
21
+ ) => Promise<T>,
22
+ ): Promise<T> => {
23
+ // TAKE OPTIONS
24
+ const action = (closure: (options: Partial<T>) => Promise<T>) =>
25
+ new Promise<T>((resolve, reject) => {
26
+ commander.program.action(async (options) => {
27
+ try {
28
+ resolve(await closure(options));
29
+ } catch (exp) {
30
+ reject(exp);
31
+ }
32
+ });
33
+ commander.program.parseAsync().catch(reject);
34
+ });
35
+ return inquiry(
36
+ pack,
37
+ commander.program,
38
+ inquirer.createPromptModule,
39
+ action,
40
+ );
41
+ };
42
+ }
@@ -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,19 +1,19 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- export namespace FileRetriever {
5
- export const directory = (props: {
6
- file: string;
7
- location: string;
8
- depth?: number;
9
- }): string | null => {
10
- const location: string = path.join(props.location, props.file);
11
- if (fs.existsSync(location)) return props.location;
12
- else if ((props.depth ?? 0) > 2) return null;
13
- return directory({
14
- file: props.file,
15
- location: path.join(props.location, ".."),
16
- depth: (props.depth ?? 0) + 1,
17
- });
18
- };
19
- }
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ export namespace FileRetriever {
5
+ export const directory = (props: {
6
+ file: string;
7
+ location: string;
8
+ depth?: number;
9
+ }): string | null => {
10
+ const location: string = path.join(props.location, props.file);
11
+ if (fs.existsSync(location)) return props.location;
12
+ else if ((props.depth ?? 0) > 2) return null;
13
+ return directory({
14
+ file: props.file,
15
+ location: path.join(props.location, ".."),
16
+ depth: (props.depth ?? 0) + 1,
17
+ });
18
+ };
19
+ }