diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f891a76..40ff25d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,8 +24,20 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} + validateBundling: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: corepack enable + - run: npm i -g @arethetypeswrong/cli + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: yarn + - run: attw --pack . release: needs: - test + - validateBundling uses: ./.github/workflows/release.yaml secrets: inherit \ No newline at end of file diff --git a/package.cjs.json b/package.cjs.json new file mode 100644 index 0000000..c9a4422 --- /dev/null +++ b/package.cjs.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/package.json b/package.json index 0b2ceb2..cacace1 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,12 @@ }, "files": [ "dist", + "upload/*.d.ts", + "validations/*.d.ts", "*.d.ts" ], "scripts": { - "build": "tsc --project tsconfig.build.json && tsc --project tsconfig.cjs.build.json && sh ./esm-postbuild.sh", + "build": "tsc --project tsconfig.build.json && tsc --project tsconfig.cjs.build.json && cpy --rename package.json ./package.cjs.json ./dist/cjs", "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --ci", "test:watch": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --watch", "test:coverage": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage", @@ -55,7 +57,7 @@ "lint:fix": "yarn lint --fix", "prettify": "prettier \"**/*.{ts,tsx,graphql,md}\" --write", "qa": "tsc --noEmit && yarn test --coverage && yarn lint && yarn format", - "prepack": "yarn build && cp ./dist/mjs/*.d.ts ." + "prepack": "yarn build && cpy ./dist/mjs/**/*.d.ts ." }, "exports": { ".": { @@ -103,6 +105,7 @@ "@types/supertest": "^6.0.2", "@typescript-eslint/eslint-plugin": "^7.4.0", "@typescript-eslint/parser": "^7.4.0", + "cpy-cli": "^5.0.0", "eslint": "^8.57.0", "express": "^4.19.2", "jest": "^29.7.0", diff --git a/src/express.ts b/src/express.ts index 8b32e1b..5713d57 100644 --- a/src/express.ts +++ b/src/express.ts @@ -15,7 +15,7 @@ import { GraphQLExecutor } from './graphQLExecutor.js' import { createOpenAPISchemaWithValidate } from './utils.js' import { createRequestHandler } from './createRequestHandler.js' -export { graphqlUploadExpress } from './graphql-upload/expressMiddleware.js' +export { graphqlUploadExpress } from './upload/expressMiddleware.js' const middlewareToPromise = (middleware: RequestHandler) => diff --git a/src/graphql-upload.ts b/src/graphql-upload.ts index b95cd50..48960c8 100644 --- a/src/graphql-upload.ts +++ b/src/graphql-upload.ts @@ -3,8 +3,8 @@ export { GraphQLUpload, createGraphQLUploads, createGraphQLUpload, -} from './graphql-upload/scalars.js' -export { processRequest, FileUpload } from './graphql-upload/processRequest.js' +} from './upload/scalars.js' +export { processRequest, FileUpload } from './upload/processRequest.js' -export { UploadScalars } from './graphql-upload/openapi.js' +export { UploadScalars } from './upload/openapi.js' export { AsyncQueue } from './iterable.js' diff --git a/src/graphql-upload/README.md b/src/upload/README.md similarity index 100% rename from src/graphql-upload/README.md rename to src/upload/README.md diff --git a/src/graphql-upload/Upload.ts b/src/upload/Upload.ts similarity index 100% rename from src/graphql-upload/Upload.ts rename to src/upload/Upload.ts diff --git a/src/graphql-upload/__tests__/__snapshots__/process-request.spec.ts.snap b/src/upload/__tests__/__snapshots__/process-request.spec.ts.snap similarity index 100% rename from src/graphql-upload/__tests__/__snapshots__/process-request.spec.ts.snap rename to src/upload/__tests__/__snapshots__/process-request.spec.ts.snap diff --git a/src/graphql-upload/__tests__/__snapshots__/utils.spec.ts.snap b/src/upload/__tests__/__snapshots__/utils.spec.ts.snap similarity index 100% rename from src/graphql-upload/__tests__/__snapshots__/utils.spec.ts.snap rename to src/upload/__tests__/__snapshots__/utils.spec.ts.snap diff --git a/src/graphql-upload/__tests__/process-request.spec.ts b/src/upload/__tests__/process-request.spec.ts similarity index 100% rename from src/graphql-upload/__tests__/process-request.spec.ts rename to src/upload/__tests__/process-request.spec.ts diff --git a/src/graphql-upload/__tests__/utils.spec.ts b/src/upload/__tests__/utils.spec.ts similarity index 100% rename from src/graphql-upload/__tests__/utils.spec.ts rename to src/upload/__tests__/utils.spec.ts diff --git a/src/graphql-upload/expressMiddleware.ts b/src/upload/expressMiddleware.ts similarity index 100% rename from src/graphql-upload/expressMiddleware.ts rename to src/upload/expressMiddleware.ts diff --git a/src/graphql-upload/ignoreStream.ts b/src/upload/ignoreStream.ts similarity index 100% rename from src/graphql-upload/ignoreStream.ts rename to src/upload/ignoreStream.ts diff --git a/src/graphql-upload/openapi.ts b/src/upload/openapi.ts similarity index 100% rename from src/graphql-upload/openapi.ts rename to src/upload/openapi.ts diff --git a/src/graphql-upload/processRequest.ts b/src/upload/processRequest.ts similarity index 100% rename from src/graphql-upload/processRequest.ts rename to src/upload/processRequest.ts diff --git a/src/graphql-upload/scalars.ts b/src/upload/scalars.ts similarity index 100% rename from src/graphql-upload/scalars.ts rename to src/upload/scalars.ts diff --git a/src/graphql-upload/utils.ts b/src/upload/utils.ts similarity index 100% rename from src/graphql-upload/utils.ts rename to src/upload/utils.ts diff --git a/yarn.lock b/yarn.lock index da1d19c..a229c02 100644 --- a/yarn.lock +++ b/yarn.lock @@ -543,6 +543,7 @@ __metadata: "@typescript-eslint/parser": "npm:^7.4.0" ajv: "npm:^8.12.0" busboy: "npm:^1.6.0" + cpy-cli: "npm:^5.0.0" eslint: "npm:^8.57.0" express: "npm:^4.19.2" fs-capacitor: "npm:^8.0.0" @@ -2297,6 +2298,16 @@ __metadata: languageName: node linkType: hard +"aggregate-error@npm:^4.0.0": + version: 4.0.1 + resolution: "aggregate-error@npm:4.0.1" + dependencies: + clean-stack: "npm:^4.0.0" + indent-string: "npm:^5.0.0" + checksum: 10c0/75fd739f5c4c60a667cce35ccaf0edf135e147ef0be9a029cab75de14ac9421779b15339d562e58d25b233ea0ef2bbd4c916f149fdbcb73c2b9a62209e611343 + languageName: node + linkType: hard + "aggregate-error@npm:^5.0.0": version: 5.0.0 resolution: "aggregate-error@npm:5.0.0" @@ -2509,6 +2520,13 @@ __metadata: languageName: node linkType: hard +"arrify@npm:^3.0.0": + version: 3.0.0 + resolution: "arrify@npm:3.0.0" + checksum: 10c0/2e26601b8486f29780f1f70f7ac05a226755814c2a3ab42e196748f650af1dc310cd575a11dd4b9841c70fd7460b2dd2b8fe6fb7a3375878e2660706efafa58e + languageName: node + linkType: hard + "asap@npm:^2.0.0": version: 2.0.6 resolution: "asap@npm:2.0.6" @@ -2932,6 +2950,15 @@ __metadata: languageName: node linkType: hard +"clean-stack@npm:^4.0.0": + version: 4.2.0 + resolution: "clean-stack@npm:4.2.0" + dependencies: + escape-string-regexp: "npm:5.0.0" + checksum: 10c0/2bdf981a0fef0a23c14255df693b30eb9ae27eedf212470d8c400a0c0b6fb82fbf1ff8c5216ccd5721e3670b700389c886b1dce5070776dc9fbcc040957758c0 + languageName: node + linkType: hard + "clean-stack@npm:^5.2.0": version: 5.2.0 resolution: "clean-stack@npm:5.2.0" @@ -3268,6 +3295,45 @@ __metadata: languageName: node linkType: hard +"cp-file@npm:^10.0.0": + version: 10.0.0 + resolution: "cp-file@npm:10.0.0" + dependencies: + graceful-fs: "npm:^4.2.10" + nested-error-stacks: "npm:^2.1.1" + p-event: "npm:^5.0.1" + checksum: 10c0/acff14b4d267c4179daa4fb913b974d9e6a3d9de9a55283712eaf7c8e05488cd50214d58173d38e0cb5b8111773afbd7755fe912d4147862009d695a51db7393 + languageName: node + linkType: hard + +"cpy-cli@npm:^5.0.0": + version: 5.0.0 + resolution: "cpy-cli@npm:5.0.0" + dependencies: + cpy: "npm:^10.1.0" + meow: "npm:^12.0.1" + bin: + cpy: cli.js + checksum: 10c0/f309f2c2ee4d38a830154fb08e2b6485c621cca73b48c61ba43a0a4b9d49d4c011b8a71d31a48edf0379e0b48325ebf8f436a82f783a4a0e751addd641b65eb8 + languageName: node + linkType: hard + +"cpy@npm:^10.1.0": + version: 10.1.0 + resolution: "cpy@npm:10.1.0" + dependencies: + arrify: "npm:^3.0.0" + cp-file: "npm:^10.0.0" + globby: "npm:^13.1.4" + junk: "npm:^4.0.1" + micromatch: "npm:^4.0.5" + nested-error-stacks: "npm:^2.1.1" + p-filter: "npm:^3.0.0" + p-map: "npm:^6.0.0" + checksum: 10c0/17ba53784c7da2b7d6c74cf38b84dc4fd3ff036842d7137fb66538715b6ad2436cebb56284570ec532022ebe677da9a3faa5525299aef126c60d1789ae89fa3b + languageName: node + linkType: hard + "create-jest@npm:^29.7.0": version: 29.7.0 resolution: "create-jest@npm:29.7.0" @@ -3937,7 +4003,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.3.2": +"fast-glob@npm:^3.3.0, fast-glob@npm:^3.3.2": version: 3.3.2 resolution: "fast-glob@npm:3.3.2" dependencies: @@ -4448,6 +4514,19 @@ __metadata: languageName: node linkType: hard +"globby@npm:^13.1.4": + version: 13.2.2 + resolution: "globby@npm:13.2.2" + dependencies: + dir-glob: "npm:^3.0.1" + fast-glob: "npm:^3.3.0" + ignore: "npm:^5.2.4" + merge2: "npm:^1.4.1" + slash: "npm:^4.0.0" + checksum: 10c0/a8d7cc7cbe5e1b2d0f81d467bbc5bc2eac35f74eaded3a6c85fc26d7acc8e6de22d396159db8a2fc340b8a342e74cac58de8f4aee74146d3d146921a76062664 + languageName: node + linkType: hard + "globby@npm:^14.0.0": version: 14.0.1 resolution: "globby@npm:14.0.1" @@ -4469,7 +4548,7 @@ __metadata: languageName: node linkType: hard -"graceful-fs@npm:^4.2.11": +"graceful-fs@npm:^4.2.10, graceful-fs@npm:^4.2.11": version: 4.2.11 resolution: "graceful-fs@npm:4.2.11" checksum: 10c0/386d011a553e02bc594ac2ca0bd6d9e4c22d7fa8cfbfc448a6d148c59ea881b092db9dbe3547ae4b88e55f1b01f7c4a2ecc53b310c042793e63aa44cf6c257f2 @@ -5871,6 +5950,13 @@ __metadata: languageName: node linkType: hard +"junk@npm:^4.0.1": + version: 4.0.1 + resolution: "junk@npm:4.0.1" + checksum: 10c0/091117a5dcf65b19a3e4b8506d95d6ab152b5b5fe6f10e8998de950b0f9d689f14d9b63bb07863b8c86c18511fd1b9a21e9a16e686246436558338ed2e8a4548 + languageName: node + linkType: hard + "just-diff-apply@npm:^5.2.0": version: 5.3.1 resolution: "just-diff-apply@npm:5.3.1" @@ -6342,7 +6428,7 @@ __metadata: languageName: node linkType: hard -"micromatch@npm:^4.0.2, micromatch@npm:^4.0.4": +"micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5": version: 4.0.5 resolution: "micromatch@npm:4.0.5" dependencies: @@ -6646,6 +6732,13 @@ __metadata: languageName: node linkType: hard +"nested-error-stacks@npm:^2.1.1": + version: 2.1.1 + resolution: "nested-error-stacks@npm:2.1.1" + checksum: 10c0/feec00417e4778661cfbbe657e6add6ca9918dcc026cd697ac330b4a56a79e4882b36dde8abc138167566b1ce4c5baa17d2d4df727a96f8b96aebace1c3ffca7 + languageName: node + linkType: hard + "node-emoji@npm:^2.1.3": version: 2.1.3 resolution: "node-emoji@npm:2.1.3" @@ -7147,6 +7240,24 @@ __metadata: languageName: node linkType: hard +"p-event@npm:^5.0.1": + version: 5.0.1 + resolution: "p-event@npm:5.0.1" + dependencies: + p-timeout: "npm:^5.0.2" + checksum: 10c0/2317171489537f316661fa863f3bb711b2ceb89182937238422cec10223cbb958c432d6c26a238446a622d788187bdd295b1d8ecedbe2e467e045930d60202b0 + languageName: node + linkType: hard + +"p-filter@npm:^3.0.0": + version: 3.0.0 + resolution: "p-filter@npm:3.0.0" + dependencies: + p-map: "npm:^5.1.0" + checksum: 10c0/32e375fa6b3afd8b5eb65915746b75a471a3bedf38264dc9d738d6b1b8a0b2797b06b363f637b3387e766e0c7c6fab316cb1119e353baf7936da3ba6d8a4ac8d + languageName: node + linkType: hard + "p-filter@npm:^4.0.0": version: 4.1.0 resolution: "p-filter@npm:4.1.0" @@ -7226,6 +7337,22 @@ __metadata: languageName: node linkType: hard +"p-map@npm:^5.1.0": + version: 5.5.0 + resolution: "p-map@npm:5.5.0" + dependencies: + aggregate-error: "npm:^4.0.0" + checksum: 10c0/410bce846b1e3db6bb2ccab6248372ecf4e635fc2b31331c8f56478e73fec9e146e8b4547585e635703160a3d252a6a65b8f855834aebc2c3408eb5789630cc4 + languageName: node + linkType: hard + +"p-map@npm:^6.0.0": + version: 6.0.0 + resolution: "p-map@npm:6.0.0" + checksum: 10c0/3fcfccf464d0f4a9a8c8a2d48f3f0933bdbdb0628158c1fb3c240dc0bbf20c0cf8115dea57300aa82baefff7b9bd1b9daf13a11a6578f15a629fc5bda78d780d + languageName: node + linkType: hard + "p-map@npm:^7.0.1": version: 7.0.1 resolution: "p-map@npm:7.0.1" @@ -7240,6 +7367,13 @@ __metadata: languageName: node linkType: hard +"p-timeout@npm:^5.0.2": + version: 5.1.0 + resolution: "p-timeout@npm:5.1.0" + checksum: 10c0/1b026cf9d5878c64bec4341ca9cda8ec6b8b3aea8a57885ca0fe2b35753a20d767fb6f9d3aa41e1252f42bc95432c05ea33b6b18f271fb10bfb0789591850a41 + languageName: node + linkType: hard + "p-try@npm:^1.0.0": version: 1.0.0 resolution: "p-try@npm:1.0.0" @@ -8214,6 +8348,13 @@ __metadata: languageName: node linkType: hard +"slash@npm:^4.0.0": + version: 4.0.0 + resolution: "slash@npm:4.0.0" + checksum: 10c0/b522ca75d80d107fd30d29df0549a7b2537c83c4c4ecd12cd7d4ea6c8aaca2ab17ada002e7a1d78a9d736a0261509f26ea5b489082ee443a3a810586ef8eff18 + languageName: node + linkType: hard + "slash@npm:^5.1.0": version: 5.1.0 resolution: "slash@npm:5.1.0"