@@ -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 = / ( j u p y t e r l a b > = ) [ \d . ] + (?: a | b | r c \d + ) ? , < [ \d . ] + / g;
143- updateVersionInFile ( filePath , pattern , version ) ;
144- }
140+ const versionPattern = / ( j u p y t e r l a b ) > = [ \d . ] + (?: a | b | r c \d + ) ? , < [ \d . ] + / g;
145141
146- async function updatePreCommitConfig ( version : IVersion ) : Promise < void > {
147- const filePath = path . resolve ( '.pre-commit-config.yaml' ) ;
148- const pattern = / ( j u p y t e r l a b ) (?: > = | = = ) [ \d . ] + (?: , < [ \d . ] + ) ? (? = " | , | \s | $ ) / ;
149- updateVersionInFile ( filePath , pattern , version ) ;
150- }
142+ const FILES_TO_UPDATE = [ 'pyproject.toml' , '.pre-commit-config.yaml' ] ;
151143
152144async 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
166159upgradeLabDependencies ( ) ;
0 commit comments