main tracks PostgreSQL 18. The PostgreSQL 18 packages are the workspace packages themselves and are
published from the root with pnpm lerna publish (dist-tag latest).
pgsql-parser and pgsql-deparser are also published for PostgreSQL 13β17, each under its own npm
dist-tag (pg13 β¦ pg17). Those packages are generated from main on demand; nothing about them is
committed apart from the version numbers in config/versions.json.
Publishing a generated package must always pass --tag pgNN. Without it npm moves latest, which
has to stay on 18.
There is one deparser: the PostgreSQL 18 one in packages/deparser/src. The package for major N is
that deparser plus the AST transformers from packages/transform-ast that upgrade an N tree to an
18 tree:
PG N AST ββ PGNToPG18Transformer βββΆ PG 18 AST ββ Deparser (18) βββΆ SQL
npm run prepare-versions in packages/deparser runs these scripts in order:
| Script | What it does |
|---|---|
strip-transformer-types |
Copies transform-ast/src/transformers/vN-to-vN+1.ts (13β14 β¦ 17β18) into versions/, replacing the @pgsql/types version imports with any |
strip-direct-transformer-types |
Same for transform-ast/src/transformers-direct/vN-to-v18/index.ts, written to versions/direct/vN-to-v18.ts |
strip-deparser-types |
Copies packages/deparser/src into versions/N/src/deparser/ with the @pgsql/types imports replaced by any |
organize-transformers |
Moves each major's chain (vN-to-vN+1.ts β¦ v17-to-v18.ts) and its vN-to-v18-direct.ts into versions/N/src/ |
generate-version-deparsers |
Writes versions/N/src/index.ts: a Deparser that runs PGNToPG18Transformer and hands the result to the 18 deparser |
generate-packages |
Writes versions/N/package.json (version and @pgsql/types range from config/versions.json, @pgsql/quotes at the workspace version), tsconfigs, README, and versions/pnpm-workspace.yaml |
Every step exits non-zero if a source file is missing.
npm run prepare-versions in packages/parser (scripts/prepare-versions.ts) writes
versions/N/ for every major in config/versions.json except the workspace's own (18). Each
package is a thin re-export of three pinned dependencies taken from config/versions.json:
libpg-queryβ the parser for that majorpgsql-deparserβ the generated deparser for that major (exact version)@pgsql/typesβ the types for that major
Because of the exact pgsql-deparser pin, the deparser for a major must be on npm before the
parser for that major can be installed, built or published.
packages/deparser/versions and packages/parser/versions are gitignored and are their own pnpm
workspaces (each gets a pnpm-workspace.yaml). They are not part of the root workspace, so run
pnpm install inside versions/ after every prepare-versions.
One entry per major:
"17": {
"libpg-query": "17.8.3",
"pgsql-parser": "17.10.0",
"pgsql-deparser": "17.19.0",
"@pgsql/types": "17.6.2",
"npmTag": "pg17"
}pgsql-parser/pgsql-deparser: the version the next publish of that major will produce.libpg-query/@pgsql/types: what the generated packages pin. Both are published from other repositories.- The
18entry is not used for generation; 18 is versioned by lerna.
pnpm bump-versions (scripts/bump-versions.ts) edits this file interactively. For each major it
reads the major's dist-tag on npm for all four packages, then:
- sets
libpg-queryand@pgsql/typesto whatever thepgNNdist-tag points at (no prompt); - prompts for
pgsql-parserandpgsql-deparser:latest(when npm is ahead of the file),patch,minor,custom, orskip; - prints a summary and asks whether to save.
Choose skip for every major you are not publishing, and commit the result.
Example for 17; replace 17 / pg17 for another major.
-
Build the workspace and set the versions:
pnpm install pnpm build pnpm bump-versions
-
Generate, build and publish the deparser:
cd packages/deparser npm run prepare-versions cd versions pnpm install cd 17 npm run build cd dist npm publish --tag pg17
-
Generate, build and publish the parser (needs step 2 to be on npm):
cd packages/parser npm run prepare-versions cd versions pnpm install cd 17 npm run build cd dist npm publish --tag pg17
-
Check that only the
pgNNtag moved:npm view pgsql-deparser dist-tags npm view pgsql-parser dist-tags
pnpm install in packages/parser/versions resolves every generated major, so each
pgsql-deparser version listed in config/versions.json for 13β17 has to exist on npm at that
point.