Skip to content

Commit 8760def

Browse files
authored
Fix update script (#7550)
* Fix script to update the lab version * fix
1 parent abd1b8c commit 8760def

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

buildutils/src/upgrade-lab-dependencies.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,23 @@ function absoluteVersion(version: string): string {
137137
return version;
138138
}
139139

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

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

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

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

160151
const version = parseVersion(args[1]);
161152
await updatePackageJson(args[1]); // Keep original string version for package.json
162-
await updatePyprojectToml(version);
163-
await updatePreCommitConfig(version);
153+
154+
for (const file of FILES_TO_UPDATE) {
155+
updateVersionInFile(path.resolve(file), versionPattern, version);
156+
}
164157
}
165158

166159
upgradeLabDependencies();

0 commit comments

Comments
 (0)