File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 15
15
********************************************************************************/
16
16
17
17
const { spawn } = require ( 'child_process' ) ;
18
+ import { execSync } from 'child_process' ;
18
19
import path = require( 'path' ) ;
19
20
import Base = require( 'yeoman-generator' ) ;
20
21
const request = require ( 'request' ) ;
@@ -130,12 +131,12 @@ module.exports = class TheiaExtension extends Base {
130
131
description : 'The extension\'s Github URL' ,
131
132
type : String
132
133
} ) ;
133
-
134
+ const latestTheiaVersion = this . getLatestPackageVersion ( '@theia/core' ) ;
134
135
this . option ( 'theia-version' , {
135
136
alias : 't' ,
136
137
description : 'The version of Theia to use' ,
137
138
type : String ,
138
- default : 'latest'
139
+ default : latestTheiaVersion
139
140
} ) ;
140
141
this . option ( 'lerna-version' , {
141
142
description : 'The version of lerna to use' ,
@@ -155,6 +156,17 @@ module.exports = class TheiaExtension extends Base {
155
156
} ) ;
156
157
}
157
158
159
+ getLatestPackageVersion ( packageName : string ) : string {
160
+ try {
161
+ // Run the npm command to get the latest version of the package
162
+ const result = execSync ( `npm show ${ packageName } version` , { encoding : 'utf-8' } ) ;
163
+ return result . trim ( ) ;
164
+ } catch ( error ) {
165
+ console . error ( 'Error fetching the latest package version:' , error ) ;
166
+ return 'latest' ;
167
+ }
168
+ }
169
+
158
170
path ( ) {
159
171
this . sourceRoot ( __dirname + '/../../templates' ) ;
160
172
}
You can’t perform that action at this time.
0 commit comments