Skip to content

Commit 4d050f4

Browse files
authored
Merge pull request #333 from constructive-io/fix/generated-versions-workspace
fix(workspace): keep generated versions/* out of the root pnpm workspace
2 parents f21d3c6 + 90ac460 commit 4d050f4

6 files changed

Lines changed: 2835 additions & 5752 deletions

File tree

‎AGENTS.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ Every package supports these scripts:
106106

107107
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.
108108

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

111117
| Package | Script | Description |

‎PUBLISH.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ The `generate-packages` script (`scripts/generate-version-packages.ts`):
7575
- Uses the template from `config/deparser-versions.json`
7676
- Creates version-specific packages in `packages/deparser/versions/`
7777
- Sets up proper dependencies and npm tags for each PostgreSQL version
78+
- Writes a `pnpm-workspace.yaml` into `versions/`, making the generated tree its
79+
own workspace (it is gitignored, so it is deliberately not part of the root one)
80+
81+
#### Install Dependencies
82+
```bash
83+
# Once per generation — covers every version directory
84+
cd packages/deparser/versions
85+
pnpm install
86+
```
7887

7988
#### Build and Publish Individual Versions
8089
```bash
@@ -106,6 +115,7 @@ cd packages/deparser
106115

107116
# Prepare all versions
108117
npm run prepare-versions
118+
(cd versions && pnpm install)
109119

110120
# Build and publish each version
111121
for version in versions/*/; do
@@ -132,6 +142,15 @@ This script (`scripts/prepare-versions.ts`):
132142
- Creates version-specific directories in `packages/parser/versions/`
133143
- Generates `package.json`, `tsconfig.json`, and source files for each PostgreSQL version
134144
- Each version gets its own libpg-query dependency and npm tag
145+
- Writes a `pnpm-workspace.yaml` into `versions/`, making the generated tree its
146+
own workspace (it is gitignored, so it is deliberately not part of the root one)
147+
148+
#### Install Dependencies
149+
```bash
150+
# Once per generation — covers every version directory
151+
cd packages/parser/versions
152+
pnpm install
153+
```
135154

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

156175
# Prepare all versions
157176
npm run prepare-versions
177+
(cd versions && pnpm install)
158178

159179
# Build and publish each version
160180
for version in versions/*/; do

‎packages/deparser/scripts/generate-version-packages.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ function generateVersionPackages(): void {
9494
console.log('Generating package.json files for each version...\n');
9595

9696
const { rootConfig, localConfig } = loadConfigs();
97+
98+
// The generated tree is gitignored, so it is its own pnpm workspace rather than
99+
// a member of the root one: root membership would depend on whether this script
100+
// has been run, and pnpm would rewrite the root lockfile accordingly.
101+
fs.mkdirSync(VERSIONS_DIR, { recursive: true });
102+
fs.writeFileSync(
103+
path.join(VERSIONS_DIR, 'pnpm-workspace.yaml'),
104+
"packages:\n - '*'\n"
105+
);
97106

98107
for (const [pgVersion, versionInfo] of Object.entries(rootConfig.versions)) {
99108
// Skip versions that don't have pgsql-deparser

‎packages/parser/scripts/prepare-versions.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ if (!fs.existsSync(versionsDir)) {
1515
fs.mkdirSync(versionsDir, { recursive: true });
1616
}
1717

18+
// The generated tree is gitignored, so it is its own pnpm workspace rather than
19+
// a member of the root one: root membership would depend on whether this script
20+
// has been run, and pnpm would rewrite the root lockfile accordingly.
21+
fs.writeFileSync(
22+
path.join(versionsDir, 'pnpm-workspace.yaml'),
23+
"packages:\n - '*'\n"
24+
);
25+
1826
// Generate version-specific packages
1927
const pgVersions = Object.keys(rootConfig.versions);
2028

0 commit comments

Comments
 (0)