@nestia/migrate 0.21.4 → 4.2.0-dev.20241211-2
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 +87 -87
- package/lib/MigrateApplication.js +5 -3
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +66 -66
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +30 -30
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/executable/migrate.js +0 -0
- package/lib/index.mjs +97 -95
- package/lib/index.mjs.map +1 -1
- package/lib/utils/openapi-down-convert/converter.js +2 -2
- package/package.json +3 -3
- package/src/MigrateApplication.ts +107 -107
- package/src/analyzers/MigrateAnalyzer.ts +18 -18
- package/src/analyzers/MigrateControllerAnalyzer.ts +40 -40
- package/src/archivers/MigrateFileArchiver.ts +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +66 -66
- package/src/bundles/SDK_TEMPLATE.ts +30 -30
- package/src/executable/bundle.js +125 -125
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/internal/MigrateCommander.ts +86 -86
- package/src/internal/MigrateInquirer.ts +89 -89
- package/src/module.ts +8 -8
- package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
- package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
- package/src/programmers/MigrateApiProgrammer.ts +103 -103
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +324 -324
- package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
- package/src/programmers/MigrateDtoProgrammer.ts +87 -87
- package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
- package/src/programmers/MigrateE2eProgrammer.ts +34 -34
- package/src/programmers/MigrateImportProgrammer.ts +118 -118
- package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
- package/src/programmers/MigrateNestMethodProgrammer.ts +371 -371
- package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
- package/src/programmers/MigrateNestProgrammer.ts +79 -79
- package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
- package/src/structures/IHttpMigrateController.ts +8 -8
- package/src/structures/IHttpMigrateDto.ts +8 -8
- package/src/structures/IHttpMigrateFile.ts +5 -5
- package/src/structures/IHttpMigrateProgram.ts +27 -27
- package/src/structures/IHttpMigrateRoute.ts +1 -1
- package/src/structures/IHttpMigrateSchema.ts +4 -4
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/OpenApiTypeChecker.ts +73 -73
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +113 -113
- package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
- package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,40 +1,40 @@
|
|
1
|
-
import { IHttpMigrateRoute } from "@samchon/openapi";
|
2
|
-
|
3
|
-
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
4
|
-
import { MapUtil } from "../utils/MapUtil";
|
5
|
-
import { StringUtil } from "../utils/StringUtil";
|
6
|
-
|
7
|
-
export namespace MigrateControllerAnalyzer {
|
8
|
-
export const analyze = (
|
9
|
-
routes: IHttpMigrateRoute[],
|
10
|
-
): IHttpMigrateController[] => {
|
11
|
-
const endpoints: Map<string, IHttpMigrateRoute[]> = new Map();
|
12
|
-
for (const r of routes) {
|
13
|
-
const location: string = r.emendedPath
|
14
|
-
.split("/")
|
15
|
-
.filter((s) => s[0] !== ":")
|
16
|
-
.join("/");
|
17
|
-
MapUtil.take(endpoints)(location)(() => []).push(r);
|
18
|
-
}
|
19
|
-
const total: IHttpMigrateController[] = [...endpoints.entries()]
|
20
|
-
.filter(([_l, routes]) => !!routes.length)
|
21
|
-
.map(([path, routes]) => {
|
22
|
-
const name: string =
|
23
|
-
routes[0].accessor.slice(0, -1).map(StringUtil.capitalize).join("") +
|
24
|
-
"Controller";
|
25
|
-
const location: string = routes[0].accessor.slice(0, -2).join("/");
|
26
|
-
return {
|
27
|
-
name,
|
28
|
-
path,
|
29
|
-
location: "src/controllers/" + location,
|
30
|
-
routes,
|
31
|
-
};
|
32
|
-
});
|
33
|
-
for (const c of total)
|
34
|
-
if (c.name === "Controller")
|
35
|
-
c.name = StringUtil.escapeDuplicate([...total.map((c) => c.name)])(
|
36
|
-
"AppController",
|
37
|
-
);
|
38
|
-
return total;
|
39
|
-
};
|
40
|
-
}
|
1
|
+
import { IHttpMigrateRoute } from "@samchon/openapi";
|
2
|
+
|
3
|
+
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
4
|
+
import { MapUtil } from "../utils/MapUtil";
|
5
|
+
import { StringUtil } from "../utils/StringUtil";
|
6
|
+
|
7
|
+
export namespace MigrateControllerAnalyzer {
|
8
|
+
export const analyze = (
|
9
|
+
routes: IHttpMigrateRoute[],
|
10
|
+
): IHttpMigrateController[] => {
|
11
|
+
const endpoints: Map<string, IHttpMigrateRoute[]> = new Map();
|
12
|
+
for (const r of routes) {
|
13
|
+
const location: string = r.emendedPath
|
14
|
+
.split("/")
|
15
|
+
.filter((s) => s[0] !== ":")
|
16
|
+
.join("/");
|
17
|
+
MapUtil.take(endpoints)(location)(() => []).push(r);
|
18
|
+
}
|
19
|
+
const total: IHttpMigrateController[] = [...endpoints.entries()]
|
20
|
+
.filter(([_l, routes]) => !!routes.length)
|
21
|
+
.map(([path, routes]) => {
|
22
|
+
const name: string =
|
23
|
+
routes[0].accessor.slice(0, -1).map(StringUtil.capitalize).join("") +
|
24
|
+
"Controller";
|
25
|
+
const location: string = routes[0].accessor.slice(0, -2).join("/");
|
26
|
+
return {
|
27
|
+
name,
|
28
|
+
path,
|
29
|
+
location: "src/controllers/" + location,
|
30
|
+
routes,
|
31
|
+
};
|
32
|
+
});
|
33
|
+
for (const c of total)
|
34
|
+
if (c.name === "Controller")
|
35
|
+
c.name = StringUtil.escapeDuplicate([...total.map((c) => c.name)])(
|
36
|
+
"AppController",
|
37
|
+
);
|
38
|
+
return total;
|
39
|
+
};
|
40
|
+
}
|
@@ -1,38 +1,38 @@
|
|
1
|
-
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
2
|
-
|
3
|
-
export namespace MigrateFileArchiver {
|
4
|
-
export interface IOperator {
|
5
|
-
mkdir(path: string): Promise<void>;
|
6
|
-
writeFile(path: string, content: string): Promise<void>;
|
7
|
-
}
|
8
|
-
|
9
|
-
export const archive =
|
10
|
-
(operator: IOperator) =>
|
11
|
-
(output: string) =>
|
12
|
-
async (files: IHttpMigrateFile[]): Promise<void> => {
|
13
|
-
const visited: Set<string> = new Set();
|
14
|
-
for (const f of files) {
|
15
|
-
await mkdir(operator.mkdir)(output)(visited)(f.location);
|
16
|
-
await operator.writeFile(
|
17
|
-
[output, f.location, f.file].join("/"),
|
18
|
-
f.content,
|
19
|
-
);
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
const mkdir =
|
24
|
-
(creator: (path: string) => void) =>
|
25
|
-
(output: string) =>
|
26
|
-
(visited: Set<string>) =>
|
27
|
-
async (path: string): Promise<void> => {
|
28
|
-
const sequence: string[] = path
|
29
|
-
.split("/")
|
30
|
-
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
31
|
-
for (const s of sequence)
|
32
|
-
if (visited.has(s) === false)
|
33
|
-
try {
|
34
|
-
await creator([output, s].join("/"));
|
35
|
-
visited.add(s);
|
36
|
-
} catch {}
|
37
|
-
};
|
38
|
-
}
|
1
|
+
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
2
|
+
|
3
|
+
export namespace MigrateFileArchiver {
|
4
|
+
export interface IOperator {
|
5
|
+
mkdir(path: string): Promise<void>;
|
6
|
+
writeFile(path: string, content: string): Promise<void>;
|
7
|
+
}
|
8
|
+
|
9
|
+
export const archive =
|
10
|
+
(operator: IOperator) =>
|
11
|
+
(output: string) =>
|
12
|
+
async (files: IHttpMigrateFile[]): Promise<void> => {
|
13
|
+
const visited: Set<string> = new Set();
|
14
|
+
for (const f of files) {
|
15
|
+
await mkdir(operator.mkdir)(output)(visited)(f.location);
|
16
|
+
await operator.writeFile(
|
17
|
+
[output, f.location, f.file].join("/"),
|
18
|
+
f.content,
|
19
|
+
);
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const mkdir =
|
24
|
+
(creator: (path: string) => void) =>
|
25
|
+
(output: string) =>
|
26
|
+
(visited: Set<string>) =>
|
27
|
+
async (path: string): Promise<void> => {
|
28
|
+
const sequence: string[] = path
|
29
|
+
.split("/")
|
30
|
+
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
31
|
+
for (const s of sequence)
|
32
|
+
if (visited.has(s) === false)
|
33
|
+
try {
|
34
|
+
await creator([output, s].join("/"));
|
35
|
+
visited.add(s);
|
36
|
+
} catch {}
|
37
|
+
};
|
38
|
+
}
|