Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update script #7550

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
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
23 changes: 8 additions & 15 deletions buildutils/src/upgrade-lab-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,23 @@ function absoluteVersion(version: string): string {
return version;
}

async function updatePyprojectToml(version: IVersion): Promise<void> {
const filePath = path.resolve('pyproject.toml');
const pattern = /(jupyterlab>=)[\d.]+(?:a|b|rc\d+)?,<[\d.]+/g;
updateVersionInFile(filePath, pattern, version);
}
const versionPattern = /(jupyterlab)>=[\d.]+(?:a|b|rc\d+)?,<[\d.]+/g;

async function updatePreCommitConfig(version: IVersion): Promise<void> {
const filePath = path.resolve('.pre-commit-config.yaml');
const pattern = /(jupyterlab)(?:>=|==)[\d.]+(?:,<[\d.]+)?(?="|,|\s|$)/;
updateVersionInFile(filePath, pattern, version);
}
const FILES_TO_UPDATE = ['pyproject.toml', '.pre-commit-config.yaml'];

async function upgradeLabDependencies(): Promise<void> {
const args: string[] = process.argv.slice(2);

if (args.length !== 2 || args[0] !== '--set-version') {
console.error('Usage: node script.js --set-version <version>');
process.exit(1);
if (args.length < 2) {
throw new Error('Please provide the set-version flag and version');
}

const version = parseVersion(args[1]);
await updatePackageJson(args[1]); // Keep original string version for package.json
await updatePyprojectToml(version);
await updatePreCommitConfig(version);

for (const file of FILES_TO_UPDATE) {
updateVersionInFile(path.resolve(file), versionPattern, version);
}
}

upgradeLabDependencies();
Loading