Files
sawyerhood__dev-browser/scripts/sync-version.js
Sawyer Hood 207ceea8d9 release: v0.2.1 (#58)
* docs: note Windows is not currently supported

* chore: align marketplace version with package.json

* docs: rewrite CHANGELOG with 0.2.0 as initial CLI release

* docs: remove zero startup cost from README features

* feat: add install-skill interactive command

* chore: add rustfmt and prettier with CI checks

* docs: simplify changelog

* docs: add _snapshotForAI to help output

* docs: expand LLM usage guide in help output

* feat: add --timeout flag for script execution

* feat: add snapshot helper for LLM-friendly page inspection

* docs: document snapshotForAI, remove custom snapshot helper

* docs: add approach guidance to LLM help

* release: v0.2.1
2026-03-19 15:49:16 -07:00

64 lines
2.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const projectRoot = join(__dirname, '..');
const cliDir = join(projectRoot, 'cli');
const marketplaceJsonPath = join(projectRoot, '.claude-plugin', 'marketplace.json');
const packageJson = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'));
const version = packageJson.version;
const cargoTomlPath = join(cliDir, 'Cargo.toml');
let cargoToml = readFileSync(cargoTomlPath, 'utf8');
const versionLine = `version = "${version}"`;
const versionPattern = /^version\s*=\s*"[^"]*"$/m;
if (!versionPattern.test(cargoToml)) {
console.error('Could not find the version field in cli/Cargo.toml.');
process.exit(1);
}
if (!cargoToml.includes(versionLine)) {
cargoToml = cargoToml.replace(versionPattern, versionLine);
writeFileSync(cargoTomlPath, cargoToml);
console.log(`Updated cli/Cargo.toml to version ${version}.`);
try {
execSync('cargo update -p dev-browser --offline', {
cwd: cliDir,
stdio: 'pipe',
});
console.log('Updated cli/Cargo.lock.');
} catch {
try {
execSync('cargo update -p dev-browser', {
cwd: cliDir,
stdio: 'pipe',
});
console.log('Updated cli/Cargo.lock.');
} catch (error) {
console.warn(`Warning: Could not update cli/Cargo.lock: ${error.message}`);
}
}
} else {
console.log(`cli/Cargo.toml already matches package.json version ${version}.`);
}
const marketplaceJson = JSON.parse(readFileSync(marketplaceJsonPath, 'utf8'));
if (!marketplaceJson.metadata) {
marketplaceJson.metadata = {};
}
if (marketplaceJson.metadata.version !== version) {
marketplaceJson.metadata.version = version;
writeFileSync(marketplaceJsonPath, `${JSON.stringify(marketplaceJson, null, 2)}\n`);
console.log(`Updated .claude-plugin/marketplace.json to version ${version}.`);
} else {
console.log(`.claude-plugin/marketplace.json already matches package.json version ${version}.`);
}