@nestia/migrate
Advanced tools
Comparing version 0.17.4 to 0.17.5-dev.20240901
@@ -19,2 +19,3 @@ "use strict"; | ||
const prettier_1 = require("prettier"); | ||
const typia_1 = __importDefault(require("typia")); | ||
const MigrateApplication_1 = require("../MigrateApplication"); | ||
@@ -37,3 +38,8 @@ const MigrateFileArchiver_1 = require("../archivers/MigrateFileArchiver"); | ||
// READ SWAGGER | ||
const document = (() => { | ||
const document = yield (() => __awaiter(this, void 0, void 0, function* () { | ||
if ((() => { return input => "string" === typeof input && (/\/|:/.test(input) && /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test(input)); })()(options.input)) { | ||
const response = yield fetch(options.input); | ||
const content = yield response.text(); | ||
return JSON.parse(content); | ||
} | ||
if (fs_1.default.existsSync(options.input) === false) | ||
@@ -44,6 +50,5 @@ halt("Unable to find the input swagger.json file."); | ||
halt("The input swagger.json is not a file."); | ||
const content = fs_1.default.readFileSync(options.input, "utf-8"); | ||
const swagger = JSON.parse(content); | ||
return swagger; | ||
})(); | ||
const content = yield fs_1.default.promises.readFile(options.input, "utf-8"); | ||
return JSON.parse(content); | ||
}))(); | ||
const result = yield MigrateApplication_1.MigrateApplication.create(document); | ||
@@ -50,0 +55,0 @@ if (result.success === false) { |
{ | ||
"name": "@nestia/migrate", | ||
"version": "0.17.4", | ||
"version": "0.17.5-dev.20240901", | ||
"description": "Migration program from swagger to NestJS", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,3 +5,3 @@ import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi"; | ||
import { format } from "prettier"; | ||
import { IValidation } from "typia"; | ||
import typia, { IValidation, tags } from "typia"; | ||
@@ -30,3 +30,8 @@ import { MigrateApplication } from "../MigrateApplication"; | ||
| OpenApiV3.IDocument | ||
| OpenApiV3_1.IDocument = (() => { | ||
| OpenApiV3_1.IDocument = await (async () => { | ||
if (typia.is<string & tags.Format<"uri">>(options.input)) { | ||
const response: Response = await fetch(options.input); | ||
const content: string = await response.text(); | ||
return JSON.parse(content); | ||
} | ||
if (fs.existsSync(options.input) === false) | ||
@@ -37,8 +42,7 @@ halt("Unable to find the input swagger.json file."); | ||
halt("The input swagger.json is not a file."); | ||
const content: string = fs.readFileSync(options.input, "utf-8"); | ||
const swagger: | ||
| SwaggerV2.IDocument | ||
| OpenApiV3.IDocument | ||
| OpenApiV3_1.IDocument = JSON.parse(content); | ||
return swagger; | ||
const content: string = await fs.promises.readFile( | ||
options.input, | ||
"utf-8", | ||
); | ||
return JSON.parse(content); | ||
})(); | ||
@@ -45,0 +49,0 @@ |
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 too big to display
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
Network access
Supply chain riskThis module accesses the network.
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
1406228
16069
3