Skip to content

Commit bd09632

Browse files
authored
Use the latest Theia version not 'latest' (#227)
fixed #221 Signed-off-by: Jonas Helming <[email protected]>
1 parent 81b072e commit bd09632

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/app/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
********************************************************************************/
1616

1717
const { spawn } = require('child_process');
18+
import { execSync } from 'child_process';
1819
import path = require('path');
1920
import Base = require('yeoman-generator');
2021
const request = require('request');
@@ -130,12 +131,12 @@ module.exports = class TheiaExtension extends Base {
130131
description: 'The extension\'s Github URL',
131132
type: String
132133
});
133-
134+
const latestTheiaVersion = this.getLatestPackageVersion('@theia/core');
134135
this.option('theia-version', {
135136
alias: 't',
136137
description: 'The version of Theia to use',
137138
type: String,
138-
default: 'latest'
139+
default: latestTheiaVersion
139140
});
140141
this.option('lerna-version', {
141142
description: 'The version of lerna to use',
@@ -155,6 +156,17 @@ module.exports = class TheiaExtension extends Base {
155156
});
156157
}
157158

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+
158170
path() {
159171
this.sourceRoot(__dirname + '/../../templates');
160172
}

0 commit comments

Comments
 (0)