Skip to content

Commit

Permalink
Use the latest Theia version not 'latest' (#227)
Browse files Browse the repository at this point in the history
fixed #221

Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
  • Loading branch information
JonasHelming authored Oct 16, 2024
1 parent 81b072e commit bd09632
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
********************************************************************************/

const { spawn } = require('child_process');
import { execSync } from 'child_process';
import path = require('path');
import Base = require('yeoman-generator');
const request = require('request');
Expand Down Expand Up @@ -130,12 +131,12 @@ module.exports = class TheiaExtension extends Base {
description: 'The extension\'s Github URL',
type: String
});

const latestTheiaVersion = this.getLatestPackageVersion('@theia/core');
this.option('theia-version', {
alias: 't',
description: 'The version of Theia to use',
type: String,
default: 'latest'
default: latestTheiaVersion
});
this.option('lerna-version', {
description: 'The version of lerna to use',
Expand All @@ -155,6 +156,17 @@ module.exports = class TheiaExtension extends Base {
});
}

getLatestPackageVersion(packageName: string): string {
try {
// Run the npm command to get the latest version of the package
const result = execSync(`npm show ${packageName} version`, { encoding: 'utf-8' });
return result.trim();
} catch (error) {
console.error('Error fetching the latest package version:', error);
return 'latest';
}
}

path() {
this.sourceRoot(__dirname + '/../../templates');
}
Expand Down

0 comments on commit bd09632

Please # to comment.