Skip to content

Commit

Permalink
Package build v1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Vercjames committed May 30, 2024
1 parent cab859f commit 4cc36ce
Show file tree
Hide file tree
Showing 14 changed files with 549 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*
!build/**/*
!packages/**/*
!package.json
!package-lock.json
!LICENSE
!README.md
10 changes: 8 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
module.exports = {
import type { JestConfigWithTsJest } from "ts-jest"

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const jestConfig: JestConfigWithTsJest = {
preset: "ts-jest",
testEnvironment: "node",
rootDir: "./tests",
testEnvironment: "node",
snapshotFormat: {
escapeString: true,
printBasicPrototype: true
}
}

// Export the configuration to be used by Jest
export default jestConfig
35 changes: 21 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
{
"name": "trpc-swagger",
"private": false,
"license": "MIT",
"version": "1.2.4",
"version": "1.2.5",
"description": "tRPC Swagger Wrapper",
"keywords": ["trpc", "openapi", "swagger"],
"author": "https://github.com/vercjames",
"homepage": "https://github.com/vercjames/package-trpc-swagger",
"bugs": "https://github.com/vercjames/package-trpc-swagger/issues",
"keywords": [
"trpc",
"openapi",
"swagger"
],
"typings": "build/index.d.ts",
"main": "build/index.js",
"types": "build/index.d.ts",
"private": false,
"repository": {
"type": "git",
"url": "git+https://github.com/vercjames/package-trpc-swagger.git"
},
"scripts": {
"test": "tsc --noEmit && jest --verbose",
"build": "rimraf build && tsc -p tsconfig.build.json",
"build": "tsup --format cjs,esm --dts",
"prepublishOnly": "tsx prepublish.ts",
"format": "eslint --fix \"./packages/**/*.{js,jsx,ts,tsx}\"",
"lint:fix": "eslint --fix \"./packages/**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint \"./packages/**/*.{js,jsx,ts,tsx}\""
"lint": "eslint \"./packages/**/*.{js,jsx,ts,tsx}\"",
"test": "node --experimental-modules --experimental-vm-modules node_modules/.bin/jest --config jest.config.ts"
},
"workspaces": [
".",
Expand All @@ -36,12 +32,13 @@
"examples/with-serverless"
],
"peerDependencies": {
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"zod": "^3.14.4"
},
"dependencies": {
"chalk-scripts": "^1.2.6",
"co-body": "^6.1.0",
"h3": "^1.11.1",
"lodash.clonedeep": "^4.5.0",
"node-mocks-http": "^1.14.1",
"openapi-types": "^12.1.3",
Expand Down Expand Up @@ -75,12 +72,22 @@
"next": "^14.2.3",
"node-fetch": "^2.7.0",
"openapi-schema-validator": "^12.1.3",
"rimraf": "^5.0.7",
"semver": "^7.6.2",
"superjson": "^1.13.3",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"tsup": "^8.0.2",
"tsx": "^4.11.0",
"typescript": "^5.4.5",
"zod": "^3.23.8"
},
"tsup": {
"entry": [
"packages/index.ts"
],
"outDir": "build",
"splitting": true,
"sourcemap": true,
"clean": true
}
}
18 changes: 18 additions & 0 deletions prepublish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { existsSync } from "fs"
import { script } from "chalk-scripts"

// Application Component || Define Setup
// =================================================================================================
// =================================================================================================
const buildFolder = "./build"

// Application Component || Define Tests
// =================================================================================================
// =================================================================================================
if (!existsSync(buildFolder)) {
(async () => {
const c = await script.start({ func: "prepublishOnly()" })
script.config(c).mistake("build folder does not exist").log()
process.exit(1)
})()
}
3 changes: 2 additions & 1 deletion tests/adapters/express.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { initTRPC } from "@trpc/server"
import express from "express"
import fetch from "node-fetch"
import { jest } from "@jest/globals"
import { initTRPC } from "@trpc/server"
import { z } from "zod"

// Application Sectional || Define Imports
Expand Down
5 changes: 3 additions & 2 deletions tests/adapters/fastify.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { initTRPC } from "@trpc/server"
import fastify from "fastify"
import fetch from "node-fetch"
import fastify from "fastify"
import { jest } from "@jest/globals"
import { initTRPC } from "@trpc/server"
import { z } from "zod"

// Application Sectional || Define Imports
Expand Down
5 changes: 3 additions & 2 deletions tests/adapters/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TRPCError, initTRPC } from "@trpc/server"
import fetch from "node-fetch"
import superjson from "superjson"
import { jest } from "@jest/globals"
import { TRPCError, initTRPC } from "@trpc/server"
import { z } from "zod"

// Application Sectional || Define Imports
Expand Down Expand Up @@ -1190,7 +1191,7 @@ describe("fetch adapter", () => {
expect(onErrorMock).toHaveBeenCalledTimes(0)
}
// @ts-expect-error - hack to re-enable zodSupportsCoerce
// eslint-disable-next-line import/namespace
// eslint-disable-next-line
zodUtils.zodSupportsCoerce = true
})

Expand Down
1 change: 1 addition & 0 deletions tests/adapters/next.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals"
import { initTRPC } from "@trpc/server"
import { NextApiRequest, NextApiResponse } from "next"
import { z } from "zod"
Expand Down
3 changes: 2 additions & 1 deletion tests/adapters/nuxt.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { initTRPC } from "@trpc/server"
import { H3Event } from "h3"
import { jest } from "@jest/globals"
import { initTRPC } from "@trpc/server"
import httpMocks, { RequestMethod } from "node-mocks-http"
import { z } from "zod"

Expand Down
12 changes: 7 additions & 5 deletions tests/adapters/standalone.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client"
import fetch from "node-fetch"
import { jest } from "@jest/globals"
import { TRPCError, initTRPC } from "@trpc/server"
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client"
import { createHTTPHandler } from "@trpc/server/adapters/standalone"
import { Server } from "http"
import fetch from "node-fetch"
import superjson from "superjson"
import { Server } from "http"
import { z } from "zod"

// Application Sectional || Define Imports
// =================================================================================================
// =================================================================================================
Expand Down Expand Up @@ -1197,7 +1199,7 @@ describe("standalone adapter", () => {
// only applies when zod does not support (below version v3.20.0)

// @ts-expect-error - hack to disable zodSupportsCoerce
// eslint-disable-next-line import/namespace
// eslint-disable-next-line
zodUtils.zodSupportsCoerce = false
{
const appRouter = t.router({
Expand Down Expand Up @@ -1231,7 +1233,7 @@ describe("standalone adapter", () => {
close()
}
// @ts-expect-error - hack to re-enable zodSupportsCoerce
// eslint-disable-next-line import/namespace
// eslint-disable-next-line
zodUtils.zodSupportsCoerce = true
})

Expand Down
7 changes: 3 additions & 4 deletions tests/generator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { initTRPC } from "@trpc/server"
import { observable } from "@trpc/server/observable"
import openAPISchemaValidator from "openapi-schema-validator"
import OpenAPISchemaValidator from "openapi-schema-validator"
import { z } from "zod"

import {
Expand All @@ -12,8 +12,7 @@ import {
import * as zodUtils from "../packages/utils/zod"

// TODO: test for duplicate paths (using getPathRegExp)

const openApiSchemaValidator = new openAPISchemaValidator({ version: openApiVersion })
const openApiSchemaValidator = new OpenAPISchemaValidator({ version: openApiVersion })

const t = initTRPC.meta<OpenApiMeta>().context<any>().create()

Expand Down Expand Up @@ -282,7 +281,7 @@ describe("generator", () => {
}

// @ts-expect-error - hack to re-enable zodSupportsCoerce
// eslint-disable-next-line import/namespace
// eslint-disable-next-line
zodUtils.zodSupportsCoerce = true
})

Expand Down
11 changes: 9 additions & 2 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"extends": "./tsconfig.json",
"include": ["**/*", ".eslintrc"],
"exclude": ["node_modules", "dist", "build"]
"include": [
"**/*",
".eslintrc"
],
"exclude": [
"dist",
"build",
"node_modules"
]
}
Loading

0 comments on commit 4cc36ce

Please sign in to comment.