From c01635ea30d51bd99cada28b5a93d9f472d78f6e Mon Sep 17 00:00:00 2001 From: anson Date: Wed, 24 Sep 2025 17:26:24 +0100 Subject: [PATCH 1/4] chore: sync constants version with lit-client --- package.json | 3 +- packages/constants/src/lib/version.ts | 3 +- scripts/sync-version.mjs | 69 +++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 scripts/sync-version.mjs diff --git a/package.json b/package.json index 542b86dea1..862c033c51 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,10 @@ "version": "0.0.1", "license": "MIT", "scripts": { + "sync-version": "node ./scripts/sync-version.mjs", "reset": "bun unlink-all && rimraf dist node_modules doc tmp yarn-error.log yarn.lock package-lock.json bun.lockb learn-debug.log tmp .nx lit-auth-storage pkp-tokens lit-auth-local ./e2e/dist ./e2e/node_modules", "go": "bun run build && bun link-all", - "build": "bun unlink-all && nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions && bun run prettier", + "build": "bun run sync-version && nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions && bun run prettier", "build:affected": "nx affected --target=build --exclude=wrapped-keys,wrapped-keys-lit-actions", "check-deps": "npx nx run-many --target=check-deps --exclude=wrapped-keys,wrapped-keys-lit-actions", "validate": "npm run check-deps && npm run build", diff --git a/packages/constants/src/lib/version.ts b/packages/constants/src/lib/version.ts index d8c01196cc..4a0e26633e 100644 --- a/packages/constants/src/lib/version.ts +++ b/packages/constants/src/lib/version.ts @@ -1 +1,2 @@ -export const version = '8.0.0-alpha.4'; +// This value is kept in sync with @lit-protocol/lit-client via scripts/sync-version.mjs, run by the build command. +export const version = '8.0.0'; diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs new file mode 100644 index 0000000000..1b8367fbd3 --- /dev/null +++ b/scripts/sync-version.mjs @@ -0,0 +1,69 @@ +#!/usr/bin/env node + +import { readFile, writeFile } from 'node:fs/promises'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +// Anchor paths relative to repo root so the script works from any cwd. +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); +const repoRoot = resolve(__dirname, '..'); + +// Matches the exported version constant in packages/constants/src/lib/version.ts. +const VERSION_EXPORT_PATTERN = /export const version = ['"]([^'\"]+)['"];?/; + +async function main() { + const litClientPackageJsonPath = resolve( + repoRoot, + 'packages', + 'lit-client', + 'package.json' + ); + const versionFilePath = resolve( + repoRoot, + 'packages', + 'constants', + 'src', + 'lib', + 'version.ts' + ); + + const litClientPackageJson = JSON.parse( + await readFile(litClientPackageJsonPath, 'utf8') + ); + const litClientVersion = litClientPackageJson.version; + + if (!litClientVersion) { + throw new Error(`Version not found in ${litClientPackageJsonPath}`); + } + + const versionFileContents = await readFile(versionFilePath, 'utf8'); + const match = versionFileContents.match(VERSION_EXPORT_PATTERN); + + if (!match) { + throw new Error( + `Could not find exported version constant in ${versionFilePath}` + ); + } + + const currentVersion = match[1]; + + if (currentVersion === litClientVersion) { + console.log(`version.ts already in sync (${currentVersion})`); + return; + } + + // Rewrite the version export so it mirrors the lit-client package version. + const updatedContents = versionFileContents.replace( + VERSION_EXPORT_PATTERN, + `export const version = '${litClientVersion}';` + ); + + await writeFile(versionFilePath, updatedContents); + console.log(`Updated version.ts to ${litClientVersion}`); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); From 1bf55921c64be8e337407100d98bc83913b8e6e3 Mon Sep 17 00:00:00 2001 From: Anson Date: Wed, 24 Sep 2025 17:38:04 +0100 Subject: [PATCH 2/4] Update scripts/sync-version.mjs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Anson --- scripts/sync-version.mjs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs index 1b8367fbd3..8586adf3cb 100644 --- a/scripts/sync-version.mjs +++ b/scripts/sync-version.mjs @@ -28,9 +28,16 @@ async function main() { 'version.ts' ); - const litClientPackageJson = JSON.parse( - await readFile(litClientPackageJsonPath, 'utf8') - ); + let litClientPackageJson; + try { + litClientPackageJson = JSON.parse( + await readFile(litClientPackageJsonPath, 'utf8') + ); + } catch (err) { + throw new Error( + `Failed to read or parse package.json at ${litClientPackageJsonPath}: ${err.message}` + ); + } const litClientVersion = litClientPackageJson.version; if (!litClientVersion) { From 9423f80309917a04a246ceb4fe2f80c9271dd469 Mon Sep 17 00:00:00 2001 From: Anson Date: Wed, 24 Sep 2025 17:38:14 +0100 Subject: [PATCH 3/4] Update scripts/sync-version.mjs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Anson --- scripts/sync-version.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs index 8586adf3cb..d8a96e65c1 100644 --- a/scripts/sync-version.mjs +++ b/scripts/sync-version.mjs @@ -44,7 +44,12 @@ async function main() { throw new Error(`Version not found in ${litClientPackageJsonPath}`); } - const versionFileContents = await readFile(versionFilePath, 'utf8'); + let versionFileContents; + try { + versionFileContents = await readFile(versionFilePath, 'utf8'); + } catch (err) { + throw new Error(`Failed to read version file at ${versionFilePath}: ${err.message}`); + } const match = versionFileContents.match(VERSION_EXPORT_PATTERN); if (!match) { From d5c716752ff31ba3b643486f666507ac4d965691 Mon Sep 17 00:00:00 2001 From: anson Date: Wed, 24 Sep 2025 17:44:04 +0100 Subject: [PATCH 4/4] fmt --- scripts/sync-version.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs index d8a96e65c1..f1175ca223 100644 --- a/scripts/sync-version.mjs +++ b/scripts/sync-version.mjs @@ -48,7 +48,9 @@ async function main() { try { versionFileContents = await readFile(versionFilePath, 'utf8'); } catch (err) { - throw new Error(`Failed to read version file at ${versionFilePath}: ${err.message}`); + throw new Error( + `Failed to read version file at ${versionFilePath}: ${err.message}` + ); } const match = versionFileContents.match(VERSION_EXPORT_PATTERN);