couchbase
Version:
The official Couchbase Node.js Client Library.
26 lines (19 loc) • 825 B
JavaScript
const fs = require('fs')
const path = require('path')
// 1. Define the paths relative to this script
const packageJsonPath = path.join(__dirname, '../package.json')
const versionTsPath = path.join(__dirname, '../lib/version.ts')
// 2. Read and parse package.json
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
const version = packageJson.version;
const name = packageJson.name;
// 3. Generate the TypeScript content
const tsContent = `// This file is auto-generated by scripts/updateVersion.js during the build process.
// DO NOT EDIT DIRECTLY.
export const SDK_VERSION = '${version}';
export const SDK_NAME = '${name}';
`;
// 4. Write it to the lib directory
fs.writeFileSync(versionTsPath, tsContent, 'utf8');
console.log(`[Build] Wrote ${name} v${version} to lib/version.ts`);