@nestia/migrate 10.0.2 → 11.0.0-dev.20260312

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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -93
  3. package/lib/NestiaMigrateApplication.d.ts +3 -3
  4. package/lib/NestiaMigrateApplication.js +10086 -7707
  5. package/lib/NestiaMigrateApplication.js.map +1 -1
  6. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +1 -1
  7. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  8. package/lib/bundles/NEST_TEMPLATE.js +48 -48
  9. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  10. package/lib/bundles/SDK_TEMPLATE.js +21 -21
  11. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  12. package/lib/executable/NestiaMigrateCommander.js +4 -4
  13. package/lib/executable/NestiaMigrateCommander.js.map +1 -1
  14. package/lib/executable/NestiaMigrateInquirer.js +13 -16
  15. package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
  16. package/lib/factories/TypeLiteralFactory.js +2 -2
  17. package/lib/factories/TypeLiteralFactory.js.map +1 -1
  18. package/lib/index.mjs +9540 -7065
  19. package/lib/index.mjs.map +1 -1
  20. package/lib/module.d.ts +3 -0
  21. package/lib/module.js +3 -0
  22. package/lib/module.js.map +1 -1
  23. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +1 -1
  24. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +1 -1
  25. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +16 -15
  26. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  27. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +2 -1
  28. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +12 -15
  29. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
  30. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +2 -1
  31. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +11 -13
  32. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
  33. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +3 -4
  34. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
  35. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +1 -1
  36. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +2 -1
  37. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +3 -4
  38. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
  39. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
  40. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +1 -1
  41. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +2 -1
  42. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +10 -13
  43. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
  44. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +1 -1
  45. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +26 -28
  46. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
  47. package/lib/structures/INestiaMigrateContext.d.ts +1 -1
  48. package/lib/structures/INestiaMigrateController.d.ts +1 -1
  49. package/lib/structures/INestiaMigrateDto.d.ts +1 -1
  50. package/lib/structures/INestiaMigrateProgram.d.ts +1 -1
  51. package/lib/utils/StringUtil.js.map +1 -1
  52. package/package.json +32 -46
  53. package/src/NestiaMigrateApplication.ts +165 -159
  54. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  55. package/src/bundles/NEST_TEMPLATE.ts +48 -48
  56. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  57. package/src/executable/NestiaMigrateCommander.ts +104 -98
  58. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  59. package/src/executable/bundle.js +125 -125
  60. package/src/executable/migrate.ts +0 -0
  61. package/src/factories/TypeLiteralFactory.ts +57 -57
  62. package/src/module.ts +7 -2
  63. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  64. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +347 -344
  65. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +517 -514
  66. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +308 -309
  67. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +197 -198
  68. package/src/programmers/NestiaMigrateDtoProgrammer.ts +98 -98
  69. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  70. package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
  71. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  72. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +69 -69
  73. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +409 -406
  74. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +465 -467
  75. package/src/programmers/index.ts +15 -0
  76. package/src/structures/INestiaMigrateContext.ts +9 -9
  77. package/src/structures/INestiaMigrateController.ts +8 -8
  78. package/src/structures/INestiaMigrateDto.ts +8 -8
  79. package/src/structures/INestiaMigrateProgram.ts +11 -11
  80. package/src/structures/index.ts +4 -0
  81. package/src/utils/FilePrinter.ts +49 -49
  82. package/src/utils/StringUtil.ts +114 -113
@@ -1,125 +1,125 @@
1
- const { version } = require("../../../../package.json");
2
- const cp = require("child_process");
3
- const fs = require("fs");
4
-
5
- const ROOT = `${__dirname}/../..`;
6
- const ASSETS = `${ROOT}/assets`;
7
-
8
- const update = (content) => {
9
- const parsed = JSON.parse(content);
10
- for (const record of [
11
- parsed.dependencies ?? {},
12
- parsed.devDependencies ?? {},
13
- ])
14
- for (const key of Object.keys(record))
15
- if (key.startsWith("@nestia/") || key === "nestia")
16
- record[key] = `^${version}`;
17
- return JSON.stringify(parsed, null, 2);
18
- };
19
-
20
- const bundle = async ({ mode, repository, exceptions, transform }) => {
21
- const root = `${__dirname}/../..`;
22
- const assets = `${root}/assets`;
23
- const template = `${assets}/${mode}`;
24
-
25
- const clone = async () => {
26
- // CLONE REPOSITORY
27
- if (fs.existsSync(template))
28
- await fs.promises.rm(template, { recursive: true });
29
- else
30
- try {
31
- await fs.promises.mkdir(ASSETS);
32
- } catch {}
33
-
34
- cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
35
- cwd: ASSETS,
36
- });
37
-
38
- // REMOVE VULNERABLE FILES
39
- for (const location of exceptions ?? [])
40
- await fs.promises.rm(`${template}/${location}`, { recursive: true });
41
- };
42
-
43
- const iterate = (collection) => async (location) => {
44
- const directory = await fs.promises.readdir(location);
45
- for (const file of directory) {
46
- const absolute = location + "/" + file;
47
- const stats = await fs.promises.stat(absolute);
48
- if (stats.isDirectory()) await iterate(collection)(absolute);
49
- else {
50
- const content = await fs.promises.readFile(absolute, "utf-8");
51
- collection[
52
- (() => {
53
- const str = absolute.replace(template, "");
54
- return str[0] === "/" ? str.substring(1) : str;
55
- })()
56
- ] = content;
57
- }
58
- }
59
- };
60
-
61
- const archive = async (collection) => {
62
- const name = `${mode.toUpperCase()}_TEMPLATE`;
63
- const body = JSON.stringify(collection, null, 2);
64
- const content = `export const ${name}: Record<string, string> = ${body}`;
65
-
66
- try {
67
- await fs.promises.mkdir(`${ROOT}/src/bundles`);
68
- } catch {}
69
- await fs.promises.writeFile(
70
- `${ROOT}/src/bundles/${name}.ts`,
71
- content,
72
- "utf8",
73
- );
74
- };
75
-
76
- const collection = {};
77
- await clone();
78
- await iterate(collection)(template);
79
- if (transform)
80
- for (const [key, value] of Object.entries(collection))
81
- collection[key] = transform(key, value);
82
- await archive(collection);
83
- };
84
-
85
- const main = async () => {
86
- await bundle({
87
- mode: "nest",
88
- repository: "nestia-start",
89
- exceptions: [
90
- ".git",
91
- ".github/dependabot.yml",
92
- ".github/workflows/dependabot-automerge.yml",
93
- "src/api/functional",
94
- "src/controllers",
95
- "src/MyModule.ts",
96
- "src/providers",
97
- "test/features",
98
- ],
99
- transform: (key, value) => {
100
- if (key === "package.json") return update(value);
101
- return value;
102
- },
103
- });
104
- await bundle({
105
- mode: "sdk",
106
- repository: "nestia-sdk-template",
107
- exceptions: [
108
- ".git",
109
- ".github/dependabot.yml",
110
- ".github/workflows/build.yml",
111
- ".github/workflows/dependabot-automerge.yml",
112
- "src/functional",
113
- "src/structures",
114
- "test/features",
115
- ],
116
- transform: (key, value) => {
117
- if (key === "package.json") return update(value);
118
- return value;
119
- },
120
- });
121
- };
122
- main().catch((exp) => {
123
- console.error(exp);
124
- process.exit(-1);
125
- });
1
+ const { version } = require("../../../../package.json");
2
+ const cp = require("child_process");
3
+ const fs = require("fs");
4
+
5
+ const ROOT = `${__dirname}/../..`;
6
+ const ASSETS = `${ROOT}/assets`;
7
+
8
+ const update = (content) => {
9
+ const parsed = JSON.parse(content);
10
+ for (const record of [
11
+ parsed.dependencies ?? {},
12
+ parsed.devDependencies ?? {},
13
+ ])
14
+ for (const key of Object.keys(record))
15
+ if (key.startsWith("@nestia/") || key === "nestia")
16
+ record[key] = `^${version}`;
17
+ return JSON.stringify(parsed, null, 2);
18
+ };
19
+
20
+ const bundle = async ({ mode, repository, exceptions, transform }) => {
21
+ const root = `${__dirname}/../..`;
22
+ const assets = `${root}/assets`;
23
+ const template = `${assets}/${mode}`;
24
+
25
+ const clone = async () => {
26
+ // CLONE REPOSITORY
27
+ if (fs.existsSync(template))
28
+ await fs.promises.rm(template, { recursive: true });
29
+ else
30
+ try {
31
+ await fs.promises.mkdir(ASSETS);
32
+ } catch {}
33
+
34
+ cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
35
+ cwd: ASSETS,
36
+ });
37
+
38
+ // REMOVE VULNERABLE FILES
39
+ for (const location of exceptions ?? [])
40
+ await fs.promises.rm(`${template}/${location}`, { recursive: true });
41
+ };
42
+
43
+ const iterate = (collection) => async (location) => {
44
+ const directory = await fs.promises.readdir(location);
45
+ for (const file of directory) {
46
+ const absolute = location + "/" + file;
47
+ const stats = await fs.promises.stat(absolute);
48
+ if (stats.isDirectory()) await iterate(collection)(absolute);
49
+ else {
50
+ const content = await fs.promises.readFile(absolute, "utf-8");
51
+ collection[
52
+ (() => {
53
+ const str = absolute.replace(template, "");
54
+ return str[0] === "/" ? str.substring(1) : str;
55
+ })()
56
+ ] = content;
57
+ }
58
+ }
59
+ };
60
+
61
+ const archive = async (collection) => {
62
+ const name = `${mode.toUpperCase()}_TEMPLATE`;
63
+ const body = JSON.stringify(collection, null, 2);
64
+ const content = `export const ${name}: Record<string, string> = ${body}`;
65
+
66
+ try {
67
+ await fs.promises.mkdir(`${ROOT}/src/bundles`);
68
+ } catch {}
69
+ await fs.promises.writeFile(
70
+ `${ROOT}/src/bundles/${name}.ts`,
71
+ content,
72
+ "utf8",
73
+ );
74
+ };
75
+
76
+ const collection = {};
77
+ await clone();
78
+ await iterate(collection)(template);
79
+ if (transform)
80
+ for (const [key, value] of Object.entries(collection))
81
+ collection[key] = transform(key, value);
82
+ await archive(collection);
83
+ };
84
+
85
+ const main = async () => {
86
+ await bundle({
87
+ mode: "nest",
88
+ repository: "nestia-start",
89
+ exceptions: [
90
+ ".git",
91
+ ".github/dependabot.yml",
92
+ ".github/workflows/dependabot-automerge.yml",
93
+ "src/api/functional",
94
+ "src/controllers",
95
+ "src/MyModule.ts",
96
+ "src/providers",
97
+ "test/features",
98
+ ],
99
+ transform: (key, value) => {
100
+ if (key === "package.json") return update(value);
101
+ return value;
102
+ },
103
+ });
104
+ await bundle({
105
+ mode: "sdk",
106
+ repository: "nestia-sdk-template",
107
+ exceptions: [
108
+ ".git",
109
+ ".github/dependabot.yml",
110
+ ".github/workflows/build.yml",
111
+ ".github/workflows/dependabot-automerge.yml",
112
+ "src/functional",
113
+ "src/structures",
114
+ "test/features",
115
+ ],
116
+ transform: (key, value) => {
117
+ if (key === "package.json") return update(value);
118
+ return value;
119
+ },
120
+ });
121
+ };
122
+ main().catch((exp) => {
123
+ console.error(exp);
124
+ process.exit(-1);
125
+ });
File without changes
@@ -1,57 +1,57 @@
1
- import ts from "typescript";
2
- import { Escaper } from "typia/lib/utils/Escaper";
3
-
4
- export namespace TypeLiteralFactory {
5
- export const generate = (value: any): ts.TypeNode =>
6
- typeof value === "boolean"
7
- ? generateBoolean(value)
8
- : typeof value === "number"
9
- ? generateNumber(value)
10
- : typeof value === "string"
11
- ? generatestring(value)
12
- : typeof value === "object"
13
- ? value === null
14
- ? generateNull()
15
- : Array.isArray(value)
16
- ? generateTuple(value)
17
- : generateObject(value)
18
- : ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
19
-
20
- const generatestring = (str: string) =>
21
- ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(str));
22
-
23
- const generateNumber = (num: number) =>
24
- ts.factory.createLiteralTypeNode(
25
- num < 0
26
- ? ts.factory.createPrefixUnaryExpression(
27
- ts.SyntaxKind.MinusToken,
28
- ts.factory.createNumericLiteral(-num),
29
- )
30
- : ts.factory.createNumericLiteral(num),
31
- );
32
-
33
- const generateBoolean = (bool: boolean) =>
34
- ts.factory.createLiteralTypeNode(
35
- bool ? ts.factory.createTrue() : ts.factory.createFalse(),
36
- );
37
-
38
- const generateNull = () =>
39
- ts.factory.createLiteralTypeNode(ts.factory.createNull());
40
-
41
- const generateTuple = (items: any[]) =>
42
- ts.factory.createTupleTypeNode(items.map(generate));
43
-
44
- const generateObject = (obj: object) =>
45
- ts.factory.createTypeLiteralNode(
46
- Object.entries(obj).map(([key, value]) =>
47
- ts.factory.createPropertySignature(
48
- undefined,
49
- Escaper.variable(key)
50
- ? ts.factory.createIdentifier(key)
51
- : ts.factory.createStringLiteral(key),
52
- undefined,
53
- generate(value),
54
- ),
55
- ),
56
- );
57
- }
1
+ import { NamingConvention } from "@typia/utils";
2
+ import ts from "typescript";
3
+
4
+ export namespace TypeLiteralFactory {
5
+ export const generate = (value: any): ts.TypeNode =>
6
+ typeof value === "boolean"
7
+ ? generateBoolean(value)
8
+ : typeof value === "number"
9
+ ? generateNumber(value)
10
+ : typeof value === "string"
11
+ ? generatestring(value)
12
+ : typeof value === "object"
13
+ ? value === null
14
+ ? generateNull()
15
+ : Array.isArray(value)
16
+ ? generateTuple(value)
17
+ : generateObject(value)
18
+ : ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
19
+
20
+ const generatestring = (str: string) =>
21
+ ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(str));
22
+
23
+ const generateNumber = (num: number) =>
24
+ ts.factory.createLiteralTypeNode(
25
+ num < 0
26
+ ? ts.factory.createPrefixUnaryExpression(
27
+ ts.SyntaxKind.MinusToken,
28
+ ts.factory.createNumericLiteral(-num),
29
+ )
30
+ : ts.factory.createNumericLiteral(num),
31
+ );
32
+
33
+ const generateBoolean = (bool: boolean) =>
34
+ ts.factory.createLiteralTypeNode(
35
+ bool ? ts.factory.createTrue() : ts.factory.createFalse(),
36
+ );
37
+
38
+ const generateNull = () =>
39
+ ts.factory.createLiteralTypeNode(ts.factory.createNull());
40
+
41
+ const generateTuple = (items: any[]) =>
42
+ ts.factory.createTupleTypeNode(items.map(generate));
43
+
44
+ const generateObject = (obj: object) =>
45
+ ts.factory.createTypeLiteralNode(
46
+ Object.entries(obj).map(([key, value]) =>
47
+ ts.factory.createPropertySignature(
48
+ undefined,
49
+ NamingConvention.variable(key)
50
+ ? ts.factory.createIdentifier(key)
51
+ : ts.factory.createStringLiteral(key),
52
+ undefined,
53
+ generate(value),
54
+ ),
55
+ ),
56
+ );
57
+ }
package/src/module.ts CHANGED
@@ -1,2 +1,7 @@
1
- export * from "./NestiaMigrateApplication";
2
- export * from "./structures/INestiaMigrateContext";
1
+ export * from "./NestiaMigrateApplication";
2
+ export * from "./structures/index";
3
+
4
+ export * from "./archivers/NestiaMigrateFileArchiver";
5
+ export * from "./executable/NestiaMigrateCommander";
6
+
7
+ export * from "./programmers/index";
@@ -1,55 +1,55 @@
1
- import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
- import ts from "typescript";
3
-
4
- import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
- import { FilePrinter } from "../utils/FilePrinter";
6
- import { NestiaMigrateApiFunctionProgrammer } from "./NestiaMigrateApiFunctionProgrammer";
7
- import { NestiaMigrateApiNamespaceProgrammer } from "./NestiaMigrateApiNamespaceProgrammer";
8
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
-
10
- export namespace NestiaMigrateApiFileProgrammer {
11
- export interface IProps {
12
- config: INestiaMigrateConfig;
13
- components: OpenApi.IComponents;
14
- namespace: string[];
15
- routes: IHttpMigrateRoute[];
16
- children: Set<string>;
17
- }
18
-
19
- export const write = (props: IProps): ts.Statement[] => {
20
- const importer: NestiaMigrateImportProgrammer =
21
- new NestiaMigrateImportProgrammer();
22
- const statements: ts.Statement[] = props.routes
23
- .map((route) => [
24
- FilePrinter.newLine(),
25
- NestiaMigrateApiFunctionProgrammer.write({
26
- config: props.config,
27
- components: props.components,
28
- importer,
29
- route,
30
- }),
31
- NestiaMigrateApiNamespaceProgrammer.write({
32
- config: props.config,
33
- components: props.components,
34
- importer,
35
- route,
36
- }),
37
- ])
38
- .flat();
39
- return [
40
- ...importer.toStatements(
41
- (ref) => `../${"../".repeat(props.namespace.length)}structures/${ref}`,
42
- ),
43
- ...[...props.children].map((child) =>
44
- ts.factory.createExportDeclaration(
45
- undefined,
46
- false,
47
- ts.factory.createNamespaceExport(ts.factory.createIdentifier(child)),
48
- ts.factory.createStringLiteral(`./${child}/index`),
49
- undefined,
50
- ),
51
- ),
52
- ...statements,
53
- ];
54
- };
55
- }
1
+ import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
+ import { FilePrinter } from "../utils/FilePrinter";
6
+ import { NestiaMigrateApiFunctionProgrammer } from "./NestiaMigrateApiFunctionProgrammer";
7
+ import { NestiaMigrateApiNamespaceProgrammer } from "./NestiaMigrateApiNamespaceProgrammer";
8
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
+
10
+ export namespace NestiaMigrateApiFileProgrammer {
11
+ export interface IProps {
12
+ config: INestiaMigrateConfig;
13
+ components: OpenApi.IComponents;
14
+ namespace: string[];
15
+ routes: IHttpMigrateRoute[];
16
+ children: Set<string>;
17
+ }
18
+
19
+ export const write = (props: IProps): ts.Statement[] => {
20
+ const importer: NestiaMigrateImportProgrammer =
21
+ new NestiaMigrateImportProgrammer();
22
+ const statements: ts.Statement[] = props.routes
23
+ .map((route) => [
24
+ FilePrinter.newLine(),
25
+ NestiaMigrateApiFunctionProgrammer.write({
26
+ config: props.config,
27
+ components: props.components,
28
+ importer,
29
+ route,
30
+ }),
31
+ NestiaMigrateApiNamespaceProgrammer.write({
32
+ config: props.config,
33
+ components: props.components,
34
+ importer,
35
+ route,
36
+ }),
37
+ ])
38
+ .flat();
39
+ return [
40
+ ...importer.toStatements(
41
+ (ref) => `../${"../".repeat(props.namespace.length)}structures/${ref}`,
42
+ ),
43
+ ...[...props.children].map((child) =>
44
+ ts.factory.createExportDeclaration(
45
+ undefined,
46
+ false,
47
+ ts.factory.createNamespaceExport(ts.factory.createIdentifier(child)),
48
+ ts.factory.createStringLiteral(`./${child}/index`),
49
+ undefined,
50
+ ),
51
+ ),
52
+ ...statements,
53
+ ];
54
+ };
55
+ }