@nestia/migrate 0.7.6 → 0.7.8
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/lib/MigrateApplication.js +7 -4
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateAnalyzer.d.ts +2 -3
- package/lib/analyzers/MigrateAnalyzer.js +1 -5
- package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
- package/lib/analyzers/MigrateControllerAnalyzer.d.ts +2 -2
- package/lib/analyzers/MigrateControllerAnalyzer.js +22 -13
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
- package/lib/analyzers/MigrateMethodAnalyzer.d.ts +2 -2
- package/lib/analyzers/MigrateMethodAnalyzer.js +16 -16
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +2 -2
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/internal/MigrateCommander.js +12 -1
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/module.d.ts +8 -0
- package/lib/module.js +8 -0
- package/lib/module.js.map +1 -1
- package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiProgrammer.js +3 -3
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/MigrateImportProgrammer.js +5 -5
- package/lib/programmers/MigrateImportProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestModuleProgrammer.js +1 -1
- package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -1
- package/lib/programmers/MigrateSchemaProgrammer.d.ts +1 -1
- package/lib/structures/IMigrateDto.d.ts +1 -1
- package/lib/structures/IMigrateProgram.d.ts +20 -4
- package/lib/structures/IMigrateRoute.d.ts +1 -1
- package/lib/structures/ISwaggerComponents.d.ts +1 -1
- package/lib/structures/ISwaggerRoute.d.ts +1 -1
- package/lib/structures/{ISwaggeSchema.js → ISwaggerSchema.js} +1 -1
- package/lib/structures/ISwaggerSchema.js.map +1 -0
- package/lib/utils/SwaggerTypeChecker.d.ts +1 -1
- package/package.json +70 -68
- package/src/MigrateApplication.ts +54 -48
- package/src/analyzers/MigrateAnalyzer.ts +9 -13
- package/src/analyzers/MigrateControllerAnalyzer.ts +139 -122
- package/src/analyzers/MigrateMethodAnalyzer.ts +350 -348
- package/src/archivers/MigrateFileArchiver.ts +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +2 -2
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/executable/bundle.ts +109 -109
- package/src/internal/MigrateCommander.ts +62 -51
- package/src/module.ts +14 -4
- package/src/programmers/MigrateApiFileProgrammer.ts +53 -53
- package/src/programmers/MigrateApiFunctionProgrammer.ts +203 -203
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +430 -430
- package/src/programmers/MigrateApiProgrammer.ts +132 -132
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +328 -328
- package/src/programmers/MigrateDtoProgrammer.ts +78 -78
- package/src/programmers/MigrateImportProgrammer.ts +114 -116
- package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
- package/src/programmers/MigrateNestMethodProgrammer.ts +249 -249
- package/src/programmers/MigrateNestModuleProgrammer.ts +63 -62
- package/src/programmers/MigrateNestProgrammer.ts +74 -74
- package/src/programmers/MigrateSchemaProgrammer.ts +257 -257
- package/src/structures/IMigrateDto.ts +8 -8
- package/src/structures/IMigrateProgram.ts +25 -9
- package/src/structures/IMigrateRoute.ts +46 -46
- package/src/structures/ISwaggerComponents.ts +7 -7
- package/src/structures/ISwaggerRoute.ts +55 -55
- package/src/structures/{ISwaggeSchema.ts → ISwaggerSchema.ts} +90 -90
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/SwaggerTypeChecker.ts +67 -67
- package/lib/IMigrateConfig.d.ts +0 -4
- package/lib/IMigrateConfig.js +0 -3
- package/lib/IMigrateConfig.js.map +0 -1
- package/lib/structures/ISwaggeSchema.js.map +0 -1
- package/src/IMigrateConfig.ts +0 -4
- /package/lib/structures/{ISwaggeSchema.d.ts → ISwaggerSchema.d.ts} +0 -0
@@ -1,38 +1,38 @@
|
|
1
|
-
import { IMigrateFile } from "../structures/IMigrateFile";
|
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: IMigrateFile[]): 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 { IMigrateFile } from "../structures/IMigrateFile";
|
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: IMigrateFile[]): 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
|
+
}
|
@@ -47,7 +47,7 @@ export const NEST_TEMPLATE = [
|
|
47
47
|
{
|
48
48
|
"location": "",
|
49
49
|
"file": "package.json",
|
50
|
-
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.1\",\r\n \"@nestia/sdk\": \"^2.5.4\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.2.2\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.5.4\",\r\n \"@nestia/fetcher\": \"^2.5.4\",\r\n \"@nestjs/common\": \"^10.3.1\",\r\n \"@nestjs/core\": \"^10.3.1\",\r\n \"@nestjs/platform-express\": \"^10.3.1\",\r\n \"commander\": \"10.0.0\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"inquirer\": \"8.2.5\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.4.
|
50
|
+
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.1\",\r\n \"@nestia/sdk\": \"^2.5.4\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.2.2\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.5.4\",\r\n \"@nestia/fetcher\": \"^2.5.4\",\r\n \"@nestjs/common\": \"^10.3.1\",\r\n \"@nestjs/core\": \"^10.3.1\",\r\n \"@nestjs/platform-express\": \"^10.3.1\",\r\n \"commander\": \"10.0.0\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"inquirer\": \"8.2.5\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.4.6\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"location": "packages/api",
|
@@ -62,7 +62,7 @@ export const NEST_TEMPLATE = [
|
|
62
62
|
{
|
63
63
|
"location": "packages/api",
|
64
64
|
"file": "package.json",
|
65
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.5.4\",\r\n \"typia\": \"^5.4.
|
65
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.5.4\",\r\n \"typia\": \"^5.4.6\"\r\n }\r\n}"
|
66
66
|
},
|
67
67
|
{
|
68
68
|
"location": "packages/api",
|
@@ -12,7 +12,7 @@ export const SDK_TEMPLATE = [
|
|
12
12
|
{
|
13
13
|
"location": "",
|
14
14
|
"file": "package.json",
|
15
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"rimraf lib && tsc\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.5.4\",\r\n \"typia\": \"^5.4.
|
15
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"rimraf lib && tsc\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.5.4\",\r\n \"typia\": \"^5.4.6\"\r\n }\r\n}"
|
16
16
|
},
|
17
17
|
{
|
18
18
|
"location": "",
|
package/src/executable/bundle.ts
CHANGED
@@ -1,109 +1,109 @@
|
|
1
|
-
import cp from "child_process";
|
2
|
-
import fs from "fs";
|
3
|
-
|
4
|
-
import { IMigrateFile } from "../structures/IMigrateFile";
|
5
|
-
|
6
|
-
const ROOT: string = `${__dirname}/../..`;
|
7
|
-
const ASSETS: string = `${ROOT}/assets`;
|
8
|
-
|
9
|
-
const bundle = async (props: {
|
10
|
-
mode: "nest" | "sdk";
|
11
|
-
repository: string;
|
12
|
-
exceptions?: string[];
|
13
|
-
}): Promise<void> => {
|
14
|
-
const root: string = `${__dirname}/../..`;
|
15
|
-
const assets: string = `${root}/assets`;
|
16
|
-
const template: string = `${assets}/${props.mode}`;
|
17
|
-
|
18
|
-
const clone = async () => {
|
19
|
-
// CLONE REPOSITORY
|
20
|
-
if (fs.existsSync(template))
|
21
|
-
await fs.promises.rm(template, { recursive: true });
|
22
|
-
else
|
23
|
-
try {
|
24
|
-
await fs.promises.mkdir(ASSETS);
|
25
|
-
} catch {}
|
26
|
-
|
27
|
-
cp.execSync(
|
28
|
-
`git clone https://github.com/samchon/${props.repository} ${props.mode}`,
|
29
|
-
{
|
30
|
-
cwd: ASSETS,
|
31
|
-
},
|
32
|
-
);
|
33
|
-
|
34
|
-
// REMOVE VUNLERABLE FILES
|
35
|
-
for (const location of props.exceptions ?? [])
|
36
|
-
await fs.promises.rm(`${template}/${location}`, { recursive: true });
|
37
|
-
};
|
38
|
-
|
39
|
-
const iterate = (collection: IMigrateFile[]) => async (location: string) => {
|
40
|
-
const directory: string[] = await fs.promises.readdir(location);
|
41
|
-
for (const file of directory) {
|
42
|
-
const absolute: string = location + "/" + file;
|
43
|
-
const stats: fs.Stats = await fs.promises.stat(absolute);
|
44
|
-
if (stats.isDirectory()) await iterate(collection)(absolute);
|
45
|
-
else {
|
46
|
-
const content: string = await fs.promises.readFile(absolute, "utf-8");
|
47
|
-
collection.push({
|
48
|
-
location: (() => {
|
49
|
-
const str: string = location.replace(template, "");
|
50
|
-
return str[0] === "/" ? str.substring(1) : str;
|
51
|
-
})(),
|
52
|
-
file,
|
53
|
-
content,
|
54
|
-
});
|
55
|
-
}
|
56
|
-
}
|
57
|
-
};
|
58
|
-
|
59
|
-
const archive = async (collection: IMigrateFile[]): Promise<void> => {
|
60
|
-
const name: string = `${props.mode.toUpperCase()}_TEMPLATE`;
|
61
|
-
const body: string = JSON.stringify(collection, null, 2);
|
62
|
-
const content: string = `export const ${name} = ${body}`;
|
63
|
-
|
64
|
-
try {
|
65
|
-
await fs.promises.mkdir(`${ROOT}/src/bundles`);
|
66
|
-
} catch {}
|
67
|
-
await fs.promises.writeFile(
|
68
|
-
`${ROOT}/src/bundles/${name}.ts`,
|
69
|
-
content,
|
70
|
-
"utf8",
|
71
|
-
);
|
72
|
-
};
|
73
|
-
|
74
|
-
const collection: IMigrateFile[] = [];
|
75
|
-
await clone();
|
76
|
-
await iterate(collection)(template);
|
77
|
-
await archive(collection);
|
78
|
-
};
|
79
|
-
|
80
|
-
const main = async (): Promise<void> => {
|
81
|
-
await bundle({
|
82
|
-
mode: "nest",
|
83
|
-
repository: "nestia-start",
|
84
|
-
exceptions: [
|
85
|
-
".git",
|
86
|
-
".github/dependabot.yml",
|
87
|
-
"src/api/functional",
|
88
|
-
"src/controllers",
|
89
|
-
"src/MyModule.ts",
|
90
|
-
"src/providers",
|
91
|
-
"test/features",
|
92
|
-
],
|
93
|
-
});
|
94
|
-
await bundle({
|
95
|
-
mode: "sdk",
|
96
|
-
repository: "nestia-sdk-template",
|
97
|
-
exceptions: [
|
98
|
-
".git",
|
99
|
-
".github/dependabot.yml",
|
100
|
-
".github/workflows/build.yml",
|
101
|
-
"src/functional",
|
102
|
-
"src/structures",
|
103
|
-
],
|
104
|
-
});
|
105
|
-
};
|
106
|
-
main().catch((exp) => {
|
107
|
-
console.error(exp);
|
108
|
-
process.exit(-1);
|
109
|
-
});
|
1
|
+
import cp from "child_process";
|
2
|
+
import fs from "fs";
|
3
|
+
|
4
|
+
import { IMigrateFile } from "../structures/IMigrateFile";
|
5
|
+
|
6
|
+
const ROOT: string = `${__dirname}/../..`;
|
7
|
+
const ASSETS: string = `${ROOT}/assets`;
|
8
|
+
|
9
|
+
const bundle = async (props: {
|
10
|
+
mode: "nest" | "sdk";
|
11
|
+
repository: string;
|
12
|
+
exceptions?: string[];
|
13
|
+
}): Promise<void> => {
|
14
|
+
const root: string = `${__dirname}/../..`;
|
15
|
+
const assets: string = `${root}/assets`;
|
16
|
+
const template: string = `${assets}/${props.mode}`;
|
17
|
+
|
18
|
+
const clone = async () => {
|
19
|
+
// CLONE REPOSITORY
|
20
|
+
if (fs.existsSync(template))
|
21
|
+
await fs.promises.rm(template, { recursive: true });
|
22
|
+
else
|
23
|
+
try {
|
24
|
+
await fs.promises.mkdir(ASSETS);
|
25
|
+
} catch {}
|
26
|
+
|
27
|
+
cp.execSync(
|
28
|
+
`git clone https://github.com/samchon/${props.repository} ${props.mode}`,
|
29
|
+
{
|
30
|
+
cwd: ASSETS,
|
31
|
+
},
|
32
|
+
);
|
33
|
+
|
34
|
+
// REMOVE VUNLERABLE FILES
|
35
|
+
for (const location of props.exceptions ?? [])
|
36
|
+
await fs.promises.rm(`${template}/${location}`, { recursive: true });
|
37
|
+
};
|
38
|
+
|
39
|
+
const iterate = (collection: IMigrateFile[]) => async (location: string) => {
|
40
|
+
const directory: string[] = await fs.promises.readdir(location);
|
41
|
+
for (const file of directory) {
|
42
|
+
const absolute: string = location + "/" + file;
|
43
|
+
const stats: fs.Stats = await fs.promises.stat(absolute);
|
44
|
+
if (stats.isDirectory()) await iterate(collection)(absolute);
|
45
|
+
else {
|
46
|
+
const content: string = await fs.promises.readFile(absolute, "utf-8");
|
47
|
+
collection.push({
|
48
|
+
location: (() => {
|
49
|
+
const str: string = location.replace(template, "");
|
50
|
+
return str[0] === "/" ? str.substring(1) : str;
|
51
|
+
})(),
|
52
|
+
file,
|
53
|
+
content,
|
54
|
+
});
|
55
|
+
}
|
56
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
const archive = async (collection: IMigrateFile[]): Promise<void> => {
|
60
|
+
const name: string = `${props.mode.toUpperCase()}_TEMPLATE`;
|
61
|
+
const body: string = JSON.stringify(collection, null, 2);
|
62
|
+
const content: string = `export const ${name} = ${body}`;
|
63
|
+
|
64
|
+
try {
|
65
|
+
await fs.promises.mkdir(`${ROOT}/src/bundles`);
|
66
|
+
} catch {}
|
67
|
+
await fs.promises.writeFile(
|
68
|
+
`${ROOT}/src/bundles/${name}.ts`,
|
69
|
+
content,
|
70
|
+
"utf8",
|
71
|
+
);
|
72
|
+
};
|
73
|
+
|
74
|
+
const collection: IMigrateFile[] = [];
|
75
|
+
await clone();
|
76
|
+
await iterate(collection)(template);
|
77
|
+
await archive(collection);
|
78
|
+
};
|
79
|
+
|
80
|
+
const main = async (): Promise<void> => {
|
81
|
+
await bundle({
|
82
|
+
mode: "nest",
|
83
|
+
repository: "nestia-start",
|
84
|
+
exceptions: [
|
85
|
+
".git",
|
86
|
+
".github/dependabot.yml",
|
87
|
+
"src/api/functional",
|
88
|
+
"src/controllers",
|
89
|
+
"src/MyModule.ts",
|
90
|
+
"src/providers",
|
91
|
+
"test/features",
|
92
|
+
],
|
93
|
+
});
|
94
|
+
await bundle({
|
95
|
+
mode: "sdk",
|
96
|
+
repository: "nestia-sdk-template",
|
97
|
+
exceptions: [
|
98
|
+
".git",
|
99
|
+
".github/dependabot.yml",
|
100
|
+
".github/workflows/build.yml",
|
101
|
+
"src/functional",
|
102
|
+
"src/structures",
|
103
|
+
],
|
104
|
+
});
|
105
|
+
};
|
106
|
+
main().catch((exp) => {
|
107
|
+
console.error(exp);
|
108
|
+
process.exit(-1);
|
109
|
+
});
|
@@ -1,51 +1,62 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import path from "path";
|
3
|
-
|
4
|
-
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
const
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
import fs from "fs";
|
2
|
+
import path from "path";
|
3
|
+
import { format } from "prettier";
|
4
|
+
|
5
|
+
import { MigrateFileArchiver } from "../archivers/MigrateFileArchiver";
|
6
|
+
import { MigrateApplication } from "../module";
|
7
|
+
import { ISwagger } from "../structures/ISwagger";
|
8
|
+
import { MigrateInquirer } from "./MigrateInquirer";
|
9
|
+
|
10
|
+
export namespace MigrateCommander {
|
11
|
+
export const main = async (): Promise<void> => {
|
12
|
+
const resolve = (str: string | undefined) =>
|
13
|
+
str ? path.resolve(str).split("\\").join("/") : undefined;
|
14
|
+
const options: MigrateInquirer.IOutput = await MigrateInquirer.parse();
|
15
|
+
|
16
|
+
// VALIDATE OUTPUT DIRECTORY
|
17
|
+
const parent: string = resolve(options.output + "/..")!;
|
18
|
+
if (fs.existsSync(options.output)) halt("Output directory alreay exists.");
|
19
|
+
else if (fs.existsSync(parent) === false)
|
20
|
+
halt("Output directory's parent directory does not exist.");
|
21
|
+
else if (fs.statSync(parent).isDirectory() === false)
|
22
|
+
halt("Output directory's parent is not a directory.");
|
23
|
+
|
24
|
+
// READ SWAGGER
|
25
|
+
const swagger: ISwagger = (() => {
|
26
|
+
if (fs.existsSync(options.input) === false)
|
27
|
+
halt("Unable to find the input swagger.json file.");
|
28
|
+
const stats: fs.Stats = fs.statSync(options.input);
|
29
|
+
if (stats.isFile() === false)
|
30
|
+
halt("The input swagger.json is not a file.");
|
31
|
+
const content: string = fs.readFileSync(options.input, "utf-8");
|
32
|
+
const swagger: ISwagger = JSON.parse(content);
|
33
|
+
return swagger;
|
34
|
+
})();
|
35
|
+
|
36
|
+
const app: MigrateApplication = new MigrateApplication(swagger);
|
37
|
+
const { files } =
|
38
|
+
options.mode === "nest"
|
39
|
+
? app.nest(options.simulate)
|
40
|
+
: app.sdk(options.simulate);
|
41
|
+
await MigrateFileArchiver.archive({
|
42
|
+
mkdir: fs.promises.mkdir,
|
43
|
+
writeFile: async (file, content) =>
|
44
|
+
fs.promises.writeFile(file, await beautify(content), "utf-8"),
|
45
|
+
})(options.output)(files);
|
46
|
+
};
|
47
|
+
|
48
|
+
const beautify = async (script: string): Promise<string> => {
|
49
|
+
try {
|
50
|
+
return await format(script, {
|
51
|
+
parser: "typescript",
|
52
|
+
});
|
53
|
+
} catch {
|
54
|
+
return script;
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
const halt = (desc: string): never => {
|
59
|
+
console.error(desc);
|
60
|
+
process.exit(-1);
|
61
|
+
};
|
62
|
+
}
|
package/src/module.ts
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
export * from "./MigrateApplication";
|
2
|
-
|
3
|
-
export * from "./
|
4
|
-
|
1
|
+
export * from "./MigrateApplication";
|
2
|
+
|
3
|
+
export * from "./analyzers/MigrateAnalyzer";
|
4
|
+
|
5
|
+
export * from "./archivers/MigrateFileArchiver";
|
6
|
+
|
7
|
+
export * from "./structures/ISwagger";
|
8
|
+
export * from "./structures/ISwaggerComponents";
|
9
|
+
export * from "./structures/ISwaggerInfo";
|
10
|
+
export * from "./structures/ISwaggerRoute";
|
11
|
+
export * from "./structures/ISwaggerSecurity";
|
12
|
+
export * from "./structures/ISwaggerSchema";
|
13
|
+
export * from "./structures/IMigrateProgram";
|
14
|
+
export * from "./structures/IMigrateSchema";
|
@@ -1,53 +1,53 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
import {
|
4
|
-
import { IMigrateController } from "../structures/IMigrateController";
|
5
|
-
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
6
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
7
|
-
import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
|
8
|
-
import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
|
9
|
-
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
10
|
-
|
11
|
-
export namespace MigrateApiFileProgrammer {
|
12
|
-
export interface IProps {
|
13
|
-
namespace: string[];
|
14
|
-
entries: IEntry[];
|
15
|
-
children: Set<string>;
|
16
|
-
}
|
17
|
-
export interface IEntry {
|
18
|
-
controller: IMigrateController;
|
19
|
-
route: IMigrateRoute;
|
20
|
-
alias: string;
|
21
|
-
}
|
22
|
-
|
23
|
-
export const write =
|
24
|
-
(config:
|
25
|
-
(components: ISwaggerComponents) =>
|
26
|
-
(props: IProps): ts.Statement[] => {
|
27
|
-
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
28
|
-
const statements: ts.Statement[] = props.entries
|
29
|
-
.map((p) => [
|
30
|
-
MigrateApiFunctionProgrammer.write(config)(components)(importer)(p),
|
31
|
-
MigrateApiNamespaceProgrammer.write(config)(components)(importer)(p),
|
32
|
-
])
|
33
|
-
.flat();
|
34
|
-
return [
|
35
|
-
...importer.toStatements(
|
36
|
-
(ref) =>
|
37
|
-
`../${"../".repeat(props.namespace.length)}structures/${ref}`,
|
38
|
-
),
|
39
|
-
...[...props.children].map((child) =>
|
40
|
-
ts.factory.createExportDeclaration(
|
41
|
-
undefined,
|
42
|
-
false,
|
43
|
-
ts.factory.createNamespaceExport(
|
44
|
-
ts.factory.createIdentifier(child),
|
45
|
-
),
|
46
|
-
ts.factory.createStringLiteral(`./${child}`),
|
47
|
-
undefined,
|
48
|
-
),
|
49
|
-
),
|
50
|
-
...statements,
|
51
|
-
];
|
52
|
-
};
|
53
|
-
}
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { IMigrateProgram } from "../module";
|
4
|
+
import { IMigrateController } from "../structures/IMigrateController";
|
5
|
+
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
6
|
+
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
7
|
+
import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
|
8
|
+
import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
|
9
|
+
import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
|
10
|
+
|
11
|
+
export namespace MigrateApiFileProgrammer {
|
12
|
+
export interface IProps {
|
13
|
+
namespace: string[];
|
14
|
+
entries: IEntry[];
|
15
|
+
children: Set<string>;
|
16
|
+
}
|
17
|
+
export interface IEntry {
|
18
|
+
controller: IMigrateController;
|
19
|
+
route: IMigrateRoute;
|
20
|
+
alias: string;
|
21
|
+
}
|
22
|
+
|
23
|
+
export const write =
|
24
|
+
(config: IMigrateProgram.IConfig) =>
|
25
|
+
(components: ISwaggerComponents) =>
|
26
|
+
(props: IProps): ts.Statement[] => {
|
27
|
+
const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
|
28
|
+
const statements: ts.Statement[] = props.entries
|
29
|
+
.map((p) => [
|
30
|
+
MigrateApiFunctionProgrammer.write(config)(components)(importer)(p),
|
31
|
+
MigrateApiNamespaceProgrammer.write(config)(components)(importer)(p),
|
32
|
+
])
|
33
|
+
.flat();
|
34
|
+
return [
|
35
|
+
...importer.toStatements(
|
36
|
+
(ref) =>
|
37
|
+
`../${"../".repeat(props.namespace.length)}structures/${ref}`,
|
38
|
+
),
|
39
|
+
...[...props.children].map((child) =>
|
40
|
+
ts.factory.createExportDeclaration(
|
41
|
+
undefined,
|
42
|
+
false,
|
43
|
+
ts.factory.createNamespaceExport(
|
44
|
+
ts.factory.createIdentifier(child),
|
45
|
+
),
|
46
|
+
ts.factory.createStringLiteral(`./${child}`),
|
47
|
+
undefined,
|
48
|
+
),
|
49
|
+
),
|
50
|
+
...statements,
|
51
|
+
];
|
52
|
+
};
|
53
|
+
}
|