diff --git a/.changeset/commit.js b/.changeset/commit.js index 44cd337161..d13983dae9 100644 --- a/.changeset/commit.js +++ b/.changeset/commit.js @@ -1,7 +1,7 @@ /* * This file exists so that `yarn changeset` auto-commits, but * `yarn changeset version` does not - we want you to run - * `yarn changeset:version` instead (which will commit). + * `yarn changeset-version` instead (which will commit). */ const commit = require("@changesets/cli/commit"); diff --git a/.changeset/config.json b/.changeset/config.json index 450466b87d..faa21af736 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,5 +1,8 @@ { "$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json", + "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { + "onlyUpdatePeerDependentsWhenOutOfRange": true + }, "changelog": [ "@changesets/changelog-github", { diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4fe364c619..d79751ca9a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,9 +28,6 @@ jobs: - name: "Build" run: yarn build - - name: "Prepack" - run: yarn workspaces foreach --parallel --topological --all run prepack - - name: "Lint Code" run: yarn eslint . @@ -73,7 +70,7 @@ jobs: - run: yarn --immutable - name: "Build Code" - run: yarn build && yarn prepack:all + run: yarn build - name: "Run depcheck script" run: node scripts/benjies-depcheck.mjs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..67d584a86e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v5 + + - name: Setup Node.js 24 + uses: actions/setup-node@v6 + with: + node-version: 24 + cache: "yarn" + + - name: Install Dependencies + run: yarn + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + version: yarn changeset-version + publish: yarn changeset-publish diff --git a/.github/workflows/test-base.yml b/.github/workflows/test-base.yml index d78c0a46d0..94b1d539a2 100644 --- a/.github/workflows/test-base.yml +++ b/.github/workflows/test-base.yml @@ -84,8 +84,5 @@ jobs: - name: "Build" run: yarn build - - name: "Prepack" - run: yarn workspaces foreach --verbose --parallel --topological --recursive --from '${{ inputs.package }}' run prepack - - name: "Test Project" run: yarn run pretest && yarn workspaces foreach --verbose --parallel --worktree --jobs 2 --from '${{ inputs.package }}' run ${{ inputs.testcommand }} diff --git a/.lintignore b/.lintignore index 30e19e967a..8ebcc1ad9a 100644 --- a/.lintignore +++ b/.lintignore @@ -23,6 +23,7 @@ node_modules/ /graphile-build/graphile-build-pg/exported-schema-for-webpack.mjs /graphile-build/graphile-build-pg/schema-export-output.mjs /graphile-build/graphile-build-pg/temp.mjs +/*/*/release/ **/__tests__/**/*.1.graphql **/__tests__/**/*.json5 **/__tests__/**/*.mermaid diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2a9d40f13d..d88aa5f66e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -270,3 +270,29 @@ have access to. - `Object.values(obj)` is better than `Object.keys(obj).map(k => obj[k])`. - `arr.find(...)` is better than `arr.filter(...)[0]` - use `async`/`await` - [it's fast!](https://v8.dev/blog/fast-async) + +## New packages + +If your package is internal, name it `@localrepo/*` (replacing `*` with a name), +and be sure to set `private: true` in `package.json`. Otherwise... + +We use trusted publishing via CI and have particular setup to make this work; +any new package should follow the conventions of existing packages, but in +particular: + +- package.json `scripts.prepack` must be set and include + `node ../../scripts/build-release.mts`; this script will call + `yarn build-package`, and thus: +- package.json `scripts.build-package` must be set; typically it will simply be + `yarn build` but if there's any tidyup or extra commands needed for publishing + that aren't needed for regular development, they would go here +- package.json `scripts.build` will typically be `tsc -b` +- package.json `publishConfig` must be present and have value + `{access: "public", directory: "release"}` +- package.json `files` should be used, and will typically be `["dist"]` +- package.json `peerDependencies` with `workspace:` spec should use an explicit + range (e.g. `workspace:^5.0.0-rc.8`) +- package.json `dependencies` and `devDependencies` with `workspace:` should use + an implicit range (typically `workspace:^`) +- `README.md` must be present +- `LICENSE.md` must be present diff --git a/grafast/bench/package.json b/grafast/bench/package.json index 85f01bf19b..e81a0270c2 100644 --- a/grafast/bench/package.json +++ b/grafast/bench/package.json @@ -44,7 +44,6 @@ "typescript": "^5.9.3" }, "files": [ - "dist", - "index.js" + "dist" ] } diff --git a/grafast/codegen-plugin/package.json b/grafast/codegen-plugin/package.json index 39f4562dac..b3b81905b2 100644 --- a/grafast/codegen-plugin/package.json +++ b/grafast/codegen-plugin/package.json @@ -3,7 +3,9 @@ "version": "1.0.0-rc.4", "description": "A GraphQL code generator plugin for Grafast schemas", "scripts": { - "prepack": "tsc -b" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b" }, "exports": { ".": { @@ -33,10 +35,10 @@ "node": ">=22" }, "files": [ - "fwd", "dist" ], "publishConfig": { + "directory": "release", "access": "public" }, "dependencies": { diff --git a/grafast/dataplan-json/LICENSE.md b/grafast/dataplan-json/LICENSE.md new file mode 100644 index 0000000000..77f2094460 --- /dev/null +++ b/grafast/dataplan-json/LICENSE.md @@ -0,0 +1,20 @@ +# The MIT License (MIT) + +Copyright © 2026 Benjie Gillam + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/grafast/dataplan-json/package.json b/grafast/dataplan-json/package.json index 430357fc24..dd22c0c638 100644 --- a/grafast/dataplan-json/package.json +++ b/grafast/dataplan-json/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "prepack": "tsc -b" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b" }, "repository": { "type": "git", @@ -33,7 +35,7 @@ "node": ">=22" }, "peerDependencies": { - "grafast": "workspace:^" + "grafast": "workspace:^1.0.0-rc.8" }, "files": [ "dist" @@ -43,5 +45,9 @@ "jest": "^30.2.0", "jest-serializer-simple": "workspace:^", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/grafast/dataplan-pg/LICENSE.md b/grafast/dataplan-pg/LICENSE.md new file mode 100644 index 0000000000..77f2094460 --- /dev/null +++ b/grafast/dataplan-pg/LICENSE.md @@ -0,0 +1,20 @@ +# The MIT License (MIT) + +Copyright © 2026 Benjie Gillam + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/grafast/dataplan-pg/package.json b/grafast/dataplan-pg/package.json index 7e70f04504..8a4e3e9d00 100644 --- a/grafast/dataplan-pg/package.json +++ b/grafast/dataplan-pg/package.json @@ -23,13 +23,15 @@ } }, "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "codegen": "yarn graphql-codegen -c codegen-examples-smallExample.ts", "update-schema": "ts-node ./src/examples/exampleSchema.ts", "test": "GRAPHILE_ENV=test jest", "posttest": "yarn test:exportSchema:graphql-js && yarn test:exportSchema:typeDefs", "test:exportSchema:graphql-js": "ts-node ./scripts/exportExampleSchema.ts graphql-js && node ./scripts/runExampleSchema.mjs", "test:exportSchema:typeDefs": "ts-node ./scripts/exportExampleSchema.ts typeDefs && node ./scripts/runExampleSchema.mjs", - "prepack": "yarn codegen && tsc -b && cp src/.npmignore dist/.npmignore", + "build": "yarn codegen && tsc -b && cp src/.npmignore dist/.npmignore", "serve:example": "GRAPHILE_ENV=development NODE_ENV=development yarn nodemon --watch serve-example-schema.js --watch dist --watch ../grafast/dist/ -x 'node --inspect --enable-source-maps serve-example-schema.js'" }, "repository": { @@ -73,7 +75,7 @@ "peerDependencies": { "@dataplan/json": "workspace:^", "grafast": "workspace:^", - "graphile-config": "workspace:^", + "graphile-config": "workspace:^1.0.0-rc.5", "graphql": "^16.9.0", "pg": "^8.7.1", "pg-sql2": "workspace:^" @@ -114,5 +116,9 @@ "webpack-cli": "^6.0.1", "webpack-node-externals": "^3.0.0", "zx": "^8.8.5" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/grafast/grafast/package.json b/grafast/grafast/package.json index 66933dc094..6d7dda3af0 100644 --- a/grafast/grafast/package.json +++ b/grafast/grafast/package.json @@ -27,12 +27,14 @@ } }, "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "graphile": "node ../../utils/graphile/dist/cli-run.js", "codegen": "cd __tests__/dcc && node --experimental-strip-types ../../../../node_modules/.bin/graphql-codegen", - "test": "yarn codegen && yarn test:mocha && yarn test:bundle", - "test:bundle": "node --experimental-strip-types scripts/testbundle.mts", - "test:mocha": "tsc -b tsconfig.test.json && NODE_ENV=test GRAPHILE_ENV=test mocha '**/__tests__/**/*-test.ts'", - "build": "zx scripts/build-npm.mjs", - "postpack": "echo 'FORBIDDEN' && exit 1", + "test": "yarn codegen && yarn test-mocha && yarn test-bundle", + "test-bundle": "node --experimental-strip-types scripts/testbundle.mts", + "test-mocha": "tsc -b tsconfig.test.json && NODE_ENV=test GRAPHILE_ENV=test mocha '**/__tests__/**/*-test.ts'", + "build": "tsc -b", "md": "spec-md CRYSTAL_FLOW.md > CRYSTAL_FLOW.html" }, "repository": { @@ -84,8 +86,7 @@ }, "files": [ "fwd", - "dist", - "browser" + "dist" ], "devDependencies": { "@graphql-codegen/cli": "^6.1.0", @@ -98,7 +99,6 @@ "@types/node": "^22.19.1", "@types/nodemon": "^3.1.1", "chai": "^5.3.3", - "graphile": "workspace:^", "graphql": "^16.9.0", "jest": "^30.2.0", "lodash": "^4.17.23", @@ -114,7 +114,7 @@ "zx": "^8.8.5" }, "publishConfig": { - "access": "public", - "directory": "release" + "directory": "release", + "access": "public" } } diff --git a/grafast/grafast/scripts/build-npm.mjs b/grafast/grafast/scripts/build-npm.mjs deleted file mode 100755 index a586e9dd8b..0000000000 --- a/grafast/grafast/scripts/build-npm.mjs +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env zx - -/* global $, cd */ - -import "zx/globals"; - -import { - /* esmHack, */ transformPackageJson, -} from "../../../scripts/build-core.mjs"; - -cd(__dirname + "/.."); -await $`rm -Rf tsconfig.tsbuildinfo dist release`; -await $`tsc -b`; -await $`find dist -type d -exec mkdir -p release/{} \\;`; -await $`find dist -type f -name '*.js' -exec cp {} release/{} \\;`; -await $`find dist -type f -name '*.d.ts' -exec cp {} release/{} \\;`; -await $`find fwd -type d -exec mkdir -p release/{} \\;`; -await $`find fwd -type f -name '*.js' -exec cp {} release/{} \\;`; -await $`find fwd -type f -name '*.d.ts' -exec cp {} release/{} \\;`; -await $`cp src/.npmignore release/dist/.npmignore`; -await $`cp LICENSE.md release/LICENSE.md`; -await $`cp README.md release/README.md`; - -await transformPackageJson( - __dirname + "/../package.json", - __dirname + "/../release/package.json", -); - -// TODO: force GRAPHILE_ENV="production" and eliminate all related dead branches - -//await esmHack(__dirname + "/../release/dist/index.js"); -//await esmHack(__dirname + "/../release/dist/envelop.js"); -//await esmHack(__dirname + "/../release/dist/mermaid.js"); diff --git a/grafast/grafserv-persisted/LICENSE.md b/grafast/grafserv-persisted/LICENSE.md new file mode 100644 index 0000000000..77f2094460 --- /dev/null +++ b/grafast/grafserv-persisted/LICENSE.md @@ -0,0 +1,20 @@ +# The MIT License (MIT) + +Copyright © 2026 Benjie Gillam + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/grafast/grafserv-persisted/package.json b/grafast/grafserv-persisted/package.json index c76f2d9fbf..da3c08be94 100644 --- a/grafast/grafserv-persisted/package.json +++ b/grafast/grafserv-persisted/package.json @@ -12,7 +12,9 @@ } }, "scripts": { - "prepack": "tsc -b", + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b", "test": "true" }, "repository": { @@ -46,9 +48,9 @@ "node": ">=22" }, "peerDependencies": { - "grafast": "workspace:^", - "grafserv": "workspace:^", - "graphile-config": "workspace:^", + "grafast": "workspace:^1.0.0-rc.8", + "grafserv": "workspace:^1.0.0-rc.6", + "graphile-config": "workspace:^1.0.0-rc.5", "graphql": "^16.9.0" }, "peerDependenciesMeta": { @@ -68,7 +70,10 @@ "typescript": "^5.9.3" }, "files": [ - "dist", - "index.js" - ] + "dist" + ], + "publishConfig": { + "directory": "release", + "access": "public" + } } diff --git a/grafast/grafserv/LICENSE.md b/grafast/grafserv/LICENSE.md new file mode 100644 index 0000000000..77f2094460 --- /dev/null +++ b/grafast/grafserv/LICENSE.md @@ -0,0 +1,20 @@ +# The MIT License (MIT) + +Copyright © 2026 Benjie Gillam + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/grafast/grafserv/package.json b/grafast/grafserv/package.json index 3c4a6440f6..272bfa792b 100644 --- a/grafast/grafserv/package.json +++ b/grafast/grafserv/package.json @@ -76,7 +76,10 @@ } }, "scripts": { - "prepack": "tsc -b", + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "graphile": "node ../../utils/graphile/dist/cli-run.js", + "build": "tsc -b", "test": "jest", "posttest": "yarn playwright install chromium && node --experimental-strip-types scripts/smoke-examples.mts" }, @@ -113,7 +116,7 @@ "peerDependencies": { "@envelop/core": "^5.0.0", "@whatwg-node/server": "^0.9.64", - "grafast": "workspace:^", + "grafast": "workspace:^1.0.0-rc.8", "graphile-config": "workspace:^", "graphql": "^16.9.0", "h3": "^1.13.0", @@ -152,7 +155,6 @@ "express": "^4.21.2", "fastify": "^4.29.1 || ^5.0.0", "grafast": "workspace:^", - "graphile": "workspace:^", "graphql": "^16.9.0", "graphql-http": "^1.22.4", "h3": "^1.15.5", @@ -169,7 +171,10 @@ }, "files": [ "dist", - "fwd", - "index.js" - ] + "fwd" + ], + "publishConfig": { + "directory": "release", + "access": "public" + } } diff --git a/grafast/ruru-components/package.json b/grafast/ruru-components/package.json index 294497fe82..afd290032f 100644 --- a/grafast/ruru-components/package.json +++ b/grafast/ruru-components/package.json @@ -16,7 +16,9 @@ } }, "scripts": { - "prepack": "tsc -b" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b" }, "repository": { "type": "git", @@ -64,7 +66,6 @@ }, "files": [ "dist", - "index.js", "ruru.css" ], "devDependencies": { @@ -78,5 +79,9 @@ "jest": "^30.2.0", "nodemon": "^3.1.11", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/grafast/ruru-types/package.json b/grafast/ruru-types/package.json index 3fcc227267..06b7dcbf6e 100644 --- a/grafast/ruru-types/package.json +++ b/grafast/ruru-types/package.json @@ -12,7 +12,9 @@ } }, "scripts": { - "prepack": "tsc -b" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b" }, "repository": { "type": "git", @@ -58,5 +60,9 @@ "react": "^18 || ^19", "react-dom": "^18 || ^19", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/grafast/ruru/package.json b/grafast/ruru/package.json index 226335e2de..fdae84c00a 100644 --- a/grafast/ruru/package.json +++ b/grafast/ruru/package.json @@ -28,10 +28,13 @@ } }, "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "rm -Rf dist static tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && yarn build", "webpack": "node --loader ts-node/esm \"$(yarn bin webpack-cli)\" --config webpack.config.mts", "watch": "yarn webpack --watch --mode=development", "make-ruru-html": "node --experimental-strip-types scripts/make-ruru-html.mts", - "prepack": "rm -Rf dist static tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && yarn webpack --mode=${BUILD_MODE:-production} && tsc -b tsconfig.build.json && cp src/.npmignore dist/ && chmod +x dist/cli-run.js && yarn make-ruru-html" + "postversion": "tsc -b tsconfig.build.json && yarn run make-ruru-html && git add ../website/static/myruru/index.html", + "build": "yarn webpack --mode=${BUILD_MODE:-production} && tsc -b tsconfig.build.json && cp src/.npmignore dist/ && chmod +x dist/cli-run.js && yarn make-ruru-html" }, "repository": { "type": "git", @@ -62,7 +65,7 @@ "node": ">=22" }, "peerDependencies": { - "graphile-config": "workspace:^", + "graphile-config": "workspace:^1.0.0-rc.5", "graphql": "^16.9.0", "react": "^18 || ^19", "react-dom": "^18 || ^19" @@ -98,5 +101,9 @@ "webpack": "^5.103.0", "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^6.0.1" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/graphile-build/graphile-build-pg/package.json b/graphile-build/graphile-build-pg/package.json index 7a8f5e7063..20a23d523f 100644 --- a/graphile-build/graphile-build-pg/package.json +++ b/graphile-build/graphile-build-pg/package.json @@ -37,8 +37,10 @@ } }, "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "jest", - "prepack": "tsc -b && cp src/.npmignore dist/.npmignore" + "build": "tsc -b && cp src/.npmignore dist/.npmignore" }, "repository": { "type": "git", @@ -74,14 +76,14 @@ "tslib": "^2.8.1" }, "peerDependencies": { - "@dataplan/pg": "workspace:^", - "grafast": "workspace:^", - "graphile-build": "workspace:^", - "graphile-config": "workspace:^", + "@dataplan/pg": "workspace:^1.0.0-rc.7", + "grafast": "workspace:^1.0.0-rc.8", + "graphile-build": "workspace:^5.0.0-rc.5", + "graphile-config": "workspace:^1.0.0-rc.5", "graphql": "^16.9.0", "pg": "^8.7.1", - "pg-sql2": "workspace:^", - "tamedevil": "workspace:^" + "pg-sql2": "workspace:^5.0.0-rc.4", + "tamedevil": "workspace:^0.1.0-rc.5" }, "peerDependenciesMeta": { "pg": { @@ -93,8 +95,7 @@ }, "files": [ "dist", - "fwd", - "index.js" + "fwd" ], "devDependencies": { "@envelop/core": "^5.3.0", @@ -120,5 +121,9 @@ "ts-node": "^10.9.2", "typescript": "^5.9.3", "ws": "^8.18.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/graphile-build/graphile-build/package.json b/graphile-build/graphile-build/package.json index 75a867016e..47b513048f 100644 --- a/graphile-build/graphile-build/package.json +++ b/graphile-build/graphile-build/package.json @@ -12,7 +12,9 @@ } }, "scripts": { - "prepack": "tsc -b && cp src/.npmignore dist/.npmignore" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b && cp src/.npmignore dist/.npmignore" }, "repository": { "type": "git", @@ -54,13 +56,12 @@ "node": ">=22" }, "peerDependencies": { - "grafast": "workspace:^", - "graphile-config": "workspace:^", + "grafast": "workspace:^1.0.0-rc.8", + "graphile-config": "workspace:^1.0.0-rc.5", "graphql": "^16.9.0" }, "files": [ - "dist", - "index.js" + "dist" ], "devDependencies": { "@types/debug": "^4.1.12", @@ -71,5 +72,9 @@ "jest": "^30.2.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/graphile-build/graphile-simplify-inflection/package.json b/graphile-build/graphile-simplify-inflection/package.json index ac84a6f1e7..44affa9e93 100644 --- a/graphile-build/graphile-simplify-inflection/package.json +++ b/graphile-build/graphile-simplify-inflection/package.json @@ -4,7 +4,9 @@ "description": "Simplifies the graphile-build/graphile-build-pg inflection to trim the `ByFooIdAndBarId` from relations, etc", "main": "dist/index.js", "scripts": { - "prepack": "tsc -b", + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b", "test": "node test.js" }, "repository": { @@ -37,6 +39,7 @@ "typescript": "^5.9.3" }, "publishConfig": { + "directory": "release", "access": "public" } } diff --git a/graphile-build/graphile-utils/LICENSE.md b/graphile-build/graphile-utils/LICENSE.md new file mode 100644 index 0000000000..77f2094460 --- /dev/null +++ b/graphile-build/graphile-utils/LICENSE.md @@ -0,0 +1,20 @@ +# The MIT License (MIT) + +Copyright © 2026 Benjie Gillam + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/graphile-build/graphile-utils/README.md b/graphile-build/graphile-utils/README.md index 5d7704fade..473c372b77 100644 --- a/graphile-build/graphile-utils/README.md +++ b/graphile-build/graphile-utils/README.md @@ -152,6 +152,6 @@ Make sure you first follow the instructions in the then run the test with the following commands: ```bash -yarn prepack +yarn build yarn test ``` diff --git a/graphile-build/graphile-utils/package.json b/graphile-build/graphile-utils/package.json index edddb5ab02..8815a46701 100644 --- a/graphile-build/graphile-utils/package.json +++ b/graphile-build/graphile-utils/package.json @@ -12,8 +12,10 @@ } }, "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "jest", - "prepack": "tsc -b tsconfig.build.json" + "build": "tsc -b tsconfig.build.json" }, "repository": { "type": "git", @@ -45,13 +47,13 @@ "node": ">=22" }, "peerDependencies": { - "@dataplan/pg": "workspace:^", - "grafast": "workspace:^", - "graphile-build": "workspace:^", - "graphile-build-pg": "workspace:^", - "graphile-config": "workspace:^", + "@dataplan/pg": "workspace:^1.0.0-rc.7", + "grafast": "workspace:^1.0.0-rc.8", + "graphile-build": "workspace:^5.0.0-rc.5", + "graphile-build-pg": "workspace:^5.0.0-rc.7", + "graphile-config": "workspace:^1.0.0-rc.5", "graphql": "^16.9.0", - "tamedevil": "workspace:^" + "tamedevil": "workspace:^0.1.0-rc.5" }, "peerDependenciesMeta": { "graphile-build-pg": { @@ -69,13 +71,16 @@ "jest": "^30.2.0", "jest-serializer-graphql-schema": "workspace:^", "nodemon": "^3.1.11", - "postgraphile": "workspace:^", + "pg-sql2": "workspace:^", "tamedevil": "workspace:^", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "files": [ - "dist", - "index.js" - ] + "dist" + ], + "publishConfig": { + "directory": "release", + "access": "public" + } } diff --git a/pack.sh b/pack.sh index 12064f58d9..6b84551a59 100755 --- a/pack.sh +++ b/pack.sh @@ -5,190 +5,55 @@ rm -rf builds/ mkdir builds/ yarn clean - -# @graphile/lru -cd utils/lru -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile__lru.tgz -cd - - -# tamedevil -cd utils/tamedevil -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/tamedevil.tgz -cd - - -# graphile-config -cd utils/graphile-config -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile-config.tgz -cd - - -#grafast -cd grafast/grafast -yarn build -cp -a ../../.yarn ../../.yarnrc.yml release -rm -Rf /tmp/grafast-build -mv release /tmp/grafast-build -# Build in temp folder -cd /tmp/grafast-build -rm -f *.tgz -yarn pack -o package.tgz -cd - -# Grab package -mv /tmp/grafast-build/package.tgz ../../builds/grafast.tgz -rm -Rf /tmp/grafast-build -cd ../.. - -# ruru-types -cd grafast/ruru-types -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/ruru-types.tgz -cd - - -# ruru-components -cd grafast/ruru-components -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/ruru-components.tgz -cd - - -# ruru -cd grafast/ruru -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/ruru.tgz -cd - - -#grafserv -cd grafast/grafserv -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/grafserv.tgz -cd - - -#@dataplan/json -cd grafast/dataplan-json -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/dataplan__json.tgz -cd - - -#eslint-plugin-graphile-export -cd utils/eslint-plugin-graphile-export -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/eslint-plugin-graphile-export.tgz -cd - - -#graphile-export -cd utils/graphile-export -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile-export.tgz -cd - - -#jest-serializer-graphql-schema -cd utils/jest-serializer-graphql-schema -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/jest-serializer-graphql-schema.tgz -cd - - -#jest-serializer-simple -cd utils/jest-serializer-simple -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/jest-serializer-simple.tgz -cd - - -#graphile-build -cd graphile-build/graphile-build -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile-build.tgz -cd - - -#pg-introspection -cd utils/pg-introspection -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/pg-introspection.tgz -cd - - -#pg-sql2 -cd utils/pg-sql2 -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/pg-sql2.tgz -cd - - -#@dataplan/pg # NEEDS CUSTOM RELEASE -cd grafast/dataplan-pg -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/dataplan__pg.tgz -cd ../.. - -#graphile-build-pg -cd graphile-build/graphile-build-pg/ -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile-build-pg.tgz -cd - - -#graphile-utils -cd graphile-build/graphile-utils -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile-utils.tgz -cd - - -#postgraphile -cd postgraphile/postgraphile/ -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/postgraphile.tgz -cd - - -#pgl -cd postgraphile/pgl/ -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/pgl.tgz -cd - - -# @graphile/simplify-inflection -cd graphile-build/graphile-simplify-inflection -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile__simplify-inflection.tgz -cd - - -# @grafserv/persisted -cd grafast/grafserv-persisted -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/grafserv__persisted.tgz -cd - - -# graphile -cd utils/graphile -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphile.tgz -cd - - -# graphql-codegen-grafast -cd grafast/codegen-plugin -rm -f *.tgz -yarn pack -o package.tgz -mv package.tgz ../../builds/graphql-codegen-grafast.tgz -cd - +yarn workspaces-prepack + +pack_pkg() { + local repoRoot="$(pwd)" + local packageDir="$1" + local outputBasename="$2" + if [ "$packageDir" == "" ]; then + echo "INVALID pack_pkg CALL! $1 $2" + exit 1 + fi + if [ "$outputBasename" == "" ]; then + echo "INVALID pack_pkg CALL! $1 $2" + exit 1 + fi + + # sub-shell means no need to `cd -` + ( + cd "${packageDir}/release" + rm -f package.tgz + yarn pack -o package.tgz + mv package.tgz "${repoRoot}/builds/${outputBasename}.tgz" + ) +} + +pack_pkg utils/lru graphile__lru +pack_pkg utils/tamedevil tamedevil +pack_pkg utils/graphile-config graphile-config +pack_pkg grafast/grafast grafast +pack_pkg grafast/ruru-types ruru-types +pack_pkg grafast/ruru-components ruru-components +pack_pkg grafast/ruru ruru +pack_pkg grafast/grafserv grafserv +pack_pkg grafast/dataplan-json dataplan__json +pack_pkg utils/eslint-plugin-graphile-export eslint-plugin-graphile-export +pack_pkg utils/graphile-export graphile-export +pack_pkg utils/jest-serializer-graphql-schema jest-serializer-graphql-schema +pack_pkg utils/jest-serializer-simple jest-serializer-simple +pack_pkg graphile-build/graphile-build graphile-build +pack_pkg utils/pg-introspection pg-introspection +pack_pkg utils/pg-sql2 pg-sql2 +pack_pkg grafast/dataplan-pg dataplan__pg +pack_pkg graphile-build/graphile-build-pg graphile-build-pg +pack_pkg graphile-build/graphile-utils graphile-utils +pack_pkg postgraphile/postgraphile postgraphile +pack_pkg postgraphile/pgl pgl +pack_pkg graphile-build/graphile-simplify-inflection graphile__simplify-inflection +pack_pkg grafast/grafserv-persisted grafserv__persisted +pack_pkg utils/graphile graphile +pack_pkg grafast/codegen-plugin graphql-codegen-grafast echo "All packages packed into 'builds/'" echo "Now publish them with './publish.sh'" diff --git a/package.json b/package.json index db25981b09..dab6898c42 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,20 @@ "private": true, "scripts": { "fwd:update": "node ./scripts/fwd.mjs", - "check": "yarn clean && yarn lint && yarn prepack:all && yarn test", + "check": "yarn clean && yarn lint && yarn build && yarn test", "lint:fix": "yarn run eslint --fix . && yarn prettier:fix", - "pretest": "tsc -b && ./scripts/pretest && yarn workspaces foreach --all --topological run pretest", - "test": "NODE_ENV=test yarn workspaces foreach --all --topological run test", - "posttest": "NODE_ENV=test yarn workspaces foreach --all --topological run posttest && node scripts/benjies-depcheck.mjs", - "prepack:all": "scripts/prepack-all", - "build": "yarn && yarn workspace ruru-components prepack && yarn workspace ruru prepack && tsc -b", + "pretest": "tsc -b && ./scripts/pretest && yarn workspaces foreach --all --topological-dev run pretest", + "test": "NODE_ENV=test yarn workspaces foreach --all --topological-dev run test", + "posttest": "NODE_ENV=test yarn workspaces foreach --all --topological-dev run posttest && node scripts/benjies-depcheck.mjs", + "build-init": "yarn && yarn workspace ruru-components build-package && yarn workspace ruru build-package && tsc -b", + "build": "yarn build-init && yarn workspaces foreach --parallel --topological-dev --all --exclude '.' --exclude 'ruru' --exclude 'ruru-components' run build-package", "watch": "BUILD_MODE=development yarn build && tsc -b --watch", + "workspaces-prepack": "yarn workspaces foreach --parallel --topological-dev --all run prepack", + "workspaces-postversion": "yarn workspaces foreach --parallel --topological-dev --all run postversion", "clean": "( jest --clearCache || true ) && ( rm -Rf {utils,grafast,graphile-build,postgraphile}/*/{dist,bundle,tsconfig.tsbuildinfo,tsconfig.*.tsbuildinfo} postgraphile/postgraphile/.tests_tmp/ grafast/ruru/static grafast/ruru/src/bundleCode.ts grafast/ruru/src/bundleMeta.ts || true )", "tsc:watch:clean": "( rm -Rf {utils,grafast,graphile-build,postgraphile}/*/{dist,tsconfig.tsbuildinfo,tsconfig.*.tsbuildinfo} || true ) && tsc -b --watch", - "changeset:version": "yarn changeset version && node scripts/postversion.mjs", + "changeset-version": "yarn changeset version && node scripts/postversion.mjs", + "changeset-publish": "yarn workspaces-prepack && changeset publish", "w": "yarn workspace", "postgraphile": "cd postgraphile/postgraphile && node dist/cli-run.js", "website:grafast": "cd grafast/website && yarn start", diff --git a/postgraphile/pgl/package.json b/postgraphile/pgl/package.json index cec2a20523..228c9d227c 100644 --- a/postgraphile/pgl/package.json +++ b/postgraphile/pgl/package.json @@ -207,7 +207,9 @@ }, "bin": "./dist/cli-run.js", "scripts": { - "prepack": "tsc -b tsconfig.build.json" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b tsconfig.build.json" }, "repository": { "type": "git", @@ -262,8 +264,7 @@ }, "files": [ "dist", - "fwd", - "index.js" + "fwd" ], "devDependencies": { "@types/debug": "^4.1.12", @@ -275,5 +276,9 @@ "nodemon": "^3.1.11", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/postgraphile/postgraphile/package.json b/postgraphile/postgraphile/package.json index 05f4218c6a..6a2bfad03f 100644 --- a/postgraphile/postgraphile/package.json +++ b/postgraphile/postgraphile/package.json @@ -223,6 +223,9 @@ }, "bin": "./dist/cli-run.js", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "graphile": "node ../../utils/graphile/dist/cli-run.js", "test": "yarn test:jest && UPDATE_SNAPSHOTS=\"\" yarn test:schema-exports && UPDATE_SNAPSHOTS=\"\" yarn test:operations-exports", "test:jest": "jest", "test:schema-exports": "node scripts/test-schema-exports.mjs", @@ -230,7 +233,7 @@ "//test:operations-exports": "yarn test:operations-exports:typeDefs && yarn test:operations-exports:graphql-js", "test:operations-exports:typeDefs": "EXPORT_SCHEMA=typeDefs jest __tests__/queries __tests__/mutations", "test:operations-exports:graphql-js": "EXPORT_SCHEMA=graphql-js jest __tests__/queries __tests__/mutations", - "prepack": "tsc -b tsconfig.build.json" + "build": "tsc -b tsconfig.build.json" }, "repository": { "type": "git", @@ -302,8 +305,7 @@ }, "files": [ "dist", - "fwd", - "index.js" + "fwd" ], "devDependencies": { "@types/debug": "^4.1.12", @@ -311,11 +313,14 @@ "@types/jest": "^30.0.0", "@types/jsonwebtoken": "^9.0.10", "@types/nodemon": "^3.1.1", - "graphile": "workspace:^", "graphile-export": "workspace:^", "jest": "^30.2.0", "nodemon": "^3.1.11", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/release b/release deleted file mode 100755 index a1d6b9ea05..0000000000 --- a/release +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e -echo "CLEANING BUILT FILES" -yarn clean -echo "PREPACKING" -yarn prepack:all -echo "TEST" -yarn test - -TAG="${1:-next}" - -# Only shift if there's something to shift -if [ "x$1" != "x" ]; then shift; fi; - -echo 'NEED A PUBLISH COMMAND!' -exit 1 -# npx lerna publish --exact --npm-tag="$TAG" "$@" -yarn run changelog -git add CHANGELOG.md -git commit -m"chore: update CHANGELOG" -git push && git push --tags diff --git a/scripts/build-core.mjs b/scripts/build-core.mjs deleted file mode 100644 index c1081bd429..0000000000 --- a/scripts/build-core.mjs +++ /dev/null @@ -1,71 +0,0 @@ -import fsp from "node:fs/promises"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -export async function transformPackageJson(sourceFilePath, targetFilePath) { - const packageJson = require(sourceFilePath); - const newJson = { ...packageJson }; - delete newJson.scripts; - delete newJson.devDependencies; - delete newJson.publishConfig.directory; - - for (const key in newJson) { - if ( - key.endsWith("ependencies") && - typeof newJson[key] === "object" && - newJson[key] !== null - ) { - const deps = { ...newJson[key] }; - newJson[key] = deps; - // Transform `workspace:` dependencies - for (const moduleName in deps) { - const version = deps[moduleName]; - if (typeof version === "string" && version.startsWith("workspace:")) { - const range = version.substring(10); - if (range.length !== 1) { - throw new Error(`Don't understand '${version}'`); - } - // Find the package's version - const packageJson = JSON.parse( - await fsp.readFile( - `${__dirname}/../node_modules/${moduleName}/package.json`, - "utf8", - ), - ); - deps[moduleName] = `${range}${packageJson.version}`; - console.log(moduleName, deps[moduleName]); - } - } - } - } - - await fsp.writeFile(targetFilePath, JSON.stringify(newJson, null, 2)); -} - -export async function esmHack(codePath) { - const pkg = require(codePath); - const code = await fsp.readFile(codePath, "utf8"); - - await fsp.writeFile( - codePath, - `\ -// Convince Node to allow ESM named imports -${Object.keys(pkg) - .map( - (varName) => - `${ - varName.match(/^[_a-zA-Z$][_a-zA-Z$0-9]*$/) - ? `exports.${varName}` - : `exports[${JSON.stringify(varName)}]` - } = null /* placeholder */;`, - ) - .join("\n")} - -// Bundled module -${code} -`, - ); -} diff --git a/scripts/build-release.mts b/scripts/build-release.mts new file mode 100644 index 0000000000..d90015bdcd --- /dev/null +++ b/scripts/build-release.mts @@ -0,0 +1,131 @@ +/* global $ */ + +import "zx/globals"; + +import { existsSync } from "node:fs"; +import fsp, { mkdir, readFile, stat } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +async function transformPackageJson(packageJson: any, targetFilePath: string) { + const newJson = JSON.parse(JSON.stringify(packageJson)); + delete newJson.scripts; + delete newJson.devDependencies; + delete newJson.publishConfig.directory; + if (!newJson.name.startsWith("@")) { + delete newJson.publishConfig.access; + } + if (Object.keys(newJson.publishConfig).length === 0) { + delete newJson.publishConfig; + } + + for (const key in newJson) { + if ( + key.endsWith("ependencies") && + typeof newJson[key] === "object" && + newJson[key] !== null + ) { + const deps = { ...newJson[key] }; + newJson[key] = deps; + // Transform `workspace:` dependencies + for (const moduleName in deps) { + const version = deps[moduleName]; + if (typeof version === "string" && version.startsWith("workspace:")) { + const range = version.substring(10); + if (range.length > 1) { + if (key !== "peerDependencies") { + throw new Error( + `${key} should typically not use explicit version range, otherwise changes may not be reflected accurately ${newJson.name}[${key}][${moduleName}] = ${version}`, + ); + } + deps[moduleName] = `${range}`; + } else { + if (key === "peerDependencies") { + if (newJson.dependencies?.[moduleName]) { + // This is okay; we're peer-depending _and_ regular depending. + } else { + throw new Error( + `${key} should use explicit version range, otherwise lots of unnecessary bumping may occur from changesets. ${newJson.name}[${key}][${moduleName}] = ${version}`, + ); + } + } + // Find the package's version + const packageJson = JSON.parse( + await fsp.readFile( + `${__dirname}/../node_modules/${moduleName}/package.json`, + "utf8", + ), + ); + deps[moduleName] = `${range}${packageJson.version}`; + } + console.log( + `packageJson.${key}[${JSON.stringify(moduleName)}] went from ${version} to ${deps[moduleName]}`, + ); + } + } + } + } + + await fsp.writeFile(targetFilePath, JSON.stringify(newJson, null, 2)); +} + +export async function build() { + const packagePath = process.cwd(); + const packageJson = JSON.parse( + await readFile(`${packagePath}/package.json`, "utf8"), + ); + + const { private: isPrivate, publishConfig, name } = packageJson; + if (isPrivate) { + throw new Error(`Can't build private package`); + } + if (!publishConfig) { + throw new Error( + `Module ${name} not set up for publishing (no \`publishConfig\`)`, + ); + } + if (!publishConfig.directory) { + throw new Error(`Module ${name} not has no release directory configured`); + } + if (publishConfig.directory !== "release") { + throw new Error( + `Module ${name} must have release directory 'release' (found: ${publishConfig.directory})`, + ); + } + + await $`rm -Rf tsconfig*.tsbuildinfo dist release`; + await $`yarn build-package`; + await mkdir("release"); + for (const f of packageJson.files) { + const stats = await stat(f); + if (stats.isDirectory()) { + await $`cp -a ${f} ${`release/${f}`}`; + } else { + await $`cp ${f} ${`release/${f}`}`; + } + } + if (existsSync(`${packagePath}/.npmignore`)) { + await $`cp .npmignore release/.npmignore`; + } + if (existsSync(`${packagePath}/src/.npmignore`)) { + await $`cp src/.npmignore release/dist/.npmignore`; + } + await $`cp LICENSE.md README.md CHANGELOG.md release/`; + + await transformPackageJson( + packageJson, + `${packagePath}/release/package.json`, + ); + + // Force yarn to treat this as it's own project, so `yarn pack` doesn't complain + await $`touch release/yarn.lock`; + + // TODO: force GRAPHILE_ENV="production" and eliminate all related dead branches +} + +if (import.meta.main) { + await build(); +} diff --git a/scripts/prepack-all b/scripts/prepack-all deleted file mode 100755 index b77ad8096d..0000000000 --- a/scripts/prepack-all +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -e - -# Build everything in the relevant order according to TypeScript project references -yarn build - -# Now run `prepack` on each package (slightly parallelised) -yarn workspaces foreach --parallel --topological --all run prepack diff --git a/utils/eslint-plugin-graphile-export/package.json b/utils/eslint-plugin-graphile-export/package.json index 5a4ed7883e..b40948b6dd 100644 --- a/utils/eslint-plugin-graphile-export/package.json +++ b/utils/eslint-plugin-graphile-export/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "prepack": "tsc -b" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b" }, "repository": { "type": "git", @@ -45,5 +47,9 @@ "jest": "^30.2.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/graphile-config/package.json b/utils/graphile-config/package.json index e7f338fcf8..41d636b2c2 100644 --- a/utils/graphile-config/package.json +++ b/utils/graphile-config/package.json @@ -20,8 +20,10 @@ } }, "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "mocha '__tests__/**/*.test.ts'", - "prepack": "tsc -b" + "build": "tsc -b" }, "repository": { "type": "git", @@ -62,5 +64,9 @@ "mocha": "^11.7.5", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/graphile-export/package.json b/utils/graphile-export/package.json index e3c5ed0a31..5ca6e0e18a 100644 --- a/utils/graphile-export/package.json +++ b/utils/graphile-export/package.json @@ -16,7 +16,9 @@ } }, "scripts": { - "prepack": "tsc -b" + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b" }, "repository": { "type": "git", @@ -54,7 +56,7 @@ }, "peerDependencies": { "eslint": "^8.48.0 || ^9.26.0", - "grafast": "workspace:^", + "grafast": "workspace:^1.0.0-rc.8", "pg-sql2": "workspace:^5.0.0-rc.4" }, "peerDependenciesMeta": { @@ -76,5 +78,9 @@ "jest": "^30.2.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/graphile/package.json b/utils/graphile/package.json index 0ac630e734..6a21b99dcf 100644 --- a/utils/graphile/package.json +++ b/utils/graphile/package.json @@ -6,8 +6,10 @@ "bin": "dist/cli-run.js", "types": "dist/index.d.ts", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "true", - "prepack": "tsc -b" + "build": "tsc -b" }, "repository": { "type": "git", @@ -39,9 +41,9 @@ "typescript": "^5.9.3" }, "peerDependencies": { - "graphile-build": "workspace:^", - "graphile-config": "workspace:^", - "postgraphile": "workspace:^" + "graphile-build": "workspace:^5.0.0-rc.5", + "graphile-config": "workspace:^1.0.0-rc.5", + "postgraphile": "workspace:^5.0.0-rc.9" }, "peerDependenciesMeta": { "graphile-build": { @@ -55,6 +57,11 @@ "@types/jest": "^30.0.0", "@types/node": "^22.19.1", "jest": "^30.2.0", + "postgraphile": "workspace:^", "ts-node": "^10.9.2" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/jest-serializer-graphql-schema/package.json b/utils/jest-serializer-graphql-schema/package.json index ad9b847567..5ae81c8561 100644 --- a/utils/jest-serializer-graphql-schema/package.json +++ b/utils/jest-serializer-graphql-schema/package.json @@ -5,8 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "jest", - "prepack": "tsc -b", + "build": "tsc -b", "watch": "tsc -b --watch" }, "repository": { @@ -41,5 +43,9 @@ }, "files": [ "dist" - ] + ], + "publishConfig": { + "directory": "release", + "access": "public" + } } diff --git a/utils/jest-serializer-simple/LICENSE.md b/utils/jest-serializer-simple/LICENSE.md new file mode 100644 index 0000000000..77f2094460 --- /dev/null +++ b/utils/jest-serializer-simple/LICENSE.md @@ -0,0 +1,20 @@ +# The MIT License (MIT) + +Copyright © 2026 Benjie Gillam + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/utils/jest-serializer-simple/package.json b/utils/jest-serializer-simple/package.json index 916fb010dd..eb8d5988cf 100644 --- a/utils/jest-serializer-simple/package.json +++ b/utils/jest-serializer-simple/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "prepack": "tsc -b", + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", + "build": "tsc -b", "watch": "tsc -b --watch" }, "repository": { @@ -40,5 +42,9 @@ }, "files": [ "dist" - ] + ], + "publishConfig": { + "directory": "release", + "access": "public" + } } diff --git a/utils/lds/package.json b/utils/lds/package.json index 860ccdd02d..95a78a7298 100644 --- a/utils/lds/package.json +++ b/utils/lds/package.json @@ -6,7 +6,7 @@ "private": true, "scripts": { "//test": "jest -i", - "prepack": "tsc -b" + "build": "tsc -b" }, "bin": { "graphile-lds": "./dist/cli.js" diff --git a/utils/lru/package.json b/utils/lru/package.json index daf56817fe..a92d117571 100644 --- a/utils/lru/package.json +++ b/utils/lru/package.json @@ -5,8 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "jest", - "prepack": "tsc -b" + "build": "tsc -b" }, "repository": { "type": "git", @@ -38,5 +40,9 @@ "jest": "^30.2.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/pg-introspection/package.json b/utils/pg-introspection/package.json index c630c046b0..c36bd32d8d 100644 --- a/utils/pg-introspection/package.json +++ b/utils/pg-introspection/package.json @@ -5,8 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "test": "node --experimental-strip-types --test", - "prepack": "tsc -b" + "build": "tsc -b" }, "repository": { "type": "git", @@ -46,5 +48,9 @@ ], "engines": { "node": ">=22" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/pg-sql2/package.json b/utils/pg-sql2/package.json index f9dbee6f76..c6343ed53d 100644 --- a/utils/pg-sql2/package.json +++ b/utils/pg-sql2/package.json @@ -5,11 +5,13 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "pretest": "node dist/index.js", "test": "jest", "posttest": "yarn test:docs", "test:docs": "markdown-doctest", - "prepack": "tsc -b" + "build": "tsc -b" }, "repository": { "type": "git", @@ -52,5 +54,9 @@ ], "engines": { "node": ">=22" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/utils/tamedevil/package.json b/utils/tamedevil/package.json index 9e9321ab68..d462b8617f 100644 --- a/utils/tamedevil/package.json +++ b/utils/tamedevil/package.json @@ -5,11 +5,13 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prepack": "node ../../scripts/build-release.mts", + "build-package": "yarn build", "pretest": "node dist/index.js", "test": "jest", "posttest": "yarn test:docs", "test:docs": "markdown-doctest", - "prepack": "tsc -b" + "build": "tsc -b" }, "repository": { "type": "git", @@ -52,5 +54,9 @@ ], "engines": { "node": ">=22" + }, + "publishConfig": { + "directory": "release", + "access": "public" } } diff --git a/yarn.lock b/yarn.lock index c1aac5749b..31d1575004 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2807,7 +2807,7 @@ __metadata: tslib: "npm:^2.8.1" typescript: "npm:^5.9.3" peerDependencies: - grafast: "workspace:^" + grafast: "workspace:^1.0.0-rc.8" languageName: unknown linkType: soft @@ -2854,7 +2854,7 @@ __metadata: peerDependencies: "@dataplan/json": "workspace:^" grafast: "workspace:^" - graphile-config: "workspace:^" + graphile-config: "workspace:^1.0.0-rc.5" graphql: ^16.9.0 pg: ^8.7.1 pg-sql2: "workspace:^" @@ -3993,9 +3993,9 @@ __metadata: tslib: "npm:^2.8.1" typescript: "npm:^5.9.3" peerDependencies: - grafast: "workspace:^" - grafserv: "workspace:^" - graphile-config: "workspace:^" + grafast: "workspace:^1.0.0-rc.8" + grafserv: "workspace:^1.0.0-rc.6" + graphile-config: "workspace:^1.0.0-rc.5" graphql: ^16.9.0 peerDependenciesMeta: graphile-config: @@ -14614,7 +14614,6 @@ __metadata: chalk: "npm:^4.1.2" debug: "npm:^4.4.3" eventemitter3: "npm:^5.0.1" - graphile: "workspace:^" graphile-config: "workspace:^" graphql: "npm:^16.9.0" iterall: "npm:^1.3.0" @@ -14661,7 +14660,6 @@ __metadata: express: "npm:^4.21.2" fastify: "npm:^4.29.1 || ^5.0.0" grafast: "workspace:^" - graphile: "workspace:^" graphile-config: "workspace:^" graphql: "npm:^16.9.0" graphql-http: "npm:^1.22.4" @@ -14682,7 +14680,7 @@ __metadata: peerDependencies: "@envelop/core": ^5.0.0 "@whatwg-node/server": ^0.9.64 - grafast: "workspace:^" + grafast: "workspace:^1.0.0-rc.8" graphile-config: "workspace:^" graphql: ^16.9.0 h3: ^1.13.0 @@ -14744,14 +14742,14 @@ __metadata: typescript: "npm:^5.9.3" ws: "npm:^8.18.3" peerDependencies: - "@dataplan/pg": "workspace:^" - grafast: "workspace:^" - graphile-build: "workspace:^" - graphile-config: "workspace:^" + "@dataplan/pg": "workspace:^1.0.0-rc.7" + grafast: "workspace:^1.0.0-rc.8" + graphile-build: "workspace:^5.0.0-rc.5" + graphile-config: "workspace:^1.0.0-rc.5" graphql: ^16.9.0 pg: ^8.7.1 - pg-sql2: "workspace:^" - tamedevil: "workspace:^" + pg-sql2: "workspace:^5.0.0-rc.4" + tamedevil: "workspace:^0.1.0-rc.5" peerDependenciesMeta: pg: optional: true @@ -14783,8 +14781,8 @@ __metadata: tslib: "npm:^2.8.1" typescript: "npm:^5.9.3" peerDependencies: - grafast: "workspace:^" - graphile-config: "workspace:^" + grafast: "workspace:^1.0.0-rc.8" + graphile-config: "workspace:^1.0.0-rc.5" graphql: ^16.9.0 languageName: unknown linkType: soft @@ -14832,7 +14830,7 @@ __metadata: typescript: "npm:^5.9.3" peerDependencies: eslint: ^8.48.0 || ^9.26.0 - grafast: "workspace:^" + grafast: "workspace:^1.0.0-rc.8" pg-sql2: "workspace:^5.0.0-rc.4" peerDependenciesMeta: eslint: @@ -14858,26 +14856,26 @@ __metadata: jest-serializer-graphql-schema: "workspace:^" json5: "npm:^2.2.3" nodemon: "npm:^3.1.11" - postgraphile: "workspace:^" + pg-sql2: "workspace:^" tamedevil: "workspace:^" ts-node: "npm:^10.9.2" tslib: "npm:^2.8.1" typescript: "npm:^5.9.3" peerDependencies: - "@dataplan/pg": "workspace:^" - grafast: "workspace:^" - graphile-build: "workspace:^" - graphile-build-pg: "workspace:^" - graphile-config: "workspace:^" + "@dataplan/pg": "workspace:^1.0.0-rc.7" + grafast: "workspace:^1.0.0-rc.8" + graphile-build: "workspace:^5.0.0-rc.5" + graphile-build-pg: "workspace:^5.0.0-rc.7" + graphile-config: "workspace:^1.0.0-rc.5" graphql: ^16.9.0 - tamedevil: "workspace:^" + tamedevil: "workspace:^0.1.0-rc.5" peerDependenciesMeta: graphile-build-pg: optional: true languageName: unknown linkType: soft -"graphile@workspace:^, graphile@workspace:utils/graphile": +"graphile@workspace:utils/graphile": version: 0.0.0-use.local resolution: "graphile@workspace:utils/graphile" dependencies: @@ -14887,14 +14885,15 @@ __metadata: chalk: "npm:^4.1.2" graphile-config: "workspace:^" jest: "npm:^30.2.0" + postgraphile: "workspace:^" source-map-js: "npm:^1.2.1" ts-node: "npm:^10.9.2" tslib: "npm:^2.8.1" typescript: "npm:^5.9.3" peerDependencies: - graphile-build: "workspace:^" - graphile-config: "workspace:^" - postgraphile: "workspace:^" + graphile-build: "workspace:^5.0.0-rc.5" + graphile-config: "workspace:^1.0.0-rc.5" + postgraphile: "workspace:^5.0.0-rc.9" peerDependenciesMeta: graphile-build: optional: true @@ -21781,7 +21780,6 @@ __metadata: debug: "npm:^4.4.3" grafast: "workspace:^" grafserv: "workspace:^" - graphile: "workspace:^" graphile-build: "workspace:^" graphile-build-pg: "workspace:^" graphile-config: "workspace:^" @@ -23279,7 +23277,7 @@ __metadata: webpack-cli: "npm:^6.0.1" yargs: "npm:^17.7.2" peerDependencies: - graphile-config: "workspace:^" + graphile-config: "workspace:^1.0.0-rc.5" graphql: ^16.9.0 react: ^18 || ^19 react-dom: ^18 || ^19