From e8d7fd17769644ceefbfe914fb672eae9cae5a81 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Wed, 18 Dec 2024 19:45:04 +0900 Subject: [PATCH 1/2] Fix `@nestia/migrate` bug and support `@HumanRoute()` --- package.json | 2 +- .../MigrateNestControllerProgrammer.ts | 2 +- .../MigrateNestMethodProgrammer.ts | 26 +++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8af2ea441..62ee470ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@nestia/station", - "version": "4.5.0", + "version": "4.5.1", "description": "Nestia station", "scripts": { "build": "node deploy build", diff --git a/packages/migrate/src/programmers/MigrateNestControllerProgrammer.ts b/packages/migrate/src/programmers/MigrateNestControllerProgrammer.ts index 2ab1f4f72..665cabad0 100644 --- a/packages/migrate/src/programmers/MigrateNestControllerProgrammer.ts +++ b/packages/migrate/src/programmers/MigrateNestControllerProgrammer.ts @@ -33,7 +33,7 @@ export namespace MigrateNestControllerProgrammer { [], [], controller.routes.map( - MigrateNestMethodProgrammer.write(components)(importer), + MigrateNestMethodProgrammer.write(components)(importer)(controller), ), ); return [ diff --git a/packages/migrate/src/programmers/MigrateNestMethodProgrammer.ts b/packages/migrate/src/programmers/MigrateNestMethodProgrammer.ts index 47405975e..f75873829 100644 --- a/packages/migrate/src/programmers/MigrateNestMethodProgrammer.ts +++ b/packages/migrate/src/programmers/MigrateNestMethodProgrammer.ts @@ -5,6 +5,7 @@ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory"; import { LiteralFactory } from "typia/lib/factories/LiteralFactory"; import { TypeFactory } from "typia/lib/factories/TypeFactory"; +import { IHttpMigrateController } from "../structures/IHttpMigrateController"; import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; import { FilePrinter } from "../utils/FilePrinter"; import { StringUtil } from "../utils/StringUtil"; @@ -15,6 +16,7 @@ export namespace MigrateNestMethodProgrammer { export const write = (components: OpenApi.IComponents) => (importer: MigrateImportProgrammer) => + (controller: IHttpMigrateController) => (route: IHttpMigrateRoute): ts.MethodDeclaration => { const output: ts.TypeNode = route.success ? MigrateSchemaProgrammer.write(components)(importer)( @@ -24,7 +26,7 @@ export namespace MigrateNestMethodProgrammer { const method: ts.MethodDeclaration = ts.factory.createMethodDeclaration( [ - ...writeMethodDecorators(components)(importer)(route), + ...writeMethodDecorators(components)(importer)(controller)(route), ts.factory.createToken(ts.SyntaxKind.PublicKeyword), ts.factory.createToken(ts.SyntaxKind.AsyncKeyword), ], @@ -78,6 +80,7 @@ export namespace MigrateNestMethodProgrammer { const writeMethodDecorators = (components: OpenApi.IComponents) => (importer: MigrateImportProgrammer) => + (controller: IHttpMigrateController) => (route: IHttpMigrateRoute): ts.Decorator[] => { const external = (lib: string) => @@ -99,7 +102,24 @@ export namespace MigrateNestMethodProgrammer { ), ); + // HUMAN-ONLY + if (route.operation()["x-samchon-human"] === true) + decorators.push( + ts.factory.createDecorator( + ts.factory.createCallExpression( + external("@nestia/core")("HumanRoute"), + undefined, + undefined, + ), + ), + ); + // ROUTER + const localPath: string = route.emendedPath + .slice(controller.path.length) + .split("/") + .filter((str) => !!str.length) + .join("/"); const router = (instance: string) => ts.factory.createDecorator( ts.factory.createCallExpression( @@ -108,7 +128,9 @@ export namespace MigrateNestMethodProgrammer { StringUtil.capitalize(route.method), ), [], - [ts.factory.createStringLiteral(route.path)], + localPath.length + ? [ts.factory.createStringLiteral(localPath)] + : undefined, ), ); if (route.success?.["x-nestia-encrypted"]) From 9b85aecf393e8d26048aa26c48e73c5d63cc487f Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Wed, 18 Dec 2024 19:46:28 +0900 Subject: [PATCH 2/2] Update publish.js --- deploy/publish.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/deploy/publish.js b/deploy/publish.js index 181389191..b816f0f8e 100644 --- a/deploy/publish.js +++ b/deploy/publish.js @@ -32,13 +32,11 @@ const setup = ({ tag, name, directory, version }) => { fs.writeFileSync(file, JSON.stringify(info, null, 2), "utf8"); if (fs.existsSync(`${directory}/package-lock.json`)) fs.rmSync(`${directory}/package-lock.json`); - try { - execute({ - cwd: directory, - script: `npm publish --tag ${tag} --access public${tag === "latest" ? " --provenance" : ""}`, - studio: "ignore", - }); - } catch {} + execute({ + cwd: directory, + script: `npm publish --tag ${tag} --access public${tag === "latest" ? " --provenance" : ""}`, + studio: "ignore", + }); // ROLLBACK THE PACKAGE.JSON for (const r of rollbacks) r();