Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support both npm and pnpm #185

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

- name: Setup PNPM
run: npm i -g pnpm && pnpm install

- name: Test Packages
run: npm install && npm run test
run: pnpm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ migrations/
node_modules/

package-lock.json
pnpm-lock.yaml
*.DS_Store
*.log
*.tgz
4 changes: 2 additions & 2 deletions deploy/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const deploy = (tag) => (version) => (name) => {
for (const key of Object.keys(record))
if (packages.includes(key.replace("@samchon/", ""))) {
if (tag === "tgz" && fs.existsSync(`${directory}/node_modules/${key}`))
execute(directory)(`npm uninstall ${key}`);
execute(directory)(`pnpm uninstall ${key}`);
record[key] =
tag === "tgz"
? path.resolve(
Expand All @@ -40,7 +40,7 @@ const deploy = (tag) => (version) => (name) => {

// SETUP UPDATED DEPENDENCIES
fs.writeFileSync(file, JSON.stringify(info, null, 2), "utf8");
execute(directory)(`npm install`);
execute(directory)(`pnpm install`);
execute(directory)(`npm run build`);

// RUN TEST PROGRAM
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@samchon/payments",
"version": "6.0.1",
"version": "6.0.3",
"description": "Collection of Payment system of Samchon",
"scripts": {
"package:latest": "node deploy latest",
Expand Down
55 changes: 27 additions & 28 deletions packages/fake-iamport-server/nestia.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@ import { NestFactory } from "@nestjs/core";
import { FakeIamportModule } from "./src/FakeIamportModule";

const NESTIA_CONFIG: INestiaConfig = {
input: () => NestFactory.create(FakeIamportModule),
output: "src/api",
simulate: true,
distribute: "../iamport-server-api",
swagger: {
output: "../iamport-server-api/swagger.json",
info: {
title: "Iamport API",
description:
"Built by [fake-iamport-server](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) with [nestia](https://github.com/samchon/nestia)",
},
servers: [
{
url: "http://localhost:10851",
description: "fake",
},
{
url: "https://api.iamport.kr",
description: "real",
},
],
security: {
bearer: {
type: "apiKey",
name: "Authorization",
in: "header",
},
},
input: () => NestFactory.create(FakeIamportModule),
output: "src/api",
distribute: "../iamport-server-api",
swagger: {
output: "../iamport-server-api/swagger.json",
info: {
title: "Iamport API",
description:
"Built by [fake-iamport-server](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) with [nestia](https://github.com/samchon/nestia)",
},
servers: [
{
url: "http://localhost:10851",
description: "fake",
},
{
url: "https://api.iamport.kr",
description: "real",
},
],
security: {
bearer: {
type: "apiKey",
name: "Authorization",
in: "header",
},
},
},
};
export default NESTIA_CONFIG;
6 changes: 4 additions & 2 deletions packages/fake-iamport-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fake-iamport-server",
"version": "6.0.1",
"version": "6.0.3",
"description": "Fake iamport server for testing",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -63,12 +63,14 @@
"@nestjs/common": "^10.2.8",
"@nestjs/core": "^10.2.8",
"@nestjs/platform-fastify": "^10.2.8",
"atob": "^2.1.2",
"btoa": "^1.2.1",
"fastify": "^4.24.3",
"serialize-error": "^4.1.0",
"source-map-support": "^0.5.19",
"tstl": "^2.5.13",
"typescript-transform-paths": "^3.4.6",
"typia": "^5.3.11",
"typia": "^5.3.12",
"uuid": "^9.0.0"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
//================================================================
import type { IConnection, Primitive } from "@nestia/fetcher";
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";
import typia from "typia";

import type { IIamportCertification } from "../../structures/IIamportCertification";
import type { IIamportResponse } from "../../structures/IIamportResponse";
import { NestiaSimulator } from "../../utils/NestiaSimulator";

export * as otp from "./otp";

Expand All @@ -37,18 +35,13 @@ export async function at(
connection: IConnection,
imp_uid: string,
): Promise<at.Output> {
return !!connection.simulate
? at.simulate(
connection,
imp_uid,
)
: PlainFetcher.fetch(
connection,
{
...at.METADATA,
path: at.path(imp_uid),
} as const,
);
return PlainFetcher.fetch(
connection,
{
...at.METADATA,
path: at.path(imp_uid),
} as const,
);
}
export namespace at {
export type Output = Primitive<IIamportResponse<IIamportCertification>>;
Expand All @@ -67,26 +60,6 @@ export namespace at {
export const path = (imp_uid: string): string => {
return `/certifications/${encodeURIComponent(imp_uid ?? "null")}`;
}
export const random = (g?: Partial<typia.IRandomGenerator>): Primitive<IIamportResponse<IIamportCertification>> =>
typia.random<Primitive<IIamportResponse<IIamportCertification>>>(g);
export const simulate = async (
connection: IConnection,
imp_uid: string,
): Promise<Output> => {
const assert = NestiaSimulator.assert({
method: METADATA.method,
host: connection.host,
path: path(imp_uid),
contentType: "application/json",
});
assert.param("imp_uid")(() => typia.assert(imp_uid));
return random(
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
}

/**
Expand All @@ -105,18 +78,13 @@ export async function erase(
connection: IConnection,
imp_uid: string,
): Promise<erase.Output> {
return !!connection.simulate
? erase.simulate(
connection,
imp_uid,
)
: PlainFetcher.fetch(
connection,
{
...erase.METADATA,
path: erase.path(imp_uid),
} as const,
);
return PlainFetcher.fetch(
connection,
{
...erase.METADATA,
path: erase.path(imp_uid),
} as const,
);
}
export namespace erase {
export type Output = Primitive<IIamportResponse<IIamportCertification>>;
Expand All @@ -135,24 +103,4 @@ export namespace erase {
export const path = (imp_uid: string): string => {
return `/certifications/${encodeURIComponent(imp_uid ?? "null")}`;
}
export const random = (g?: Partial<typia.IRandomGenerator>): Primitive<IIamportResponse<IIamportCertification>> =>
typia.random<Primitive<IIamportResponse<IIamportCertification>>>(g);
export const simulate = async (
connection: IConnection,
imp_uid: string,
): Promise<Output> => {
const assert = NestiaSimulator.assert({
method: METADATA.method,
host: connection.host,
path: path(imp_uid),
contentType: "application/json",
});
assert.param("imp_uid")(() => typia.assert(imp_uid));
return random(
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
//================================================================
import type { IConnection, Primitive } from "@nestia/fetcher";
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";
import typia from "typia";

import type { IIamportCertification } from "../../../structures/IIamportCertification";
import type { IIamportResponse } from "../../../structures/IIamportResponse";
import { NestiaSimulator } from "../../../utils/NestiaSimulator";

/**
* 본인인증 요청하기.
Expand Down Expand Up @@ -38,25 +36,20 @@ export async function request(
connection: IConnection,
input: request.Input,
): Promise<request.Output> {
return !!connection.simulate
? request.simulate(
connection,
input,
)
: PlainFetcher.fetch(
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
{
...request.METADATA,
path: request.path(),
} as const,
input,
);
return PlainFetcher.fetch(
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
{
...request.METADATA,
path: request.path(),
} as const,
input,
);
}
export namespace request {
export type Input = Primitive<IIamportCertification.ICreate>;
Expand All @@ -79,26 +72,6 @@ export namespace request {
export const path = (): string => {
return `/certifications/otp/request`;
}
export const random = (g?: Partial<typia.IRandomGenerator>): Primitive<IIamportResponse<IIamportCertification.IAccessor>> =>
typia.random<Primitive<IIamportResponse<IIamportCertification.IAccessor>>>(g);
export const simulate = async (
connection: IConnection,
input: request.Input,
): Promise<Output> => {
const assert = NestiaSimulator.assert({
method: METADATA.method,
host: connection.host,
path: path(),
contentType: "application/json",
});
assert.body(() => typia.assert(input));
return random(
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
}

/**
Expand Down Expand Up @@ -128,26 +101,20 @@ export async function confirm(
imp_uid: string,
input: confirm.Input,
): Promise<confirm.Output> {
return !!connection.simulate
? confirm.simulate(
connection,
imp_uid,
input,
)
: PlainFetcher.fetch(
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
{
...confirm.METADATA,
path: confirm.path(imp_uid),
} as const,
input,
);
return PlainFetcher.fetch(
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
{
...confirm.METADATA,
path: confirm.path(imp_uid),
} as const,
input,
);
}
export namespace confirm {
export type Input = Primitive<IIamportCertification.IConfirm>;
Expand All @@ -170,26 +137,4 @@ export namespace confirm {
export const path = (imp_uid: string): string => {
return `/certifications/otp/confirm/${encodeURIComponent(imp_uid ?? "null")}`;
}
export const random = (g?: Partial<typia.IRandomGenerator>): Primitive<IIamportResponse<IIamportCertification>> =>
typia.random<Primitive<IIamportResponse<IIamportCertification>>>(g);
export const simulate = async (
connection: IConnection,
imp_uid: string,
input: confirm.Input,
): Promise<Output> => {
const assert = NestiaSimulator.assert({
method: METADATA.method,
host: connection.host,
path: path(imp_uid),
contentType: "application/json",
});
assert.param("imp_uid")(() => typia.assert(imp_uid));
assert.body(() => typia.assert(input));
return random(
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
}
Loading
Loading