@nestia/migrate 0.1.4 → 0.1.5
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 +2 -2
- 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/test/index.js +11 -23
- package/lib/test/index.js.map +1 -1
- package/package.json +1 -1
- package/src/NestiaMigrateApplication.ts +4 -7
- package/src/archivers/FileArchiver.ts +9 -9
- package/src/bundles/TEMPLATE.ts +2 -2
- package/src/executable/migrate.ts +19 -17
- package/src/test/index.ts +10 -16
@@ -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":"
|
1
|
+
{"version":3,"file":"NestiaMigrateApplication.js","sourceRoot":"","sources":["../src/NestiaMigrateApplication.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AAKpE,MAAa,wBAAwB;IAKjC,YAAmB,OAAiB;QAoB7B,aAAQ,GACX,CAAC,QAA4C,EAAE,EAAE,CACjD,CAAC,MAAc,EAAQ,EAAE;YACrB,M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CD,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.5\",\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.
|
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.5\",\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",
|
@@ -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,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1,19 +1,11 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
|
-
var __awaiter = (this && 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,0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I,CAAC,6CAA6C,CAAC,CAAC;QACxD,MAAM,KAAK,GAAa,YAAE,CAAC,QAAQ,CAAC,KAAK,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"}
|
package/lib/test/index.js
CHANGED
@@ -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
|
};
|
@@ -17,29 +8,26 @@ const module_1 = require("../module");
|
|
17
8
|
const SetupWizard_1 = require("../utils/SetupWizard");
|
18
9
|
const INPUT = __dirname + "/../../assets/input";
|
19
10
|
const OUTPUT = __dirname + "/../../assets/output";
|
20
|
-
const main = () =>
|
11
|
+
const main = () => {
|
21
12
|
if (fs_1.default.existsSync(OUTPUT))
|
22
|
-
|
23
|
-
|
24
|
-
const directory =
|
13
|
+
fs_1.default.rmSync(OUTPUT, { recursive: true });
|
14
|
+
fs_1.default.mkdirSync(OUTPUT);
|
15
|
+
const directory = fs_1.default.readdirSync(INPUT);
|
25
16
|
for (const file of directory) {
|
26
17
|
const location = `${INPUT}/${file}`;
|
27
18
|
if (!location.endsWith(".json"))
|
28
19
|
continue;
|
29
|
-
const swagger = JSON.parse(
|
20
|
+
const swagger = JSON.parse(fs_1.default.readFileSync(location, "utf8"));
|
30
21
|
const app = new module_1.NestiaMigrateApplication(swagger);
|
31
22
|
app.analyze();
|
32
23
|
const project = `${OUTPUT}/${file.replace(".json", "")}`;
|
33
|
-
|
34
|
-
|
35
|
-
mkdir: fs_1.default.
|
24
|
+
fs_1.default.mkdirSync(project);
|
25
|
+
app.generate({
|
26
|
+
mkdir: fs_1.default.mkdirSync,
|
36
27
|
writeFile: (path, content) => fs_1.default.promises.writeFile(path, content, "utf8"),
|
37
28
|
})(project);
|
38
|
-
|
29
|
+
SetupWizard_1.SetupWizard.setup(project);
|
39
30
|
}
|
40
|
-
}
|
41
|
-
main()
|
42
|
-
console.error(exp);
|
43
|
-
process.exit(-1);
|
44
|
-
});
|
31
|
+
};
|
32
|
+
main();
|
45
33
|
//# sourceMappingURL=index.js.map
|
package/lib/test/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AAEpB,sCAA+D;AAC/D,sDAAmD;AAEnD,MAAM,KAAK,GAAG,SAAS,GAAG,qBAAqB,CAAC;AAChD,MAAM,MAAM,GAAG,SAAS,GAAG,sBAAsB,CAAC;AAElD,MAAM,IAAI,GAAG,GAAG,EAAE;IACd,IAAI,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,YAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,YAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAErB,MAAM,SAAS,GAAa,YAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC1B,MAAM,QAAQ,GAAW,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAS;QAE1C,MAAM,OAAO,GAAa,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACxE,MAAM,GAAG,GAAG,IAAI,iCAAwB,CAAC,OAAO,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,EAAE,CAAC;QAEd,MAAM,OAAO,GAAW,GAAG,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;QACjE,YAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACtB,GAAG,CAAC,QAAQ,CAAC;YACT,KAAK,EAAE,YAAE,CAAC,SAAS;YACnB,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACzB,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;SACnD,CAAC,CAAC,OAAO,CAAC,CAAC;QACZ,yBAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;AACL,CAAC,CAAC;AACF,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
@@ -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.5\",\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.
|
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.5\",\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",
|
@@ -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));
|
package/src/test/index.ts
CHANGED
@@ -6,33 +6,27 @@ import { SetupWizard } from "../utils/SetupWizard";
|
|
6
6
|
const INPUT = __dirname + "/../../assets/input";
|
7
7
|
const OUTPUT = __dirname + "/../../assets/output";
|
8
8
|
|
9
|
-
const main =
|
10
|
-
if (fs.existsSync(OUTPUT))
|
11
|
-
|
12
|
-
await fs.promises.mkdir(OUTPUT);
|
9
|
+
const main = () => {
|
10
|
+
if (fs.existsSync(OUTPUT)) fs.rmSync(OUTPUT, { recursive: true });
|
11
|
+
fs.mkdirSync(OUTPUT);
|
13
12
|
|
14
|
-
const directory: string[] =
|
13
|
+
const directory: string[] = fs.readdirSync(INPUT);
|
15
14
|
for (const file of directory) {
|
16
15
|
const location: string = `${INPUT}/${file}`;
|
17
16
|
if (!location.endsWith(".json")) continue;
|
18
17
|
|
19
|
-
const swagger: ISwagger = JSON.parse(
|
20
|
-
await fs.promises.readFile(location, "utf8"),
|
21
|
-
);
|
18
|
+
const swagger: ISwagger = JSON.parse(fs.readFileSync(location, "utf8"));
|
22
19
|
const app = new NestiaMigrateApplication(swagger);
|
23
20
|
app.analyze();
|
24
21
|
|
25
22
|
const project: string = `${OUTPUT}/${file.replace(".json", "")}`;
|
26
|
-
|
27
|
-
|
28
|
-
mkdir: fs.
|
23
|
+
fs.mkdirSync(project);
|
24
|
+
app.generate({
|
25
|
+
mkdir: fs.mkdirSync,
|
29
26
|
writeFile: (path, content) =>
|
30
27
|
fs.promises.writeFile(path, content, "utf8"),
|
31
28
|
})(project);
|
32
|
-
|
29
|
+
SetupWizard.setup(project);
|
33
30
|
}
|
34
31
|
};
|
35
|
-
main()
|
36
|
-
console.error(exp);
|
37
|
-
process.exit(-1);
|
38
|
-
});
|
32
|
+
main();
|