@nestia/migrate
Advanced tools
Comparing version 0.1.4 to 0.1.5
import { IMigrateFile } from "../structures/IMigrateFile"; | ||
export declare namespace FileArchiver { | ||
interface IOperator { | ||
mkdir(path: string): Promise<void>; | ||
writeFile(path: string, content: string): Promise<void>; | ||
mkdir(path: string): void; | ||
writeFile(path: string, content: string): void; | ||
} | ||
const archive: (operator: IOperator) => (output: string) => (files: IMigrateFile[]) => Promise<void>; | ||
const archive: (operator: IOperator) => (output: string) => (files: IMigrateFile[]) => void; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -15,11 +6,11 @@ exports.FileArchiver = void 0; | ||
(function (FileArchiver) { | ||
FileArchiver.archive = (operator) => (output) => (files) => __awaiter(this, void 0, void 0, function* () { | ||
yield operator.mkdir(output); | ||
FileArchiver.archive = (operator) => (output) => (files) => { | ||
operator.mkdir(output); | ||
const visited = new Set(); | ||
for (const f of files) { | ||
yield mkdir(operator.mkdir)(output)(visited)(f.location); | ||
yield operator.writeFile([output, f.location, f.file].join("/"), f.content); | ||
mkdir(operator.mkdir)(output)(visited)(f.location); | ||
operator.writeFile([output, f.location, f.file].join("/"), f.content); | ||
} | ||
}); | ||
const mkdir = (creator) => (output) => (visited) => (path) => __awaiter(this, void 0, void 0, function* () { | ||
}; | ||
const mkdir = (creator) => (output) => (visited) => (path) => { | ||
const sequence = path | ||
@@ -31,8 +22,8 @@ .split("/") | ||
try { | ||
yield creator([output, s].join("/")); | ||
creator([output, s].join("/")); | ||
visited.add(s); | ||
} | ||
catch (_a) { } | ||
}); | ||
}; | ||
})(FileArchiver || (exports.FileArchiver = FileArchiver = {})); | ||
//# sourceMappingURL=FileArchiver.js.map |
@@ -28,3 +28,3 @@ "use strict"; | ||
"file": ".prettierignore", | ||
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nREADME.md\r\ntsconfig.json" | ||
"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" | ||
}, | ||
@@ -54,3 +54,3 @@ { | ||
"file": "package.json", | ||
"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.2\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^4.1.3\",\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}" | ||
"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}" | ||
}, | ||
@@ -57,0 +57,0 @@ { |
#!/usr/bin/env node | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -17,2 +8,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const NestiaMigrateApplication_1 = require("../NestiaMigrateApplication"); | ||
@@ -30,38 +22,38 @@ const SetupWizard_1 = require("../utils/SetupWizard"); | ||
} | ||
const main = (argv) => __awaiter(void 0, void 0, void 0, function* () { | ||
const input = argv[0]; | ||
const output = argv[1]; | ||
const main = (argv) => { | ||
const resolve = (str) => str ? path_1.default.resolve(str).split("\\").join("/") : undefined; | ||
const input = resolve(argv[0]); | ||
const output = resolve(argv[1]); | ||
// VALIDATE ARGUMENTS | ||
if (input === undefined || output === undefined) | ||
halt(USAGE); | ||
else if (fs_1.default.existsSync(output)) | ||
// VALIDATE OUTPUT DIRECTORY | ||
const parent = resolve(output + "/.."); | ||
if (fs_1.default.existsSync(output)) | ||
halt("Output directory alreay exists."); | ||
else if (fs_1.default.existsSync(output + "/..") === false) | ||
else if (fs_1.default.existsSync(parent) === false) | ||
halt("Output directory's parent directory does not exist."); | ||
else if ((yield fs_1.default.promises.stat(output + "/..")).isDirectory() === false) | ||
else if (fs_1.default.statSync(parent).isDirectory() === false) | ||
halt("Output directory's parent is not a directory."); | ||
// READ SWAGGER | ||
const swagger = yield (() => __awaiter(void 0, void 0, void 0, function* () { | ||
const swagger = (() => { | ||
if (fs_1.default.existsSync(input) === false) | ||
halt("Unable to find the input swagger.json file."); | ||
const stats = yield fs_1.default.promises.stat(input); | ||
const stats = fs_1.default.statSync(input); | ||
if (stats.isFile() === false) | ||
halt("The input swagger.json is not a file."); | ||
const content = yield fs_1.default.readFileSync(input, "utf-8"); | ||
const content = fs_1.default.readFileSync(input, "utf-8"); | ||
const swagger = JSON.parse(content); | ||
return swagger; | ||
}))(); | ||
})(); | ||
// DO GENERATE | ||
const app = new NestiaMigrateApplication_1.NestiaMigrateApplication(swagger); | ||
yield app.generate({ | ||
mkdir: fs_1.default.promises.mkdir, | ||
writeFile: (path, content) => fs_1.default.promises.writeFile(path, content, "utf8"), | ||
app.generate({ | ||
mkdir: fs_1.default.mkdirSync, | ||
writeFile: (path, content) => fs_1.default.writeFileSync(path, content, "utf8"), | ||
})(output); | ||
// RUN SCRIPTS | ||
SetupWizard_1.SetupWizard.setup(output); | ||
}); | ||
main(process.argv.slice(2)).catch((exp) => { | ||
console.log(exp); | ||
process.exit(-1); | ||
}); | ||
}; | ||
main(process.argv.slice(2)); | ||
//# sourceMappingURL=migrate.js.map |
@@ -11,9 +11,9 @@ import { IMigrateFile } from "./structures/IMigrateFile"; | ||
write(): IMigrateFile[]; | ||
generate: (archiver: NestiaMigrateApplication.IArchiver) => (output: string) => Promise<void>; | ||
generate: (archiver: NestiaMigrateApplication.IArchiver) => (output: string) => void; | ||
} | ||
export declare namespace NestiaMigrateApplication { | ||
interface IArchiver { | ||
mkdir: (path: string) => Promise<void>; | ||
writeFile: (path: string, content: string) => Promise<void>; | ||
mkdir: (path: string) => void; | ||
writeFile: (path: string, content: string) => void; | ||
} | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -20,7 +11,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const OUTPUT = __dirname + "/../../assets/output"; | ||
const main = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const main = () => { | ||
if (fs_1.default.existsSync(OUTPUT)) | ||
yield fs_1.default.promises.rm(OUTPUT, { recursive: true }); | ||
yield fs_1.default.promises.mkdir(OUTPUT); | ||
const directory = yield fs_1.default.promises.readdir(INPUT); | ||
fs_1.default.rmSync(OUTPUT, { recursive: true }); | ||
fs_1.default.mkdirSync(OUTPUT); | ||
const directory = fs_1.default.readdirSync(INPUT); | ||
for (const file of directory) { | ||
@@ -30,18 +21,15 @@ const location = `${INPUT}/${file}`; | ||
continue; | ||
const swagger = JSON.parse(yield fs_1.default.promises.readFile(location, "utf8")); | ||
const swagger = JSON.parse(fs_1.default.readFileSync(location, "utf8")); | ||
const app = new module_1.NestiaMigrateApplication(swagger); | ||
app.analyze(); | ||
const project = `${OUTPUT}/${file.replace(".json", "")}`; | ||
yield fs_1.default.promises.mkdir(project); | ||
yield app.generate({ | ||
mkdir: fs_1.default.promises.mkdir, | ||
fs_1.default.mkdirSync(project); | ||
app.generate({ | ||
mkdir: fs_1.default.mkdirSync, | ||
writeFile: (path, content) => fs_1.default.promises.writeFile(path, content, "utf8"), | ||
})(project); | ||
yield SetupWizard_1.SetupWizard.setup(project); | ||
SetupWizard_1.SetupWizard.setup(project); | ||
} | ||
}); | ||
main().catch((exp) => { | ||
console.error(exp); | ||
process.exit(-1); | ||
}); | ||
}; | ||
main(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@nestia/migrate", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Migration program from swagger to NestJS", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,4 +5,4 @@ import { IMigrateFile } from "../structures/IMigrateFile"; | ||
export interface IOperator { | ||
mkdir(path: string): Promise<void>; | ||
writeFile(path: string, content: string): Promise<void>; | ||
mkdir(path: string): void; | ||
writeFile(path: string, content: string): void; | ||
} | ||
@@ -13,8 +13,8 @@ | ||
(output: string) => | ||
async (files: IMigrateFile[]): Promise<void> => { | ||
await operator.mkdir(output); | ||
(files: IMigrateFile[]): void => { | ||
operator.mkdir(output); | ||
const visited: Set<string> = new Set(); | ||
for (const f of files) { | ||
await mkdir(operator.mkdir)(output)(visited)(f.location); | ||
await operator.writeFile( | ||
mkdir(operator.mkdir)(output)(visited)(f.location); | ||
operator.writeFile( | ||
[output, f.location, f.file].join("/"), | ||
@@ -27,6 +27,6 @@ f.content, | ||
const mkdir = | ||
(creator: (path: string) => Promise<void>) => | ||
(creator: (path: string) => void) => | ||
(output: string) => | ||
(visited: Set<string>) => | ||
async (path: string): Promise<void> => { | ||
(path: string): void => { | ||
const sequence: string[] = path | ||
@@ -38,3 +38,3 @@ .split("/") | ||
try { | ||
await creator([output, s].join("/")); | ||
creator([output, s].join("/")); | ||
visited.add(s); | ||
@@ -41,0 +41,0 @@ } catch {} |
@@ -25,3 +25,3 @@ export const TEMPLATE = [ | ||
"file": ".prettierignore", | ||
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nREADME.md\r\ntsconfig.json" | ||
"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" | ||
}, | ||
@@ -51,3 +51,3 @@ { | ||
"file": "package.json", | ||
"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.2\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^4.1.3\",\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}" | ||
"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,0 +54,0 @@ { |
#!/usr/bin/env node | ||
import fs from "fs"; | ||
import path from "path"; | ||
@@ -20,22 +21,27 @@ import { NestiaMigrateApplication } from "../NestiaMigrateApplication"; | ||
const main = async (argv: string[]) => { | ||
const input: string | undefined = argv[0]; | ||
const output: string | undefined = argv[1]; | ||
const main = (argv: string[]) => { | ||
const resolve = (str: string | undefined) => | ||
str ? path.resolve(str).split("\\").join("/") : undefined; | ||
const input: string | undefined = resolve(argv[0]); | ||
const output: string | undefined = resolve(argv[1]); | ||
// VALIDATE ARGUMENTS | ||
if (input === undefined || output === undefined) halt(USAGE); | ||
else if (fs.existsSync(output)) halt("Output directory alreay exists."); | ||
else if (fs.existsSync(output + "/..") === false) | ||
// VALIDATE OUTPUT DIRECTORY | ||
const parent: string = resolve(output + "/..")!; | ||
if (fs.existsSync(output)) halt("Output directory alreay exists."); | ||
else if (fs.existsSync(parent) === false) | ||
halt("Output directory's parent directory does not exist."); | ||
else if ((await fs.promises.stat(output + "/..")).isDirectory() === false) | ||
else if (fs.statSync(parent).isDirectory() === false) | ||
halt("Output directory's parent is not a directory."); | ||
// READ SWAGGER | ||
const swagger: ISwagger = await (async () => { | ||
const swagger: ISwagger = (() => { | ||
if (fs.existsSync(input) === false) | ||
halt("Unable to find the input swagger.json file."); | ||
const stats: fs.Stats = await fs.promises.stat(input); | ||
const stats: fs.Stats = fs.statSync(input); | ||
if (stats.isFile() === false) | ||
halt("The input swagger.json is not a file."); | ||
const content: string = await fs.readFileSync(input, "utf-8"); | ||
const content: string = fs.readFileSync(input, "utf-8"); | ||
const swagger: ISwagger = JSON.parse(content); | ||
@@ -47,6 +53,5 @@ return swagger; | ||
const app = new NestiaMigrateApplication(swagger); | ||
await app.generate({ | ||
mkdir: fs.promises.mkdir, | ||
writeFile: (path, content) => | ||
fs.promises.writeFile(path, content, "utf8"), | ||
app.generate({ | ||
mkdir: fs.mkdirSync, | ||
writeFile: (path, content) => fs.writeFileSync(path, content, "utf8"), | ||
})(output); | ||
@@ -57,5 +62,2 @@ | ||
}; | ||
main(process.argv.slice(2)).catch((exp) => { | ||
console.log(exp); | ||
process.exit(-1); | ||
}); | ||
main(process.argv.slice(2)); |
@@ -37,9 +37,6 @@ import typia from "typia"; | ||
(archiver: NestiaMigrateApplication.IArchiver) => | ||
async (output: string): Promise<void> => { | ||
(output: string): void => { | ||
const program: IMigrateProgram = this.analyze(); | ||
const files: IMigrateFile[] = MigrateProgrammer.write(program); | ||
await FileArchiver.archive(archiver)(output)([ | ||
...files, | ||
...TEMPLATE, | ||
]); | ||
FileArchiver.archive(archiver)(output)([...files, ...TEMPLATE]); | ||
}; | ||
@@ -49,5 +46,5 @@ } | ||
export interface IArchiver { | ||
mkdir: (path: string) => Promise<void>; | ||
writeFile: (path: string, content: string) => Promise<void>; | ||
mkdir: (path: string) => void; | ||
writeFile: (path: string, content: string) => void; | ||
} | ||
} |
@@ -9,8 +9,7 @@ import fs from "fs"; | ||
const main = async () => { | ||
if (fs.existsSync(OUTPUT)) | ||
await fs.promises.rm(OUTPUT, { recursive: true }); | ||
await fs.promises.mkdir(OUTPUT); | ||
const main = () => { | ||
if (fs.existsSync(OUTPUT)) fs.rmSync(OUTPUT, { recursive: true }); | ||
fs.mkdirSync(OUTPUT); | ||
const directory: string[] = await fs.promises.readdir(INPUT); | ||
const directory: string[] = fs.readdirSync(INPUT); | ||
for (const file of directory) { | ||
@@ -20,5 +19,3 @@ const location: string = `${INPUT}/${file}`; | ||
const swagger: ISwagger = JSON.parse( | ||
await fs.promises.readFile(location, "utf8"), | ||
); | ||
const swagger: ISwagger = JSON.parse(fs.readFileSync(location, "utf8")); | ||
const app = new NestiaMigrateApplication(swagger); | ||
@@ -28,14 +25,11 @@ app.analyze(); | ||
const project: string = `${OUTPUT}/${file.replace(".json", "")}`; | ||
await fs.promises.mkdir(project); | ||
await app.generate({ | ||
mkdir: fs.promises.mkdir, | ||
fs.mkdirSync(project); | ||
app.generate({ | ||
mkdir: fs.mkdirSync, | ||
writeFile: (path, content) => | ||
fs.promises.writeFile(path, content, "utf8"), | ||
})(project); | ||
await SetupWizard.setup(project); | ||
SetupWizard.setup(project); | ||
} | ||
}; | ||
main().catch((exp) => { | ||
console.error(exp); | ||
process.exit(-1); | ||
}); | ||
main(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
340535
4437