diff --git a/.gitignore b/.gitignore index 806b4d0e..9da13f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .eslintcache dist .turbo +*.tsbuildinfo +output/ # Yarn .pnp.* diff --git a/package-lock.json b/package-lock.json index 22485a89..0ca04ba0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,8 @@ "eslint-config-custom": "^0.0.0", "eslint-plugin-prettier": "^4.2.1", "prettier": "^2.8.8", - "turbo": "^1.13.0" + "turbo": "^1.13.0", + "typescript": "^5.5.4" } }, "demo": { @@ -1537,10 +1538,11 @@ } }, "node_modules/@shopify/semaphore": { - "version": "3.0.2", - "license": "MIT", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@shopify/semaphore/-/semaphore-3.1.0.tgz", + "integrity": "sha512-LxonkiWEu12FbZhuOMhsdocpxCqm7By8C/2U9QgNuEoXUx2iMrlXjJv3p93RwfNC6TrdlNRo17gRer1z1309VQ==", "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": ">=18.12.0" } }, "node_modules/@sinonjs/commons": { @@ -7857,7 +7859,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -8185,8 +8189,7 @@ "eslint": "^8.57.0", "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", - "should": "^13.2.3", - "typescript": "^5.3.3" + "should": "^13.2.3" }, "engines": { "node": ">=16" @@ -8212,8 +8215,7 @@ "eslint": "^8.57.0", "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", - "should": "^13.2.3", - "typescript": "^5.3.3" + "should": "^13.2.3" }, "engines": { "node": ">=16" @@ -8228,7 +8230,7 @@ "license": "MIT", "dependencies": { "@aws-sdk/client-s3": "^3.490.0", - "@shopify/semaphore": "^3.0.2", + "@shopify/semaphore": "^3.1.0", "@tus/utils": "^0.3.0", "debug": "^4.3.4", "multistream": "^4.1.0" @@ -8241,8 +8243,7 @@ "eslint": "^8.57.0", "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", - "should": "^13.2.3", - "typescript": "^5.3.3" + "should": "^13.2.3" }, "engines": { "node": ">=16" @@ -8271,8 +8272,7 @@ "should": "^13.2.3", "sinon": "^17.0.1", "supertest": "^6.3.4", - "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "ts-node": "^10.9.2" }, "engines": { "node": ">=16" @@ -8293,8 +8293,7 @@ "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", "should": "^13.2.3", - "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "ts-node": "^10.9.2" }, "engines": { "node": ">=16" @@ -8321,8 +8320,7 @@ "sinon": "^17.0.1", "supertest": "^6.3.4", "throttle": "^1.0.3", - "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "ts-node": "^10.9.2" } } } diff --git a/package.json b/package.json index 81f41553..bfe6fb9d 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,13 @@ "test" ], "scripts": { - "build": "turbo run build", + "build": "tsc --build", "demo": "npm run --workspace demo start", "demo:gcs": "npm run --workspace demo start:gcs", "demo:s3": "npm run --workspace demo start:s3", - "lint": "turbo run lint", - "format": "turbo run format", + "lint": "eslint .", + "format": "eslint --fix .", + "pretest": "tsc --build", "test": "turbo run test", "version": "changeset version", "release": "gh workflow run release", @@ -25,7 +26,8 @@ "eslint-config-custom": "^0.0.0", "eslint-plugin-prettier": "^4.2.1", "prettier": "^2.8.8", - "turbo": "^1.13.0" + "turbo": "^1.13.0", + "typescript": "^5.5.4" }, "version": "0.0.0" } diff --git a/packages/file-store/package.json b/packages/file-store/package.json index fc10f949..d8b7715d 100644 --- a/packages/file-store/package.json +++ b/packages/file-store/package.json @@ -4,7 +4,6 @@ "version": "1.4.0", "description": "Local file storage for @tus/server", "main": "dist/index.js", - "types": "dist/index.d.ts", "homepage": "https://github.com/tus/tus-node-server#readme", "bugs": "https://github.com/tus/tus-node-server/issues", "repository": "tus/tus-node-server", @@ -15,10 +14,10 @@ ], "license": "MIT", "scripts": { - "build": "tsc", + "build": "tsc --build", "lint": "eslint .", "format": "eslint --fix .", - "test": "mocha test.ts --exit --extension ts --require ts-node/register" + "test": "mocha --exit --extension ts --require ts-node/register" }, "dependencies": { "@tus/utils": "^0.3.0", @@ -31,8 +30,7 @@ "eslint": "^8.57.0", "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", - "should": "^13.2.3", - "typescript": "^5.3.3" + "should": "^13.2.3" }, "optionalDependencies": { "@redis/client": "^1.5.13" diff --git a/packages/file-store/configstores/index.ts b/packages/file-store/src/configstores/index.ts similarity index 100% rename from packages/file-store/configstores/index.ts rename to packages/file-store/src/configstores/index.ts diff --git a/packages/file-store/index.ts b/packages/file-store/src/index.ts similarity index 100% rename from packages/file-store/index.ts rename to packages/file-store/src/index.ts diff --git a/packages/file-store/test.ts b/packages/file-store/test/index.ts similarity index 97% rename from packages/file-store/test.ts rename to packages/file-store/test/index.ts index 215c00b6..ea8bc3c5 100644 --- a/packages/file-store/test.ts +++ b/packages/file-store/test/index.ts @@ -7,10 +7,10 @@ import path from 'node:path' import sinon from 'sinon' -import {FileStore, FileConfigstore} from './' +import {FileStore, FileConfigstore} from '../src' import {Upload} from '@tus/utils' -import * as shared from '../../test/stores.test' +import * as shared from 'test/stores.test' const fixturesPath = path.resolve('../', '../', 'test', 'fixtures') const storePath = path.resolve('../', '../', 'test', 'output', 'file-store') diff --git a/packages/file-store/tsconfig.build.json b/packages/file-store/tsconfig.build.json new file mode 100644 index 00000000..1342a95a --- /dev/null +++ b/packages/file-store/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "references": [{"path": "../utils/tsconfig.build.json"}], + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/packages/file-store/tsconfig.json b/packages/file-store/tsconfig.json index 82640f1d..22f7865a 100644 --- a/packages/file-store/tsconfig.json +++ b/packages/file-store/tsconfig.json @@ -1,8 +1,9 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../../tsconfig.json", - "include": ["index.ts"], + "references": [{"path": "./tsconfig.build.json"}, {"path": "../../test/tsconfig.json"}], + "extends": "../../tsconfig.base.json", + "exclude": ["src"], "compilerOptions": { - "outDir": "./dist" + "noEmit": true } } diff --git a/packages/gcs-store/package.json b/packages/gcs-store/package.json index 0cada6c9..465d972e 100644 --- a/packages/gcs-store/package.json +++ b/packages/gcs-store/package.json @@ -4,7 +4,6 @@ "version": "1.3.0", "description": "Google Cloud Storage for @tus/server", "main": "dist/index.js", - "types": "dist/index.d.ts", "homepage": "https://github.com/tus/tus-node-server#readme", "bugs": "https://github.com/tus/tus-node-server/issues", "repository": "tus/tus-node-server", @@ -15,10 +14,10 @@ "dist" ], "scripts": { - "build": "tsc", + "build": "tsc --build", "lint": "eslint .", "format": "eslint --fix .", - "test": "mocha test.ts --timeout 30000 --exit --extension ts --require ts-node/register" + "test": "mocha --timeout 30000 --exit --extension ts --require ts-node/register" }, "dependencies": { "@tus/utils": "^0.3.0", @@ -33,8 +32,7 @@ "eslint": "^8.57.0", "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", - "should": "^13.2.3", - "typescript": "^5.3.3" + "should": "^13.2.3" }, "peerDependencies": { "@google-cloud/storage": "^7.12.0" diff --git a/packages/gcs-store/index.ts b/packages/gcs-store/src/index.ts similarity index 100% rename from packages/gcs-store/index.ts rename to packages/gcs-store/src/index.ts diff --git a/packages/gcs-store/test.ts b/packages/gcs-store/test/index.ts similarity index 92% rename from packages/gcs-store/test.ts rename to packages/gcs-store/test/index.ts index 810437df..c08f968b 100644 --- a/packages/gcs-store/test.ts +++ b/packages/gcs-store/test/index.ts @@ -1,8 +1,8 @@ import path from 'node:path' -import {GCSStore} from './' +import {GCSStore} from '../src' -import * as shared from '../../test/stores.test' +import * as shared from 'test/stores.test' import {Storage} from '@google-cloud/storage' diff --git a/packages/gcs-store/tsconfig.build.json b/packages/gcs-store/tsconfig.build.json new file mode 100644 index 00000000..a34ce5d0 --- /dev/null +++ b/packages/gcs-store/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "references": [{"path": "../utils//tsconfig.build.json"}], + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/packages/gcs-store/tsconfig.json b/packages/gcs-store/tsconfig.json index 82640f1d..22f7865a 100644 --- a/packages/gcs-store/tsconfig.json +++ b/packages/gcs-store/tsconfig.json @@ -1,8 +1,9 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../../tsconfig.json", - "include": ["index.ts"], + "references": [{"path": "./tsconfig.build.json"}, {"path": "../../test/tsconfig.json"}], + "extends": "../../tsconfig.base.json", + "exclude": ["src"], "compilerOptions": { - "outDir": "./dist" + "noEmit": true } } diff --git a/packages/s3-store/package.json b/packages/s3-store/package.json index aa36c238..dc468d81 100644 --- a/packages/s3-store/package.json +++ b/packages/s3-store/package.json @@ -4,7 +4,6 @@ "version": "1.5.0", "description": "AWS S3 store for @tus/server", "main": "dist/index.js", - "types": "dist/index.d.ts", "homepage": "https://github.com/tus/tus-node-server#readme", "bugs": "https://github.com/tus/tus-node-server/issues", "repository": "tus/tus-node-server", @@ -15,14 +14,14 @@ "dist" ], "scripts": { - "build": "tsc", + "build": "tsc --build", "lint": "eslint .", "format": "eslint --fix .", - "test": "mocha test.ts --timeout 40000 --exit --extension ts --require ts-node/register" + "test": "mocha --timeout 40000 --exit --extension ts --require ts-node/register" }, "dependencies": { "@aws-sdk/client-s3": "^3.490.0", - "@shopify/semaphore": "^3.0.2", + "@shopify/semaphore": "^3.1.0", "@tus/utils": "^0.3.0", "debug": "^4.3.4", "multistream": "^4.1.0" @@ -35,8 +34,7 @@ "eslint": "^8.57.0", "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", - "should": "^13.2.3", - "typescript": "^5.3.3" + "should": "^13.2.3" }, "engines": { "node": ">=16" diff --git a/packages/s3-store/index.ts b/packages/s3-store/src/index.ts similarity index 100% rename from packages/s3-store/index.ts rename to packages/s3-store/src/index.ts diff --git a/packages/s3-store/test.ts b/packages/s3-store/test/index.ts similarity index 98% rename from packages/s3-store/test.ts rename to packages/s3-store/test/index.ts index 2101ccb3..6abcf32c 100644 --- a/packages/s3-store/test.ts +++ b/packages/s3-store/test/index.ts @@ -4,8 +4,8 @@ import {Readable} from 'node:stream' import sinon from 'sinon' -import {S3Store} from './' -import * as shared from '../../test/stores.test' +import {S3Store} from '../src' +import * as shared from 'test/stores.test' import {Upload} from '@tus/utils' const fixturesPath = path.resolve('../', '../', 'test', 'fixtures') diff --git a/packages/s3-store/tsconfig.build.json b/packages/s3-store/tsconfig.build.json new file mode 100644 index 00000000..a34ce5d0 --- /dev/null +++ b/packages/s3-store/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "references": [{"path": "../utils//tsconfig.build.json"}], + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/packages/s3-store/tsconfig.json b/packages/s3-store/tsconfig.json index 82640f1d..22f7865a 100644 --- a/packages/s3-store/tsconfig.json +++ b/packages/s3-store/tsconfig.json @@ -1,8 +1,9 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../../tsconfig.json", - "include": ["index.ts"], + "references": [{"path": "./tsconfig.build.json"}, {"path": "../../test/tsconfig.json"}], + "extends": "../../tsconfig.base.json", + "exclude": ["src"], "compilerOptions": { - "outDir": "./dist" + "noEmit": true } } diff --git a/packages/server/package.json b/packages/server/package.json index 4435dd3d..f5a634e4 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -4,7 +4,6 @@ "version": "1.7.0", "description": "Tus resumable upload protocol in Node.js", "main": "dist/index.js", - "types": "dist/index.d.ts", "homepage": "https://github.com/tus/tus-node-server#readme", "bugs": "https://github.com/tus/tus-node-server/issues", "repository": "tus/tus-node-server", @@ -15,7 +14,7 @@ "dist" ], "scripts": { - "build": "tsc", + "build": "tsc --build", "lint": "eslint .", "format": "eslint --fix .", "test": "mocha --timeout 40000 --exit --extension ts --require ts-node/register" @@ -39,8 +38,7 @@ "should": "^13.2.3", "sinon": "^17.0.1", "supertest": "^6.3.4", - "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "ts-node": "^10.9.2" }, "optionalDependencies": { "@redis/client": "^1.5.13" diff --git a/packages/server/tsconfig.build.json b/packages/server/tsconfig.build.json new file mode 100644 index 00000000..1342a95a --- /dev/null +++ b/packages/server/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "references": [{"path": "../utils/tsconfig.build.json"}], + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/packages/server/tsconfig.json b/packages/server/tsconfig.json index 962ac078..3a707d7e 100644 --- a/packages/server/tsconfig.json +++ b/packages/server/tsconfig.json @@ -1,8 +1,9 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../../tsconfig.json", - "include": ["src"], + "references": [{"path": "./tsconfig.build.json"}], + "extends": "../../tsconfig.base.json", + "exclude": ["src"], "compilerOptions": { - "outDir": "./dist" + "noEmit": true } } diff --git a/packages/utils/package.json b/packages/utils/package.json index 6b60ea6a..6c8ca864 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -4,7 +4,6 @@ "version": "0.3.0", "description": "Internal utils for tus Node.js server and stores", "main": "dist/index.js", - "types": "dist/index.d.ts", "homepage": "https://github.com/tus/tus-node-server#readme", "bugs": "https://github.com/tus/tus-node-server/issues", "repository": "tus/tus-node-server", @@ -15,7 +14,7 @@ "dist" ], "scripts": { - "build": "tsc", + "build": "tsc --build", "lint": "eslint .", "format": "eslint --fix .", "test": "mocha --timeout 40000 --exit --extension ts --require ts-node/register" @@ -28,8 +27,7 @@ "eslint-config-custom": "^0.0.0", "mocha": "^10.4.0", "should": "^13.2.3", - "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "ts-node": "^10.9.2" }, "engines": { "node": ">=16" diff --git a/packages/utils/tsconfig.build.json b/packages/utils/tsconfig.build.json new file mode 100644 index 00000000..5eaf56de --- /dev/null +++ b/packages/utils/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 962ac078..3a707d7e 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -1,8 +1,9 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../../tsconfig.json", - "include": ["src"], + "references": [{"path": "./tsconfig.build.json"}], + "extends": "../../tsconfig.base.json", + "exclude": ["src"], "compilerOptions": { - "outDir": "./dist" + "noEmit": true } } diff --git a/test/package.json b/test/package.json index b9fcf683..bff25578 100644 --- a/test/package.json +++ b/test/package.json @@ -3,8 +3,11 @@ "name": "test", "private": true, "scripts": { - "build": "tsc", - "test": "mocha e2e.test.ts s3.e2e.ts --timeout 40000 --exit --extension ts --require ts-node/register" + "build": "tsc --build", + "test": "mocha dist/e2e.test.js dist/s3.e2e.js --timeout 40000 --exit --extension ts --require ts-node/register" + }, + "exports": { + "./stores.test": "./dist/stores.test.js" }, "dependencies": { "@google-cloud/storage": "^7.12.0", @@ -26,7 +29,6 @@ "sinon": "^17.0.1", "supertest": "^6.3.4", "throttle": "^1.0.3", - "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "ts-node": "^10.9.2" } } diff --git a/test/e2e.test.ts b/test/src/e2e.test.ts similarity index 100% rename from test/e2e.test.ts rename to test/src/e2e.test.ts diff --git a/test/s3.e2e.ts b/test/src/s3.e2e.ts similarity index 100% rename from test/s3.e2e.ts rename to test/src/s3.e2e.ts diff --git a/test/stores.test.ts b/test/src/stores.test.ts similarity index 100% rename from test/stores.test.ts rename to test/src/stores.test.ts diff --git a/test/tsconfig.json b/test/tsconfig.json index 296861d8..2c512eed 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,8 +1,15 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../tsconfig.json", - "include": ["e2e.test.ts"], + "references": [ + {"path": "../packages/file-store/tsconfig.build.json"}, + {"path": "../packages/gcs-store/tsconfig.build.json"}, + {"path": "../packages/s3-store/tsconfig.build.json"}, + {"path": "../packages/server/tsconfig.build.json"} + ], + "extends": "../tsconfig.base.json", + "include": ["src"], "compilerOptions": { - "noEmit": true + "rootDir": "src", + "outDir": "dist" } } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..a9598a7e --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "compilerOptions": { + "composite": true, + "lib": ["es2020"], + "module": "node16", + "target": "es2020", + "strict": true, + "declaration": true, + "useUnknownInCatchVariables": false + } +} diff --git a/tsconfig.json b/tsconfig.json index baac30bf..e4ba358d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,12 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", - "exclude": ["node_modules"], - "compilerOptions": { - "lib": ["es2020"], - "module": "commonjs", - "target": "es2020", - "strict": true, - "declaration": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "useUnknownInCatchVariables": false - } + "files": [], + "references": [ + {"path": "packages/file-store/tsconfig.json"}, + {"path": "packages/gcs-store/tsconfig.json"}, + {"path": "packages/s3-store/tsconfig.json"}, + {"path": "packages/server/tsconfig.json"}, + {"path": "packages/utils/tsconfig.json"}, + {"path": "test/tsconfig.json"} + ] }