diff --git a/PUBLISH.md b/PUBLISH.md index deab377..95941a3 100644 --- a/PUBLISH.md +++ b/PUBLISH.md @@ -40,7 +40,7 @@ This interactive script will: - Ask if you want to skip the build step (useful if already built) - Always run tests (even if build is skipped) - Publish each selected version -- Optionally promote pg17 to latest (`latest` is currently pg18; to keep it there, answer no) +- If the highest major (pg18) was published, optionally promote it to `latest` ### Types Packages ```bash diff --git a/scripts/publish-single-version.js b/scripts/publish-single-version.js index 09de5d5..96b04b9 100644 --- a/scripts/publish-single-version.js +++ b/scripts/publish-single-version.js @@ -12,7 +12,8 @@ if (!fs.existsSync(pkgPath)) { process.exit(1); } -const original = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); +const originalText = fs.readFileSync(pkgPath, 'utf8'); +const original = JSON.parse(originalText); const publishMeta = original['x-publish'] || {}; const publishName = publishMeta.publishName || 'libpg-query'; @@ -48,7 +49,8 @@ try { console.log('āœ… Publish complete.'); } catch (err) { console.error('āŒ Publish failed:', err.message); + process.exitCode = 1; } finally { - fs.writeFileSync(pkgPath, JSON.stringify(original, null, 2)); + fs.writeFileSync(pkgPath, originalText); console.log('šŸ”„ Restored original package.json'); } diff --git a/scripts/publish-versions.js b/scripts/publish-versions.js index f9e08a8..9b3cd16 100755 --- a/scripts/publish-versions.js +++ b/scripts/publish-versions.js @@ -125,14 +125,15 @@ async function main() { } // Ask about promoting to latest - if (selectedVersions.includes('17')) { + const latestVersion = versionDirs[0]; + if (selectedVersions.includes(latestVersion)) { console.log('\nšŸ·ļø Tag Management'); - const promoteVersions = await question('Promote libpg-query@pg17 to latest? (y/N): '); + const promoteVersions = await question(`Promote libpg-query@pg${latestVersion} to latest? (y/N): `); if (promoteVersions.toLowerCase() === 'y') { try { - execSync('npm dist-tag add libpg-query@pg17 latest', { stdio: 'inherit' }); - console.log('āœ… libpg-query@pg17 promoted to latest'); + execSync(`npm dist-tag add libpg-query@pg${latestVersion} latest`, { stdio: 'inherit' }); + console.log(`āœ… libpg-query@pg${latestVersion} promoted to latest`); } catch (error) { console.error('āŒ Failed to promote tag:', error.message); } diff --git a/versions/17/README.md b/versions/17/README.md index 18715b2..a134682 100644 --- a/versions/17/README.md +++ b/versions/17/README.md @@ -59,7 +59,7 @@ Our latest is built with the `18-latest` branch from libpg_query | PG Major Version | libpg_query | npm dist-tag |--------------------------|-------------|---------| | 18 | 18.0.0 | [`pg18`](https://www.npmjs.com/package/libpg-query/v/pg18) -| 17 | 17-6.1.0 | [`pg17`](https://www.npmjs.com/package/libpg-query/v/latest) +| 17 | 17-6.1.0 | [`pg17`](https://www.npmjs.com/package/libpg-query/v/pg17) | 16 | 16-5.2.0 | [`pg16`](https://www.npmjs.com/package/libpg-query/v/pg16) | 15 | 15-4.2.4 | [`pg15`](https://www.npmjs.com/package/libpg-query/v/pg15) | 14 | 14-3.0.0 | [`pg14`](https://www.npmjs.com/package/libpg-query/v/pg14) @@ -89,7 +89,7 @@ const result = parseSync('SELECT * FROM users WHERE active = true'); // Returns: ParseResult - parsed query object ``` -⚠ **Note:** If you need additional functionality like `fingerprint`, `scan`, `deparse`, or `normalize`, check out the full package (`@libpg-query/parser`) in the [./full](https://github.com/constructive-io/libpg-query-node/tree/main/full) folder of the repo. +⚠ **Note:** This package only parses. For `fingerprint`, `normalize`, `scan` and `parsePlPgSQL`, upgrade to [`libpg-query@pg18`](https://www.npmjs.com/package/libpg-query/v/pg18). ### Initialization