diff --git a/.gitignore b/.gitignore index 6026758a1..b6fbb9f47 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ yarn-error.log coverage tests/**/yarn.lock tests/**/quick-start.ts -tests/**/issue952.* diff --git a/.prettierignore b/.prettierignore index 2f730cc54..f349d0fd8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,3 @@ node_modules dist coverage tests/**/quick-start.ts -tests/**/issue952.* diff --git a/package.json b/package.json index 118065552..d9cd6390f 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,9 @@ "start": "yarn tsnode example/index.ts", "build": "yarn build:compile && yarn build:tests && yarn build:assets", "build:compile": "tsup && attw --pack", - "build:tests": "yarn build:int && yarn build:esm && yarn build:vi", + "build:tests": "yarn cleanup && yarn build:int && yarn build:952 && yarn build:esm && yarn build:vi", "build:int": "yarn tsnode tools/integration-test.ts && yarn install --cwd ./tests/integration", + "build:952": "yarn tsnode tools/issue952-test.ts && yarn install --cwd ./tests/issue952", "build:esm": "yarn tsnode tools/esm-test.ts && yarn install --cwd ./tests/esm", "build:vi": "yarn install --cwd ./tests/vitest", "build:assets": "yarn build:swagger && yarn build:client && yarn build:license", @@ -31,7 +32,7 @@ "build:logo": "yarn tsnode tools/startup-logo.ts", "test": "yarn test:types && yarn test:jest && yarn test:badge", "test:int": "jest ./tests/integration", - "test:952": "yarn --cwd tests/integration tsc -p tsconfig.issue952.json && rm tests/integration/issue952.d.ts", + "test:952": "yarn --cwd ./tests/issue952 test", "test:esm": "jest ./tests/esm", "test:vi": "yarn --cwd ./tests/vitest test", "test:u": "yarn test:jest -u && yarn test:badge", @@ -40,6 +41,7 @@ "test:badge": "make-coverage-badge --output-path ./coverage.svg", "lint": "eslint src example tests tools && yarn prettier *.md --check", "mdfix": "prettier *.md --write", + "cleanup": "rm -rf tests/**/node_modules", "tsnode": "node -r @swc-node/register", "precommit": "yarn build && yarn lint && yarn test && git add example/example.swagger.yaml example/example.client.ts ./LICENSE ./coverage.svg", "prepublishOnly": "yarn build && yarn lint && yarn test", diff --git a/tests/esm/package.json b/tests/esm/package.json index 874311ca8..db3f2e277 100644 --- a/tests/esm/package.json +++ b/tests/esm/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "dependencies": { - "express-zod-api": "../..", + "express-zod-api": "link:../..", "express": "^4", "http-errors": "^2", "typescript": "^5", diff --git a/tests/integration/package.json b/tests/integration/package.json index 1d85ed810..38f5abeda 100644 --- a/tests/integration/package.json +++ b/tests/integration/package.json @@ -3,13 +3,10 @@ "private": true, "version": "0.0.0", "dependencies": { - "express-zod-api": "../..", + "express-zod-api": "link:../..", "express": "^4", "http-errors": "^2", "typescript": "^5", "zod": "^3" - }, - "devDependencies": { - "@types/express": "^4" } } diff --git a/tests/issue952/package.json b/tests/issue952/package.json new file mode 100644 index 000000000..6a1172784 --- /dev/null +++ b/tests/issue952/package.json @@ -0,0 +1,19 @@ +{ + "name": "express-zod-api-issue-952-test", + "private": true, + "version": "0.0.0", + "scripts": { + "test": "tsc -p tsconfig.json", + "posttest": "rm quick-start.d.ts" + }, + "dependencies": { + "express-zod-api": "link:../..", + "express": "^4", + "http-errors": "^2", + "typescript": "^5", + "zod": "^3" + }, + "devDependencies": { + "@types/express": "^4" + } +} diff --git a/tests/integration/tsconfig.issue952.json b/tests/issue952/tsconfig.json similarity index 68% rename from tests/integration/tsconfig.issue952.json rename to tests/issue952/tsconfig.json index f6d0d4353..4f3fd6c04 100644 --- a/tests/integration/tsconfig.issue952.json +++ b/tests/issue952/tsconfig.json @@ -4,6 +4,5 @@ "declaration": true, "emitDeclarationOnly": true }, - "include": ["issue952.ts"], - "exclude": ["quick*.ts"] + "include": ["*.ts"] } diff --git a/tools/integration-test.ts b/tools/integration-test.ts index a50cd8e40..b510965b3 100644 --- a/tools/integration-test.ts +++ b/tools/integration-test.ts @@ -3,9 +3,5 @@ import { extractReadmeQuickStart } from "./extract-quick-start"; const quickStart = extractReadmeQuickStart(); -/** @link https://github.com/RobinTail/express-zod-api/issues/952 */ -const issue952 = quickStart.replace(/const/g, "export const"); - const dir = "./tests/integration"; writeFileSync(`${dir}/quick-start.ts`, quickStart.trim()); -writeFileSync(`${dir}/issue952.ts`, issue952.trim()); diff --git a/tools/issue952-test.ts b/tools/issue952-test.ts new file mode 100644 index 000000000..5fee1b2de --- /dev/null +++ b/tools/issue952-test.ts @@ -0,0 +1,10 @@ +import { writeFileSync } from "node:fs"; +import { extractReadmeQuickStart } from "./extract-quick-start"; + +const quickStart = extractReadmeQuickStart(); + +/** @link https://github.com/RobinTail/express-zod-api/issues/952 */ +const issue952 = quickStart.replace(/const/g, "export const"); + +const dir = "./tests/issue952"; +writeFileSync(`${dir}/quick-start.ts`, issue952.trim());