@nestia/migrate 11.0.0-dev.20260316 → 11.0.1

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 (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/lib/NestiaMigrateApplication.js +341 -341
  4. package/lib/bundles/NEST_TEMPLATE.js +48 -48
  5. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  6. package/lib/bundles/SDK_TEMPLATE.js +21 -21
  7. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  8. package/lib/executable/migrate.js +0 -0
  9. package/lib/index.mjs +469 -469
  10. package/lib/index.mjs.map +1 -1
  11. package/package.json +10 -8
  12. package/src/NestiaMigrateApplication.ts +168 -168
  13. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  14. package/src/bundles/NEST_TEMPLATE.ts +48 -48
  15. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  16. package/src/executable/NestiaMigrateCommander.ts +104 -104
  17. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  18. package/src/executable/bundle.js +129 -125
  19. package/src/executable/migrate.ts +0 -0
  20. package/src/factories/TypeLiteralFactory.ts +57 -57
  21. package/src/module.ts +7 -7
  22. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  23. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +347 -347
  24. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +517 -517
  25. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +308 -308
  26. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +197 -197
  27. package/src/programmers/NestiaMigrateDtoProgrammer.ts +98 -98
  28. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  29. package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
  30. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  31. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +69 -69
  32. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +409 -409
  33. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +465 -465
  34. package/src/programmers/index.ts +15 -15
  35. package/src/structures/INestiaMigrateContext.ts +9 -9
  36. package/src/structures/INestiaMigrateController.ts +8 -8
  37. package/src/structures/INestiaMigrateDto.ts +8 -8
  38. package/src/structures/INestiaMigrateProgram.ts +11 -11
  39. package/src/structures/index.ts +4 -4
  40. package/src/utils/FilePrinter.ts +49 -49
  41. package/src/utils/StringUtil.ts +114 -114
@@ -1,125 +1,129 @@
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
+ const TYPIA = require("js-yaml").load(
8
+ fs.readFileSync(`${__dirname}/../../../../pnpm-lock.yaml`, "utf8"),
9
+ ).catalogs.samchon;
10
+
11
+ const update = (content) => {
12
+ const parsed = JSON.parse(content);
13
+ for (const record of [
14
+ parsed.dependencies ?? {},
15
+ parsed.devDependencies ?? {},
16
+ ])
17
+ for (const key of Object.keys(record))
18
+ if (key.startsWith("@nestia/") || key === "nestia")
19
+ record[key] = `^${version}`;
20
+ else if (TYPIA[key]) record[key] = TYPIA[key].specifier;
21
+ return JSON.stringify(parsed, null, 2);
22
+ };
23
+
24
+ const bundle = async ({ mode, repository, exceptions, transform }) => {
25
+ const root = `${__dirname}/../..`;
26
+ const assets = `${root}/assets`;
27
+ const template = `${assets}/${mode}`;
28
+
29
+ const clone = async () => {
30
+ // CLONE REPOSITORY
31
+ if (fs.existsSync(template))
32
+ await fs.promises.rm(template, { recursive: true });
33
+ else
34
+ try {
35
+ await fs.promises.mkdir(ASSETS);
36
+ } catch {}
37
+
38
+ cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
39
+ cwd: ASSETS,
40
+ });
41
+
42
+ // REMOVE VULNERABLE FILES
43
+ for (const location of exceptions ?? [])
44
+ await fs.promises.rm(`${template}/${location}`, { recursive: true });
45
+ };
46
+
47
+ const iterate = (collection) => async (location) => {
48
+ const directory = await fs.promises.readdir(location);
49
+ for (const file of directory) {
50
+ const absolute = location + "/" + file;
51
+ const stats = await fs.promises.stat(absolute);
52
+ if (stats.isDirectory()) await iterate(collection)(absolute);
53
+ else {
54
+ const content = await fs.promises.readFile(absolute, "utf-8");
55
+ collection[
56
+ (() => {
57
+ const str = absolute.replace(template, "");
58
+ return str[0] === "/" ? str.substring(1) : str;
59
+ })()
60
+ ] = content;
61
+ }
62
+ }
63
+ };
64
+
65
+ const archive = async (collection) => {
66
+ const name = `${mode.toUpperCase()}_TEMPLATE`;
67
+ const body = JSON.stringify(collection, null, 2);
68
+ const content = `export const ${name}: Record<string, string> = ${body}`;
69
+
70
+ try {
71
+ await fs.promises.mkdir(`${ROOT}/src/bundles`);
72
+ } catch {}
73
+ await fs.promises.writeFile(
74
+ `${ROOT}/src/bundles/${name}.ts`,
75
+ content,
76
+ "utf8",
77
+ );
78
+ };
79
+
80
+ const collection = {};
81
+ await clone();
82
+ await iterate(collection)(template);
83
+ if (transform)
84
+ for (const [key, value] of Object.entries(collection))
85
+ collection[key] = transform(key, value);
86
+ await archive(collection);
87
+ };
88
+
89
+ const main = async () => {
90
+ await bundle({
91
+ mode: "nest",
92
+ repository: "nestia-start",
93
+ exceptions: [
94
+ ".git",
95
+ ".github/dependabot.yml",
96
+ ".github/workflows/dependabot-automerge.yml",
97
+ "src/api/functional",
98
+ "src/controllers",
99
+ "src/MyModule.ts",
100
+ "src/providers",
101
+ "test/features",
102
+ ],
103
+ transform: (key, value) => {
104
+ if (key.endsWith("package.json")) return update(value);
105
+ return value;
106
+ },
107
+ });
108
+ await bundle({
109
+ mode: "sdk",
110
+ repository: "nestia-sdk-template",
111
+ exceptions: [
112
+ ".git",
113
+ ".github/dependabot.yml",
114
+ ".github/workflows/build.yml",
115
+ ".github/workflows/dependabot-automerge.yml",
116
+ "src/functional",
117
+ "src/structures",
118
+ "test/features",
119
+ ],
120
+ transform: (key, value) => {
121
+ if (key.endsWith("package.json")) return update(value);
122
+ return value;
123
+ },
124
+ });
125
+ };
126
+ main().catch((exp) => {
127
+ console.error(exp);
128
+ process.exit(-1);
129
+ });
File without changes
@@ -1,57 +1,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
- }
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,7 +1,7 @@
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
+ 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 "@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
- }
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
+ }