Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ Every package supports these scripts:

Version configuration lives in `config/versions.json` — maps PG versions (13-17) to their `libpg-query`, `pgsql-parser`, `pgsql-deparser`, and `@pgsql/types` versions plus npm dist-tags.

`prepare-versions` writes into `packages/{parser,deparser}/versions/`, which is gitignored and
**not** part of the root pnpm workspace — each generated tree gets its own `pnpm-workspace.yaml`,
so run `pnpm install` inside `versions/` before building them (see `PUBLISH.md`). Adding those
directories back to the root `pnpm-workspace.yaml` makes the root `pnpm-lock.yaml` depend on
whether a machine has run the generator, which means every install rewrites it.

### CLI Development

| Package | Script | Description |
Expand Down
20 changes: 20 additions & 0 deletions PUBLISH.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ The `generate-packages` script (`scripts/generate-version-packages.ts`):
- Uses the template from `config/deparser-versions.json`
- Creates version-specific packages in `packages/deparser/versions/`
- Sets up proper dependencies and npm tags for each PostgreSQL version
- Writes a `pnpm-workspace.yaml` into `versions/`, making the generated tree its
own workspace (it is gitignored, so it is deliberately not part of the root one)

#### Install Dependencies
```bash
# Once per generation — covers every version directory
cd packages/deparser/versions
pnpm install
```

#### Build and Publish Individual Versions
```bash
Expand Down Expand Up @@ -106,6 +115,7 @@ cd packages/deparser

# Prepare all versions
npm run prepare-versions
(cd versions && pnpm install)

# Build and publish each version
for version in versions/*/; do
Expand All @@ -132,6 +142,15 @@ This script (`scripts/prepare-versions.ts`):
- Creates version-specific directories in `packages/parser/versions/`
- Generates `package.json`, `tsconfig.json`, and source files for each PostgreSQL version
- Each version gets its own libpg-query dependency and npm tag
- Writes a `pnpm-workspace.yaml` into `versions/`, making the generated tree its
own workspace (it is gitignored, so it is deliberately not part of the root one)

#### Install Dependencies
```bash
# Once per generation — covers every version directory
cd packages/parser/versions
pnpm install
```

#### Build and Publish Individual Versions
```bash
Expand All @@ -155,6 +174,7 @@ cd packages/parser

# Prepare all versions
npm run prepare-versions
(cd versions && pnpm install)

# Build and publish each version
for version in versions/*/; do
Expand Down
9 changes: 9 additions & 0 deletions packages/deparser/scripts/generate-version-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ function generateVersionPackages(): void {
console.log('Generating package.json files for each version...\n');

const { rootConfig, localConfig } = loadConfigs();

// The generated tree is gitignored, so it is its own pnpm workspace rather than
// a member of the root one: root membership would depend on whether this script
// has been run, and pnpm would rewrite the root lockfile accordingly.
fs.mkdirSync(VERSIONS_DIR, { recursive: true });
fs.writeFileSync(
path.join(VERSIONS_DIR, 'pnpm-workspace.yaml'),
"packages:\n - '*'\n"
);

for (const [pgVersion, versionInfo] of Object.entries(rootConfig.versions)) {
// Skip versions that don't have pgsql-deparser
Expand Down
8 changes: 8 additions & 0 deletions packages/parser/scripts/prepare-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ if (!fs.existsSync(versionsDir)) {
fs.mkdirSync(versionsDir, { recursive: true });
}

// The generated tree is gitignored, so it is its own pnpm workspace rather than
// a member of the root one: root membership would depend on whether this script
// has been run, and pnpm would rewrite the root lockfile accordingly.
fs.writeFileSync(
path.join(versionsDir, 'pnpm-workspace.yaml'),
"packages:\n - '*'\n"
);

// Generate version-specific packages
const pgVersions = Object.keys(rootConfig.versions);

Expand Down
Loading
Loading