Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/constants/src/lib/version.ts
Original file line number Diff line number Diff line change
@@ -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';
69 changes: 69 additions & 0 deletions scripts/sync-version.mjs
Original file line number Diff line number Diff line change
@@ -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 = ['"]([^'\"]+)['"];?/;
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex character class [^'\"]+ contains an unescaped double quote inside the brackets, which could cause parsing issues. The double quote should be escaped: [^'\\\"]+

Suggested change
const VERSION_EXPORT_PATTERN = /export const version = ['"]([^'\"]+)['"];?/;
const VERSION_EXPORT_PATTERN = /export const version = ['"]([^'\\"]+)['"];?/;

Copilot uses AI. Check for mistakes.

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;
});
Loading