@nestia/migrate 0.1.4 → 0.1.6
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/NestiaMigrateApplication.d.ts +3 -3
- package/lib/NestiaMigrateApplication.js +3 -15
- package/lib/NestiaMigrateApplication.js.map +1 -1
- package/lib/archivers/FileArchiver.d.ts +3 -3
- package/lib/archivers/FileArchiver.js +8 -17
- package/lib/archivers/FileArchiver.js.map +1 -1
- package/lib/bundles/TEMPLATE.js +5 -5
- package/lib/bundles/TEMPLATE.js.map +1 -1
- package/lib/executable/migrate.js +19 -27
- package/lib/executable/migrate.js.map +1 -1
- package/lib/programmers/ControllerProgrammer.js +14 -4
- package/lib/programmers/ControllerProgrammer.js.map +1 -1
- package/lib/programmers/RouteProgrammer.js +21 -8
- package/lib/programmers/RouteProgrammer.js.map +1 -1
- package/lib/structures/IMigrateRoute.d.ts +6 -2
- package/package.json +14 -5
- package/src/NestiaMigrateApplication.ts +4 -7
- package/src/archivers/FileArchiver.ts +9 -9
- package/src/bundles/TEMPLATE.ts +5 -5
- package/src/executable/migrate.ts +19 -17
- package/src/programmers/ControllerProgrammer.ts +17 -4
- package/src/programmers/RouteProgrammer.ts +32 -11
- package/src/structures/IMigrateRoute.ts +6 -2
- package/lib/test/index.d.ts +0 -1
- package/lib/test/index.js +0 -45
- package/lib/test/index.js.map +0 -1
- package/src/test/index.ts +0 -38
@@ -8,11 +8,11 @@ export declare class NestiaMigrateApplication {
|
|
8
8
|
constructor(swagger: ISwagger);
|
9
9
|
analyze(): IMigrateProgram;
|
10
10
|
write(): IMigrateFile[];
|
11
|
-
generate: (archiver: NestiaMigrateApplication.IArchiver) => (output: string) =>
|
11
|
+
generate: (archiver: NestiaMigrateApplication.IArchiver) => (output: string) => void;
|
12
12
|
}
|
13
13
|
export declare namespace NestiaMigrateApplication {
|
14
14
|
interface IArchiver {
|
15
|
-
mkdir: (path: string) =>
|
16
|
-
writeFile: (path: string, content: string) =>
|
15
|
+
mkdir: (path: string) => void;
|
16
|
+
writeFile: (path: string, content: string) => void;
|
17
17
|
}
|
18
18
|
}
|
@@ -1,13 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
@@ -19,14 +10,11 @@ const TEMPLATE_1 = require("./bundles/TEMPLATE");
|
|
19
10
|
const MigrateProgrammer_1 = require("./programmers/MigrateProgrammer");
|
20
11
|
class NestiaMigrateApplication {
|
21
12
|
constructor(swagger) {
|
22
|
-
this.generate = (archiver) => (output) =>
|
13
|
+
this.generate = (archiver) => (output) => {
|
23
14
|
const program = this.analyze();
|
24
15
|
const files = MigrateProgrammer_1.MigrateProgrammer.write(program);
|
25
|
-
|
26
|
-
|
27
|
-
...TEMPLATE_1.TEMPLATE,
|
28
|
-
]);
|
29
|
-
});
|
16
|
+
FileArchiver_1.FileArchiver.archive(archiver)(output)([...files, ...TEMPLATE_1.TEMPLATE]);
|
17
|
+
};
|
30
18
|
this.swagger = (input => {
|
31
19
|
const __is = input => {
|
32
20
|
const $join = typia_1.default.assert.join;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApplication.js","sourceRoot":"","sources":["../src/NestiaMigrateApplication.ts"],"names":[],"mappings":"
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I,CAAC,OAAO,CAAC;IACxB,CAAC;IAEM,KAAK;QACR,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;YACrB,MAAM,OAAO,GAAoB,IAAI,CAAC,OAAO,EAAE,CAAC;YAChD,IAAI,CAAC,KAAK,GAAG,qCAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACjD;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CASJ;AAhCD,4DAgCC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { IMigrateFile } from "../structures/IMigrateFile";
|
2
2
|
export declare namespace FileArchiver {
|
3
3
|
interface IOperator {
|
4
|
-
mkdir(path: string):
|
5
|
-
writeFile(path: string, content: string):
|
4
|
+
mkdir(path: string): void;
|
5
|
+
writeFile(path: string, content: string): void;
|
6
6
|
}
|
7
|
-
const archive: (operator: IOperator) => (output: string) => (files: IMigrateFile[]) =>
|
7
|
+
const archive: (operator: IOperator) => (output: string) => (files: IMigrateFile[]) => void;
|
8
8
|
}
|
@@ -1,36 +1,27 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
3
|
exports.FileArchiver = void 0;
|
13
4
|
var FileArchiver;
|
14
5
|
(function (FileArchiver) {
|
15
|
-
FileArchiver.archive = (operator) => (output) => (files) =>
|
16
|
-
|
6
|
+
FileArchiver.archive = (operator) => (output) => (files) => {
|
7
|
+
operator.mkdir(output);
|
17
8
|
const visited = new Set();
|
18
9
|
for (const f of files) {
|
19
|
-
|
20
|
-
|
10
|
+
mkdir(operator.mkdir)(output)(visited)(f.location);
|
11
|
+
operator.writeFile([output, f.location, f.file].join("/"), f.content);
|
21
12
|
}
|
22
|
-
}
|
23
|
-
const mkdir = (creator) => (output) => (visited) => (path) =>
|
13
|
+
};
|
14
|
+
const mkdir = (creator) => (output) => (visited) => (path) => {
|
24
15
|
const sequence = path
|
25
16
|
.split("/")
|
26
17
|
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
27
18
|
for (const s of sequence)
|
28
19
|
if (visited.has(s) === false)
|
29
20
|
try {
|
30
|
-
|
21
|
+
creator([output, s].join("/"));
|
31
22
|
visited.add(s);
|
32
23
|
}
|
33
24
|
catch (_a) { }
|
34
|
-
}
|
25
|
+
};
|
35
26
|
})(FileArchiver || (exports.FileArchiver = FileArchiver = {}));
|
36
27
|
//# sourceMappingURL=FileArchiver.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileArchiver.js","sourceRoot":"","sources":["../../src/archivers/FileArchiver.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"FileArchiver.js","sourceRoot":"","sources":["../../src/archivers/FileArchiver.ts"],"names":[],"mappings":";;;AAEA,IAAiB,YAAY,CAoC5B;AApCD,WAAiB,YAAY;IAMZ,oBAAO,GAChB,CAAC,QAAmB,EAAE,EAAE,CACxB,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,KAAqB,EAAQ,EAAE;QAC5B,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvB,MAAM,OAAO,GAAgB,IAAI,GAAG,EAAE,CAAC;QACvC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;YACnB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YACnD,QAAQ,CAAC,SAAS,CACd,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACtC,CAAC,CAAC,OAAO,CACZ,CAAC;SACL;IACL,CAAC,CAAC;IAEN,MAAM,KAAK,GACP,CAAC,OAA+B,EAAE,EAAE,CACpC,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,OAAoB,EAAE,EAAE,CACzB,CAAC,IAAY,EAAQ,EAAE;QACnB,MAAM,QAAQ,GAAa,IAAI;aAC1B,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,KAAK,MAAM,CAAC,IAAI,QAAQ;YACpB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK;gBACxB,IAAI;oBACA,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC/B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAClB;gBAAC,WAAM,GAAE;IACtB,CAAC,CAAC;AACV,CAAC,EApCgB,YAAY,4BAAZ,YAAY,QAoC5B"}
|
package/lib/bundles/TEMPLATE.js
CHANGED
@@ -25,7 +25,7 @@ exports.TEMPLATE = [
|
|
25
25
|
{
|
26
26
|
"location": "",
|
27
27
|
"file": ".prettierignore",
|
28
|
-
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nREADME.md\r\ntsconfig.json"
|
28
|
+
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nsrc/api/utils/NestiaSimulator.ts\r\nREADME.md\r\ntsconfig.json"
|
29
29
|
},
|
30
30
|
{
|
31
31
|
"location": "/.vscode",
|
@@ -50,7 +50,7 @@ exports.TEMPLATE = [
|
|
50
50
|
{
|
51
51
|
"location": "",
|
52
52
|
"file": "package.json",
|
53
|
-
"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 \"----------------------------------------------\": \"\",\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\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\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-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.
|
53
|
+
"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 \"----------------------------------------------\": \"\",\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\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\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-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.9\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^3.3.1\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^5.40.0\",\r\n \"@typescript-eslint/parser\": \"^5.40.0\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"eslint-plugin-deprecation\": \"^1.4.1\",\r\n \"nestia\": \"^4.3.2\",\r\n \"prettier\": \"^2.7.1\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.0\",\r\n \"typescript\": \"^5.1.3\",\r\n \"typescript-transform-paths\": \"^3.4.6\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^1.4.3\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^4.1.4\",\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}"
|
54
54
|
},
|
55
55
|
{
|
56
56
|
"location": "/packages/api",
|
@@ -60,7 +60,7 @@ exports.TEMPLATE = [
|
|
60
60
|
{
|
61
61
|
"location": "/packages/api",
|
62
62
|
"file": "package.json",
|
63
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.
|
63
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.4\"\r\n }\r\n}\r\n"
|
64
64
|
},
|
65
65
|
{
|
66
66
|
"location": "/packages/api",
|
@@ -85,12 +85,12 @@ exports.TEMPLATE = [
|
|
85
85
|
{
|
86
86
|
"location": "/src",
|
87
87
|
"file": "Backend.ts",
|
88
|
-
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(
|
88
|
+
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(Configuration.API_PORT());\r\n\r\n //----\r\n // POST-PROCESSES\r\n //----\r\n // INFORM TO THE PM2\r\n if (process.send) process.send(\"ready\");\r\n\r\n // WHEN KILL COMMAND COMES\r\n process.on(\"SIGINT\", async () => {\r\n await this.close();\r\n process.exit(0);\r\n });\r\n }\r\n\r\n public async close(): Promise<void> {\r\n if (this.application_ === undefined) return;\r\n\r\n // DO CLOSE\r\n await this.application_.close();\r\n delete this.application_;\r\n }\r\n}\r\n"
|
89
89
|
},
|
90
90
|
{
|
91
91
|
"location": "/src",
|
92
92
|
"file": "Configuration.ts",
|
93
|
-
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT =
|
93
|
+
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT = () => 37001;\r\n\r\n export const ROOT = __filename.includes(\r\n path.join(\"bin\", \"src\", \"ShoppingConfiguration\"),\r\n )\r\n ? path.resolve(__dirname + \"/../..\")\r\n : path.resolve(__dirname + \"/..\");\r\n}\r\n"
|
94
94
|
},
|
95
95
|
{
|
96
96
|
"location": "/src/executable",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,6lCAA6lC;KAC3mC;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,qtBAAqtB;KACnuB;IACD;QACI,UAAU,EAAE,oBAAoB;QAChC,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,+lBAA+lB;KAC7mB;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,sFAAsF;KACpG;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,6lCAA6lC;KAC3mC;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,qtBAAqtB;KACnuB;IACD;QACI,UAAU,EAAE,oBAAoB;QAChC,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,+lBAA+lB;KAC7mB;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,sFAAsF;KACpG;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,iIAAiI;KAC/I;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,isBAAisB;KAC/sB;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,mQAAmQ;KACjR;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC/nC;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,kBAAkB;QAC1B,SAAS,EAAE,4hBAA4hB;KAC1iB;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,krFAAkrF;KAChsF;IACD;QACI,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,8mCAA8mC;KAC5nC;IACD;QACI,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,uoBAAuoB;KACrpB;IACD;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this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10
|
-
});
|
11
|
-
};
|
12
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
13
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
14
5
|
};
|
15
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
16
7
|
const fs_1 = __importDefault(require("fs"));
|
8
|
+
const path_1 = __importDefault(require("path"));
|
17
9
|
const NestiaMigrateApplication_1 = require("../NestiaMigrateApplication");
|
18
10
|
const SetupWizard_1 = require("../utils/SetupWizard");
|
19
11
|
const USAGE = `Wrong command has been detected. Use like below:
|
@@ -26,40 +18,40 @@ function halt(desc) {
|
|
26
18
|
console.error(desc);
|
27
19
|
process.exit(-1);
|
28
20
|
}
|
29
|
-
const main = (argv) =>
|
30
|
-
const
|
31
|
-
const
|
21
|
+
const main = (argv) => {
|
22
|
+
const resolve = (str) => str ? path_1.default.resolve(str).split("\\").join("/") : undefined;
|
23
|
+
const input = resolve(argv[0]);
|
24
|
+
const output = resolve(argv[1]);
|
32
25
|
// VALIDATE ARGUMENTS
|
33
26
|
if (input === undefined || output === undefined)
|
34
27
|
halt(USAGE);
|
35
|
-
|
28
|
+
// VALIDATE OUTPUT DIRECTORY
|
29
|
+
const parent = resolve(output + "/..");
|
30
|
+
if (fs_1.default.existsSync(output))
|
36
31
|
halt("Output directory alreay exists.");
|
37
|
-
else if (fs_1.default.existsSync(
|
32
|
+
else if (fs_1.default.existsSync(parent) === false)
|
38
33
|
halt("Output directory's parent directory does not exist.");
|
39
|
-
else if (
|
34
|
+
else if (fs_1.default.statSync(parent).isDirectory() === false)
|
40
35
|
halt("Output directory's parent is not a directory.");
|
41
36
|
// READ SWAGGER
|
42
|
-
const swagger =
|
37
|
+
const swagger = (() => {
|
43
38
|
if (fs_1.default.existsSync(input) === false)
|
44
39
|
halt("Unable to find the input swagger.json file.");
|
45
|
-
const stats =
|
40
|
+
const stats = fs_1.default.statSync(input);
|
46
41
|
if (stats.isFile() === false)
|
47
42
|
halt("The input swagger.json is not a file.");
|
48
|
-
const content =
|
43
|
+
const content = fs_1.default.readFileSync(input, "utf-8");
|
49
44
|
const swagger = JSON.parse(content);
|
50
45
|
return swagger;
|
51
|
-
})
|
46
|
+
})();
|
52
47
|
// DO GENERATE
|
53
48
|
const app = new NestiaMigrateApplication_1.NestiaMigrateApplication(swagger);
|
54
|
-
|
55
|
-
mkdir: fs_1.default.
|
56
|
-
writeFile: (path, content) => fs_1.default.
|
49
|
+
app.generate({
|
50
|
+
mkdir: fs_1.default.mkdirSync,
|
51
|
+
writeFile: (path, content) => fs_1.default.writeFileSync(path, content, "utf8"),
|
57
52
|
})(output);
|
58
53
|
// RUN SCRIPTS
|
59
54
|
SetupWizard_1.SetupWizard.setup(output);
|
60
|
-
}
|
61
|
-
main(process.argv.slice(2))
|
62
|
-
console.log(exp);
|
63
|
-
process.exit(-1);
|
64
|
-
});
|
55
|
+
};
|
56
|
+
main(process.argv.slice(2));
|
65
57
|
//# sourceMappingURL=migrate.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/executable/migrate.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/executable/migrate.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AACpB,gDAAwB;AAExB,0EAAuE;AAEvE,sDAAmD;AAEnD,MAAM,KAAK,GAAG;;;;;CAKb,CAAC;AAEF,SAAS,IA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AAK,CAAC,CAAC;QAC3C,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,KAAK;YACxB,IAAI,CAAC,uCAAuC,CAAC,CAAC;QAClD,MAAM,OAAO,GAAW,YAAE,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,OAAO,GAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC,EAAE,CAAC;IAEL,cAAc;IACd,MAAM,GAAG,GAAG,IAAI,mDAAwB,CAAC,OAAO,CAAC,CAAC;IAClD,GAAG,CAAC,QAAQ,CAAC;QACT,KAAK,EAAE,YAAE,CAAC,SAAS;QACnB,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,YAAE,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;KACxE,CAAC,CAAC,MAAM,CAAC,CAAC;IAEX,cAAc;IACd,yBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC,CAAC;AACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
@@ -88,6 +88,7 @@ var ControllerProgrammer;
|
|
88
88
|
}
|
89
89
|
};
|
90
90
|
ControllerProgrammer.write = (controller) => {
|
91
|
+
var _a;
|
91
92
|
const references = [];
|
92
93
|
const body = [
|
93
94
|
`@Controller(${JSON.stringify(controller.path)})`,
|
@@ -100,18 +101,27 @@ var ControllerProgrammer;
|
|
100
101
|
.join("\n\n"),
|
101
102
|
`}`,
|
102
103
|
].join("\n");
|
104
|
+
const core = controller.routes.some((r) => r.body !== null ||
|
105
|
+
r.response === null ||
|
106
|
+
r.response.type === "application/json");
|
103
107
|
const typia = controller.routes.some((m) => m.response !== null);
|
104
|
-
const
|
108
|
+
const common = new Set(["Controller"]);
|
109
|
+
for (const r of controller.routes)
|
110
|
+
if (((_a = r.response) === null || _a === void 0 ? void 0 : _a.type) === "text/plain") {
|
111
|
+
common.add("Header");
|
112
|
+
common.add(StringUtil_1.StringUtil.capitalize(r.method));
|
113
|
+
}
|
114
|
+
const dtoImports = [
|
105
115
|
...new Set(references.map((r) => r.$ref
|
106
116
|
.replace("#/components/schemas/", "")
|
107
117
|
.split(".")[0])),
|
108
118
|
].map((ref) => `import { ${ref} } from "${"../".repeat(StringUtil_1.StringUtil.split(controller.location).length - 1)}api/structures/${ref}"`);
|
109
119
|
return [
|
110
|
-
`import core from "@nestia/core"
|
111
|
-
`import {
|
120
|
+
...(core ? [`import core from "@nestia/core";`] : []),
|
121
|
+
`import { ${[...common].join(", ")} } from "@nestjs/common";`,
|
112
122
|
...(typia ? [`import typia from "typia";`] : []),
|
113
123
|
"",
|
114
|
-
...(
|
124
|
+
...(dtoImports.length ? [...dtoImports, ""] : []),
|
115
125
|
body,
|
116
126
|
].join("\n");
|
117
127
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ControllerProgrammer.js","sourceRoot":"","sources":["../../src/programmers/ControllerProgrammer.ts"],"names":[],"mappings":";;;AAIA,8CAA2C;AAC3C,oDAAiD;AACjD,uDAAoD;AAEpD,IAAiB,oBAAoB,
|
1
|
+
{"version":3,"file":"ControllerProgrammer.js","sourceRoot":"","sources":["../../src/programmers/ControllerProgrammer.ts"],"names":[],"mappings":";;;AAIA,8CAA2C;AAC3C,oDAAiD;AACjD,uDAAoD;AAEpD,IAAiB,oBAAoB,CAmKpC;AAnKD,WAAiB,oBAAoB;IACpB,4BAAO,GAAG,CAAC,OAAiB,EAAwB,EAAE;QAC/D,MAAM,IAAI,GAAiC,IAAI,GAAG,EAAE,CAAC;QAErD,gBAAgB;QAChB,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC5D,sBAAsB;YACtB,MAAM,QAAQ,GAAW,uBAAU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AC,CAAC,CAAC,EAAE,CAAC;YACjD,IAAI;SACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC;AACN,CAAC,EAnKgB,oBAAoB,oCAApB,oBAAoB,QAmKpC"}
|
@@ -10,8 +10,10 @@ var RouteProgrammer;
|
|
10
10
|
var _a, _b, _c;
|
11
11
|
const body = emplaceBodySchema(emplaceReference(swagger)("body"))((_a = route.requestBody) === null || _a === void 0 ? void 0 : _a.content);
|
12
12
|
const response = emplaceBodySchema(emplaceReference(swagger)("response"))((_c = ((_b = route.responses["200"]) !== null && _b !== void 0 ? _b : route.responses["201"])) === null || _c === void 0 ? void 0 : _c.content);
|
13
|
-
if (body === false || response === false)
|
13
|
+
if (body === false || response === false) {
|
14
|
+
console.log(`Failed to migrate ${props.method.toUpperCase()} ${props.path}: @nestia/migrate supports only application/json or text/plain format yet.`);
|
14
15
|
return null;
|
16
|
+
}
|
15
17
|
const [headers, query] = ["header", "query"].map((type) => {
|
16
18
|
const parameters = route.parameters.filter((p) => p.in === type);
|
17
19
|
if (parameters.length === 0)
|
@@ -135,10 +137,15 @@ var RouteProgrammer;
|
|
135
137
|
return null;
|
136
138
|
else if (content["application/json"]) {
|
137
139
|
const schema = content["application/json"].schema;
|
138
|
-
return
|
140
|
+
return {
|
141
|
+
type: "application/json",
|
142
|
+
schema: isNotObjectLiteral(schema)
|
143
|
+
? schema
|
144
|
+
: emplacer(schema),
|
145
|
+
};
|
139
146
|
}
|
140
147
|
else if (content["text/plain"])
|
141
|
-
return { type: "string" };
|
148
|
+
return { type: "text/plain", schema: { type: "string" } };
|
142
149
|
return false;
|
143
150
|
};
|
144
151
|
const emplaceReference = (swagger) => (name) => (schema) => {
|
@@ -149,9 +156,13 @@ var RouteProgrammer;
|
|
149
156
|
return { $ref: `#/components/schemas/${name}` };
|
150
157
|
};
|
151
158
|
RouteProgrammer.write = (references) => (route) => {
|
159
|
+
var _a;
|
152
160
|
const output = route.response
|
153
|
-
? SchemaProgrammer_1.SchemaProgrammer.write(references)(route.response)
|
161
|
+
? SchemaProgrammer_1.SchemaProgrammer.write(references)(route.response.schema)
|
154
162
|
: "void";
|
163
|
+
const decorator = ((_a = route.body) === null || _a === void 0 ? void 0 : _a.type) === "text/plain"
|
164
|
+
? [`@Header("Content-Type", "text/plain")`, `@`].join("\n")
|
165
|
+
: "@core.TypedRoute.";
|
155
166
|
const content = [
|
156
167
|
...(route.description
|
157
168
|
? [
|
@@ -162,7 +173,7 @@ var RouteProgrammer;
|
|
162
173
|
" */",
|
163
174
|
]
|
164
175
|
: []),
|
165
|
-
|
176
|
+
`${decorator}${StringUtil_1.StringUtil.capitalize(route.method)}${route.path.length ? `(${JSON.stringify(route.path)})` : "()"}`,
|
166
177
|
`public async ${route.name}(`,
|
167
178
|
...route.parameters.map((p) => ` ${writeParameter(p)},`),
|
168
179
|
...(route.query
|
@@ -171,9 +182,11 @@ var RouteProgrammer;
|
|
171
182
|
]
|
172
183
|
: []),
|
173
184
|
...(route.body
|
174
|
-
?
|
175
|
-
|
176
|
-
|
185
|
+
? route.body.type === "application/json"
|
186
|
+
? [
|
187
|
+
` @core.TypedBody() body: ${SchemaProgrammer_1.SchemaProgrammer.write(references)(route.body.schema)},`,
|
188
|
+
]
|
189
|
+
: [` @core.PlainBody() body: string,`]
|
177
190
|
: []),
|
178
191
|
`): Promise<${output}> {`,
|
179
192
|
...route.parameters.map((p) => ` ${StringUtil_1.StringUtil.normalize(p.key)};`),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RouteProgrammer.js","sourceRoot":"","sources":["../../src/programmers/RouteProgrammer.ts"],"names":[],"mappings":";;;AAIA,8DAA2D;AAC3D,oDAAiD;AACjD,yDAAsD;AAEtD,IAAiB,eAAe,
|
1
|
+
{"version":3,"file":"RouteProgrammer.js","sourceRoot":"","sources":["../../src/programmers/RouteProgrammer.ts"],"names":[],"mappings":";;;AAIA,8DAA2D;AAC3D,oDAAiD;AACjD,yDAAsD;AAEtD,I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AAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAC1C,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAC7C,KAAK,QAAQ,KAAK,mCAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3D,CAAC,CAAC;AACN,CAAC,EApRgB,eAAe,+BAAf,eAAe,QAoR/B"}
|
@@ -6,8 +6,8 @@ export interface IMigrateRoute {
|
|
6
6
|
parameters: IMigrateRoute.IParameter[];
|
7
7
|
headers: ISwaggerSchema | null;
|
8
8
|
query: ISwaggerSchema | null;
|
9
|
-
body:
|
10
|
-
response:
|
9
|
+
body: IMigrateRoute.IBody | null;
|
10
|
+
response: IMigrateRoute.IBody | null;
|
11
11
|
description?: string;
|
12
12
|
}
|
13
13
|
export declare namespace IMigrateRoute {
|
@@ -16,4 +16,8 @@ export declare namespace IMigrateRoute {
|
|
16
16
|
schema: ISwaggerSchema;
|
17
17
|
description?: string;
|
18
18
|
}
|
19
|
+
interface IBody {
|
20
|
+
type: "text/plain" | "application/json";
|
21
|
+
schema: ISwaggerSchema;
|
22
|
+
}
|
19
23
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nestia/migrate",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.6",
|
4
4
|
"description": "Migration program from swagger to NestJS",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"typings": "lib/index.d.ts",
|
@@ -10,7 +10,8 @@
|
|
10
10
|
"scripts": {
|
11
11
|
"build": "rimraf lib && tsc",
|
12
12
|
"dev": "npm run build -- --watch",
|
13
|
-
"prepare": "ts-patch install && ts-node src/executable/bundle.ts"
|
13
|
+
"prepare": "ts-patch install && ts-node src/executable/bundle.ts",
|
14
|
+
"test": "node lib/test"
|
14
15
|
},
|
15
16
|
"repository": {
|
16
17
|
"type": "git",
|
@@ -29,22 +30,30 @@
|
|
29
30
|
},
|
30
31
|
"homepage": "https://github.com/samchon/nestia#readme",
|
31
32
|
"devDependencies": {
|
33
|
+
"@nestia/core": "^1.4.3",
|
34
|
+
"@nestia/fetcher": "^1.4.0",
|
32
35
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
33
36
|
"@types/node": "^20.3.3",
|
34
37
|
"prettier": "^2.8.8",
|
35
38
|
"rimraf": "^5.0.1",
|
39
|
+
"serialize-error": "^4.1.0",
|
40
|
+
"source-map-support": "^0.5.21",
|
36
41
|
"ts-node": "^10.9.1",
|
37
42
|
"ts-patch": "^3.0.1",
|
38
|
-
"
|
43
|
+
"tstl": "^2.5.13",
|
44
|
+
"typescript": "^5.1.6",
|
45
|
+
"typescript-transform-paths": "^3.4.6"
|
39
46
|
},
|
40
47
|
"dependencies": {
|
41
|
-
"typia": "^4.1.
|
48
|
+
"typia": "^4.1.4"
|
42
49
|
},
|
43
50
|
"files": [
|
44
51
|
"lib",
|
45
52
|
"src",
|
53
|
+
"!lib/test",
|
54
|
+
"!src/test",
|
46
55
|
"package.json",
|
47
56
|
"README.md",
|
48
57
|
"LICENSE"
|
49
58
|
]
|
50
|
-
}
|
59
|
+
}
|
@@ -34,18 +34,15 @@ export class NestiaMigrateApplication {
|
|
34
34
|
|
35
35
|
public generate =
|
36
36
|
(archiver: NestiaMigrateApplication.IArchiver) =>
|
37
|
-
|
37
|
+
(output: string): void => {
|
38
38
|
const program: IMigrateProgram = this.analyze();
|
39
39
|
const files: IMigrateFile[] = MigrateProgrammer.write(program);
|
40
|
-
|
41
|
-
...files,
|
42
|
-
...TEMPLATE,
|
43
|
-
]);
|
40
|
+
FileArchiver.archive(archiver)(output)([...files, ...TEMPLATE]);
|
44
41
|
};
|
45
42
|
}
|
46
43
|
export namespace NestiaMigrateApplication {
|
47
44
|
export interface IArchiver {
|
48
|
-
mkdir: (path: string) =>
|
49
|
-
writeFile: (path: string, content: string) =>
|
45
|
+
mkdir: (path: string) => void;
|
46
|
+
writeFile: (path: string, content: string) => void;
|
50
47
|
}
|
51
48
|
}
|
@@ -2,19 +2,19 @@ import { IMigrateFile } from "../structures/IMigrateFile";
|
|
2
2
|
|
3
3
|
export namespace FileArchiver {
|
4
4
|
export interface IOperator {
|
5
|
-
mkdir(path: string):
|
6
|
-
writeFile(path: string, content: string):
|
5
|
+
mkdir(path: string): void;
|
6
|
+
writeFile(path: string, content: string): void;
|
7
7
|
}
|
8
8
|
|
9
9
|
export const archive =
|
10
10
|
(operator: IOperator) =>
|
11
11
|
(output: string) =>
|
12
|
-
|
13
|
-
|
12
|
+
(files: IMigrateFile[]): void => {
|
13
|
+
operator.mkdir(output);
|
14
14
|
const visited: Set<string> = new Set();
|
15
15
|
for (const f of files) {
|
16
|
-
|
17
|
-
|
16
|
+
mkdir(operator.mkdir)(output)(visited)(f.location);
|
17
|
+
operator.writeFile(
|
18
18
|
[output, f.location, f.file].join("/"),
|
19
19
|
f.content,
|
20
20
|
);
|
@@ -22,17 +22,17 @@ export namespace FileArchiver {
|
|
22
22
|
};
|
23
23
|
|
24
24
|
const mkdir =
|
25
|
-
(creator: (path: string) =>
|
25
|
+
(creator: (path: string) => void) =>
|
26
26
|
(output: string) =>
|
27
27
|
(visited: Set<string>) =>
|
28
|
-
|
28
|
+
(path: string): void => {
|
29
29
|
const sequence: string[] = path
|
30
30
|
.split("/")
|
31
31
|
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
32
32
|
for (const s of sequence)
|
33
33
|
if (visited.has(s) === false)
|
34
34
|
try {
|
35
|
-
|
35
|
+
creator([output, s].join("/"));
|
36
36
|
visited.add(s);
|
37
37
|
} catch {}
|
38
38
|
};
|
package/src/bundles/TEMPLATE.ts
CHANGED
@@ -22,7 +22,7 @@ export const TEMPLATE = [
|
|
22
22
|
{
|
23
23
|
"location": "",
|
24
24
|
"file": ".prettierignore",
|
25
|
-
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nREADME.md\r\ntsconfig.json"
|
25
|
+
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nsrc/api/utils/NestiaSimulator.ts\r\nREADME.md\r\ntsconfig.json"
|
26
26
|
},
|
27
27
|
{
|
28
28
|
"location": "/.vscode",
|
@@ -47,7 +47,7 @@ export const 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 \"----------------------------------------------\": \"\",\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\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\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-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.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 \"----------------------------------------------\": \"\",\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\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\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-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.9\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^3.3.1\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^5.40.0\",\r\n \"@typescript-eslint/parser\": \"^5.40.0\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"eslint-plugin-deprecation\": \"^1.4.1\",\r\n \"nestia\": \"^4.3.2\",\r\n \"prettier\": \"^2.7.1\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.0\",\r\n \"typescript\": \"^5.1.3\",\r\n \"typescript-transform-paths\": \"^3.4.6\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^1.4.3\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^4.1.4\",\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",
|
@@ -57,7 +57,7 @@ export const TEMPLATE = [
|
|
57
57
|
{
|
58
58
|
"location": "/packages/api",
|
59
59
|
"file": "package.json",
|
60
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.
|
60
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.4\"\r\n }\r\n}\r\n"
|
61
61
|
},
|
62
62
|
{
|
63
63
|
"location": "/packages/api",
|
@@ -82,12 +82,12 @@ export const TEMPLATE = [
|
|
82
82
|
{
|
83
83
|
"location": "/src",
|
84
84
|
"file": "Backend.ts",
|
85
|
-
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(
|
85
|
+
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(Configuration.API_PORT());\r\n\r\n //----\r\n // POST-PROCESSES\r\n //----\r\n // INFORM TO THE PM2\r\n if (process.send) process.send(\"ready\");\r\n\r\n // WHEN KILL COMMAND COMES\r\n process.on(\"SIGINT\", async () => {\r\n await this.close();\r\n process.exit(0);\r\n });\r\n }\r\n\r\n public async close(): Promise<void> {\r\n if (this.application_ === undefined) return;\r\n\r\n // DO CLOSE\r\n await this.application_.close();\r\n delete this.application_;\r\n }\r\n}\r\n"
|
86
86
|
},
|
87
87
|
{
|
88
88
|
"location": "/src",
|
89
89
|
"file": "Configuration.ts",
|
90
|
-
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT =
|
90
|
+
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT = () => 37001;\r\n\r\n export const ROOT = __filename.includes(\r\n path.join(\"bin\", \"src\", \"ShoppingConfiguration\"),\r\n )\r\n ? path.resolve(__dirname + \"/../..\")\r\n : path.resolve(__dirname + \"/..\");\r\n}\r\n"
|
91
91
|
},
|
92
92
|
{
|
93
93
|
"location": "/src/executable",
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import fs from "fs";
|
3
|
+
import path from "path";
|
3
4
|
|
4
5
|
import { NestiaMigrateApplication } from "../NestiaMigrateApplication";
|
5
6
|
import { ISwagger } from "../structures/ISwagger";
|
@@ -17,42 +18,43 @@ function halt(desc: string): never {
|
|
17
18
|
process.exit(-1);
|
18
19
|
}
|
19
20
|
|
20
|
-
const main =
|
21
|
-
const
|
22
|
-
|
21
|
+
const main = (argv: string[]) => {
|
22
|
+
const resolve = (str: string | undefined) =>
|
23
|
+
str ? path.resolve(str).split("\\").join("/") : undefined;
|
24
|
+
const input: string | undefined = resolve(argv[0]);
|
25
|
+
const output: string | undefined = resolve(argv[1]);
|
23
26
|
|
24
27
|
// VALIDATE ARGUMENTS
|
25
28
|
if (input === undefined || output === undefined) halt(USAGE);
|
26
|
-
|
27
|
-
|
29
|
+
|
30
|
+
// VALIDATE OUTPUT DIRECTORY
|
31
|
+
const parent: string = resolve(output + "/..")!;
|
32
|
+
if (fs.existsSync(output)) halt("Output directory alreay exists.");
|
33
|
+
else if (fs.existsSync(parent) === false)
|
28
34
|
halt("Output directory's parent directory does not exist.");
|
29
|
-
else if (
|
35
|
+
else if (fs.statSync(parent).isDirectory() === false)
|
30
36
|
halt("Output directory's parent is not a directory.");
|
31
37
|
|
32
38
|
// READ SWAGGER
|
33
|
-
const swagger: ISwagger =
|
39
|
+
const swagger: ISwagger = (() => {
|
34
40
|
if (fs.existsSync(input) === false)
|
35
41
|
halt("Unable to find the input swagger.json file.");
|
36
|
-
const stats: fs.Stats =
|
42
|
+
const stats: fs.Stats = fs.statSync(input);
|
37
43
|
if (stats.isFile() === false)
|
38
44
|
halt("The input swagger.json is not a file.");
|
39
|
-
const content: string =
|
45
|
+
const content: string = fs.readFileSync(input, "utf-8");
|
40
46
|
const swagger: ISwagger = JSON.parse(content);
|
41
47
|
return swagger;
|
42
48
|
})();
|
43
49
|
|
44
50
|
// DO GENERATE
|
45
51
|
const app = new NestiaMigrateApplication(swagger);
|
46
|
-
|
47
|
-
mkdir: fs.
|
48
|
-
writeFile: (path, content) =>
|
49
|
-
fs.promises.writeFile(path, content, "utf8"),
|
52
|
+
app.generate({
|
53
|
+
mkdir: fs.mkdirSync,
|
54
|
+
writeFile: (path, content) => fs.writeFileSync(path, content, "utf8"),
|
50
55
|
})(output);
|
51
56
|
|
52
57
|
// RUN SCRIPTS
|
53
58
|
SetupWizard.setup(output);
|
54
59
|
};
|
55
|
-
main(process.argv.slice(2))
|
56
|
-
console.log(exp);
|
57
|
-
process.exit(-1);
|
58
|
-
});
|
60
|
+
main(process.argv.slice(2));
|
@@ -128,10 +128,23 @@ export namespace ControllerProgrammer {
|
|
128
128
|
`}`,
|
129
129
|
].join("\n");
|
130
130
|
|
131
|
+
const core: boolean = controller.routes.some(
|
132
|
+
(r) =>
|
133
|
+
r.body !== null ||
|
134
|
+
r.response === null ||
|
135
|
+
r.response.type === "application/json",
|
136
|
+
);
|
131
137
|
const typia: boolean = controller.routes.some(
|
132
138
|
(m) => m.response !== null,
|
133
139
|
);
|
134
|
-
const
|
140
|
+
const common: Set<string> = new Set(["Controller"]);
|
141
|
+
for (const r of controller.routes)
|
142
|
+
if (r.response?.type === "text/plain") {
|
143
|
+
common.add("Header");
|
144
|
+
common.add(StringUtil.capitalize(r.method));
|
145
|
+
}
|
146
|
+
|
147
|
+
const dtoImports: string[] = [
|
135
148
|
...new Set(
|
136
149
|
references.map(
|
137
150
|
(r) =>
|
@@ -148,11 +161,11 @@ export namespace ControllerProgrammer {
|
|
148
161
|
);
|
149
162
|
|
150
163
|
return [
|
151
|
-
`import core from "@nestia/core"
|
152
|
-
`import {
|
164
|
+
...(core ? [`import core from "@nestia/core";`] : []),
|
165
|
+
`import { ${[...common].join(", ")} } from "@nestjs/common";`,
|
153
166
|
...(typia ? [`import typia from "typia";`] : []),
|
154
167
|
"",
|
155
|
-
...(
|
168
|
+
...(dtoImports.length ? [...dtoImports, ""] : []),
|
156
169
|
body,
|
157
170
|
].join("\n");
|
158
171
|
};
|
@@ -17,7 +17,14 @@ export namespace RouteProgrammer {
|
|
17
17
|
const response = emplaceBodySchema(
|
18
18
|
emplaceReference(swagger)("response"),
|
19
19
|
)((route.responses["200"] ?? route.responses["201"])?.content);
|
20
|
-
if (body === false || response === false)
|
20
|
+
if (body === false || response === false) {
|
21
|
+
console.log(
|
22
|
+
`Failed to migrate ${props.method.toUpperCase()} ${
|
23
|
+
props.path
|
24
|
+
}: @nestia/migrate supports only application/json or text/plain format yet.`,
|
25
|
+
);
|
26
|
+
return null;
|
27
|
+
}
|
21
28
|
|
22
29
|
const [headers, query] = ["header", "query"].map((type) => {
|
23
30
|
const parameters = route.parameters.filter(
|
@@ -179,12 +186,20 @@ export namespace RouteProgrammer {
|
|
179
186
|
|
180
187
|
const emplaceBodySchema =
|
181
188
|
(emplacer: (schema: ISwaggerSchema) => ISwaggerSchema.IReference) =>
|
182
|
-
(
|
189
|
+
(
|
190
|
+
content?: ISwaggerRoute.IContent,
|
191
|
+
): false | null | IMigrateRoute.IBody => {
|
183
192
|
if (!content) return null;
|
184
193
|
else if (content["application/json"]) {
|
185
194
|
const schema = content["application/json"].schema;
|
186
|
-
return
|
187
|
-
|
195
|
+
return {
|
196
|
+
type: "application/json",
|
197
|
+
schema: isNotObjectLiteral(schema)
|
198
|
+
? schema
|
199
|
+
: emplacer(schema),
|
200
|
+
};
|
201
|
+
} else if (content["text/plain"])
|
202
|
+
return { type: "text/plain", schema: { type: "string" } };
|
188
203
|
return false;
|
189
204
|
};
|
190
205
|
|
@@ -201,8 +216,12 @@ export namespace RouteProgrammer {
|
|
201
216
|
(references: ISwaggerSchema.IReference[]) =>
|
202
217
|
(route: IMigrateRoute): string => {
|
203
218
|
const output: string = route.response
|
204
|
-
? SchemaProgrammer.write(references)(route.response)
|
219
|
+
? SchemaProgrammer.write(references)(route.response.schema)
|
205
220
|
: "void";
|
221
|
+
const decorator: string =
|
222
|
+
route.body?.type === "text/plain"
|
223
|
+
? [`@Header("Content-Type", "text/plain")`, `@`].join("\n")
|
224
|
+
: "@core.TypedRoute.";
|
206
225
|
const content: string[] = [
|
207
226
|
...(route.description
|
208
227
|
? [
|
@@ -213,7 +232,7 @@ export namespace RouteProgrammer {
|
|
213
232
|
" */",
|
214
233
|
]
|
215
234
|
: []),
|
216
|
-
|
235
|
+
`${decorator}${StringUtil.capitalize(route.method)}${
|
217
236
|
route.path.length ? `(${JSON.stringify(route.path)})` : "()"
|
218
237
|
}`,
|
219
238
|
`public async ${route.name}(`,
|
@@ -226,11 +245,13 @@ export namespace RouteProgrammer {
|
|
226
245
|
]
|
227
246
|
: []),
|
228
247
|
...(route.body
|
229
|
-
?
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
248
|
+
? route.body.type === "application/json"
|
249
|
+
? [
|
250
|
+
` @core.TypedBody() body: ${SchemaProgrammer.write(
|
251
|
+
references,
|
252
|
+
)(route.body.schema)},`,
|
253
|
+
]
|
254
|
+
: [` @core.PlainBody() body: string,`]
|
234
255
|
: []),
|
235
256
|
`): Promise<${output}> {`,
|
236
257
|
...route.parameters.map(
|
@@ -7,8 +7,8 @@ export interface IMigrateRoute {
|
|
7
7
|
parameters: IMigrateRoute.IParameter[];
|
8
8
|
headers: ISwaggerSchema | null;
|
9
9
|
query: ISwaggerSchema | null;
|
10
|
-
body:
|
11
|
-
response:
|
10
|
+
body: IMigrateRoute.IBody | null;
|
11
|
+
response: IMigrateRoute.IBody | null;
|
12
12
|
description?: string;
|
13
13
|
}
|
14
14
|
export namespace IMigrateRoute {
|
@@ -17,4 +17,8 @@ export namespace IMigrateRoute {
|
|
17
17
|
schema: ISwaggerSchema;
|
18
18
|
description?: string;
|
19
19
|
}
|
20
|
+
export interface IBody {
|
21
|
+
type: "text/plain" | "application/json";
|
22
|
+
schema: ISwaggerSchema;
|
23
|
+
}
|
20
24
|
}
|
package/lib/test/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/lib/test/index.js
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
16
|
-
const module_1 = require("../module");
|
17
|
-
const SetupWizard_1 = require("../utils/SetupWizard");
|
18
|
-
const INPUT = __dirname + "/../../assets/input";
|
19
|
-
const OUTPUT = __dirname + "/../../assets/output";
|
20
|
-
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
21
|
-
if (fs_1.default.existsSync(OUTPUT))
|
22
|
-
yield fs_1.default.promises.rm(OUTPUT, { recursive: true });
|
23
|
-
yield fs_1.default.promises.mkdir(OUTPUT);
|
24
|
-
const directory = yield fs_1.default.promises.readdir(INPUT);
|
25
|
-
for (const file of directory) {
|
26
|
-
const location = `${INPUT}/${file}`;
|
27
|
-
if (!location.endsWith(".json"))
|
28
|
-
continue;
|
29
|
-
const swagger = JSON.parse(yield fs_1.default.promises.readFile(location, "utf8"));
|
30
|
-
const app = new module_1.NestiaMigrateApplication(swagger);
|
31
|
-
app.analyze();
|
32
|
-
const project = `${OUTPUT}/${file.replace(".json", "")}`;
|
33
|
-
yield fs_1.default.promises.mkdir(project);
|
34
|
-
yield app.generate({
|
35
|
-
mkdir: fs_1.default.promises.mkdir,
|
36
|
-
writeFile: (path, content) => fs_1.default.promises.writeFile(path, content, "utf8"),
|
37
|
-
})(project);
|
38
|
-
yield SetupWizard_1.SetupWizard.setup(project);
|
39
|
-
}
|
40
|
-
});
|
41
|
-
main().catch((exp) => {
|
42
|
-
console.error(exp);
|
43
|
-
process.exit(-1);
|
44
|
-
});
|
45
|
-
//# sourceMappingURL=index.js.map
|
package/lib/test/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/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E,EAAE,CACzB,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;SACnD,CAAC,CAAC,OAAO,CAAC,CAAC;QACZ,MAAM,yBAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACpC;AACL,CAAC,CAAA,CAAC;AACF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
package/src/test/index.ts
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
|
3
|
-
import { ISwagger, NestiaMigrateApplication } from "../module";
|
4
|
-
import { SetupWizard } from "../utils/SetupWizard";
|
5
|
-
|
6
|
-
const INPUT = __dirname + "/../../assets/input";
|
7
|
-
const OUTPUT = __dirname + "/../../assets/output";
|
8
|
-
|
9
|
-
const main = async () => {
|
10
|
-
if (fs.existsSync(OUTPUT))
|
11
|
-
await fs.promises.rm(OUTPUT, { recursive: true });
|
12
|
-
await fs.promises.mkdir(OUTPUT);
|
13
|
-
|
14
|
-
const directory: string[] = await fs.promises.readdir(INPUT);
|
15
|
-
for (const file of directory) {
|
16
|
-
const location: string = `${INPUT}/${file}`;
|
17
|
-
if (!location.endsWith(".json")) continue;
|
18
|
-
|
19
|
-
const swagger: ISwagger = JSON.parse(
|
20
|
-
await fs.promises.readFile(location, "utf8"),
|
21
|
-
);
|
22
|
-
const app = new NestiaMigrateApplication(swagger);
|
23
|
-
app.analyze();
|
24
|
-
|
25
|
-
const project: string = `${OUTPUT}/${file.replace(".json", "")}`;
|
26
|
-
await fs.promises.mkdir(project);
|
27
|
-
await app.generate({
|
28
|
-
mkdir: fs.promises.mkdir,
|
29
|
-
writeFile: (path, content) =>
|
30
|
-
fs.promises.writeFile(path, content, "utf8"),
|
31
|
-
})(project);
|
32
|
-
await SetupWizard.setup(project);
|
33
|
-
}
|
34
|
-
};
|
35
|
-
main().catch((exp) => {
|
36
|
-
console.error(exp);
|
37
|
-
process.exit(-1);
|
38
|
-
});
|